1 // Created on: 1995-11-02
2 // Created by: Jacques GOUSSARD
3 // Copyright (c) 1995-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 _GCPnts_QuasiUniformDeflection_HeaderFile
18 #define _GCPnts_QuasiUniformDeflection_HeaderFile
20 #include <StdFail_NotDone.hxx>
21 #include <TColStd_SequenceOfReal.hxx>
22 #include <TColgp_SequenceOfPnt.hxx>
23 #include <GeomAbs_Shape.hxx>
25 class Standard_DomainError;
26 class Standard_ConstructionError;
27 class Standard_OutOfRange;
28 class StdFail_NotDone;
29 class Adaptor3d_Curve;
30 class Adaptor2d_Curve2d;
33 //! This class computes a distribution of points on a
34 //! curve. The points may respect the deflection. The algorithm
35 //! is not based on the classical prediction (with second
36 //! derivative of curve), but either on the evaluation of
37 //! the distance between the mid point and the point of
38 //! mid parameter of the two points, or the distance
39 //! between the mid point and the point at parameter 0.5
40 //! on the cubic interpolation of the two points and their
42 //! Note: this algorithm is faster than a
43 //! GCPnts_UniformDeflection algorithm, and is
44 //! able to work with non-"C2" continuous curves.
45 //! However, it generates more points in the distribution.
46 class GCPnts_QuasiUniformDeflection
53 //! Constructs an empty algorithm. To define the problem
54 //! to be solved, use the function Initialize.
55 Standard_EXPORT GCPnts_QuasiUniformDeflection();
57 //! Computes a QuasiUniform Deflection distribution
58 //! of points on the Curve <C>.
59 Standard_EXPORT GCPnts_QuasiUniformDeflection(const Adaptor3d_Curve& C, const Standard_Real Deflection, const GeomAbs_Shape Continuity = GeomAbs_C1);
61 //! Computes a QuasiUniform Deflection distribution
62 //! of points on the Curve <C>.
63 Standard_EXPORT GCPnts_QuasiUniformDeflection(const Adaptor2d_Curve2d& C, const Standard_Real Deflection, const GeomAbs_Shape Continuity = GeomAbs_C1);
65 //! Computes a QuasiUniform Deflection distribution
66 //! of points on a part of the Curve <C>.
67 Standard_EXPORT GCPnts_QuasiUniformDeflection(const Adaptor3d_Curve& C, const Standard_Real Deflection, const Standard_Real U1, const Standard_Real U2, const GeomAbs_Shape Continuity = GeomAbs_C1);
69 //! Computes a QuasiUniform Deflection distribution
70 //! of points on a part of the Curve <C>.
71 //! This and the above algorithms compute a distribution of points:
72 //! - on the curve C, or
73 //! - on the part of curve C limited by the two
74 //! parameter values U1 and U2,
75 //! where the deflection resulting from the distributed
76 //! points is not greater than Deflection.
77 //! The first point of the distribution is either the origin of
78 //! curve C or the point of parameter U1. The last point
79 //! of the distribution is either the end point of curve C or
80 //! the point of parameter U2.
81 //! Intermediate points of the distribution are built such
82 //! that the deflection is not greater than Deflection.
83 //! Using the following evaluation of the deflection:
84 //! if Pi and Pj are two consecutive points of the
85 //! distribution, respectively of parameter ui and uj on
86 //! the curve, the deflection is the distance between:
87 //! - the mid-point of Pi and Pj (the center of the
88 //! chord joining these two points)
89 //! - and the point of mid-parameter of these two
90 //! points (the point of parameter [(ui+uj) / 2 ] on curve C).
91 //! Continuity, defaulted to GeomAbs_C1, gives the
92 //! degree of continuity of the curve C. (Note that C is an
93 //! Adaptor3d_Curve or an Adaptor2d_Curve2d
94 //! object, and does not know the degree of continuity of
95 //! the underlying curve).
96 //! Use the function IsDone to verify that the
97 //! computation was successful, the function NbPoints
98 //! to obtain the number of points of the computed
99 //! distribution, and the function Parameter to read the
100 //! parameter of each point.
102 //! - The roles of U1 and U2 are inverted if U1 > U2.
103 //! - Derivative functions on the curve are called
104 //! according to Continuity. An error may occur if
105 //! Continuity is greater than the real degree of
106 //! continuity of the curve.
108 //! C is an adapted curve, i.e. an object which is an
109 //! interface between:
110 //! - the services provided by either a 2D curve from
111 //! the package Geom2d (in the case of an
112 //! Adaptor2d_Curve2d curve) or a 3D curve from
113 //! the package Geom (in the case of an
114 //! Adaptor3d_Curve curve),
115 //! - and those required on the curve by the
116 //! computation algorithm.
117 Standard_EXPORT GCPnts_QuasiUniformDeflection(const Adaptor2d_Curve2d& C, const Standard_Real Deflection, const Standard_Real U1, const Standard_Real U2, const GeomAbs_Shape Continuity = GeomAbs_C1);
119 //! Initialize the algoritms with <C>, <Deflection>
120 Standard_EXPORT void Initialize (const Adaptor3d_Curve& C, const Standard_Real Deflection, const GeomAbs_Shape Continuity = GeomAbs_C1);
122 //! Initialize the algoritms with <C>, <Deflection>
123 Standard_EXPORT void Initialize (const Adaptor2d_Curve2d& C, const Standard_Real Deflection, const GeomAbs_Shape Continuity = GeomAbs_C1);
125 //! Initialize the algoritms with <C>, <Deflection>,
127 Standard_EXPORT void Initialize (const Adaptor3d_Curve& C, const Standard_Real Deflection, const Standard_Real U1, const Standard_Real U2, const GeomAbs_Shape Continuity = GeomAbs_C1);
129 //! Initialize the algoritms with <C>, <Deflection>,
131 //! This and the above algorithms initialize (or reinitialize)
132 //! this algorithm and compute a distribution of points:
133 //! - on the curve C, or
134 //! - on the part of curve C limited by the two
135 //! parameter values U1 and U2,
136 //! where the deflection resulting from the distributed
137 //! points is not greater than Deflection.
138 //! The first point of the distribution is either the origin
139 //! of curve C or the point of parameter U1. The last
140 //! point of the distribution is either the end point of
141 //! curve C or the point of parameter U2.
142 //! Intermediate points of the distribution are built in
143 //! such a way that the deflection is not greater than
144 //! Deflection. Using the following evaluation of the deflection:
145 //! if Pi and Pj are two consecutive points of the
146 //! distribution, respectively of parameter ui and uj
147 //! on the curve, the deflection is the distance between:
148 //! - the mid-point of Pi and Pj (the center of the
149 //! chord joining these two points)
150 //! - and the point of mid-parameter of these two
151 //! points (the point of parameter [(ui+uj) / 2 ] on curve C).
152 //! Continuity, defaulted to GeomAbs_C1, gives the
153 //! degree of continuity of the curve C. (Note that C is
154 //! an Adaptor3d_Curve or an
155 //! Adaptor2d_Curve2d object, and does not know
156 //! the degree of continuity of the underlying curve).
157 //! Use the function IsDone to verify that the
158 //! computation was successful, the function NbPoints
159 //! to obtain the number of points of the computed
160 //! distribution, and the function Parameter to read
161 //! the parameter of each point.
163 //! - The roles of U1 and U2 are inverted if U1 > U2.
164 //! - Derivative functions on the curve are called
165 //! according to Continuity. An error may occur if
166 //! Continuity is greater than the real degree of
167 //! continuity of the curve.
169 //! C is an adapted curve, i.e. an object which is an
170 //! interface between:
171 //! - the services provided by either a 2D curve from
172 //! the package Geom2d (in the case of an
173 //! Adaptor2d_Curve2d curve) or a 3D curve from
174 //! the package Geom (in the case of an Adaptor3d_Curve curve),
175 //! and those required on the curve by the computation algorithm.
176 Standard_EXPORT void Initialize (const Adaptor2d_Curve2d& C, const Standard_Real Deflection, const Standard_Real U1, const Standard_Real U2, const GeomAbs_Shape Continuity = GeomAbs_C1);
179 //! Returns true if the computation was successful.
180 //! IsDone is a protection against:
181 //! - non-convergence of the algorithm
182 //! - querying the results before computation.
183 Standard_Boolean IsDone () const
188 //! Returns the number of points of the distribution
189 //! computed by this algorithm.
191 //! StdFail_NotDone if this algorithm has not been
192 //! initialized, or if the computation was not successful.
193 Standard_Integer NbPoints () const
195 StdFail_NotDone_Raise_if (!myDone, "GCPnts_QuasiUniformDeflection::NbPoints()");
196 return myParams.Length ();
199 //! Returns the parameter of the point of index Index in
200 //! the distribution computed by this algorithm.
202 //! Index must be greater than or equal to 1, and less
203 //! than or equal to the number of points of the
204 //! distribution. However, pay particular attention as this
205 //! condition is not checked by this function.
207 //! StdFail_NotDone if this algorithm has not been
208 //! initialized, or if the computation was not successful.
209 Standard_Real Parameter (const Standard_Integer Index) const
211 StdFail_NotDone_Raise_if (!myDone, "GCPnts_QuasiUniformDeflection::Parameter()");
212 return myParams (Index);
215 //! Returns the point of index Index in the distribution
216 //! computed by this algorithm.
218 //! Index must be greater than or equal to 1, and less
219 //! than or equal to the number of points of the
220 //! distribution. However, pay particular attention as this
221 //! condition is not checked by this function.
223 //! StdFail_NotDone if this algorithm has not been
224 //! initialized, or if the computation was not successful.
225 Standard_EXPORT gp_Pnt Value (const Standard_Integer Index) const;
227 //! Returns the deflection between the curve and the
228 //! polygon resulting from the points of the distribution
229 //! computed by this algorithm.
230 //! This is the value given to the algorithm at the time
231 //! of construction (or initialization).
233 //! StdFail_NotDone if this algorithm has not been
234 //! initialized, or if the computation was not successful.
235 Standard_Real Deflection () const
237 StdFail_NotDone_Raise_if (!myDone, "GCPnts_QuasiUniformDeflection::Deflection()");
242 Standard_Boolean myDone;
243 Standard_Real myDeflection;
244 TColStd_SequenceOfReal myParams;
245 TColgp_SequenceOfPnt myPoints;
246 GeomAbs_Shape myCont;
249 #endif // _GCPnts_QuasiUniformDeflection_HeaderFile