1 // Created on: 1995-01-16
2 // Created by: Remi LEQUETTE
3 // Copyright (c) 1995-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 _GeomAPI_PointsToBSplineSurface_HeaderFile
18 #define _GeomAPI_PointsToBSplineSurface_HeaderFile
20 #include <Standard.hxx>
21 #include <Standard_DefineAlloc.hxx>
22 #include <Standard_Handle.hxx>
24 #include <TColgp_Array2OfPnt.hxx>
25 #include <Standard_Integer.hxx>
26 #include <GeomAbs_Shape.hxx>
27 #include <Approx_ParametrizationType.hxx>
28 #include <TColStd_Array2OfReal.hxx>
29 class Geom_BSplineSurface;
32 //! This class is used to approximate or interpolate
33 //! a BSplineSurface passing through an Array2 of
34 //! points, with a given continuity.
35 //! Describes functions for building a BSpline
36 //! surface which approximates or interpolates a set of points.
37 //! A PointsToBSplineSurface object provides a framework for:
38 //! - defining the data of the BSpline surface to be built,
39 //! - implementing the approximation algorithm
40 //! or the interpolation algorithm, and consulting the results.
41 //! In fact, class contains 3 algorithms, 2 for approximation and 1
42 //! for interpolation.
43 //! First approximation algorithm is based on usual least square criterium:
44 //! minimization of square distance between samplimg points and result surface.
45 //! Second approximation algorithm uses least square criterium and additional
46 //! minimization of some local characteristic of surface (first, second and third
47 //! partial derivative), which allows managing shape of surface.
48 //! Interpolation algorithm produces surface, which passes through sampling points.
50 //! There is accordance between parametrization of result surface S(U, V) and
51 //! indexes of array Points(i, j): first index corresponds U parameter of surface,
52 //! second - V parameter of surface.
53 //! So, points of any j-th column Points(*, j) represent any V isoline of surface,
54 //! points of any i-th row Point(i, *) represent any U isoline of surface.
56 //! For each sampling point parameters U, V are calculated according to
57 //! type of parametrization, which can be Approx_ChordLength, Approx_Centripetal
58 //! or Approx_IsoParametric. Default value is Approx_ChordLength.
59 //! For ChordLength parametrisation U(i) = U(i-1) + P(i).Distance(P(i-1)),
60 //! For Centripetal type U(i) = U(i-1) + Sqrt(P(i).Distance(P(i-1))).
61 //! Centripetal type can get better result for irregular distances between points.
63 //! Approximation and interpolation algorithms can build periodical surface along U
64 //! direction, which corresponds columns of array Points(i, j),
65 //! if corresponding parameter (thePeriodic, see comments below) of called
66 //! methods is set to True. Algorithm uses first row Points(1, *) as periodic boundary,
67 //! so to avoid getting wrong surface it is necessary to keep distance between
68 //! corresponding points of first and last rows of Points:
69 //! Points(1, *) != Points(Upper, *).
71 class GeomAPI_PointsToBSplineSurface
78 //! Constructs an empty algorithm for
79 //! approximation or interpolation of a surface.
81 //! - an Init function to define and build the
82 //! BSpline surface by approximation, or
83 //! - an Interpolate function to define and build
84 //! the BSpline surface by interpolation.
85 Standard_EXPORT GeomAPI_PointsToBSplineSurface();
87 //! Approximates a BSpline Surface passing through an
88 //! array of Points. The resulting BSpline will have
89 //! the following properties:
90 //! 1- his degree will be in the range [Degmin,Degmax]
91 //! 2- his continuity will be at least <Continuity>
92 //! 3- the distance from the point <Points> to the
93 //! BSpline will be lower to Tol3D.
95 Standard_EXPORT GeomAPI_PointsToBSplineSurface(const TColgp_Array2OfPnt& Points,
96 const Standard_Integer DegMin = 3, const Standard_Integer DegMax = 8,
97 const GeomAbs_Shape Continuity = GeomAbs_C2, const Standard_Real Tol3D = 1.0e-3);
99 //! Approximates a BSpline Surface passing through an
100 //! array of Points. The resulting BSpline will have
101 //! the following properties:
102 //! 1- his degree will be in the range [Degmin,Degmax]
103 //! 2- his continuity will be at least <Continuity>
104 //! 3- the distance from the point <Points> to the
105 //! BSpline will be lower to Tol3D.
107 Standard_EXPORT GeomAPI_PointsToBSplineSurface(const TColgp_Array2OfPnt& Points,
108 const Approx_ParametrizationType ParType,
109 const Standard_Integer DegMin = 3, const Standard_Integer DegMax = 8,
110 const GeomAbs_Shape Continuity = GeomAbs_C2, const Standard_Real Tol3D = 1.0e-3);
112 //! Approximates a BSpline Surface passing through an
113 //! array of points using variational smoothing algorithm,
114 //! which tries to minimize additional criterium:
115 //! Weight1*CurveLength + Weight2*Curvature + Weight3*Torsion.
117 Standard_EXPORT GeomAPI_PointsToBSplineSurface(const TColgp_Array2OfPnt& Points,
118 const Standard_Real Weight1, const Standard_Real Weight2, const Standard_Real Weight3,
119 const Standard_Integer DegMax = 8, const GeomAbs_Shape Continuity = GeomAbs_C2,
120 const Standard_Real Tol3D = 1.0e-3);
122 //! Approximates a BSpline Surface passing through an
125 //! The points will be constructed as follow:
126 //! P(i,j) = gp_Pnt( X0 + (i-1)*dX ,
130 //! The resulting BSpline will have the following
132 //! 1- his degree will be in the range [Degmin,Degmax]
133 //! 2- his continuity will be at least <Continuity>
134 //! 3- the distance from the point <Points> to the
135 //! BSpline will be lower to Tol3D
136 //! 4- the parametrization of the surface will verify:
137 //! S->Value( U, V) = gp_Pnt( U, V, Z(U,V) );
139 Standard_EXPORT GeomAPI_PointsToBSplineSurface(const TColStd_Array2OfReal& ZPoints,
140 const Standard_Real X0, const Standard_Real dX,
141 const Standard_Real Y0, const Standard_Real dY,
142 const Standard_Integer DegMin = 3, const Standard_Integer DegMax = 8,
143 const GeomAbs_Shape Continuity = GeomAbs_C2, const Standard_Real Tol3D = 1.0e-3);
145 //! Approximates a BSpline Surface passing through an
146 //! array of Point. The resulting BSpline will have
147 //! the following properties:
148 //! 1- his degree will be in the range [Degmin,Degmax]
149 //! 2- his continuity will be at least <Continuity>
150 //! 3- the distance from the point <Points> to the
151 //! BSpline will be lower to Tol3D.
153 Standard_EXPORT void Init (const TColgp_Array2OfPnt& Points,
154 const Standard_Integer DegMin = 3, const Standard_Integer DegMax = 8,
155 const GeomAbs_Shape Continuity = GeomAbs_C2, const Standard_Real Tol3D = 1.0e-3);
157 //! Interpolates a BSpline Surface passing through an
158 //! array of Point. The resulting BSpline will have
159 //! the following properties:
160 //! 1- his degree will be 3.
161 //! 2- his continuity will be C2.
163 Standard_EXPORT void Interpolate (const TColgp_Array2OfPnt& Points,
164 const Standard_Boolean thePeriodic = Standard_False);
166 //! Interpolates a BSpline Surface passing through an
167 //! array of Point. The resulting BSpline will have
168 //! the following properties:
169 //! 1- his degree will be 3.
170 //! 2- his continuity will be C2.
172 Standard_EXPORT void Interpolate (const TColgp_Array2OfPnt& Points, const Approx_ParametrizationType ParType,
173 const Standard_Boolean thePeriodic = Standard_False);
175 //! Approximates a BSpline Surface passing through an
178 //! The points will be constructed as follow:
179 //! P(i,j) = gp_Pnt( X0 + (i-1)*dX ,
183 //! The resulting BSpline will have the following
185 //! 1- his degree will be in the range [Degmin,Degmax]
186 //! 2- his continuity will be at least <Continuity>
187 //! 3- the distance from the point <Points> to the
188 //! BSpline will be lower to Tol3D
189 //! 4- the parametrization of the surface will verify:
190 //! S->Value( U, V) = gp_Pnt( U, V, Z(U,V) );
192 Standard_EXPORT void Init (const TColStd_Array2OfReal& ZPoints,
193 const Standard_Real X0, const Standard_Real dX,
194 const Standard_Real Y0, const Standard_Real dY,
195 const Standard_Integer DegMin = 3, const Standard_Integer DegMax = 8,
196 const GeomAbs_Shape Continuity = GeomAbs_C2, const Standard_Real Tol3D = 1.0e-3);
198 //! Interpolates a BSpline Surface passing through an
201 //! The points will be constructed as follow:
202 //! P(i,j) = gp_Pnt( X0 + (i-1)*dX ,
206 //! The resulting BSpline will have the following
208 //! 1- his degree will be 3
209 //! 2- his continuity will be C2.
210 //! 4- the parametrization of the surface will verify:
211 //! S->Value( U, V) = gp_Pnt( U, V, Z(U,V) );
213 Standard_EXPORT void Interpolate (const TColStd_Array2OfReal& ZPoints,
214 const Standard_Real X0, const Standard_Real dX, const Standard_Real Y0, const Standard_Real dY);
216 //! Approximates a BSpline Surface passing through an
217 //! array of Point. The resulting BSpline will have
218 //! the following properties:
219 //! 1- his degree will be in the range [Degmin,Degmax]
220 //! 2- his continuity will be at least <Continuity>
221 //! 3- the distance from the point <Points> to the
222 //! BSpline will be lower to Tol3D.
224 Standard_EXPORT void Init (const TColgp_Array2OfPnt& Points,
225 const Approx_ParametrizationType ParType,
226 const Standard_Integer DegMin = 3, const Standard_Integer DegMax = 8,
227 const GeomAbs_Shape Continuity = GeomAbs_C2,
228 const Standard_Real Tol3D = 1.0e-3, const Standard_Boolean thePeriodic = Standard_False);
230 //! Approximates a BSpline Surface passing through an
231 //! array of point using variational smoothing algorithm,
232 //! which tries to minimize additional criterium:
233 //! Weight1*CurveLength + Weight2*Curvature + Weight3*Torsion.
235 Standard_EXPORT void Init (const TColgp_Array2OfPnt& Points,
236 const Standard_Real Weight1, const Standard_Real Weight2, const Standard_Real Weight3,
237 const Standard_Integer DegMax = 8,
238 const GeomAbs_Shape Continuity = GeomAbs_C2, const Standard_Real Tol3D = 1.0e-3);
240 //! Returns the approximate BSpline Surface
241 Standard_EXPORT const Handle(Geom_BSplineSurface)& Surface() const;
242 Standard_EXPORT operator Handle(Geom_BSplineSurface)() const;
244 Standard_EXPORT Standard_Boolean IsDone() const;
259 Standard_Boolean myIsDone;
260 Handle(Geom_BSplineSurface) mySurface;
271 #endif // _GeomAPI_PointsToBSplineSurface_HeaderFile