1 // Copyright (C) 2019-2020 CEA/DEN, EDF R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 #include <GeomAPI_BSpline.h>
21 #include <GeomAPI_Pnt.h>
23 #include <Geom_BSplineCurve.hxx>
25 #define MY_BSPLINE (*(implPtr<Handle_Geom_BSplineCurve>()))
27 GeomAPI_BSpline::GeomAPI_BSpline(const GeomCurvePtr& theCurve)
29 GeomCurvePtr anUntrimmedCurve = theCurve->basisCurve();
30 Handle(Geom_Curve) aCurve = anUntrimmedCurve->impl<Handle(Geom_Curve)>();
31 Handle(Geom_BSplineCurve) aBSpl = Handle(Geom_BSplineCurve)::DownCast(aCurve);
33 throw Standard_ConstructionError("GeomAPI_BSpline: Curve is not a B-spline");
34 setImpl(new Handle_Geom_BSplineCurve(aBSpl));
37 int GeomAPI_BSpline::degree() const
39 return MY_BSPLINE->Degree();
42 std::list<GeomPointPtr> GeomAPI_BSpline::poles() const
44 const TColgp_Array1OfPnt& aBSplPoles = MY_BSPLINE->Poles();
46 std::list<GeomPointPtr> aPoles;
47 for (int anIndex = aBSplPoles.Lower(); anIndex <= aBSplPoles.Upper(); ++anIndex) {
48 const gp_Pnt& aPoint = aBSplPoles.Value(anIndex);
49 aPoles.push_back(GeomPointPtr(new GeomAPI_Pnt(aPoint.X(), aPoint.Y(), aPoint.Z())));
54 std::list<double> GeomAPI_BSpline::weights() const
56 std::list<double> aWeights;
57 const TColStd_Array1OfReal* aBSplWeights = MY_BSPLINE->Weights();
59 aWeights.assign(aBSplWeights->begin(), aBSplWeights->end());
63 std::list<double> GeomAPI_BSpline::knots() const
65 const TColStd_Array1OfReal& aBSplKnots = MY_BSPLINE->Knots();
66 return std::list<double>(aBSplKnots.begin(), aBSplKnots.end());
69 std::list<int> GeomAPI_BSpline::mults() const
71 const TColStd_Array1OfInteger& aBSplMults = MY_BSPLINE->Multiplicities();
72 return std::list<int>(aBSplMults.begin(), aBSplMults.end());
75 bool GeomAPI_BSpline::isPeriodic() const
77 return MY_BSPLINE->IsPeriodic();