BRepExtrema_ExtPF fails | bug?


I'm using BRepExtrema_ExtPF to find the closest point on a face from a given point.
Now, when I do so with a sphere, all works out just fine.
When I'm running the same code on a double curved surface, all points are located in the starting ( approx 0, 0 uv coords ) corner of the surface.
Which is more likely the maximum rather than minimum distance.

I've uploaded some screencaps to illustrate the problem:
When a surface is used ( only a single face ) all points are found in the lower left corner ( see surfac_detail.png )

The file I'm using is here:

Below you'll find the ( Python ) code, excuse me for the dialect.

Any ideas why this problem arises?
Seems like a bug to me?

Best regards,



sphere = utils.file_to_shape('c:\\Documents and Settings\\Administrator\\workspace\\foam_pavilion\\src\\test_srf_b.stp')
#_sphere = occ.BRepPrimAPI_MakeSphere(1000.)


topoExplorer = occ.TopExp_Explorer()
topoExplorer.Init(sphere, occ.TopAbs_FACE)
#topoExplorer.Init(sphere, occ.TopAbs_FACE)
tds = occ.TopoDS()
face = tds.Face(topoExplorer.Current())

mat = occ.Graphic3d_MaterialAspect(occ.Quantity_NOC_BLUEVIOLET)

for i in xrange(10):
vertex = occ.BRepBuilderAPI_MakeVertex( rnd_pnt() )
v = vertex.Vertex()
extr = occ.BRepExtrema_ExtPF(v, face)

print 'n extrema', extr.NbExt()

for i in range(1,extr.NbExt()+1):
print 'added sphere',n
sph = occ.BRepPrimAPI_MakeSphere( extr.Point(i), 50)
display.DisplayShape(sph.Shape(), mat)

jelle's picture

So far I've not been able to make any progress with this isse. ShapeAnalysis_Surface.Value returns the same location.
I'm very curious how to get a closest point on a trimmed surface, so far it seems that OCC has a hard time with this.

Cauchy Ding's picture

Hi jelle,

In your step file, there only exist one bspline surface, so I generated one point randomly. This point is not far away the surface(about 3000~4000 unit length away, the diagnoal length of the surface is about 30000), the extrema find about 6 points on the surface, five points is not we want, but the left one seems as the minimum distance point. If you insert one point at your step file, it's better for testing.

-Cauchy Ding