+ else if (aType == POINT_CURVE_LENGTH) {
+ // RefCurve
+ Handle(GEOM_Function) aRefCurve = aPI.GetCurve();
+ if (aRefCurve.IsNull()) {
+ Standard_NullObject::Raise
+ ("Point On Curve creation aborted : curve object is null");
+ }
+ TopoDS_Shape aRefShape1 = aRefCurve->GetValue();
+ if (aRefShape1.ShapeType() != TopAbs_EDGE) {
+ Standard_TypeMismatch::Raise
+ ("Point On Curve creation aborted : curve shape is not an edge");
+ }
+ TopoDS_Edge aRefEdge = TopoDS::Edge(aRefShape1);
+ TopoDS_Vertex V1, V2;
+ TopExp::Vertices(aRefEdge, V1, V2, Standard_True);
+
+ // RefPoint
+ TopoDS_Vertex aRefVertex;
+ Handle(GEOM_Function) aRefPoint = aPI.GetRef();
+ if (aRefPoint.IsNull()) {
+ aRefVertex = V1;
+ }
+ else {
+ TopoDS_Shape aRefShape2 = aRefPoint->GetValue();
+ if (aRefShape2.ShapeType() != TopAbs_VERTEX) {
+ Standard_TypeMismatch::Raise
+ ("Point On Curve creation aborted : start point shape is not a vertex");
+ }
+ aRefVertex = TopoDS::Vertex(aRefShape2);
+ }
+ gp_Pnt aRefPnt = BRep_Tool::Pnt(aRefVertex);
+
+ // Length
+ Standard_Real aLength = aPI.GetLength();
+ //Standard_Real theCurveLength = IntTools::Length(aRefEdge);
+ //if (aLength > theCurveLength) {
+ // Standard_ConstructionError::Raise
+ // ("Point On Curve creation aborted : given length is greater than edges length");
+ //}
+
+ // Check orientation
+ Standard_Real UFirst, ULast;
+ Handle(Geom_Curve) EdgeCurve = BRep_Tool::Curve(aRefEdge, UFirst, ULast);
+ Handle(Geom_Curve) ReOrientedCurve = EdgeCurve;
+
+ Standard_Real dU = ULast - UFirst;
+ Standard_Real par1 = UFirst + 0.1 * dU;
+ Standard_Real par2 = ULast - 0.1 * dU;
+
+ gp_Pnt P1 = EdgeCurve->Value(par1);
+ gp_Pnt P2 = EdgeCurve->Value(par2);
+
+ if (aRefPnt.SquareDistance(P2) < aRefPnt.SquareDistance(P1)) {
+ ReOrientedCurve = EdgeCurve->Reversed();
+ UFirst = EdgeCurve->ReversedParameter(ULast);
+ }
+
+ // Get the point by length
+ GeomAdaptor_Curve AdapCurve = GeomAdaptor_Curve(ReOrientedCurve);
+ GCPnts_AbscissaPoint anAbsPnt (AdapCurve, aLength, UFirst);
+ Standard_Real aParam = anAbsPnt.Parameter();
+ aPnt = AdapCurve.Value(aParam);
+ }