0031668: Visualization - WebGL sample doesn't work on Emscripten 1.39
[occt.git] / src / CPnts / CPnts_UniformDeflection.hxx
CommitLineData
42cf5bc1 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
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 _CPnts_UniformDeflection_HeaderFile
18#define _CPnts_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_Address.hxx>
26#include <Standard_Real.hxx>
27#include <Standard_Integer.hxx>
28#include <gp_Pnt.hxx>
29class Standard_DomainError;
30class StdFail_NotDone;
31class Standard_OutOfRange;
32class Adaptor3d_Curve;
33class Adaptor2d_Curve2d;
34
35
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
39//! circle.
40//! The continuity of the curve must be at least C2.
41//!
42//! the usage of the is the following.
43//!
44//! class myUniformDFeflection instantiates
45//! UniformDeflection(Curve, Tool);
46//!
47//! Curve C; // Curve inherits from Curve or Curve2d from Adaptor2d
48//! myUniformDeflection Iter1;
49//! DefPntOfmyUniformDeflection P;
50//!
51//! for(Iter1.Initialize(C, Deflection, EPSILON, True);
52//! Iter1.More();
53//! Iter1.Next()) {
54//! P = Iter1.Value();
55//! ... make something with P
56//! }
57//! if(!Iter1.IsAllDone()) {
58//! ... something wrong happened
59//! }
60class CPnts_UniformDeflection
61{
62public:
63
64 DEFINE_STANDARD_ALLOC
65
66
67 //! creation of a indefinite UniformDeflection
68 Standard_EXPORT CPnts_UniformDeflection();
69
70 //! Computes a uniform deflection distribution of points
71 //! on the curve <C>.
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
78 //! deflection
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);
85
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);
88
89
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);
95
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);
98
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);
102
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);
106
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);
110
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);
114
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;
120
121 //! go to the next Point.
122 void Next();
123
124 //! returns True if it exists a next Point.
125 Standard_EXPORT Standard_Boolean More();
126
127 //! return the computed parameter
128 Standard_Real Value() const;
129
130 //! return the computed parameter
131 gp_Pnt Point() const;
132
133
134
135
136protected:
137
138
139
140
141
142private:
143
144
145 //! algorithm
146 Standard_EXPORT void Perform();
147
148
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];
158 gp_Pnt myPoints[3];
159 Standard_Real myDwmax;
160 Standard_Real myDeflection;
161 Standard_Real myFirstParam;
162 Standard_Real myLastParam;
163 Standard_Real myDu;
164
165
166};
167
168
169#include <CPnts_UniformDeflection.lxx>
170
171
172
173
174
175#endif // _CPnts_UniformDeflection_HeaderFile