0031939: Coding - correction of spelling errors in comments
[occt.git] / src / GCPnts / GCPnts_UniformDeflection.hxx
CommitLineData
42cf5bc1 1// Created on: 1992-03-23
2// Created by: Herve LEGRAND
3// Copyright (c) 1992-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_UniformDeflection_HeaderFile
18#define _GCPnts_UniformDeflection_HeaderFile
19
9bf3ef83 20#include <StdFail_NotDone.hxx>
42cf5bc1 21#include <TColStd_SequenceOfReal.hxx>
22#include <TColgp_SequenceOfPnt.hxx>
9bf3ef83 23
42cf5bc1 24class Standard_DomainError;
25class Standard_ConstructionError;
26class Standard_OutOfRange;
27class StdFail_NotDone;
28class Adaptor3d_Curve;
29class Adaptor2d_Curve2d;
30class gp_Pnt;
31
42cf5bc1 32//! Provides an algorithm to compute a distribution of
33//! points on a 'C2' continuous curve. The algorithm
34//! respects a criterion of maximum deflection between
35//! the curve and the polygon that results from the computed points.
36//! Note: This algorithm is relatively time consuming. A
37//! GCPnts_QuasiUniformDeflection algorithm is
38//! quicker; it can also work with non-'C2' continuous
39//! curves, but it generates more points in the distribution.
40class GCPnts_UniformDeflection
41{
42public:
43
44 DEFINE_STANDARD_ALLOC
45
46
47 //! Constructs an empty algorithm. To define the problem
48 //! to be solved, use the function Initialize.
49 Standard_EXPORT GCPnts_UniformDeflection();
50
51 //! Computes a uniform Deflection distribution of points on
52 //! the Curve <C>.
53 //! if <WithControl> is True,the algorithm controls the estimate
54 //! deflection
37782ec2 55 Standard_EXPORT GCPnts_UniformDeflection(const Adaptor3d_Curve& C, const Standard_Real Deflection, const Standard_Boolean WithControl = Standard_True);
42cf5bc1 56
57 //! Computes a uniform Deflection distribution of points on
58 //! the Curve <C>.
59 //! if <WithControl> is True,the algorithm controls the estimate
60 //! deflection
37782ec2 61 Standard_EXPORT GCPnts_UniformDeflection(const Adaptor2d_Curve2d& C, const Standard_Real Deflection, const Standard_Boolean WithControl = Standard_True);
42cf5bc1 62
63 //! Computes a Uniform Deflection distribution of points
64 //! on a part of the Curve <C>.
65 //! if <WithControl> is True,the algorithm controls the estimate
66 //! deflection
37782ec2 67 Standard_EXPORT GCPnts_UniformDeflection(const Adaptor3d_Curve& C, const Standard_Real Deflection, const Standard_Real U1, const Standard_Real U2, const Standard_Boolean WithControl = Standard_True);
42cf5bc1 68
69 //! Computes a Uniform Deflection distribution of points
70 //! on a part of the Curve <C>.
71 //! if <WithControl> is True,the algorithm controls the estimate
72 //! deflection
37782ec2 73 Standard_EXPORT GCPnts_UniformDeflection(const Adaptor2d_Curve2d& C, const Standard_Real Deflection, const Standard_Real U1, const Standard_Real U2, const Standard_Boolean WithControl = Standard_True);
42cf5bc1 74
21c7c457 75 //! Initialize the algorithms with <C>, <Deflection>
37782ec2 76 Standard_EXPORT void Initialize (const Adaptor3d_Curve& C, const Standard_Real Deflection, const Standard_Boolean WithControl = Standard_True);
42cf5bc1 77
21c7c457 78 //! Initialize the algorithms with <C>, <Deflection>
37782ec2 79 Standard_EXPORT void Initialize (const Adaptor2d_Curve2d& C, const Standard_Real Deflection, const Standard_Boolean WithControl = Standard_True);
42cf5bc1 80
21c7c457 81 //! Initialize the algorithms with <C>, <Deflection>,
42cf5bc1 82 //! <U1>,<U2>
37782ec2 83 Standard_EXPORT void Initialize (const Adaptor3d_Curve& C, const Standard_Real Deflection, const Standard_Real U1, const Standard_Real U2, const Standard_Boolean WithControl = Standard_True);
42cf5bc1 84
21c7c457 85 //! Initialize the algorithms with <C>, <Deflection>,
42cf5bc1 86 //! <U1>,<U2>
87 //! This and the above methods initialize (or reinitialize) this algorithm and
88 //! compute a distribution of points:
89 //! - on the curve C, or
90 //! - on the part of curve C limited by the two
91 //! parameter values U1 and U2,
92 //! where the maximum distance between C and the
93 //! polygon that results from the points of the
94 //! distribution is not greater than Deflection.
95 //! The first point of the distribution is either the origin
96 //! of curve C or the point of parameter U1. The last
97 //! point of the distribution is either the end point of
98 //! curve C or the point of parameter U2. Intermediate
99 //! points of the distribution are built using
100 //! interpolations of segments of the curve limited at
101 //! the 2nd degree. The construction ensures, in a first
102 //! step, that the chordal deviation for this
103 //! interpolation of the curve is less than or equal to
104 //! Deflection. However, it does not ensure that the
105 //! chordal deviation for the curve itself is less than or
106 //! equal to Deflection. To do this a check is
107 //! necessary, which may generate (second step)
108 //! additional intermediate points. This check is time
109 //! consuming, and can be avoided by setting
110 //! WithControl to false. Note that by default
111 //! WithControl is true and check is performed.
112 //! Use the function IsDone to verify that the
113 //! computation was successful, the function NbPoints
114 //! to obtain the number of points of the computed
115 //! distribution, and the function Parameter to read
116 //! the parameter of each point.
117 //! Warning
118 //! - C is necessary, 'C2' continuous. This property is
119 //! not checked at construction time.
120 //! - The roles of U1 and U2 are inverted if U1 > U2.
121 //! Warning
122 //! C is an adapted curve, i.e. an object which is an interface between:
123 //! - the services provided by either a 2D curve from
124 //! the package Geom2d (in the case of an
125 //! Adaptor2d_Curve2d curve) or a 3D curve from
126 //! the package Geom (in the case of an Adaptor3d_Curve curve),
127 //! - and those required on the curve by the computation algorithm.
37782ec2 128 Standard_EXPORT void Initialize (const Adaptor2d_Curve2d& C, const Standard_Real Deflection, const Standard_Real U1, const Standard_Real U2, const Standard_Boolean WithControl = Standard_True);
42cf5bc1 129
130 //! Returns true if the computation was successful.
131 //! IsDone is a protection against:
132 //! - non-convergence of the algorithm
133 //! - querying the results before computation.
9bf3ef83 134 Standard_Boolean IsDone () const
135 {
136 return myDone;
137 }
42cf5bc1 138
139 //! Returns the number of points of the distribution
140 //! computed by this algorithm.
141 //! Exceptions
142 //! StdFail_NotDone if this algorithm has not been
143 //! initialized, or if the computation was not successful.
9bf3ef83 144 Standard_Integer NbPoints () const
145 {
146 StdFail_NotDone_Raise_if (!myDone, "GCPnts_UniformDeflection::NbPoints()");
147 return myParams.Length ();
148 }
42cf5bc1 149
150 //! Returns the parameter of the point of index Index in
151 //! the distribution computed by this algorithm.
152 //! Warning
153 //! Index must be greater than or equal to 1, and less
154 //! than or equal to the number of points of the
155 //! distribution. However, pay particular attention as this
156 //! condition is not checked by this function.
157 //! Exceptions
158 //! StdFail_NotDone if this algorithm has not been
159 //! initialized, or if the computation was not successful.
9bf3ef83 160 Standard_Real Parameter (const Standard_Integer Index) const
161 {
162 StdFail_NotDone_Raise_if (!myDone, "GCPnts_UniformDeflection::Parameter()");
163 return myParams (Index);
164 }
42cf5bc1 165
166 //! Returns the point of index Index in the distribution
167 //! computed by this algorithm.
168 //! Warning
169 //! Index must be greater than or equal to 1, and less
170 //! than or equal to the number of points of the
171 //! distribution. However, pay particular attention as this
172 //! condition is not checked by this function.
173 //! Exceptions
174 //! StdFAil_NotDone if this algorithm has not been
175 //! initialized, or if the computation was not successful.
176 Standard_EXPORT gp_Pnt Value (const Standard_Integer Index) const;
177
178 //! Returns the deflection between the curve and the
179 //! polygon resulting from the points of the distribution
180 //! computed by this algorithm.
181 //! This value is the one given to the algorithm at the
182 //! time of construction (or initialization).
183 //! Exceptions
184 //! StdFail_NotDone if this algorithm has not been
185 //! initialized, or if the computation was not successful.
9bf3ef83 186 Standard_Real Deflection () const
187 {
188 StdFail_NotDone_Raise_if (!myDone, "GCPnts_UniformDeflection::Deflection()");
189 return myDeflection;
190 }
42cf5bc1 191
192private:
42cf5bc1 193 Standard_Boolean myDone;
194 Standard_Real myDeflection;
195 TColStd_SequenceOfReal myParams;
196 TColgp_SequenceOfPnt myPoints;
42cf5bc1 197};
198
42cf5bc1 199#endif // _GCPnts_UniformDeflection_HeaderFile