0026912: CLang 3.6.2 compiler warning [-Winconsistent-missing-override]
[occt.git] / src / Geom2d / Geom2d_OffsetCurve.hxx
CommitLineData
42cf5bc1 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
5//
6// This file is part of Open CASCADE Technology software library.
7//
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.
13//
14// Alternatively, this file may be used under the terms of Open CASCADE
15// commercial license or contractual agreement.
16
17#ifndef _Geom2d_OffsetCurve_HeaderFile
18#define _Geom2d_OffsetCurve_HeaderFile
19
20#include <Standard.hxx>
21#include <Standard_Type.hxx>
22
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>
28class Geom2d_Curve;
29class Standard_ConstructionError;
30class Standard_RangeError;
31class Standard_NoSuchObject;
32class Geom2d_UndefinedDerivative;
33class Geom2d_UndefinedValue;
34class Standard_NotImplemented;
35class gp_Pnt2d;
36class gp_Vec2d;
37class gp_Trsf2d;
38class Geom2d_Geometry;
39
40
41class Geom2d_OffsetCurve;
42DEFINE_STANDARD_HANDLE(Geom2d_OffsetCurve, Geom2d_Curve)
43
44
45//! This class implements the basis services for the creation,
46//! edition, modification and evaluation of planar offset curve.
47//! The offset curve is obtained by offsetting by distance along
48//! the normal to a basis curve defined in 2D space.
49//! The offset curve in this package can be a self intersecting
50//! curve even if the basis curve does not self-intersect.
51//! The self intersecting portions are not deleted at the
52//! construction time.
53//! An offset curve is a curve at constant distance (Offset) from a
54//! basis curve and the offset curve takes its parametrization from
55//! the basis curve. The Offset curve is in the direction of the
56//! normal to the basis curve N.
57//! The distance offset may be positive or negative to indicate the
58//! preferred side of the curve :
59//! . distance offset >0 => the curve is in the direction of N
60//! . distance offset >0 => the curve is in the direction of - N
61//! On the Offset curve :
62//! Value(u) = BasisCurve.Value(U) + (Offset * (T ^ Z)) / ||T ^ Z||
63//! where T is the tangent vector to the basis curve and Z the
64//! direction of the normal vector to the plane of the curve,
65//! N = T ^ Z defines the offset direction and should not have
66//! null length.
67//!
68//! Warnings :
69//! In this package we suppose that the continuity of the offset
70//! curve is one degree less than the continuity of the
71//! basis curve and we don't check that at any point ||T^Z|| != 0.0
72//!
73//! So to evaluate the curve it is better to check that the offset
74//! curve is well defined at any point because an exception could
75//! be raised. The check is not done in this package at the creation
76//! of the offset curve because the control needs the use of an
77//! algorithm which cannot be implemented in this package.
78//! The OffsetCurve is closed if the first point and the last point
79//! are the same (The distance between these two points is lower or
80//! equal to the Resolution sea package gp) . The OffsetCurve can be
81//! closed even if the basis curve is not closed.
82class Geom2d_OffsetCurve : public Geom2d_Curve
83{
84
85public:
86
87
88 //! Constructs a curve offset from the basis curve C,
89 //! where Offset is the distance between the offset
90 //! curve and the basis curve at any point.
91 //! A point on the offset curve is built by measuring the
92 //! offset value along a normal vector at a point on C.
93 //! This normal vector is obtained by rotating the
94 //! vector tangential to C at 90 degrees in the
95 //! anti-trigonometric sense. The side of C on which
96 //! the offset value is measured is indicated by this
97 //! normal vector if Offset is positive, or in the inverse
98 //! sense if Offset is negative.
99 //! If isNotCheckC0 = TRUE checking if basis curve has C0-continuity
100 //! is not made.
101 //! Warnings :
102 //! In this package the entities are not shared. The OffsetCurve is
103 //! built with a copy of the curve C. So when C is modified the
104 //! OffsetCurve is not modified
105 //! Warning! if isNotCheckC0 = false,
106 //! ConstructionError raised if the basis curve C is not at least C1.
107 //! No check is done to know if ||V^Z|| != 0.0 at any point.
108 Standard_EXPORT Geom2d_OffsetCurve(const Handle(Geom2d_Curve)& C, const Standard_Real Offset, const Standard_Boolean isNotCheckC0 = Standard_False);
109
110 //! Changes the direction of parametrization of <me>.
111 //! As a result:
112 //! - the basis curve is reversed,
113 //! - the start point of the initial curve becomes the end
114 //! point of the reversed curve,
115 //! - the end point of the initial curve becomes the start
116 //! point of the reversed curve, and
117 //! - the first and last parameters are recomputed.
79104795 118 Standard_EXPORT void Reverse() Standard_OVERRIDE;
42cf5bc1 119
120 //! Computes the parameter on the reversed curve for
121 //! the point of parameter U on this offset curve.
79104795 122 Standard_EXPORT Standard_Real ReversedParameter (const Standard_Real U) const Standard_OVERRIDE;
42cf5bc1 123
124 //! Changes this offset curve by assigning C as the
125 //! basis curve from which it is built.
126 //! If isNotCheckC0 = TRUE checking if basis curve has C0-continuity
127 //! is not made.
128 //! Exceptions
129 //! if isNotCheckC0 = false,
130 //! Standard_ConstructionError if the curve C is not at least "C1" continuous.
131 Standard_EXPORT void SetBasisCurve (const Handle(Geom2d_Curve)& C, const Standard_Boolean isNotCheckC0 = Standard_False);
132
133 //! Changes this offset curve by assigning D as the offset value.
134 Standard_EXPORT void SetOffsetValue (const Standard_Real D);
135
136 //! Returns the basis curve of this offset curve. The basis curve can be an offset curve.
137 Standard_EXPORT Handle(Geom2d_Curve) BasisCurve() const;
138
139
140 //! Continuity of the Offset curve :
141 //! C0 : only geometric continuity,
142 //! C1 : continuity of the first derivative all along the Curve,
143 //! C2 : continuity of the second derivative all along the Curve,
144 //! C3 : continuity of the third derivative all along the Curve,
145 //! G1 : tangency continuity all along the Curve,
146 //! G2 : curvature continuity all along the Curve,
147 //! CN : the order of continuity is infinite.
148 //! Warnings :
149 //! Returns the continuity of the basis curve - 1.
150 //! The offset curve must have a unique normal direction defined
151 //! at any point.
152 //! Value and derivatives
153 //!
154 //! Warnings :
155 //! The exception UndefinedValue or UndefinedDerivative is
156 //! raised if it is not possible to compute a unique offset
157 //! direction.
158 //! If T is the first derivative with not null length and
159 //! Z the direction normal to the plane of the curve, the
160 //! relation ||T(U) ^ Z|| != 0 must be satisfied to evaluate
161 //! the offset curve.
162 //! No check is done at the creation time and we suppose
163 //! in this package that the offset curve is well defined.
79104795 164 Standard_EXPORT GeomAbs_Shape Continuity() const Standard_OVERRIDE;
42cf5bc1 165
166 //! Warning! this should not be called
167 //! if the basis curve is not at least C1. Nevertheless
168 //! if used on portion where the curve is C1, it is OK
79104795 169 Standard_EXPORT void D0 (const Standard_Real U, gp_Pnt2d& P) const Standard_OVERRIDE;
42cf5bc1 170
171 //! Warning! this should not be called
172 //! if the continuity of the basis curve is not C2.
173 //! Nevertheless, it's OK to use it on portion
174 //! where the curve is C2
79104795 175 Standard_EXPORT void D1 (const Standard_Real U, gp_Pnt2d& P, gp_Vec2d& V1) const Standard_OVERRIDE;
42cf5bc1 176
177 //! Warning! This should not be called
178 //! if the continuity of the basis curve is not C3.
179 //! Nevertheless, it's OK to use it on portion
180 //! where the curve is C3
79104795 181 Standard_EXPORT void D2 (const Standard_Real U, gp_Pnt2d& P, gp_Vec2d& V1, gp_Vec2d& V2) const Standard_OVERRIDE;
42cf5bc1 182
183 //! Warning! This should not be called
184 //! if the continuity of the basis curve is not C4.
185 //! Nevertheless, it's OK to use it on portion
186 //! where the curve is C4
79104795 187 Standard_EXPORT void D3 (const Standard_Real U, gp_Pnt2d& P, gp_Vec2d& V1, gp_Vec2d& V2, gp_Vec2d& V3) const Standard_OVERRIDE;
42cf5bc1 188
189 //! The returned vector gives the value of the derivative
190 //! for the order of derivation N.
191 //! Warning! this should not be called
192 //! raises UndefunedDerivative if the continuity of the basis curve is not CN+1.
193 //! Nevertheless, it's OK to use it on portion
194 //! where the curve is CN+1
195 //! raises RangeError if N < 1.
196 //! raises NotImplemented if N > 3.
197 //! The following functions compute the value and derivatives
198 //! on the offset curve and returns the derivatives on the
199 //! basis curve too.
200 //! The computation of the value and derivatives on the basis
201 //! curve are used to evaluate the offset curve
202 //! Warnings :
203 //! The exception UndefinedValue or UndefinedDerivative is
204 //! raised if it is not possible to compute a unique offset direction.
79104795 205 Standard_EXPORT gp_Vec2d DN (const Standard_Real U, const Standard_Integer N) const Standard_OVERRIDE;
42cf5bc1 206
207 //! Warning! this should not be called
208 //! if the basis curve is not at least C1. Nevertheless
209 //! if used on portion where the curve is C1, it is OK
210 Standard_EXPORT void Value (const Standard_Real U, gp_Pnt2d& P, gp_Pnt2d& Pbasis, gp_Vec2d& V1basis) const;
211
212 //! Warning! this should not be called
213 //! if the continuity of the basis curve is not C1.
214 //! Nevertheless, it's OK to use it on portion
215 //! where the curve is C1
216 Standard_EXPORT void D1 (const Standard_Real U, gp_Pnt2d& P, gp_Pnt2d& Pbasis, gp_Vec2d& V1, gp_Vec2d& V1basis, gp_Vec2d& V2basis) const;
217
218 //! Warning! this should not be called
219 //! if the continuity of the basis curve is not C3.
220 //! Nevertheless, it's OK to use it on portion
221 //! where the curve is C3
222 Standard_EXPORT void D2 (const Standard_Real U, gp_Pnt2d& P, gp_Pnt2d& Pbasis, gp_Vec2d& V1, gp_Vec2d& V2, gp_Vec2d& V1basis, gp_Vec2d& V2basis, gp_Vec2d& V3basis) const;
223
79104795 224 Standard_EXPORT Standard_Real FirstParameter() const Standard_OVERRIDE;
42cf5bc1 225
226 //! Returns the value of the first or last parameter of this
227 //! offset curve. The first parameter corresponds to the
228 //! start point of the curve. The last parameter
229 //! corresponds to the end point.
230 //! Note: the first and last parameters of this offset curve
231 //! are also the ones of its basis curve.
79104795 232 Standard_EXPORT Standard_Real LastParameter() const Standard_OVERRIDE;
42cf5bc1 233
234 //! Returns the offset value of this offset curve.
235 Standard_EXPORT Standard_Real Offset() const;
236
237
238 //! Returns True if the distance between the start point
239 //! and the end point of the curve is lower or equal to
240 //! Resolution from package gp.
79104795 241 Standard_EXPORT Standard_Boolean IsClosed() const Standard_OVERRIDE;
42cf5bc1 242
243 //! Is the order of continuity of the curve N ?
244 //! Warnings :
245 //! This method answer True if the continuity of the basis curve
246 //! is N + 1. We suppose in this class that a normal direction
247 //! to the basis curve (used to compute the offset curve) is
248 //! defined at any point on the basis curve.
249 //! Raised if N < 0.
79104795 250 Standard_EXPORT Standard_Boolean IsCN (const Standard_Integer N) const Standard_OVERRIDE;
42cf5bc1 251
252 //! Is the parametrization of a curve is periodic ?
253 //! If the basis curve is a circle or an ellipse the corresponding
254 //! OffsetCurve is periodic. If the basis curve can't be periodic
255 //! (for example BezierCurve) the OffsetCurve can't be periodic.
79104795 256 Standard_EXPORT Standard_Boolean IsPeriodic() const Standard_OVERRIDE;
42cf5bc1 257
258 //! Returns the period of this offset curve, i.e. the period
259 //! of the basis curve of this offset curve.
260 //! Exceptions
261 //! Standard_NoSuchObject if the basis curve is not periodic.
262 Standard_EXPORT virtual Standard_Real Period() const Standard_OVERRIDE;
263
264 //! Applies the transformation T to this offset curve.
265 //! Note: the basis curve is also modified.
79104795 266 Standard_EXPORT void Transform (const gp_Trsf2d& T) Standard_OVERRIDE;
42cf5bc1 267
268 //! Returns the parameter on the transformed curve for
269 //! the transform of the point of parameter U on <me>.
270 //!
271 //! me->Transformed(T)->Value(me->TransformedParameter(U,T))
272 //!
273 //! is the same point as
274 //!
275 //! me->Value(U).Transformed(T)
276 //!
277 //! This methods calls the basis curve method.
278 Standard_EXPORT virtual Standard_Real TransformedParameter (const Standard_Real U, const gp_Trsf2d& T) const Standard_OVERRIDE;
279
280 //! Returns a coefficient to compute the parameter on
281 //! the transformed curve for the transform of the
282 //! point on <me>.
283 //!
284 //! Transformed(T)->Value(U * ParametricTransformation(T))
285 //!
286 //! is the same point as
287 //!
288 //! Value(U).Transformed(T)
289 //!
290 //! This methods calls the basis curve method.
291 Standard_EXPORT virtual Standard_Real ParametricTransformation (const gp_Trsf2d& T) const Standard_OVERRIDE;
292
293 //! Creates a new object, which is a copy of this offset curve.
79104795 294 Standard_EXPORT Handle(Geom2d_Geometry) Copy() const Standard_OVERRIDE;
42cf5bc1 295
296 //! Returns continuity of the basis curve.
297 Standard_EXPORT GeomAbs_Shape GetBasisCurveContinuity() const;
298
299
300
301
302 DEFINE_STANDARD_RTTI(Geom2d_OffsetCurve,Geom2d_Curve)
303
304protected:
305
306
307
308
309private:
310
311
312 Handle(Geom2d_Curve) basisCurve;
313 Standard_Real offsetValue;
314 GeomAbs_Shape myBasisCurveContinuity;
315
316
317};
318
319
320
321
322
323
324
325#endif // _Geom2d_OffsetCurve_HeaderFile