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
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 _Geom2dAPI_PointsToBSpline_HeaderFile
18 #define _Geom2dAPI_PointsToBSpline_HeaderFile
20 #include <Standard.hxx>
21 #include <Standard_DefineAlloc.hxx>
22 #include <Standard_Handle.hxx>
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>
31 class Geom2d_BSplineCurve;
32 class StdFail_NotDone;
33 class Standard_OutOfRange;
36 //! This class is used to approximate a BsplineCurve
37 //! passing through an array of points, with a given
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
45 class Geom2dAPI_PointsToBSpline
52 //! Constructs an empty approximation algorithm.
53 //! Use an Init function to define and build the BSpline curve.
54 Standard_EXPORT Geom2dAPI_PointsToBSpline();
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);
65 //! Approximate a BSpline Curve passing through an
66 //! array of Point. Of coordinates :
68 //! X = X0 + DX * (i-YValues.Lower())
71 //! With i in the range YValues.Lower(), YValues.Upper()
73 //! The BSpline will be parametrized from t = X0 to
74 //! X0 + DX * (YValues.Upper() - YValues.Lower())
76 //! And will satisfy X(t) = t
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);
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);
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
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);
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);
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);
121 //! Approximate a BSpline Curve passing through an
122 //! array of Point. Of coordinates :
124 //! X = X0 + DX * (i-YValues.Lower())
127 //! With i in the range YValues.Lower(), YValues.Upper()
129 //! The BSpline will be parametrized from t = X0 to
130 //! X0 + DX * (YValues.Upper() - YValues.Lower())
132 //! And will satisfy X(t) = t
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);
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);
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
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);
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);
168 //! Returns the approximate BSpline Curve
169 Standard_EXPORT const Handle(Geom2d_BSplineCurve)& Curve() const;
170 Standard_EXPORT operator Handle(Geom2d_BSplineCurve)() const;
172 Standard_EXPORT Standard_Boolean IsDone() const;
187 Standard_Boolean myIsDone;
188 Handle(Geom2d_BSplineCurve) myCurve;
199 #endif // _Geom2dAPI_PointsToBSpline_HeaderFile