1 -- Created on: 1991-10-03
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.
20 -- This package provides an implementation of algorithmes to do
21 -- the conversion between equivalent geometric entities from
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
29 -- All the geometric entities used in this package are bounded.
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
38 -- . A survey of curve and surface methods in CAGD (Wolfgang BOHM)
41 uses Standard, TColStd, TColGeom2d,gp, Geom2d, Convert,GeomAbs
46 class BSplineCurveKnotSplitting;
48 -- This algorithm searches the knot values corresponding to the
49 -- splitting of a given B-spline curve into several arcs with
50 -- the same continuity. The continuity order is given at the
51 -- construction time. It is possible to compute the curve arcs
52 -- corresponding to this splitting with the method of package
57 class BSplineCurveToBezierCurve;
59 -- This algorithm converts a B-spline curve from the package Geom
60 -- into several Bezier curves.
62 class CompCurveToBSplineCurve;
64 -- This algorithm converts and concat sevral curve in a
67 ---Purpose : -- Convert a curve to BSpline by Approximation
70 SplitBSplineCurve (C : BSplineCurve from Geom2d;
71 FromK1, ToK2 : Integer;
72 SameOrientation : Boolean = Standard_True)
73 returns BSplineCurve from Geom2d
75 -- This method computes the arc of B-spline curve between the two
76 -- knots FromK1 and ToK2. If C is periodic the arc has the same
77 -- orientation as C if SameOrientation = Standard_True.
78 -- If C is not periodic SameOrientation is not used for the
79 -- computation and C is oriented from the knot fromK1 to the
81 -- We just keep the local definition of C between the knots
82 -- FromK1 and ToK2. The returned B-spline curve has its first
83 -- and last knots with a multiplicity equal to degree + 1, where
84 -- degree is the polynomial degree of C.
85 -- The indexes of the knots FromK1 and ToK2 doesn't include the
86 -- repetition of multiple knots in their definition.
87 raises OutOfRange from Standard,
89 -- Raised if FromK1 or ToK2 are out of the bounds
90 -- [FirstUKnotIndex, LastUKnotIndex]
91 DomainError from Standard;
92 --- Purpose : Raised if FromK1 = ToK2
96 SplitBSplineCurve (C : BSplineCurve from Geom2d;
98 ParametricTolerance : Real;
99 SameOrientation : Boolean = Standard_True)
100 returns BSplineCurve from Geom2d
102 -- This function computes the segment of B-spline curve between the
103 -- parametric values FromU1, ToU2.
104 -- If C is periodic the arc has the same orientation as C if
105 -- SameOrientation = True.
106 -- If C is not periodic SameOrientation is not used for the
107 -- computation and C is oriented fromU1 toU2.
108 -- If U1 and U2 and two parametric values we consider that
109 -- U1 = U2 if Abs (U1 - U2) <= ParametricTolerance and
110 -- ParametricTolerance must be greater or equal to Resolution
112 raises DomainError from Standard;
114 -- Raised if FromU1 or ToU2 are out of the parametric bounds of the
115 -- curve (The tolerance criterion is ParametricTolerance).
116 -- Raised if Abs (FromU1 - ToU2) <= ParametricTolerance
117 -- Raised if ParametricTolerance < Resolution from gp.
121 CurveToBSplineCurve (C : Curve from Geom2d ;
122 Parameterisation : ParameterisationType from Convert
123 = Convert_TgtThetaOver2)
124 returns BSplineCurve from Geom2d
125 --- Purpose : This function converts a non infinite curve from
126 -- Geom into a B-spline curve. C must be an ellipse or a
127 -- circle or a trimmed conic or a trimmed line or a Bezier
128 -- curve or a trimmed Bezier curve or a BSpline curve or a
129 -- trimmed BSpline curve or an Offset curve or a trimmed
131 -- The returned B-spline is not periodic except if C is a
132 -- Circle or an Ellipse.
133 -- ParameterisationType applies only if the curve is a Circle
140 -- Purpose: this is the classical rational parameterisation
143 -- cos(theta) = ------
148 -- sin(theta) = ------
154 -- with TgtThetaOver2 the routine will compute the number of spans
155 -- using the rule num_spans = [ (ULast - UFirst) / 1.2 ] + 1
156 -- with TgtThetaOver2_N, N spans will be forced: an error will
157 -- be raized if (ULast - UFirst) >= PI and N = 1,
158 -- ULast - UFirst >= 2 PI and N = 2
161 -- here t is a rational function that approximates
162 -- theta ----> tan(theta/2).
163 -- Neverthless the composing with above function yields exact
164 -- functions whose square sum up to 1
166 -- t is replaced by a polynomial function of u so as to grant
167 -- C1 contiuity across knots.
169 -- Standard_DomainError if the curve C is infinite.
170 -- Standard_ConstructionError:
171 -- - if C is a complete circle or ellipse, and if
172 -- Parameterisation is not equal to
173 -- Convert_TgtThetaOver2 or to Convert_RationalC1, or
174 -- - if C is a trimmed circle or ellipse and if
175 -- Parameterisation is equal to
176 -- Convert_TgtThetaOver2_1 and if U2 - U1 >
177 -- 0.9999 * Pi where U1 and U2 are
178 -- respectively the first and the last parameters of the
179 -- trimmed curve (this method of parameterization
180 -- cannot be used to convert a half-circle or a
181 -- half-ellipse, for example), or
182 -- - if C is a trimmed circle or ellipse and
183 -- Parameterisation is equal to
184 -- Convert_TgtThetaOver2_2 and U2 - U1 >
185 -- 1.9999 * Pi where U1 and U2 are
186 -- respectively the first and the last parameters of the
187 -- trimmed curve (this method of parameterization
188 -- cannot be used to convert a quasi-complete circle or ellipse).
193 ConcatG1(ArrayOfCurves : in out Array1OfBSplineCurve from TColGeom2d;
194 ArrayOfToler : in Array1OfReal from TColStd;
195 ArrayOfConcatenated : out HArray1OfBSplineCurve from TColGeom2d;
196 ClosedFlag : in Boolean from Standard ;
197 ClosedTolerance : in Real from Standard);
198 --- Purpose : This Method concatenates G1 the ArrayOfCurves as far
199 -- as it is possible.
200 -- ArrayOfCurves[0..N-1]
201 -- ArrayOfToler contains the biggest tolerance of the two
202 -- points shared by two consecutives curves.
203 -- Its dimension: [0..N-2]
204 -- ClosedTolerance indicates if the ArrayOfCurves is closed.
205 -- In this case ClosedTolerance contains the biggest tolerance
206 -- of the two points which are at the closure.
207 -- Otherwise its value is 0.0
210 ConcatC1(ArrayOfCurves : in out Array1OfBSplineCurve from TColGeom2d;
211 ArrayOfToler : in Array1OfReal from TColStd;
212 ArrayOfIndices : out HArray1OfInteger from TColStd;
213 ArrayOfConcatenated : out HArray1OfBSplineCurve from TColGeom2d;
214 ClosedFlag : in Boolean from Standard ;
215 ClosedTolerance : in Real from Standard);
216 --- Purpose : This Method concatenates C1 the ArrayOfCurves as far
217 -- as it is possible.
218 -- ArrayOfCurves[0..N-1]
219 -- ArrayOfToler contains the biggest tolerance of the two
220 -- points shared by two consecutives curves.
221 -- Its dimension: [0..N-2]
222 -- ClosedTolerance indicates if the ArrayOfCurves is closed.
223 -- In this case ClosedTolerance contains the biggest tolerance
224 -- of the two points which are at the closure.
225 -- Otherwise its value is 0.0
227 ConcatC1(ArrayOfCurves : in out Array1OfBSplineCurve from TColGeom2d;
228 ArrayOfToler : in Array1OfReal from TColStd;
229 ArrayOfIndices : out HArray1OfInteger from TColStd;
230 ArrayOfConcatenated : out HArray1OfBSplineCurve from TColGeom2d;
231 ClosedFlag : in Boolean from Standard ;
232 ClosedTolerance : in Real from Standard;
233 AngularTolerance : in Real from Standard) ;
234 --- Purpose : This Method concatenates C1 the ArrayOfCurves as far
235 -- as it is possible.
236 -- ArrayOfCurves[0..N-1]
237 -- ArrayOfToler contains the biggest tolerance of the two
238 -- points shared by two consecutives curves.
239 -- Its dimension: [0..N-2]
240 -- ClosedTolerance indicates if the ArrayOfCurves is closed.
241 -- In this case ClosedTolerance contains the biggest tolerance
242 -- of the two points which are at the closure.
243 -- Otherwise its value is 0.0
245 C0BSplineToC1BSplineCurve(BS : in out BSplineCurve from Geom2d;
246 Tolerance : in Real from Standard);
247 --- Purpose : This Method reduces as far as it is possible the
248 -- multiplicities of the knots of the BSpline BS.(keeping the geometry).
249 -- It returns a new BSpline which could still be C0.
250 -- tolerance is a geometrical tolerance
253 C0BSplineToArrayOfC1BSplineCurve(BS : in BSplineCurve from Geom2d;
254 tabBS : out HArray1OfBSplineCurve from TColGeom2d;
255 Tolerance :in Real from Standard);
256 --- Purpose :This Method reduces as far as it is possible the
257 -- multiplicities of the knots of the BSpline BS.(keeping the geometry).
258 -- It returns an array of BSpline C1.
259 -- Tolerance is a geometrical tolerance
261 C0BSplineToArrayOfC1BSplineCurve( BS : in BSplineCurve from Geom2d;
262 tabBS : out HArray1OfBSplineCurve from TColGeom2d;
263 AngularTolerance : in Real from Standard;
264 Tolerance : in Real from Standard) ;
265 --- Purpose :This Method reduces as far as it is possible the
266 -- multiplicities of the knots of the BSpline BS.(keeping the geometry).
267 -- It returns an array of BSpline C1.
268 -- tolerance is a geometrical tolerance