-// Copyright (C) 2014-2019 CEA/DEN, EDF R&D
+// Copyright (C) 2014-2024 CEA, EDF
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
#include <GeomAlgoAPI_EdgeBuilder.h>
#include <GeomAPI_Ax2.h>
+#include <GeomAPI_Ax3.h>
+#include <GeomAPI_BSpline2d.h>
#include <GeomAPI_Ellipse.h>
+#include <GeomAPI_Pnt2d.h>
#include <gp_Pln.hxx>
#include <BRepBuilderAPI_MakeEdge.hxx>
#include <TopoDS_Face.hxx>
#include <TopoDS.hxx>
#include <BRep_Tool.hxx>
-#include <Geom_BSplineCurve.hxx>
+#include <Geom2d_BSplineCurve.hxx>
#include <Geom_Plane.hxx>
#include <Geom_CylindricalSurface.hxx>
#include <Geom_RectangularTrimmedSurface.hxx>
+#include <GeomLib.hxx>
#include <gp_Ax2.hxx>
#include <gp_Circ.hxx>
return aRes;
}
-GeomEdgePtr GeomAlgoAPI_EdgeBuilder::bspline(const std::vector<GeomPointPtr>& thePoles,
- const std::vector<double>& theWeights,
- const bool thePeriodic)
+GeomEdgePtr GeomAlgoAPI_EdgeBuilder::bsplineOnPlane(
+ const std::shared_ptr<GeomAPI_Ax3>& thePlane,
+ const std::list<GeomPnt2dPtr>& thePoles,
+ const std::list<double>& theWeights,
+ const std::list<double>& theKnots,
+ const std::list<int>& theMults,
+ const int theDegree,
+ const bool thePeriodic)
{
- int aDegree = 3;
- if ((int)thePoles.size() <= aDegree)
- aDegree = (int)thePoles.size() - 1;
- if (aDegree <= 0)
- return GeomEdgePtr();
-
- int aNbKnots = (int)thePoles.size() - aDegree + 1;
-
- // collect arrays of poles, weights, knots and multiplicities
- TColgp_Array1OfPnt aPoles(1, (int)thePoles.size());
- TColStd_Array1OfReal aWeights(1, (int)theWeights.size());
- TColStd_Array1OfReal aKnots(1, aNbKnots);
- TColStd_Array1OfInteger aMults(1, aNbKnots);
-
- int anIndex = 1;
- for (std::vector<GeomPointPtr>::const_iterator aPIt = thePoles.begin();
- aPIt != thePoles.end(); ++aPIt, ++anIndex)
- aPoles.SetValue(anIndex, gp_Pnt((*aPIt)->x(), (*aPIt)->y(), (*aPIt)->z()));
- anIndex = 1;
- for (std::vector<double>::const_iterator aWIt = theWeights.begin();
- aWIt != theWeights.end(); ++aWIt, ++anIndex)
- aWeights.SetValue(anIndex, *aWIt);
- anIndex = 1;
- static const double aStartParam = 0.0;
- static const double aEndParam = 1.0;
- double aStep = aEndParam / (aNbKnots - 1);
- for (double aKnot = aStartParam; anIndex < aNbKnots; ++anIndex, aKnot += aStep)
- aKnots.SetValue(anIndex, aKnot);
- aKnots.ChangeLast() = aEndParam;
- anIndex = 1;
- aMults.SetValue(anIndex, aDegree + 1);
- for (++anIndex; anIndex < aNbKnots; ++anIndex)
- aMults.SetValue(anIndex, 1);
- aMults.SetValue(aNbKnots, aDegree + 1);
-
- Handle(Geom_BSplineCurve) aCurve =
- new Geom_BSplineCurve(aPoles, aWeights, aKnots, aMults, aDegree, thePeriodic);
-
- BRepBuilderAPI_MakeEdge anEdgeBuilder(aCurve, aStartParam, aEndParam);
+ std::shared_ptr<GeomAPI_BSpline2d> aBSplineCurve(
+ new GeomAPI_BSpline2d(theDegree, thePoles, theWeights, theKnots, theMults, thePeriodic));
+ return bsplineOnPlane(thePlane, aBSplineCurve);
+}
+
+GeomEdgePtr GeomAlgoAPI_EdgeBuilder::bsplineOnPlane(
+ const std::shared_ptr<GeomAPI_Ax3>& thePlane,
+ const std::shared_ptr<GeomAPI_BSpline2d>& theCurve)
+{
+ Handle(Geom_Curve) aCurve3D = GeomLib::To3d(thePlane->impl<gp_Ax3>().Ax2(),
+ theCurve->impl<Handle_Geom2d_BSplineCurve>());
+
+ BRepBuilderAPI_MakeEdge anEdgeBuilder(aCurve3D);
GeomEdgePtr aRes(new GeomAPI_Edge);
TopoDS_Edge anEdge = anEdgeBuilder.Edge();
aRes->setImpl(new TopoDS_Shape(anEdge));