1 // Created on: 2015-09-21
2 // Copyright (c) 2015 OPEN CASCADE SAS
4 // This file is part of Open CASCADE Technology software library.
6 // This library is free software; you can redistribute it and/or modify it under
7 // the terms of the GNU Lesser General Public License version 2.1 as published
8 // by the Free Software Foundation, with special exception defined in the file
9 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
10 // distribution for complete text of the license and disclaimer of any warranty.
12 // Alternatively, this file may be used under the terms of Open CASCADE
13 // commercial license or contractual agreement.
15 #ifndef _GeomEvaluator_OffsetCurve_HeaderFile
16 #define _GeomEvaluator_OffsetCurve_HeaderFile
18 #include <GeomAdaptor_Curve.hxx>
19 #include <GeomEvaluator_Curve.hxx>
22 //! Allows to calculate values and derivatives for offset curves in 3D
23 class GeomEvaluator_OffsetCurve : public GeomEvaluator_Curve
26 //! Initialize evaluator by curve
27 Standard_EXPORT GeomEvaluator_OffsetCurve(
28 const Handle(Geom_Curve)& theBase,
29 const Standard_Real theOffset,
30 const gp_Dir& theDirection);
31 //! Initialize evaluator by curve adaptor
32 Standard_EXPORT GeomEvaluator_OffsetCurve(
33 const Handle(GeomAdaptor_Curve)& theBase,
34 const Standard_Real theOffset,
35 const gp_Dir& theDirection);
37 //! Change the offset value
38 void SetOffsetValue(Standard_Real theOffset)
39 { myOffset = theOffset; }
41 void SetOffsetDirection(const gp_Dir& theDirection)
42 { myOffsetDir = theDirection; }
45 Standard_EXPORT void D0(const Standard_Real theU,
46 gp_Pnt& theValue) const Standard_OVERRIDE;
47 //! Value and first derivatives of curve
48 Standard_EXPORT void D1(const Standard_Real theU,
49 gp_Pnt& theValue, gp_Vec& theD1) const Standard_OVERRIDE;
50 //! Value, first and second derivatives of curve
51 Standard_EXPORT void D2(const Standard_Real theU,
52 gp_Pnt& theValue, gp_Vec& theD1, gp_Vec& theD2) const Standard_OVERRIDE;
53 //! Value, first, second and third derivatives of curve
54 Standard_EXPORT void D3(const Standard_Real theU,
55 gp_Pnt& theValue, gp_Vec& theD1,
56 gp_Vec& theD2, gp_Vec& theD3) const Standard_OVERRIDE;
57 //! Calculates N-th derivatives of curve, where N = theDeriv. Raises if N < 1
58 Standard_EXPORT gp_Vec DN(const Standard_Real theU,
59 const Standard_Integer theDeriv) const Standard_OVERRIDE;
61 Standard_EXPORT virtual Handle(GeomEvaluator_Curve) ShallowCopy() const Standard_OVERRIDE;
63 DEFINE_STANDARD_RTTIEXT(GeomEvaluator_OffsetCurve,GeomEvaluator_Curve)
66 //! Recalculate D1 values of base curve into D0 value of offset curve
67 void CalculateD0( gp_Pnt& theValue,
68 const gp_Vec& theD1) const;
69 //! Recalculate D2 values of base curve into D1 values of offset curve
70 void CalculateD1( gp_Pnt& theValue,
72 const gp_Vec& theD2) const;
73 //! Recalculate D3 values of base curve into D2 values of offset curve
74 void CalculateD2( gp_Pnt& theValue,
78 const Standard_Boolean theIsDirChange) const;
79 //! Recalculate D3 values of base curve into D3 values of offset curve
80 void CalculateD3( gp_Pnt& theValue,
85 const Standard_Boolean theIsDirChange) const;
87 //! Calculate value of base curve/adaptor
88 void BaseD0(const Standard_Real theU, gp_Pnt& theValue) const;
89 //! Calculate value and first derivatives of base curve/adaptor
90 void BaseD1(const Standard_Real theU,
91 gp_Pnt& theValue, gp_Vec& theD1) const;
92 //! Calculate value, first and second derivatives of base curve/adaptor
93 void BaseD2(const Standard_Real theU,
94 gp_Pnt& theValue, gp_Vec& theD1, gp_Vec& theD2) const;
95 //! Calculate value, first, second and third derivatives of base curve/adaptor
96 void BaseD3(const Standard_Real theU,
97 gp_Pnt& theValue, gp_Vec& theD1, gp_Vec& theD2, gp_Vec& theD3) const;
98 //! Calculate value and derivatives till 4th of base curve/adaptor
99 void BaseD4(const Standard_Real theU,
100 gp_Pnt& theValue, gp_Vec& theD1, gp_Vec& theD2, gp_Vec& theD3, gp_Vec& theD4) const;
101 //! Calculate N-th derivative of base curve/adaptor
102 gp_Vec BaseDN(const Standard_Real theU, const Standard_Integer theDeriv) const;
104 // Recalculate derivatives in the singular point
105 // Returns true if the direction of derivatives is changed
106 Standard_Boolean AdjustDerivative(const Standard_Integer theMaxDerivative,
107 const Standard_Real theU,
111 gp_Vec& theD4) const;
114 Handle(Geom_Curve) myBaseCurve;
115 Handle(GeomAdaptor_Curve) myBaseAdaptor;
117 Standard_Real myOffset; ///< offset value
118 gp_Dir myOffsetDir; ///< offset direction
121 DEFINE_STANDARD_HANDLE(GeomEvaluator_OffsetCurve, GeomEvaluator_Curve)
124 #endif // _GeomEvaluator_OffsetCurve_HeaderFile