0031642: Visualization - crash in Graphic3d_Structure::SetVisual() on redisplaying...
[occt.git] / src / Convert / Convert_CompBezierCurves2dToBSplineCurve2d.hxx
CommitLineData
42cf5bc1 1// Created on: 1993-11-09
2// Created by: Modelistation
3// Copyright (c) 1993-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 _Convert_CompBezierCurves2dToBSplineCurve2d_HeaderFile
18#define _Convert_CompBezierCurves2dToBSplineCurve2d_HeaderFile
19
20#include <Standard.hxx>
21#include <Standard_DefineAlloc.hxx>
22#include <Standard_Handle.hxx>
23
24#include <Convert_SequenceOfArray1OfPoles2d.hxx>
25#include <TColgp_SequenceOfPnt2d.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_Array1OfPnt2d.hxx>
32#include <TColStd_Array1OfReal.hxx>
33#include <TColStd_Array1OfInteger.hxx>
34class Standard_ConstructionError;
35
36
37//! Converts a list of connecting Bezier Curves 2d to a
38//! BSplineCurve 2d.
39//! if possible, the continuity of the BSpline will be
40//! increased to more than C0.
41class Convert_CompBezierCurves2dToBSplineCurve2d
42{
43public:
44
45 DEFINE_STANDARD_ALLOC
46
47
48 //! Constructs a framework for converting a sequence of
49 //! adjacent non-rational Bezier curves into a BSpline curve.
50 //! Knots will be created on the computed BSpline curve at
51 //! each junction point of two consecutive Bezier curves. The
52 //! degree of continuity of the BSpline curve will be increased at
53 //! the junction point of two consecutive Bezier curves if their
54 //! tangent vectors at this point are parallel. AngularTolerance
55 //! (given in radians, and defaulted to 1.0 e-4) will be used
56 //! to check the parallelism of the two tangent vectors.
57 //! Use the following functions:
58 //! - AddCurve to define in sequence the adjacent Bezier
59 //! curves to be converted,
60 //! - Perform to compute the data needed to build the BSpline curve,
61 //! - and the available consultation functions to access the
62 //! computed data. This data may be used to construct the BSpline curve.
63 Standard_EXPORT Convert_CompBezierCurves2dToBSplineCurve2d(const Standard_Real AngularTolerance = 1.0e-4);
64
65 //! Adds the Bezier curve defined by the table of poles Poles, to
66 //! the sequence (still contained in this framework) of adjacent
67 //! Bezier curves to be converted into a BSpline curve.
68 //! Only polynomial (i.e. non-rational) Bezier curves are
69 //! converted using this framework.
70 //! If this is not the first call to the function (i.e. if this framework
71 //! still contains data in its sequence of Bezier curves), the
72 //! degree of continuity of the BSpline curve will be increased at
73 //! the time of computation at the first point of the added Bezier
74 //! curve (i.e. the first point of the Poles table). This will be the
75 //! case if the tangent vector of the curve at this point is
76 //! parallel to the tangent vector at the end point of the
77 //! preceding Bezier curve in the sequence of Bezier curves still
78 //! contained in this framework. An angular tolerance given at
79 //! the time of construction of this framework, will be used to
80 //! check the parallelism of the two tangent vectors. This
81 //! checking procedure, and all the relative computations will be
82 //! performed by the function Perform.
83 //! When the sequence of adjacent Bezier curves is complete,
84 //! use the following functions:
85 //! - Perform to compute the data needed to build the BSpline curve,
86 //! - and the available consultation functions to access the
87 //! computed data. This data may be used to construct the BSpline curve.
88 //! Warning
89 //! The sequence of Bezier curves treated by this framework is
90 //! automatically initialized with the first Bezier curve when the
91 //! function is first called. During subsequent use of this function,
92 //! ensure that the first point of the added Bezier curve (i.e. the
93 //! first point of the Poles table) is coincident with the last point
94 //! of the sequence (i.e. the last point of the preceding Bezier
95 //! curve in the sequence) of Bezier curves still contained in
96 //! this framework. An error may occur at the time of
97 //! computation if this condition is not satisfied. Particular care
98 //! must be taken with respect to the above, as this condition is
99 //! not checked either when defining the sequence of Bezier
100 //! curves or at the time of computation.
101 Standard_EXPORT void AddCurve (const TColgp_Array1OfPnt2d& Poles);
102
103 //! Computes all the data needed to build a BSpline curve
104 //! equivalent to the sequence of adjacent Bezier curves still
105 //! contained in this framework.
106 //! A knot is inserted on the computed BSpline curve at the
107 //! junction point of two consecutive Bezier curves. The
108 //! degree of continuity of the BSpline curve will be increased
109 //! at the junction point of two consecutive Bezier curves if
110 //! their tangent vectors at this point are parallel. An angular
111 //! tolerance given at the time of construction of this
112 //! framework is used to check the parallelism of the two
113 //! tangent vectors.
114 //! Use the available consultation functions to access the
115 //! computed data. This data may then be used to construct
116 //! the BSpline curve.
117 //! Warning
118 //! Ensure that the curves in the sequence of Bezier curves
119 //! contained in this framework are adjacent. An error may
120 //! occur at the time of computation if this condition is not
121 //! satisfied. Particular care must be taken with respect to the
122 //! above as this condition is not checked, either when
123 //! defining the Bezier curve sequence or at the time of computation.
124 Standard_EXPORT void Perform();
125
126 //! Returns the degree of the BSpline curve whose data is
127 //! computed in this framework.
128 //! Warning
129 //! Take particular care not to use this function before the
130 //! computation is performed (Perform function), as this
131 //! condition is not checked and an error may therefore occur.
132 Standard_EXPORT Standard_Integer Degree() const;
133
134 //! Returns the number of poles of the BSpline curve whose
135 //! data is computed in this framework.
136 //! Warning
137 //! Take particular care not to use this function before the
138 //! computation is performed (Perform function), as this
139 //! condition is not checked and an error may therefore occur.
140 Standard_EXPORT Standard_Integer NbPoles() const;
141
142 //! Loads the Poles table with the poles of the BSpline curve
143 //! whose data is computed in this framework.
144 //! Warning
145 //! - Do not use this function before the computation is
146 //! performed (Perform function).
147 //! - The length of the Poles array must be equal to the
148 //! number of poles of the BSpline curve whose data is
149 //! computed in this framework.
150 //! Particular care must be taken with respect to the above, as
151 //! these conditions are not checked, and an error may occur.
152 Standard_EXPORT void Poles (TColgp_Array1OfPnt2d& Poles) const;
153
154 //! Returns the number of knots of the BSpline curve whose
155 //! data is computed in this framework.
156 //! Warning
157 //! Take particular care not to use this function before the
158 //! computation is performed (Perform function), as this
159 //! condition is not checked and an error may therefore occur.
160 Standard_EXPORT Standard_Integer NbKnots() const;
161
162 //! Loads the Knots table with the knots
163 //! and the Mults table with the corresponding multiplicities
164 //! of the BSpline curve whose data is computed in this framework.
165 //! Warning
166 //! - Do not use this function before the computation is
167 //! performed (Perform function).
168 //! - The length of the Knots and Mults arrays must be equal
169 //! to the number of knots in the BSpline curve whose data is
170 //! computed in this framework.
171 //! Particular care must be taken with respect to the above as
172 //! these conditions are not checked, and an error may occur.
173 Standard_EXPORT void KnotsAndMults (TColStd_Array1OfReal& Knots, TColStd_Array1OfInteger& Mults) const;
174
175
176
177
178protected:
179
180
181
182
183
184private:
185
186
187
188 Convert_SequenceOfArray1OfPoles2d mySequence;
189 TColgp_SequenceOfPnt2d CurvePoles;
190 TColStd_SequenceOfReal CurveKnots;
191 TColStd_SequenceOfInteger KnotsMultiplicities;
192 Standard_Integer myDegree;
193 Standard_Real myAngular;
194 Standard_Boolean myDone;
195
196
197};
198
199
200
201
202
203
204
205#endif // _Convert_CompBezierCurves2dToBSplineCurve2d_HeaderFile