1 // Created on: 1993-03-24
2 // Created by: Philippe DAUTRY
3 // Copyright (c) 1993-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
6 // This file is part of Open CASCADE Technology software library.
8 // This library is free software; you can redistribute it and/or modify it under
9 // the terms of the GNU Lesser General Public License version 2.1 as published
10 // by the Free Software Foundation, with special exception defined in the file
11 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12 // distribution for complete text of the license and disclaimer of any warranty.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
17 #ifndef _Geom2d_OffsetCurve_HeaderFile
18 #define _Geom2d_OffsetCurve_HeaderFile
20 #include <Standard.hxx>
21 #include <Standard_Type.hxx>
23 #include <Standard_Real.hxx>
24 #include <GeomAbs_Shape.hxx>
25 #include <Geom2d_Curve.hxx>
26 #include <Standard_Boolean.hxx>
27 #include <Standard_Integer.hxx>
28 #include <Geom2dEvaluator_OffsetCurve.hxx>
31 class Standard_ConstructionError;
32 class Standard_RangeError;
33 class Standard_NoSuchObject;
34 class Geom2d_UndefinedDerivative;
35 class Geom2d_UndefinedValue;
36 class Standard_NotImplemented;
40 class Geom2d_Geometry;
43 class Geom2d_OffsetCurve;
44 DEFINE_STANDARD_HANDLE(Geom2d_OffsetCurve, Geom2d_Curve)
47 //! This class implements the basis services for the creation,
48 //! edition, modification and evaluation of planar offset curve.
49 //! The offset curve is obtained by offsetting by distance along
50 //! the normal to a basis curve defined in 2D space.
51 //! The offset curve in this package can be a self intersecting
52 //! curve even if the basis curve does not self-intersect.
53 //! The self intersecting portions are not deleted at the
54 //! construction time.
55 //! An offset curve is a curve at constant distance (Offset) from a
56 //! basis curve and the offset curve takes its parametrization from
57 //! the basis curve. The Offset curve is in the direction of the
58 //! normal to the basis curve N.
59 //! The distance offset may be positive or negative to indicate the
60 //! preferred side of the curve :
61 //! . distance offset >0 => the curve is in the direction of N
62 //! . distance offset >0 => the curve is in the direction of - N
63 //! On the Offset curve :
64 //! Value(u) = BasisCurve.Value(U) + (Offset * (T ^ Z)) / ||T ^ Z||
65 //! where T is the tangent vector to the basis curve and Z the
66 //! direction of the normal vector to the plane of the curve,
67 //! N = T ^ Z defines the offset direction and should not have
71 //! In this package we suppose that the continuity of the offset
72 //! curve is one degree less than the continuity of the
73 //! basis curve and we don't check that at any point ||T^Z|| != 0.0
75 //! So to evaluate the curve it is better to check that the offset
76 //! curve is well defined at any point because an exception could
77 //! be raised. The check is not done in this package at the creation
78 //! of the offset curve because the control needs the use of an
79 //! algorithm which cannot be implemented in this package.
80 //! The OffsetCurve is closed if the first point and the last point
81 //! are the same (The distance between these two points is lower or
82 //! equal to the Resolution sea package gp) . The OffsetCurve can be
83 //! closed even if the basis curve is not closed.
84 class Geom2d_OffsetCurve : public Geom2d_Curve
90 //! Constructs a curve offset from the basis curve C,
91 //! where Offset is the distance between the offset
92 //! curve and the basis curve at any point.
93 //! A point on the offset curve is built by measuring the
94 //! offset value along a normal vector at a point on C.
95 //! This normal vector is obtained by rotating the
96 //! vector tangential to C at 90 degrees in the
97 //! anti-trigonometric sense. The side of C on which
98 //! the offset value is measured is indicated by this
99 //! normal vector if Offset is positive, or in the inverse
100 //! sense if Offset is negative.
101 //! If isNotCheckC0 = TRUE checking if basis curve has C0-continuity
104 //! In this package the entities are not shared. The OffsetCurve is
105 //! built with a copy of the curve C. So when C is modified the
106 //! OffsetCurve is not modified
107 //! Warning! if isNotCheckC0 = false,
108 //! ConstructionError raised if the basis curve C is not at least C1.
109 //! No check is done to know if ||V^Z|| != 0.0 at any point.
110 Standard_EXPORT Geom2d_OffsetCurve(const Handle(Geom2d_Curve)& C, const Standard_Real Offset, const Standard_Boolean isNotCheckC0 = Standard_False);
112 //! Changes the direction of parametrization of <me>.
114 //! - the basis curve is reversed,
115 //! - the start point of the initial curve becomes the end
116 //! point of the reversed curve,
117 //! - the end point of the initial curve becomes the start
118 //! point of the reversed curve, and
119 //! - the first and last parameters are recomputed.
120 Standard_EXPORT void Reverse() Standard_OVERRIDE;
122 //! Computes the parameter on the reversed curve for
123 //! the point of parameter U on this offset curve.
124 Standard_EXPORT Standard_Real ReversedParameter (const Standard_Real U) const Standard_OVERRIDE;
126 //! Changes this offset curve by assigning C as the
127 //! basis curve from which it is built.
128 //! If isNotCheckC0 = TRUE checking if basis curve has C0-continuity
131 //! if isNotCheckC0 = false,
132 //! Standard_ConstructionError if the curve C is not at least "C1" continuous.
133 Standard_EXPORT void SetBasisCurve (const Handle(Geom2d_Curve)& C, const Standard_Boolean isNotCheckC0 = Standard_False);
135 //! Changes this offset curve by assigning D as the offset value.
136 Standard_EXPORT void SetOffsetValue (const Standard_Real D);
138 //! Returns the basis curve of this offset curve. The basis curve can be an offset curve.
139 Standard_EXPORT Handle(Geom2d_Curve) BasisCurve() const;
142 //! Continuity of the Offset curve :
143 //! C0 : only geometric continuity,
144 //! C1 : continuity of the first derivative all along the Curve,
145 //! C2 : continuity of the second derivative all along the Curve,
146 //! C3 : continuity of the third derivative all along the Curve,
147 //! G1 : tangency continuity all along the Curve,
148 //! G2 : curvature continuity all along the Curve,
149 //! CN : the order of continuity is infinite.
151 //! Returns the continuity of the basis curve - 1.
152 //! The offset curve must have a unique normal direction defined
154 //! Value and derivatives
157 //! The exception UndefinedValue or UndefinedDerivative is
158 //! raised if it is not possible to compute a unique offset
160 //! If T is the first derivative with not null length and
161 //! Z the direction normal to the plane of the curve, the
162 //! relation ||T(U) ^ Z|| != 0 must be satisfied to evaluate
163 //! the offset curve.
164 //! No check is done at the creation time and we suppose
165 //! in this package that the offset curve is well defined.
166 Standard_EXPORT GeomAbs_Shape Continuity() const Standard_OVERRIDE;
168 //! Warning! this should not be called
169 //! if the basis curve is not at least C1. Nevertheless
170 //! if used on portion where the curve is C1, it is OK
171 Standard_EXPORT void D0 (const Standard_Real U, gp_Pnt2d& P) const Standard_OVERRIDE;
173 //! Warning! this should not be called
174 //! if the continuity of the basis curve is not C2.
175 //! Nevertheless, it's OK to use it on portion
176 //! where the curve is C2
177 Standard_EXPORT void D1 (const Standard_Real U, gp_Pnt2d& P, gp_Vec2d& V1) const Standard_OVERRIDE;
179 //! Warning! This should not be called
180 //! if the continuity of the basis curve is not C3.
181 //! Nevertheless, it's OK to use it on portion
182 //! where the curve is C3
183 Standard_EXPORT void D2 (const Standard_Real U, gp_Pnt2d& P, gp_Vec2d& V1, gp_Vec2d& V2) const Standard_OVERRIDE;
185 //! Warning! This should not be called
186 //! if the continuity of the basis curve is not C4.
187 //! Nevertheless, it's OK to use it on portion
188 //! where the curve is C4
189 Standard_EXPORT void D3 (const Standard_Real U, gp_Pnt2d& P, gp_Vec2d& V1, gp_Vec2d& V2, gp_Vec2d& V3) const Standard_OVERRIDE;
191 //! The returned vector gives the value of the derivative
192 //! for the order of derivation N.
193 //! Warning! this should not be called
194 //! raises UndefunedDerivative if the continuity of the basis curve is not CN+1.
195 //! Nevertheless, it's OK to use it on portion
196 //! where the curve is CN+1
197 //! raises RangeError if N < 1.
198 //! raises NotImplemented if N > 3.
199 //! The following functions compute the value and derivatives
200 //! on the offset curve and returns the derivatives on the
202 //! The computation of the value and derivatives on the basis
203 //! curve are used to evaluate the offset curve
205 //! The exception UndefinedValue or UndefinedDerivative is
206 //! raised if it is not possible to compute a unique offset direction.
207 Standard_EXPORT gp_Vec2d DN (const Standard_Real U, const Standard_Integer N) const Standard_OVERRIDE;
209 //! Returns the value of the first parameter of this
210 //! offset curve. The first parameter corresponds to the
211 //! start point of the curve.
212 //! Note: the first and last parameters of this offset curve
213 //! are also the ones of its basis curve.
214 Standard_EXPORT Standard_Real FirstParameter() const Standard_OVERRIDE;
216 //! Returns the value of the last parameter of this
217 //! offset curve. The last parameter
218 //! corresponds to the end point.
219 //! Note: the first and last parameters of this offset curve
220 //! are also the ones of its basis curve.
221 Standard_EXPORT Standard_Real LastParameter() const Standard_OVERRIDE;
223 //! Returns the offset value of this offset curve.
224 Standard_EXPORT Standard_Real Offset() const;
227 //! Returns True if the distance between the start point
228 //! and the end point of the curve is lower or equal to
229 //! Resolution from package gp.
230 Standard_EXPORT Standard_Boolean IsClosed() const Standard_OVERRIDE;
232 //! Is the order of continuity of the curve N ?
234 //! This method answer True if the continuity of the basis curve
235 //! is N + 1. We suppose in this class that a normal direction
236 //! to the basis curve (used to compute the offset curve) is
237 //! defined at any point on the basis curve.
239 Standard_EXPORT Standard_Boolean IsCN (const Standard_Integer N) const Standard_OVERRIDE;
241 //! Is the parametrization of a curve is periodic ?
242 //! If the basis curve is a circle or an ellipse the corresponding
243 //! OffsetCurve is periodic. If the basis curve can't be periodic
244 //! (for example BezierCurve) the OffsetCurve can't be periodic.
245 Standard_EXPORT Standard_Boolean IsPeriodic() const Standard_OVERRIDE;
247 //! Returns the period of this offset curve, i.e. the period
248 //! of the basis curve of this offset curve.
250 //! Standard_NoSuchObject if the basis curve is not periodic.
251 Standard_EXPORT virtual Standard_Real Period() const Standard_OVERRIDE;
253 //! Applies the transformation T to this offset curve.
254 //! Note: the basis curve is also modified.
255 Standard_EXPORT void Transform (const gp_Trsf2d& T) Standard_OVERRIDE;
257 //! Returns the parameter on the transformed curve for
258 //! the transform of the point of parameter U on <me>.
260 //! me->Transformed(T)->Value(me->TransformedParameter(U,T))
262 //! is the same point as
264 //! me->Value(U).Transformed(T)
266 //! This methods calls the basis curve method.
267 Standard_EXPORT virtual Standard_Real TransformedParameter (const Standard_Real U, const gp_Trsf2d& T) const Standard_OVERRIDE;
269 //! Returns a coefficient to compute the parameter on
270 //! the transformed curve for the transform of the
273 //! Transformed(T)->Value(U * ParametricTransformation(T))
275 //! is the same point as
277 //! Value(U).Transformed(T)
279 //! This methods calls the basis curve method.
280 Standard_EXPORT virtual Standard_Real ParametricTransformation (const gp_Trsf2d& T) const Standard_OVERRIDE;
282 //! Creates a new object, which is a copy of this offset curve.
283 Standard_EXPORT Handle(Geom2d_Geometry) Copy() const Standard_OVERRIDE;
285 //! Returns continuity of the basis curve.
286 Standard_EXPORT GeomAbs_Shape GetBasisCurveContinuity() const;
291 DEFINE_STANDARD_RTTIEXT(Geom2d_OffsetCurve,Geom2d_Curve)
301 Handle(Geom2d_Curve) basisCurve;
302 Standard_Real offsetValue;
303 GeomAbs_Shape myBasisCurveContinuity;
304 Handle(Geom2dEvaluator_OffsetCurve) myEvaluator;
314 #endif // _Geom2d_OffsetCurve_HeaderFile