1 // Created on: 1993-10-20
2 // Created by: Bruno DUMORTIER
3 // Copyright (c) 1993-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 _Convert_CompBezierCurvesToBSplineCurve_HeaderFile
18 #define _Convert_CompBezierCurvesToBSplineCurve_HeaderFile
20 #include <Standard.hxx>
21 #include <Standard_DefineAlloc.hxx>
22 #include <Standard_Handle.hxx>
24 #include <Convert_SequenceOfArray1OfPoles.hxx>
25 #include <TColgp_SequenceOfPnt.hxx>
26 #include <TColStd_SequenceOfReal.hxx>
27 #include <TColStd_SequenceOfInteger.hxx>
28 #include <Standard_Integer.hxx>
29 #include <Standard_Real.hxx>
30 #include <Standard_Boolean.hxx>
31 #include <TColgp_Array1OfPnt.hxx>
32 #include <TColStd_Array1OfReal.hxx>
33 #include <TColStd_Array1OfInteger.hxx>
34 class Standard_ConstructionError;
37 //! An algorithm to convert a sequence of adjacent
38 //! non-rational Bezier curves into a BSpline curve.
39 //! A CompBezierCurvesToBSplineCurve object provides a framework for:
40 //! - defining the sequence of adjacent non-rational Bezier
41 //! curves to be converted into a BSpline curve,
42 //! - implementing the computation algorithm, and
43 //! - consulting the results.
45 //! Do not attempt to convert rational Bezier curves using this type of algorithm.
46 class Convert_CompBezierCurvesToBSplineCurve
53 //! Constructs a framework for converting a sequence of
54 //! adjacent non-rational Bezier curves into a BSpline curve.
55 //! Knots will be created on the computed BSpline curve at
56 //! each junction point of two consecutive Bezier curves. The
57 //! degree of continuity of the BSpline curve will be increased at
58 //! the junction point of two consecutive Bezier curves if their
59 //! tangent vectors at this point are parallel. AngularTolerance
60 //! (given in radians, and defaulted to 1.0 e-4) will be used
61 //! to check the parallelism of the two tangent vectors.
62 //! Use the following functions:
63 //! - AddCurve to define in sequence the adjacent Bezier
64 //! curves to be converted,
65 //! - Perform to compute the data needed to build the BSpline curve,
66 //! - and the available consultation functions to access the
67 //! computed data. This data may be used to construct the BSpline curve.
68 Standard_EXPORT Convert_CompBezierCurvesToBSplineCurve(const Standard_Real AngularTolerance = 1.0e-4);
70 //! Adds the Bezier curve defined by the table of poles Poles, to
71 //! the sequence (still contained in this framework) of adjacent
72 //! Bezier curves to be converted into a BSpline curve.
73 //! Only polynomial (i.e. non-rational) Bezier curves are
74 //! converted using this framework.
75 //! If this is not the first call to the function (i.e. if this framework
76 //! still contains data in its Bezier curve sequence), the degree
77 //! of continuity of the BSpline curve will be increased at the
78 //! time of computation at the first point of the added Bezier
79 //! curve (i.e. the first point of the Poles table). This will be the
80 //! case if the tangent vector of the curve at this point is
81 //! parallel to the tangent vector at the end point of the
82 //! preceding Bezier curve in the Bezier curve sequence still
83 //! contained in this framework. An angular tolerance given at
84 //! the time of construction of this framework will be used to
85 //! check the parallelism of the two tangent vectors. This
86 //! checking procedure and all related computations will be
87 //! performed by the Perform function.
88 //! When the adjacent Bezier curve sequence is complete, use
89 //! the following functions:
90 //! - Perform to compute the data needed to build the BSpline curve,
91 //! - and the available consultation functions to access the
92 //! computed data. This data may be used to construct the BSpline curve.
94 //! The Bezier curve sequence treated by this framework is
95 //! automatically initialized with the first Bezier curve when the
96 //! function is first called. During subsequent use of this function,
97 //! ensure that the first point of the added Bezier curve (i.e. the
98 //! first point of the Poles table) is coincident with the last point
99 //! of the Bezier curve sequence (i.e. the last point of the
100 //! preceding Bezier curve in the sequence) still contained in
101 //! this framework. An error may occur at the time of
102 //! computation if this condition is not satisfied. Particular care
103 //! must be taken with respect to the above, as this condition is
104 //! not checked either when defining the Bezier curve
105 //! sequence or at the time of computation.
106 Standard_EXPORT void AddCurve (const TColgp_Array1OfPnt& Poles);
108 //! Computes all the data needed to build a BSpline curve
109 //! equivalent to the adjacent Bezier curve sequence still
110 //! contained in this framework.
111 //! A knot is inserted on the computed BSpline curve at the
112 //! junction point of two consecutive Bezier curves. The
113 //! degree of continuity of the BSpline curve will be increased
114 //! at the junction point of two consecutive Bezier curves if
115 //! their tangent vectors at this point are parallel. An angular
116 //! tolerance given at the time of construction of this
117 //! framework is used to check the parallelism of the two
119 //! Use the available consultation functions to access the
120 //! computed data. This data may then be used to construct
121 //! the BSpline curve.
123 //! Make sure that the curves in the Bezier curve sequence
124 //! contained in this framework are adjacent. An error may
125 //! occur at the time of computation if this condition is not
126 //! satisfied. Particular care must be taken with respect to the
127 //! above as this condition is not checked, either when
128 //! defining the Bezier curve sequence or at the time of computation.
129 Standard_EXPORT void Perform();
131 //! Returns the degree of the BSpline curve whose data is
132 //! computed in this framework.
134 //! Take particular care not to use this function before the
135 //! computation is performed (Perform function), as this
136 //! condition is not checked and an error may therefore occur.
137 Standard_EXPORT Standard_Integer Degree() const;
139 //! Returns the number of poles of the BSpline curve whose
140 //! data is computed in this framework.
142 //! Take particular care not to use this function before the
143 //! computation is performed (Perform function), as this
144 //! condition is not checked and an error may therefore occur.
145 Standard_EXPORT Standard_Integer NbPoles() const;
147 //! Loads the Poles table with the poles of the BSpline curve
148 //! whose data is computed in this framework.
150 //! - Do not use this function before the computation is
151 //! performed (Perform function).
152 //! - The length of the Poles array must be equal to the
153 //! number of poles of the BSpline curve whose data is
154 //! computed in this framework.
155 //! Particular care must be taken with respect to the above, as
156 //! these conditions are not checked, and an error may occur.
157 Standard_EXPORT void Poles (TColgp_Array1OfPnt& Poles) const;
159 //! Returns the number of knots of the BSpline curve whose
160 //! data is computed in this framework.
162 //! Take particular care not to use this function before the
163 //! computation is performed (Perform function), as this
164 //! condition is not checked and an error may therefore occur.
165 Standard_EXPORT Standard_Integer NbKnots() const;
168 //! - loads the Knots table with the knots,
169 //! - and loads the Mults table with the corresponding multiplicities
170 //! of the BSpline curve whose data is computed in this framework.
172 //! - Do not use this function before the computation is
173 //! performed (Perform function).
174 //! - The length of the Knots and Mults arrays must be equal
175 //! to the number of knots in the BSpline curve whose data is
176 //! computed in this framework.
177 //! Particular care must be taken with respect to the above as
178 //! these conditions are not checked, and an error may occur.
179 Standard_EXPORT void KnotsAndMults (TColStd_Array1OfReal& Knots, TColStd_Array1OfInteger& Mults) const;
194 Convert_SequenceOfArray1OfPoles mySequence;
195 TColgp_SequenceOfPnt CurvePoles;
196 TColStd_SequenceOfReal CurveKnots;
197 TColStd_SequenceOfInteger KnotsMultiplicities;
198 Standard_Integer myDegree;
199 Standard_Real myAngular;
200 Standard_Boolean myDone;
211 #endif // _Convert_CompBezierCurvesToBSplineCurve_HeaderFile