I have done things like you are trying to do for very big meshes. But I didn't understand correctly what is your problem.
Does your problem is finding point (nodes) to curve distance? Or edge to edge distance? When you compare distances, a way to compute faster is to scape from sqrt. For example Slow way to compare the distance of a_point to a point-set: For each point in point_set; sqrt(dot(point-a_point,point-a_point) < distance; Faster way to compare the distance of a_point to a point-set: For each point in point_set; dot(point-a_point,point-a_point) < distance**2; Even faster way to compare the distance of a_point to a point-set: temp=distance**2; For each point in point_set; dot(point-a_point,point-a_point) < temp; Good luck Lie Pablo On 6 August 2013 13:21, Uwe Schlifkowitz <schlifkow...@intales.com> wrote: > Hi all, > > I am trying to find vertices that are near an edge within some kind of > tolerance. > > Imagine lots of short edges intersecting a surface. The edges are > parallel to the surface normal and evenly distributed over the surface. > The surface has a mesh and I have a dictionary of said edges and a > dictionary of mesh nodes (vertices). > > So what I'm trying to do is assign all nodes that are within ~3mm of an > edge to that edge. > > I used BRepExtrema_DistShapeShape which seems to do the job quite well > for small numbers of points and edges (600 points, 72 edges). > For larger numbers however, the process consumes all available memory > (16GB) and then hangs the machine. > > So my questions are: > * Is there a better way to achieve what i want? > * How can I reduce memory consumption? > > Unrelated question: why does the conversion from TopoDS_Vertex to gp_Pnt > fail when i write TopoDS_Vertex instead of TopoDS_vertex? What exactly > is the difference? If it's in the docs I must have missed it. > > > Thanks, > Uwe > > #--------------------------------------- > pntDic = {} # some dictionary of gp_Pnt > curveDic = {} # some dictionary of TopoDS_Edge > tol = 3 > curveToNode = {} > for k in pntDic: > for l in curveDic: > v = BRepBuilderAPI_MakeVertex(pntDic[k]) > dist = BRepExtrema_DistShapeShape(v.Vertex(), curveDic[l]) > if dist.Value() <= tol: > # assign curve to node > # get normalized edge direction > # get start and end vertex of edge > ex = TopExp_Explorer(curveDic[l], TopAbs_VERTEX) > > # no need for a loop since we know for a fact that > # the edge has only one start and one end > c = ex.Current() > cv = TopoDS_vertex(c) > v0 = BRep_Tool_Pnt(cv) > ex.Next() > c = ex.Current() > cv = TopoDS_vertex(c) > v1 = BRep_Tool_Pnt(cv) > dx = v1.X() - v0.X() > dy = v1.Y() - v0.Y() > dz = v1.Z() - v0.Z() > edgeScaling = sqrt(dx ** 2 + dy ** 2 + dz ** 2) > edgeDirection = [dx / edgeScaling, > dy / edgeScaling, > dz / edgeScaling] > curveToNode[k] = (l, edgeDirection) > del ex, v1, v0, dx, dy, dz, c, cv > del edgeScaling, edgeDirection > else: > pass > del v, dist > #--------------------------------------- > > > -- > INTALES GmbH Engineering Solutions > Uwe Schlifkowitz -- Software Engineer > Innsbrucker Str. 1, A-6161 Natters > Phone: +43 512 54611120 -- schlifkow...@intales.com > > _______________________________________________ > Pythonocc-users mailing list > Pythonocc-users@gna.org > https://mail.gna.org/listinfo/pythonocc-users >
_______________________________________________ Pythonocc-users mailing list Pythonocc-users@gna.org https://mail.gna.org/listinfo/pythonocc-users