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_TrimmedCurve_HeaderFile
18 #define _Geom2d_TrimmedCurve_HeaderFile
20 #include <Standard.hxx>
21 #include <Standard_Type.hxx>
23 #include <Standard_Real.hxx>
24 #include <Geom2d_BoundedCurve.hxx>
25 #include <Standard_Boolean.hxx>
26 #include <GeomAbs_Shape.hxx>
27 #include <Standard_Integer.hxx>
29 class Standard_ConstructionError;
30 class Standard_RangeError;
31 class Standard_NoSuchObject;
32 class Geom2d_UndefinedDerivative;
33 class Geom2d_UndefinedValue;
37 class Geom2d_Geometry;
40 class Geom2d_TrimmedCurve;
41 DEFINE_STANDARD_HANDLE(Geom2d_TrimmedCurve, Geom2d_BoundedCurve)
44 //! Defines a portion of a curve limited by two values of
45 //! parameters inside the parametric domain of the curve.
46 //! The trimmed curve is defined by:
47 //! - the basis curve, and
48 //! - the two parameter values which limit it.
49 //! The trimmed curve can either have the same
50 //! orientation as the basis curve or the opposite orientation.
51 class Geom2d_TrimmedCurve : public Geom2d_BoundedCurve
58 //! Creates a trimmed curve from the basis curve C limited between
61 //! . U1 can be greater or lower than U2.
62 //! . The returned curve is oriented from U1 to U2.
63 //! . If the basis curve C is periodic there is an ambiguity
64 //! because two parts are available. In this case by default
65 //! the trimmed curve has the same orientation as the basis
66 //! curve (Sense = True). If Sense = False then the orientation
67 //! of the trimmed curve is opposite to the orientation of the
69 //! If the curve is closed but not periodic it is not possible
70 //! to keep the part of the curve including the junction point
71 //! (except if the junction point is at the beginning or
72 //! at the end of the trimmed curve) because you could lose the
73 //! fundamental characteristics of the basis curve which are
74 //! used for example to compute the derivatives of the trimmed
75 //! curve. So for a closed curve the rules are the same as for
78 //! In this package the entities are not shared. The TrimmedCurve is
79 //! built with a copy of the curve C. So when C is modified the
80 //! TrimmedCurve is not modified
82 //! If <C> is periodic and <theAdjustPeriodic> is True, parametrics
83 //! bounds of the TrimmedCurve, can be different to [<U1>;<U2>},
84 //! if <U1> or <U2> are not in the principal period.
86 //! For more explanation see the scheme given with this class.
87 //! Raises ConstructionError the C is not periodic and U1 or U2 are out of
89 //! Raised if U1 = U2.
90 Standard_EXPORT Geom2d_TrimmedCurve(const Handle(Geom2d_Curve)& C, const Standard_Real U1, const Standard_Real U2, const Standard_Boolean Sense = Standard_True, const Standard_Boolean theAdjustPeriodic = Standard_True);
93 //! Changes the direction of parametrization of <me>. The first and
94 //! the last parametric values are modified. The "StartPoint"
95 //! of the initial curve becomes the "EndPoint" of the reversed
96 //! curve and the "EndPoint" of the initial curve becomes the
97 //! "StartPoint" of the reversed curve.
98 //! Example - If the trimmed curve is defined by:
99 //! - a basis curve whose parameter range is [ 0.,1. ], and
100 //! - the two trim values U1 (first parameter) and U2 (last parameter),
101 //! the reversed trimmed curve is defined by:
102 //! - the reversed basis curve, whose parameter range is still [ 0.,1. ], and
103 //! - the two trim values 1. - U2 (first parameter)
104 //! and 1. - U1 (last parameter).
105 Standard_EXPORT void Reverse() Standard_OVERRIDE;
107 //! Returns the parameter on the reversed curve for
108 //! the point of parameter U on <me>.
110 //! returns UFirst + ULast - U
111 Standard_EXPORT Standard_Real ReversedParameter (const Standard_Real U) const Standard_OVERRIDE;
113 //! Changes this trimmed curve, by redefining the
114 //! parameter values U1 and U2, which limit its basis curve.
115 //! Note: If the basis curve is periodic, the trimmed curve
116 //! has the same orientation as the basis curve if Sense
117 //! is true (default value) or the opposite orientation if Sense is false.
119 //! If the basis curve is periodic and theAdjustPeriodic is True,
120 //! the bounds of the trimmed curve may be different from U1 and U2 if the
121 //! parametric origin of the basis curve is within the arc
122 //! of the trimmed curve. In this case, the modified
123 //! parameter will be equal to U1 or U2 plus or minus the period.
124 //! If theAdjustPeriodic is False, parameters U1 and U2 will stay unchanged.
126 //! Standard_ConstructionError if:
127 //! - the basis curve is not periodic, and either U1 or U2
128 //! are outside the bounds of the basis curve, or
129 //! - U1 is equal to U2.
130 Standard_EXPORT void SetTrim (const Standard_Real U1, const Standard_Real U2, const Standard_Boolean Sense = Standard_True, const Standard_Boolean theAdjustPeriodic = Standard_True);
132 //! Returns the basis curve.
134 //! This function does not return a constant reference.
135 //! Consequently, any modification of the returned value
136 //! directly modifies the trimmed curve.
137 Standard_EXPORT Handle(Geom2d_Curve) BasisCurve() const;
140 //! Returns the global continuity of the basis curve of this trimmed 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 //! CN : the order of continuity is infinite.
146 Standard_EXPORT GeomAbs_Shape Continuity() const Standard_OVERRIDE;
149 //! Returns True if the order of continuity of the
150 //! trimmed curve is N. A trimmed curve is at least "C0" continuous.
152 //! The continuity of the trimmed curve can be greater than
153 //! the continuity of the basis curve because you consider
154 //! only a part of the basis curve.
156 Standard_EXPORT Standard_Boolean IsCN (const Standard_Integer N) const Standard_OVERRIDE;
159 //! Returns the end point of <me>. This point is the
160 //! evaluation of the curve for the "LastParameter".
161 Standard_EXPORT gp_Pnt2d EndPoint() const Standard_OVERRIDE;
164 //! Returns the value of the first parameter of <me>.
165 //! The first parameter is the parameter of the "StartPoint"
166 //! of the trimmed curve.
167 Standard_EXPORT Standard_Real FirstParameter() const Standard_OVERRIDE;
170 //! Returns True if the distance between the StartPoint and
171 //! the EndPoint is lower or equal to Resolution from package
173 Standard_EXPORT Standard_Boolean IsClosed() const Standard_OVERRIDE;
175 //! Always returns FALSE (independently of the type of basis curve).
176 Standard_EXPORT Standard_Boolean IsPeriodic() const Standard_OVERRIDE;
178 //! Returns the period of the basis curve of this trimmed curve.
180 //! Standard_NoSuchObject if the basis curve is not periodic.
181 Standard_EXPORT virtual Standard_Real Period() const Standard_OVERRIDE;
184 //! Returns the value of the last parameter of <me>.
185 //! The last parameter is the parameter of the "EndPoint" of the
187 Standard_EXPORT Standard_Real LastParameter() const Standard_OVERRIDE;
190 //! Returns the start point of <me>.
191 //! This point is the evaluation of the curve from the
192 //! "FirstParameter".
193 //! value and derivatives
195 //! The returned derivatives have the same orientation as the
196 //! derivatives of the basis curve.
197 Standard_EXPORT gp_Pnt2d StartPoint() const Standard_OVERRIDE;
200 //! If the basis curve is an OffsetCurve sometimes it is not
201 //! possible to do the evaluation of the curve at the parameter
202 //! U (see class OffsetCurve).
203 Standard_EXPORT void D0 (const Standard_Real U, gp_Pnt2d& P) const Standard_OVERRIDE;
205 //! Raised if the continuity of the curve is not C1.
206 Standard_EXPORT void D1 (const Standard_Real U, gp_Pnt2d& P, gp_Vec2d& V1) const Standard_OVERRIDE;
208 //! Raised if the continuity of the curve is not C2.
209 Standard_EXPORT void D2 (const Standard_Real U, gp_Pnt2d& P, gp_Vec2d& V1, gp_Vec2d& V2) const Standard_OVERRIDE;
211 //! Raised if the continuity of the curve is not C3.
212 Standard_EXPORT void D3 (const Standard_Real U, gp_Pnt2d& P, gp_Vec2d& V1, gp_Vec2d& V2, gp_Vec2d& V3) const Standard_OVERRIDE;
214 //! For the point of parameter U of this trimmed curve,
215 //! computes the vector corresponding to the Nth derivative.
217 //! The returned derivative vector has the same
218 //! orientation as the derivative vector of the basis curve,
219 //! even if the trimmed curve does not have the same
220 //! orientation as the basis curve.
222 //! Standard_RangeError if N is less than 1.
223 //! geometric transformations
224 Standard_EXPORT gp_Vec2d DN (const Standard_Real U, const Standard_Integer N) const Standard_OVERRIDE;
226 //! Applies the transformation T to this trimmed curve.
227 //! Warning The basis curve is also modified.
228 Standard_EXPORT void Transform (const gp_Trsf2d& T) Standard_OVERRIDE;
230 //! Returns the parameter on the transformed curve for
231 //! the transform of the point of parameter U on <me>.
233 //! me->Transformed(T)->Value(me->TransformedParameter(U,T))
235 //! is the same point as
237 //! me->Value(U).Transformed(T)
239 //! This methods calls the basis curve method.
240 Standard_EXPORT virtual Standard_Real TransformedParameter (const Standard_Real U, const gp_Trsf2d& T) const Standard_OVERRIDE;
242 //! Returns a coefficient to compute the parameter on
243 //! the transformed curve for the transform of the
246 //! Transformed(T)->Value(U * ParametricTransformation(T))
248 //! is the same point as
250 //! Value(U).Transformed(T)
252 //! This methods calls the basis curve method.
253 Standard_EXPORT virtual Standard_Real ParametricTransformation (const gp_Trsf2d& T) const Standard_OVERRIDE;
256 //! Creates a new object, which is a copy of this trimmed curve.
257 Standard_EXPORT Handle(Geom2d_Geometry) Copy() const Standard_OVERRIDE;
259 //! Dumps the content of me into the stream
260 Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const Standard_OVERRIDE;
265 DEFINE_STANDARD_RTTIEXT(Geom2d_TrimmedCurve,Geom2d_BoundedCurve)
275 Handle(Geom2d_Curve) basisCurve;
276 Standard_Real uTrim1;
277 Standard_Real uTrim2;
288 #endif // _Geom2d_TrimmedCurve_HeaderFile