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 <Geom_Curve.hxx>
19 #include <GeomEvaluator_Curve.hxx>
22 class GeomAdaptor_HCurve;
24 //! Allows to calculate values and derivatives for offset curves in 3D
25 class GeomEvaluator_OffsetCurve : public GeomEvaluator_Curve
28 //! Initialize evaluator by curve
29 Standard_EXPORT GeomEvaluator_OffsetCurve(
30 const Handle(Geom_Curve)& theBase,
31 const Standard_Real theOffset,
32 const gp_Dir& theDirection);
33 //! Initialize evaluator by curve adaptor
34 Standard_EXPORT GeomEvaluator_OffsetCurve(
35 const Handle(GeomAdaptor_HCurve)& theBase,
36 const Standard_Real theOffset,
37 const gp_Dir& theDirection);
39 //! Change the offset value
40 void SetOffsetValue(Standard_Real theOffset)
41 { myOffset = theOffset; }
43 void SetOffsetDirection(const gp_Dir& theDirection)
44 { myOffsetDir = theDirection; }
47 Standard_EXPORT void D0(const Standard_Real theU,
48 gp_Pnt& theValue) const Standard_OVERRIDE;
49 //! Value and first derivatives of curve
50 Standard_EXPORT void D1(const Standard_Real theU,
51 gp_Pnt& theValue, gp_Vec& theD1) const Standard_OVERRIDE;
52 //! Value, first and second derivatives of curve
53 Standard_EXPORT void D2(const Standard_Real theU,
54 gp_Pnt& theValue, gp_Vec& theD1, gp_Vec& theD2) const Standard_OVERRIDE;
55 //! Value, first, second and third derivatives of curve
56 Standard_EXPORT void D3(const Standard_Real theU,
57 gp_Pnt& theValue, gp_Vec& theD1,
58 gp_Vec& theD2, gp_Vec& theD3) const Standard_OVERRIDE;
59 //! Calculates N-th derivatives of curve, where N = theDeriv. Raises if N < 1
60 Standard_EXPORT gp_Vec DN(const Standard_Real theU,
61 const Standard_Integer theDeriv) const Standard_OVERRIDE;
63 DEFINE_STANDARD_RTTI(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_HCurve) 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