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.
17 #ifndef _Geom2dConvert_HeaderFile
18 #define _Geom2dConvert_HeaderFile
20 #include <Standard.hxx>
21 #include <Standard_DefineAlloc.hxx>
22 #include <Standard_Handle.hxx>
24 #include <Standard_Integer.hxx>
25 #include <Standard_Boolean.hxx>
26 #include <Standard_Real.hxx>
27 #include <Convert_ParameterisationType.hxx>
28 #include <TColGeom2d_Array1OfBSplineCurve.hxx>
29 #include <TColStd_Array1OfReal.hxx>
30 #include <TColGeom2d_HArray1OfBSplineCurve.hxx>
31 #include <TColStd_HArray1OfInteger.hxx>
32 class Geom2d_BSplineCurve;
34 class Geom2dConvert_BSplineCurveKnotSplitting;
35 class Geom2dConvert_BSplineCurveToBezierCurve;
36 class Geom2dConvert_CompCurveToBSplineCurve;
37 class Geom2dConvert_ApproxCurve;
41 //! This package provides an implementation of algorithmes to do
42 //! the conversion between equivalent geometric entities from
44 //! It gives the possibility :
45 //! . to obtain the B-spline representation of bounded curves.
46 //! . to split a B-spline curve into several B-spline curves
47 //! with some constraints of continuity,
48 //! . to convert a B-spline curve into several Bezier curves
50 //! All the geometric entities used in this package are bounded.
52 //! . Generating the Bezier Points of B-spline curves and surfaces
53 //! (Wolfgang Bohm) CAGD volume 13 number 6 november 1981
54 //! . On NURBS: A Survey (Leslie Piegl) IEEE Computer Graphics and
55 //! Application January 1991
56 //! . Curve and surface construction using rational B-splines
57 //! (Leslie Piegl and Wayne Tiller) CAD Volume 19 number 9 november
59 //! . A survey of curve and surface methods in CAGD (Wolfgang BOHM)
68 //! -- Convert a curve to BSpline by Approximation
70 //! This method computes the arc of B-spline curve between the two
71 //! knots FromK1 and ToK2. If C is periodic the arc has the same
72 //! orientation as C if SameOrientation = Standard_True.
73 //! If C is not periodic SameOrientation is not used for the
74 //! computation and C is oriented from the knot fromK1 to the
76 //! We just keep the local definition of C between the knots
77 //! FromK1 and ToK2. The returned B-spline curve has its first
78 //! and last knots with a multiplicity equal to degree + 1, where
79 //! degree is the polynomial degree of C.
80 //! The indexes of the knots FromK1 and ToK2 doesn't include the
81 //! repetition of multiple knots in their definition.
83 //! Raised if FromK1 or ToK2 are out of the bounds
84 //! [FirstUKnotIndex, LastUKnotIndex]
85 //! Raised if FromK1 = ToK2
86 Standard_EXPORT static Handle(Geom2d_BSplineCurve) SplitBSplineCurve (const Handle(Geom2d_BSplineCurve)& C, const Standard_Integer FromK1, const Standard_Integer ToK2, const Standard_Boolean SameOrientation = Standard_True);
89 //! This function computes the segment of B-spline curve between the
90 //! parametric values FromU1, ToU2.
91 //! If C is periodic the arc has the same orientation as C if
92 //! SameOrientation = True.
93 //! If C is not periodic SameOrientation is not used for the
94 //! computation and C is oriented fromU1 toU2.
95 //! If U1 and U2 and two parametric values we consider that
96 //! U1 = U2 if Abs (U1 - U2) <= ParametricTolerance and
97 //! ParametricTolerance must be greater or equal to Resolution
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 Standard_EXPORT static Handle(Geom2d_BSplineCurve) SplitBSplineCurve (const Handle(Geom2d_BSplineCurve)& C, const Standard_Real FromU1, const Standard_Real ToU2, const Standard_Real ParametricTolerance, const Standard_Boolean SameOrientation = Standard_True);
106 //! This function converts a non infinite curve from
107 //! Geom into a B-spline curve. C must be an ellipse or a
108 //! circle or a trimmed conic or a trimmed line or a Bezier
109 //! curve or a trimmed Bezier curve or a BSpline curve or a
110 //! trimmed BSpline curve or an Offset curve or a trimmed
112 //! The returned B-spline is not periodic except if C is a
113 //! Circle or an Ellipse.
114 //! ParameterisationType applies only if the curve is a Circle
121 //! Purpose: this is the classical rational parameterisation
124 //! cos(theta) = ------
129 //! sin(theta) = ------
133 //! t = tan (theta/2)
135 //! with TgtThetaOver2 the routine will compute the number of spans
136 //! using the rule num_spans = [ (ULast - UFirst) / 1.2 ] + 1
137 //! with TgtThetaOver2_N, N spans will be forced: an error will
138 //! be raized if (ULast - UFirst) >= PI and N = 1,
139 //! ULast - UFirst >= 2 PI and N = 2
142 //! here t is a rational function that approximates
143 //! theta ----> tan(theta/2).
144 //! Neverthless the composing with above function yields exact
145 //! functions whose square sum up to 1
147 //! t is replaced by a polynomial function of u so as to grant
148 //! C1 contiuity across knots.
150 //! Standard_DomainError if the curve C is infinite.
151 //! Standard_ConstructionError:
152 //! - if C is a complete circle or ellipse, and if
153 //! Parameterisation is not equal to
154 //! Convert_TgtThetaOver2 or to Convert_RationalC1, or
155 //! - if C is a trimmed circle or ellipse and if
156 //! Parameterisation is equal to
157 //! Convert_TgtThetaOver2_1 and if U2 - U1 >
158 //! 0.9999 * Pi where U1 and U2 are
159 //! respectively the first and the last parameters of the
160 //! trimmed curve (this method of parameterization
161 //! cannot be used to convert a half-circle or a
162 //! half-ellipse, for example), or
163 //! - if C is a trimmed circle or ellipse and
164 //! Parameterisation is equal to
165 //! Convert_TgtThetaOver2_2 and U2 - U1 >
166 //! 1.9999 * Pi where U1 and U2 are
167 //! respectively the first and the last parameters of the
168 //! trimmed curve (this method of parameterization
169 //! cannot be used to convert a quasi-complete circle or ellipse).
170 Standard_EXPORT static Handle(Geom2d_BSplineCurve) CurveToBSplineCurve (const Handle(Geom2d_Curve)& C, const Convert_ParameterisationType Parameterisation = Convert_TgtThetaOver2);
172 //! This Method concatenates G1 the ArrayOfCurves as far
173 //! as it is possible.
174 //! ArrayOfCurves[0..N-1]
175 //! ArrayOfToler contains the biggest tolerance of the two
176 //! points shared by two consecutives curves.
177 //! Its dimension: [0..N-2]
178 //! ClosedTolerance indicates if the ArrayOfCurves is closed.
179 //! In this case ClosedTolerance contains the biggest tolerance
180 //! of the two points which are at the closure.
181 //! Otherwise its value is 0.0
182 Standard_EXPORT static void ConcatG1 (TColGeom2d_Array1OfBSplineCurve& ArrayOfCurves, const TColStd_Array1OfReal& ArrayOfToler, Handle(TColGeom2d_HArray1OfBSplineCurve)& ArrayOfConcatenated, const Standard_Boolean ClosedFlag, const Standard_Real ClosedTolerance);
184 //! This Method concatenates C1 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 Standard_EXPORT static void ConcatC1 (TColGeom2d_Array1OfBSplineCurve& ArrayOfCurves, const TColStd_Array1OfReal& ArrayOfToler, Handle(TColStd_HArray1OfInteger)& ArrayOfIndices, Handle(TColGeom2d_HArray1OfBSplineCurve)& ArrayOfConcatenated, const Standard_Boolean ClosedFlag, const Standard_Real ClosedTolerance);
196 //! This Method concatenates C1 the ArrayOfCurves as far
197 //! as it is possible.
198 //! ArrayOfCurves[0..N-1]
199 //! ArrayOfToler contains the biggest tolerance of the two
200 //! points shared by two consecutives curves.
201 //! Its dimension: [0..N-2]
202 //! ClosedTolerance indicates if the ArrayOfCurves is closed.
203 //! In this case ClosedTolerance contains the biggest tolerance
204 //! of the two points which are at the closure.
205 //! Otherwise its value is 0.0
206 Standard_EXPORT static void ConcatC1 (TColGeom2d_Array1OfBSplineCurve& ArrayOfCurves, const TColStd_Array1OfReal& ArrayOfToler, Handle(TColStd_HArray1OfInteger)& ArrayOfIndices, Handle(TColGeom2d_HArray1OfBSplineCurve)& ArrayOfConcatenated, const Standard_Boolean ClosedFlag, const Standard_Real ClosedTolerance, const Standard_Real AngularTolerance);
208 //! This Method reduces as far as it is possible the
209 //! multiplicities of the knots of the BSpline BS.(keeping the geometry).
210 //! It returns a new BSpline which could still be C0.
211 //! tolerance is a geometrical tolerance
212 Standard_EXPORT static void C0BSplineToC1BSplineCurve (Handle(Geom2d_BSplineCurve)& BS, const Standard_Real Tolerance);
214 //! This Method reduces as far as it is possible the
215 //! multiplicities of the knots of the BSpline BS.(keeping the geometry).
216 //! It returns an array of BSpline C1.
217 //! Tolerance is a geometrical tolerance
218 Standard_EXPORT static void C0BSplineToArrayOfC1BSplineCurve (const Handle(Geom2d_BSplineCurve)& BS, Handle(TColGeom2d_HArray1OfBSplineCurve)& tabBS, const Standard_Real Tolerance);
220 //! This Method reduces as far as it is possible the
221 //! multiplicities of the knots of the BSpline BS.(keeping the geometry).
222 //! It returns an array of BSpline C1.
223 //! tolerance is a geometrical tolerance
224 Standard_EXPORT static void C0BSplineToArrayOfC1BSplineCurve (const Handle(Geom2d_BSplineCurve)& BS, Handle(TColGeom2d_HArray1OfBSplineCurve)& tabBS, const Standard_Real AngularTolerance, const Standard_Real Tolerance);
240 friend class Geom2dConvert_BSplineCurveKnotSplitting;
241 friend class Geom2dConvert_BSplineCurveToBezierCurve;
242 friend class Geom2dConvert_CompCurveToBSplineCurve;
243 friend class Geom2dConvert_ApproxCurve;
253 #endif // _Geom2dConvert_HeaderFile