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