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