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_TrimmedCurve_HeaderFile
18 #define _Geom_TrimmedCurve_HeaderFile
20 #include <Standard.hxx>
21 #include <Standard_Type.hxx>
23 #include <Geom_BoundedCurve.hxx>
24 #include <GeomAbs_Shape.hxx>
25 #include <Standard_Integer.hxx>
33 class Geom_TrimmedCurve;
34 DEFINE_STANDARD_HANDLE(Geom_TrimmedCurve, Geom_BoundedCurve)
36 //! Describes a portion of a curve (termed the "basis
37 //! curve") limited by two parameter values inside the
38 //! parametric domain of the basis curve.
39 //! The trimmed curve is defined by:
40 //! - the basis curve, and
41 //! - the two parameter values which limit it.
42 //! The trimmed curve can either have the same
43 //! orientation as the basis curve or the opposite orientation.
44 class Geom_TrimmedCurve : public Geom_BoundedCurve
50 //! Constructs a trimmed curve from the basis curve C
51 //! which is limited between parameter values U1 and U2.
52 //! Note: - U1 can be greater or less than U2; in both cases,
53 //! the returned curve is oriented from U1 to U2.
54 //! - If the basis curve C is periodic, there is an
55 //! ambiguity because two parts are available. In this
56 //! case, the trimmed curve has the same orientation
57 //! as the basis curve if Sense is true (default value)
58 //! or the opposite orientation if Sense is false.
59 //! - If the curve is closed but not periodic, it is not
60 //! possible to keep the part of the curve which
61 //! includes the junction point (except if the junction
62 //! point is at the beginning or at the end of the
63 //! trimmed curve). If you tried to do this, you could
64 //! alter the fundamental characteristics of the basis
65 //! curve, which are used, for example, to compute
66 //! the derivatives of the trimmed curve. The rules
67 //! for a closed curve are therefore the same as
68 //! those for an open curve.
69 //! Warning: The trimmed curve is built from a copy of curve C.
70 //! Therefore, when C is modified, the trimmed curve
72 //! - If the basis curve is periodic and theAdjustPeriodic is True,
73 //! the bounds of the trimmed curve may be different from U1 and U2
74 //! if the parametric origin of the basis curve is within
75 //! the arc of the trimmed curve. In this case, the
76 //! modified parameter will be equal to U1 or U2
77 //! plus or minus the period.
78 //! When theAdjustPeriodic is False, parameters U1 and U2 will be
79 //! the same, without adjustment into the first period.
81 //! Standard_ConstructionError if:
82 //! - C is not periodic and U1 or U2 is outside the
84 //! - U1 is equal to U2.
85 Standard_EXPORT Geom_TrimmedCurve(const Handle(Geom_Curve)& C, const Standard_Real U1, const Standard_Real U2, const Standard_Boolean Sense = Standard_True, const Standard_Boolean theAdjustPeriodic = Standard_True);
87 //! Changes the orientation of this trimmed curve.
89 //! - the basis curve is reversed,
90 //! - the start point of the initial curve becomes the
91 //! end point of the reversed curve,
92 //! - the end point of the initial curve becomes the
93 //! start point of the reversed curve,
94 //! - the first and last parameters are recomputed.
95 //! If the trimmed curve was defined by:
96 //! - a basis curve whose parameter range is [ 0., 1. ],
97 //! - the two trim values U1 (first parameter) and U2 (last parameter),
98 //! the reversed trimmed curve is defined by:
99 //! - the reversed basis curve, whose parameter range is still [ 0., 1. ],
100 //! - the two trim values 1. - U2 (first parameter) and 1. - U1 (last parameter).
101 Standard_EXPORT void Reverse() Standard_OVERRIDE;
103 //! Computes the parameter on the reversed curve for
104 //! the point of parameter U on this trimmed curve.
105 Standard_EXPORT Standard_Real ReversedParameter (const Standard_Real U) const Standard_OVERRIDE;
107 //! Changes this trimmed curve, by redefining the
108 //! parameter values U1 and U2 which limit its basis curve.
109 //! Note: If the basis curve is periodic, the trimmed curve
110 //! has the same orientation as the basis curve if Sense
111 //! is true (default value) or the opposite orientation if Sense is false.
113 //! If the basis curve is periodic and theAdjustPeriodic is True,
114 //! the bounds of the trimmed curve may be different from U1 and U2 if the
115 //! parametric origin of the basis curve is within the arc of
116 //! the trimmed curve. In this case, the modified
117 //! parameter will be equal to U1 or U2 plus or minus the period.
118 //! When theAdjustPeriodic is False, parameters U1 and U2 will be
119 //! the same, without adjustment into the first period.
121 //! Standard_ConstructionError if:
122 //! - the basis curve is not periodic, and either U1 or U2
123 //! are outside the bounds of the basis curve, or
124 //! - U1 is equal to U2.
125 Standard_EXPORT void SetTrim (const Standard_Real U1, const Standard_Real U2, const Standard_Boolean Sense = Standard_True, const Standard_Boolean theAdjustPeriodic = Standard_True);
127 //! Returns the basis curve.
129 //! This function does not return a constant reference.
130 //! Consequently, any modification of the returned value
131 //! directly modifies the trimmed curve.
132 Standard_EXPORT Handle(Geom_Curve) BasisCurve() const;
135 //! Returns the continuity of the curve :
136 //! C0 : only geometric continuity,
137 //! C1 : continuity of the first derivative all along the Curve,
138 //! C2 : continuity of the second derivative all along the Curve,
139 //! C3 : continuity of the third derivative all along the Curve,
140 //! CN : the order of continuity is infinite.
141 Standard_EXPORT GeomAbs_Shape Continuity() const Standard_OVERRIDE;
143 //! Returns true if the degree of continuity of the basis
144 //! curve of this trimmed curve is at least N. A trimmed
145 //! curve is at least "C0" continuous.
147 //! The continuity of the trimmed curve can be greater than
148 //! the continuity of the basis curve because you consider
149 //! only a part of the basis curve.
151 Standard_EXPORT Standard_Boolean IsCN (const Standard_Integer N) const Standard_OVERRIDE;
154 //! Returns the end point of <me>. This point is the
155 //! evaluation of the curve for the "LastParameter".
156 Standard_EXPORT gp_Pnt EndPoint() const Standard_OVERRIDE;
159 //! Returns the value of the first parameter of <me>.
160 //! The first parameter is the parameter of the "StartPoint"
161 //! of the trimmed curve.
162 Standard_EXPORT Standard_Real FirstParameter() const Standard_OVERRIDE;
165 //! Returns True if the distance between the StartPoint and
166 //! the EndPoint is lower or equal to Resolution from package gp.
167 Standard_EXPORT Standard_Boolean IsClosed() const Standard_OVERRIDE;
169 //! Always returns FALSE (independently of the type of basis curve).
170 Standard_EXPORT Standard_Boolean IsPeriodic() const Standard_OVERRIDE;
172 //! Returns the period of the basis curve of this trimmed curve.
174 //! Standard_NoSuchObject if the basis curve is not periodic.
175 Standard_EXPORT virtual Standard_Real Period() const Standard_OVERRIDE;
178 //! Returns the value of the last parameter of <me>.
179 //! The last parameter is the parameter of the "EndPoint" of the
181 Standard_EXPORT Standard_Real LastParameter() const Standard_OVERRIDE;
184 //! Returns the start point of <me>.
185 //! This point is the evaluation of the curve from the
186 //! "FirstParameter".
187 //! value and derivatives
189 //! The returned derivatives have the same orientation as the
190 //! derivatives of the basis curve even if the trimmed curve
191 //! has not the same orientation as the basis curve.
192 Standard_EXPORT gp_Pnt StartPoint() const Standard_OVERRIDE;
194 //! Returns in P the point of parameter U.
196 //! If the basis curve is an OffsetCurve sometimes it is not
197 //! possible to do the evaluation of the curve at the parameter
198 //! U (see class OffsetCurve).
199 Standard_EXPORT void D0 (const Standard_Real U, gp_Pnt& P) const Standard_OVERRIDE;
201 //! Raised if the continuity of the curve is not C1.
202 Standard_EXPORT void D1 (const Standard_Real U, gp_Pnt& P, gp_Vec& V1) const Standard_OVERRIDE;
204 //! Raised if the continuity of the curve is not C2.
205 Standard_EXPORT void D2 (const Standard_Real U, gp_Pnt& P, gp_Vec& V1, gp_Vec& V2) const Standard_OVERRIDE;
207 //! Raised if the continuity of the curve is not C3.
208 Standard_EXPORT void D3 (const Standard_Real U, gp_Pnt& P, gp_Vec& V1, gp_Vec& V2, gp_Vec& V3) const Standard_OVERRIDE;
210 //! N is the order of derivation.
211 //! Raised if the continuity of the curve is not CN.
213 //! geometric transformations
214 Standard_EXPORT gp_Vec DN (const Standard_Real U, const Standard_Integer N) const Standard_OVERRIDE;
216 //! Applies the transformation T to this trimmed curve.
217 //! Warning The basis curve is also modified.
218 Standard_EXPORT void Transform (const gp_Trsf& T) Standard_OVERRIDE;
220 //! Returns the parameter on the transformed curve for
221 //! the transform of the point of parameter U on <me>.
223 //! me->Transformed(T)->Value(me->TransformedParameter(U,T))
225 //! is the same point as
227 //! me->Value(U).Transformed(T)
229 //! This methods calls the basis curve method.
230 Standard_EXPORT virtual Standard_Real TransformedParameter (const Standard_Real U, const gp_Trsf& T) const Standard_OVERRIDE;
232 //! Returns a coefficient to compute the parameter on
233 //! the transformed curve for the transform of the
236 //! Transformed(T)->Value(U * ParametricTransformation(T))
238 //! is the same point as
240 //! Value(U).Transformed(T)
242 //! This methods calls the basis curve method.
243 Standard_EXPORT virtual Standard_Real ParametricTransformation (const gp_Trsf& T) const Standard_OVERRIDE;
245 //! Creates a new object which is a copy of this trimmed curve.
246 Standard_EXPORT Handle(Geom_Geometry) Copy() const Standard_OVERRIDE;
248 //! Dumps the content of me into the stream
249 Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const Standard_OVERRIDE;
254 DEFINE_STANDARD_RTTIEXT(Geom_TrimmedCurve,Geom_BoundedCurve)
264 Handle(Geom_Curve) basisCurve;
265 Standard_Real uTrim1;
266 Standard_Real uTrim2;
277 #endif // _Geom_TrimmedCurve_HeaderFile