b311480e |
1 | -- Created on: 1991-02-27 |
2 | -- Created by: Jean Claude Vauthier |
3 | -- Copyright (c) 1991-1999 Matra Datavision |
973c2be1 |
4 | -- Copyright (c) 1999-2014 OPEN CASCADE SAS |
b311480e |
5 | -- |
973c2be1 |
6 | -- This file is part of Open CASCADE Technology software library. |
b311480e |
7 | -- |
d5f74e42 |
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 |
973c2be1 |
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. |
b311480e |
13 | -- |
973c2be1 |
14 | -- Alternatively, this file may be used under the terms of Open CASCADE |
15 | -- commercial license or contractual agreement. |
b311480e |
16 | |
17 | class UniformDeflection from CPnts |
7fd59977 |
18 | |
ff8178ef |
19 | ---Purpose : This class defines an algorithm to create a set of points |
20 | -- (with a given chordal deviation) at the |
21 | -- positions of constant deflection of a given parametrized curve or a trimmed |
7fd59977 |
22 | -- circle. |
23 | -- The continuity of the curve must be at least C2. |
24 | -- |
25 | -- the usage of the is the following. |
26 | -- |
27 | -- class myUniformDFeflection instantiates |
28 | -- UniformDeflection(Curve, Tool); |
29 | -- |
30 | -- |
31 | -- Curve C; // Curve inherits from Curve or Curve2d from Adaptor2d |
32 | -- myUniformDeflection Iter1; |
33 | -- DefPntOfmyUniformDeflection P; |
34 | -- |
35 | -- for(Iter1.Initialize(C, Deflection, EPSILON, True); |
36 | -- Iter1.More(); |
37 | -- Iter1.Next()) { |
38 | -- P = Iter1.Value(); |
39 | -- ... make something with P |
40 | -- } |
41 | -- if(!Iter1.IsAllDone()) { |
42 | -- ... something wrong happened |
43 | -- } |
44 | uses |
45 | Curve from Adaptor3d, |
46 | Curve2d from Adaptor2d, |
47 | Pnt from gp |
48 | |
49 | raises DomainError from Standard, |
50 | NotDone from StdFail, |
51 | OutOfRange from Standard |
52 | |
53 | is |
54 | |
55 | |
56 | -- |
57 | |
58 | Create |
59 | ---Purpose: creation of a indefinite UniformDeflection |
60 | returns UniformDeflection; |
61 | |
62 | Create(C : Curve from Adaptor3d; Deflection, Resolution : Real; |
63 | WithControl : Boolean ) |
64 | --- Purpose : Computes a uniform deflection distribution of points |
65 | -- on the curve <C>. |
66 | -- <Deflection> defines the constant deflection value. |
67 | -- The algorithm computes the number of points and the points. |
68 | -- The curve <C> must be at least C2 else the computation can fail. |
69 | -- If just some parts of the curve is C2 it is better to give the |
70 | -- parameters bounds and to use the below constructor . |
71 | -- if <WithControl> is True, the algorithm controls the estimate |
72 | -- deflection |
73 | -- when the curve is singular at the point P(u),the algorithm |
74 | -- computes the next point as |
75 | -- P(u + Max(CurrentStep,Abs(LastParameter-FirstParameter))) |
76 | -- if the singularity is at the first point ,the next point |
77 | -- calculated is the P(LastParameter) |
78 | returns UniformDeflection; |
79 | |
80 | Create(C : Curve2d from Adaptor2d; Deflection, Resolution : Real; |
81 | WithControl : Boolean ) |
82 | ---Purpose: As above with 2d curve |
83 | returns UniformDeflection; |
84 | |
85 | Create(C : Curve from Adaptor3d; Deflection, U1, U2, Resolution : Real; |
86 | WithControl : Boolean) |
87 | --- Purpose : |
88 | -- Computes an uniform deflection distribution of points on a part of |
89 | -- the curve <C>. Deflection defines the step between the points. |
90 | -- <U1> and <U2> define the distribution span. |
91 | -- <U1> and <U2> must be in the parametric range of the curve. |
92 | returns UniformDeflection |
93 | raises DomainError; |
94 | -- raised if U1 and U2 are not in the parametric bounds of the curve. |
95 | |
96 | Create(C : Curve2d from Adaptor2d; Deflection, U1, U2, Resolution : Real; |
97 | WithControl : Boolean) |
98 | --- Purpose : As above with 2d curve |
99 | returns UniformDeflection |
100 | raises DomainError; |
101 | -- raised if U1 and U2 are not in the parametric bounds of the curve. |
102 | |
103 | Initialize(me : in out; C : Curve from Adaptor3d; |
104 | Deflection, Resolution : Real; |
105 | WithControl : Boolean) |
106 | ---Purpose: Initialize the algoritms with <C>, <Deflection>, <UStep>, |
107 | -- <Resolution> and <WithControl> |
108 | is static; |
109 | |
110 | Initialize(me : in out; C : Curve2d from Adaptor2d; |
111 | Deflection, Resolution : Real; |
112 | WithControl : Boolean) |
113 | ---Purpose: Initialize the algoritms with <C>, <Deflection>, <UStep>, |
114 | -- <Resolution> and <WithControl> |
115 | is static; |
116 | |
117 | Initialize(me : in out; C : Curve from Adaptor3d; |
118 | Deflection, U1, U2, Resolution : Real; |
119 | WithControl : Boolean) |
120 | ---Purpose: Initialize the algoritms with <C>, <Deflection>, <UStep>, |
121 | -- <U1>, <U2> and <WithControl> |
122 | raises DomainError |
123 | is static; |
124 | |
125 | Initialize(me : in out; C : Curve2d from Adaptor2d; |
126 | Deflection, U1, U2, Resolution : Real; |
127 | WithControl : Boolean) |
128 | ---Purpose: Initialize the algoritms with <C>, <Deflection>, <UStep>, |
129 | -- <U1>, <U2> and <WithControl> |
130 | raises DomainError |
131 | is static; |
132 | |
133 | IsAllDone (me) |
134 | --- Purpose : To know if all the calculus were done successfully |
135 | -- (ie all the points have been computed). The calculus can fail if |
136 | -- the Curve is not C1 in the considered domain. |
137 | -- Returns True if the calculus was successful. |
138 | ---C++: inline |
139 | returns Boolean |
140 | is static; |
141 | |
142 | Next(me : in out) |
143 | ---Purpose: go to the next Point. |
144 | ---C++: inline |
145 | raises OutOfRange |
146 | is static; |
147 | |
148 | More(me : in out) |
149 | ---Purpose: returns True if it exists a next Point. |
150 | returns Boolean |
151 | is static; |
152 | |
153 | Value(me) returns Real |
154 | ---Purpose : return the computed parameter |
155 | ---C++: inline |
156 | is static; |
157 | |
158 | |
159 | Point(me) returns Pnt from gp |
160 | ---Purpose : return the computed parameter |
161 | ---C++: inline |
162 | is static; |
163 | |
164 | Perform (me : in out) |
165 | ---Purpose: algorithm |
166 | is static private; |
167 | |
168 | fields |
169 | |
170 | myDone : Boolean; |
171 | my3d : Boolean; |
172 | myCurve : Address from Standard; |
173 | myFinish : Boolean; |
174 | myTolCur : Real; |
175 | myControl : Boolean; |
176 | myIPoint : Integer; |
177 | myNbPoints : Integer; |
178 | myParams : Real[3]; |
179 | myPoints : Pnt from gp [3] ; |
180 | myDwmax : Real; |
181 | myDeflection : Real; |
182 | myFirstParam : Real; |
183 | myLastParam : Real; |
184 | myDu : Real; |
185 | |
186 | end UniformDeflection; |
187 | |
188 | |
189 | |
190 | |
191 | |