]> SALOME platform Git repositories - modules/shaper.git/blobdiff - src/GeomAPI/GeomAPI_BSpline.cpp
Salome HOME
updated copyright message
[modules/shaper.git] / src / GeomAPI / GeomAPI_BSpline.cpp
index 6b4c0fe84e83fc96d812f7f3025633f4fbfedf4b..ac2e96899588cca4ea79deddcfda3bb092a8b410 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2019-2020  CEA/DEN, EDF R&D
+// Copyright (C) 2019-2023  CEA, EDF
 //
 // This library is free software; you can redistribute it and/or
 // modify it under the terms of the GNU Lesser General Public
 
 #define MY_BSPLINE (*(implPtr<Handle_Geom_BSplineCurve>()))
 
-GeomAPI_BSpline::GeomAPI_BSpline (const GeomCurvePtr& theCurve,
-                                  const bool isForced)
+GeomAPI_BSpline::GeomAPI_BSpline (const GeomCurvePtr& theCurve)
 {
   GeomCurvePtr anUntrimmedCurve = theCurve->basisCurve();
   Handle(Geom_Curve) aCurve = anUntrimmedCurve->impl<Handle(Geom_Curve)>();
   Handle(Geom_BSplineCurve) aBSpl = Handle(Geom_BSplineCurve)::DownCast(aCurve);
-  if (aBSpl.IsNull() && isForced) {
-    // convert to b-spline
-    aBSpl = GeomConvert::CurveToBSplineCurve(aCurve);
-  }
   if (aBSpl.IsNull())
     throw Standard_ConstructionError("GeomAPI_BSpline: Curve is not a B-spline");
   setImpl(new Handle_Geom_BSplineCurve(aBSpl));
@@ -83,3 +78,20 @@ bool GeomAPI_BSpline::isPeriodic() const
 {
   return MY_BSPLINE->IsPeriodic();
 }
+
+GeomBSplinePtr GeomAPI_BSpline::convertToBSpline (const GeomCurvePtr& theCurve)
+{
+  GeomCurvePtr anUntrimmedCurve = theCurve->basisCurve();
+  Handle(Geom_Curve) aCurve = anUntrimmedCurve->impl<Handle(Geom_Curve)>();
+  Handle(Geom_BSplineCurve) aBSpl = Handle(Geom_BSplineCurve)::DownCast(aCurve);
+  if (aBSpl.IsNull()) {
+    // convert to b-spline
+    aBSpl = GeomConvert::CurveToBSplineCurve(aCurve);
+  }
+  if (aBSpl.IsNull())
+    throw Standard_ConstructionError("GeomAPI_BSpline: Conversion to B-spline failed");
+  GeomCurvePtr aResCurve (new GeomAPI_Curve());
+  aResCurve->setImpl(new Handle_Geom_BSplineCurve(aBSpl));
+  GeomBSplinePtr aResult (new GeomAPI_BSpline(aResCurve));
+  return aResult;
+}