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_Curve_HeaderFile
18 #define _Geom_Curve_HeaderFile
20 #include <Standard.hxx>
21 #include <Standard_Type.hxx>
23 #include <Geom_Geometry.hxx>
24 #include <Standard_Real.hxx>
25 #include <Standard_Boolean.hxx>
26 #include <GeomAbs_Shape.hxx>
27 #include <Standard_Integer.hxx>
28 class Standard_RangeError;
29 class Standard_NoSuchObject;
30 class Geom_UndefinedDerivative;
31 class Geom_UndefinedValue;
38 DEFINE_STANDARD_HANDLE(Geom_Curve, Geom_Geometry)
40 //! The abstract class Curve describes the common
41 //! behavior of curves in 3D space. The Geom package
42 //! provides numerous concrete classes of derived
43 //! curves, including lines, circles, conics, Bezier or
44 //! BSpline curves, etc.
45 //! The main characteristic of these curves is that they
46 //! are parameterized. The Geom_Curve class shows:
47 //! - how to work with the parametric equation of a curve
48 //! in order to calculate the point of parameter u,
49 //! together with the vector tangent and the derivative
50 //! vectors of order 2, 3,..., N at this point;
51 //! - how to obtain general information about the curve
52 //! (for example, level of continuity, closed
53 //! characteristics, periodicity, bounds of the parameter field);
54 //! - how the parameter changes when a geometric
55 //! transformation is applied to the curve or when the
56 //! orientation of the curve is inverted.
57 //! All curves must have a geometric continuity: a curve is
58 //! at least "C0". Generally, this property is checked at
59 //! the time of construction or when the curve is edited.
60 //! Where this is not the case, the documentation states so explicitly.
62 //! The Geom package does not prevent the
63 //! construction of curves with null length or curves which
65 class Geom_Curve : public Geom_Geometry
72 //! Changes the direction of parametrization of <me>.
73 //! The "FirstParameter" and the "LastParameter" are not changed
74 //! but the orientation of the curve is modified. If the curve
75 //! is bounded the StartPoint of the initial curve becomes the
76 //! EndPoint of the reversed curve and the EndPoint of the initial
77 //! curve becomes the StartPoint of the reversed curve.
78 Standard_EXPORT virtual void Reverse() = 0;
80 //! Returns the parameter on the reversed curve for
81 //! the point of parameter U on <me>.
83 //! me->Reversed()->Value(me->ReversedParameter(U))
85 //! is the same point as
88 Standard_EXPORT virtual Standard_Real ReversedParameter (const Standard_Real U) const = 0;
90 //! Returns the parameter on the transformed curve for
91 //! the transform of the point of parameter U on <me>.
93 //! me->Transformed(T)->Value(me->TransformedParameter(U,T))
95 //! is the same point as
97 //! me->Value(U).Transformed(T)
99 //! This methods returns <U>
101 //! It can be redefined. For example on the Line.
102 Standard_EXPORT virtual Standard_Real TransformedParameter (const Standard_Real U, const gp_Trsf& T) const;
104 //! Returns a coefficient to compute the parameter on
105 //! the transformed curve for the transform of the
108 //! Transformed(T)->Value(U * ParametricTransformation(T))
110 //! is the same point as
112 //! Value(U).Transformed(T)
114 //! This methods returns 1.
116 //! It can be redefined. For example on the Line.
117 Standard_EXPORT virtual Standard_Real ParametricTransformation (const gp_Trsf& T) const;
119 //! Returns a copy of <me> reversed.
120 Standard_NODISCARD Standard_EXPORT Handle(Geom_Curve) Reversed() const;
122 //! Returns the value of the first parameter.
124 //! It can be RealFirst from package Standard
125 //! if the curve is infinite
126 Standard_EXPORT virtual Standard_Real FirstParameter() const = 0;
128 //! Returns the value of the last parameter.
130 //! It can be RealLast from package Standard
131 //! if the curve is infinite
132 Standard_EXPORT virtual Standard_Real LastParameter() const = 0;
134 //! Returns true if the curve is closed.
135 //! Some curves such as circle are always closed, others such as line
136 //! are never closed (by definition).
137 //! Some Curves such as OffsetCurve can be closed or not. These curves
138 //! are considered as closed if the distance between the first point
139 //! and the last point of the curve is lower or equal to the Resolution
140 //! from package gp wich is a fixed criterion independant of the
142 Standard_EXPORT virtual Standard_Boolean IsClosed() const = 0;
144 //! Is the parametrization of the curve periodic ?
145 //! It is possible only if the curve is closed and if the
146 //! following relation is satisfied :
147 //! for each parametric value U the distance between the point
148 //! P(u) and the point P (u + T) is lower or equal to Resolution
149 //! from package gp, T is the period and must be a constant.
150 //! There are three possibilities :
151 //! . the curve is never periodic by definition (SegmentLine)
152 //! . the curve is always periodic by definition (Circle)
153 //! . the curve can be defined as periodic (BSpline). In this case
154 //! a function SetPeriodic allows you to give the shape of the
155 //! curve. The general rule for this case is : if a curve can be
156 //! periodic or not the default periodicity set is non periodic
157 //! and you have to turn (explicitly) the curve into a periodic
158 //! curve if you want the curve to be periodic.
159 Standard_EXPORT virtual Standard_Boolean IsPeriodic() const = 0;
161 //! Returns the period of this curve.
162 //! Exceptions Standard_NoSuchObject if this curve is not periodic.
163 Standard_EXPORT virtual Standard_Real Period() const;
165 //! It is the global continuity of the curve
166 //! C0 : only geometric continuity,
167 //! C1 : continuity of the first derivative all along the Curve,
168 //! C2 : continuity of the second derivative all along the Curve,
169 //! C3 : continuity of the third derivative all along the Curve,
170 //! G1 : tangency continuity all along the Curve,
171 //! G2 : curvature continuity all along the Curve,
172 //! CN : the order of continuity is infinite.
173 Standard_EXPORT virtual GeomAbs_Shape Continuity() const = 0;
175 //! Returns true if the degree of continuity of this curve is at least N.
176 //! Exceptions - Standard_RangeError if N is less than 0.
177 Standard_EXPORT virtual Standard_Boolean IsCN (const Standard_Integer N) const = 0;
179 //! Returns in P the point of parameter U.
180 //! If the curve is periodic then the returned point is P(U) with
181 //! U = Ustart + (U - Uend) where Ustart and Uend are the
182 //! parametric bounds of the curve.
184 //! Raised only for the "OffsetCurve" if it is not possible to
185 //! compute the current point. For example when the first
186 //! derivative on the basis curve and the offset direction
188 Standard_EXPORT virtual void D0 (const Standard_Real U, gp_Pnt& P) const = 0;
191 //! Returns the point P of parameter U and the first derivative V1.
192 //! Raised if the continuity of the curve is not C1.
193 Standard_EXPORT virtual void D1 (const Standard_Real U, gp_Pnt& P, gp_Vec& V1) const = 0;
196 //! Returns the point P of parameter U, the first and second
197 //! derivatives V1 and V2.
198 //! Raised if the continuity of the curve is not C2.
199 Standard_EXPORT virtual void D2 (const Standard_Real U, gp_Pnt& P, gp_Vec& V1, gp_Vec& V2) const = 0;
202 //! Returns the point P of parameter U, the first, the second
203 //! and the third derivative.
204 //! Raised if the continuity of the curve is not C3.
205 Standard_EXPORT virtual void D3 (const Standard_Real U, gp_Pnt& P, gp_Vec& V1, gp_Vec& V2, gp_Vec& V3) const = 0;
208 //! The returned vector gives the value of the derivative for the
209 //! order of derivation N.
210 //! Raised if the continuity of the curve is not CN.
212 //! Raised if the derivative cannot be computed
213 //! easily. e.g. rational bspline and n > 3.
215 Standard_EXPORT virtual gp_Vec DN (const Standard_Real U, const Standard_Integer N) const = 0;
217 //! Computes the point of parameter U on <me>.
218 //! If the curve is periodic then the returned point is P(U) with
219 //! U = Ustart + (U - Uend) where Ustart and Uend are the
220 //! parametric bounds of the curve.
221 //! it is implemented with D0.
223 //! Raised only for the "OffsetCurve" if it is not possible to
224 //! compute the current point. For example when the first
225 //! derivative on the basis curve and the offset direction are parallel.
226 Standard_EXPORT gp_Pnt Value (const Standard_Real U) const;
228 //! Dumps the content of me into the stream
229 Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const Standard_OVERRIDE;
234 DEFINE_STANDARD_RTTIEXT(Geom_Curve,Geom_Geometry)
254 #endif // _Geom_Curve_HeaderFile