- // Unable to project - set the parameter of the closest boundary
- const TopoDS_Vertex& aV1 = TopoDS::Vertex(myDS->Shape(aPB2->Pave1().Index()));
- const TopoDS_Vertex& aV2 = TopoDS::Vertex(myDS->Shape(aPB2->Pave2().Index()));
- //
- gp_Pnt aP = BRep_Tool::Pnt(aV);
- gp_Pnt aP1 = BRep_Tool::Pnt(aV1);
- gp_Pnt aP2 = BRep_Tool::Pnt(aV2);
- //
- Standard_Real aDist1 = aP.SquareDistance(aP1);
- Standard_Real aDist2 = aP.SquareDistance(aP2);
- //
- aPave[i].SetParameter(aDist1 < aDist2 ? aPB2->Pave1().Parameter() : aPB2->Pave2().Parameter());
+ // Compute the parameter by projecting the point
+ const TopoDS_Vertex& aV = TopoDS::Vertex(myDS->Shape(nV));
+ const TopoDS_Edge& aEOr = TopoDS::Edge(myDS->Shape(nE));
+ Standard_Real aTOut, aDist;
+ Standard_Integer iErr = myContext->ComputeVE(aV, aEOr, aTOut, aDist, myFuzzyValue);
+ if (!iErr) {
+ aPave[i].SetParameter(aTOut);
+ }
+ else {
+ // Unable to project - set the parameter of the closest boundary
+ const TopoDS_Vertex& aV1 = TopoDS::Vertex(myDS->Shape(aPB2->Pave1().Index()));
+ const TopoDS_Vertex& aV2 = TopoDS::Vertex(myDS->Shape(aPB2->Pave2().Index()));
+ //
+ gp_Pnt aP = BRep_Tool::Pnt(aV);
+ gp_Pnt aP1 = BRep_Tool::Pnt(aV1);
+ gp_Pnt aP2 = BRep_Tool::Pnt(aV2);
+ //
+ Standard_Real aDist1 = aP.SquareDistance(aP1);
+ Standard_Real aDist2 = aP.SquareDistance(aP2);
+ //
+ aPave[i].SetParameter(aDist1 < aDist2 ? aPB2->Pave1().Parameter() : aPB2->Pave2().Parameter());
+ }