0028724: Extrema between circle and plane cannot be found
[occt.git] / src / Geom2d / Geom2d_TrimmedCurve.hxx
CommitLineData
42cf5bc1 1// Created on: 1993-03-24
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 _Geom2d_TrimmedCurve_HeaderFile
18#define _Geom2d_TrimmedCurve_HeaderFile
19
20#include <Standard.hxx>
21#include <Standard_Type.hxx>
22
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>
28class Geom2d_Curve;
29class Standard_ConstructionError;
30class Standard_RangeError;
31class Standard_NoSuchObject;
32class Geom2d_UndefinedDerivative;
33class Geom2d_UndefinedValue;
34class gp_Pnt2d;
35class gp_Vec2d;
36class gp_Trsf2d;
37class Geom2d_Geometry;
38
39
40class Geom2d_TrimmedCurve;
41DEFINE_STANDARD_HANDLE(Geom2d_TrimmedCurve, Geom2d_BoundedCurve)
42
43
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.
51class Geom2d_TrimmedCurve : public Geom2d_BoundedCurve
52{
53
54public:
55
56
57
58 //! Creates a trimmed curve from the basis curve C limited between
59 //! U1 and U2.
60 //!
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
68 //! basis curve C.
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
76 //! a open curve.
77 //! Warnings :
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
81 //! Warnings :
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.
85 //! Include :
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
88 //! the bounds of C.
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);
91
92
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).
79104795 105 Standard_EXPORT void Reverse() Standard_OVERRIDE;
42cf5bc1 106
107 //! Returns the parameter on the reversed curve for
108 //! the point of parameter U on <me>.
109 //!
110 //! returns UFirst + ULast - U
79104795 111 Standard_EXPORT Standard_Real ReversedParameter (const Standard_Real U) const Standard_OVERRIDE;
42cf5bc1 112
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.
118 //! Warning
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.
125 //! Exceptions
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);
131
132 //! Returns the basis curve.
133 //! Warning
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;
138
139
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.
79104795 146 Standard_EXPORT GeomAbs_Shape Continuity() const Standard_OVERRIDE;
42cf5bc1 147
148 //! --- Purpose
149 //! Returns True if the order of continuity of the
150 //! trimmed curve is N. A trimmed curve is at least "C0" continuous.
151 //! Warnings :
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.
155 //! Raised if N < 0.
79104795 156 Standard_EXPORT Standard_Boolean IsCN (const Standard_Integer N) const Standard_OVERRIDE;
42cf5bc1 157
158
159 //! Returns the end point of <me>. This point is the
160 //! evaluation of the curve for the "LastParameter".
79104795 161 Standard_EXPORT gp_Pnt2d EndPoint() const Standard_OVERRIDE;
42cf5bc1 162
163
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.
79104795 167 Standard_EXPORT Standard_Real FirstParameter() const Standard_OVERRIDE;
42cf5bc1 168
169
170 //! Returns True if the distance between the StartPoint and
171 //! the EndPoint is lower or equal to Resolution from package
172 //! gp.
79104795 173 Standard_EXPORT Standard_Boolean IsClosed() const Standard_OVERRIDE;
42cf5bc1 174
ff3f0387 175 //! Always returns FALSE (independently of the type of basis curve).
79104795 176 Standard_EXPORT Standard_Boolean IsPeriodic() const Standard_OVERRIDE;
42cf5bc1 177
178 //! Returns the period of the basis curve of this trimmed curve.
179 //! Exceptions
180 //! Standard_NoSuchObject if the basis curve is not periodic.
181 Standard_EXPORT virtual Standard_Real Period() const Standard_OVERRIDE;
182
183
184 //! Returns the value of the last parameter of <me>.
185 //! The last parameter is the parameter of the "EndPoint" of the
186 //! trimmed curve.
79104795 187 Standard_EXPORT Standard_Real LastParameter() const Standard_OVERRIDE;
42cf5bc1 188
189
190 //! Returns the start point of <me>.
191 //! This point is the evaluation of the curve from the
192 //! "FirstParameter".
193 //! value and derivatives
194 //! Warnings :
195 //! The returned derivatives have the same orientation as the
196 //! derivatives of the basis curve.
79104795 197 Standard_EXPORT gp_Pnt2d StartPoint() const Standard_OVERRIDE;
42cf5bc1 198
199
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).
79104795 203 Standard_EXPORT void D0 (const Standard_Real U, gp_Pnt2d& P) const Standard_OVERRIDE;
42cf5bc1 204
205 //! Raised if the continuity of the curve is not C1.
79104795 206 Standard_EXPORT void D1 (const Standard_Real U, gp_Pnt2d& P, gp_Vec2d& V1) const Standard_OVERRIDE;
42cf5bc1 207
208 //! Raised if the continuity of the curve is not C2.
79104795 209 Standard_EXPORT void D2 (const Standard_Real U, gp_Pnt2d& P, gp_Vec2d& V1, gp_Vec2d& V2) const Standard_OVERRIDE;
42cf5bc1 210
211 //! Raised if the continuity of the curve is not C3.
79104795 212 Standard_EXPORT void D3 (const Standard_Real U, gp_Pnt2d& P, gp_Vec2d& V1, gp_Vec2d& V2, gp_Vec2d& V3) const Standard_OVERRIDE;
42cf5bc1 213
214 //! For the point of parameter U of this trimmed curve,
215 //! computes the vector corresponding to the Nth derivative.
216 //! Warning
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.
221 //! Exceptions
222 //! Standard_RangeError if N is less than 1.
223 //! geometric transformations
79104795 224 Standard_EXPORT gp_Vec2d DN (const Standard_Real U, const Standard_Integer N) const Standard_OVERRIDE;
42cf5bc1 225
226 //! Applies the transformation T to this trimmed curve.
227 //! Warning The basis curve is also modified.
79104795 228 Standard_EXPORT void Transform (const gp_Trsf2d& T) Standard_OVERRIDE;
42cf5bc1 229
230 //! Returns the parameter on the transformed curve for
231 //! the transform of the point of parameter U on <me>.
232 //!
233 //! me->Transformed(T)->Value(me->TransformedParameter(U,T))
234 //!
235 //! is the same point as
236 //!
237 //! me->Value(U).Transformed(T)
238 //!
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;
241
242 //! Returns a coefficient to compute the parameter on
243 //! the transformed curve for the transform of the
244 //! point on <me>.
245 //!
246 //! Transformed(T)->Value(U * ParametricTransformation(T))
247 //!
248 //! is the same point as
249 //!
250 //! Value(U).Transformed(T)
251 //!
252 //! This methods calls the basis curve method.
253 Standard_EXPORT virtual Standard_Real ParametricTransformation (const gp_Trsf2d& T) const Standard_OVERRIDE;
254
255
256 //! Creates a new object, which is a copy of this trimmed curve.
79104795 257 Standard_EXPORT Handle(Geom2d_Geometry) Copy() const Standard_OVERRIDE;
42cf5bc1 258
259
260
261
92efcf78 262 DEFINE_STANDARD_RTTIEXT(Geom2d_TrimmedCurve,Geom2d_BoundedCurve)
42cf5bc1 263
264protected:
265
266
267
268
269private:
270
271
272 Handle(Geom2d_Curve) basisCurve;
273 Standard_Real uTrim1;
274 Standard_Real uTrim2;
275
276
277};
278
279
280
281
282
283
284
285#endif // _Geom2d_TrimmedCurve_HeaderFile