b311480e |
1 | -- Created on: 1996-06-06 |
2 | -- Created by: Philippe MANGIN |
3 | -- Copyright (c) 1996-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. |
7fd59977 |
16 | |
17 | class CompBezierSurfacesToBSplineSurface from GeomConvert |
18 | |
19 | ---Purpose: An algorithm to convert a grid of adjacent |
ff8178ef |
20 | -- non-rational Bezier surfaces (with continuity CM) into a |
21 | -- BSpline surface (with continuity CM). |
7fd59977 |
22 | -- A CompBezierSurfacesToBSplineSurface object |
23 | -- provides a framework for: |
24 | -- - defining the grid of adjacent Bezier surfaces |
25 | -- which is to be converted into a BSpline surface, |
26 | -- - implementing the computation algorithm, and |
27 | -- - consulting the results. |
28 | -- Warning |
29 | -- Do not attempt to convert rational Bezier surfaces using such an algorithm. |
30 | -- Input is array of Bezier patch |
31 | -- 1 2 3 4 -> VIndex [1, NbVPatches] -> VDirection |
32 | -- ----------------------- |
33 | -- 1 | | | | | |
34 | -- ----------------------- |
35 | -- 2 | | | | | |
36 | -- ----------------------- |
37 | -- 3 | | | | | |
38 | -- ----------------------- |
39 | -- UIndex [1, NbUPatches] Udirection |
40 | -- |
41 | -- Warning! Patches must have compatible parametrization |
42 | |
43 | uses |
44 | Array2OfBezierSurface from TColGeom, |
45 | HArray2OfPnt from TColgp, |
46 | Array1OfReal from TColStd, |
47 | HArray1OfReal from TColStd, |
48 | Shape from GeomAbs, |
49 | HArray1OfInteger from TColStd |
50 | |
51 | raises |
52 | DimensionError from Standard, |
53 | NotImplemented from Standard, |
54 | ConstructionError from Standard |
55 | |
56 | is |
57 | Create(Beziers : Array2OfBezierSurface) |
58 | ---Purpose : Computes all the data needed to build a "C0" |
59 | -- continuous BSpline surface equivalent to the grid of |
60 | -- adjacent non-rational Bezier surfaces Beziers. |
61 | -- Each surface in the Beziers grid becomes a natural |
62 | -- patch, limited by knots values, on the BSpline surface |
63 | -- whose data is computed. Surfaces in the grid must |
64 | -- satisfy the following conditions: |
65 | -- - Coincident bounding curves between two |
66 | -- consecutive surfaces in a row of the Beziers grid |
67 | -- must be u-isoparametric bounding curves of these two surfaces. |
68 | -- - Coincident bounding curves between two |
69 | -- consecutive surfaces in a column of the Beziers |
70 | -- grid must be v-isoparametric bounding curves of these two surfaces. |
71 | -- The BSpline surface whose data is computed has the |
72 | -- following characteristics: |
73 | -- - Its degree in the u (respectively v) parametric |
74 | -- direction is equal to that of the Bezier surface |
75 | -- which has the highest degree in the u |
76 | -- (respectively v) parametric direction in the Beziers grid. |
77 | -- - It is a "Piecewise Bezier" in both u and v |
78 | -- parametric directions, i.e.: |
79 | -- - the knots are regularly spaced in each |
80 | -- parametric direction (i.e. the difference between |
81 | -- two consecutive knots is a constant), and |
82 | -- - all the multiplicities of the surface knots in a |
83 | -- given parametric direction are equal to |
84 | -- Degree, which is the degree of the BSpline |
85 | -- surface in this parametric direction, except for |
86 | -- the first and last knots for which the multiplicity is |
87 | -- equal to Degree + 1. |
88 | -- - Coincident bounding curves between two |
89 | -- consecutive columns of Bezier surfaces in the |
90 | -- Beziers grid become u-isoparametric curves, |
91 | -- corresponding to knots values of the BSpline surface. |
92 | -- - Coincident bounding curves between two |
93 | -- consecutive rows of Bezier surfaces in the Beziers |
94 | -- grid become v-isoparametric curves |
95 | -- corresponding to knots values of the BSpline surface. |
96 | -- Use the available consultation functions to access the |
97 | -- computed data. This data may be used to construct the BSpline surface. |
98 | -- Warning |
99 | -- The surfaces in the Beziers grid must be adjacent, i.e. |
100 | -- two consecutive Bezier surfaces in the grid (in a row |
101 | -- or column) must have a coincident bounding curve. In |
102 | -- addition, the location of the parameterization on each |
103 | -- of these surfaces (i.e. the relative location of u and v |
104 | -- isoparametric curves on the surface) is of importance |
105 | -- with regard to the positioning of the surfaces in the |
106 | -- Beziers grid. Care must be taken with respect to the |
107 | -- above, as these properties are not checked and an |
108 | -- error may occur if they are not satisfied. |
109 | -- Exceptions |
110 | -- Standard_NotImplemented if one of the Bezier |
111 | -- surfaces of the Beziers grid is rational. |
112 | returns CompBezierSurfacesToBSplineSurface |
113 | raises NotImplemented; |
114 | |
115 | Create(Beziers : Array2OfBezierSurface; |
116 | Tolerance : Real; |
117 | RemoveKnots : Boolean = Standard_True) |
118 | ---Purpose : Build an Ci uniform (Rational) BSpline surface |
119 | -- The higest Continuity Ci is imposed, like the |
120 | -- maximal deformation is lower than <Tolerance>. |
121 | -- Warning: The Continuity C0 is imposed without any check. |
122 | returns CompBezierSurfacesToBSplineSurface |
123 | raises NotImplemented; |
124 | |
125 | Create(Beziers : Array2OfBezierSurface; |
126 | UKnots : Array1OfReal; |
127 | VKnots : Array1OfReal; |
128 | UContinuity : Shape = GeomAbs_C0; |
129 | VContinuity : Shape = GeomAbs_C0; |
130 | Tolerance : Real = 1.0e-4) |
131 | ---Purpose : Computes all the data needed to construct a BSpline |
132 | -- surface equivalent to the adjacent non-rational |
133 | -- Bezier surfaces Beziers grid. |
134 | -- Each surface in the Beziers grid becomes a natural |
135 | -- patch, limited by knots values, on the BSpline surface |
136 | -- whose data is computed. Surfaces in the grid must |
137 | -- satisfy the following conditions: |
138 | -- - Coincident bounding curves between two |
139 | -- consecutive surfaces in a row of the Beziers grid |
140 | -- must be u-isoparametric bounding curves of these two surfaces. |
141 | -- - Coincident bounding curves between two |
142 | -- consecutive surfaces in a column of the Beziers |
143 | -- grid must be v-isoparametric bounding curves of these two surfaces. |
144 | -- The BSpline surface whose data is computed has the |
145 | -- following characteristics: |
146 | -- - Its degree in the u (respectively v) parametric |
147 | -- direction is equal to that of the Bezier surface |
148 | -- which has the highest degree in the u |
149 | -- (respectively v) parametric direction in the Beziers grid. |
150 | -- - Coincident bounding curves between two |
151 | -- consecutive columns of Bezier surfaces in the |
152 | -- Beziers grid become u-isoparametric curves |
153 | -- corresponding to knots values of the BSpline surface. |
154 | -- - Coincident bounding curves between two |
155 | -- consecutive rows of Bezier surfaces in the Beziers |
156 | -- grid become v-isoparametric curves |
157 | -- corresponding to knots values of the BSpline surface. |
158 | -- Knots values of the BSpline surface are given in the two tables: |
159 | -- - UKnots for the u parametric direction (which |
160 | -- corresponds to the order of Bezier surface columns in the Beziers grid), and |
161 | -- - VKnots for the v parametric direction (which |
162 | -- corresponds to the order of Bezier surface rows in the Beziers grid). |
163 | -- The dimensions of UKnots (respectively VKnots) |
164 | -- must be equal to the number of columns (respectively, |
165 | -- rows) of the Beziers grid, plus 1 . |
166 | -- UContinuity and VContinuity, which are both |
167 | -- defaulted to GeomAbs_C0, specify the required |
168 | -- continuity on the BSpline surface. If the required |
169 | -- degree of continuity is greater than 0 in a given |
170 | -- parametric direction, a deformation is applied locally |
171 | -- on the initial surface (as defined by the Beziers grid) |
172 | -- to satisfy this condition. This local deformation is not |
173 | -- applied however, if it is greater than Tolerance |
174 | -- (defaulted to 1.0 e-7). In such cases, the |
175 | -- continuity condition is not satisfied, and the function |
176 | -- IsDone will return false. A small tolerance value |
177 | -- prevents any modification of the surface and a large |
178 | -- tolerance value "smoothes" the surface. |
179 | -- Use the available consultation functions to access the |
180 | -- computed data. This data may be used to construct the BSpline surface. |
181 | -- Warning |
182 | -- The surfaces in the Beziers grid must be adjacent, i.e. |
183 | -- two consecutive Bezier surfaces in the grid (in a row |
184 | -- or column) must have a coincident bounding curve. In |
185 | -- addition, the location of the parameterization on each |
186 | -- of these surfaces (i.e. the relative location of u and v |
187 | -- isoparametric curves on the surface) is of importance |
188 | -- with regard to the positioning of the surfaces in the |
189 | -- Beziers grid. Care must be taken with respect to the |
190 | -- above, as these properties are not checked and an |
191 | -- error may occur if they are not satisfied. |
192 | -- Exceptions |
193 | -- Standard_DimensionMismatch: |
194 | -- - if the number of knots in the UKnots table (i.e. the |
195 | -- length of the UKnots array) is not equal to the |
196 | -- number of columns of Bezier surfaces in the |
197 | -- Beziers grid plus 1, or |
198 | -- - if the number of knots in the VKnots table (i.e. the |
199 | -- length of the VKnots array) is not equal to the |
200 | -- number of rows of Bezier surfaces in the Beziers grid, plus 1. |
201 | -- Standard_ConstructionError: |
202 | -- - if UContinuity and VContinuity are not equal to |
203 | -- one of the following values: GeomAbs_C0, |
204 | -- GeomAbs_C1, GeomAbs_C2 and GeomAbs_C3; or |
205 | -- - if the number of columns in the Beziers grid is |
206 | -- greater than 1, and the required degree of |
207 | -- continuity in the u parametric direction is greater |
208 | -- than that of the Bezier surface with the highest |
209 | -- degree in the u parametric direction (in the Beziers grid), minus 1; or |
210 | -- - if the number of rows in the Beziers grid is |
211 | -- greater than 1, and the required degree of |
212 | -- continuity in the v parametric direction is greater |
213 | -- than that of the Bezier surface with the highest |
214 | -- degree in the v parametric direction (in the Beziers grid), minus 1 . |
215 | -- Standard_NotImplemented if one of the Bezier |
216 | -- surfaces in the Beziers grid is rational. |
217 | returns CompBezierSurfacesToBSplineSurface |
218 | raises ConstructionError, |
219 | DimensionError, |
220 | NotImplemented; |
221 | |
222 | Perform (me : in out; Beziers : Array2OfBezierSurface) |
223 | ---Purpose : It used internaly by the constructors. |
224 | is private; |
225 | |
226 | NbUKnots (me) returns Integer; |
227 | ---Purpose : Returns the number of knots in the U direction |
228 | -- of the BSpline surface whose data is computed in this framework. |
229 | ---C++: inline |
230 | |
231 | NbUPoles (me) returns Integer; |
232 | ---Purpose : Returns number of poles in the U direction |
233 | -- of the BSpline surface whose data is computed in this framework. |
234 | ---C++: inline |
235 | |
236 | NbVKnots (me) returns Integer; |
237 | ---Purpose : Returns the number of knots in the V direction |
238 | -- of the BSpline surface whose data is computed in this framework. |
239 | ---C++: inline |
240 | |
241 | NbVPoles (me) returns Integer; |
242 | ---Purpose : Returns the number of poles in the V direction |
243 | -- of the BSpline surface whose data is computed in this framework. |
244 | ---C++: inline |
245 | |
246 | Poles(me) |
247 | ---Purpose : Returns the table of poles of the BSpline surface |
248 | -- whose data is computed in this framework. |
249 | ---C++: inline |
250 | ---C++: return const & |
251 | returns HArray2OfPnt; |
252 | |
253 | |
254 | UKnots (me) |
255 | ---Purpose : Returns the knots table for the u parametric |
256 | -- direction of the BSpline surface whose data is computed in this framework. |
257 | ---C++: inline |
258 | ---C++: return const & |
259 | returns HArray1OfReal; |
260 | |
261 | UDegree (me) returns Integer; |
262 | ---Purpose : Returns the degree for the u parametric |
263 | -- direction of the BSpline surface whose data is computed in this framework. |
264 | ---C++: inline |
265 | |
266 | VKnots (me) |
267 | ---Purpose : Returns the knots table for the v parametric |
268 | -- direction of the BSpline surface whose data is computed in this framework. |
269 | ---C++: inline |
270 | ---C++: return const & |
271 | returns HArray1OfReal; |
272 | |
273 | |
274 | VDegree (me) |
275 | ---Purpose : Returns the degree for the v parametric |
276 | -- direction of the BSpline surface whose data is computed in this framework. |
277 | ---C++: inline |
278 | returns Integer; |
279 | |
280 | UMultiplicities (me) |
281 | ---Purpose : |
282 | -- Returns the multiplicities table for the u |
283 | -- parametric direction of the knots of the BSpline |
284 | -- surface whose data is computed in this framework. |
285 | ---C++: inline |
286 | ---C++: return const & |
287 | returns HArray1OfInteger; |
288 | |
289 | VMultiplicities (me) |
290 | ---Purpose : -- Returns the multiplicities table for the v |
291 | -- parametric direction of the knots of the BSpline |
292 | -- surface whose data is computed in this framework. |
293 | ---C++: inline |
294 | ---C++: return const & |
295 | returns HArray1OfInteger; |
296 | |
297 | IsDone(me) |
298 | ---Purpose : Returns true if the conversion was successful. |
299 | -- Unless an exception was raised at the time of |
300 | -- construction, the conversion of the Bezier surface |
301 | -- grid assigned to this algorithm is always carried out. |
302 | -- IsDone returns false if the constraints defined at the |
303 | -- time of construction cannot be respected. This occurs |
304 | -- when there is an incompatibility between a required |
305 | -- degree of continuity on the BSpline surface, and the |
306 | -- maximum tolerance accepted for local deformations |
307 | -- of the surface. In such a case the computed data |
308 | -- does not satisfy all the initial constraints. |
309 | returns Boolean ; |
310 | |
311 | |
312 | fields |
313 | myUDegree : Integer; |
314 | myVDegree : Integer; |
315 | myVMults : HArray1OfInteger; |
316 | myUMults : HArray1OfInteger; |
317 | myUKnots : HArray1OfReal; |
318 | myVKnots : HArray1OfReal; |
319 | myPoles : HArray2OfPnt; |
320 | isrational : Boolean; |
321 | myDone : Boolean; |
322 | |
323 | end CompBezierSurfacesToBSplineSurface; |