In order to get the poles and knot vector of some faces, I first use "Extract Geometry" command to extract surfaces.
But now I need a mapping between edges of original model and edges of extracted geometry model.
My proposal is to first compare the length and vertices position of 2 edges, if they are same, we can say these two edges are same.
It's not difficult to compare the length of two edges, but if I need to compare the vertices of edges, I need to first know order the vertices and do the comparsion, which is quite time-consuming.
So I would like ask whether there are any other ways to find corresponding edge for extract and original geometry model.
Here in the following I list some useful commands for getting edge length
t1 = NXObjectManager::Get(tag);
double length = Edge1->GetLength()
Unless I am missing somethig I feel that it is unnecessary to use edges and vertices to get the face relations.
Assuming you can easily identify all faces that you wish to extract then simply cycle through these faces doing the extraction one face at a time (not all faces of a body) which then gives you the extracted face for each model face.
Thanks for you reply.
Up to now, I do extract the faces one by one as you said.
But in order to get the mapping information of edges, I think I should still do the length and vertices checking.
How do you think ?
I have never needed to do what you want. What I have needed was to determine edge loops. I think the general method should work for you.
Basically what I would do is use a distance function between two points. I have my own functions for using point3d object to get the distance.
Public Shared Function Distance(ByVal pnt1 As Point3d, ByVal pnt2 As Point3d) As Double Return Math.Sqrt((pnt1.X - pnt2.X) ^ 2 + (pnt1.Y - pnt2.Y) ^ 2 + (pnt1.Z - pnt2.Z) ^ 2) End Function
So basically I would compare similar points (say 0.1 parameter value along the edge) on model and extracted edges. The minimum distance (allowing for modelling tolerance error) case would result in the correct edges pair. Do not use vertices because this would give you two possible edges. If you do not use mid points then the edge direction is also known.
Thanks for your reply, Frank.
If I have not interpreted wrong,
You mean, I can first loop over each edge's loop, and then choose a parameter (for example, 0.1 ) in order to get a vertice for each edge among an edge's loop. Then if the distance between two vertices are small(Let's say 0.01). We can say they are one edge pair.
But in this case, we still need to check the edge sense first due to the reason that in parameter space, zero value may start either at one end of the edge or at the other end of the edge.
Would it be better if we only compare mid point so that we don't need to check edge sense?
Thanks a lot
Checking arclengths plus mid-points might be OK.
Of course, it's easy to invent cases where this algorithm won't work (where two edges have the same length and the same mid-point, even though they are not the same). But these cases are probably pretty rare, and it's probably OK to take the risk of an error (only you can decide that).
If you really want to be sure that two edges are the same, then you need to measure the maximum distance between them. This will be slow, and, in effect, you'll just be re-implementing the Deviation Checking function.
My original reason for suggesting you do not use the mid point is that for checking the direction I thought it would be enough to know the relevent 0 and 1 parameter values. If you find that this is not sufficiently positive then a further distance test for a pair of vertices would give the desired result.
I am sorry but I think using deviation checking would be slower and more difficul..
To quote your own work
Could the OP use the ufs.Modl.AskBoundingBox function on each edge and use a similar sorting routine?
I've found this extremely efficient even with large amounts of data.
My understanding re the originalquestion is that we have here a case of an extracted surface associated with (sitting on) a model face. We then have a list of edges for both model face and extracted face and what is required is (why I do not know) the relation of edges. If this is correct then simply checking a point on each model edge against all similar points on the extracted face edges and checking the distance would give a pair of edges (if the point is not a vertex) solution. The next question was to get the direction relationship. Now, again I do not know why, but it is possible to check the distances from the used points to the vertexes on the related edges. The equal distances would give the required relationships. This is why I suggested not using a centre point.
The starting position of this question was that the extracted face and model face is known. When this is not the case then the face bounding box approach is useful.
I was suggesting edge bounding boxes not face bounding boxes.
Option Strict Off Imports System Imports NXOpen Imports NXOpen.UF Imports NXOpen.Utilities Imports System.Data Imports System.Collections.Generic Module find_duplicates Dim ufs As UFSession = UFSession.GetUFSession() ' Explicit Activation ' This entry point is used to activate the application explicitly Dim theSession As Session = Session.GetSession() Dim workPart As Part = theSession.Parts.Work Dim theUfSession As UFSession = UFSession.GetUFSession() Dim lw As ListingWindow = theSession.ListingWindow Dim myModelingTolerance As Double Sub Main() Dim my_layers As Layer.LayerManager = workPart.Layers lw.Open() If IsNothing(theSession.Parts.Display) Then lw.WriteLine("Active part required, journal exiting") lw.Close() Exit Sub End If Dim sheetCount As Integer = 0 For Each obj As Body In workPart.Bodies If obj.IsSheetBody Then sheetCount += 1 'must have at least 2 sheet bodies to run a meaningful comparison If sheetCount >= 2 Then Exit For End If End If Next If sheetCount < 2 Then lw.WriteLine("Insufficient number of sheet bodies found, journal exiting") Exit Sub End If 'reset sheetCount variable sheetCount = 0 Dim markId1 As Session.UndoMarkId markId1 = theSession.SetUndoMark(Session.MarkVisibility.Visi
ble, "Identify duplicate sheet bodies") 'Optional: write output file with bounding box info that was used for preliminary comparison 'layer we will move duplicate sheets to Const dumpLayer As Integer = 255 'if any sheet bodies start out on the dumpLayer, move them to this layer Const holdingLayer As Integer = 251 Dim numMatches As Integer = 0 'time variables to record how long the operation took Dim startTime As DateTime = Now Dim endTime As DateTime Dim timeElapsed As TimeSpan thesession.listingwindow.open Dim faceTable As New DataTable("Face") faceTable.Columns.Add("ID", GetType(Integer)) faceTable.Columns.Add("Xmin", GetType(Double)) faceTable.Columns.Add("Ymin", GetType(Double)) faceTable.Columns.Add("Zmin", GetType(Double)) faceTable.Columns.Add("Xmax", GetType(Double)) faceTable.Columns.Add("Ymax", GetType(Double)) faceTable.Columns.Add("Zmax", GetType(Double)) Dim bbox(5) As Double Dim facePt(2) As Double Dim faceDir(2) As Double 'collect info on each face For Each obj As Body In workPart.Bodies If obj.IsSheetBody Then If not my_layers.GetState(obj.Layer) > 1 Then If obj.IsBlanked = false Then ' only check visible objects Dim myFace As Face = obj.GetFaces(0) If obj.Layer = dumpLayer Then obj.Layer = holdingLayer obj.RedisplayObject() End If sheetCount += 1 dim my_edges() as edge = myface.getedges for int as integer = 0 to my_edges.length-1 theUfSession.Modl.AskBoundingBox(my_edges(int).Tag , bbox) thesession.listingwindow.writeline( bbox(0)& " , "& bbox(1)& " , "& bbox(2)& " , "& bbox(3)& " , "& bbox(4)& " , "& bbox(5)) next End If End If End If Next end sub end module
As an alternative approach.
Not sure how the bounding box would work on a striaght line in const x y or z though.