0033661: Data Exchange, Step Import - Tessellated GDTs are not imported
[occt.git] / src / Geom2dConvert / Geom2dConvert.hxx
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
5 //
6 // This file is part of Open CASCADE Technology software library.
7 //
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.
13 //
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
16
17 #ifndef _Geom2dConvert_HeaderFile
18 #define _Geom2dConvert_HeaderFile
19
20 #include <Standard.hxx>
21 #include <Standard_DefineAlloc.hxx>
22 #include <Standard_Handle.hxx>
23
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;
33 class Geom2d_Curve;
34
35
36
37 //! This package provides an implementation of algorithms to do
38 //! the conversion between equivalent geometric entities from
39 //! package Geom2d.
40 //! It gives the possibility :
41 //! . to obtain the B-spline representation of bounded curves.
42 //! . to split a B-spline curve into several B-spline curves
43 //! with some constraints of continuity,
44 //! . to convert a B-spline curve into several Bezier curves
45 //! or surfaces.
46 //! All the geometric entities used in this package are bounded.
47 //! References :
48 //! . Generating the Bezier Points of B-spline curves and surfaces
49 //! (Wolfgang Bohm) CAGD volume 13 number 6 november 1981
50 //! . On NURBS: A Survey  (Leslie Piegl) IEEE Computer Graphics and
51 //! Application January 1991
52 //! . Curve and surface construction using rational B-splines
53 //! (Leslie Piegl and Wayne Tiller) CAD Volume 19 number 9 november
54 //! 1987
55 //! . A survey of curve and surface methods in CAGD (Wolfgang BOHM)
56 //! CAGD 1 1984
57 class Geom2dConvert 
58 {
59 public:
60
61   DEFINE_STANDARD_ALLOC
62
63   
64   //! -- Convert a curve to BSpline  by Approximation
65   //!
66   //! This method computes the arc of B-spline curve between the two
67   //! knots FromK1 and ToK2.  If C is periodic the arc has the same
68   //! orientation as C if SameOrientation = Standard_True.
69   //! If C is not periodic  SameOrientation is not used for the
70   //! computation and C is oriented from the knot fromK1 to the
71   //! knot toK2.
72   //! We just keep the local definition of C between the knots
73   //! FromK1 and ToK2.  The returned B-spline curve has its first
74   //! and last knots with a multiplicity equal to degree + 1, where
75   //! degree is the polynomial degree of C.
76   //! The indexes of the knots FromK1 and ToK2 doesn't include the
77   //! repetition of multiple knots in their definition.
78   //!
79   //! Raised if FromK1 or ToK2 are out of the bounds
80   //! [FirstUKnotIndex, LastUKnotIndex]
81   //! Raised if FromK1 = ToK2
82   Standard_EXPORT static Handle(Geom2d_BSplineCurve) SplitBSplineCurve (const Handle(Geom2d_BSplineCurve)& C,
83                                                                         const Standard_Integer FromK1,
84                                                                         const Standard_Integer ToK2,
85                                                                         const Standard_Boolean SameOrientation = Standard_True);
86   
87
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   //!
99   //! Raised if FromU1 or ToU2 are out of the parametric bounds of the
100   //! curve (The tolerance criterion is ParametricTolerance).
101   //! Raised if Abs (FromU1 - ToU2) <= ParametricTolerance
102   //! Raised if ParametricTolerance < Resolution from gp.
103   Standard_EXPORT static Handle(Geom2d_BSplineCurve) SplitBSplineCurve (const Handle(Geom2d_BSplineCurve)& C,
104                                                                         const Standard_Real FromU1,
105                                                                         const Standard_Real ToU2,
106                                                                         const Standard_Real ParametricTolerance,
107                                                                         const Standard_Boolean SameOrientation = Standard_True);
108   
109   //! This function converts a non infinite curve from
110   //! Geom into a  B-spline curve.  C must  be  an ellipse or a
111   //! circle or a trimmed conic  or a trimmed  line or a Bezier
112   //! curve or a trimmed  Bezier curve or a  BSpline curve or  a
113   //! trimmed BSpline   curve  or an  Offset  curve or a  trimmed
114   //! Offset curve.
115   //! The returned B-spline is not periodic except if C is a
116   //! Circle or an Ellipse.
117   //! ParameterisationType applies only if the curve is a Circle
118   //! or an ellipse :
119   //! TgtThetaOver2,
120   //! TgtThetaOver2_1,
121   //! TgtThetaOver2_2,
122   //! TgtThetaOver2_3,
123   //! TgtThetaOver2_4,
124   //! Purpose: this is the classical rational parameterisation
125   //! 2
126   //! 1 - t
127   //! cos(theta) = ------
128   //! 2
129   //! 1 + t
130   //!
131   //! 2t
132   //! sin(theta) = ------
133   //! 2
134   //! 1 + t
135   //!
136   //! t = tan (theta/2)
137   //!
138   //! with TgtThetaOver2  the routine will compute the number of spans
139   //! using the rule num_spans = [ (ULast - UFirst) / 1.2 ] + 1
140   //! with TgtThetaOver2_N, N  spans will be forced: an error will
141   //! be raized if (ULast - UFirst) >= PI and N = 1,
142   //! ULast - UFirst >= 2 PI and N = 2
143   //!
144   //! QuasiAngular,
145   //! here t is a rational function that approximates
146   //! theta ----> tan(theta/2).
147   //! Nevetheless the composing with above function yields exact
148   //! functions whose square sum up to 1
149   //! RationalC1 ;
150   //! t is replaced by a polynomial function of u so as to grant
151   //! C1 contiuity across knots.
152   //! Exceptions
153   //! Standard_DomainError if the curve C is infinite.
154   //! Standard_ConstructionError:
155   //! -   if C is a complete circle or ellipse, and if
156   //! Parameterisation is not equal to
157   //! Convert_TgtThetaOver2 or to Convert_RationalC1, or
158   //! -   if C is a trimmed circle or ellipse and if
159   //! Parameterisation is equal to
160   //! Convert_TgtThetaOver2_1 and if U2 - U1 >
161   //! 0.9999 * Pi where U1 and U2 are
162   //! respectively the first and the last parameters of the
163   //! trimmed curve (this method of parameterization
164   //! cannot be used to convert a half-circle or a
165   //! half-ellipse, for example), or
166   //! -   if C is a trimmed circle or ellipse and
167   //! Parameterisation is equal to
168   //! Convert_TgtThetaOver2_2 and U2 - U1 >
169   //! 1.9999 * Pi where U1 and U2 are
170   //! respectively the first and the last parameters of the
171   //! trimmed curve (this method of parameterization
172   //! cannot be used to convert a quasi-complete circle or ellipse).
173   Standard_EXPORT static Handle(Geom2d_BSplineCurve) CurveToBSplineCurve (const Handle(Geom2d_Curve)& C,
174                                                                           const Convert_ParameterisationType Parameterisation = Convert_TgtThetaOver2);
175   
176   //! This Method concatenates G1 the ArrayOfCurves as far
177   //! as it is possible.
178   //! ArrayOfCurves[0..N-1]
179   //! ArrayOfToler contains the  biggest tolerance of the two
180   //! points shared by two consecutives curves.
181   //! Its dimension: [0..N-2]
182   //! ClosedFlag     indicates if the ArrayOfCurves is closed.
183   //! In this case ClosedTolerance contains the biggest tolerance
184   //! of the two points which are at the closure.
185   //! Otherwise its value is 0.0
186   //! ClosedFlag becomes False on the output
187   //! if it is impossible to build closed curve.
188   Standard_EXPORT static void ConcatG1 (TColGeom2d_Array1OfBSplineCurve& ArrayOfCurves,
189                                         const TColStd_Array1OfReal& ArrayOfToler,
190                                         Handle(TColGeom2d_HArray1OfBSplineCurve)& ArrayOfConcatenated,
191                                         Standard_Boolean& ClosedFlag,
192                                         const Standard_Real ClosedTolerance);
193   
194   //! This Method concatenates C1 the ArrayOfCurves as far
195   //! as it is possible.
196   //! ArrayOfCurves[0..N-1]
197   //! ArrayOfToler contains the  biggest tolerance of the two
198   //! points shared by two consecutives curves.
199   //! Its dimension: [0..N-2]
200   //! ClosedFlag     indicates if the ArrayOfCurves is closed.
201   //! In this case ClosedTolerance contains the biggest tolerance
202   //! of the two points which are at the closure.
203   //! Otherwise its value is 0.0
204   //! ClosedFlag becomes False on the output
205   //! if it is impossible to build closed curve.
206   Standard_EXPORT static void ConcatC1 (TColGeom2d_Array1OfBSplineCurve& ArrayOfCurves,
207                                         const TColStd_Array1OfReal& ArrayOfToler,
208                                         Handle(TColStd_HArray1OfInteger)& ArrayOfIndices,
209                                         Handle(TColGeom2d_HArray1OfBSplineCurve)& ArrayOfConcatenated,
210                                         Standard_Boolean& ClosedFlag,
211                                         const Standard_Real ClosedTolerance);
212   
213   //! This Method concatenates C1 the ArrayOfCurves as far
214   //! as it is possible.
215   //! ArrayOfCurves[0..N-1]
216   //! ArrayOfToler contains the  biggest tolerance of the two
217   //! points shared by two consecutives curves.
218   //! Its dimension: [0..N-2]
219   //! ClosedFlag     indicates if the ArrayOfCurves is closed.
220   //! In this case ClosedTolerance contains the biggest tolerance
221   //! of the two points which are at the closure.
222   //! Otherwise its value is 0.0
223   //! ClosedFlag becomes False on the output
224   //! if it is impossible to build closed curve.
225   Standard_EXPORT static void ConcatC1 (TColGeom2d_Array1OfBSplineCurve& ArrayOfCurves,
226                                         const TColStd_Array1OfReal& ArrayOfToler,
227                                         Handle(TColStd_HArray1OfInteger)& ArrayOfIndices,
228                                         Handle(TColGeom2d_HArray1OfBSplineCurve)& ArrayOfConcatenated,
229                                         Standard_Boolean& ClosedFlag,
230                                         const Standard_Real ClosedTolerance,
231                                         const Standard_Real AngularTolerance);
232   
233   //! 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   Standard_EXPORT static void C0BSplineToC1BSplineCurve (Handle(Geom2d_BSplineCurve)& BS,
238                                                          const Standard_Real Tolerance);
239   
240   //! This Method   reduces as far  as  it is possible  the
241   //! multiplicities  of  the knots  of the BSpline  BS.(keeping the geometry).
242   //! It returns an array of BSpline C1.
243   //! Tolerance is a geometrical tolerance
244   Standard_EXPORT static void C0BSplineToArrayOfC1BSplineCurve (const Handle(Geom2d_BSplineCurve)& BS,
245                                                                 Handle(TColGeom2d_HArray1OfBSplineCurve)& tabBS,
246                                                                 const Standard_Real Tolerance);
247   
248   //! This Method   reduces as far  as  it is possible  the
249   //! multiplicities  of  the knots  of the BSpline  BS.(keeping the geometry).
250   //! It returns an array of BSpline C1.
251   //! tolerance is a geometrical tolerance
252   Standard_EXPORT static void C0BSplineToArrayOfC1BSplineCurve (const Handle(Geom2d_BSplineCurve)& BS,
253                                                                 Handle(TColGeom2d_HArray1OfBSplineCurve)& tabBS,
254                                                                 const Standard_Real AngularTolerance,
255                                                                 const Standard_Real Tolerance);
256
257 };
258
259 #endif // _Geom2dConvert_HeaderFile