0031303: Different calculation of offset direction in Adaptor2d_OffsetCurve and Geom2...
[occt.git] / src / Geom2dEvaluator / Geom2dEvaluator_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 _Geom2dEvaluator_OffsetCurve_HeaderFile
16#define _Geom2dEvaluator_OffsetCurve_HeaderFile
17
18#include <Geom2d_Curve.hxx>
19#include <Geom2dEvaluator_Curve.hxx>
20
21class Geom2dAdaptor_HCurve;
22
23//! Allows to calculate values and derivatives for offset curves in 2D
24class Geom2dEvaluator_OffsetCurve : public Geom2dEvaluator_Curve
25{
26public:
27 //! Initialize evaluator by curve
28 Standard_EXPORT Geom2dEvaluator_OffsetCurve(
29 const Handle(Geom2d_Curve)& theBase,
30 const Standard_Real theOffset);
31 //! Initialize evaluator by curve adaptor
32 Standard_EXPORT Geom2dEvaluator_OffsetCurve(
33 const Handle(Geom2dAdaptor_HCurve)& theBase,
34 const Standard_Real theOffset);
35
36 //! Change the offset value
37 void SetOffsetValue(Standard_Real theOffset)
38 { myOffset = theOffset; }
39
40 //! Value of curve
41 Standard_EXPORT void D0(const Standard_Real theU,
42 gp_Pnt2d& theValue) const Standard_OVERRIDE;
43 //! Value and first derivatives of curve
44 Standard_EXPORT void D1(const Standard_Real theU,
45 gp_Pnt2d& theValue, gp_Vec2d& theD1) const Standard_OVERRIDE;
46 //! Value, first and second derivatives of curve
47 Standard_EXPORT void D2(const Standard_Real theU,
48 gp_Pnt2d& theValue, gp_Vec2d& theD1, gp_Vec2d& theD2) const Standard_OVERRIDE;
49 //! Value, first, second and third derivatives of curve
50 Standard_EXPORT void D3(const Standard_Real theU,
51 gp_Pnt2d& theValue, gp_Vec2d& theD1,
52 gp_Vec2d& theD2, gp_Vec2d& theD3) const Standard_OVERRIDE;
53 //! Calculates N-th derivatives of curve, where N = theDeriv. Raises if N < 1
54 Standard_EXPORT gp_Vec2d DN(const Standard_Real theU,
55 const Standard_Integer theDeriv) const Standard_OVERRIDE;
56
92efcf78 57 DEFINE_STANDARD_RTTIEXT(Geom2dEvaluator_OffsetCurve,Geom2dEvaluator_Curve)
d660a72a 58
59private:
d660a72a 60 //! Calculate value of base curve/adaptor
61 void BaseD0(const Standard_Real theU, gp_Pnt2d& theValue) const;
62 //! Calculate value and first derivatives of base curve/adaptor
63 void BaseD1(const Standard_Real theU,
64 gp_Pnt2d& theValue, gp_Vec2d& theD1) const;
65 //! Calculate value, first and second derivatives of base curve/adaptor
66 void BaseD2(const Standard_Real theU,
67 gp_Pnt2d& theValue, gp_Vec2d& theD1, gp_Vec2d& theD2) const;
68 //! Calculate value, first, second and third derivatives of base curve/adaptor
69 void BaseD3(const Standard_Real theU,
70 gp_Pnt2d& theValue, gp_Vec2d& theD1, gp_Vec2d& theD2, gp_Vec2d& theD3) const;
71 //! Calculate value and derivatives till 4th of base curve/adaptor
72 void BaseD4(const Standard_Real theU,
73 gp_Pnt2d& theValue, gp_Vec2d& theD1, gp_Vec2d& theD2, gp_Vec2d& theD3, gp_Vec2d& theD4) const;
74 //! Calculate N-th derivative of base curve/adaptor
75 gp_Vec2d BaseDN(const Standard_Real theU, const Standard_Integer theDeriv) const;
76
77 // Recalculate derivatives in the singular point
78 // Returns true if the direction of derivatives is changed
79 Standard_Boolean AdjustDerivative(const Standard_Integer theMaxDerivative,
80 const Standard_Real theU,
81 gp_Vec2d& theD1,
82 gp_Vec2d& theD2,
83 gp_Vec2d& theD3,
84 gp_Vec2d& theD4) const;
85
86private:
87 Handle(Geom2d_Curve) myBaseCurve;
88 Handle(Geom2dAdaptor_HCurve) myBaseAdaptor;
89
90 Standard_Real myOffset; ///< offset value
91};
92
93DEFINE_STANDARD_HANDLE(Geom2dEvaluator_OffsetCurve, Geom2dEvaluator_Curve)
94
95
96#endif // _Geom2dEvaluator_OffsetCurve_HeaderFile