0027281: Some classes in GCPnts are not const-correct
[occt.git] / src / GCPnts / GCPnts_QuasiUniformDeflection.hxx
CommitLineData
42cf5bc1 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
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 _GCPnts_QuasiUniformDeflection_HeaderFile
18#define _GCPnts_QuasiUniformDeflection_HeaderFile
19
20#include <Standard.hxx>
21#include <Standard_DefineAlloc.hxx>
22#include <Standard_Handle.hxx>
23
24#include <Standard_Boolean.hxx>
25#include <Standard_Real.hxx>
26#include <TColStd_SequenceOfReal.hxx>
27#include <TColgp_SequenceOfPnt.hxx>
28#include <GeomAbs_Shape.hxx>
29#include <Standard_Integer.hxx>
30class Standard_DomainError;
31class Standard_ConstructionError;
32class Standard_OutOfRange;
33class StdFail_NotDone;
34class Adaptor3d_Curve;
35class Adaptor2d_Curve2d;
36class gp_Pnt;
37
38
39//! This class computes a distribution of points on a
40//! curve. The points may respect the deflection. The algorithm
41//! is not based on the classical prediction (with second
42//! derivative of curve), but either on the evaluation of
43//! the distance between the mid point and the point of
44//! mid parameter of the two points, or the distance
45//! between the mid point and the point at parameter 0.5
46//! on the cubic interpolation of the two points and their
47//! tangents.
48//! Note: this algorithm is faster than a
49//! GCPnts_UniformDeflection algorithm, and is
50//! able to work with non-"C2" continuous curves.
51//! However, it generates more points in the distribution.
52class GCPnts_QuasiUniformDeflection
53{
54public:
55
56 DEFINE_STANDARD_ALLOC
57
58
59 //! Constructs an empty algorithm. To define the problem
60 //! to be solved, use the function Initialize.
61 Standard_EXPORT GCPnts_QuasiUniformDeflection();
62
63 //! Computes a QuasiUniform Deflection distribution
64 //! of points on the Curve <C>.
37782ec2 65 Standard_EXPORT GCPnts_QuasiUniformDeflection(const Adaptor3d_Curve& C, const Standard_Real Deflection, const GeomAbs_Shape Continuity = GeomAbs_C1);
42cf5bc1 66
67 //! Computes a QuasiUniform Deflection distribution
68 //! of points on the Curve <C>.
37782ec2 69 Standard_EXPORT GCPnts_QuasiUniformDeflection(const Adaptor2d_Curve2d& C, const Standard_Real Deflection, const GeomAbs_Shape Continuity = GeomAbs_C1);
42cf5bc1 70
71 //! Computes a QuasiUniform Deflection distribution
72 //! of points on a part of the Curve <C>.
37782ec2 73 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);
42cf5bc1 74
75 //! Computes a QuasiUniform Deflection distribution
76 //! of points on a part of the Curve <C>.
77 //! This and the above algorithms compute a distribution of points:
78 //! - on the curve C, or
79 //! - on the part of curve C limited by the two
80 //! parameter values U1 and U2,
81 //! where the deflection resulting from the distributed
82 //! points is not greater than Deflection.
83 //! The first point of the distribution is either the origin of
84 //! curve C or the point of parameter U1. The last point
85 //! of the distribution is either the end point of curve C or
86 //! the point of parameter U2.
87 //! Intermediate points of the distribution are built such
88 //! that the deflection is not greater than Deflection.
89 //! Using the following evaluation of the deflection:
90 //! if Pi and Pj are two consecutive points of the
91 //! distribution, respectively of parameter ui and uj on
92 //! the curve, the deflection is the distance between:
93 //! - the mid-point of Pi and Pj (the center of the
94 //! chord joining these two points)
95 //! - and the point of mid-parameter of these two
96 //! points (the point of parameter [(ui+uj) / 2 ] on curve C).
97 //! Continuity, defaulted to GeomAbs_C1, gives the
98 //! degree of continuity of the curve C. (Note that C is an
99 //! Adaptor3d_Curve or an Adaptor2d_Curve2d
100 //! object, and does not know the degree of continuity of
101 //! the underlying curve).
102 //! Use the function IsDone to verify that the
103 //! computation was successful, the function NbPoints
104 //! to obtain the number of points of the computed
105 //! distribution, and the function Parameter to read the
106 //! parameter of each point.
107 //! Warning
108 //! - The roles of U1 and U2 are inverted if U1 > U2.
109 //! - Derivative functions on the curve are called
110 //! according to Continuity. An error may occur if
111 //! Continuity is greater than the real degree of
112 //! continuity of the curve.
113 //! Warning
114 //! C is an adapted curve, i.e. an object which is an
115 //! interface between:
116 //! - the services provided by either a 2D curve from
117 //! the package Geom2d (in the case of an
118 //! Adaptor2d_Curve2d curve) or a 3D curve from
119 //! the package Geom (in the case of an
120 //! Adaptor3d_Curve curve),
121 //! - and those required on the curve by the
122 //! computation algorithm.
37782ec2 123 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);
42cf5bc1 124
125 //! Initialize the algoritms with <C>, <Deflection>
37782ec2 126 Standard_EXPORT void Initialize (const Adaptor3d_Curve& C, const Standard_Real Deflection, const GeomAbs_Shape Continuity = GeomAbs_C1);
42cf5bc1 127
128 //! Initialize the algoritms with <C>, <Deflection>
37782ec2 129 Standard_EXPORT void Initialize (const Adaptor2d_Curve2d& C, const Standard_Real Deflection, const GeomAbs_Shape Continuity = GeomAbs_C1);
42cf5bc1 130
131 //! Initialize the algoritms with <C>, <Deflection>,
132 //! <U1>,<U2>
37782ec2 133 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);
42cf5bc1 134
135 //! Initialize the algoritms with <C>, <Deflection>,
136 //! -- <U1>,<U2>
137 //! This and the above algorithms initialize (or reinitialize)
138 //! this algorithm and compute a distribution of points:
139 //! - on the curve C, or
140 //! - on the part of curve C limited by the two
141 //! parameter values U1 and U2,
142 //! where the deflection resulting from the distributed
143 //! points is not greater than Deflection.
144 //! The first point of the distribution is either the origin
145 //! of curve C or the point of parameter U1. The last
146 //! point of the distribution is either the end point of
147 //! curve C or the point of parameter U2.
148 //! Intermediate points of the distribution are built in
149 //! such a way that the deflection is not greater than
150 //! Deflection. Using the following evaluation of the deflection:
151 //! if Pi and Pj are two consecutive points of the
152 //! distribution, respectively of parameter ui and uj
153 //! on the curve, the deflection is the distance between:
154 //! - the mid-point of Pi and Pj (the center of the
155 //! chord joining these two points)
156 //! - and the point of mid-parameter of these two
157 //! points (the point of parameter [(ui+uj) / 2 ] on curve C).
158 //! Continuity, defaulted to GeomAbs_C1, gives the
159 //! degree of continuity of the curve C. (Note that C is
160 //! an Adaptor3d_Curve or an
161 //! Adaptor2d_Curve2d object, and does not know
162 //! the degree of continuity of the underlying curve).
163 //! Use the function IsDone to verify that the
164 //! computation was successful, the function NbPoints
165 //! to obtain the number of points of the computed
166 //! distribution, and the function Parameter to read
167 //! the parameter of each point.
168 //! Warning
169 //! - The roles of U1 and U2 are inverted if U1 > U2.
170 //! - Derivative functions on the curve are called
171 //! according to Continuity. An error may occur if
172 //! Continuity is greater than the real degree of
173 //! continuity of the curve.
174 //! Warning
175 //! C is an adapted curve, i.e. an object which is an
176 //! interface between:
177 //! - the services provided by either a 2D curve from
178 //! the package Geom2d (in the case of an
179 //! Adaptor2d_Curve2d curve) or a 3D curve from
180 //! the package Geom (in the case of an Adaptor3d_Curve curve),
181 //! and those required on the curve by the computation algorithm.
37782ec2 182 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);
42cf5bc1 183
184
185 //! Returns true if the computation was successful.
186 //! IsDone is a protection against:
187 //! - non-convergence of the algorithm
188 //! - querying the results before computation.
189 Standard_Boolean IsDone() const;
190
191
192 //! Returns the number of points of the distribution
193 //! computed by this algorithm.
194 //! Exceptions
195 //! StdFail_NotDone if this algorithm has not been
196 //! initialized, or if the computation was not successful.
197 Standard_Integer NbPoints() const;
198
199 //! Returns the parameter of the point of index Index in
200 //! the distribution computed by this algorithm.
201 //! Warning
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.
206 //! Exceptions
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;
210
211 //! Returns the point of index Index in the distribution
212 //! computed by this algorithm.
213 //! Warning
214 //! Index must be greater than or equal to 1, and less
215 //! than or equal to the number of points of the
216 //! distribution. However, pay particular attention as this
217 //! condition is not checked by this function.
218 //! Exceptions
219 //! StdFail_NotDone if this algorithm has not been
220 //! initialized, or if the computation was not successful.
221 Standard_EXPORT gp_Pnt Value (const Standard_Integer Index) const;
222
223 //! Returns the deflection between the curve and the
224 //! polygon resulting from the points of the distribution
225 //! computed by this algorithm.
226 //! This is the value given to the algorithm at the time
227 //! of construction (or initialization).
228 //! Exceptions
229 //! StdFail_NotDone if this algorithm has not been
230 //! initialized, or if the computation was not successful.
231 Standard_Real Deflection() const;
232
233
234
235
236protected:
237
238
239
240
241
242private:
243
244
245
246 Standard_Boolean myDone;
247 Standard_Real myDeflection;
248 TColStd_SequenceOfReal myParams;
249 TColgp_SequenceOfPnt myPoints;
250 GeomAbs_Shape myCont;
251
252
253};
254
255
256#include <GCPnts_QuasiUniformDeflection.lxx>
257
258
259
260
261
262#endif // _GCPnts_QuasiUniformDeflection_HeaderFile