0031642: Visualization - crash in Graphic3d_Structure::SetVisual() on redisplaying...
[occt.git] / src / Geom2dAPI / Geom2dAPI_PointsToBSpline.hxx
CommitLineData
42cf5bc1 1// Created on: 1994-03-23
2// Created by: Bruno DUMORTIER
3// Copyright (c) 1994-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 _Geom2dAPI_PointsToBSpline_HeaderFile
18#define _Geom2dAPI_PointsToBSpline_HeaderFile
19
20#include <Standard.hxx>
21#include <Standard_DefineAlloc.hxx>
22#include <Standard_Handle.hxx>
23
24#include <Standard_Boolean.hxx>
25#include <TColgp_Array1OfPnt2d.hxx>
26#include <Standard_Integer.hxx>
27#include <GeomAbs_Shape.hxx>
28#include <Standard_Real.hxx>
29#include <TColStd_Array1OfReal.hxx>
30#include <Approx_ParametrizationType.hxx>
31class Geom2d_BSplineCurve;
32class StdFail_NotDone;
33class Standard_OutOfRange;
34
35
36//! This class is used to approximate a BsplineCurve
37//! passing through an array of points, with a given
38//! Continuity.
39//! Describes functions for building a 2D BSpline
40//! curve which approximates a set of points.
41//! A PointsToBSpline object provides a framework for:
42//! - defining the data of the BSpline curve to be built,
43//! - implementing the approximation algorithm, and
44//! - consulting the results
45class Geom2dAPI_PointsToBSpline
46{
47public:
48
49 DEFINE_STANDARD_ALLOC
50
51
52 //! Constructs an empty approximation algorithm.
53 //! Use an Init function to define and build the BSpline curve.
54 Standard_EXPORT Geom2dAPI_PointsToBSpline();
55
56 //! Approximate a BSpline Curve passing through an
57 //! array of Point. The resulting BSpline will have
58 //! the following properties:
59 //! 1- his degree will be in the range [Degmin,Degmax]
60 //! 2- his continuity will be at least <Continuity>
61 //! 3- the distance from the point <Points> to the
62 //! BSpline will be lower to Tol2D
63 Standard_EXPORT Geom2dAPI_PointsToBSpline(const TColgp_Array1OfPnt2d& Points, const Standard_Integer DegMin = 3, const Standard_Integer DegMax = 8, const GeomAbs_Shape Continuity = GeomAbs_C2, const Standard_Real Tol2D = 1.0e-6);
64
65 //! Approximate a BSpline Curve passing through an
66 //! array of Point. Of coordinates :
67 //!
68 //! X = X0 + DX * (i-YValues.Lower())
69 //! Y = YValues(i)
70 //!
71 //! With i in the range YValues.Lower(), YValues.Upper()
72 //!
73 //! The BSpline will be parametrized from t = X0 to
74 //! X0 + DX * (YValues.Upper() - YValues.Lower())
75 //!
76 //! And will satisfy X(t) = t
77 //!
78 //! The resulting BSpline will have
79 //! the following properties:
80 //! 1- his degree will be in the range [Degmin,Degmax]
81 //! 2- his continuity will be at least <Continuity>
82 //! 3- the distance from the point <Points> to the
83 //! BSpline will be lower to Tol2D
84 Standard_EXPORT Geom2dAPI_PointsToBSpline(const TColStd_Array1OfReal& YValues, const Standard_Real X0, const Standard_Real DX, const Standard_Integer DegMin = 3, const Standard_Integer DegMax = 8, const GeomAbs_Shape Continuity = GeomAbs_C2, const Standard_Real Tol2D = 1.0e-6);
85
86 //! Approximate a BSpline Curve passing through an
87 //! array of Point. The resulting BSpline will have
88 //! the following properties:
89 //! 1- his degree will be in the range [Degmin,Degmax]
90 //! 2- his continuity will be at least <Continuity>
91 //! 3- the distance from the point <Points> to the
92 //! BSpline will be lower to Tol2D
93 Standard_EXPORT Geom2dAPI_PointsToBSpline(const TColgp_Array1OfPnt2d& Points, const Approx_ParametrizationType ParType, const Standard_Integer DegMin = 3, const Standard_Integer DegMax = 8, const GeomAbs_Shape Continuity = GeomAbs_C2, const Standard_Real Tol2D = 1.0e-3);
94
95 //! Approximate a BSpline Curve passing through an
96 //! array of Point, which parameters are given by the
97 //! array <Parameters>.
98 //! The resulting BSpline will have the following
99 //! properties:
100 //! 1- his degree will be in the range [Degmin,Degmax]
101 //! 2- his continuity will be at least <Continuity>
102 //! 3- the distance from the point <Points> to the
103 //! BSpline will be lower to Tol2D
104 Standard_EXPORT Geom2dAPI_PointsToBSpline(const TColgp_Array1OfPnt2d& Points, const TColStd_Array1OfReal& Parameters, const Standard_Integer DegMin = 3, const Standard_Integer DegMax = 8, const GeomAbs_Shape Continuity = GeomAbs_C2, const Standard_Real Tol2D = 1.0e-3);
105
106 //! Approximate a BSpline Curve passing through an
107 //! array of Point using variational smoothing algorithm,
108 //! which tries to minimize additional criterium:
109 //! Weight1*CurveLength + Weight2*Curvature + Weight3*Torsion
110 Standard_EXPORT Geom2dAPI_PointsToBSpline(const TColgp_Array1OfPnt2d& Points, const Standard_Real Weight1, const Standard_Real Weight2, const Standard_Real Weight3, const Standard_Integer DegMax = 8, const GeomAbs_Shape Continuity = GeomAbs_C2, const Standard_Real Tol3D = 1.0e-3);
111
112 //! Approximate a BSpline Curve passing through an
113 //! array of Point. The resulting BSpline will have
114 //! the following properties:
115 //! 1- his degree will be in the range [Degmin,Degmax]
116 //! 2- his continuity will be at least <Continuity>
117 //! 3- the distance from the point <Points> to the
118 //! BSpline will be lower to Tol2D
119 Standard_EXPORT void Init (const TColgp_Array1OfPnt2d& Points, const Standard_Integer DegMin = 3, const Standard_Integer DegMax = 8, const GeomAbs_Shape Continuity = GeomAbs_C2, const Standard_Real Tol2D = 1.0e-6);
120
121 //! Approximate a BSpline Curve passing through an
122 //! array of Point. Of coordinates :
123 //!
124 //! X = X0 + DX * (i-YValues.Lower())
125 //! Y = YValues(i)
126 //!
127 //! With i in the range YValues.Lower(), YValues.Upper()
128 //!
129 //! The BSpline will be parametrized from t = X0 to
130 //! X0 + DX * (YValues.Upper() - YValues.Lower())
131 //!
132 //! And will satisfy X(t) = t
133 //!
134 //! The resulting BSpline will have
135 //! the following properties:
136 //! 1- his degree will be in the range [Degmin,Degmax]
137 //! 2- his continuity will be at least <Continuity>
138 //! 3- the distance from the point <Points> to the
139 //! BSpline will be lower to Tol2D
140 Standard_EXPORT void Init (const TColStd_Array1OfReal& YValues, const Standard_Real X0, const Standard_Real DX, const Standard_Integer DegMin = 3, const Standard_Integer DegMax = 8, const GeomAbs_Shape Continuity = GeomAbs_C2, const Standard_Real Tol2D = 1.0e-6);
141
142 //! Approximate a BSpline Curve passing through an
143 //! array of Point. The resulting BSpline will have
144 //! the following properties:
145 //! 1- his degree will be in the range [Degmin,Degmax]
146 //! 2- his continuity will be at least <Continuity>
147 //! 3- the distance from the point <Points> to the
148 //! BSpline will be lower to Tol2D
149 Standard_EXPORT void Init (const TColgp_Array1OfPnt2d& Points, const Approx_ParametrizationType ParType, const Standard_Integer DegMin = 3, const Standard_Integer DegMax = 8, const GeomAbs_Shape Continuity = GeomAbs_C2, const Standard_Real Tol2D = 1.0e-3);
150
151 //! Approximate a BSpline Curve passing through an
152 //! array of Point, which parameters are given by the
153 //! array <Parameters>.
154 //! The resulting BSpline will have the following
155 //! properties:
156 //! 1- his degree will be in the range [Degmin,Degmax]
157 //! 2- his continuity will be at least <Continuity>
158 //! 3- the distance from the point <Points> to the
159 //! BSpline will be lower to Tol2D
160 Standard_EXPORT void Init (const TColgp_Array1OfPnt2d& Points, const TColStd_Array1OfReal& Parameters, const Standard_Integer DegMin = 3, const Standard_Integer DegMax = 8, const GeomAbs_Shape Continuity = GeomAbs_C2, const Standard_Real Tol2D = 1.0e-3);
161
162 //! Approximate a BSpline Curve passing through an
163 //! array of Point using variational smoothing algorithm,
164 //! which tries to minimize additional criterium:
165 //! Weight1*CurveLength + Weight2*Curvature + Weight3*Torsion
166 Standard_EXPORT void Init (const TColgp_Array1OfPnt2d& Points, const Standard_Real Weight1, const Standard_Real Weight2, const Standard_Real Weight3, const Standard_Integer DegMax = 8, const GeomAbs_Shape Continuity = GeomAbs_C2, const Standard_Real Tol2D = 1.0e-3);
167
168 //! Returns the approximate BSpline Curve
169 Standard_EXPORT const Handle(Geom2d_BSplineCurve)& Curve() const;
170Standard_EXPORT operator Handle(Geom2d_BSplineCurve)() const;
171
172 Standard_EXPORT Standard_Boolean IsDone() const;
173
174
175
176
177protected:
178
179
180
181
182
183private:
184
185
186
187 Standard_Boolean myIsDone;
188 Handle(Geom2d_BSplineCurve) myCurve;
189
190
191};
192
193
194
195
196
197
198
199#endif // _Geom2dAPI_PointsToBSpline_HeaderFile