how to create a object of the class of "BRepExtrema_DistShapeShape"

Recently I want to implement measuring the distance between two points( or vertexs).So I use the class of BRepExtrema_DistShapeShape.
I define a object of the class as the following :
TopoDS_Shape sh1,sh2;
BRepExtrema_DistShapeShape myDistShapeShape;
myDistShapeShape=new BRepExtrema_DistShapeShape(&sh1,&sh2);
As the result,there are some errors appearing:
1) D:\Developingsoftware\Opencascade5.1\samples\standard\mfc\VSTAR\VSTARDoc.cpp(351) : error C2512: 'BRepExtrema_DistShapeShape' : no appropriate default constructor available
2) D:\Developingsoftware\Opencascade5.1\samples\standard\mfc\VSTAR\VSTARDoc.cpp(352) : error C2664: '__thiscall BRepExtrema_DistShapeShape::BRepExtrema_DistShapeShape(const class TopoDS_Shape &,const class TopoDS_Shape &)' : cannot convert parameter 1 from 'class TopoDS_Shape *' to 'const class TopoDS_Shape &'
Reason: cannot convert from 'class TopoDS_Shape *' to 'const class TopoDS_Shape'
No constructor could take the source type, or constructor overload resolution was ambiguous

So I don't know how to construct the object of the class of BRepExtrema_DistShapeShape.so if you know ,plese tell me.Tanke you firstly. My Email:lhb_0531@163.com

Patrik Mueller's picture

Hi,

try this:

TopoDS_Shape sh1,sh2;
BRepExtrema_DistShapeShape myDistShapeShape;
myDistShapeShape=new BRepExtrema_DistShapeShape(sh1,sh2);

Greets,

Patrik

Francois Lauzon's picture

Hi,
I would suggest this instead:
TopoDS_Shape sh1,sh2;
BRepExtrema_DistShapeShape myDistShapeShape(sh1,sh2);

Francois.

Rob Bachrach's picture

If you are just looking for the distance between two vertexes
and not generic shapes, BRepExtrema_DistShapeShape is probably
overkill. You might consider:

Standard_Real dist = BRep_Tool::Pnt(v1).Distance(BRep_Tool::Pnt(v2));