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