1 // Created on: 1993-03-10
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 _Geom_OffsetCurve_HeaderFile
18 #define _Geom_OffsetCurve_HeaderFile
20 #include <Standard.hxx>
21 #include <Standard_Type.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>
29 #include <GeomEvaluator_OffsetCurve.hxx>
32 class Standard_ConstructionError;
33 class Standard_RangeError;
34 class Standard_NoSuchObject;
35 class Geom_UndefinedDerivative;
36 class Geom_UndefinedValue;
44 class Geom_OffsetCurve;
45 DEFINE_STANDARD_HANDLE(Geom_OffsetCurve, Geom_Curve)
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
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
65 //! On the Offset curve :
66 //! Value (U) = BasisCurve.Value(U) + (Offset * (T ^ V)) / ||T ^ V||
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.
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
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.
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.
89 class Geom_OffsetCurve : public Geom_Curve
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
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
110 //! Raised if the basis curve C is not at least C1.
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);
115 //! Changes the orientation of this offset curve.
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.
123 Standard_EXPORT void Reverse() Standard_OVERRIDE;
125 //! Computes the parameter on the reversed curve for
126 //! the point of parameter U on this offset curve.
127 Standard_EXPORT Standard_Real ReversedParameter (const Standard_Real U) const Standard_OVERRIDE;
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.
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);
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);
141 //! Changes this offset curve by assigning D as the offset value.
142 Standard_EXPORT void SetOffsetValue (const Standard_Real D);
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;
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.
161 //! Returns the continuity of the basis curve - 1.
162 //! The offset curve must have a unique offset direction defined
164 Standard_EXPORT GeomAbs_Shape Continuity() const Standard_OVERRIDE;
166 //! Returns the reference vector of this offset curve.
167 //! Value and derivatives
169 //! The exception UndefinedValue or UndefinedDerivative is
170 //! raised if it is not possible to compute a unique offset
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;
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
182 Standard_EXPORT void D0 (const Standard_Real U, gp_Pnt& P) const Standard_OVERRIDE;
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
188 Standard_EXPORT void D1 (const Standard_Real U, gp_Pnt& P, gp_Vec& V1) const Standard_OVERRIDE;
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
194 Standard_EXPORT void D2 (const Standard_Real U, gp_Pnt& P, gp_Vec& V1, gp_Vec& V2) const Standard_OVERRIDE;
196 Standard_EXPORT void D3 (const Standard_Real U, gp_Pnt& P, gp_Vec& V1, gp_Vec& V2, gp_Vec& V3) const Standard_OVERRIDE;
199 //! The returned vector gives the value of the derivative
200 //! for the order of derivation N.
202 //! The following functions compute the value and derivatives
203 //! on the offset curve and returns the derivatives on the
205 //! The computation of the value and derivatives on the basis
206 //! curve are used to evaluate the offset curve
209 //! The exception UndefinedValue or UndefinedDerivative is
210 //! raised if it is not possible to compute a unique offset
213 Standard_EXPORT gp_Vec DN (const Standard_Real U, const Standard_Integer N) const Standard_OVERRIDE;
215 //! Returns the value of the first parameter of this
216 //! offset curve. The first parameter corresponds to the
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;
222 //! Returns the value of the last parameter of this
223 //! offset curve. The last parameter
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.
227 Standard_EXPORT Standard_Real LastParameter() const Standard_OVERRIDE;
229 //! Returns the offset value of this offset curve.
230 Standard_EXPORT Standard_Real Offset() const;
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.
235 Standard_EXPORT Standard_Boolean IsClosed() const Standard_OVERRIDE;
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.
244 Standard_EXPORT Standard_Boolean IsCN (const Standard_Integer N) const Standard_OVERRIDE;
246 //! Returns true if this offset curve is periodic, i.e. if the
247 //! basis curve of this offset curve is periodic.
248 Standard_EXPORT Standard_Boolean IsPeriodic() const Standard_OVERRIDE;
250 //! Returns the period of this offset curve, i.e. the period
251 //! of the basis curve of this offset curve.
253 //! Standard_NoSuchObject if the basis curve is not periodic.
254 Standard_EXPORT virtual Standard_Real Period() const Standard_OVERRIDE;
256 //! Applies the transformation T to this offset curve.
257 //! Note: the basis curve is also modified.
258 Standard_EXPORT void Transform (const gp_Trsf& T) Standard_OVERRIDE;
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;
268 //! Returns a coefficient to compute the parameter on
269 //! the transformed curve for the transform of the
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;
278 //! Creates a new object which is a copy of this offset curve.
279 Standard_EXPORT Handle(Geom_Geometry) Copy() const Standard_OVERRIDE;
281 //! Returns continuity of the basis curve.
282 Standard_EXPORT GeomAbs_Shape GetBasisCurveContinuity() const;
284 //! Dumps the content of me into the stream
285 Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const Standard_OVERRIDE;
290 DEFINE_STANDARD_RTTIEXT(Geom_OffsetCurve,Geom_Curve)
300 Handle(Geom_Curve) basisCurve;
302 Standard_Real offsetValue;
303 GeomAbs_Shape myBasisCurveContinuity;
304 Handle(GeomEvaluator_OffsetCurve) myEvaluator;
314 #endif // _Geom_OffsetCurve_HeaderFile