0031687: Draw Harness, ViewerTest - extend command vrenderparams with option updating...
[occt.git] / src / Geom2dConvert / Geom2dConvert.hxx
CommitLineData
42cf5bc1 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>
32class Geom2d_BSplineCurve;
33class Geom2d_Curve;
34class Geom2dConvert_BSplineCurveKnotSplitting;
35class Geom2dConvert_BSplineCurveToBezierCurve;
36class Geom2dConvert_CompCurveToBSplineCurve;
37class Geom2dConvert_ApproxCurve;
38
39
40
41//! This package provides an implementation of algorithmes to do
42//! the conversion between equivalent geometric entities from
43//! package Geom2d.
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
49//! or surfaces.
50//! All the geometric entities used in this package are bounded.
51//! References :
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
58//! 1987
59//! . A survey of curve and surface methods in CAGD (Wolfgang BOHM)
60//! CAGD 1 1984
61class Geom2dConvert
62{
63public:
64
65 DEFINE_STANDARD_ALLOC
66
67
68 //! -- Convert a curve to BSpline by Approximation
69 //!
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
75 //! knot toK2.
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.
82 //!
83 //! Raised if FromK1 or ToK2 are out of the bounds
84 //! [FirstUKnotIndex, LastUKnotIndex]
85 //! Raised if FromK1 = ToK2
4a361058 86 Standard_EXPORT static Handle(Geom2d_BSplineCurve) SplitBSplineCurve (const Handle(Geom2d_BSplineCurve)& C,
87 const Standard_Integer FromK1,
88 const Standard_Integer ToK2,
89 const Standard_Boolean SameOrientation = Standard_True);
42cf5bc1 90
91
92 //! This function computes the segment of B-spline curve between the
93 //! parametric values FromU1, ToU2.
94 //! If C is periodic the arc has the same orientation as C if
95 //! SameOrientation = True.
96 //! If C is not periodic SameOrientation is not used for the
97 //! computation and C is oriented fromU1 toU2.
98 //! If U1 and U2 and two parametric values we consider that
99 //! U1 = U2 if Abs (U1 - U2) <= ParametricTolerance and
100 //! ParametricTolerance must be greater or equal to Resolution
101 //! from package gp.
102 //!
103 //! Raised if FromU1 or ToU2 are out of the parametric bounds of the
104 //! curve (The tolerance criterion is ParametricTolerance).
105 //! Raised if Abs (FromU1 - ToU2) <= ParametricTolerance
106 //! Raised if ParametricTolerance < Resolution from gp.
4a361058 107 Standard_EXPORT static Handle(Geom2d_BSplineCurve) SplitBSplineCurve (const Handle(Geom2d_BSplineCurve)& C,
108 const Standard_Real FromU1,
109 const Standard_Real ToU2,
110 const Standard_Real ParametricTolerance,
111 const Standard_Boolean SameOrientation = Standard_True);
42cf5bc1 112
113 //! This function converts a non infinite curve from
114 //! Geom into a B-spline curve. C must be an ellipse or a
115 //! circle or a trimmed conic or a trimmed line or a Bezier
116 //! curve or a trimmed Bezier curve or a BSpline curve or a
117 //! trimmed BSpline curve or an Offset curve or a trimmed
118 //! Offset curve.
119 //! The returned B-spline is not periodic except if C is a
120 //! Circle or an Ellipse.
121 //! ParameterisationType applies only if the curve is a Circle
122 //! or an ellipse :
123 //! TgtThetaOver2,
124 //! TgtThetaOver2_1,
125 //! TgtThetaOver2_2,
126 //! TgtThetaOver2_3,
127 //! TgtThetaOver2_4,
128 //! Purpose: this is the classical rational parameterisation
129 //! 2
130 //! 1 - t
131 //! cos(theta) = ------
132 //! 2
133 //! 1 + t
134 //!
135 //! 2t
136 //! sin(theta) = ------
137 //! 2
138 //! 1 + t
139 //!
140 //! t = tan (theta/2)
141 //!
142 //! with TgtThetaOver2 the routine will compute the number of spans
143 //! using the rule num_spans = [ (ULast - UFirst) / 1.2 ] + 1
144 //! with TgtThetaOver2_N, N spans will be forced: an error will
145 //! be raized if (ULast - UFirst) >= PI and N = 1,
146 //! ULast - UFirst >= 2 PI and N = 2
147 //!
148 //! QuasiAngular,
149 //! here t is a rational function that approximates
150 //! theta ----> tan(theta/2).
151 //! Neverthless the composing with above function yields exact
152 //! functions whose square sum up to 1
153 //! RationalC1 ;
154 //! t is replaced by a polynomial function of u so as to grant
155 //! C1 contiuity across knots.
156 //! Exceptions
157 //! Standard_DomainError if the curve C is infinite.
158 //! Standard_ConstructionError:
159 //! - if C is a complete circle or ellipse, and if
160 //! Parameterisation is not equal to
161 //! Convert_TgtThetaOver2 or to Convert_RationalC1, or
162 //! - if C is a trimmed circle or ellipse and if
163 //! Parameterisation is equal to
164 //! Convert_TgtThetaOver2_1 and if U2 - U1 >
165 //! 0.9999 * Pi where U1 and U2 are
166 //! respectively the first and the last parameters of the
167 //! trimmed curve (this method of parameterization
168 //! cannot be used to convert a half-circle or a
169 //! half-ellipse, for example), or
170 //! - if C is a trimmed circle or ellipse and
171 //! Parameterisation is equal to
172 //! Convert_TgtThetaOver2_2 and U2 - U1 >
173 //! 1.9999 * Pi where U1 and U2 are
174 //! respectively the first and the last parameters of the
175 //! trimmed curve (this method of parameterization
176 //! cannot be used to convert a quasi-complete circle or ellipse).
4a361058 177 Standard_EXPORT static Handle(Geom2d_BSplineCurve) CurveToBSplineCurve (const Handle(Geom2d_Curve)& C,
178 const Convert_ParameterisationType Parameterisation = Convert_TgtThetaOver2);
42cf5bc1 179
180 //! This Method concatenates G1 the ArrayOfCurves as far
181 //! as it is possible.
182 //! ArrayOfCurves[0..N-1]
183 //! ArrayOfToler contains the biggest tolerance of the two
184 //! points shared by two consecutives curves.
185 //! Its dimension: [0..N-2]
4a361058 186 //! ClosedFlag indicates if the ArrayOfCurves is closed.
42cf5bc1 187 //! In this case ClosedTolerance contains the biggest tolerance
188 //! of the two points which are at the closure.
189 //! Otherwise its value is 0.0
4a361058 190 //! ClosedFlag becomes False on the output
191 //! if it is impossible to build closed curve.
192 Standard_EXPORT static void ConcatG1 (TColGeom2d_Array1OfBSplineCurve& ArrayOfCurves,
193 const TColStd_Array1OfReal& ArrayOfToler,
194 Handle(TColGeom2d_HArray1OfBSplineCurve)& ArrayOfConcatenated,
195 Standard_Boolean& ClosedFlag,
196 const Standard_Real ClosedTolerance);
42cf5bc1 197
198 //! This Method concatenates C1 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]
4a361058 204 //! ClosedFlag indicates if the ArrayOfCurves is closed.
42cf5bc1 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
4a361058 208 //! ClosedFlag becomes False on the output
209 //! if it is impossible to build closed curve.
210 Standard_EXPORT static void ConcatC1 (TColGeom2d_Array1OfBSplineCurve& ArrayOfCurves,
211 const TColStd_Array1OfReal& ArrayOfToler,
212 Handle(TColStd_HArray1OfInteger)& ArrayOfIndices,
213 Handle(TColGeom2d_HArray1OfBSplineCurve)& ArrayOfConcatenated,
214 Standard_Boolean& ClosedFlag,
215 const Standard_Real ClosedTolerance);
42cf5bc1 216
217 //! This Method concatenates C1 the ArrayOfCurves as far
218 //! as it is possible.
219 //! ArrayOfCurves[0..N-1]
220 //! ArrayOfToler contains the biggest tolerance of the two
221 //! points shared by two consecutives curves.
222 //! Its dimension: [0..N-2]
4a361058 223 //! ClosedFlag indicates if the ArrayOfCurves is closed.
42cf5bc1 224 //! In this case ClosedTolerance contains the biggest tolerance
225 //! of the two points which are at the closure.
226 //! Otherwise its value is 0.0
4a361058 227 //! ClosedFlag becomes False on the output
228 //! if it is impossible to build closed curve.
229 Standard_EXPORT static void ConcatC1 (TColGeom2d_Array1OfBSplineCurve& ArrayOfCurves,
230 const TColStd_Array1OfReal& ArrayOfToler,
231 Handle(TColStd_HArray1OfInteger)& ArrayOfIndices,
232 Handle(TColGeom2d_HArray1OfBSplineCurve)& ArrayOfConcatenated,
233 Standard_Boolean& ClosedFlag,
234 const Standard_Real ClosedTolerance,
235 const Standard_Real AngularTolerance);
42cf5bc1 236
237 //! This Method reduces as far as it is possible the
238 //! multiplicities of the knots of the BSpline BS.(keeping the geometry).
239 //! It returns a new BSpline which could still be C0.
240 //! tolerance is a geometrical tolerance
4a361058 241 Standard_EXPORT static void C0BSplineToC1BSplineCurve (Handle(Geom2d_BSplineCurve)& BS,
242 const Standard_Real Tolerance);
42cf5bc1 243
244 //! This Method reduces as far as it is possible the
245 //! multiplicities of the knots of the BSpline BS.(keeping the geometry).
246 //! It returns an array of BSpline C1.
247 //! Tolerance is a geometrical tolerance
4a361058 248 Standard_EXPORT static void C0BSplineToArrayOfC1BSplineCurve (const Handle(Geom2d_BSplineCurve)& BS,
249 Handle(TColGeom2d_HArray1OfBSplineCurve)& tabBS,
250 const Standard_Real Tolerance);
42cf5bc1 251
252 //! This Method reduces as far as it is possible the
253 //! multiplicities of the knots of the BSpline BS.(keeping the geometry).
254 //! It returns an array of BSpline C1.
255 //! tolerance is a geometrical tolerance
4a361058 256 Standard_EXPORT static void C0BSplineToArrayOfC1BSplineCurve (const Handle(Geom2d_BSplineCurve)& BS,
257 Handle(TColGeom2d_HArray1OfBSplineCurve)& tabBS,
258 const Standard_Real AngularTolerance,
259 const Standard_Real Tolerance);
42cf5bc1 260
261
262
263
264protected:
265
266
267
268
269
270private:
271
272
273
274
275friend class Geom2dConvert_BSplineCurveKnotSplitting;
276friend class Geom2dConvert_BSplineCurveToBezierCurve;
277friend class Geom2dConvert_CompCurveToBSplineCurve;
278friend class Geom2dConvert_ApproxCurve;
279
280};
281
282
283
284
285
286
287
288#endif // _Geom2dConvert_HeaderFile