diff --git a/src/Mod/Part/App/Geometry.cpp b/src/Mod/Part/App/Geometry.cpp index 9158d69e84..6ebcf01b0a 100644 --- a/src/Mod/Part/App/Geometry.cpp +++ b/src/Mod/Part/App/Geometry.cpp @@ -1394,6 +1394,22 @@ bool GeomBSplineCurve::join(const Handle(Geom_BSplineCurve)& spline) return true; } +void GeomBSplineCurve::interpolate(const std::vector& p, Standard_Boolean periodic) +{ + if (p.size() < 2) + Standard_ConstructionError::Raise(); + + double tol3d = Precision::Approximation(); + Handle(TColgp_HArray1OfPnt) pts = new TColgp_HArray1OfPnt(1, p.size()); + for (std::size_t i=0; iSetValue(i+1, p[i]); + } + + GeomAPI_Interpolate interpolate(pts, periodic, tol3d); + interpolate.Perform(); + this->myCurve = interpolate.Curve(); +} + void GeomBSplineCurve::interpolate(const std::vector& p, const std::vector& t) { diff --git a/src/Mod/Part/App/Geometry.h b/src/Mod/Part/App/Geometry.h index 3bc70703d0..033a36cedb 100644 --- a/src/Mod/Part/App/Geometry.h +++ b/src/Mod/Part/App/Geometry.h @@ -265,6 +265,10 @@ public: virtual ~GeomBSplineCurve(); virtual Geometry *copy(void) const; + /*! + * Interpolate a spline passing through the given points without tangency. + */ + void interpolate(const std::vector&, Standard_Boolean=Standard_False); /*! * Set the poles and tangents for the cubic Hermite spline */