1 // Created on: 1991-02-27
2 // Created by: Jean Claude Vauthier
3 // Copyright (c) 1991-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 _CPnts_UniformDeflection_HeaderFile
18 #define _CPnts_UniformDeflection_HeaderFile
20 #include <Standard.hxx>
21 #include <Standard_DefineAlloc.hxx>
22 #include <Standard_Handle.hxx>
24 #include <Standard_Boolean.hxx>
25 #include <Standard_Address.hxx>
26 #include <Standard_Real.hxx>
27 #include <Standard_Integer.hxx>
29 class Standard_DomainError;
30 class StdFail_NotDone;
31 class Standard_OutOfRange;
32 class Adaptor3d_Curve;
33 class Adaptor2d_Curve2d;
36 //! This class defines an algorithm to create a set of points
37 //! (with a given chordal deviation) at the
38 //! positions of constant deflection of a given parametrized curve or a trimmed
40 //! The continuity of the curve must be at least C2.
42 //! the usage of the is the following.
44 //! class myUniformDFeflection instantiates
45 //! UniformDeflection(Curve, Tool);
47 //! Curve C; // Curve inherits from Curve or Curve2d from Adaptor2d
48 //! myUniformDeflection Iter1;
49 //! DefPntOfmyUniformDeflection P;
51 //! for(Iter1.Initialize(C, Deflection, EPSILON, True);
54 //! P = Iter1.Value();
55 //! ... make something with P
57 //! if(!Iter1.IsAllDone()) {
58 //! ... something wrong happened
60 class CPnts_UniformDeflection
67 //! creation of a indefinite UniformDeflection
68 Standard_EXPORT CPnts_UniformDeflection();
70 //! Computes a uniform deflection distribution of points
72 //! <Deflection> defines the constant deflection value.
73 //! The algorithm computes the number of points and the points.
74 //! The curve <C> must be at least C2 else the computation can fail.
75 //! If just some parts of the curve is C2 it is better to give the
76 //! parameters bounds and to use the below constructor .
77 //! if <WithControl> is True, the algorithm controls the estimate
79 //! when the curve is singular at the point P(u),the algorithm
80 //! computes the next point as
81 //! P(u + Max(CurrentStep,Abs(LastParameter-FirstParameter)))
82 //! if the singularity is at the first point ,the next point
83 //! calculated is the P(LastParameter)
84 Standard_EXPORT CPnts_UniformDeflection(const Adaptor3d_Curve& C, const Standard_Real Deflection, const Standard_Real Resolution, const Standard_Boolean WithControl);
86 //! As above with 2d curve
87 Standard_EXPORT CPnts_UniformDeflection(const Adaptor2d_Curve2d& C, const Standard_Real Deflection, const Standard_Real Resolution, const Standard_Boolean WithControl);
90 //! Computes an uniform deflection distribution of points on a part of
91 //! the curve <C>. Deflection defines the step between the points.
92 //! <U1> and <U2> define the distribution span.
93 //! <U1> and <U2> must be in the parametric range of the curve.
94 Standard_EXPORT CPnts_UniformDeflection(const Adaptor3d_Curve& C, const Standard_Real Deflection, const Standard_Real U1, const Standard_Real U2, const Standard_Real Resolution, const Standard_Boolean WithControl);
96 //! As above with 2d curve
97 Standard_EXPORT CPnts_UniformDeflection(const Adaptor2d_Curve2d& C, const Standard_Real Deflection, const Standard_Real U1, const Standard_Real U2, const Standard_Real Resolution, const Standard_Boolean WithControl);
99 //! Initialize the algoritms with <C>, <Deflection>, <UStep>,
100 //! <Resolution> and <WithControl>
101 Standard_EXPORT void Initialize (const Adaptor3d_Curve& C, const Standard_Real Deflection, const Standard_Real Resolution, const Standard_Boolean WithControl);
103 //! Initialize the algoritms with <C>, <Deflection>, <UStep>,
104 //! <Resolution> and <WithControl>
105 Standard_EXPORT void Initialize (const Adaptor2d_Curve2d& C, const Standard_Real Deflection, const Standard_Real Resolution, const Standard_Boolean WithControl);
107 //! Initialize the algoritms with <C>, <Deflection>, <UStep>,
108 //! <U1>, <U2> and <WithControl>
109 Standard_EXPORT void Initialize (const Adaptor3d_Curve& C, const Standard_Real Deflection, const Standard_Real U1, const Standard_Real U2, const Standard_Real Resolution, const Standard_Boolean WithControl);
111 //! Initialize the algoritms with <C>, <Deflection>, <UStep>,
112 //! <U1>, <U2> and <WithControl>
113 Standard_EXPORT void Initialize (const Adaptor2d_Curve2d& C, const Standard_Real Deflection, const Standard_Real U1, const Standard_Real U2, const Standard_Real Resolution, const Standard_Boolean WithControl);
115 //! To know if all the calculus were done successfully
116 //! (ie all the points have been computed). The calculus can fail if
117 //! the Curve is not C1 in the considered domain.
118 //! Returns True if the calculus was successful.
119 Standard_Boolean IsAllDone() const;
121 //! go to the next Point.
124 //! returns True if it exists a next Point.
125 Standard_EXPORT Standard_Boolean More();
127 //! return the computed parameter
128 Standard_Real Value() const;
130 //! return the computed parameter
131 gp_Pnt Point() const;
146 Standard_EXPORT void Perform();
149 Standard_Boolean myDone;
150 Standard_Boolean my3d;
151 Standard_Address myCurve;
152 Standard_Boolean myFinish;
153 Standard_Real myTolCur;
154 Standard_Boolean myControl;
155 Standard_Integer myIPoint;
156 Standard_Integer myNbPoints;
157 Standard_Real myParams[3];
159 Standard_Real myDwmax;
160 Standard_Real myDeflection;
161 Standard_Real myFirstParam;
162 Standard_Real myLastParam;
169 #include <CPnts_UniformDeflection.lxx>
175 #endif // _CPnts_UniformDeflection_HeaderFile