42cf5bc1 |
1 | // Created on: 1993-03-10 |
2 | // Created by: JCV |
3 | // Copyright (c) 1993-1999 Matra Datavision |
4 | // Copyright (c) 1999-2014 OPEN CASCADE SAS |
5 | // |
6 | // This file is part of Open CASCADE Technology software library. |
7 | // |
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. |
13 | // |
14 | // Alternatively, this file may be used under the terms of Open CASCADE |
15 | // commercial license or contractual agreement. |
16 | |
17 | #ifndef _Geom_TrimmedCurve_HeaderFile |
18 | #define _Geom_TrimmedCurve_HeaderFile |
19 | |
20 | #include <Standard.hxx> |
21 | #include <Standard_Type.hxx> |
22 | |
23 | #include <Standard_Real.hxx> |
24 | #include <Geom_BoundedCurve.hxx> |
25 | #include <Standard_Boolean.hxx> |
26 | #include <GeomAbs_Shape.hxx> |
27 | #include <Standard_Integer.hxx> |
28 | class Geom_Curve; |
29 | class Standard_ConstructionError; |
30 | class Standard_RangeError; |
31 | class Standard_NoSuchObject; |
32 | class Geom_UndefinedDerivative; |
33 | class Geom_UndefinedValue; |
34 | class gp_Pnt; |
35 | class gp_Vec; |
36 | class gp_Trsf; |
37 | class Geom_Geometry; |
38 | |
39 | |
40 | class Geom_TrimmedCurve; |
41 | DEFINE_STANDARD_HANDLE(Geom_TrimmedCurve, Geom_BoundedCurve) |
42 | |
43 | //! Describes a portion of a curve (termed the "basis |
44 | //! curve") limited by two parameter values inside the |
45 | //! parametric domain of the basis 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 Geom_TrimmedCurve : public Geom_BoundedCurve |
52 | { |
53 | |
54 | public: |
55 | |
56 | |
57 | //! Constructs a trimmed curve from the basis curve C |
58 | //! which is limited between parameter values U1 and U2. |
59 | //! Note: - U1 can be greater or less than U2; in both cases, |
60 | //! the returned curve is oriented from U1 to U2. |
61 | //! - If the basis curve C is periodic, there is an |
62 | //! ambiguity because two parts are available. In this |
63 | //! case, the trimmed curve has the same orientation |
64 | //! as the basis curve if Sense is true (default value) |
65 | //! or the opposite orientation if Sense is false. |
66 | //! - If the curve is closed but not periodic, it is not |
67 | //! possible to keep the part of the curve which |
68 | //! includes the junction point (except if the junction |
69 | //! point is at the beginning or at the end of the |
70 | //! trimmed curve). If you tried to do this, you could |
71 | //! alter the fundamental characteristics of the basis |
72 | //! curve, which are used, for example, to compute |
73 | //! the derivatives of the trimmed curve. The rules |
74 | //! for a closed curve are therefore the same as |
75 | //! those for an open curve. |
76 | //! Warning: The trimmed curve is built from a copy of curve C. |
77 | //! Therefore, when C is modified, the trimmed curve |
78 | //! is not modified. |
79 | //! - If the basis curve is periodic and theAdjustPeriodic is True, |
80 | //! the bounds of the trimmed curve may be different from U1 and U2 |
81 | //! if the parametric origin of the basis curve is within |
82 | //! the arc of the trimmed curve. In this case, the |
83 | //! modified parameter will be equal to U1 or U2 |
84 | //! plus or minus the period. |
85 | //! When theAdjustPeriodic is False, parameters U1 and U2 will be |
86 | //! the same, without adjustment into the first period. |
87 | //! Exceptions |
88 | //! Standard_ConstructionError if: |
89 | //! - C is not periodic and U1 or U2 is outside the |
90 | //! bounds of C, or |
91 | //! - U1 is equal to U2. |
92 | 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); |
93 | |
94 | //! Changes the orientation of this trimmed curve. |
95 | //! As a result: |
96 | //! - the basis curve is reversed, |
97 | //! - the start point of the initial curve becomes the |
98 | //! end point of the reversed curve, |
99 | //! - the end point of the initial curve becomes the |
100 | //! start point of the reversed curve, |
101 | //! - the first and last parameters are recomputed. |
102 | //! If the trimmed curve was defined by: |
103 | //! - a basis curve whose parameter range is [ 0., 1. ], |
104 | //! - the two trim values U1 (first parameter) and U2 (last parameter), |
105 | //! the reversed trimmed curve is defined by: |
106 | //! - the reversed basis curve, whose parameter range is still [ 0., 1. ], |
107 | //! - the two trim values 1. - U2 (first parameter) and 1. - U1 (last parameter). |
79104795 |
108 | Standard_EXPORT void Reverse() Standard_OVERRIDE; |
42cf5bc1 |
109 | |
110 | //! Computes the parameter on the reversed curve for |
111 | //! the point of parameter U on this trimmed curve. |
79104795 |
112 | Standard_EXPORT Standard_Real ReversedParameter (const Standard_Real U) const Standard_OVERRIDE; |
42cf5bc1 |
113 | |
114 | //! Changes this trimmed curve, by redefining the |
115 | //! parameter values U1 and U2 which limit its basis curve. |
116 | //! Note: If the basis curve is periodic, the trimmed curve |
117 | //! has the same orientation as the basis curve if Sense |
118 | //! is true (default value) or the opposite orientation if Sense is false. |
119 | //! Warning |
120 | //! If the basis curve is periodic and theAdjustPeriodic is True, |
121 | //! the bounds of the trimmed curve may be different from U1 and U2 if the |
122 | //! parametric origin of the basis curve is within the arc of |
123 | //! the trimmed curve. In this case, the modified |
124 | //! parameter will be equal to U1 or U2 plus or minus the period. |
125 | //! When theAdjustPeriodic is False, parameters U1 and U2 will be |
126 | //! the same, without adjustment into the first period. |
127 | //! Exceptions |
128 | //! Standard_ConstructionError if: |
129 | //! - the basis curve is not periodic, and either U1 or U2 |
130 | //! are outside the bounds of the basis curve, or |
131 | //! - U1 is equal to U2. |
132 | Standard_EXPORT void SetTrim (const Standard_Real U1, const Standard_Real U2, const Standard_Boolean Sense = Standard_True, const Standard_Boolean theAdjustPeriodic = Standard_True); |
133 | |
134 | //! Returns the basis curve. |
135 | //! Warning |
136 | //! This function does not return a constant reference. |
137 | //! Consequently, any modification of the returned value |
138 | //! directly modifies the trimmed curve. |
139 | Standard_EXPORT Handle(Geom_Curve) BasisCurve() const; |
140 | |
141 | |
142 | //! Returns the continuity of the curve : |
143 | //! C0 : only geometric continuity, |
144 | //! C1 : continuity of the first derivative all along the Curve, |
145 | //! C2 : continuity of the second derivative all along the Curve, |
146 | //! C3 : continuity of the third derivative all along the Curve, |
147 | //! CN : the order of continuity is infinite. |
79104795 |
148 | Standard_EXPORT GeomAbs_Shape Continuity() const Standard_OVERRIDE; |
42cf5bc1 |
149 | |
150 | //! Returns true if the degree of continuity of the basis |
151 | //! curve of this trimmed curve is at least N. A trimmed |
152 | //! curve is at least "C0" continuous. |
153 | //! Warnings : |
154 | //! The continuity of the trimmed curve can be greater than |
155 | //! the continuity of the basis curve because you consider |
156 | //! only a part of the basis curve. |
157 | //! Raised if N < 0. |
79104795 |
158 | Standard_EXPORT Standard_Boolean IsCN (const Standard_Integer N) const Standard_OVERRIDE; |
42cf5bc1 |
159 | |
160 | |
161 | //! Returns the end point of <me>. This point is the |
162 | //! evaluation of the curve for the "LastParameter". |
79104795 |
163 | Standard_EXPORT gp_Pnt EndPoint() const Standard_OVERRIDE; |
42cf5bc1 |
164 | |
165 | |
166 | //! Returns the value of the first parameter of <me>. |
167 | //! The first parameter is the parameter of the "StartPoint" |
168 | //! of the trimmed curve. |
79104795 |
169 | Standard_EXPORT Standard_Real FirstParameter() const Standard_OVERRIDE; |
42cf5bc1 |
170 | |
171 | |
172 | //! Returns True if the distance between the StartPoint and |
173 | //! the EndPoint is lower or equal to Resolution from package gp. |
79104795 |
174 | Standard_EXPORT Standard_Boolean IsClosed() const Standard_OVERRIDE; |
42cf5bc1 |
175 | |
ff3f0387 |
176 | //! Always returns FALSE (independently of the type of basis curve). |
79104795 |
177 | Standard_EXPORT Standard_Boolean IsPeriodic() const Standard_OVERRIDE; |
42cf5bc1 |
178 | |
179 | //! Returns the period of the basis curve of this trimmed curve. |
180 | //! Exceptions |
181 | //! Standard_NoSuchObject if the basis curve is not periodic. |
182 | Standard_EXPORT virtual Standard_Real Period() const Standard_OVERRIDE; |
183 | |
184 | |
185 | //! Returns the value of the last parameter of <me>. |
186 | //! The last parameter is the parameter of the "EndPoint" of the |
187 | //! trimmed curve. |
79104795 |
188 | Standard_EXPORT Standard_Real LastParameter() const Standard_OVERRIDE; |
42cf5bc1 |
189 | |
190 | |
191 | //! Returns the start point of <me>. |
192 | //! This point is the evaluation of the curve from the |
193 | //! "FirstParameter". |
194 | //! value and derivatives |
195 | //! Warnings : |
196 | //! The returned derivatives have the same orientation as the |
197 | //! derivatives of the basis curve even if the trimmed curve |
198 | //! has not the same orientation as the basis curve. |
79104795 |
199 | Standard_EXPORT gp_Pnt StartPoint() const Standard_OVERRIDE; |
42cf5bc1 |
200 | |
201 | //! Returns in P the point of parameter U. |
202 | //! |
203 | //! If the basis curve is an OffsetCurve sometimes it is not |
204 | //! possible to do the evaluation of the curve at the parameter |
205 | //! U (see class OffsetCurve). |
79104795 |
206 | Standard_EXPORT void D0 (const Standard_Real U, gp_Pnt& P) const Standard_OVERRIDE; |
42cf5bc1 |
207 | |
208 | //! Raised if the continuity of the curve is not C1. |
79104795 |
209 | Standard_EXPORT void D1 (const Standard_Real U, gp_Pnt& P, gp_Vec& V1) const Standard_OVERRIDE; |
42cf5bc1 |
210 | |
211 | //! Raised if the continuity of the curve is not C2. |
79104795 |
212 | Standard_EXPORT void D2 (const Standard_Real U, gp_Pnt& P, gp_Vec& V1, gp_Vec& V2) const Standard_OVERRIDE; |
42cf5bc1 |
213 | |
214 | //! Raised if the continuity of the curve is not C3. |
79104795 |
215 | Standard_EXPORT void D3 (const Standard_Real U, gp_Pnt& P, gp_Vec& V1, gp_Vec& V2, gp_Vec& V3) const Standard_OVERRIDE; |
42cf5bc1 |
216 | |
217 | //! N is the order of derivation. |
218 | //! Raised if the continuity of the curve is not CN. |
219 | //! Raised if N < 1. |
220 | //! geometric transformations |
79104795 |
221 | Standard_EXPORT gp_Vec DN (const Standard_Real U, const Standard_Integer N) const Standard_OVERRIDE; |
42cf5bc1 |
222 | |
223 | //! Applies the transformation T to this trimmed curve. |
224 | //! Warning The basis curve is also modified. |
79104795 |
225 | Standard_EXPORT void Transform (const gp_Trsf& T) Standard_OVERRIDE; |
42cf5bc1 |
226 | |
227 | //! Returns the parameter on the transformed curve for |
228 | //! the transform of the point of parameter U on <me>. |
229 | //! |
230 | //! me->Transformed(T)->Value(me->TransformedParameter(U,T)) |
231 | //! |
232 | //! is the same point as |
233 | //! |
234 | //! me->Value(U).Transformed(T) |
235 | //! |
236 | //! This methods calls the basis curve method. |
237 | Standard_EXPORT virtual Standard_Real TransformedParameter (const Standard_Real U, const gp_Trsf& T) const Standard_OVERRIDE; |
238 | |
239 | //! Returns a coefficient to compute the parameter on |
240 | //! the transformed curve for the transform of the |
241 | //! point on <me>. |
242 | //! |
243 | //! Transformed(T)->Value(U * ParametricTransformation(T)) |
244 | //! |
245 | //! is the same point as |
246 | //! |
247 | //! Value(U).Transformed(T) |
248 | //! |
249 | //! This methods calls the basis curve method. |
250 | Standard_EXPORT virtual Standard_Real ParametricTransformation (const gp_Trsf& T) const Standard_OVERRIDE; |
251 | |
252 | //! Creates a new object which is a copy of this trimmed curve. |
79104795 |
253 | Standard_EXPORT Handle(Geom_Geometry) Copy() const Standard_OVERRIDE; |
42cf5bc1 |
254 | |
255 | |
256 | |
257 | |
92efcf78 |
258 | DEFINE_STANDARD_RTTIEXT(Geom_TrimmedCurve,Geom_BoundedCurve) |
42cf5bc1 |
259 | |
260 | protected: |
261 | |
262 | |
263 | |
264 | |
265 | private: |
266 | |
267 | |
268 | Handle(Geom_Curve) basisCurve; |
269 | Standard_Real uTrim1; |
270 | Standard_Real uTrim2; |
271 | |
272 | |
273 | }; |
274 | |
275 | |
276 | |
277 | |
278 | |
279 | |
280 | |
281 | #endif // _Geom_TrimmedCurve_HeaderFile |