1 // Created on: 1993-03-24
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_Curve_HeaderFile
18 #define _Geom2d_Curve_HeaderFile
20 #include <Standard.hxx>
21 #include <Standard_Type.hxx>
23 #include <Geom2d_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 Geom2d_UndefinedDerivative;
31 class Geom2d_UndefinedValue;
38 DEFINE_STANDARD_HANDLE(Geom2d_Curve, Geom2d_Geometry)
40 //! The abstract class Curve describes the common
41 //! behavior of curves in 2D space. The Geom2d
42 //! package provides numerous concrete classes of
43 //! derived curves, including lines, circles, conics, Bezier
44 //! or BSpline curves, etc.
45 //! The main characteristic of these curves is that they
46 //! are parameterized. The Geom2d_Curve class shows:
47 //! - how to work with the parametric equation of a
48 //! curve in order to calculate the point of parameter
49 //! u, together with the vector tangent and the
50 //! derivative 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
61 //! explicitly states so.
63 //! The Geom2d package does not prevent the
64 //! construction of curves with null length or curves which
66 class Geom2d_Curve : public Geom2d_Geometry
73 //! Changes the direction of parametrization of <me>.
74 //! The "FirstParameter" and the "LastParameter" are not changed
75 //! but the orientation of the curve is modified. If the curve
76 //! is bounded the StartPoint of the initial curve becomes the
77 //! EndPoint of the reversed curve and the EndPoint of the initial
78 //! curve becomes the StartPoint of the reversed curve.
79 Standard_EXPORT virtual void Reverse() = 0;
81 //! Computes the parameter on the reversed curve for
82 //! the point of parameter U on this curve.
83 //! Note: The point of parameter U on this curve is
84 //! identical to the point of parameter
85 //! ReversedParameter(U) on the reversed curve.
86 Standard_EXPORT virtual Standard_Real ReversedParameter (const Standard_Real U) const = 0;
88 //! Computes the parameter on the curve transformed by
89 //! T for the point of parameter U on this curve.
90 //! Note: this function generally returns U but it can be
91 //! redefined (for example, on a line).
92 Standard_EXPORT virtual Standard_Real TransformedParameter (const Standard_Real U, const gp_Trsf2d& T) const;
94 //! Returns the coefficient required to compute the
95 //! parametric transformation of this curve when
96 //! transformation T is applied. This coefficient is the
97 //! ratio between the parameter of a point on this curve
98 //! and the parameter of the transformed point on the
99 //! new curve transformed by T.
100 //! Note: this function generally returns 1. but it can be
101 //! redefined (for example, on a line).
102 Standard_EXPORT virtual Standard_Real ParametricTransformation (const gp_Trsf2d& T) const;
104 //! Creates a reversed duplicate Changes the orientation of this curve. The first and
105 //! last parameters are not changed, but the parametric
106 //! direction of the curve is reversed.
107 //! If the curve is bounded:
108 //! - the start point of the initial curve becomes the end
109 //! point of the reversed curve, and
110 //! - the end point of the initial curve becomes the start
111 //! point of the reversed curve.
112 //! - Reversed creates a new curve.
113 Standard_EXPORT Handle(Geom2d_Curve) Reversed() const;
115 //! Returns the value of the first parameter.
117 //! It can be RealFirst or RealLast from package Standard
118 //! if the curve is infinite
119 Standard_EXPORT virtual Standard_Real FirstParameter() const = 0;
121 //! Value of the last parameter.
123 //! It can be RealFirst or RealLast from package Standard
124 //! if the curve is infinite
125 Standard_EXPORT virtual Standard_Real LastParameter() const = 0;
127 //! Returns true if the curve is closed.
129 //! Some curves such as circle are always closed, others such as line
130 //! are never closed (by definition).
131 //! Some Curves such as OffsetCurve can be closed or not. These curves
132 //! are considered as closed if the distance between the first point
133 //! and the last point of the curve is lower or equal to the Resolution
134 //! from package gp wich is a fixed criterion independant of the
136 Standard_EXPORT virtual Standard_Boolean IsClosed() const = 0;
139 //! Returns true if the parameter of the curve is periodic.
140 //! It is possible only if the curve is closed and if the
141 //! following relation is satisfied :
142 //! for each parametric value U the distance between the point
143 //! P(u) and the point P (u + T) is lower or equal to Resolution
144 //! from package gp, T is the period and must be a constant.
145 //! There are three possibilities :
146 //! . the curve is never periodic by definition (SegmentLine)
147 //! . the curve is always periodic by definition (Circle)
148 //! . the curve can be defined as periodic (BSpline). In this case
149 //! a function SetPeriodic allows you to give the shape of the
150 //! curve. The general rule for this case is : if a curve can be
151 //! periodic or not the default periodicity set is non periodic
152 //! and you have to turn (explicitly) the curve into a periodic
153 //! curve if you want the curve to be periodic.
154 Standard_EXPORT virtual Standard_Boolean IsPeriodic() const = 0;
156 //! Returns thne period of this curve.
157 //! raises if the curve is not periodic
158 Standard_EXPORT virtual Standard_Real Period() const;
161 //! It is the global continuity of the curve :
162 //! C0 : only geometric continuity,
163 //! C1 : continuity of the first derivative all along the Curve,
164 //! C2 : continuity of the second derivative all along the Curve,
165 //! C3 : continuity of the third derivative all along the Curve,
166 //! G1 : tangency continuity all along the Curve,
167 //! G2 : curvature continuity all along the Curve,
168 //! CN : the order of continuity is infinite.
169 Standard_EXPORT virtual GeomAbs_Shape Continuity() const = 0;
171 //! Returns true if the degree of continuity of this curve is at least N.
172 //! Exceptions Standard_RangeError if N is less than 0.
173 Standard_EXPORT virtual Standard_Boolean IsCN (const Standard_Integer N) const = 0;
175 //! Returns in P the point of parameter U.
176 //! If the curve is periodic then the returned point is P(U) with
177 //! U = Ustart + (U - Uend) where Ustart and Uend are the
178 //! parametric bounds of the curve.
180 //! Raised only for the "OffsetCurve" if it is not possible to
181 //! compute the current point. For example when the first
182 //! derivative on the basis curve and the offset direction
184 Standard_EXPORT virtual void D0 (const Standard_Real U, gp_Pnt2d& P) const = 0;
187 //! Returns the point P of parameter U and the first derivative V1.
188 //! Raised if the continuity of the curve is not C1.
189 Standard_EXPORT virtual void D1 (const Standard_Real U, gp_Pnt2d& P, gp_Vec2d& V1) const = 0;
192 //! Returns the point P of parameter U, the first and second
193 //! derivatives V1 and V2.
194 //! Raised if the continuity of the curve is not C2.
195 Standard_EXPORT virtual void D2 (const Standard_Real U, gp_Pnt2d& P, gp_Vec2d& V1, gp_Vec2d& V2) const = 0;
198 //! Returns the point P of parameter U, the first, the second
199 //! and the third derivative.
200 //! Raised if the continuity of the curve is not C3.
201 Standard_EXPORT virtual void D3 (const Standard_Real U, gp_Pnt2d& P, gp_Vec2d& V1, gp_Vec2d& V2, gp_Vec2d& V3) const = 0;
203 //! For the point of parameter U of this curve, computes
204 //! the vector corresponding to the Nth derivative.
206 //! StdFail_UndefinedDerivative if:
207 //! - the continuity of the curve is not "CN", or
208 //! - the derivative vector cannot be computed easily;
209 //! this is the case with specific types of curve (for
210 //! example, a rational BSpline curve where N is greater than 3).
211 //! Standard_RangeError if N is less than 1.
212 Standard_EXPORT virtual gp_Vec2d DN (const Standard_Real U, const Standard_Integer N) const = 0;
214 //! Computes the point of parameter U on <me>.
215 //! If the curve is periodic then the returned point is P(U) with
216 //! U = Ustart + (U - Uend) where Ustart and Uend are the
217 //! parametric bounds of the curve.
219 //! it is implemented with D0.
221 //! Raised only for the "OffsetCurve" if it is not possible to
222 //! compute the current point. For example when the first
223 //! derivative on the basis curve and the offset direction
225 Standard_EXPORT gp_Pnt2d Value (const Standard_Real U) const;
230 DEFINE_STANDARD_RTTI(Geom2d_Curve,Geom2d_Geometry)
250 #endif // _Geom2d_Curve_HeaderFile