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
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_UniformDeflection_HeaderFile
18 #define _GCPnts_UniformDeflection_HeaderFile
20 #include <StdFail_NotDone.hxx>
21 #include <TColStd_SequenceOfReal.hxx>
22 #include <TColgp_SequenceOfPnt.hxx>
24 class Standard_DomainError;
25 class Standard_ConstructionError;
26 class Standard_OutOfRange;
27 class StdFail_NotDone;
28 class Adaptor3d_Curve;
29 class Adaptor2d_Curve2d;
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.
40 class GCPnts_UniformDeflection
47 //! Constructs an empty algorithm. To define the problem
48 //! to be solved, use the function Initialize.
49 Standard_EXPORT GCPnts_UniformDeflection();
51 //! Computes a uniform Deflection distribution of points on
53 //! if <WithControl> is True,the algorithm controls the estimate
55 Standard_EXPORT GCPnts_UniformDeflection(const Adaptor3d_Curve& C, const Standard_Real Deflection, const Standard_Boolean WithControl = Standard_True);
57 //! Computes a uniform Deflection distribution of points on
59 //! if <WithControl> is True,the algorithm controls the estimate
61 Standard_EXPORT GCPnts_UniformDeflection(const Adaptor2d_Curve2d& C, const Standard_Real Deflection, const Standard_Boolean WithControl = Standard_True);
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
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);
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
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);
75 //! Initialize the algoritms with <C>, <Deflection>
76 Standard_EXPORT void Initialize (const Adaptor3d_Curve& C, const Standard_Real Deflection, const Standard_Boolean WithControl = Standard_True);
78 //! Initialize the algoritms with <C>, <Deflection>
79 Standard_EXPORT void Initialize (const Adaptor2d_Curve2d& C, const Standard_Real Deflection, const Standard_Boolean WithControl = Standard_True);
81 //! Initialize the algoritms with <C>, <Deflection>,
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);
85 //! Initialize the algoritms with <C>, <Deflection>,
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.
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.
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.
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);
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.
134 Standard_Boolean IsDone () const
139 //! Returns the number of points of the distribution
140 //! computed by this algorithm.
142 //! StdFail_NotDone if this algorithm has not been
143 //! initialized, or if the computation was not successful.
144 Standard_Integer NbPoints () const
146 StdFail_NotDone_Raise_if (!myDone, "GCPnts_UniformDeflection::NbPoints()");
147 return myParams.Length ();
150 //! Returns the parameter of the point of index Index in
151 //! the distribution computed by this algorithm.
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.
158 //! StdFail_NotDone if this algorithm has not been
159 //! initialized, or if the computation was not successful.
160 Standard_Real Parameter (const Standard_Integer Index) const
162 StdFail_NotDone_Raise_if (!myDone, "GCPnts_UniformDeflection::Parameter()");
163 return myParams (Index);
166 //! Returns the point of index Index in the distribution
167 //! computed by this algorithm.
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.
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;
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).
184 //! StdFail_NotDone if this algorithm has not been
185 //! initialized, or if the computation was not successful.
186 Standard_Real Deflection () const
188 StdFail_NotDone_Raise_if (!myDone, "GCPnts_UniformDeflection::Deflection()");
193 Standard_Boolean myDone;
194 Standard_Real myDeflection;
195 TColStd_SequenceOfReal myParams;
196 TColgp_SequenceOfPnt myPoints;
199 #endif // _GCPnts_UniformDeflection_HeaderFile