Hi Charles, my edges are indeed segments. From the link you gave me and some other sources (https://priithon.googlecode.com/hg/Priithon/usefulGeo.py) i coded some functions to calculate point to point distance and point to line distance, see http://pastebin.com/2Zm4rnV9 I'm going to replace the remaining BRepExtrema_DistShapeShape occurrences with these new functions on monday and see if it is faster.
My first approach was without pre-filtering, on my second approach (after your suggestion) i remembered my experience with KD-trees and used that. It is not very elegant since the mid points of the edges do not lie on the surface, but it is working now. Of course, there's always room for improvement! Regarding the possible memory leak: I'm going to test again next week and report on anything i find out. Hi Lie Pablo, i'm not sure if there is a misunderstanding. I want to assign mesh nodes to edges that are almost perpendicular to the mesh surface. The mesh in the image i sent is only for illustration purposes and has almost nothing to do with the distribution of the nodes in my real example which i am unfortunately not allowed to show. >From what you wrote, it seems you project points into a mesh. If i am wrong, please explain. Thanks for your help (both of you)! Have a nice weekend. -Uwe On 09/08/13 14:05, Charles Sharman wrote: > Hi Uwe, > > In pythonOCC an edge has an underlying geometry: straight line, parabola, > circle, ellipse, or spline, to name a few. By a segment, I meant a straight > line geometry bounded by two vertices. BRepExtrema_DistShapeShape is > written for arbitrary shapes. In the case of the distance between a vertex > and an edge, it works for edges of any geometry. If all you need is the > distance between a straight line and a vertex, BRepExtrema_DistShapeShape is > overkill, and it will be slower than a more specialized approach. So, are > your edges straight lines bounded by two vertices or something else (like a > spline)? If they're straight lines, I currently lack the time to create an > example. However, I'd simply be putting the formula at: > http://mathworld.wolfram.com/Point-LineDistance3-Dimensional.html into > python numpy. If you need help coding it up, let me know, and I can try to > help later next week. > > If I understand correctly, your current approach already pre-filters distant > edges with the midpoint/KDTree search, so my bounding box advice is > superfluous. > > If you're crashing for a small set of edges (<100k), I think > BRepExtrema_DistShapeShape has a memory leak. If that's the case, we need > to find whether it's a pythonOCC bug or an OCC bug and notify the > developers. > > If it is a leak, have you tried not destroying the > BRepExtrema_DistShapeShape instance every time in the loop as a workaround? > The pertinent lines in your example would look like this: > > b1 = BRepExtrema_DistShapeShape() > for k in pntDic: > for l in curveDic: > v = BRepBuilderAPI_MakeVertex(pntDic[k]) > b1.LoadS1(v.Vertex()) > b1.LoadS2(curveDic[l]) > b1.Perform() > dist = b1.Value() > > All that said, I don't understand Lie Pablo's response. Perhaps I'm missing > something, and I'm not really helping. > > - Charles > > > > _______________________________________________ > 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