b311480e |
1 | -- Created on: 1991-10-03 |
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. |
7fd59977 |
16 | |
17 | package Geom2dConvert |
18 | |
19 | --- Purpose : |
20 | -- This package provides an implementation of algorithmes to do |
21 | -- the conversion between equivalent geometric entities from |
22 | -- package Geom2d. |
23 | -- It gives the possibility : |
24 | -- . to obtain the B-spline representation of bounded curves. |
25 | -- . to split a B-spline curve into several B-spline curves |
26 | -- with some constraints of continuity, |
27 | -- . to convert a B-spline curve into several Bezier curves |
28 | -- or surfaces. |
29 | -- All the geometric entities used in this package are bounded. |
30 | -- References : |
31 | -- . Generating the Bezier Points of B-spline curves and surfaces |
32 | -- (Wolfgang Bohm) CAGD volume 13 number 6 november 1981 |
33 | -- . On NURBS: A Survey (Leslie Piegl) IEEE Computer Graphics and |
34 | -- Application January 1991 |
35 | -- . Curve and surface construction using rational B-splines |
36 | -- (Leslie Piegl and Wayne Tiller) CAD Volume 19 number 9 november |
37 | -- 1987 |
38 | -- . A survey of curve and surface methods in CAGD (Wolfgang BOHM) |
39 | -- CAGD 1 1984 |
40 | |
41 | uses Standard, TColStd, TColGeom2d,gp, Geom2d, Convert,GeomAbs |
42 | |
43 | is |
44 | |
45 | |
46 | class BSplineCurveKnotSplitting; |
7fd59977 |
47 | |
48 | class BSplineCurveToBezierCurve; |
7fd59977 |
49 | |
50 | class CompCurveToBSplineCurve; |
ff8178ef |
51 | |
7fd59977 |
52 | class ApproxCurve; |
53 | ---Purpose : -- Convert a curve to BSpline by Approximation |
54 | -- |
55 | |
56 | SplitBSplineCurve (C : BSplineCurve from Geom2d; |
57 | FromK1, ToK2 : Integer; |
58 | SameOrientation : Boolean = Standard_True) |
6e33d3ce |
59 | returns BSplineCurve from Geom2d |
7fd59977 |
60 | --- Purpose : |
61 | -- This method computes the arc of B-spline curve between the two |
62 | -- knots FromK1 and ToK2. If C is periodic the arc has the same |
63 | -- orientation as C if SameOrientation = Standard_True. |
64 | -- If C is not periodic SameOrientation is not used for the |
65 | -- computation and C is oriented from the knot fromK1 to the |
66 | -- knot toK2. |
67 | -- We just keep the local definition of C between the knots |
68 | -- FromK1 and ToK2. The returned B-spline curve has its first |
69 | -- and last knots with a multiplicity equal to degree + 1, where |
70 | -- degree is the polynomial degree of C. |
71 | -- The indexes of the knots FromK1 and ToK2 doesn't include the |
72 | -- repetition of multiple knots in their definition. |
73 | raises OutOfRange from Standard, |
74 | --- Purpose : |
75 | -- Raised if FromK1 or ToK2 are out of the bounds |
76 | -- [FirstUKnotIndex, LastUKnotIndex] |
77 | DomainError from Standard; |
78 | --- Purpose : Raised if FromK1 = ToK2 |
79 | |
80 | |
81 | |
82 | SplitBSplineCurve (C : BSplineCurve from Geom2d; |
83 | FromU1, ToU2 : Real; |
84 | ParametricTolerance : Real; |
85 | SameOrientation : Boolean = Standard_True) |
6e33d3ce |
86 | returns BSplineCurve from Geom2d |
7fd59977 |
87 | --- Purpose : |
88 | -- This function computes the segment of B-spline curve between the |
89 | -- parametric values FromU1, ToU2. |
90 | -- If C is periodic the arc has the same orientation as C if |
91 | -- SameOrientation = True. |
92 | -- If C is not periodic SameOrientation is not used for the |
93 | -- computation and C is oriented fromU1 toU2. |
94 | -- If U1 and U2 and two parametric values we consider that |
95 | -- U1 = U2 if Abs (U1 - U2) <= ParametricTolerance and |
96 | -- ParametricTolerance must be greater or equal to Resolution |
97 | -- from package gp. |
98 | raises DomainError from Standard; |
99 | --- Purpose : |
100 | -- Raised if FromU1 or ToU2 are out of the parametric bounds of the |
101 | -- curve (The tolerance criterion is ParametricTolerance). |
102 | -- Raised if Abs (FromU1 - ToU2) <= ParametricTolerance |
103 | -- Raised if ParametricTolerance < Resolution from gp. |
104 | |
105 | |
106 | |
107 | CurveToBSplineCurve (C : Curve from Geom2d ; |
108 | Parameterisation : ParameterisationType from Convert |
109 | = Convert_TgtThetaOver2) |
6e33d3ce |
110 | returns BSplineCurve from Geom2d |
7fd59977 |
111 | --- Purpose : This function converts a non infinite curve from |
112 | -- Geom into a B-spline curve. C must be an ellipse or a |
113 | -- circle or a trimmed conic or a trimmed line or a Bezier |
114 | -- curve or a trimmed Bezier curve or a BSpline curve or a |
115 | -- trimmed BSpline curve or an Offset curve or a trimmed |
116 | -- Offset curve. |
117 | -- The returned B-spline is not periodic except if C is a |
118 | -- Circle or an Ellipse. |
119 | -- ParameterisationType applies only if the curve is a Circle |
120 | -- or an ellipse : |
121 | -- TgtThetaOver2, |
122 | -- TgtThetaOver2_1, |
123 | -- TgtThetaOver2_2, |
124 | -- TgtThetaOver2_3, |
125 | -- TgtThetaOver2_4, |
126 | -- Purpose: this is the classical rational parameterisation |
127 | -- 2 |
128 | -- 1 - t |
129 | -- cos(theta) = ------ |
130 | -- 2 |
131 | -- 1 + t |
132 | -- |
133 | -- 2t |
134 | -- sin(theta) = ------ |
135 | -- 2 |
136 | -- 1 + t |
137 | -- |
138 | -- t = tan (theta/2) |
139 | -- |
140 | -- with TgtThetaOver2 the routine will compute the number of spans |
141 | -- using the rule num_spans = [ (ULast - UFirst) / 1.2 ] + 1 |
142 | -- with TgtThetaOver2_N, N spans will be forced: an error will |
143 | -- be raized if (ULast - UFirst) >= PI and N = 1, |
144 | -- ULast - UFirst >= 2 PI and N = 2 |
145 | -- |
146 | -- QuasiAngular, |
147 | -- here t is a rational function that approximates |
148 | -- theta ----> tan(theta/2). |
149 | -- Neverthless the composing with above function yields exact |
150 | -- functions whose square sum up to 1 |
151 | -- RationalC1 ; |
152 | -- t is replaced by a polynomial function of u so as to grant |
153 | -- C1 contiuity across knots. |
154 | -- Exceptions |
155 | -- Standard_DomainError if the curve C is infinite. |
156 | -- Standard_ConstructionError: |
157 | -- - if C is a complete circle or ellipse, and if |
158 | -- Parameterisation is not equal to |
159 | -- Convert_TgtThetaOver2 or to Convert_RationalC1, or |
160 | -- - if C is a trimmed circle or ellipse and if |
161 | -- Parameterisation is equal to |
162 | -- Convert_TgtThetaOver2_1 and if U2 - U1 > |
163 | -- 0.9999 * Pi where U1 and U2 are |
164 | -- respectively the first and the last parameters of the |
165 | -- trimmed curve (this method of parameterization |
166 | -- cannot be used to convert a half-circle or a |
167 | -- half-ellipse, for example), or |
168 | -- - if C is a trimmed circle or ellipse and |
169 | -- Parameterisation is equal to |
170 | -- Convert_TgtThetaOver2_2 and U2 - U1 > |
171 | -- 1.9999 * Pi where U1 and U2 are |
172 | -- respectively the first and the last parameters of the |
173 | -- trimmed curve (this method of parameterization |
174 | -- cannot be used to convert a quasi-complete circle or ellipse). |
175 | raises DomainError; |
176 | |
177 | |
178 | |
179 | ConcatG1(ArrayOfCurves : in out Array1OfBSplineCurve from TColGeom2d; |
180 | ArrayOfToler : in Array1OfReal from TColStd; |
181 | ArrayOfConcatenated : out HArray1OfBSplineCurve from TColGeom2d; |
182 | ClosedFlag : in Boolean from Standard ; |
183 | ClosedTolerance : in Real from Standard); |
184 | --- Purpose : This Method concatenates G1 the ArrayOfCurves as far |
185 | -- as it is possible. |
186 | -- ArrayOfCurves[0..N-1] |
187 | -- ArrayOfToler contains the biggest tolerance of the two |
188 | -- points shared by two consecutives curves. |
189 | -- Its dimension: [0..N-2] |
190 | -- ClosedTolerance indicates if the ArrayOfCurves is closed. |
191 | -- In this case ClosedTolerance contains the biggest tolerance |
192 | -- of the two points which are at the closure. |
193 | -- Otherwise its value is 0.0 |
194 | |
195 | |
196 | ConcatC1(ArrayOfCurves : in out Array1OfBSplineCurve from TColGeom2d; |
197 | ArrayOfToler : in Array1OfReal from TColStd; |
198 | ArrayOfIndices : out HArray1OfInteger from TColStd; |
199 | ArrayOfConcatenated : out HArray1OfBSplineCurve from TColGeom2d; |
200 | ClosedFlag : in Boolean from Standard ; |
201 | ClosedTolerance : in Real from Standard); |
202 | --- Purpose : This Method concatenates C1 the ArrayOfCurves as far |
203 | -- as it is possible. |
204 | -- ArrayOfCurves[0..N-1] |
205 | -- ArrayOfToler contains the biggest tolerance of the two |
206 | -- points shared by two consecutives curves. |
207 | -- Its dimension: [0..N-2] |
208 | -- ClosedTolerance indicates if the ArrayOfCurves is closed. |
209 | -- In this case ClosedTolerance contains the biggest tolerance |
210 | -- of the two points which are at the closure. |
211 | -- Otherwise its value is 0.0 |
212 | -- |
213 | ConcatC1(ArrayOfCurves : in out Array1OfBSplineCurve from TColGeom2d; |
214 | ArrayOfToler : in Array1OfReal from TColStd; |
215 | ArrayOfIndices : out HArray1OfInteger from TColStd; |
216 | ArrayOfConcatenated : out HArray1OfBSplineCurve from TColGeom2d; |
217 | ClosedFlag : in Boolean from Standard ; |
218 | ClosedTolerance : in Real from Standard; |
219 | AngularTolerance : in Real from Standard) ; |
220 | --- Purpose : This Method concatenates C1 the ArrayOfCurves as far |
221 | -- as it is possible. |
222 | -- ArrayOfCurves[0..N-1] |
223 | -- ArrayOfToler contains the biggest tolerance of the two |
224 | -- points shared by two consecutives curves. |
225 | -- Its dimension: [0..N-2] |
226 | -- ClosedTolerance indicates if the ArrayOfCurves is closed. |
227 | -- In this case ClosedTolerance contains the biggest tolerance |
228 | -- of the two points which are at the closure. |
229 | -- Otherwise its value is 0.0 |
230 | |
231 | C0BSplineToC1BSplineCurve(BS : in out BSplineCurve from Geom2d; |
232 | Tolerance : in Real from Standard); |
233 | --- Purpose : This Method reduces as far as it is possible the |
234 | -- multiplicities of the knots of the BSpline BS.(keeping the geometry). |
235 | -- It returns a new BSpline which could still be C0. |
236 | -- tolerance is a geometrical tolerance |
237 | |
238 | |
239 | C0BSplineToArrayOfC1BSplineCurve(BS : in BSplineCurve from Geom2d; |
240 | tabBS : out HArray1OfBSplineCurve from TColGeom2d; |
241 | Tolerance :in Real from Standard); |
242 | --- Purpose :This Method reduces as far as it is possible the |
243 | -- multiplicities of the knots of the BSpline BS.(keeping the geometry). |
244 | -- It returns an array of BSpline C1. |
245 | -- Tolerance is a geometrical tolerance |
246 | |
247 | C0BSplineToArrayOfC1BSplineCurve( BS : in BSplineCurve from Geom2d; |
248 | tabBS : out HArray1OfBSplineCurve from TColGeom2d; |
249 | AngularTolerance : in Real from Standard; |
250 | Tolerance : in Real from Standard) ; |
251 | --- Purpose :This Method reduces as far as it is possible the |
252 | -- multiplicities of the knots of the BSpline BS.(keeping the geometry). |
253 | -- It returns an array of BSpline C1. |
254 | -- tolerance is a geometrical tolerance |
255 | |
256 | |
257 | |
258 | end Geom2dConvert; |
259 | |
260 | |
261 | |
262 | |
263 | |
264 | |
265 | |
266 | |
267 | |