0022048: Visualization, AIS_InteractiveContext - single object selection should alway...
[occt.git] / src / GeomEvaluator / GeomEvaluator_OffsetCurve.hxx
CommitLineData
d660a72a 1// Created on: 2015-09-21
2// Copyright (c) 2015 OPEN CASCADE SAS
3//
4// This file is part of Open CASCADE Technology software library.
5//
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.
11//
12// Alternatively, this file may be used under the terms of Open CASCADE
13// commercial license or contractual agreement.
14
15#ifndef _GeomEvaluator_OffsetCurve_HeaderFile
16#define _GeomEvaluator_OffsetCurve_HeaderFile
17
18#include <Geom_Curve.hxx>
19#include <GeomEvaluator_Curve.hxx>
20#include <gp_Dir.hxx>
21
22class GeomAdaptor_HCurve;
23
24//! Allows to calculate values and derivatives for offset curves in 3D
25class GeomEvaluator_OffsetCurve : public GeomEvaluator_Curve
26{
27public:
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);
38
39 //! Change the offset value
40 void SetOffsetValue(Standard_Real theOffset)
41 { myOffset = theOffset; }
42
43 void SetOffsetDirection(const gp_Dir& theDirection)
44 { myOffsetDir = theDirection; }
45
46 //! Value of curve
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;
62
92efcf78 63 DEFINE_STANDARD_RTTIEXT(GeomEvaluator_OffsetCurve,GeomEvaluator_Curve)
d660a72a 64
65private:
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,
71 gp_Vec& theD1,
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,
75 gp_Vec& theD1,
76 gp_Vec& theD2,
77 const gp_Vec& theD3,
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,
81 gp_Vec& theD1,
82 gp_Vec& theD2,
83 gp_Vec& theD3,
84 const gp_Vec& theD4,
85 const Standard_Boolean theIsDirChange) const;
86
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;
103
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,
108 gp_Vec& theD1,
109 gp_Vec& theD2,
110 gp_Vec& theD3,
111 gp_Vec& theD4) const;
112
113private:
114 Handle(Geom_Curve) myBaseCurve;
115 Handle(GeomAdaptor_HCurve) myBaseAdaptor;
116
117 Standard_Real myOffset; ///< offset value
118 gp_Dir myOffsetDir; ///< offset direction
119};
120
121DEFINE_STANDARD_HANDLE(GeomEvaluator_OffsetCurve, GeomEvaluator_Curve)
122
123
124#endif // _GeomEvaluator_OffsetCurve_HeaderFile