0033661: Data Exchange, Step Import - Tessellated GDTs are not imported
[occt.git] / src / GCPnts / GCPnts_QuasiUniformDeflection.hxx
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 <StdFail_NotDone.hxx>
21 #include <TColStd_SequenceOfReal.hxx>
22 #include <TColgp_SequenceOfPnt.hxx>
23 #include <GeomAbs_Shape.hxx>
24
25 class Standard_DomainError;
26 class Standard_ConstructionError;
27 class Standard_OutOfRange;
28 class StdFail_NotDone;
29 class Adaptor3d_Curve;
30 class Adaptor2d_Curve2d;
31 class gp_Pnt;
32
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
41 //! tangents.
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 
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_QuasiUniformDeflection();
56   
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);
60   
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);
64   
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);
68   
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.
101   //! Warning
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.
107   //! Warning
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);
118   
119   //! Initialize the algorithms with <C>, <Deflection>
120   Standard_EXPORT void Initialize (const Adaptor3d_Curve& C, const Standard_Real Deflection, const GeomAbs_Shape Continuity = GeomAbs_C1);
121   
122   //! Initialize the algorithms with <C>, <Deflection>
123   Standard_EXPORT void Initialize (const Adaptor2d_Curve2d& C, const Standard_Real Deflection, const GeomAbs_Shape Continuity = GeomAbs_C1);
124   
125   //! Initialize the algorithms with <C>, <Deflection>,
126   //! <U1>,<U2>
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);
128   
129   //! Initialize  the  algorithms with <C>, <Deflection>,
130   //! -- <U1>,<U2>
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.
162   //! Warning
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.
168   //! Warning
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);
177   
178
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
184   {
185     return myDone;
186   }
187
188   //! Returns the number of points of the distribution
189   //! computed by this algorithm.
190   //! Exceptions
191   //! StdFail_NotDone if this algorithm has not been
192   //! initialized, or if the computation was not successful.
193   Standard_Integer NbPoints () const
194   {
195     StdFail_NotDone_Raise_if (!myDone, "GCPnts_QuasiUniformDeflection::NbPoints()");
196     return myParams.Length ();
197   }
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     StdFail_NotDone_Raise_if (!myDone, "GCPnts_QuasiUniformDeflection::Parameter()");
212     return myParams (Index);
213   }
214   
215   //! Returns the point of index Index in the distribution
216   //! computed by this algorithm.
217   //! Warning
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.
222   //! Exceptions
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;
226   
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).
232   //! Exceptions
233   //! StdFail_NotDone if this algorithm has not been
234   //! initialized, or if the computation was not successful.
235   Standard_Real Deflection () const
236   {
237     StdFail_NotDone_Raise_if (!myDone, "GCPnts_QuasiUniformDeflection::Deflection()");
238     return myDeflection;
239   }
240
241 private:
242   Standard_Boolean myDone;
243   Standard_Real myDeflection;
244   TColStd_SequenceOfReal myParams;
245   TColgp_SequenceOfPnt myPoints;
246   GeomAbs_Shape myCont;
247 };
248
249 #endif // _GCPnts_QuasiUniformDeflection_HeaderFile