
Tue, 06/06/2006 - 18:48
Hi,
I'm trying to use Extrema_ExtPC to compute the minimum distance between a wire and a point.
But the results returned by the algorithms are wrong.
Does somebody succeeded using this class ?
did I make a mistake somewhere ?
I'm using this algorithm to be able to compute points on the wire (with GCPnts package) between 2 points on the wire. It is the reason why I need the parameters of the points on the Adaptor curve.
If you have alternatives....
Thanks for the help.
Stephane
http://www.exotk.org
here is a code example :
//create a wire (a square)
TopoDS_Wire w = BRepBuilderAPI_MakePolygon(
gp_Pnt(0,0,0),
gp_Pnt(10,0,0),
gp_Pnt(10,10,0),
gp_Pnt(0,10,0),Standard_True);
//create an adaptor curve
BRepAdaptor_CompCurve pseudoCurve(w);
//get the parameters
Standard_Real f = pseudoCurve.FirstParameter();
Standard_Real l = pseudoCurve.LastParameter();
//f = 0.0 ; l = 4.0
//create 2 points to project on the wire
gp_Pnt P1(5,0,0);//for this one I'm expecting param = 0.5
gp_Pnt P2(0,5,0);//for this one, I'm expecting param = 3.5
gp_Pnt newP1,newP2;
Standard_Real newVal1,newVal2;
Extrema_ExtPC ext1(P1,pseudoCurve);
if ( ext1.IsDone() && ext1.NbExt() > 0 )
{
for ( Standard_Integer i = 1 ; i
{
if ( ext1.IsMin(i) )
{
newVal1 = ext1.Value(i);
newP1 = ext1.Point(i).Value();
//break;
}
}
}
Extrema_ExtPC ext2(P2,pseudoCurve);
if ( ext2.IsDone() && ext2.NbExt() > 0 )
{
for ( Standard_Integer i = 1 ; i
{
if ( ext2.IsMin(i) )
{
newVal2 = ext2.Value(i);
newP2 = ext2.Point(i).Value();
//break;
}
}
}
Tue, 06/06/2006 - 19:05
oops ! my mistake.
should be
newVal2 = ext2.Point(i).Parameter();
the Value() returns the distance between the wire and the point.
So, Extrema_ExtPC works fine with wires.
Stephane