Minimum Distance between Shapes

Hi everybody,

I'm trying to find the minimum distance
between two shapes (actually between
two TopoDS_Shape).

What I'm doing is reported below:

146 for (ExA.Init((*pShapeA), TopAbs_FACE); ExA.More(); ExA.Next()){
147 faceOnA = TopoDS::Face(ExA.Current());
148 ExB.Clear();
149
150 for (ExB.Init((*pShapeB), TopAbs_FACE); ExB.More(); ExB.Next()){
151 faceOnB = TopoDS::Face(ExB.Current());
152
153 extremaSS.Init(BRep_Tool::Surface(faceOnB), BRep_Tool::Surface(faceOnA));
154
155 if(extremaSS.NbExtrema() == 0){
156 // cout 157 return -1;
158 }
159
160 Quantity_Length l = extremaSS.LowerDistance();
161
162 //
163 // Check the precision
164 //
165 if(Abs(l) 166 l = 0; // The distance is zero
167
168 if((l 169 result = l;
170
171 }

Where:

pShapeA and pShapeB are two pointers to the TopoDS_Shape instances.
ExA and ExB are TopExp_Explorer,
extremaSS is a ExtremaSurfaceSurface class type.

Basically I navigate the content of each shape
looking for TopoDS_Face elements.
For each of two TopoDS_Face (one belonging to pShapeA and
the other belonging to pShapeB) I convert them to Geom_Surface
in order to be able to use the class GeomAPI_ExtremaSurfaceSurface
to get the minimum distance in between them using the method LowerDistance.

Is that a correct way to find out the distance between two
shapes ?

Does somebody else known a better solution?

Thanks in advance.

Paolo.

Stephane Routelous's picture

use BRepExtrema_DistShapeShape

BRepExtrema_DistShapeShape have error's picture

BRepExtrema_DistShapeShape have error!