From 51ab458dbd0ec66bc042f0496e19ba7c7d055092 Mon Sep 17 00:00:00 2001 From: Pasukhin Dmitry Date: Thu, 5 Mar 2026 10:35:15 +0000 Subject: [PATCH] Modeling Data - Introduce GeomAdaptor_TransformedCurve and unify Eval-based evaluation API (#1139) Add GeomAdaptor_TransformedCurve as a new base class for BRepAdaptor_Curve that wraps a GeomAdaptor_Curve (or Adaptor3d_CurveOnSurface) with an applied gp_Trsf transformation. This mirrors the existing GeomAdaptor_TransformedSurface pattern for curves. Refactor the adaptor evaluation API across Adaptor3d_Curve and Adaptor3d_Surface hierarchies so that EvalD0/D1/D2/D3/DN are the primary virtual evaluation methods: - Adaptor3d_Curve: Value, D0-DN become non-virtual inline wrappers delegating to EvalD*. Base EvalD* implementations now throw Standard_NotImplemented instead of calling D*. - Adaptor3d_Surface: same pattern applied symmetrically. - Adaptor3d_CurveOnSurface: removes Value/D0-DN overrides (inherited from base); adds EvalD0/D1/D2/D3/DN marked final with the full dispatch logic. - Adaptor3d_IsoCurve: removes Value/D0-DN overrides; adds EvalD* final with iso-curve projection logic (IsoU selects D1V/D2V/D3V, IsoV selects D1U/D2U/D3U). - GeomAdaptor_Curve: removes Value/D0-DN overrides (now inherited inline); EvalD* remain final with BSpline cache and analytical dispatch logic. - GeomAdaptor_Surface: removes Value/D0-DN overrides (now inherited inline); EvalD* remain final with BSpline cache and analytical dispatch logic. - GeomAdaptor_TransformedCurve: overrides EvalD* with transform-and-dispatch logic; no need to override Value/D0-DN (inherited from Adaptor3d_Curve). - GeomAdaptor_TransformedSurface: removes Value/D0-DN overrides (now inherited inline). - BRepAdaptor_Curve: refactored to inherit GeomAdaptor_TransformedCurve, removing all duplicated evaluation and geometry-extraction method implementations. - BRepAdaptor_CompCurve: removes Value/D0-DN overrides; adds EvalD* final with compound-curve parameter mapping and derivative scaling logic. - ProjLib_ProjectOnPlane: removes Value/D0-DN overrides; adds EvalD* final delegating to the projected result adaptor or the OnPlane_* free functions. - GeomFill_SnglrFunc: removes Value/D0-DN overrides; adds EvalD* final implementing the C'(t) x C''(t) singular function with ratio scaling. - ChFiDS_ElSpine: removes Value/D0-D3 overrides; adds EvalD0-D3 final delegating to the internal GeomAdaptor_Curve member. - BiTgte_CurveOnEdge: removes Value/D0-DN overrides; adds EvalD* final. - BiTgte_CurveOnVertex: removes Value/D0-DN overrides; adds EvalD* final (D1-DN throw Standard_NotImplemented as the curve represents a degenerate point). - HelixGeom_HelixCurve: removes Value/D0-D2/DN overrides; adds EvalD0/D1/D2/DN final with trigonometric helix evaluation. Add GTest coverage for GeomAdaptor_TransformedCurve: point/derivative evaluation with transformation, curve-on-surface path, GeomGridEval_Curve batch evaluation. --- .../TopoDSToStep_MakeStepEdge.cxx | 1 - .../TopoDSToStep_WireframeBuilder.cxx | 1 - .../TKFeat/LocOpe/LocOpe.cxx | 2 - .../TKFillet/ChFiDS/ChFiDS_ElSpine.cxx | 23 +- .../TKFillet/ChFiDS/ChFiDS_ElSpine.hxx | 18 +- .../GeomFill/GeomFill_SnglrFunc.cxx | 82 ++-- .../GeomFill/GeomFill_SnglrFunc.hxx | 42 +- .../HelixGeom/HelixGeom_HelixCurve.cxx | 78 ++-- .../HelixGeom/HelixGeom_HelixCurve.hxx | 20 +- .../BRepMesh_EdgeParameterProvider.hxx | 1 - .../BRepOffset_MakeSimpleOffset.cxx | 1 - .../TKOffset/BiTgte/BiTgte_CurveOnEdge.cxx | 27 +- .../TKOffset/BiTgte/BiTgte_CurveOnEdge.hxx | 42 +- .../TKOffset/BiTgte/BiTgte_CurveOnVertex.cxx | 18 +- .../TKOffset/BiTgte/BiTgte_CurveOnVertex.hxx | 41 +- .../BRepAdaptor/BRepAdaptor_CompCurve.cxx | 55 +-- .../BRepAdaptor/BRepAdaptor_CompCurve.hxx | 39 +- .../TKBRep/BRepAdaptor/BRepAdaptor_Curve.cxx | 442 +----------------- .../TKBRep/BRepAdaptor/BRepAdaptor_Curve.hxx | 152 +----- .../TKG3d/Adaptor3d/Adaptor3d_Curve.cxx | 77 +-- .../TKG3d/Adaptor3d/Adaptor3d_Curve.hxx | 34 +- .../Adaptor3d/Adaptor3d_CurveOnSurface.cxx | 197 ++++---- .../Adaptor3d/Adaptor3d_CurveOnSurface.hxx | 40 +- .../TKG3d/Adaptor3d/Adaptor3d_IsoCurve.cxx | 197 +++----- .../TKG3d/Adaptor3d/Adaptor3d_IsoCurve.hxx | 43 +- .../TKG3d/Adaptor3d/Adaptor3d_Surface.cxx | 110 +---- .../TKG3d/Adaptor3d/Adaptor3d_Surface.hxx | 86 ++-- src/ModelingData/TKG3d/GTests/FILES.cmake | 1 + .../GeomAdaptor_TransformedCurve_Test.cxx | 367 +++++++++++++++ src/ModelingData/TKG3d/Geom/Geom_Curve.cxx | 9 - src/ModelingData/TKG3d/Geom/Geom_Curve.hxx | 3 +- src/ModelingData/TKG3d/Geom/Geom_Surface.cxx | 9 - src/ModelingData/TKG3d/Geom/Geom_Surface.hxx | 4 +- .../TKG3d/GeomAdaptor/FILES.cmake | 2 + .../TKG3d/GeomAdaptor/GeomAdaptor_Curve.cxx | 53 --- .../TKG3d/GeomAdaptor/GeomAdaptor_Curve.hxx | 46 -- .../TKG3d/GeomAdaptor/GeomAdaptor_Surface.cxx | 85 ---- .../TKG3d/GeomAdaptor/GeomAdaptor_Surface.hxx | 65 --- .../GeomAdaptor_TransformedCurve.cxx | 270 +++++++++++ .../GeomAdaptor_TransformedCurve.hxx | 212 +++++++++ .../GeomAdaptor_TransformedSurface.cxx | 105 ++--- .../GeomAdaptor_TransformedSurface.hxx | 60 +-- .../ProjLib/ProjLib_ProjectOnPlane.cxx | 54 +-- .../ProjLib/ProjLib_ProjectOnPlane.hxx | 45 +- 44 files changed, 1427 insertions(+), 1832 deletions(-) create mode 100644 src/ModelingData/TKG3d/GTests/GeomAdaptor_TransformedCurve_Test.cxx create mode 100644 src/ModelingData/TKG3d/GeomAdaptor/GeomAdaptor_TransformedCurve.cxx create mode 100644 src/ModelingData/TKG3d/GeomAdaptor/GeomAdaptor_TransformedCurve.hxx diff --git a/src/DataExchange/TKDESTEP/TopoDSToStep/TopoDSToStep_MakeStepEdge.cxx b/src/DataExchange/TKDESTEP/TopoDSToStep/TopoDSToStep_MakeStepEdge.cxx index 1b021e19ca..9ad45f22f6 100644 --- a/src/DataExchange/TKDESTEP/TopoDSToStep/TopoDSToStep_MakeStepEdge.cxx +++ b/src/DataExchange/TKDESTEP/TopoDSToStep/TopoDSToStep_MakeStepEdge.cxx @@ -14,7 +14,6 @@ // Alternatively, this file may be used under the terms of Open CASCADE // commercial license or contractual agreement. -#include #include #include #include diff --git a/src/DataExchange/TKDESTEP/TopoDSToStep/TopoDSToStep_WireframeBuilder.cxx b/src/DataExchange/TKDESTEP/TopoDSToStep/TopoDSToStep_WireframeBuilder.cxx index fcf3e8316f..261ea8e800 100644 --- a/src/DataExchange/TKDESTEP/TopoDSToStep/TopoDSToStep_WireframeBuilder.cxx +++ b/src/DataExchange/TKDESTEP/TopoDSToStep/TopoDSToStep_WireframeBuilder.cxx @@ -17,7 +17,6 @@ // - fixed trimming of circles and ellipses (radians used instead of degrees) // szv#4 S4163 -#include #include #include #include diff --git a/src/ModelingAlgorithms/TKFeat/LocOpe/LocOpe.cxx b/src/ModelingAlgorithms/TKFeat/LocOpe/LocOpe.cxx index 1f6a20b409..9840841835 100644 --- a/src/ModelingAlgorithms/TKFeat/LocOpe/LocOpe.cxx +++ b/src/ModelingAlgorithms/TKFeat/LocOpe/LocOpe.cxx @@ -143,8 +143,6 @@ bool LocOpe::TgtFaces(const TopoDS_Edge& E, const TopoDS_Face& F1, const TopoDS_ HC2d->Initialize(e, F1); HC2d2->Initialize(e, F2); - // Adaptor3d_CurveOnSurface C1(HC2d,HS1); - bool rev1 = (F1.Orientation() == TopAbs_REVERSED); bool rev2 = (F2.Orientation() == TopAbs_REVERSED); double f, l, eps, angmin = M_PI, angmax = -M_PI, ang; diff --git a/src/ModelingAlgorithms/TKFillet/ChFiDS/ChFiDS_ElSpine.cxx b/src/ModelingAlgorithms/TKFillet/ChFiDS/ChFiDS_ElSpine.cxx index eb6508542e..f657be2454 100644 --- a/src/ModelingAlgorithms/TKFillet/ChFiDS/ChFiDS_ElSpine.cxx +++ b/src/ModelingAlgorithms/TKFillet/ChFiDS/ChFiDS_ElSpine.cxx @@ -169,37 +169,30 @@ double ChFiDS_ElSpine::Period() const //================================================================================================= -gp_Pnt ChFiDS_ElSpine::Value(const double AbsC) const +gp_Pnt ChFiDS_ElSpine::EvalD0(double theAbsC) const { - return curve.Value(AbsC); + return curve.EvalD0(theAbsC); } //================================================================================================= -void ChFiDS_ElSpine::D0(const double AbsC, gp_Pnt& P) const +Geom_Curve::ResD1 ChFiDS_ElSpine::EvalD1(double theAbsC) const { - curve.D0(AbsC, P); + return curve.EvalD1(theAbsC); } //================================================================================================= -void ChFiDS_ElSpine::D1(const double AbsC, gp_Pnt& P, gp_Vec& V1) const +Geom_Curve::ResD2 ChFiDS_ElSpine::EvalD2(double theAbsC) const { - curve.D1(AbsC, P, V1); + return curve.EvalD2(theAbsC); } //================================================================================================= -void ChFiDS_ElSpine::D2(const double AbsC, gp_Pnt& P, gp_Vec& V1, gp_Vec& V2) const +Geom_Curve::ResD3 ChFiDS_ElSpine::EvalD3(double theAbsC) const { - curve.D2(AbsC, P, V1, V2); -} - -//================================================================================================= - -void ChFiDS_ElSpine::D3(const double AbsC, gp_Pnt& P, gp_Vec& V1, gp_Vec& V2, gp_Vec& V3) const -{ - curve.D3(AbsC, P, V1, V2, V3); + return curve.EvalD3(theAbsC); } //================================================================================================= diff --git a/src/ModelingAlgorithms/TKFillet/ChFiDS/ChFiDS_ElSpine.hxx b/src/ModelingAlgorithms/TKFillet/ChFiDS/ChFiDS_ElSpine.hxx index d5715ad4d3..58159a266e 100644 --- a/src/ModelingAlgorithms/TKFillet/ChFiDS/ChFiDS_ElSpine.hxx +++ b/src/ModelingAlgorithms/TKFillet/ChFiDS/ChFiDS_ElSpine.hxx @@ -84,19 +84,17 @@ public: Standard_EXPORT double Period() const override; - Standard_EXPORT gp_Pnt Value(const double AbsC) const override; + //! Computes the point of parameter theAbsC on the curve. + [[nodiscard]] Standard_EXPORT gp_Pnt EvalD0(double theAbsC) const final; - Standard_EXPORT void D0(const double AbsC, gp_Pnt& P) const override; + //! Computes the point and first derivative at parameter theAbsC. + [[nodiscard]] Standard_EXPORT Geom_Curve::ResD1 EvalD1(double theAbsC) const final; - Standard_EXPORT void D1(const double AbsC, gp_Pnt& P, gp_Vec& V1) const override; + //! Computes the point and first two derivatives at parameter theAbsC. + [[nodiscard]] Standard_EXPORT Geom_Curve::ResD2 EvalD2(double theAbsC) const final; - Standard_EXPORT void D2(const double AbsC, gp_Pnt& P, gp_Vec& V1, gp_Vec& V2) const override; - - Standard_EXPORT void D3(const double AbsC, - gp_Pnt& P, - gp_Vec& V1, - gp_Vec& V2, - gp_Vec& V3) const override; + //! Computes the point and first three derivatives at parameter theAbsC. + [[nodiscard]] Standard_EXPORT Geom_Curve::ResD3 EvalD3(double theAbsC) const final; Standard_EXPORT void FirstParameter(const double P); diff --git a/src/ModelingAlgorithms/TKGeomAlgo/GeomFill/GeomFill_SnglrFunc.cxx b/src/ModelingAlgorithms/TKGeomAlgo/GeomFill/GeomFill_SnglrFunc.cxx index 8452401cc2..f50b7ab1ba 100644 --- a/src/ModelingAlgorithms/TKGeomAlgo/GeomFill/GeomFill_SnglrFunc.cxx +++ b/src/ModelingAlgorithms/TKGeomAlgo/GeomFill/GeomFill_SnglrFunc.cxx @@ -97,79 +97,51 @@ double GeomFill_SnglrFunc::Period() const return myHCurve->Period(); } -gp_Pnt GeomFill_SnglrFunc::Value(const double U) const +gp_Pnt GeomFill_SnglrFunc::EvalD0(double theU) const { - gp_Pnt C; - gp_Vec DC, D2C; - myHCurve->D2(U, C, DC, D2C); - DC *= ratio; - return gp_Pnt(DC.Crossed(D2C).XYZ()); + const Geom_Curve::ResD2 aRes = myHCurve->EvalD2(theU); + return gp_Pnt((aRes.D1 * ratio).Crossed(aRes.D2).XYZ()); } -void GeomFill_SnglrFunc::D0(const double U, gp_Pnt& P) const +Geom_Curve::ResD1 GeomFill_SnglrFunc::EvalD1(double theU) const { - gp_Pnt C; - gp_Vec DC, D2C; - myHCurve->D2(U, C, DC, D2C); - DC *= ratio; - P = gp_Pnt(DC.Crossed(D2C).XYZ()); + const Geom_Curve::ResD3 aRes = myHCurve->EvalD3(theU); + const gp_Vec aDC = aRes.D1 * ratio; + return {gp_Pnt(aDC.Crossed(aRes.D2).XYZ()), aDC.Crossed(aRes.D3)}; } -void GeomFill_SnglrFunc::D1(const double U, gp_Pnt& P, gp_Vec& V) const +Geom_Curve::ResD2 GeomFill_SnglrFunc::EvalD2(double theU) const { - gp_Pnt C; - gp_Vec DC, D2C, D3C; - myHCurve->D3(U, C, DC, D2C, D3C); - DC *= ratio; - P = gp_Pnt(DC.Crossed(D2C).XYZ()); - V = DC.Crossed(D3C); + const Geom_Curve::ResD3 aRes = myHCurve->EvalD3(theU); + const gp_Vec aD4 = myHCurve->EvalDN(theU, 4); + return {gp_Pnt((aRes.D1.Crossed(aRes.D2) * ratio).XYZ()), + aRes.D1.Crossed(aRes.D3) * ratio, + (aRes.D2.Crossed(aRes.D3) + aRes.D1.Crossed(aD4)) * ratio}; } -void GeomFill_SnglrFunc::D2(const double U, gp_Pnt& P, gp_Vec& V1, gp_Vec& V2) const +Geom_Curve::ResD3 GeomFill_SnglrFunc::EvalD3(double theU) const { - gp_Pnt C; - gp_Vec DC, D2C, D3C, D4C; - myHCurve->D3(U, C, DC, D2C, D3C); - P = gp_Pnt(DC.Crossed(D2C).XYZ()); - V1 = DC.Crossed(D3C); - D4C = myHCurve->DN(U, 4); - V2 = D2C.Crossed(D3C) + DC.Crossed(D4C); - - P.ChangeCoord() *= ratio; - V1 *= ratio; - V2 *= ratio; + const Geom_Curve::ResD3 aRes = myHCurve->EvalD3(theU); + const gp_Vec aD4 = myHCurve->EvalDN(theU, 4); + const gp_Vec aD5 = myHCurve->EvalDN(theU, 5); + return {gp_Pnt((aRes.D1.Crossed(aRes.D2) * ratio).XYZ()), + aRes.D1.Crossed(aRes.D3) * ratio, + (aRes.D2.Crossed(aRes.D3) + aRes.D1.Crossed(aD4)) * ratio, + (aRes.D1.Crossed(aD5) + aRes.D2.Crossed(aD4) * 2) * ratio}; } -void GeomFill_SnglrFunc::D3(const double U, gp_Pnt& P, gp_Vec& V1, gp_Vec& V2, gp_Vec& V3) const +gp_Vec GeomFill_SnglrFunc::EvalDN(double theU, int theN) const { - gp_Vec DC, D2C, D3C, D4C, D5C; - myHCurve->D3(U, P, DC, D2C, D3C); - D4C = myHCurve->DN(U, 4); - D5C = myHCurve->DN(U, 5); - P = gp_Pnt(DC.Crossed(D2C).XYZ()).ChangeCoord() * ratio; - V1 = DC.Crossed(D3C) * ratio; - V2 = (D2C.Crossed(D3C) + DC.Crossed(D4C)) * ratio; - V3 = (DC.Crossed(D5C) + D2C.Crossed(D4C) * 2) * ratio; -} + Standard_RangeError_Raise_if(theN < 1, "Exception: Geom2d_OffsetCurve::DN(). N<1."); -gp_Vec GeomFill_SnglrFunc::DN(const double U, const int N) const -{ - Standard_RangeError_Raise_if(N < 1, "Exception: Geom2d_OffsetCurve::DN(). N<1."); - - gp_Vec D1C, D2C, D3C; - gp_Pnt C; - - switch (N) + switch (theN) { case 1: - D1(U, C, D1C); - return D1C; + return EvalD1(theU).D1; case 2: - D2(U, C, D1C, D2C); - return D2C; + return EvalD2(theU).D2; case 3: - D3(U, C, D1C, D2C, D3C); - return D3C; + return EvalD3(theU).D3; default: throw Standard_NotImplemented("Exception: Derivative order is greater than 3. " "Cannot compute of derivative."); diff --git a/src/ModelingAlgorithms/TKGeomAlgo/GeomFill/GeomFill_SnglrFunc.hxx b/src/ModelingAlgorithms/TKGeomAlgo/GeomFill/GeomFill_SnglrFunc.hxx index 518498f18e..d96dc1a16e 100644 --- a/src/ModelingAlgorithms/TKGeomAlgo/GeomFill/GeomFill_SnglrFunc.hxx +++ b/src/ModelingAlgorithms/TKGeomAlgo/GeomFill/GeomFill_SnglrFunc.hxx @@ -59,42 +59,28 @@ public: Standard_EXPORT void Intervals(NCollection_Array1& T, const GeomAbs_Shape S) const override; - //! Computes the point of parameter U on the curve. - Standard_EXPORT gp_Pnt Value(const double U) const override; - Standard_EXPORT bool IsPeriodic() const override; Standard_EXPORT double Period() const override; - //! Computes the point of parameter U on the curve. - Standard_EXPORT void D0(const double U, gp_Pnt& P) const override; + //! Computes the point of parameter theU on the curve. + [[nodiscard]] Standard_EXPORT gp_Pnt EvalD0(double theU) const final; - //! Computes the point of parameter U on the curve with its - //! first derivative. - //! Raised if the continuity of the current interval - //! is not C1. - Standard_EXPORT void D1(const double U, gp_Pnt& P, gp_Vec& V) const override; + //! Computes the point of parameter theU on the curve with its first derivative. + //! Raised if the continuity of the current interval is not C1. + [[nodiscard]] Standard_EXPORT Geom_Curve::ResD1 EvalD1(double theU) const final; - //! Returns the point P of parameter U, the first and second - //! derivatives V1 and V2. - //! Raised if the continuity of the current interval - //! is not C2. - Standard_EXPORT void D2(const double U, gp_Pnt& P, gp_Vec& V1, gp_Vec& V2) const override; + //! Returns the point and the first and second derivatives at parameter theU. + //! Raised if the continuity of the current interval is not C2. + [[nodiscard]] Standard_EXPORT Geom_Curve::ResD2 EvalD2(double theU) const final; - //! Returns the point P of parameter U, the first, the second - //! and the third derivative. - //! Raised if the continuity of the current interval - //! is not C1. - Standard_EXPORT void D3(const double U, - gp_Pnt& P, - gp_Vec& V1, - gp_Vec& V2, - gp_Vec& V3) const override; + //! Returns the point and the first, second and third derivatives at parameter theU. + //! Raised if the continuity of the current interval is not C3. + [[nodiscard]] Standard_EXPORT Geom_Curve::ResD3 EvalD3(double theU) const final; - //! The returned vector gives the value of the derivative for the - //! order of derivation N. - //! Raised if N < 1. - Standard_EXPORT gp_Vec DN(const double U, const int N) const override; + //! Returns the derivative of order theN at parameter theU. + //! Raised if theN < 1. + [[nodiscard]] Standard_EXPORT gp_Vec EvalDN(double theU, int theN) const final; //! Returns the parametric resolution corresponding //! to the real space resolution . diff --git a/src/ModelingAlgorithms/TKHelix/HelixGeom/HelixGeom_HelixCurve.cxx b/src/ModelingAlgorithms/TKHelix/HelixGeom/HelixGeom_HelixCurve.cxx index de378332e4..a2ee65994c 100644 --- a/src/ModelingAlgorithms/TKHelix/HelixGeom/HelixGeom_HelixCurve.cxx +++ b/src/ModelingAlgorithms/TKHelix/HelixGeom/HelixGeom_HelixCurve.cxx @@ -13,6 +13,7 @@ #include +#include #include #include #include @@ -160,13 +161,13 @@ double HelixGeom_HelixCurve::Period() const //================================================================================================= -gp_Pnt HelixGeom_HelixCurve::Value(const double aT) const +gp_Pnt HelixGeom_HelixCurve::EvalD0(double theT) const { double aST, aCT, aX, aY, aZ, a1; // Calculate trigonometric values and radius - aCT = cos(aT); - aST = sin(aT); - a1 = myRStart + myC1 * myTgBeta * aT; + aCT = cos(theT); + aST = sin(theT); + a1 = myRStart + myC1 * myTgBeta * theT; // Calculate Cartesian coordinates aX = a1 * aCT; aY = a1 * aST; @@ -174,27 +175,20 @@ gp_Pnt HelixGeom_HelixCurve::Value(const double aT) const { aY = -aY; } - aZ = myC1 * aT; + aZ = myC1 * theT; return gp_Pnt(aX, aY, aZ); } //================================================================================================= -void HelixGeom_HelixCurve::D0(const double aT, gp_Pnt& aP) const -{ - aP = Value(aT); -} - -//================================================================================================= - -void HelixGeom_HelixCurve::D1(const double aT, gp_Pnt& aP, gp_Vec& aV1) const +Geom_Curve::ResD1 HelixGeom_HelixCurve::EvalD1(double theT) const { double aST, aCT, aX, aY, aZ, a1, a2; // Calculate point and first derivative - aCT = cos(aT); - aST = sin(aT); + aCT = cos(theT); + aST = sin(theT); // Calculate radius at parameter t - a1 = myRStart + myC1 * myTgBeta * aT; + a1 = myRStart + myC1 * myTgBeta * theT; // Calculate point coordinates aX = a1 * aCT; aY = a1 * aST; @@ -202,11 +196,11 @@ void HelixGeom_HelixCurve::D1(const double aT, gp_Pnt& aP, gp_Vec& aV1) const { aY = -aY; } - aZ = myC1 * aT; - aP.SetCoord(aX, aY, aZ); + aZ = myC1 * theT; + gp_Pnt aP(aX, aY, aZ); // Calculate first derivative coefficients a1 = myC1 * myTgBeta; - a2 = myRStart + a1 * aT; + a2 = myRStart + a1 * theT; // Calculate first derivative components aX = a1 * aCT - a2 * aST; aY = a1 * aST + a2 * aCT; @@ -215,19 +209,20 @@ void HelixGeom_HelixCurve::D1(const double aT, gp_Pnt& aP, gp_Vec& aV1) const aY = -aY; } aZ = myC1; - aV1.SetCoord(aX, aY, aZ); + gp_Vec aV1(aX, aY, aZ); + return {aP, aV1}; } //================================================================================================= -void HelixGeom_HelixCurve::D2(const double aT, gp_Pnt& aP, gp_Vec& aV1, gp_Vec& aV2) const +Geom_Curve::ResD2 HelixGeom_HelixCurve::EvalD2(double theT) const { double aST, aCT, aX, aY, aZ, a1, a2; // Calculate point, first and second derivatives - aCT = cos(aT); - aST = sin(aT); + aCT = cos(theT); + aST = sin(theT); // Calculate radius at parameter t - a1 = myRStart + myC1 * myTgBeta * aT; + a1 = myRStart + myC1 * myTgBeta * theT; // Calculate point coordinates aX = a1 * aCT; aY = a1 * aST; @@ -235,11 +230,11 @@ void HelixGeom_HelixCurve::D2(const double aT, gp_Pnt& aP, gp_Vec& aV1, gp_Vec& { aY = -aY; } - aZ = myC1 * aT; - aP.SetCoord(aX, aY, aZ); + aZ = myC1 * theT; + gp_Pnt aP(aX, aY, aZ); // Calculate first derivative coefficients a1 = myC1 * myTgBeta; - a2 = myRStart + a1 * aT; + a2 = myRStart + a1 * theT; // Calculate first derivative components aX = a1 * aCT - a2 * aST; aY = a1 * aST + a2 * aCT; @@ -248,7 +243,7 @@ void HelixGeom_HelixCurve::D2(const double aT, gp_Pnt& aP, gp_Vec& aV1, gp_Vec& aY = -aY; } aZ = myC1; - aV1.SetCoord(aX, aY, aZ); + gp_Vec aV1(aX, aY, aZ); // Calculate second derivative a1 = 2. * a1; aX = -a2 * aCT - a1 * aST; @@ -258,27 +253,28 @@ void HelixGeom_HelixCurve::D2(const double aT, gp_Pnt& aP, gp_Vec& aV1, gp_Vec& aY = -aY; } aZ = 0.; - aV2.SetCoord(aX, aY, aZ); + gp_Vec aV2(aX, aY, aZ); + return {aP, aV1, aV2}; } //================================================================================================= -gp_Vec HelixGeom_HelixCurve::DN(const double aT, const int aN) const +gp_Vec HelixGeom_HelixCurve::EvalDN(double theT, int theN) const { - gp_Pnt aP; - gp_Vec aV1, aV2; // Compute derivative based on order - switch (aN) + switch (theN) { - case 1: - D1(aT, aP, aV1); - break; - case 2: - D2(aT, aP, aV1, aV2); - break; + case 1: { + const Geom_Curve::ResD1 aRes = EvalD1(theT); + return aRes.D1; + } + case 2: { + const Geom_Curve::ResD2 aRes = EvalD2(theT); + return aRes.D2; + } default: - throw Standard_NotImplemented("HelixGeom_HelixCurve::DN"); + throw Standard_NotImplemented("HelixGeom_HelixCurve::EvalDN"); break; } - return (aN == 1) ? aV1 : aV2; + return gp_Vec(); } diff --git a/src/ModelingAlgorithms/TKHelix/HelixGeom/HelixGeom_HelixCurve.hxx b/src/ModelingAlgorithms/TKHelix/HelixGeom/HelixGeom_HelixCurve.hxx index 819bed8f3a..7cac183eba 100644 --- a/src/ModelingAlgorithms/TKHelix/HelixGeom/HelixGeom_HelixCurve.hxx +++ b/src/ModelingAlgorithms/TKHelix/HelixGeom/HelixGeom_HelixCurve.hxx @@ -15,6 +15,7 @@ #define _HelixGeom_HelixCurve_HeaderFile #include +#include #include class gp_Pnt; @@ -80,20 +81,17 @@ public: //! Returns 2*PI Standard_EXPORT double Period() const override; - //! Gets curve point for parameter U - Standard_EXPORT gp_Pnt Value(const double U) const override; + //! Computes the point of parameter theU on the curve. + [[nodiscard]] Standard_EXPORT gp_Pnt EvalD0(double theU) const final; - //! Gets curve point for parameter U - Standard_EXPORT void D0(const double U, gp_Pnt& P) const override; + //! Computes the point and first derivative at parameter theU. + [[nodiscard]] Standard_EXPORT Geom_Curve::ResD1 EvalD1(double theU) const final; - //! Gets curve point and first derivatives for parameter U - Standard_EXPORT void D1(const double U, gp_Pnt& P, gp_Vec& V1) const override; + //! Computes the point and first two derivatives at parameter theU. + [[nodiscard]] Standard_EXPORT Geom_Curve::ResD2 EvalD2(double theU) const final; - //! Gets curve point, first and second derivatives for parameter U - Standard_EXPORT void D2(const double U, gp_Pnt& P, gp_Vec& V1, gp_Vec& V2) const override; - - //! Gets curve derivative of demanded order for parameter U - Standard_EXPORT gp_Vec DN(const double U, const int N) const override; + //! Returns the derivative of order theN at parameter theU. + [[nodiscard]] Standard_EXPORT gp_Vec EvalDN(double theU, int theN) const final; protected: double myFirst; diff --git a/src/ModelingAlgorithms/TKMesh/BRepMesh/BRepMesh_EdgeParameterProvider.hxx b/src/ModelingAlgorithms/TKMesh/BRepMesh/BRepMesh_EdgeParameterProvider.hxx index 1e6cd7ba46..9b11675ba3 100644 --- a/src/ModelingAlgorithms/TKMesh/BRepMesh/BRepMesh_EdgeParameterProvider.hxx +++ b/src/ModelingAlgorithms/TKMesh/BRepMesh/BRepMesh_EdgeParameterProvider.hxx @@ -24,7 +24,6 @@ #include #include #include -#include #include class gp_Pnt; diff --git a/src/ModelingAlgorithms/TKOffset/BRepOffset/BRepOffset_MakeSimpleOffset.cxx b/src/ModelingAlgorithms/TKOffset/BRepOffset/BRepOffset_MakeSimpleOffset.cxx index c68ac43f8a..a24ead1995 100644 --- a/src/ModelingAlgorithms/TKOffset/BRepOffset/BRepOffset_MakeSimpleOffset.cxx +++ b/src/ModelingAlgorithms/TKOffset/BRepOffset/BRepOffset_MakeSimpleOffset.cxx @@ -17,7 +17,6 @@ // Include self. #include -#include #include #include #include diff --git a/src/ModelingAlgorithms/TKOffset/BiTgte/BiTgte_CurveOnEdge.cxx b/src/ModelingAlgorithms/TKOffset/BiTgte/BiTgte_CurveOnEdge.cxx index 2246909077..488f7e67df 100644 --- a/src/ModelingAlgorithms/TKOffset/BiTgte/BiTgte_CurveOnEdge.cxx +++ b/src/ModelingAlgorithms/TKOffset/BiTgte/BiTgte_CurveOnEdge.cxx @@ -168,47 +168,38 @@ double BiTgte_CurveOnEdge::Period() const //================================================================================================= -gp_Pnt BiTgte_CurveOnEdge::Value(const double U) const +gp_Pnt BiTgte_CurveOnEdge::EvalD0(double theU) const { - gp_Pnt P; - D0(U, P); - return P; + GeomAPI_ProjectPointOnCurve aProjector; + gp_Pnt aP = myConF->Value(theU); + aProjector.Init(aP, myCurv); + return aProjector.NearestPoint(); } //================================================================================================= -void BiTgte_CurveOnEdge::D0(const double U, gp_Pnt& P) const -{ - GeomAPI_ProjectPointOnCurve Projector; - P = myConF->Value(U); - Projector.Init(P, myCurv); - P = Projector.NearestPoint(); -} - -//================================================================================================= - -void BiTgte_CurveOnEdge::D1(const double, gp_Pnt&, gp_Vec&) const +Geom_Curve::ResD1 BiTgte_CurveOnEdge::EvalD1(double) const { throw Standard_NotImplemented("BiTgte_CurveOnEdge"); } //================================================================================================= -void BiTgte_CurveOnEdge::D2(const double, gp_Pnt&, gp_Vec&, gp_Vec&) const +Geom_Curve::ResD2 BiTgte_CurveOnEdge::EvalD2(double) const { throw Standard_NotImplemented("BiTgte_CurveOnEdge"); } //================================================================================================= -void BiTgte_CurveOnEdge::D3(const double, gp_Pnt&, gp_Vec&, gp_Vec&, gp_Vec&) const +Geom_Curve::ResD3 BiTgte_CurveOnEdge::EvalD3(double) const { throw Standard_NotImplemented("BiTgte_CurveOnEdge"); } //================================================================================================= -gp_Vec BiTgte_CurveOnEdge::DN(const double, const int) const +gp_Vec BiTgte_CurveOnEdge::EvalDN(double, int) const { throw Standard_NotImplemented("BiTgte_CurveOnEdge"); } diff --git a/src/ModelingAlgorithms/TKOffset/BiTgte/BiTgte_CurveOnEdge.hxx b/src/ModelingAlgorithms/TKOffset/BiTgte/BiTgte_CurveOnEdge.hxx index 4a2ac5abc6..c50695c78c 100644 --- a/src/ModelingAlgorithms/TKOffset/BiTgte/BiTgte_CurveOnEdge.hxx +++ b/src/ModelingAlgorithms/TKOffset/BiTgte/BiTgte_CurveOnEdge.hxx @@ -28,7 +28,7 @@ #include #include #include -class Geom_Curve; +#include class gp_Pnt; class gp_Vec; class gp_Lin; @@ -85,40 +85,20 @@ public: Standard_EXPORT double Period() const override; - //! Computes the point of parameter U on the curve. - Standard_EXPORT gp_Pnt Value(const double U) const override; + //! Computes the point of parameter theU on the curve. + [[nodiscard]] Standard_EXPORT gp_Pnt EvalD0(double theU) const final; - //! Computes the point of parameter U on the curve. - Standard_EXPORT void D0(const double U, gp_Pnt& P) const override; + //! Computes the point and first derivative at parameter theU. + [[nodiscard]] Standard_EXPORT Geom_Curve::ResD1 EvalD1(double theU) const final; - //! Computes the point of parameter U on the curve with its - //! first derivative. - //! Raised if the continuity of the current interval - //! is not C1. - Standard_EXPORT void D1(const double U, gp_Pnt& P, gp_Vec& V) const override; + //! Computes the point and first two derivatives at parameter theU. + [[nodiscard]] Standard_EXPORT Geom_Curve::ResD2 EvalD2(double theU) const final; - //! Returns the point P of parameter U, the first and second - //! derivatives V1 and V2. - //! Raised if the continuity of the current interval - //! is not C2. - Standard_EXPORT void D2(const double U, gp_Pnt& P, gp_Vec& V1, gp_Vec& V2) const override; + //! Computes the point and first three derivatives at parameter theU. + [[nodiscard]] Standard_EXPORT Geom_Curve::ResD3 EvalD3(double theU) const final; - //! Returns the point P of parameter U, the first, the second - //! and the third derivative. - //! Raised if the continuity of the current interval - //! is not C3. - Standard_EXPORT void D3(const double U, - gp_Pnt& P, - gp_Vec& V1, - gp_Vec& V2, - gp_Vec& V3) const override; - - //! The returned vector gives the value of the derivative for the - //! order of derivation N. - //! Raised if the continuity of the current interval - //! is not CN. - //! Raised if N < 1. - Standard_EXPORT gp_Vec DN(const double U, const int N) const override; + //! Returns the derivative of order theN at parameter theU. + [[nodiscard]] Standard_EXPORT gp_Vec EvalDN(double theU, int theN) const final; //! Returns the parametric resolution corresponding //! to the real space resolution . diff --git a/src/ModelingAlgorithms/TKOffset/BiTgte/BiTgte_CurveOnVertex.cxx b/src/ModelingAlgorithms/TKOffset/BiTgte/BiTgte_CurveOnVertex.cxx index a61c6010ea..3d301cc5c9 100644 --- a/src/ModelingAlgorithms/TKOffset/BiTgte/BiTgte_CurveOnVertex.cxx +++ b/src/ModelingAlgorithms/TKOffset/BiTgte/BiTgte_CurveOnVertex.cxx @@ -20,6 +20,7 @@ #include #include #include +#include #include #include #include @@ -127,42 +128,35 @@ double BiTgte_CurveOnVertex::Period() const //================================================================================================= -gp_Pnt BiTgte_CurveOnVertex::Value(const double) const +gp_Pnt BiTgte_CurveOnVertex::EvalD0(double) const { return myPnt; } //================================================================================================= -void BiTgte_CurveOnVertex::D0(const double /*U*/, gp_Pnt& P) const -{ - P = myPnt; -} - -//================================================================================================= - -void BiTgte_CurveOnVertex::D1(const double, gp_Pnt&, gp_Vec&) const +Geom_Curve::ResD1 BiTgte_CurveOnVertex::EvalD1(double) const { throw Standard_NotImplemented("BiTgte_CurveOnVertex"); } //================================================================================================= -void BiTgte_CurveOnVertex::D2(const double, gp_Pnt&, gp_Vec&, gp_Vec&) const +Geom_Curve::ResD2 BiTgte_CurveOnVertex::EvalD2(double) const { throw Standard_NotImplemented("BiTgte_CurveOnVertex"); } //================================================================================================= -void BiTgte_CurveOnVertex::D3(const double, gp_Pnt&, gp_Vec&, gp_Vec&, gp_Vec&) const +Geom_Curve::ResD3 BiTgte_CurveOnVertex::EvalD3(double) const { throw Standard_NotImplemented("BiTgte_CurveOnVertex"); } //================================================================================================= -gp_Vec BiTgte_CurveOnVertex::DN(const double, const int) const +gp_Vec BiTgte_CurveOnVertex::EvalDN(double, int) const { throw Standard_NotImplemented("BiTgte_CurveOnVertex"); } diff --git a/src/ModelingAlgorithms/TKOffset/BiTgte/BiTgte_CurveOnVertex.hxx b/src/ModelingAlgorithms/TKOffset/BiTgte/BiTgte_CurveOnVertex.hxx index 7a5722630a..94617be9af 100644 --- a/src/ModelingAlgorithms/TKOffset/BiTgte/BiTgte_CurveOnVertex.hxx +++ b/src/ModelingAlgorithms/TKOffset/BiTgte/BiTgte_CurveOnVertex.hxx @@ -20,6 +20,7 @@ #include #include +#include #include #include #include @@ -82,40 +83,20 @@ public: Standard_EXPORT double Period() const override; - //! Computes the point of parameter U on the curve. - Standard_EXPORT gp_Pnt Value(const double U) const override; + //! Computes the point of parameter theU on the curve. + [[nodiscard]] Standard_EXPORT gp_Pnt EvalD0(double theU) const final; - //! Computes the point of parameter U on the curve. - Standard_EXPORT void D0(const double U, gp_Pnt& P) const override; + //! Computes the point and first derivative at parameter theU. + [[nodiscard]] Standard_EXPORT Geom_Curve::ResD1 EvalD1(double theU) const final; - //! Computes the point of parameter U on the curve with its - //! first derivative. - //! Raised if the continuity of the current interval - //! is not C1. - Standard_EXPORT void D1(const double U, gp_Pnt& P, gp_Vec& V) const override; + //! Computes the point and first two derivatives at parameter theU. + [[nodiscard]] Standard_EXPORT Geom_Curve::ResD2 EvalD2(double theU) const final; - //! Returns the point P of parameter U, the first and second - //! derivatives V1 and V2. - //! Raised if the continuity of the current interval - //! is not C2. - Standard_EXPORT void D2(const double U, gp_Pnt& P, gp_Vec& V1, gp_Vec& V2) const override; + //! Computes the point and first three derivatives at parameter theU. + [[nodiscard]] Standard_EXPORT Geom_Curve::ResD3 EvalD3(double theU) const final; - //! Returns the point P of parameter U, the first, the second - //! and the third derivative. - //! Raised if the continuity of the current interval - //! is not C3. - Standard_EXPORT void D3(const double U, - gp_Pnt& P, - gp_Vec& V1, - gp_Vec& V2, - gp_Vec& V3) const override; - - //! The returned vector gives the value of the derivative for the - //! order of derivation N. - //! Raised if the continuity of the current interval - //! is not CN. - //! Raised if N < 1. - Standard_EXPORT gp_Vec DN(const double U, const int N) const override; + //! Returns the derivative of order theN at parameter theU. + [[nodiscard]] Standard_EXPORT gp_Vec EvalDN(double theU, int theN) const final; //! Returns the parametric resolution corresponding //! to the real space resolution . diff --git a/src/ModelingData/TKBRep/BRepAdaptor/BRepAdaptor_CompCurve.cxx b/src/ModelingData/TKBRep/BRepAdaptor/BRepAdaptor_CompCurve.cxx index dc6bcb8dfe..bb30db0903 100644 --- a/src/ModelingData/TKBRep/BRepAdaptor/BRepAdaptor_CompCurve.cxx +++ b/src/ModelingData/TKBRep/BRepAdaptor/BRepAdaptor_CompCurve.cxx @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include @@ -319,59 +320,53 @@ double BRepAdaptor_CompCurve::Period() const return (TLast - TFirst); } -gp_Pnt BRepAdaptor_CompCurve::Value(const double U) const +gp_Pnt BRepAdaptor_CompCurve::EvalD0(double theU) const { - double u = U, d; + double u = theU, d; int index = CurIndex; Prepare(u, d, index); - return myCurves->Value(index).Value(u); + return myCurves->Value(index).EvalD0(u); } -void BRepAdaptor_CompCurve::D0(const double U, gp_Pnt& P) const +Geom_Curve::ResD1 BRepAdaptor_CompCurve::EvalD1(double theU) const { - double u = U, d; + double u = theU, d; int index = CurIndex; Prepare(u, d, index); - myCurves->Value(index).D0(u, P); + Geom_Curve::ResD1 aRes = myCurves->Value(index).EvalD1(u); + aRes.D1 *= d; + return aRes; } -void BRepAdaptor_CompCurve::D1(const double U, gp_Pnt& P, gp_Vec& V) const +Geom_Curve::ResD2 BRepAdaptor_CompCurve::EvalD2(double theU) const { - double u = U, d; + double u = theU, d; int index = CurIndex; Prepare(u, d, index); - myCurves->Value(index).D1(u, P, V); - V *= d; + Geom_Curve::ResD2 aRes = myCurves->Value(index).EvalD2(u); + aRes.D1 *= d; + aRes.D2 *= d * d; + return aRes; } -void BRepAdaptor_CompCurve::D2(const double U, gp_Pnt& P, gp_Vec& V1, gp_Vec& V2) const +Geom_Curve::ResD3 BRepAdaptor_CompCurve::EvalD3(double theU) const { - double u = U, d; + double u = theU, d; int index = CurIndex; Prepare(u, d, index); - myCurves->Value(index).D2(u, P, V1, V2); - V1 *= d; - V2 *= d * d; + Geom_Curve::ResD3 aRes = myCurves->Value(index).EvalD3(u); + aRes.D1 *= d; + aRes.D2 *= d * d; + aRes.D3 *= d * d * d; + return aRes; } -void BRepAdaptor_CompCurve::D3(const double U, gp_Pnt& P, gp_Vec& V1, gp_Vec& V2, gp_Vec& V3) const +gp_Vec BRepAdaptor_CompCurve::EvalDN(double theU, int theN) const { - double u = U, d; + double u = theU, d; int index = CurIndex; Prepare(u, d, index); - myCurves->Value(index).D3(u, P, V1, V2, V3); - V1 *= d; - V2 *= d * d; - V3 *= d * d * d; -} - -gp_Vec BRepAdaptor_CompCurve::DN(const double U, const int N) const -{ - double u = U, d; - int index = CurIndex; - Prepare(u, d, index); - - return (myCurves->Value(index).DN(u, N) * std::pow(d, N)); + return myCurves->Value(index).EvalDN(u, theN) * std::pow(d, theN); } double BRepAdaptor_CompCurve::Resolution(const double R3d) const diff --git a/src/ModelingData/TKBRep/BRepAdaptor/BRepAdaptor_CompCurve.hxx b/src/ModelingData/TKBRep/BRepAdaptor/BRepAdaptor_CompCurve.hxx index 1d0a0eefe3..0dbd8d5c2b 100644 --- a/src/ModelingData/TKBRep/BRepAdaptor/BRepAdaptor_CompCurve.hxx +++ b/src/ModelingData/TKBRep/BRepAdaptor/BRepAdaptor_CompCurve.hxx @@ -122,38 +122,25 @@ public: Standard_EXPORT double Period() const override; - //! Computes the point of parameter U on the curve - Standard_EXPORT gp_Pnt Value(const double U) const override; + //! Computes the point of parameter theU on the curve. + [[nodiscard]] Standard_EXPORT gp_Pnt EvalD0(double theU) const final; - //! Computes the point of parameter U. - Standard_EXPORT void D0(const double U, gp_Pnt& P) const override; - - //! Computes the point of parameter U on the curve - //! with its first derivative. + //! Computes the point of parameter theU on the curve with its first derivative. //! Raised if the continuity of the current interval is not C1. - Standard_EXPORT void D1(const double U, gp_Pnt& P, gp_Vec& V) const override; + [[nodiscard]] Standard_EXPORT Geom_Curve::ResD1 EvalD1(double theU) const final; - //! Returns the point P of parameter U, the first and second - //! derivatives V1 and V2. - //! Raised if the continuity of the current interval - //! is not C2. - Standard_EXPORT void D2(const double U, gp_Pnt& P, gp_Vec& V1, gp_Vec& V2) const override; + //! Returns the point and the first and second derivatives at parameter theU. + //! Raised if the continuity of the current interval is not C2. + [[nodiscard]] Standard_EXPORT Geom_Curve::ResD2 EvalD2(double theU) const final; - //! Returns the point P of parameter U, the first, the second - //! and the third derivative. - //! Raised if the continuity of the current interval - //! is not C3. - Standard_EXPORT void D3(const double U, - gp_Pnt& P, - gp_Vec& V1, - gp_Vec& V2, - gp_Vec& V3) const override; + //! Returns the point and the first, second and third derivatives at parameter theU. + //! Raised if the continuity of the current interval is not C3. + [[nodiscard]] Standard_EXPORT Geom_Curve::ResD3 EvalD3(double theU) const final; - //! The returned vector gives the value of the derivative for the - //! order of derivation N. + //! Returns the derivative of order theN at parameter theU. //! Raised if the continuity of the current interval is not CN. - //! Raised if N < 1. - Standard_EXPORT gp_Vec DN(const double U, const int N) const override; + //! Raised if theN < 1. + [[nodiscard]] Standard_EXPORT gp_Vec EvalDN(double theU, int theN) const final; //! returns the parametric resolution Standard_EXPORT double Resolution(const double R3d) const override; diff --git a/src/ModelingData/TKBRep/BRepAdaptor/BRepAdaptor_Curve.cxx b/src/ModelingData/TKBRep/BRepAdaptor/BRepAdaptor_Curve.cxx index 292659f8ac..cfed8892bc 100644 --- a/src/ModelingData/TKBRep/BRepAdaptor/BRepAdaptor_Curve.cxx +++ b/src/ModelingData/TKBRep/BRepAdaptor/BRepAdaptor_Curve.cxx @@ -20,53 +20,37 @@ #include #include #include -#include -#include #include -#include #include -#include -#include -#include -#include -#include -#include -#include -#include -#include #include -#include #include -#include -IMPLEMENT_STANDARD_RTTIEXT(BRepAdaptor_Curve, Adaptor3d_Curve) +IMPLEMENT_STANDARD_RTTIEXT(BRepAdaptor_Curve, GeomAdaptor_TransformedCurve) -//================================================================================================= +//================================================================================================== BRepAdaptor_Curve::BRepAdaptor_Curve() = default; -//================================================================================================= +//================================================================================================== BRepAdaptor_Curve::BRepAdaptor_Curve(const TopoDS_Edge& E) { Initialize(E); } -//================================================================================================= +//================================================================================================== BRepAdaptor_Curve::BRepAdaptor_Curve(const TopoDS_Edge& E, const TopoDS_Face& F) { Initialize(E, F); } -//================================================================================================= +//================================================================================================== occ::handle BRepAdaptor_Curve::ShallowCopy() const { occ::handle aCopy = new BRepAdaptor_Curve(); - aCopy->myTrsf = myTrsf; - const occ::handle aCurve = myCurve.ShallowCopy(); const GeomAdaptor_Curve& aGeomCurve = *(occ::down_cast(aCurve)); aCopy->myCurve = aGeomCurve; @@ -75,12 +59,13 @@ occ::handle BRepAdaptor_Curve::ShallowCopy() const { aCopy->myConSurf = occ::down_cast(myConSurf->ShallowCopy()); } + aCopy->myTrsf = myTrsf; aCopy->myEdge = myEdge; return aCopy; } -//================================================================================================= +//================================================================================================== void BRepAdaptor_Curve::Reset() { @@ -90,7 +75,7 @@ void BRepAdaptor_Curve::Reset() myTrsf = gp_Trsf(); } -//================================================================================================= +//================================================================================================== void BRepAdaptor_Curve::Initialize(const TopoDS_Edge& E) { @@ -127,7 +112,7 @@ void BRepAdaptor_Curve::Initialize(const TopoDS_Edge& E) myTrsf = L.Transformation(); } -//================================================================================================= +//================================================================================================== void BRepAdaptor_Curve::Initialize(const TopoDS_Edge& E, const TopoDS_Face& F) { @@ -149,126 +134,21 @@ void BRepAdaptor_Curve::Initialize(const TopoDS_Edge& E, const TopoDS_Face& F) myTrsf = L.Transformation(); } -//================================================================================================= - -const gp_Trsf& BRepAdaptor_Curve::Trsf() const -{ - return myTrsf; -} - -//================================================================================================= - -bool BRepAdaptor_Curve::Is3DCurve() const -{ - return myConSurf.IsNull(); -} - -//================================================================================================= - -bool BRepAdaptor_Curve::IsCurveOnSurface() const -{ - return !myConSurf.IsNull(); -} - -//================================================================================================= - -const GeomAdaptor_Curve& BRepAdaptor_Curve::Curve() const -{ - return myCurve; -} - -//================================================================================================= - -const Adaptor3d_CurveOnSurface& BRepAdaptor_Curve::CurveOnSurface() const -{ - return *myConSurf; -} - -//================================================================================================= +//================================================================================================== const TopoDS_Edge& BRepAdaptor_Curve::Edge() const { return myEdge; } -//================================================================================================= +//================================================================================================== double BRepAdaptor_Curve::Tolerance() const { return BRep_Tool::Tolerance(myEdge); } -//================================================================================================= - -double BRepAdaptor_Curve::FirstParameter() const -{ - if (myConSurf.IsNull()) - { - return myCurve.FirstParameter(); - } - else - { - return myConSurf->FirstParameter(); - } -} - -//================================================================================================= - -double BRepAdaptor_Curve::LastParameter() const -{ - if (myConSurf.IsNull()) - { - return myCurve.LastParameter(); - } - else - { - return myConSurf->LastParameter(); - } -} - -//================================================================================================= - -GeomAbs_Shape BRepAdaptor_Curve::Continuity() const -{ - if (myConSurf.IsNull()) - { - return myCurve.Continuity(); - } - else - { - return myConSurf->Continuity(); - } -} - -//================================================================================================= - -int BRepAdaptor_Curve::NbIntervals(const GeomAbs_Shape S) const -{ - if (myConSurf.IsNull()) - { - return myCurve.NbIntervals(S); - } - else - { - return myConSurf->NbIntervals(S); - } -} - -//================================================================================================= - -void BRepAdaptor_Curve::Intervals(NCollection_Array1& T, const GeomAbs_Shape S) const -{ - if (myConSurf.IsNull()) - { - myCurve.Intervals(T, S); - } - else - { - myConSurf->Intervals(T, S); - } -} - -//================================================================================================= +//================================================================================================== occ::handle BRepAdaptor_Curve::Trim(const double First, const double Last, @@ -294,301 +174,3 @@ occ::handle BRepAdaptor_Curve::Trim(const double First, } return res; } - -//================================================================================================= - -bool BRepAdaptor_Curve::IsClosed() const -{ - if (myConSurf.IsNull()) - { - return myCurve.IsClosed(); - } - else - { - return myConSurf->IsClosed(); - } -} - -//================================================================================================= - -bool BRepAdaptor_Curve::IsPeriodic() const -{ - if (myConSurf.IsNull()) - { - return myCurve.IsPeriodic(); - } - else - { - return myConSurf->IsPeriodic(); - } -} - -//================================================================================================= - -double BRepAdaptor_Curve::Period() const -{ - if (myConSurf.IsNull()) - { - return myCurve.Period(); - } - else - { - return myConSurf->Period(); - } -} - -//================================================================================================= - -gp_Pnt BRepAdaptor_Curve::Value(const double U) const -{ - gp_Pnt P; - if (myConSurf.IsNull()) - P = myCurve.Value(U); - else - P = myConSurf->Value(U); - P.Transform(myTrsf); - return P; -} - -//================================================================================================= - -void BRepAdaptor_Curve::D0(const double U, gp_Pnt& P) const -{ - if (myConSurf.IsNull()) - myCurve.D0(U, P); - else - myConSurf->D0(U, P); - P.Transform(myTrsf); -} - -//================================================================================================= - -void BRepAdaptor_Curve::D1(const double U, gp_Pnt& P, gp_Vec& V) const -{ - if (myConSurf.IsNull()) - myCurve.D1(U, P, V); - else - myConSurf->D1(U, P, V); - P.Transform(myTrsf); - V.Transform(myTrsf); -} - -//================================================================================================= - -void BRepAdaptor_Curve::D2(const double U, gp_Pnt& P, gp_Vec& V1, gp_Vec& V2) const -{ - if (myConSurf.IsNull()) - myCurve.D2(U, P, V1, V2); - else - myConSurf->D2(U, P, V1, V2); - P.Transform(myTrsf); - V1.Transform(myTrsf); - V2.Transform(myTrsf); -} - -//================================================================================================= - -void BRepAdaptor_Curve::D3(const double U, gp_Pnt& P, gp_Vec& V1, gp_Vec& V2, gp_Vec& V3) const -{ - if (myConSurf.IsNull()) - myCurve.D3(U, P, V1, V2, V3); - else - myConSurf->D3(U, P, V1, V2, V3); - P.Transform(myTrsf); - V1.Transform(myTrsf); - V2.Transform(myTrsf); - V3.Transform(myTrsf); -} - -//================================================================================================= - -gp_Vec BRepAdaptor_Curve::DN(const double U, const int N) const -{ - gp_Vec V; - if (myConSurf.IsNull()) - V = myCurve.DN(U, N); - else - V = myConSurf->DN(U, N); - V.Transform(myTrsf); - return V; -} - -//================================================================================================= - -double BRepAdaptor_Curve::Resolution(const double R) const -{ - if (myConSurf.IsNull()) - { - return myCurve.Resolution(R); - } - else - { - return myConSurf->Resolution(R); - } -} - -//================================================================================================= - -GeomAbs_CurveType BRepAdaptor_Curve::GetType() const -{ - if (myConSurf.IsNull()) - { - return myCurve.GetType(); - } - else - { - return myConSurf->GetType(); - } -} - -//================================================================================================= - -gp_Lin BRepAdaptor_Curve::Line() const -{ - gp_Lin L; - if (myConSurf.IsNull()) - L = myCurve.Line(); - else - L = myConSurf->Line(); - L.Transform(myTrsf); - return L; -} - -//================================================================================================= - -gp_Circ BRepAdaptor_Curve::Circle() const -{ - gp_Circ C; - if (myConSurf.IsNull()) - C = myCurve.Circle(); - else - C = myConSurf->Circle(); - C.Transform(myTrsf); - return C; -} - -//================================================================================================= - -gp_Elips BRepAdaptor_Curve::Ellipse() const -{ - gp_Elips E; - if (myConSurf.IsNull()) - E = myCurve.Ellipse(); - else - E = myConSurf->Ellipse(); - E.Transform(myTrsf); - return E; -} - -//================================================================================================= - -gp_Hypr BRepAdaptor_Curve::Hyperbola() const -{ - gp_Hypr H; - if (myConSurf.IsNull()) - H = myCurve.Hyperbola(); - else - H = myConSurf->Hyperbola(); - H.Transform(myTrsf); - return H; -} - -//================================================================================================= - -gp_Parab BRepAdaptor_Curve::Parabola() const -{ - gp_Parab P; - if (myConSurf.IsNull()) - P = myCurve.Parabola(); - else - P = myConSurf->Parabola(); - P.Transform(myTrsf); - return P; -} - -//================================================================================================= - -int BRepAdaptor_Curve::Degree() const -{ - if (myConSurf.IsNull()) - return myCurve.Degree(); - else - return myConSurf->Degree(); -} - -//================================================================================================= - -bool BRepAdaptor_Curve::IsRational() const -{ - if (myConSurf.IsNull()) - return myCurve.IsRational(); - else - return myConSurf->IsRational(); -} - -//================================================================================================= - -int BRepAdaptor_Curve::NbPoles() const -{ - if (myConSurf.IsNull()) - return myCurve.NbPoles(); - else - return myConSurf->NbPoles(); -} - -//================================================================================================= - -int BRepAdaptor_Curve::NbKnots() const -{ - if (myConSurf.IsNull()) - return myCurve.NbKnots(); - else - return myConSurf->NbKnots(); -} - -//================================================================================================= - -occ::handle BRepAdaptor_Curve::Bezier() const -{ - occ::handle BC; - if (myConSurf.IsNull()) - { - BC = myCurve.Bezier(); - } - else - { - BC = myConSurf->Bezier(); - } - return myTrsf.Form() == gp_Identity ? BC - : occ::down_cast(BC->Transformed(myTrsf)); -} - -//================================================================================================= - -occ::handle BRepAdaptor_Curve::BSpline() const -{ - occ::handle BS; - if (myConSurf.IsNull()) - { - BS = myCurve.BSpline(); - } - else - { - BS = myConSurf->BSpline(); - } - return myTrsf.Form() == gp_Identity ? BS - : occ::down_cast(BS->Transformed(myTrsf)); -} - -//================================================================================================= - -occ::handle BRepAdaptor_Curve::OffsetCurve() const -{ - if (!Is3DCurve() || myCurve.GetType() != GeomAbs_OffsetCurve) - throw Standard_NoSuchObject("BRepAdaptor_Curve::OffsetCurve"); - - occ::handle anOffC = myCurve.OffsetCurve(); - return myTrsf.Form() == gp_Identity - ? anOffC - : occ::down_cast(anOffC->Transformed(myTrsf)); -} diff --git a/src/ModelingData/TKBRep/BRepAdaptor/BRepAdaptor_Curve.hxx b/src/ModelingData/TKBRep/BRepAdaptor/BRepAdaptor_Curve.hxx index 2dddbfe6fb..15dabfbeb6 100644 --- a/src/ModelingData/TKBRep/BRepAdaptor/BRepAdaptor_Curve.hxx +++ b/src/ModelingData/TKBRep/BRepAdaptor/BRepAdaptor_Curve.hxx @@ -17,29 +17,10 @@ #ifndef _BRepAdaptor_Curve_HeaderFile #define _BRepAdaptor_Curve_HeaderFile -#include -#include -#include +#include #include -#include -#include -#include -#include -#include -#include class TopoDS_Face; -class Adaptor3d_CurveOnSurface; -class gp_Pnt; -class gp_Vec; -class gp_Lin; -class gp_Circ; -class gp_Elips; -class gp_Hypr; -class gp_Parab; -class Geom_BezierCurve; -class Geom_BSplineCurve; -class Geom_OffsetCurve; //! The Curve from BRepAdaptor allows to use an Edge //! of the BRep topology like a 3D curve. @@ -53,9 +34,9 @@ class Geom_OffsetCurve; //! surface is used. It is possible to enforce using a //! curve on surface by creating or initialising with //! an Edge and a Face. -class BRepAdaptor_Curve : public Adaptor3d_Curve +class BRepAdaptor_Curve : public GeomAdaptor_TransformedCurve { - DEFINE_STANDARD_RTTIEXT(BRepAdaptor_Curve, Adaptor3d_Curve) + DEFINE_STANDARD_RTTIEXT(BRepAdaptor_Curve, GeomAdaptor_TransformedCurve) public: //! Creates an undefined Curve with no Edge loaded. Standard_EXPORT BRepAdaptor_Curve(); @@ -87,136 +68,33 @@ public: //! the face. Standard_EXPORT void Initialize(const TopoDS_Edge& E, const TopoDS_Face& F); - //! Returns the coordinate system of the curve. - Standard_EXPORT const gp_Trsf& Trsf() const; - - //! Returns True if the edge geometry is computed from - //! a 3D curve. - Standard_EXPORT bool Is3DCurve() const; - - //! Returns True if the edge geometry is computed from - //! a pcurve on a surface. - Standard_EXPORT bool IsCurveOnSurface() const; - - //! Returns the Curve of the edge. - Standard_EXPORT const GeomAdaptor_Curve& Curve() const; - - //! Returns the CurveOnSurface of the edge. - Standard_EXPORT const Adaptor3d_CurveOnSurface& CurveOnSurface() const; - //! Returns the edge. Standard_EXPORT const TopoDS_Edge& Edge() const; //! Returns the edge tolerance. Standard_EXPORT double Tolerance() const; - Standard_EXPORT double FirstParameter() const override; - - Standard_EXPORT double LastParameter() const override; - - Standard_EXPORT GeomAbs_Shape Continuity() const override; - - //! Returns the number of intervals for continuity - //! . May be one if Continuity(me) >= - Standard_EXPORT int NbIntervals(const GeomAbs_Shape S) const override; - - //! Stores in the parameters bounding the intervals - //! of continuity . - //! - //! The array must provide enough room to accommodate - //! for the parameters. i.e. T.Length() > NbIntervals() - Standard_EXPORT void Intervals(NCollection_Array1& T, - const GeomAbs_Shape S) const override; - //! Returns a curve equivalent of between //! parameters and . is used to //! test for 3d points confusion. - //! If >= Standard_EXPORT occ::handle Trim(const double First, const double Last, const double Tol) const override; - Standard_EXPORT bool IsClosed() const override; - - Standard_EXPORT bool IsPeriodic() const override; - - Standard_EXPORT double Period() const override; - - //! Computes the point of parameter U on the curve - Standard_EXPORT gp_Pnt Value(const double U) const override; - - //! Computes the point of parameter U. - Standard_EXPORT void D0(const double U, gp_Pnt& P) const override; - - //! Computes the point of parameter U on the curve - //! with its first derivative. - //! Raised if the continuity of the current interval - //! is not C1. - Standard_EXPORT void D1(const double U, gp_Pnt& P, gp_Vec& V) const override; - - //! Returns the point P of parameter U, the first and second - //! derivatives V1 and V2. - //! Raised if the continuity of the current interval - //! is not C2. - Standard_EXPORT void D2(const double U, gp_Pnt& P, gp_Vec& V1, gp_Vec& V2) const override; - - //! Returns the point P of parameter U, the first, the second - //! and the third derivative. - //! Raised if the continuity of the current interval - //! is not C3. - Standard_EXPORT void D3(const double U, - gp_Pnt& P, - gp_Vec& V1, - gp_Vec& V2, - gp_Vec& V3) const override; - - //! The returned vector gives the value of the derivative for the - //! order of derivation N. - //! Raised if the continuity of the current interval - //! is not CN. - //! Raised if N < 1. - Standard_EXPORT gp_Vec DN(const double U, const int N) const override; - - //! returns the parametric resolution - Standard_EXPORT double Resolution(const double R3d) const override; - - Standard_EXPORT GeomAbs_CurveType GetType() const override; - - Standard_EXPORT gp_Lin Line() const override; - - Standard_EXPORT gp_Circ Circle() const override; - - Standard_EXPORT gp_Elips Ellipse() const override; - - Standard_EXPORT gp_Hypr Hyperbola() const override; - - Standard_EXPORT gp_Parab Parabola() const override; - - Standard_EXPORT int Degree() const override; - - Standard_EXPORT bool IsRational() const override; - - Standard_EXPORT int NbPoles() const override; - - Standard_EXPORT int NbKnots() const override; - - //! Warning: - //! This will make a copy of the Bezier Curve since it applies to it myTsrf. - //! Be careful when using this method. - Standard_EXPORT occ::handle Bezier() const override; - - //! Warning: - //! This will make a copy of the BSpline Curve since it applies to it myTsrf. - //! Be careful when using this method. - Standard_EXPORT occ::handle BSpline() const override; - - Standard_EXPORT occ::handle OffsetCurve() const override; + // Note: Most methods are inherited from GeomAdaptor_TransformedCurve. + // The following methods provide access to the underlying curve/transformation: + // - Curve() - returns const GeomAdaptor_Curve& + // - ChangeCurve() - returns GeomAdaptor_Curve& + // - Trsf() - returns const gp_Trsf& + // - Is3DCurve() - returns true if 3D curve is used + // - IsCurveOnSurface() - returns true if COS is used + // - CurveOnSurface() - returns const Adaptor3d_CurveOnSurface& + // + // Value, D0, D1, D2, D3, DN methods are inherited and marked as final. + // They apply the transformation automatically. private: - gp_Trsf myTrsf; - GeomAdaptor_Curve myCurve; - occ::handle myConSurf; - TopoDS_Edge myEdge; + TopoDS_Edge myEdge; }; #endif // _BRepAdaptor_Curve_HeaderFile diff --git a/src/ModelingData/TKG3d/Adaptor3d/Adaptor3d_Curve.cxx b/src/ModelingData/TKG3d/Adaptor3d/Adaptor3d_Curve.cxx index 74d2843eab..09a5a33cf2 100644 --- a/src/ModelingData/TKG3d/Adaptor3d/Adaptor3d_Curve.cxx +++ b/src/ModelingData/TKG3d/Adaptor3d/Adaptor3d_Curve.cxx @@ -107,55 +107,6 @@ double Adaptor3d_Curve::Period() const //================================================================================================= -// gp_Pnt Adaptor3d_Curve::Value(const double U) const -gp_Pnt Adaptor3d_Curve::Value(const double) const -{ - throw Standard_NotImplemented("Adaptor3d_Curve::Value"); -} - -//================================================================================================= - -// void Adaptor3d_Curve::D0(const double U, gp_Pnt& P) const -void Adaptor3d_Curve::D0(const double, gp_Pnt&) const -{ - throw Standard_NotImplemented("Adaptor3d_Curve::D0"); -} - -//================================================================================================= - -// void Adaptor3d_Curve::D1(const double U, gp_Pnt& P, gp_Vec& V) const -void Adaptor3d_Curve::D1(const double, gp_Pnt&, gp_Vec&) const -{ - throw Standard_NotImplemented("Adaptor3d_Curve::D1"); -} - -//================================================================================================= - -// void Adaptor3d_Curve::D2(const double U, gp_Pnt& P, gp_Vec& V1, gp_Vec& V2) const -void Adaptor3d_Curve::D2(const double, gp_Pnt&, gp_Vec&, gp_Vec&) const -{ - throw Standard_NotImplemented("Adaptor3d_Curve::D2"); -} - -//================================================================================================= - -// void Adaptor3d_Curve::D3(const double U, gp_Pnt& P, gp_Vec& V1, gp_Vec& V2, gp_Vec& V3) -// const -void Adaptor3d_Curve::D3(const double, gp_Pnt&, gp_Vec&, gp_Vec&, gp_Vec&) const -{ - throw Standard_NotImplemented("Adaptor3d_Curve::D3"); -} - -//================================================================================================= - -// gp_Vec Adaptor3d_Curve::DN(const double U, const int N) const -gp_Vec Adaptor3d_Curve::DN(const double, const int) const -{ - throw Standard_NotImplemented("Adaptor3d_Curve::DN"); -} - -//================================================================================================= - // double Adaptor3d_Curve::Resolution(const double R3d) const double Adaptor3d_Curve::Resolution(const double) const { @@ -255,43 +206,35 @@ occ::handle Adaptor3d_Curve::OffsetCurve() const //================================================================================================= -gp_Pnt Adaptor3d_Curve::EvalD0(double theU) const +gp_Pnt Adaptor3d_Curve::EvalD0(double) const { - gp_Pnt aP; - D0(theU, aP); - return aP; + throw Standard_NotImplemented("Adaptor3d_Curve::EvalD0"); } //================================================================================================= -Geom_Curve::ResD1 Adaptor3d_Curve::EvalD1(double theU) const +Geom_Curve::ResD1 Adaptor3d_Curve::EvalD1(double) const { - Geom_Curve::ResD1 aResult; - D1(theU, aResult.Point, aResult.D1); - return aResult; + throw Standard_NotImplemented("Adaptor3d_Curve::EvalD1"); } //================================================================================================= -Geom_Curve::ResD2 Adaptor3d_Curve::EvalD2(double theU) const +Geom_Curve::ResD2 Adaptor3d_Curve::EvalD2(double) const { - Geom_Curve::ResD2 aResult; - D2(theU, aResult.Point, aResult.D1, aResult.D2); - return aResult; + throw Standard_NotImplemented("Adaptor3d_Curve::EvalD2"); } //================================================================================================= -Geom_Curve::ResD3 Adaptor3d_Curve::EvalD3(double theU) const +Geom_Curve::ResD3 Adaptor3d_Curve::EvalD3(double) const { - Geom_Curve::ResD3 aResult; - D3(theU, aResult.Point, aResult.D1, aResult.D2, aResult.D3); - return aResult; + throw Standard_NotImplemented("Adaptor3d_Curve::EvalD3"); } //================================================================================================= -gp_Vec Adaptor3d_Curve::EvalDN(double theU, int theN) const +gp_Vec Adaptor3d_Curve::EvalDN(double, int) const { - return DN(theU, theN); + throw Standard_NotImplemented("Adaptor3d_Curve::EvalDN"); } diff --git a/src/ModelingData/TKG3d/Adaptor3d/Adaptor3d_Curve.hxx b/src/ModelingData/TKG3d/Adaptor3d/Adaptor3d_Curve.hxx index 650740736a..714e7791a5 100644 --- a/src/ModelingData/TKG3d/Adaptor3d/Adaptor3d_Curve.hxx +++ b/src/ModelingData/TKG3d/Adaptor3d/Adaptor3d_Curve.hxx @@ -86,39 +86,53 @@ public: Standard_EXPORT virtual double Period() const; //! Computes the point of parameter U on the curve. - Standard_EXPORT virtual gp_Pnt Value(const double U) const; + gp_Pnt Value(const double theU) const { return EvalD0(theU); } //! Computes the point of parameter U on the curve. - Standard_EXPORT virtual void D0(const double U, gp_Pnt& P) const; + void D0(const double theU, gp_Pnt& theP) const { theP = EvalD0(theU); } //! Computes the point of parameter U on the curve with its //! first derivative. //! Raised if the continuity of the current interval //! is not C1. - Standard_EXPORT virtual void D1(const double U, gp_Pnt& P, gp_Vec& V) const; + void D1(const double theU, gp_Pnt& theP, gp_Vec& theV) const + { + const Geom_Curve::ResD1 aRes = EvalD1(theU); + theP = aRes.Point; + theV = aRes.D1; + } //! Returns the point P of parameter U, the first and second //! derivatives V1 and V2. //! Raised if the continuity of the current interval //! is not C2. - Standard_EXPORT virtual void D2(const double U, gp_Pnt& P, gp_Vec& V1, gp_Vec& V2) const; + void D2(const double theU, gp_Pnt& theP, gp_Vec& theV1, gp_Vec& theV2) const + { + const Geom_Curve::ResD2 aRes = EvalD2(theU); + theP = aRes.Point; + theV1 = aRes.D1; + theV2 = aRes.D2; + } //! Returns the point P of parameter U, the first, the second //! and the third derivative. //! Raised if the continuity of the current interval //! is not C3. - Standard_EXPORT virtual void D3(const double U, - gp_Pnt& P, - gp_Vec& V1, - gp_Vec& V2, - gp_Vec& V3) const; + void D3(const double theU, gp_Pnt& theP, gp_Vec& theV1, gp_Vec& theV2, gp_Vec& theV3) const + { + const Geom_Curve::ResD3 aRes = EvalD3(theU); + theP = aRes.Point; + theV1 = aRes.D1; + theV2 = aRes.D2; + theV3 = aRes.D3; + } //! The returned vector gives the value of the derivative for the //! order of derivation N. //! Raised if the continuity of the current interval //! is not CN. //! Raised if N < 1. - Standard_EXPORT virtual gp_Vec DN(const double U, const int N) const; + gp_Vec DN(const double theU, const int theN) const { return EvalDN(theU, theN); } //! Returns the parametric resolution corresponding //! to the real space resolution . diff --git a/src/ModelingData/TKG3d/Adaptor3d/Adaptor3d_CurveOnSurface.cxx b/src/ModelingData/TKG3d/Adaptor3d/Adaptor3d_CurveOnSurface.cxx index a4cfdff311..1b8fce9bdb 100644 --- a/src/ModelingData/TKG3d/Adaptor3d/Adaptor3d_CurveOnSurface.cxx +++ b/src/ModelingData/TKG3d/Adaptor3d/Adaptor3d_CurveOnSurface.cxx @@ -1139,18 +1139,18 @@ double Adaptor3d_CurveOnSurface::Period() const //================================================================================================= -gp_Pnt Adaptor3d_CurveOnSurface::Value(const double U) const +gp_Pnt Adaptor3d_CurveOnSurface::EvalD0(const double theU) const { gp_Pnt P; gp_Pnt2d Puv; if (myType == GeomAbs_Line) - P = ElCLib::Value(U, myLin); + P = ElCLib::Value(theU, myLin); else if (myType == GeomAbs_Circle) - P = ElCLib::Value(U, myCirc); + P = ElCLib::Value(theU, myCirc); else { - myCurve->D0(U, Puv); + myCurve->D0(theU, Puv); mySurface->D0(Puv.X(), Puv.Y(), P); } @@ -1159,185 +1159,158 @@ gp_Pnt Adaptor3d_CurveOnSurface::Value(const double U) const //================================================================================================= -void Adaptor3d_CurveOnSurface::D0(const double U, gp_Pnt& P) const -{ - gp_Pnt2d Puv; - - if (myType == GeomAbs_Line) - P = ElCLib::Value(U, myLin); - else if (myType == GeomAbs_Circle) - P = ElCLib::Value(U, myCirc); - else - { - myCurve->D0(U, Puv); - mySurface->D0(Puv.X(), Puv.Y(), P); - } -} - -//================================================================================================= - -void Adaptor3d_CurveOnSurface::D1(const double U, gp_Pnt& P, gp_Vec& V) const +Geom_Curve::ResD1 Adaptor3d_CurveOnSurface::EvalD1(const double theU) const { gp_Pnt2d Puv; gp_Vec2d Duv; gp_Vec D1U, D1V; - double FP = myCurve->FirstParameter(); - double LP = myCurve->LastParameter(); + Geom_Curve::ResD1 aRes; + const double FP = myCurve->FirstParameter(); + const double LP = myCurve->LastParameter(); constexpr double Tol = Precision::PConfusion() / 10; - if ((std::abs(U - FP) < Tol) && (!myFirstSurf.IsNull())) + + if ((std::abs(theU - FP) < Tol) && (!myFirstSurf.IsNull())) { - myCurve->D1(U, Puv, Duv); - myFirstSurf->D1(Puv.X(), Puv.Y(), P, D1U, D1V); - V.SetLinearForm(Duv.X(), D1U, Duv.Y(), D1V); + myCurve->D1(theU, Puv, Duv); + myFirstSurf->D1(Puv.X(), Puv.Y(), aRes.Point, D1U, D1V); + aRes.D1.SetLinearForm(Duv.X(), D1U, Duv.Y(), D1V); } - else if ((std::abs(U - LP) < Tol) && (!myLastSurf.IsNull())) + else if ((std::abs(theU - LP) < Tol) && (!myLastSurf.IsNull())) { - myCurve->D1(U, Puv, Duv); - myLastSurf->D1(Puv.X(), Puv.Y(), P, D1U, D1V); - V.SetLinearForm(Duv.X(), D1U, Duv.Y(), D1V); + myCurve->D1(theU, Puv, Duv); + myLastSurf->D1(Puv.X(), Puv.Y(), aRes.Point, D1U, D1V); + aRes.D1.SetLinearForm(Duv.X(), D1U, Duv.Y(), D1V); } else if (myType == GeomAbs_Line) - ElCLib::D1(U, myLin, P, V); + ElCLib::D1(theU, myLin, aRes.Point, aRes.D1); else if (myType == GeomAbs_Circle) - ElCLib::D1(U, myCirc, P, V); + ElCLib::D1(theU, myCirc, aRes.Point, aRes.D1); else { - myCurve->D1(U, Puv, Duv); - mySurface->D1(Puv.X(), Puv.Y(), P, D1U, D1V); - V.SetLinearForm(Duv.X(), D1U, Duv.Y(), D1V); + myCurve->D1(theU, Puv, Duv); + mySurface->D1(Puv.X(), Puv.Y(), aRes.Point, D1U, D1V); + aRes.D1.SetLinearForm(Duv.X(), D1U, Duv.Y(), D1V); } + return aRes; } //================================================================================================= -void Adaptor3d_CurveOnSurface::D2(const double U, gp_Pnt& P, gp_Vec& V1, gp_Vec& V2) const +Geom_Curve::ResD2 Adaptor3d_CurveOnSurface::EvalD2(const double theU) const { gp_Pnt2d UV; gp_Vec2d DW, D2W; gp_Vec D1U, D1V, D2U, D2V, D2UV; - double FP = myCurve->FirstParameter(); - double LP = myCurve->LastParameter(); + Geom_Curve::ResD2 aRes; + const double FP = myCurve->FirstParameter(); + const double LP = myCurve->LastParameter(); constexpr double Tol = Precision::PConfusion() / 10; - if ((std::abs(U - FP) < Tol) && (!myFirstSurf.IsNull())) - { - myCurve->D2(U, UV, DW, D2W); - myFirstSurf->D2(UV.X(), UV.Y(), P, D1U, D1V, D2U, D2V, D2UV); - V1.SetLinearForm(DW.X(), D1U, DW.Y(), D1V); - V2.SetLinearForm(D2W.X(), D1U, D2W.Y(), D1V, 2. * DW.X() * DW.Y(), D2UV); - V2.SetLinearForm(DW.X() * DW.X(), D2U, DW.Y() * DW.Y(), D2V, V2); + if ((std::abs(theU - FP) < Tol) && (!myFirstSurf.IsNull())) + { + myCurve->D2(theU, UV, DW, D2W); + myFirstSurf->D2(UV.X(), UV.Y(), aRes.Point, D1U, D1V, D2U, D2V, D2UV); + aRes.D1.SetLinearForm(DW.X(), D1U, DW.Y(), D1V); + aRes.D2.SetLinearForm(D2W.X(), D1U, D2W.Y(), D1V, 2. * DW.X() * DW.Y(), D2UV); + aRes.D2.SetLinearForm(DW.X() * DW.X(), D2U, DW.Y() * DW.Y(), D2V, aRes.D2); } - else if ((std::abs(U - LP) < Tol) && (!myLastSurf.IsNull())) + else if ((std::abs(theU - LP) < Tol) && (!myLastSurf.IsNull())) { - myCurve->D2(U, UV, DW, D2W); - myLastSurf->D2(UV.X(), UV.Y(), P, D1U, D1V, D2U, D2V, D2UV); - - V1.SetLinearForm(DW.X(), D1U, DW.Y(), D1V); - V2.SetLinearForm(D2W.X(), D1U, D2W.Y(), D1V, 2. * DW.X() * DW.Y(), D2UV); - V2.SetLinearForm(DW.X() * DW.X(), D2U, DW.Y() * DW.Y(), D2V, V2); + myCurve->D2(theU, UV, DW, D2W); + myLastSurf->D2(UV.X(), UV.Y(), aRes.Point, D1U, D1V, D2U, D2V, D2UV); + aRes.D1.SetLinearForm(DW.X(), D1U, DW.Y(), D1V); + aRes.D2.SetLinearForm(D2W.X(), D1U, D2W.Y(), D1V, 2. * DW.X() * DW.Y(), D2UV); + aRes.D2.SetLinearForm(DW.X() * DW.X(), D2U, DW.Y() * DW.Y(), D2V, aRes.D2); } else if (myType == GeomAbs_Line) { - ElCLib::D1(U, myLin, P, V1); - V2.SetCoord(0., 0., 0.); + ElCLib::D1(theU, myLin, aRes.Point, aRes.D1); + aRes.D2.SetCoord(0., 0., 0.); } else if (myType == GeomAbs_Circle) - ElCLib::D2(U, myCirc, P, V1, V2); + ElCLib::D2(theU, myCirc, aRes.Point, aRes.D1, aRes.D2); else { - myCurve->D2(U, UV, DW, D2W); - mySurface->D2(UV.X(), UV.Y(), P, D1U, D1V, D2U, D2V, D2UV); - - V1.SetLinearForm(DW.X(), D1U, DW.Y(), D1V); - V2.SetLinearForm(D2W.X(), D1U, D2W.Y(), D1V, 2. * DW.X() * DW.Y(), D2UV); - V2.SetLinearForm(DW.X() * DW.X(), D2U, DW.Y() * DW.Y(), D2V, V2); + myCurve->D2(theU, UV, DW, D2W); + mySurface->D2(UV.X(), UV.Y(), aRes.Point, D1U, D1V, D2U, D2V, D2UV); + aRes.D1.SetLinearForm(DW.X(), D1U, DW.Y(), D1V); + aRes.D2.SetLinearForm(D2W.X(), D1U, D2W.Y(), D1V, 2. * DW.X() * DW.Y(), D2UV); + aRes.D2.SetLinearForm(DW.X() * DW.X(), D2U, DW.Y() * DW.Y(), D2V, aRes.D2); } + return aRes; } //================================================================================================= -void Adaptor3d_CurveOnSurface::D3(const double U, - gp_Pnt& P, - gp_Vec& V1, - gp_Vec& V2, - gp_Vec& V3) const +Geom_Curve::ResD3 Adaptor3d_CurveOnSurface::EvalD3(const double theU) const { - constexpr double Tol = Precision::PConfusion() / 10; gp_Pnt2d UV; gp_Vec2d DW, D2W, D3W; gp_Vec D1U, D1V, D2U, D2V, D2UV, D3U, D3V, D3UUV, D3UVV; - double FP = myCurve->FirstParameter(); - double LP = myCurve->LastParameter(); + Geom_Curve::ResD3 aRes; - if ((std::abs(U - FP) < Tol) && (!myFirstSurf.IsNull())) + const double FP = myCurve->FirstParameter(); + const double LP = myCurve->LastParameter(); + + if ((std::abs(theU - FP) < Tol) && (!myFirstSurf.IsNull())) { - myCurve->D3(U, UV, DW, D2W, D3W); - myFirstSurf->D3(UV.X(), UV.Y(), P, D1U, D1V, D2U, D2V, D2UV, D3U, D3V, D3UUV, D3UVV); - V1.SetLinearForm(DW.X(), D1U, DW.Y(), D1V); - V2.SetLinearForm(D2W.X(), D1U, D2W.Y(), D1V, 2. * DW.X() * DW.Y(), D2UV); - V2.SetLinearForm(DW.X() * DW.X(), D2U, DW.Y() * DW.Y(), D2V, V2); - V3 = SetLinearForm(DW, D2W, D3W, D1U, D1V, D2U, D2V, D2UV, D3U, D3V, D3UUV, D3UVV); + myCurve->D3(theU, UV, DW, D2W, D3W); + myFirstSurf->D3(UV.X(), UV.Y(), aRes.Point, D1U, D1V, D2U, D2V, D2UV, D3U, D3V, D3UUV, D3UVV); + aRes.D1.SetLinearForm(DW.X(), D1U, DW.Y(), D1V); + aRes.D2.SetLinearForm(D2W.X(), D1U, D2W.Y(), D1V, 2. * DW.X() * DW.Y(), D2UV); + aRes.D2.SetLinearForm(DW.X() * DW.X(), D2U, DW.Y() * DW.Y(), D2V, aRes.D2); + aRes.D3 = SetLinearForm(DW, D2W, D3W, D1U, D1V, D2U, D2V, D2UV, D3U, D3V, D3UUV, D3UVV); } - else - - if ((std::abs(U - LP) < Tol) && (!myLastSurf.IsNull())) + else if ((std::abs(theU - LP) < Tol) && (!myLastSurf.IsNull())) { - myCurve->D3(U, UV, DW, D2W, D3W); - myLastSurf->D3(UV.X(), UV.Y(), P, D1U, D1V, D2U, D2V, D2UV, D3U, D3V, D3UUV, D3UVV); - V1.SetLinearForm(DW.X(), D1U, DW.Y(), D1V); - - V2.SetLinearForm(D2W.X(), D1U, D2W.Y(), D1V, 2. * DW.X() * DW.Y(), D2UV); - V2.SetLinearForm(DW.X() * DW.X(), D2U, DW.Y() * DW.Y(), D2V, V2); - V3 = SetLinearForm(DW, D2W, D3W, D1U, D1V, D2U, D2V, D2UV, D3U, D3V, D3UUV, D3UVV); + myCurve->D3(theU, UV, DW, D2W, D3W); + myLastSurf->D3(UV.X(), UV.Y(), aRes.Point, D1U, D1V, D2U, D2V, D2UV, D3U, D3V, D3UUV, D3UVV); + aRes.D1.SetLinearForm(DW.X(), D1U, DW.Y(), D1V); + aRes.D2.SetLinearForm(D2W.X(), D1U, D2W.Y(), D1V, 2. * DW.X() * DW.Y(), D2UV); + aRes.D2.SetLinearForm(DW.X() * DW.X(), D2U, DW.Y() * DW.Y(), D2V, aRes.D2); + aRes.D3 = SetLinearForm(DW, D2W, D3W, D1U, D1V, D2U, D2V, D2UV, D3U, D3V, D3UUV, D3UVV); } else if (myType == GeomAbs_Line) { - ElCLib::D1(U, myLin, P, V1); - V2.SetCoord(0., 0., 0.); - V3.SetCoord(0., 0., 0.); + ElCLib::D1(theU, myLin, aRes.Point, aRes.D1); + aRes.D2.SetCoord(0., 0., 0.); + aRes.D3.SetCoord(0., 0., 0.); } else if (myType == GeomAbs_Circle) - ElCLib::D3(U, myCirc, P, V1, V2, V3); + ElCLib::D3(theU, myCirc, aRes.Point, aRes.D1, aRes.D2, aRes.D3); else { - myCurve->D3(U, UV, DW, D2W, D3W); - mySurface->D3(UV.X(), UV.Y(), P, D1U, D1V, D2U, D2V, D2UV, D3U, D3V, D3UUV, D3UVV); - V1.SetLinearForm(DW.X(), D1U, DW.Y(), D1V); - - V2.SetLinearForm(D2W.X(), D1U, D2W.Y(), D1V, 2. * DW.X() * DW.Y(), D2UV); - V2.SetLinearForm(DW.X() * DW.X(), D2U, DW.Y() * DW.Y(), D2V, V2); - V3 = SetLinearForm(DW, D2W, D3W, D1U, D1V, D2U, D2V, D2UV, D3U, D3V, D3UUV, D3UVV); + myCurve->D3(theU, UV, DW, D2W, D3W); + mySurface->D3(UV.X(), UV.Y(), aRes.Point, D1U, D1V, D2U, D2V, D2UV, D3U, D3V, D3UUV, D3UVV); + aRes.D1.SetLinearForm(DW.X(), D1U, DW.Y(), D1V); + aRes.D2.SetLinearForm(D2W.X(), D1U, D2W.Y(), D1V, 2. * DW.X() * DW.Y(), D2UV); + aRes.D2.SetLinearForm(DW.X() * DW.X(), D2U, DW.Y() * DW.Y(), D2V, aRes.D2); + aRes.D3 = SetLinearForm(DW, D2W, D3W, D1U, D1V, D2U, D2V, D2UV, D3U, D3V, D3UUV, D3UVV); } + return aRes; } //================================================================================================= -gp_Vec Adaptor3d_CurveOnSurface::DN(const double U, const int N) const +gp_Vec Adaptor3d_CurveOnSurface::EvalDN(const double theU, const int theN) const { - gp_Pnt P; - gp_Vec V1, V2, V; - switch (N) + switch (theN) { case 1: - D1(U, P, V); - break; + return EvalD1(theU).D1; case 2: - D2(U, P, V1, V); - break; + return EvalD2(theU).D2; case 3: - D3(U, P, V1, V2, V); - break; + return EvalD3(theU).D3; default: - throw Standard_NotImplemented("Adaptor3d_CurveOnSurface:DN"); - break; + throw Standard_NotImplemented("Adaptor3d_CurveOnSurface:EvalDN"); } - return V; } //================================================================================================= diff --git a/src/ModelingData/TKG3d/Adaptor3d/Adaptor3d_CurveOnSurface.hxx b/src/ModelingData/TKG3d/Adaptor3d/Adaptor3d_CurveOnSurface.hxx index 5ef2120604..0b3a5b5bf7 100644 --- a/src/ModelingData/TKG3d/Adaptor3d/Adaptor3d_CurveOnSurface.hxx +++ b/src/ModelingData/TKG3d/Adaptor3d/Adaptor3d_CurveOnSurface.hxx @@ -96,40 +96,20 @@ public: Standard_EXPORT double Period() const override; - //! Computes the point of parameter U on the curve. - Standard_EXPORT gp_Pnt Value(const double U) const override; + //! Point evaluation. Raises an exception on failure. + [[nodiscard]] Standard_EXPORT gp_Pnt EvalD0(const double theU) const final; - //! Computes the point of parameter U on the curve. - Standard_EXPORT void D0(const double U, gp_Pnt& P) const override; + //! D1 evaluation. Raises an exception on failure. + [[nodiscard]] Standard_EXPORT Geom_Curve::ResD1 EvalD1(const double theU) const final; - //! Computes the point of parameter U on the curve with its - //! first derivative. - //! Raised if the continuity of the current interval - //! is not C1. - Standard_EXPORT void D1(const double U, gp_Pnt& P, gp_Vec& V) const override; + //! D2 evaluation. Raises an exception on failure. + [[nodiscard]] Standard_EXPORT Geom_Curve::ResD2 EvalD2(const double theU) const final; - //! Returns the point P of parameter U, the first and second - //! derivatives V1 and V2. - //! Raised if the continuity of the current interval - //! is not C2. - Standard_EXPORT void D2(const double U, gp_Pnt& P, gp_Vec& V1, gp_Vec& V2) const override; + //! D3 evaluation. Raises an exception on failure. + [[nodiscard]] Standard_EXPORT Geom_Curve::ResD3 EvalD3(const double theU) const final; - //! Returns the point P of parameter U, the first, the second - //! and the third derivative. - //! Raised if the continuity of the current interval - //! is not C3. - Standard_EXPORT void D3(const double U, - gp_Pnt& P, - gp_Vec& V1, - gp_Vec& V2, - gp_Vec& V3) const override; - - //! The returned vector gives the value of the derivative for the - //! order of derivation N. - //! Raised if the continuity of the current interval - //! is not CN. - //! Raised if N < 1. - Standard_EXPORT gp_Vec DN(const double U, const int N) const override; + //! DN evaluation. Raises an exception on failure. + [[nodiscard]] Standard_EXPORT gp_Vec EvalDN(const double theU, const int theN) const final; //! Returns the parametric resolution corresponding //! to the real space resolution . diff --git a/src/ModelingData/TKG3d/Adaptor3d/Adaptor3d_IsoCurve.cxx b/src/ModelingData/TKG3d/Adaptor3d/Adaptor3d_IsoCurve.cxx index 55198e0bce..a6e3b54015 100644 --- a/src/ModelingData/TKG3d/Adaptor3d/Adaptor3d_IsoCurve.cxx +++ b/src/ModelingData/TKG3d/Adaptor3d/Adaptor3d_IsoCurve.cxx @@ -19,6 +19,7 @@ #include #include #include +#include #include #include #include @@ -359,151 +360,93 @@ double Adaptor3d_IsoCurve::Period() const //================================================================================================= -gp_Pnt Adaptor3d_IsoCurve::Value(const double T) const +gp_Pnt Adaptor3d_IsoCurve::EvalD0(double theT) const { switch (myIso) { - case GeomAbs_IsoU: - return mySurface->Value(myParameter, T); - + return mySurface->EvalD0(myParameter, theT); case GeomAbs_IsoV: - return mySurface->Value(T, myParameter); - - case GeomAbs_NoneIso: { + return mySurface->EvalD0(theT, myParameter); + case GeomAbs_NoneIso: throw Standard_NoSuchObject("Adaptor3d_IsoCurve:NoneIso"); - break; - } } - // portage WNT return gp_Pnt(); } //================================================================================================= -void Adaptor3d_IsoCurve::D0(const double T, gp_Pnt& P) const +Geom_Curve::ResD1 Adaptor3d_IsoCurve::EvalD1(double theT) const { switch (myIso) { - - case GeomAbs_IsoU: - mySurface->D0(myParameter, T, P); - break; - - case GeomAbs_IsoV: - mySurface->D0(T, myParameter, P); - break; - - case GeomAbs_NoneIso: - throw Standard_NoSuchObject("Adaptor3d_IsoCurve:NoneIso"); - break; - } -} - -//================================================================================================= - -void Adaptor3d_IsoCurve::D1(const double T, gp_Pnt& P, gp_Vec& V) const -{ - gp_Vec dummy; - switch (myIso) - { - - case GeomAbs_IsoU: - mySurface->D1(myParameter, T, P, dummy, V); - break; - - case GeomAbs_IsoV: - mySurface->D1(T, myParameter, P, V, dummy); - break; - - case GeomAbs_NoneIso: - throw Standard_NoSuchObject("Adaptor3d_IsoCurve:NoneIso"); - break; - } -} - -//================================================================================================= - -void Adaptor3d_IsoCurve::D2(const double T, gp_Pnt& P, gp_Vec& V1, gp_Vec& V2) const -{ - gp_Vec dummy1, dummy2, dummy3; - switch (myIso) - { - - case GeomAbs_IsoU: - mySurface->D2(myParameter, T, P, dummy1, V1, dummy2, V2, dummy3); - break; - case GeomAbs_IsoV: - mySurface->D2(T, myParameter, P, V1, dummy1, V2, dummy2, dummy3); - break; - case GeomAbs_NoneIso: - throw Standard_NoSuchObject("Adaptor3d_IsoCurve:NoneIso"); - break; - } -} - -//================================================================================================= - -void Adaptor3d_IsoCurve::D3(const double T, gp_Pnt& P, gp_Vec& V1, gp_Vec& V2, gp_Vec& V3) const -{ - gp_Vec dummy[6]; - switch (myIso) - { - - case GeomAbs_IsoU: - mySurface->D3(myParameter, - T, - P, - dummy[0], - V1, - dummy[1], - V2, - dummy[2], - dummy[3], - V3, - dummy[4], - dummy[5]); - break; - - case GeomAbs_IsoV: - mySurface->D3(T, - myParameter, - P, - V1, - dummy[0], - V2, - dummy[1], - dummy[2], - V3, - dummy[3], - dummy[4], - dummy[5]); - break; - - case GeomAbs_NoneIso: - throw Standard_NoSuchObject("Adaptor3d_IsoCurve:NoneIso"); - break; - } -} - -//================================================================================================= - -gp_Vec Adaptor3d_IsoCurve::DN(const double T, const int N) const -{ - switch (myIso) - { - - case GeomAbs_IsoU: - return mySurface->DN(myParameter, T, 0, N); - case GeomAbs_IsoV: - return mySurface->DN(T, myParameter, N, 0); - case GeomAbs_NoneIso: { - throw Standard_NoSuchObject("Adaptor3d_IsoCurve:NoneIso"); - break; + case GeomAbs_IsoU: { + const Geom_Surface::ResD1 aRes = mySurface->EvalD1(myParameter, theT); + return {aRes.Point, aRes.D1V}; } + case GeomAbs_IsoV: { + const Geom_Surface::ResD1 aRes = mySurface->EvalD1(theT, myParameter); + return {aRes.Point, aRes.D1U}; + } + case GeomAbs_NoneIso: + throw Standard_NoSuchObject("Adaptor3d_IsoCurve:NoneIso"); } + return {}; +} - // portage WNT +//================================================================================================= + +Geom_Curve::ResD2 Adaptor3d_IsoCurve::EvalD2(double theT) const +{ + switch (myIso) + { + case GeomAbs_IsoU: { + const Geom_Surface::ResD2 aRes = mySurface->EvalD2(myParameter, theT); + return {aRes.Point, aRes.D1V, aRes.D2V}; + } + case GeomAbs_IsoV: { + const Geom_Surface::ResD2 aRes = mySurface->EvalD2(theT, myParameter); + return {aRes.Point, aRes.D1U, aRes.D2U}; + } + case GeomAbs_NoneIso: + throw Standard_NoSuchObject("Adaptor3d_IsoCurve:NoneIso"); + } + return {}; +} + +//================================================================================================= + +Geom_Curve::ResD3 Adaptor3d_IsoCurve::EvalD3(double theT) const +{ + switch (myIso) + { + case GeomAbs_IsoU: { + const Geom_Surface::ResD3 aRes = mySurface->EvalD3(myParameter, theT); + return {aRes.Point, aRes.D1V, aRes.D2V, aRes.D3V}; + } + case GeomAbs_IsoV: { + const Geom_Surface::ResD3 aRes = mySurface->EvalD3(theT, myParameter); + return {aRes.Point, aRes.D1U, aRes.D2U, aRes.D3U}; + } + case GeomAbs_NoneIso: + throw Standard_NoSuchObject("Adaptor3d_IsoCurve:NoneIso"); + } + return {}; +} + +//================================================================================================= + +gp_Vec Adaptor3d_IsoCurve::EvalDN(double theT, int theN) const +{ + switch (myIso) + { + case GeomAbs_IsoU: + return mySurface->EvalDN(myParameter, theT, 0, theN); + case GeomAbs_IsoV: + return mySurface->EvalDN(theT, myParameter, theN, 0); + case GeomAbs_NoneIso: + throw Standard_NoSuchObject("Adaptor3d_IsoCurve:NoneIso"); + } return gp_Vec(); } diff --git a/src/ModelingData/TKG3d/Adaptor3d/Adaptor3d_IsoCurve.hxx b/src/ModelingData/TKG3d/Adaptor3d/Adaptor3d_IsoCurve.hxx index 4ef32f3d91..471ed958f2 100644 --- a/src/ModelingData/TKG3d/Adaptor3d/Adaptor3d_IsoCurve.hxx +++ b/src/ModelingData/TKG3d/Adaptor3d/Adaptor3d_IsoCurve.hxx @@ -18,6 +18,7 @@ #define _Adaptor3d_IsoCurve_HeaderFile #include +#include #include //! Defines an isoparametric curve on a surface. The @@ -104,39 +105,25 @@ public: Standard_EXPORT double Period() const override; - //! Computes the point of parameter U on the curve. - Standard_EXPORT gp_Pnt Value(const double U) const override; + //! Computes the point of parameter theU on the curve. + [[nodiscard]] Standard_EXPORT gp_Pnt EvalD0(double theU) const final; - //! Computes the point of parameter U on the curve. - Standard_EXPORT void D0(const double U, gp_Pnt& P) const override; + //! Computes the point of parameter theU on the curve with its first derivative. + //! Raised if the continuity of the current interval is not C1. + [[nodiscard]] Standard_EXPORT Geom_Curve::ResD1 EvalD1(double theU) const final; - //! Computes the point of parameter U on the curve with its - //! first derivative. - //! Raised if the continuity of the current interval - //! is not C1. - Standard_EXPORT void D1(const double U, gp_Pnt& P, gp_Vec& V) const override; + //! Returns the point and the first and second derivatives at parameter theU. + //! Raised if the continuity of the current interval is not C2. + [[nodiscard]] Standard_EXPORT Geom_Curve::ResD2 EvalD2(double theU) const final; - //! Returns the point P of parameter U, the first and second - //! derivatives V1 and V2. - //! Raised if the continuity of the current interval - //! is not C2. - Standard_EXPORT void D2(const double U, gp_Pnt& P, gp_Vec& V1, gp_Vec& V2) const override; + //! Returns the point and the first, second and third derivatives at parameter theU. + //! Raised if the continuity of the current interval is not C3. + [[nodiscard]] Standard_EXPORT Geom_Curve::ResD3 EvalD3(double theU) const final; - //! Returns the point P of parameter U, the first, the second - //! and the third derivative. - //! Raised if the continuity of the current interval - //! is not C3. - Standard_EXPORT void D3(const double U, - gp_Pnt& P, - gp_Vec& V1, - gp_Vec& V2, - gp_Vec& V3) const override; - - //! The returned vector gives the value of the derivative for the - //! order of derivation N. + //! Returns the derivative of order theN at parameter theU. //! Raised if the continuity of the current interval is not CN. - //! Raised if N < 1. - Standard_EXPORT gp_Vec DN(const double U, const int N) const override; + //! Raised if theN < 1. + [[nodiscard]] Standard_EXPORT gp_Vec EvalDN(double theU, int theN) const final; //! Returns the parametric resolution corresponding //! to the real space resolution . diff --git a/src/ModelingData/TKG3d/Adaptor3d/Adaptor3d_Surface.cxx b/src/ModelingData/TKG3d/Adaptor3d/Adaptor3d_Surface.cxx index bb58d774f5..caec36d042 100644 --- a/src/ModelingData/TKG3d/Adaptor3d/Adaptor3d_Surface.cxx +++ b/src/ModelingData/TKG3d/Adaptor3d/Adaptor3d_Surface.cxx @@ -184,77 +184,6 @@ double Adaptor3d_Surface::VPeriod() const //================================================================================================= -// gp_Pnt Adaptor3d_Surface::Value(const double U, const double V) const -gp_Pnt Adaptor3d_Surface::Value(const double, const double) const -{ - throw Standard_NotImplemented("Adaptor3d_Surface::Value"); -} - -//================================================================================================= - -// void Adaptor3d_Surface::D0(const double U, const double V, gp_Pnt& P) const -void Adaptor3d_Surface::D0(const double, const double, gp_Pnt&) const -{ - throw Standard_NotImplemented("Adaptor3d_Surface::D0"); -} - -//================================================================================================= - -// void Adaptor3d_Surface::D1(const double U, const double V, gp_Pnt& P, gp_Vec& D1U, -// gp_Vec& D1V) const -void Adaptor3d_Surface::D1(const double, const double, gp_Pnt&, gp_Vec&, gp_Vec&) const -{ - throw Standard_NotImplemented("Adaptor3d_Surface::D1"); -} - -//================================================================================================= - -// void Adaptor3d_Surface::D2(const double U, const double V, gp_Pnt& P, gp_Vec& D1U, -// gp_Vec& D1V, gp_Vec& D2U, gp_Vec& D2V, gp_Vec& D2UV) const -void Adaptor3d_Surface::D2(const double, - const double, - gp_Pnt&, - gp_Vec&, - gp_Vec&, - gp_Vec&, - gp_Vec&, - gp_Vec&) const -{ - throw Standard_NotImplemented("Adaptor3d_Surface::D2"); -} - -//================================================================================================= - -// void Adaptor3d_Surface::D3(const double U, const double V, gp_Pnt& P, gp_Vec& D1U, -// gp_Vec& D1V, gp_Vec& D2U, gp_Vec& D2V, gp_Vec& D2UV, gp_Vec& D3U, gp_Vec& D3V, gp_Vec& D3UUV, -// gp_Vec& D3UVV) const -void Adaptor3d_Surface::D3(const double, - const double, - gp_Pnt&, - gp_Vec&, - gp_Vec&, - gp_Vec&, - gp_Vec&, - gp_Vec&, - gp_Vec&, - gp_Vec&, - gp_Vec&, - gp_Vec&) const -{ - throw Standard_NotImplemented("Adaptor3d_Surface::D3"); -} - -//================================================================================================= - -// gp_Vec Adaptor3d_Surface::DN(const double U, const double V, const int -// Nu, const int Nv) const -gp_Vec Adaptor3d_Surface::DN(const double, const double, const int, const int) const -{ - throw Standard_NotImplemented("Adaptor3d_Surface::DN"); -} - -//================================================================================================= - // double Adaptor3d_Surface::UResolution(const double R3d) const double Adaptor3d_Surface::UResolution(const double) const { @@ -418,54 +347,35 @@ double Adaptor3d_Surface::OffsetValue() const //================================================================================================= -gp_Pnt Adaptor3d_Surface::EvalD0(double theU, double theV) const +gp_Pnt Adaptor3d_Surface::EvalD0(double, double) const { - gp_Pnt aP; - D0(theU, theV, aP); - return aP; + throw Standard_NotImplemented("Adaptor3d_Surface::EvalD0"); } //================================================================================================= -Geom_Surface::ResD1 Adaptor3d_Surface::EvalD1(double theU, double theV) const +Geom_Surface::ResD1 Adaptor3d_Surface::EvalD1(double, double) const { - Geom_Surface::ResD1 aResult; - D1(theU, theV, aResult.Point, aResult.D1U, aResult.D1V); - return aResult; + throw Standard_NotImplemented("Adaptor3d_Surface::EvalD1"); } //================================================================================================= -Geom_Surface::ResD2 Adaptor3d_Surface::EvalD2(double theU, double theV) const +Geom_Surface::ResD2 Adaptor3d_Surface::EvalD2(double, double) const { - Geom_Surface::ResD2 aResult; - D2(theU, theV, aResult.Point, aResult.D1U, aResult.D1V, aResult.D2U, aResult.D2V, aResult.D2UV); - return aResult; + throw Standard_NotImplemented("Adaptor3d_Surface::EvalD2"); } //================================================================================================= -Geom_Surface::ResD3 Adaptor3d_Surface::EvalD3(double theU, double theV) const +Geom_Surface::ResD3 Adaptor3d_Surface::EvalD3(double, double) const { - Geom_Surface::ResD3 aResult; - D3(theU, - theV, - aResult.Point, - aResult.D1U, - aResult.D1V, - aResult.D2U, - aResult.D2V, - aResult.D2UV, - aResult.D3U, - aResult.D3V, - aResult.D3UUV, - aResult.D3UVV); - return aResult; + throw Standard_NotImplemented("Adaptor3d_Surface::EvalD3"); } //================================================================================================= -gp_Vec Adaptor3d_Surface::EvalDN(double theU, double theV, int theNu, int theNv) const +gp_Vec Adaptor3d_Surface::EvalDN(double, double, int, int) const { - return DN(theU, theV, theNu, theNv); + throw Standard_NotImplemented("Adaptor3d_Surface::EvalDN"); } diff --git a/src/ModelingData/TKG3d/Adaptor3d/Adaptor3d_Surface.hxx b/src/ModelingData/TKG3d/Adaptor3d/Adaptor3d_Surface.hxx index 2d8946aa4e..8eac2f13cf 100644 --- a/src/ModelingData/TKG3d/Adaptor3d/Adaptor3d_Surface.hxx +++ b/src/ModelingData/TKG3d/Adaptor3d/Adaptor3d_Surface.hxx @@ -122,60 +122,84 @@ public: //! Computes the point of parameters U,V on the surface. //! Tip: use GeomLib::NormEstim() to calculate surface normal at specified (U, V) point. - Standard_EXPORT virtual gp_Pnt Value(const double U, const double V) const; + gp_Pnt Value(const double theU, const double theV) const { return EvalD0(theU, theV); } //! Computes the point of parameters U,V on the surface. - Standard_EXPORT virtual void D0(const double U, const double V, gp_Pnt& P) const; + void D0(const double theU, const double theV, gp_Pnt& theP) const { theP = EvalD0(theU, theV); } //! Computes the point and the first derivatives on the surface. //! Raised if the continuity of the current intervals is not C1. //! //! Tip: use GeomLib::NormEstim() to calculate surface normal at specified (U, V) point. - Standard_EXPORT virtual void D1(const double U, - const double V, - gp_Pnt& P, - gp_Vec& D1U, - gp_Vec& D1V) const; + void D1(const double theU, const double theV, gp_Pnt& theP, gp_Vec& theD1U, gp_Vec& theD1V) const + { + const Geom_Surface::ResD1 aRes = EvalD1(theU, theV); + theP = aRes.Point; + theD1U = aRes.D1U; + theD1V = aRes.D1V; + } //! Computes the point, the first and second //! derivatives on the surface. //! Raised if the continuity of the current //! intervals is not C2. - Standard_EXPORT virtual void D2(const double U, - const double V, - gp_Pnt& P, - gp_Vec& D1U, - gp_Vec& D1V, - gp_Vec& D2U, - gp_Vec& D2V, - gp_Vec& D2UV) const; + void D2(const double theU, + const double theV, + gp_Pnt& theP, + gp_Vec& theD1U, + gp_Vec& theD1V, + gp_Vec& theD2U, + gp_Vec& theD2V, + gp_Vec& theD2UV) const + { + const Geom_Surface::ResD2 aRes = EvalD2(theU, theV); + theP = aRes.Point; + theD1U = aRes.D1U; + theD1V = aRes.D1V; + theD2U = aRes.D2U; + theD2V = aRes.D2V; + theD2UV = aRes.D2UV; + } //! Computes the point, the first, second and third //! derivatives on the surface. //! Raised if the continuity of the current //! intervals is not C3. - Standard_EXPORT virtual void D3(const double U, - const double V, - gp_Pnt& P, - gp_Vec& D1U, - gp_Vec& D1V, - gp_Vec& D2U, - gp_Vec& D2V, - gp_Vec& D2UV, - gp_Vec& D3U, - gp_Vec& D3V, - gp_Vec& D3UUV, - gp_Vec& D3UVV) const; + void D3(const double theU, + const double theV, + gp_Pnt& theP, + gp_Vec& theD1U, + gp_Vec& theD1V, + gp_Vec& theD2U, + gp_Vec& theD2V, + gp_Vec& theD2UV, + gp_Vec& theD3U, + gp_Vec& theD3V, + gp_Vec& theD3UUV, + gp_Vec& theD3UVV) const + { + const Geom_Surface::ResD3 aRes = EvalD3(theU, theV); + theP = aRes.Point; + theD1U = aRes.D1U; + theD1V = aRes.D1V; + theD2U = aRes.D2U; + theD2V = aRes.D2V; + theD2UV = aRes.D2UV; + theD3U = aRes.D3U; + theD3V = aRes.D3V; + theD3UUV = aRes.D3UUV; + theD3UVV = aRes.D3UVV; + } //! Computes the derivative of order Nu in the direction U and Nv //! in the direction V at the point P(U, V). //! Raised if the current U interval is not not CNu //! and the current V interval is not CNv. //! Raised if Nu + Nv < 1 or Nu < 0 or Nv < 0. - Standard_EXPORT virtual gp_Vec DN(const double U, - const double V, - const int Nu, - const int Nv) const; + gp_Vec DN(const double theU, const double theV, const int theNu, const int theNv) const + { + return EvalDN(theU, theV, theNu, theNv); + } //! Returns the parametric U resolution corresponding //! to the real space resolution . diff --git a/src/ModelingData/TKG3d/GTests/FILES.cmake b/src/ModelingData/TKG3d/GTests/FILES.cmake index 75951a4c51..428e837c48 100644 --- a/src/ModelingData/TKG3d/GTests/FILES.cmake +++ b/src/ModelingData/TKG3d/GTests/FILES.cmake @@ -27,6 +27,7 @@ set(OCCT_TKG3d_GTests_FILES GeomEval_TBezierSurface_Test.cxx GeomAPI_ExtremaCurveCurve_Test.cxx GeomAPI_Interpolate_Test.cxx + GeomAdaptor_TransformedCurve_Test.cxx GeomGridEval_BezierCurve_Test.cxx GeomGridEval_BezierSurface_Test.cxx GeomGridEval_BSplineSurface_Test.cxx diff --git a/src/ModelingData/TKG3d/GTests/GeomAdaptor_TransformedCurve_Test.cxx b/src/ModelingData/TKG3d/GTests/GeomAdaptor_TransformedCurve_Test.cxx new file mode 100644 index 0000000000..ab5cebf513 --- /dev/null +++ b/src/ModelingData/TKG3d/GTests/GeomAdaptor_TransformedCurve_Test.cxx @@ -0,0 +1,367 @@ +// Copyright (c) 2025 OPEN CASCADE SAS +// +// This file is part of Open CASCADE Technology software library. +// +// This library is free software; you can redistribute it and/or modify it under +// the terms of the GNU Lesser General Public License version 2.1 as published +// by the Free Software Foundation, with special exception defined in the file +// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT +// distribution for complete text of the license and disclaimer of any warranty. +// +// Alternatively, this file may be used under the terms of Open CASCADE +// commercial license or contractual agreement. + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include + +namespace +{ +const double THE_TOLERANCE = 1e-10; + +//! Helper function to create uniform parameters. +NCollection_Array1 CreateUniformParams(double theFirst, double theLast, int theNbPoints) +{ + NCollection_Array1 aParams(1, theNbPoints); + const double aStep = (theLast - theFirst) / (theNbPoints - 1); + for (int i = 1; i <= theNbPoints; ++i) + { + aParams.SetValue(i, theFirst + (i - 1) * aStep); + } + return aParams; +} + +//! Helper function to create a translation transformation. +gp_Trsf CreateTranslation(double theDx, double theDy, double theDz) +{ + gp_Trsf aTrsf; + aTrsf.SetTranslation(gp_Vec(theDx, theDy, theDz)); + return aTrsf; +} + +//! Helper function to create a rotation transformation around Z axis. +gp_Trsf CreateRotationZ(double theAngleRad) +{ + gp_Trsf aTrsf; + aTrsf.SetRotation(gp_Ax1(gp_Pnt(0, 0, 0), gp_Dir(0, 0, 1)), theAngleRad); + return aTrsf; +} +} // namespace + +//================================================================================================== +// Tests for GeomAdaptor_TransformedCurve construction +//================================================================================================== + +TEST(GeomAdaptor_TransformedCurveTest, DefaultConstructor) +{ + GeomAdaptor_TransformedCurve aCurve; + EXPECT_TRUE(aCurve.Is3DCurve()); + EXPECT_FALSE(aCurve.IsCurveOnSurface()); + EXPECT_EQ(aCurve.Trsf().Form(), gp_Identity); +} + +TEST(GeomAdaptor_TransformedCurveTest, ConstructWithCurveAndTrsf) +{ + occ::handle aLine = new Geom_Line(gp_Pnt(0, 0, 0), gp_Dir(1, 0, 0)); + gp_Trsf aTrsf = CreateTranslation(0, 0, 5); + + GeomAdaptor_TransformedCurve aCurve(aLine, aTrsf); + EXPECT_TRUE(aCurve.Is3DCurve()); + EXPECT_EQ(aCurve.GetType(), GeomAbs_Line); + EXPECT_EQ(aCurve.Trsf().Form(), gp_Translation); +} + +TEST(GeomAdaptor_TransformedCurveTest, ConstructWithBounds) +{ + occ::handle aLine = new Geom_Line(gp_Pnt(0, 0, 0), gp_Dir(1, 0, 0)); + gp_Trsf aTrsf = CreateTranslation(0, 0, 5); + + GeomAdaptor_TransformedCurve aCurve(aLine, 0.0, 10.0, aTrsf); + EXPECT_NEAR(aCurve.FirstParameter(), 0.0, THE_TOLERANCE); + EXPECT_NEAR(aCurve.LastParameter(), 10.0, THE_TOLERANCE); +} + +//================================================================================================== +// Tests for evaluation with identity transform +//================================================================================================== + +TEST(GeomAdaptor_TransformedCurveTest, Line_IdentityTransform) +{ + occ::handle aLine = new Geom_Line(gp_Pnt(1, 2, 3), gp_Dir(1, 0, 0)); + gp_Trsf aTrsf; // identity + + GeomAdaptor_TransformedCurve aCurve(aLine, aTrsf); + + // With identity transform, results should match direct Geom_Line evaluation + const double aT = 5.0; + gp_Pnt aPnt = aCurve.Value(aT); + gp_Pnt aExpected = aLine->Value(aT); + EXPECT_NEAR(aPnt.Distance(aExpected), 0.0, THE_TOLERANCE); +} + +TEST(GeomAdaptor_TransformedCurveTest, Circle_IdentityTransform) +{ + occ::handle aCircle = new Geom_Circle(gp_Ax2(gp_Pnt(0, 0, 0), gp_Dir(0, 0, 1)), 2.0); + gp_Trsf aTrsf; // identity + + GeomAdaptor_TransformedCurve aCurve(aCircle, aTrsf); + EXPECT_EQ(aCurve.GetType(), GeomAbs_Circle); + + NCollection_Array1 aParams(1, 5); + aParams.SetValue(1, 0.0); + aParams.SetValue(2, M_PI / 2); + aParams.SetValue(3, M_PI); + aParams.SetValue(4, 3 * M_PI / 2); + aParams.SetValue(5, 2 * M_PI); + + for (int i = 1; i <= 5; ++i) + { + gp_Pnt aPnt = aCurve.Value(aParams.Value(i)); + gp_Pnt aExpected = aCircle->Value(aParams.Value(i)); + EXPECT_NEAR(aPnt.Distance(aExpected), 0.0, THE_TOLERANCE); + } +} + +//================================================================================================== +// Tests for evaluation with non-identity transform +//================================================================================================== + +TEST(GeomAdaptor_TransformedCurveTest, Line_Translation) +{ + occ::handle aLine = new Geom_Line(gp_Pnt(0, 0, 0), gp_Dir(1, 0, 0)); + gp_Trsf aTrsf = CreateTranslation(0, 0, 5); + + GeomAdaptor_TransformedCurve aCurve(aLine, aTrsf); + + // Line along X at Z=0, translated to Z=5 + gp_Pnt aPnt = aCurve.Value(3.0); + EXPECT_NEAR(aPnt.X(), 3.0, THE_TOLERANCE); + EXPECT_NEAR(aPnt.Y(), 0.0, THE_TOLERANCE); + EXPECT_NEAR(aPnt.Z(), 5.0, THE_TOLERANCE); +} + +TEST(GeomAdaptor_TransformedCurveTest, Line_Rotation) +{ + occ::handle aLine = new Geom_Line(gp_Pnt(0, 0, 0), gp_Dir(1, 0, 0)); + gp_Trsf aTrsf = CreateRotationZ(M_PI / 2); + + GeomAdaptor_TransformedCurve aCurve(aLine, aTrsf); + + // Line along X rotated 90 degrees -> line along Y + gp_Pnt aPnt = aCurve.Value(3.0); + EXPECT_NEAR(aPnt.X(), 0.0, THE_TOLERANCE); + EXPECT_NEAR(aPnt.Y(), 3.0, THE_TOLERANCE); + EXPECT_NEAR(aPnt.Z(), 0.0, THE_TOLERANCE); +} + +TEST(GeomAdaptor_TransformedCurveTest, Circle_Translation) +{ + occ::handle aCircle = new Geom_Circle(gp_Ax2(gp_Pnt(0, 0, 0), gp_Dir(0, 0, 1)), 2.0); + gp_Trsf aTrsf = CreateTranslation(10, 20, 30); + + GeomAdaptor_TransformedCurve aCurve(aCircle, aTrsf); + + NCollection_Array1 aParams = CreateUniformParams(0.0, 2 * M_PI, 17); + + for (int i = 1; i <= 17; ++i) + { + gp_Pnt aPnt = aCurve.Value(aParams.Value(i)); + gp_Pnt aLocal = aCircle->Value(aParams.Value(i)); + gp_Pnt aExpected(aLocal.X() + 10, aLocal.Y() + 20, aLocal.Z() + 30); + EXPECT_NEAR(aPnt.Distance(aExpected), 0.0, THE_TOLERANCE); + } +} + +//================================================================================================== +// Tests for derivative evaluation with transform +//================================================================================================== + +TEST(GeomAdaptor_TransformedCurveTest, D1_Translation) +{ + occ::handle aCircle = new Geom_Circle(gp_Ax2(gp_Pnt(0, 0, 0), gp_Dir(0, 0, 1)), 2.0); + gp_Trsf aTrsf = CreateTranslation(10, 20, 30); + + GeomAdaptor_TransformedCurve aCurve(aCircle, aTrsf); + + NCollection_Array1 aParams = CreateUniformParams(0.0, 2 * M_PI, 9); + + for (int i = 1; i <= 9; ++i) + { + gp_Pnt aPnt; + gp_Vec aD1; + aCurve.D1(aParams.Value(i), aPnt, aD1); + + // Point should be translated + gp_Pnt aLocalPnt = aCircle->Value(aParams.Value(i)); + gp_Pnt aExpectedPnt(aLocalPnt.X() + 10, aLocalPnt.Y() + 20, aLocalPnt.Z() + 30); + EXPECT_NEAR(aPnt.Distance(aExpectedPnt), 0.0, THE_TOLERANCE); + + // D1 vector: translation doesn't change vectors, so should match local D1 + gp_Pnt aLocalP; + gp_Vec aLocalD1; + aCircle->D1(aParams.Value(i), aLocalP, aLocalD1); + EXPECT_NEAR((aD1 - aLocalD1).Magnitude(), 0.0, THE_TOLERANCE); + } +} + +TEST(GeomAdaptor_TransformedCurveTest, D1_Rotation) +{ + occ::handle aLine = new Geom_Line(gp_Pnt(0, 0, 0), gp_Dir(1, 0, 0)); + gp_Trsf aTrsf = CreateRotationZ(M_PI / 2); + + GeomAdaptor_TransformedCurve aCurve(aLine, aTrsf); + + gp_Pnt aPnt; + gp_Vec aD1; + aCurve.D1(3.0, aPnt, aD1); + + // D1 for line along X is (1,0,0), rotated 90 degrees becomes (0,1,0) + EXPECT_NEAR(aD1.X(), 0.0, THE_TOLERANCE); + EXPECT_NEAR(aD1.Y(), 1.0, THE_TOLERANCE); + EXPECT_NEAR(aD1.Z(), 0.0, THE_TOLERANCE); +} + +TEST(GeomAdaptor_TransformedCurveTest, D2_Translation) +{ + occ::handle aCircle = new Geom_Circle(gp_Ax2(gp_Pnt(0, 0, 0), gp_Dir(0, 0, 1)), 2.0); + gp_Trsf aTrsf = CreateTranslation(10, 20, 30); + + GeomAdaptor_TransformedCurve aCurve(aCircle, aTrsf); + + NCollection_Array1 aParams = CreateUniformParams(0.0, 2 * M_PI, 9); + + for (int i = 1; i <= 9; ++i) + { + gp_Pnt aPnt; + gp_Vec aD1, aD2; + aCurve.D2(aParams.Value(i), aPnt, aD1, aD2); + + gp_Pnt aLocalP; + gp_Vec aLocalD1, aLocalD2; + aCircle->D2(aParams.Value(i), aLocalP, aLocalD1, aLocalD2); + + EXPECT_NEAR((aD1 - aLocalD1).Magnitude(), 0.0, THE_TOLERANCE); + EXPECT_NEAR((aD2 - aLocalD2).Magnitude(), 0.0, THE_TOLERANCE); + } +} + +TEST(GeomAdaptor_TransformedCurveTest, D3_Rotation) +{ + occ::handle aCircle = new Geom_Circle(gp_Ax2(gp_Pnt(0, 0, 0), gp_Dir(0, 0, 1)), 2.0); + gp_Trsf aTrsf = CreateRotationZ(M_PI / 4); + + GeomAdaptor_TransformedCurve aCurve(aCircle, aTrsf); + + NCollection_Array1 aParams = CreateUniformParams(0.0, 2 * M_PI, 9); + + for (int i = 1; i <= 9; ++i) + { + gp_Pnt aPnt; + gp_Vec aD1, aD2, aD3; + aCurve.D3(aParams.Value(i), aPnt, aD1, aD2, aD3); + + // Get local values and transform manually + gp_Pnt aLocalP; + gp_Vec aLocalD1, aLocalD2, aLocalD3; + aCircle->D3(aParams.Value(i), aLocalP, aLocalD1, aLocalD2, aLocalD3); + aLocalP.Transform(aTrsf); + aLocalD1.Transform(aTrsf); + aLocalD2.Transform(aTrsf); + aLocalD3.Transform(aTrsf); + + EXPECT_NEAR(aPnt.Distance(aLocalP), 0.0, THE_TOLERANCE); + EXPECT_NEAR((aD1 - aLocalD1).Magnitude(), 0.0, THE_TOLERANCE); + EXPECT_NEAR((aD2 - aLocalD2).Magnitude(), 0.0, THE_TOLERANCE); + EXPECT_NEAR((aD3 - aLocalD3).Magnitude(), 0.0, THE_TOLERANCE); + } +} + +TEST(GeomAdaptor_TransformedCurveTest, DN_Rotation) +{ + occ::handle aCircle = new Geom_Circle(gp_Ax2(gp_Pnt(0, 0, 0), gp_Dir(0, 0, 1)), 2.0); + gp_Trsf aTrsf = CreateRotationZ(M_PI / 3); + + GeomAdaptor_TransformedCurve aCurve(aCircle, aTrsf); + + for (int aOrder = 1; aOrder <= 3; ++aOrder) + { + gp_Vec aResult = aCurve.DN(1.0, aOrder); + gp_Vec aExpected = aCircle->DN(1.0, aOrder); + aExpected.Transform(aTrsf); + EXPECT_NEAR((aResult - aExpected).Magnitude(), 0.0, THE_TOLERANCE); + } +} + +//================================================================================================== +// Tests for geometry extraction with transform +//================================================================================================== + +TEST(GeomAdaptor_TransformedCurveTest, LineExtraction_Transform) +{ + occ::handle aLine = new Geom_Line(gp_Pnt(0, 0, 0), gp_Dir(1, 0, 0)); + gp_Trsf aTrsf = CreateTranslation(0, 0, 5); + + GeomAdaptor_TransformedCurve aCurve(aLine, aTrsf); + + gp_Lin aExtracted = aCurve.Line(); + + // Line should be translated: origin at (0,0,5), direction unchanged + EXPECT_NEAR(aExtracted.Location().X(), 0.0, THE_TOLERANCE); + EXPECT_NEAR(aExtracted.Location().Y(), 0.0, THE_TOLERANCE); + EXPECT_NEAR(aExtracted.Location().Z(), 5.0, THE_TOLERANCE); + EXPECT_NEAR(aExtracted.Direction().X(), 1.0, THE_TOLERANCE); +} + +TEST(GeomAdaptor_TransformedCurveTest, CircleExtraction_Transform) +{ + occ::handle aCircle = new Geom_Circle(gp_Ax2(gp_Pnt(0, 0, 0), gp_Dir(0, 0, 1)), 2.0); + gp_Trsf aTrsf = CreateTranslation(10, 0, 0); + + GeomAdaptor_TransformedCurve aCurve(aCircle, aTrsf); + + gp_Circ aExtracted = aCurve.Circle(); + + // Circle center should be translated to (10,0,0) + EXPECT_NEAR(aExtracted.Location().X(), 10.0, THE_TOLERANCE); + EXPECT_NEAR(aExtracted.Location().Y(), 0.0, THE_TOLERANCE); + EXPECT_NEAR(aExtracted.Location().Z(), 0.0, THE_TOLERANCE); + EXPECT_NEAR(aExtracted.Radius(), 2.0, THE_TOLERANCE); +} + +//================================================================================================== +// Tests for ShallowCopy +//================================================================================================== + +TEST(GeomAdaptor_TransformedCurveTest, ShallowCopy) +{ + occ::handle aLine = new Geom_Line(gp_Pnt(0, 0, 0), gp_Dir(1, 0, 0)); + gp_Trsf aTrsf = CreateTranslation(0, 0, 5); + + GeomAdaptor_TransformedCurve aCurve(aLine, 0.0, 10.0, aTrsf); + + occ::handle aCopy = aCurve.ShallowCopy(); + ASSERT_FALSE(aCopy.IsNull()); + + // Copy should evaluate the same + gp_Pnt aPnt1 = aCurve.Value(3.0); + gp_Pnt aPnt2 = aCopy->Value(3.0); + EXPECT_NEAR(aPnt1.Distance(aPnt2), 0.0, THE_TOLERANCE); +} \ No newline at end of file diff --git a/src/ModelingData/TKG3d/Geom/Geom_Curve.cxx b/src/ModelingData/TKG3d/Geom/Geom_Curve.cxx index 3c7d9421e3..8dca4a0b65 100644 --- a/src/ModelingData/TKG3d/Geom/Geom_Curve.cxx +++ b/src/ModelingData/TKG3d/Geom/Geom_Curve.cxx @@ -46,15 +46,6 @@ double Geom_Curve::Period() const //================================================================================================= -gp_Pnt Geom_Curve::Value(const double U) const -{ - gp_Pnt P; - D0(U, P); - return P; -} - -//================================================================================================= - double Geom_Curve::TransformedParameter(const double U, const gp_Trsf&) const { return U; diff --git a/src/ModelingData/TKG3d/Geom/Geom_Curve.hxx b/src/ModelingData/TKG3d/Geom/Geom_Curve.hxx index a3ea8a6d01..18f09b9526 100644 --- a/src/ModelingData/TKG3d/Geom/Geom_Curve.hxx +++ b/src/ModelingData/TKG3d/Geom/Geom_Curve.hxx @@ -243,8 +243,7 @@ public: inline gp_Vec DN(const double U, const int N) const { return EvalDN(U, N); } //! Computes the point of parameter U on . - //! It is implemented with D0. - Standard_EXPORT gp_Pnt Value(const double U) const; + gp_Pnt Value(const double U) const { return EvalD0(U); } //! Dumps the content of me into the stream Standard_EXPORT void DumpJson(Standard_OStream& theOStream, int theDepth = -1) const override; diff --git a/src/ModelingData/TKG3d/Geom/Geom_Surface.cxx b/src/ModelingData/TKG3d/Geom/Geom_Surface.cxx index 030238c720..f2cc49d592 100644 --- a/src/ModelingData/TKG3d/Geom/Geom_Surface.cxx +++ b/src/ModelingData/TKG3d/Geom/Geom_Surface.cxx @@ -82,15 +82,6 @@ double Geom_Surface::VPeriod() const //================================================================================================= -gp_Pnt Geom_Surface::Value(const double U, const double V) const -{ - gp_Pnt P; - D0(U, V, P); - return P; -} - -//================================================================================================= - void Geom_Surface::DumpJson(Standard_OStream& theOStream, int theDepth) const { OCCT_DUMP_TRANSIENT_CLASS_BEGIN(theOStream) diff --git a/src/ModelingData/TKG3d/Geom/Geom_Surface.hxx b/src/ModelingData/TKG3d/Geom/Geom_Surface.hxx index 709d3fdee1..50e3b43d77 100644 --- a/src/ModelingData/TKG3d/Geom/Geom_Surface.hxx +++ b/src/ModelingData/TKG3d/Geom/Geom_Surface.hxx @@ -326,8 +326,8 @@ public: return EvalDN(U, V, Nu, Nv); } - //! Computes the point of parameter (U, V) on the surface. Implemented with D0. - Standard_EXPORT gp_Pnt Value(const double U, const double V) const; + //! Computes the point of parameter (U, V) on the surface. + gp_Pnt Value(const double U, const double V) const { return EvalD0(U, V); } //! Dumps the content of me into the stream Standard_EXPORT void DumpJson(Standard_OStream& theOStream, int theDepth = -1) const override; diff --git a/src/ModelingData/TKG3d/GeomAdaptor/FILES.cmake b/src/ModelingData/TKG3d/GeomAdaptor/FILES.cmake index d4db65237f..2099c5f814 100644 --- a/src/ModelingData/TKG3d/GeomAdaptor/FILES.cmake +++ b/src/ModelingData/TKG3d/GeomAdaptor/FILES.cmake @@ -12,6 +12,8 @@ set(OCCT_GeomAdaptor_FILES GeomAdaptor_SurfaceOfLinearExtrusion.hxx GeomAdaptor_SurfaceOfRevolution.cxx GeomAdaptor_SurfaceOfRevolution.hxx + GeomAdaptor_TransformedCurve.cxx + GeomAdaptor_TransformedCurve.hxx GeomAdaptor_TransformedSurface.cxx GeomAdaptor_TransformedSurface.hxx ) diff --git a/src/ModelingData/TKG3d/GeomAdaptor/GeomAdaptor_Curve.cxx b/src/ModelingData/TKG3d/GeomAdaptor/GeomAdaptor_Curve.cxx index 511b0e46c0..cfdbe817a8 100644 --- a/src/ModelingData/TKG3d/GeomAdaptor/GeomAdaptor_Curve.cxx +++ b/src/ModelingData/TKG3d/GeomAdaptor/GeomAdaptor_Curve.cxx @@ -646,22 +646,6 @@ bool GeomAdaptor_Curve::IsBoundary(const double theU, int& theSpanStart, int& th //================================================================================================= -gp_Pnt GeomAdaptor_Curve::Value(const double U) const -{ - gp_Pnt aValue; - D0(U, aValue); - return aValue; -} - -//================================================================================================= - -void GeomAdaptor_Curve::D0(const double U, gp_Pnt& P) const -{ - P = EvalD0(U); -} - -//================================================================================================= - gp_Pnt GeomAdaptor_Curve::EvalD0(double U) const { gp_Pnt P; @@ -743,15 +727,6 @@ gp_Pnt GeomAdaptor_Curve::EvalD0(double U) const //================================================================================================= -void GeomAdaptor_Curve::D1(const double U, gp_Pnt& P, gp_Vec& V) const -{ - const Geom_Curve::ResD1 aResult = EvalD1(U); - P = aResult.Point; - V = aResult.D1; -} - -//================================================================================================= - Geom_Curve::ResD1 GeomAdaptor_Curve::EvalD1(double U) const { Geom_Curve::ResD1 aResult; @@ -834,16 +809,6 @@ Geom_Curve::ResD1 GeomAdaptor_Curve::EvalD1(double U) const //================================================================================================= -void GeomAdaptor_Curve::D2(const double U, gp_Pnt& P, gp_Vec& V1, gp_Vec& V2) const -{ - const Geom_Curve::ResD2 aResult = EvalD2(U); - P = aResult.Point; - V1 = aResult.D1; - V2 = aResult.D2; -} - -//================================================================================================= - Geom_Curve::ResD2 GeomAdaptor_Curve::EvalD2(double U) const { Geom_Curve::ResD2 aResult; @@ -928,17 +893,6 @@ Geom_Curve::ResD2 GeomAdaptor_Curve::EvalD2(double U) const //================================================================================================= -void GeomAdaptor_Curve::D3(const double U, gp_Pnt& P, gp_Vec& V1, gp_Vec& V2, gp_Vec& V3) const -{ - const Geom_Curve::ResD3 aResult = EvalD3(U); - P = aResult.Point; - V1 = aResult.D1; - V2 = aResult.D2; - V3 = aResult.D3; -} - -//================================================================================================= - Geom_Curve::ResD3 GeomAdaptor_Curve::EvalD3(double U) const { Geom_Curve::ResD3 aResult; @@ -1042,13 +996,6 @@ Geom_Curve::ResD3 GeomAdaptor_Curve::EvalD3(double U) const //================================================================================================= -gp_Vec GeomAdaptor_Curve::DN(const double U, const int N) const -{ - return EvalDN(U, N); -} - -//================================================================================================= - gp_Vec GeomAdaptor_Curve::EvalDN(double U, int N) const { switch (myTypeCurve) diff --git a/src/ModelingData/TKG3d/GeomAdaptor/GeomAdaptor_Curve.hxx b/src/ModelingData/TKG3d/GeomAdaptor/GeomAdaptor_Curve.hxx index aabd1419be..e0fe82fd2b 100644 --- a/src/ModelingData/TKG3d/GeomAdaptor/GeomAdaptor_Curve.hxx +++ b/src/ModelingData/TKG3d/GeomAdaptor/GeomAdaptor_Curve.hxx @@ -173,52 +173,6 @@ public: Standard_EXPORT double Period() const override; - //! Computes the point of parameter U on the curve - Standard_EXPORT gp_Pnt Value(const double U) const final; - - //! Computes the point of parameter U. - Standard_EXPORT void D0(const double U, gp_Pnt& P) const final; - - //! Computes the point of parameter U on the curve - //! with its first derivative. - //! - //! Warning : On the specific case of BSplineCurve: - //! if the curve is cut in interval of continuity at least C1, the - //! derivatives are computed on the current interval. - //! else the derivatives are computed on the basis curve. - Standard_EXPORT void D1(const double U, gp_Pnt& P, gp_Vec& V) const final; - - //! Returns the point P of parameter U, the first and second - //! derivatives V1 and V2. - //! - //! Warning : On the specific case of BSplineCurve: - //! if the curve is cut in interval of continuity at least C2, the - //! derivatives are computed on the current interval. - //! else the derivatives are computed on the basis curve. - Standard_EXPORT void D2(const double U, gp_Pnt& P, gp_Vec& V1, gp_Vec& V2) const final; - - //! Returns the point P of parameter U, the first, the second - //! and the third derivative. - //! - //! Warning : On the specific case of BSplineCurve: - //! if the curve is cut in interval of continuity at least C3, the - //! derivatives are computed on the current interval. - //! else the derivatives are computed on the basis curve. - Standard_EXPORT void D3(const double U, - gp_Pnt& P, - gp_Vec& V1, - gp_Vec& V2, - gp_Vec& V3) const final; - - //! The returned vector gives the value of the derivative for the - //! order of derivation N. - //! Warning : On the specific case of BSplineCurve: - //! if the curve is cut in interval of continuity CN, the - //! derivatives are computed on the current interval. - //! else the derivatives are computed on the basis curve. - //! Raised if N < 1. - Standard_EXPORT gp_Vec DN(const double U, const int N) const final; - //! returns the parametric resolution Standard_EXPORT double Resolution(const double R3d) const override; diff --git a/src/ModelingData/TKG3d/GeomAdaptor/GeomAdaptor_Surface.cxx b/src/ModelingData/TKG3d/GeomAdaptor/GeomAdaptor_Surface.cxx index 4470137466..838dad8e65 100644 --- a/src/ModelingData/TKG3d/GeomAdaptor/GeomAdaptor_Surface.cxx +++ b/src/ModelingData/TKG3d/GeomAdaptor/GeomAdaptor_Surface.cxx @@ -1009,22 +1009,6 @@ void GeomAdaptor_Surface::RebuildCache(const double theU, const double theV) con //================================================================================================= -gp_Pnt GeomAdaptor_Surface::Value(const double U, const double V) const -{ - gp_Pnt aValue; - D0(U, V, aValue); - return aValue; -} - -//================================================================================================= - -void GeomAdaptor_Surface::D0(const double U, const double V, gp_Pnt& P) const -{ - P = EvalD0(U, V); -} - -//================================================================================================= - gp_Pnt GeomAdaptor_Surface::EvalD0(double U, double V) const { gp_Pnt P; @@ -1109,20 +1093,6 @@ gp_Pnt GeomAdaptor_Surface::EvalD0(double U, double V) const //================================================================================================= -void GeomAdaptor_Surface::D1(const double U, - const double V, - gp_Pnt& P, - gp_Vec& D1U, - gp_Vec& D1V) const -{ - const Geom_Surface::ResD1 aResult = EvalD1(U, V); - P = aResult.Point; - D1U = aResult.D1U; - D1V = aResult.D1V; -} - -//================================================================================================= - Geom_Surface::ResD1 GeomAdaptor_Surface::EvalD1(double U, double V) const { Geom_Surface::ResD1 aResult; @@ -1253,26 +1223,6 @@ Geom_Surface::ResD1 GeomAdaptor_Surface::EvalD1(double U, double V) const //================================================================================================= -void GeomAdaptor_Surface::D2(const double U, - const double V, - gp_Pnt& P, - gp_Vec& D1U, - gp_Vec& D1V, - gp_Vec& D2U, - gp_Vec& D2V, - gp_Vec& D2UV) const -{ - const Geom_Surface::ResD2 aResult = EvalD2(U, V); - P = aResult.Point; - D1U = aResult.D1U; - D1V = aResult.D1V; - D2U = aResult.D2U; - D2V = aResult.D2V; - D2UV = aResult.D2UV; -} - -//================================================================================================= - Geom_Surface::ResD2 GeomAdaptor_Surface::EvalD2(double U, double V) const { Geom_Surface::ResD2 aResult; @@ -1466,34 +1416,6 @@ Geom_Surface::ResD2 GeomAdaptor_Surface::EvalD2(double U, double V) const //================================================================================================= -void GeomAdaptor_Surface::D3(const double U, - const double V, - gp_Pnt& P, - gp_Vec& D1U, - gp_Vec& D1V, - gp_Vec& D2U, - gp_Vec& D2V, - gp_Vec& D2UV, - gp_Vec& D3U, - gp_Vec& D3V, - gp_Vec& D3UUV, - gp_Vec& D3UVV) const -{ - const Geom_Surface::ResD3 aResult = EvalD3(U, V); - P = aResult.Point; - D1U = aResult.D1U; - D1V = aResult.D1V; - D2U = aResult.D2U; - D2V = aResult.D2V; - D2UV = aResult.D2UV; - D3U = aResult.D3U; - D3V = aResult.D3V; - D3UUV = aResult.D3UUV; - D3UVV = aResult.D3UVV; -} - -//================================================================================================= - Geom_Surface::ResD3 GeomAdaptor_Surface::EvalD3(double U, double V) const { Geom_Surface::ResD3 aResult; @@ -1708,13 +1630,6 @@ Geom_Surface::ResD3 GeomAdaptor_Surface::EvalD3(double U, double V) const //================================================================================================= -gp_Vec GeomAdaptor_Surface::DN(const double U, const double V, const int Nu, const int Nv) const -{ - return EvalDN(U, V, Nu, Nv); -} - -//================================================================================================= - gp_Vec GeomAdaptor_Surface::EvalDN(double U, double V, int Nu, int Nv) const { int Ideb, Ifin, IVdeb, IVfin, USide = 0, VSide = 0; diff --git a/src/ModelingData/TKG3d/GeomAdaptor/GeomAdaptor_Surface.hxx b/src/ModelingData/TKG3d/GeomAdaptor/GeomAdaptor_Surface.hxx index 2587aa727e..3ceff119ee 100644 --- a/src/ModelingData/TKG3d/GeomAdaptor/GeomAdaptor_Surface.hxx +++ b/src/ModelingData/TKG3d/GeomAdaptor/GeomAdaptor_Surface.hxx @@ -254,71 +254,6 @@ public: Standard_EXPORT double VPeriod() const override; - //! Computes the point of parameters U,V on the surface. - Standard_EXPORT gp_Pnt Value(const double U, const double V) const final; - - //! Computes the point of parameters U,V on the surface. - Standard_EXPORT void D0(const double U, const double V, gp_Pnt& P) const final; - - //! Computes the point and the first derivatives on - //! the surface. - //! - //! Warning : On the specific case of BSplineSurface: - //! if the surface is cut in interval of continuity at least C1, - //! the derivatives are computed on the current interval. - //! else the derivatives are computed on the basis surface. - Standard_EXPORT void D1(const double U, - const double V, - gp_Pnt& P, - gp_Vec& D1U, - gp_Vec& D1V) const final; - - //! Computes the point, the first and second derivatives - //! on the surface. - //! - //! Warning : On the specific case of BSplineSurface: - //! if the surface is cut in interval of continuity at least C2, - //! the derivatives are computed on the current interval. - //! else the derivatives are computed on the basis surface. - Standard_EXPORT void D2(const double U, - const double V, - gp_Pnt& P, - gp_Vec& D1U, - gp_Vec& D1V, - gp_Vec& D2U, - gp_Vec& D2V, - gp_Vec& D2UV) const final; - - //! Computes the point, the first, second and third - //! derivatives on the surface. - //! - //! Warning : On the specific case of BSplineSurface: - //! if the surface is cut in interval of continuity at least C3, - //! the derivatives are computed on the current interval. - //! else the derivatives are computed on the basis surface. - Standard_EXPORT void D3(const double U, - const double V, - gp_Pnt& P, - gp_Vec& D1U, - gp_Vec& D1V, - gp_Vec& D2U, - gp_Vec& D2V, - gp_Vec& D2UV, - gp_Vec& D3U, - gp_Vec& D3V, - gp_Vec& D3UUV, - gp_Vec& D3UVV) const final; - - //! Computes the derivative of order Nu in the - //! direction U and Nv in the direction V at the point P(U, V). - //! - //! Warning : On the specific case of BSplineSurface: - //! if the surface is cut in interval of continuity CN, - //! the derivatives are computed on the current interval. - //! else the derivatives are computed on the basis surface. - //! Raised if Nu + Nv < 1 or Nu < 0 or Nv < 0. - Standard_EXPORT gp_Vec DN(const double U, const double V, const int Nu, const int Nv) const final; - //! Point evaluation. Raises an exception on failure. [[nodiscard]] Standard_EXPORT gp_Pnt EvalD0(double U, double V) const final; diff --git a/src/ModelingData/TKG3d/GeomAdaptor/GeomAdaptor_TransformedCurve.cxx b/src/ModelingData/TKG3d/GeomAdaptor/GeomAdaptor_TransformedCurve.cxx new file mode 100644 index 0000000000..3ef1c9480d --- /dev/null +++ b/src/ModelingData/TKG3d/GeomAdaptor/GeomAdaptor_TransformedCurve.cxx @@ -0,0 +1,270 @@ +// Copyright (c) 2025 OPEN CASCADE SAS +// +// This file is part of Open CASCADE Technology software library. +// +// This library is free software; you can redistribute it and/or modify it under +// the terms of the GNU Lesser General Public License version 2.1 as published +// by the Free Software Foundation, with special exception defined in the file +// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT +// distribution for complete text of the license and disclaimer of any warranty. +// +// Alternatively, this file may be used under the terms of Open CASCADE +// commercial license or contractual agreement. + +#include + +#include +#include +#include +#include + +IMPLEMENT_STANDARD_RTTIEXT(GeomAdaptor_TransformedCurve, Adaptor3d_Curve) + +//================================================================================================== + +GeomAdaptor_TransformedCurve::GeomAdaptor_TransformedCurve() = default; + +//================================================================================================== + +GeomAdaptor_TransformedCurve::GeomAdaptor_TransformedCurve(const occ::handle& theCurve, + const gp_Trsf& theTrsf) + : myCurve(theCurve), + myTrsf(theTrsf) +{ +} + +//================================================================================================== + +GeomAdaptor_TransformedCurve::GeomAdaptor_TransformedCurve(const occ::handle& theCurve, + const double theFirst, + const double theLast, + const gp_Trsf& theTrsf) + : myCurve(theCurve, theFirst, theLast), + myTrsf(theTrsf) +{ +} + +//================================================================================================== + +occ::handle GeomAdaptor_TransformedCurve::ShallowCopy() const +{ + occ::handle aCopy = new GeomAdaptor_TransformedCurve(); + + const occ::handle aCurve = myCurve.ShallowCopy(); + const GeomAdaptor_Curve& aGeomCurve = *occ::down_cast(aCurve); + aCopy->myCurve = aGeomCurve; + + if (!myConSurf.IsNull()) + { + aCopy->myConSurf = occ::down_cast(myConSurf->ShallowCopy()); + } + aCopy->myTrsf = myTrsf; + + return aCopy; +} + +//================================================================================================== + +void GeomAdaptor_TransformedCurve::Intervals(NCollection_Array1& theT, + const GeomAbs_Shape theS) const +{ + if (myConSurf.IsNull()) + myCurve.Intervals(theT, theS); + else + myConSurf->Intervals(theT, theS); +} + +//================================================================================================== + +occ::handle GeomAdaptor_TransformedCurve::Trim(const double theFirst, + const double theLast, + const double theTol) const +{ + occ::handle aCopy = new GeomAdaptor_TransformedCurve(); + if (myConSurf.IsNull()) + { + aCopy->myCurve.Load(myCurve.Curve(), theFirst, theLast); + } + else + { + aCopy->myConSurf = + occ::down_cast(myConSurf->Trim(theFirst, theLast, theTol)); + } + aCopy->myTrsf = myTrsf; + return aCopy; +} + +//================================================================================================== + +gp_Lin GeomAdaptor_TransformedCurve::Line() const +{ + gp_Lin aL; + if (myConSurf.IsNull()) + aL = myCurve.Line(); + else + aL = myConSurf->Line(); + aL.Transform(myTrsf); + return aL; +} + +//================================================================================================== + +gp_Circ GeomAdaptor_TransformedCurve::Circle() const +{ + gp_Circ aC; + if (myConSurf.IsNull()) + aC = myCurve.Circle(); + else + aC = myConSurf->Circle(); + aC.Transform(myTrsf); + return aC; +} + +//================================================================================================== + +gp_Elips GeomAdaptor_TransformedCurve::Ellipse() const +{ + gp_Elips aE; + if (myConSurf.IsNull()) + aE = myCurve.Ellipse(); + else + aE = myConSurf->Ellipse(); + aE.Transform(myTrsf); + return aE; +} + +//================================================================================================== + +gp_Hypr GeomAdaptor_TransformedCurve::Hyperbola() const +{ + gp_Hypr aH; + if (myConSurf.IsNull()) + aH = myCurve.Hyperbola(); + else + aH = myConSurf->Hyperbola(); + aH.Transform(myTrsf); + return aH; +} + +//================================================================================================== + +gp_Parab GeomAdaptor_TransformedCurve::Parabola() const +{ + gp_Parab aP; + if (myConSurf.IsNull()) + aP = myCurve.Parabola(); + else + aP = myConSurf->Parabola(); + aP.Transform(myTrsf); + return aP; +} + +//================================================================================================== + +occ::handle GeomAdaptor_TransformedCurve::Bezier() const +{ + occ::handle aBC; + if (myConSurf.IsNull()) + aBC = myCurve.Bezier(); + else + aBC = myConSurf->Bezier(); + return myTrsf.Form() == gp_Identity ? aBC + : occ::down_cast(aBC->Transformed(myTrsf)); +} + +//================================================================================================== + +occ::handle GeomAdaptor_TransformedCurve::BSpline() const +{ + occ::handle aBS; + if (myConSurf.IsNull()) + aBS = myCurve.BSpline(); + else + aBS = myConSurf->BSpline(); + return myTrsf.Form() == gp_Identity ? aBS + : occ::down_cast(aBS->Transformed(myTrsf)); +} + +//================================================================================================== + +occ::handle GeomAdaptor_TransformedCurve::OffsetCurve() const +{ + if (!Is3DCurve() || myCurve.GetType() != GeomAbs_OffsetCurve) + throw Standard_NoSuchObject("GeomAdaptor_TransformedCurve::OffsetCurve"); + + occ::handle anOffC = myCurve.OffsetCurve(); + return myTrsf.Form() == gp_Identity + ? anOffC + : occ::down_cast(anOffC->Transformed(myTrsf)); +} + +//================================================================================================== + +gp_Pnt GeomAdaptor_TransformedCurve::EvalD0(double theU) const +{ + gp_Pnt aP; + if (myConSurf.IsNull()) + aP = myCurve.EvalD0(theU); + else + myConSurf->D0(theU, aP); + aP.Transform(myTrsf); + return aP; +} + +//================================================================================================== + +Geom_Curve::ResD1 GeomAdaptor_TransformedCurve::EvalD1(double theU) const +{ + Geom_Curve::ResD1 aRes; + if (myConSurf.IsNull()) + aRes = myCurve.EvalD1(theU); + else + myConSurf->D1(theU, aRes.Point, aRes.D1); + aRes.Point.Transform(myTrsf); + aRes.D1.Transform(myTrsf); + return aRes; +} + +//================================================================================================== + +Geom_Curve::ResD2 GeomAdaptor_TransformedCurve::EvalD2(double theU) const +{ + Geom_Curve::ResD2 aRes; + if (myConSurf.IsNull()) + aRes = myCurve.EvalD2(theU); + else + myConSurf->D2(theU, aRes.Point, aRes.D1, aRes.D2); + aRes.Point.Transform(myTrsf); + aRes.D1.Transform(myTrsf); + aRes.D2.Transform(myTrsf); + return aRes; +} + +//================================================================================================== + +Geom_Curve::ResD3 GeomAdaptor_TransformedCurve::EvalD3(double theU) const +{ + Geom_Curve::ResD3 aRes; + if (myConSurf.IsNull()) + aRes = myCurve.EvalD3(theU); + else + myConSurf->D3(theU, aRes.Point, aRes.D1, aRes.D2, aRes.D3); + aRes.Point.Transform(myTrsf); + aRes.D1.Transform(myTrsf); + aRes.D2.Transform(myTrsf); + aRes.D3.Transform(myTrsf); + return aRes; +} + +//================================================================================================== + +gp_Vec GeomAdaptor_TransformedCurve::EvalDN(double theU, int theN) const +{ + gp_Vec aV; + if (myConSurf.IsNull()) + aV = myCurve.EvalDN(theU, theN); + else + aV = myConSurf->DN(theU, theN); + aV.Transform(myTrsf); + return aV; +} diff --git a/src/ModelingData/TKG3d/GeomAdaptor/GeomAdaptor_TransformedCurve.hxx b/src/ModelingData/TKG3d/GeomAdaptor/GeomAdaptor_TransformedCurve.hxx new file mode 100644 index 0000000000..6b7ca54f2c --- /dev/null +++ b/src/ModelingData/TKG3d/GeomAdaptor/GeomAdaptor_TransformedCurve.hxx @@ -0,0 +1,212 @@ +// Copyright (c) 2025 OPEN CASCADE SAS +// +// This file is part of Open CASCADE Technology software library. +// +// This library is free software; you can redistribute it and/or modify it under +// the terms of the GNU Lesser General Public License version 2.1 as published +// by the Free Software Foundation, with special exception defined in the file +// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT +// distribution for complete text of the license and disclaimer of any warranty. +// +// Alternatively, this file may be used under the terms of Open CASCADE +// commercial license or contractual agreement. + +#ifndef _GeomAdaptor_TransformedCurve_HeaderFile +#define _GeomAdaptor_TransformedCurve_HeaderFile + +#include +#include +#include +#include + +//! An adaptor for curves with an applied transformation. +//! +//! This class wraps a GeomAdaptor_Curve (or an Adaptor3d_CurveOnSurface) and +//! applies a gp_Trsf transformation to all point and derivative evaluations. +//! It serves as a base class for BRepAdaptor_Curve and allows batch evaluation +//! with transformations in GeomGridEval_Curve. +//! +//! The evaluation methods (Value, D0, D1, D2, D3, DN) are marked final +//! to enable optimizations in grid evaluation. +class GeomAdaptor_TransformedCurve : public Adaptor3d_Curve +{ + DEFINE_STANDARD_RTTIEXT(GeomAdaptor_TransformedCurve, Adaptor3d_Curve) +public: + //! Creates an undefined curve with identity transformation. + Standard_EXPORT GeomAdaptor_TransformedCurve(); + + //! Creates a curve adaptor with transformation. + //! @param theCurve underlying geometry + //! @param theTrsf transformation to apply + Standard_EXPORT GeomAdaptor_TransformedCurve(const occ::handle& theCurve, + const gp_Trsf& theTrsf); + + //! Creates a curve adaptor with transformation and parameter bounds. + //! @param theCurve underlying geometry + //! @param theFirst minimum parameter + //! @param theLast maximum parameter + //! @param theTrsf transformation to apply + Standard_EXPORT GeomAdaptor_TransformedCurve(const occ::handle& theCurve, + const double theFirst, + const double theLast, + const gp_Trsf& theTrsf); + + //! Shallow copy of adaptor. + Standard_EXPORT occ::handle ShallowCopy() const override; + + //! Loads the curve geometry. + //! @param theCurve underlying geometry + void Load(const occ::handle& theCurve) { myCurve.Load(theCurve); } + + //! Loads the curve geometry with parameter bounds. + //! @param theCurve underlying geometry + //! @param theFirst minimum parameter + //! @param theLast maximum parameter + void Load(const occ::handle& theCurve, const double theFirst, const double theLast) + { + myCurve.Load(theCurve, theFirst, theLast); + } + + //! Sets the curve on surface adaptor. + //! @param theConSurf curve on surface adaptor + void LoadCurveOnSurface(const occ::handle& theConSurf) + { + myConSurf = theConSurf; + } + + //! Sets the transformation. + //! @param theTrsf transformation to apply + void SetTrsf(const gp_Trsf& theTrsf) { myTrsf = theTrsf; } + + //! Returns the transformation. + const gp_Trsf& Trsf() const { return myTrsf; } + + //! Returns true if the geometry is a 3D curve (not curve on surface). + bool Is3DCurve() const { return myConSurf.IsNull(); } + + //! Returns true if the geometry is a curve on surface. + bool IsCurveOnSurface() const { return !myConSurf.IsNull(); } + + //! Returns the underlying GeomAdaptor_Curve. + const GeomAdaptor_Curve& Curve() const { return myCurve; } + + //! Returns the underlying GeomAdaptor_Curve for modification. + GeomAdaptor_Curve& ChangeCurve() { return myCurve; } + + //! Returns the CurveOnSurface adaptor. + const Adaptor3d_CurveOnSurface& CurveOnSurface() const { return *myConSurf; } + + //! Returns the underlying Geom_Curve. + const occ::handle& GeomCurve() const { return myCurve.Curve(); } + + // Parameter range methods - delegate to underlying curve or COS + double FirstParameter() const override + { + return myConSurf.IsNull() ? myCurve.FirstParameter() : myConSurf->FirstParameter(); + } + + double LastParameter() const override + { + return myConSurf.IsNull() ? myCurve.LastParameter() : myConSurf->LastParameter(); + } + + GeomAbs_Shape Continuity() const override + { + return myConSurf.IsNull() ? myCurve.Continuity() : myConSurf->Continuity(); + } + + int NbIntervals(const GeomAbs_Shape theS) const override + { + return myConSurf.IsNull() ? myCurve.NbIntervals(theS) : myConSurf->NbIntervals(theS); + } + + Standard_EXPORT void Intervals(NCollection_Array1& theT, + const GeomAbs_Shape theS) const override; + + Standard_EXPORT occ::handle Trim(const double theFirst, + const double theLast, + const double theTol) const override; + + bool IsClosed() const override + { + return myConSurf.IsNull() ? myCurve.IsClosed() : myConSurf->IsClosed(); + } + + bool IsPeriodic() const override + { + return myConSurf.IsNull() ? myCurve.IsPeriodic() : myConSurf->IsPeriodic(); + } + + double Period() const override + { + return myConSurf.IsNull() ? myCurve.Period() : myConSurf->Period(); + } + + //! Point evaluation. Applies transformation after evaluation. + [[nodiscard]] Standard_EXPORT gp_Pnt EvalD0(const double theU) const final; + + //! D1 evaluation. Applies transformation after evaluation. + [[nodiscard]] Standard_EXPORT Geom_Curve::ResD1 EvalD1(const double theU) const final; + + //! D2 evaluation. Applies transformation after evaluation. + [[nodiscard]] Standard_EXPORT Geom_Curve::ResD2 EvalD2(const double theU) const final; + + //! D3 evaluation. Applies transformation after evaluation. + [[nodiscard]] Standard_EXPORT Geom_Curve::ResD3 EvalD3(const double theU) const final; + + //! DN evaluation. Applies transformation after evaluation. + [[nodiscard]] Standard_EXPORT gp_Vec EvalDN(const double theU, const int theN) const final; + + double Resolution(const double theR3d) const override + { + return myConSurf.IsNull() ? myCurve.Resolution(theR3d) : myConSurf->Resolution(theR3d); + } + + GeomAbs_CurveType GetType() const override + { + return myConSurf.IsNull() ? myCurve.GetType() : myConSurf->GetType(); + } + + Standard_EXPORT gp_Lin Line() const override; + + Standard_EXPORT gp_Circ Circle() const override; + + Standard_EXPORT gp_Elips Ellipse() const override; + + Standard_EXPORT gp_Hypr Hyperbola() const override; + + Standard_EXPORT gp_Parab Parabola() const override; + + int Degree() const override + { + return myConSurf.IsNull() ? myCurve.Degree() : myConSurf->Degree(); + } + + bool IsRational() const override + { + return myConSurf.IsNull() ? myCurve.IsRational() : myConSurf->IsRational(); + } + + int NbPoles() const override + { + return myConSurf.IsNull() ? myCurve.NbPoles() : myConSurf->NbPoles(); + } + + int NbKnots() const override + { + return myConSurf.IsNull() ? myCurve.NbKnots() : myConSurf->NbKnots(); + } + + Standard_EXPORT occ::handle Bezier() const override; + + Standard_EXPORT occ::handle BSpline() const override; + + Standard_EXPORT occ::handle OffsetCurve() const override; + +protected: + GeomAdaptor_Curve myCurve; + occ::handle myConSurf; + gp_Trsf myTrsf; +}; + +#endif // _GeomAdaptor_TransformedCurve_HeaderFile diff --git a/src/ModelingData/TKG3d/GeomAdaptor/GeomAdaptor_TransformedSurface.cxx b/src/ModelingData/TKG3d/GeomAdaptor/GeomAdaptor_TransformedSurface.cxx index f98bf6223e..e7722b9ac5 100644 --- a/src/ModelingData/TKG3d/GeomAdaptor/GeomAdaptor_TransformedSurface.cxx +++ b/src/ModelingData/TKG3d/GeomAdaptor/GeomAdaptor_TransformedSurface.cxx @@ -102,100 +102,59 @@ occ::handle GeomAdaptor_TransformedSurface::VTrim(const doubl //================================================================================================= -gp_Pnt GeomAdaptor_TransformedSurface::Value(const double theU, const double theV) const +gp_Pnt GeomAdaptor_TransformedSurface::EvalD0(double theU, double theV) const { - return mySurf.Value(theU, theV).Transformed(myTrsf); + return mySurf.EvalD0(theU, theV).Transformed(myTrsf); } //================================================================================================= -void GeomAdaptor_TransformedSurface::D0(const double theU, const double theV, gp_Pnt& theP) const +Geom_Surface::ResD1 GeomAdaptor_TransformedSurface::EvalD1(double theU, double theV) const { - mySurf.D0(theU, theV, theP); - theP.Transform(myTrsf); + Geom_Surface::ResD1 aRes = mySurf.EvalD1(theU, theV); + aRes.Point.Transform(myTrsf); + aRes.D1U.Transform(myTrsf); + aRes.D1V.Transform(myTrsf); + return aRes; } //================================================================================================= -void GeomAdaptor_TransformedSurface::D1(const double theU, - const double theV, - gp_Pnt& theP, - gp_Vec& theD1U, - gp_Vec& theD1V) const +Geom_Surface::ResD2 GeomAdaptor_TransformedSurface::EvalD2(double theU, double theV) const { - mySurf.D1(theU, theV, theP, theD1U, theD1V); - theP.Transform(myTrsf); - theD1U.Transform(myTrsf); - theD1V.Transform(myTrsf); + Geom_Surface::ResD2 aRes = mySurf.EvalD2(theU, theV); + aRes.Point.Transform(myTrsf); + aRes.D1U.Transform(myTrsf); + aRes.D1V.Transform(myTrsf); + aRes.D2U.Transform(myTrsf); + aRes.D2V.Transform(myTrsf); + aRes.D2UV.Transform(myTrsf); + return aRes; } //================================================================================================= -void GeomAdaptor_TransformedSurface::D2(const double theU, - const double theV, - gp_Pnt& theP, - gp_Vec& theD1U, - gp_Vec& theD1V, - gp_Vec& theD2U, - gp_Vec& theD2V, - gp_Vec& theD2UV) const +Geom_Surface::ResD3 GeomAdaptor_TransformedSurface::EvalD3(double theU, double theV) const { - mySurf.D2(theU, theV, theP, theD1U, theD1V, theD2U, theD2V, theD2UV); - theP.Transform(myTrsf); - theD1U.Transform(myTrsf); - theD1V.Transform(myTrsf); - theD2U.Transform(myTrsf); - theD2V.Transform(myTrsf); - theD2UV.Transform(myTrsf); + Geom_Surface::ResD3 aRes = mySurf.EvalD3(theU, theV); + aRes.Point.Transform(myTrsf); + aRes.D1U.Transform(myTrsf); + aRes.D1V.Transform(myTrsf); + aRes.D2U.Transform(myTrsf); + aRes.D2V.Transform(myTrsf); + aRes.D2UV.Transform(myTrsf); + aRes.D3U.Transform(myTrsf); + aRes.D3V.Transform(myTrsf); + aRes.D3UUV.Transform(myTrsf); + aRes.D3UVV.Transform(myTrsf); + return aRes; } //================================================================================================= -void GeomAdaptor_TransformedSurface::D3(const double theU, - const double theV, - gp_Pnt& theP, - gp_Vec& theD1U, - gp_Vec& theD1V, - gp_Vec& theD2U, - gp_Vec& theD2V, - gp_Vec& theD2UV, - gp_Vec& theD3U, - gp_Vec& theD3V, - gp_Vec& theD3UUV, - gp_Vec& theD3UVV) const +gp_Vec GeomAdaptor_TransformedSurface::EvalDN(double theU, double theV, int theNu, int theNv) const { - mySurf.D3(theU, - theV, - theP, - theD1U, - theD1V, - theD2U, - theD2V, - theD2UV, - theD3U, - theD3V, - theD3UUV, - theD3UVV); - theP.Transform(myTrsf); - theD1U.Transform(myTrsf); - theD1V.Transform(myTrsf); - theD2U.Transform(myTrsf); - theD2V.Transform(myTrsf); - theD2UV.Transform(myTrsf); - theD3U.Transform(myTrsf); - theD3V.Transform(myTrsf); - theD3UUV.Transform(myTrsf); - theD3UVV.Transform(myTrsf); -} - -//================================================================================================= - -gp_Vec GeomAdaptor_TransformedSurface::DN(const double theU, - const double theV, - const int theNu, - const int theNv) const -{ - return mySurf.DN(theU, theV, theNu, theNv).Transformed(myTrsf); + return mySurf.EvalDN(theU, theV, theNu, theNv).Transformed(myTrsf); } //================================================================================================= diff --git a/src/ModelingData/TKG3d/GeomAdaptor/GeomAdaptor_TransformedSurface.hxx b/src/ModelingData/TKG3d/GeomAdaptor/GeomAdaptor_TransformedSurface.hxx index 3cbe87c430..39a4fc4ce0 100644 --- a/src/ModelingData/TKG3d/GeomAdaptor/GeomAdaptor_TransformedSurface.hxx +++ b/src/ModelingData/TKG3d/GeomAdaptor/GeomAdaptor_TransformedSurface.hxx @@ -143,54 +143,26 @@ public: double VPeriod() const override { return mySurf.VPeriod(); } - //! Computes the point of parameters U,V on the surface. - //! Applies transformation after evaluation. - Standard_EXPORT gp_Pnt Value(const double theU, const double theV) const final; + //! Point evaluation. Applies transformation after evaluation. + [[nodiscard]] Standard_EXPORT gp_Pnt EvalD0(const double theU, const double theV) const final; - //! Computes the point of parameters U,V on the surface. - //! Applies transformation after evaluation. - Standard_EXPORT void D0(const double theU, const double theV, gp_Pnt& theP) const final; + //! D1 evaluation. Applies transformation after evaluation. + [[nodiscard]] Standard_EXPORT Geom_Surface::ResD1 EvalD1(const double theU, + const double theV) const final; - //! Computes the point and the first derivatives on the surface. - //! Applies transformation after evaluation. - Standard_EXPORT void D1(const double theU, - const double theV, - gp_Pnt& theP, - gp_Vec& theD1U, - gp_Vec& theD1V) const final; + //! D2 evaluation. Applies transformation after evaluation. + [[nodiscard]] Standard_EXPORT Geom_Surface::ResD2 EvalD2(const double theU, + const double theV) const final; - //! Computes the point, the first and second derivatives on the surface. - //! Applies transformation after evaluation. - Standard_EXPORT void D2(const double theU, - const double theV, - gp_Pnt& theP, - gp_Vec& theD1U, - gp_Vec& theD1V, - gp_Vec& theD2U, - gp_Vec& theD2V, - gp_Vec& theD2UV) const final; + //! D3 evaluation. Applies transformation after evaluation. + [[nodiscard]] Standard_EXPORT Geom_Surface::ResD3 EvalD3(const double theU, + const double theV) const final; - //! Computes the point, the first, second and third derivatives on the surface. - //! Applies transformation after evaluation. - Standard_EXPORT void D3(const double theU, - const double theV, - gp_Pnt& theP, - gp_Vec& theD1U, - gp_Vec& theD1V, - gp_Vec& theD2U, - gp_Vec& theD2V, - gp_Vec& theD2UV, - gp_Vec& theD3U, - gp_Vec& theD3V, - gp_Vec& theD3UUV, - gp_Vec& theD3UVV) const final; - - //! Computes the derivative of order Nu in the direction U and Nv in the direction V. - //! Applies transformation after evaluation. - Standard_EXPORT gp_Vec DN(const double theU, - const double theV, - const int theNu, - const int theNv) const final; + //! DN evaluation. Applies transformation after evaluation. + [[nodiscard]] Standard_EXPORT gp_Vec EvalDN(const double theU, + const double theV, + const int theNu, + const int theNv) const final; double UResolution(const double theR3d) const override { return mySurf.UResolution(theR3d); } diff --git a/src/ModelingData/TKGeomBase/ProjLib/ProjLib_ProjectOnPlane.cxx b/src/ModelingData/TKGeomBase/ProjLib/ProjLib_ProjectOnPlane.cxx index bd8802c8bc..2d465196a2 100644 --- a/src/ModelingData/TKGeomBase/ProjLib/ProjLib_ProjectOnPlane.cxx +++ b/src/ModelingData/TKGeomBase/ProjLib/ProjLib_ProjectOnPlane.cxx @@ -26,6 +26,7 @@ #include #include #include +#include #include #include #include @@ -1081,85 +1082,80 @@ double ProjLib_ProjectOnPlane::Period() const //================================================================================================= -gp_Pnt ProjLib_ProjectOnPlane::Value(const double U) const +gp_Pnt ProjLib_ProjectOnPlane::EvalD0(double theU) const { if (myType != GeomAbs_OtherCurve) { - return myResult->Value(U); + return myResult->EvalD0(theU); } else { - return OnPlane_Value(U, myCurve, myPlane, myDirection); + return OnPlane_Value(theU, myCurve, myPlane, myDirection); } } //================================================================================================= -void ProjLib_ProjectOnPlane::D0(const double U, gp_Pnt& P) const +Geom_Curve::ResD1 ProjLib_ProjectOnPlane::EvalD1(double theU) const { if (myType != GeomAbs_OtherCurve) { - myResult->D0(U, P); + return myResult->EvalD1(theU); } else { - P = OnPlane_Value(U, myCurve, myPlane, myDirection); + gp_Pnt aP; + gp_Vec aV; + OnPlane_D1(theU, aP, aV, myCurve, myPlane, myDirection); + return {aP, aV}; } } //================================================================================================= -void ProjLib_ProjectOnPlane::D1(const double U, gp_Pnt& P, gp_Vec& V) const +Geom_Curve::ResD2 ProjLib_ProjectOnPlane::EvalD2(double theU) const { if (myType != GeomAbs_OtherCurve) { - myResult->D1(U, P, V); + return myResult->EvalD2(theU); } else { - OnPlane_D1(U, P, V, myCurve, myPlane, myDirection); + gp_Pnt aP; + gp_Vec aV1, aV2; + OnPlane_D2(theU, aP, aV1, aV2, myCurve, myPlane, myDirection); + return {aP, aV1, aV2}; } } //================================================================================================= -void ProjLib_ProjectOnPlane::D2(const double U, gp_Pnt& P, gp_Vec& V1, gp_Vec& V2) const +Geom_Curve::ResD3 ProjLib_ProjectOnPlane::EvalD3(double theU) const { if (myType != GeomAbs_OtherCurve) { - myResult->D2(U, P, V1, V2); + return myResult->EvalD3(theU); } else { - OnPlane_D2(U, P, V1, V2, myCurve, myPlane, myDirection); + gp_Pnt aP; + gp_Vec aV1, aV2, aV3; + OnPlane_D3(theU, aP, aV1, aV2, aV3, myCurve, myPlane, myDirection); + return {aP, aV1, aV2, aV3}; } } //================================================================================================= -void ProjLib_ProjectOnPlane::D3(const double U, gp_Pnt& P, gp_Vec& V1, gp_Vec& V2, gp_Vec& V3) const +gp_Vec ProjLib_ProjectOnPlane::EvalDN(double theU, int theN) const { if (myType != GeomAbs_OtherCurve) { - myResult->D3(U, P, V1, V2, V3); + return myResult->EvalDN(theU, theN); } else { - OnPlane_D3(U, P, V1, V2, V3, myCurve, myPlane, myDirection); - } -} - -//================================================================================================= - -gp_Vec ProjLib_ProjectOnPlane::DN(const double U, const int DerivativeRequest) const -{ - if (myType != GeomAbs_OtherCurve) - { - return myResult->DN(U, DerivativeRequest); - } - else - { - return OnPlane_DN(U, DerivativeRequest, myCurve, myPlane, myDirection); + return OnPlane_DN(theU, theN, myCurve, myPlane, myDirection); } } diff --git a/src/ModelingData/TKGeomBase/ProjLib/ProjLib_ProjectOnPlane.hxx b/src/ModelingData/TKGeomBase/ProjLib/ProjLib_ProjectOnPlane.hxx index 7f2b9ce635..474634487e 100644 --- a/src/ModelingData/TKGeomBase/ProjLib/ProjLib_ProjectOnPlane.hxx +++ b/src/ModelingData/TKGeomBase/ProjLib/ProjLib_ProjectOnPlane.hxx @@ -114,40 +114,25 @@ public: Standard_EXPORT double Period() const override; - //! Computes the point of parameter U on the curve. - Standard_EXPORT gp_Pnt Value(const double U) const override; + //! Computes the point of parameter theU on the curve. + [[nodiscard]] Standard_EXPORT gp_Pnt EvalD0(double theU) const final; - //! Computes the point of parameter U on the curve. - Standard_EXPORT void D0(const double U, gp_Pnt& P) const override; + //! Computes the point of parameter theU on the curve with its first derivative. + //! Raised if the continuity of the current interval is not C1. + [[nodiscard]] Standard_EXPORT Geom_Curve::ResD1 EvalD1(double theU) const final; - //! Computes the point of parameter U on the curve with its - //! first derivative. - //! Raised if the continuity of the current interval - //! is not C1. - Standard_EXPORT void D1(const double U, gp_Pnt& P, gp_Vec& V) const override; + //! Returns the point and the first and second derivatives at parameter theU. + //! Raised if the continuity of the current interval is not C2. + [[nodiscard]] Standard_EXPORT Geom_Curve::ResD2 EvalD2(double theU) const final; - //! Returns the point P of parameter U, the first and second - //! derivatives V1 and V2. - //! Raised if the continuity of the current interval - //! is not C2. - Standard_EXPORT void D2(const double U, gp_Pnt& P, gp_Vec& V1, gp_Vec& V2) const override; + //! Returns the point and the first, second and third derivatives at parameter theU. + //! Raised if the continuity of the current interval is not C3. + [[nodiscard]] Standard_EXPORT Geom_Curve::ResD3 EvalD3(double theU) const final; - //! Returns the point P of parameter U, the first, the second - //! and the third derivative. - //! Raised if the continuity of the current interval - //! is not C3. - Standard_EXPORT void D3(const double U, - gp_Pnt& P, - gp_Vec& V1, - gp_Vec& V2, - gp_Vec& V3) const override; - - //! The returned vector gives the value of the derivative for the - //! order of derivation N. - //! Raised if the continuity of the current interval - //! is not CN. - //! Raised if N < 1. - Standard_EXPORT gp_Vec DN(const double U, const int N) const override; + //! Returns the derivative of order theN at parameter theU. + //! Raised if the continuity of the current interval is not CN. + //! Raised if theN < 1. + [[nodiscard]] Standard_EXPORT gp_Vec EvalDN(double theU, int theN) const final; //! Returns the parametric resolution corresponding //! to the real space resolution .