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 <Standard_Boolean.hxx>
25 #include <TColgp_Array2OfPnt.hxx>
26 #include <Standard_Integer.hxx>
27 #include <GeomAbs_Shape.hxx>
28 #include <Standard_Real.hxx>
29 #include <Approx_ParametrizationType.hxx>
30 #include <TColStd_Array2OfReal.hxx>
31 class Geom_BSplineSurface;
32 class StdFail_NotDone;
35 //! This class is used to approximate or interpolate
36 //! a BSplineSurface passing through an Array2 of
37 //! points, with a given continuity.
38 //! Describes functions for building a BSpline
39 //! surface which approximates or interpolates a set of points.
40 //! A PointsToBSplineSurface object provides a framework for:
41 //! - defining the data of the BSpline surface to be built,
42 //! - implementing the approximation algorithm
43 //! or the interpolation algorithm, and consulting the results.
44 //! In fact, class contains 3 algorithms, 2 for approximation and 1
45 //! for interpolation.
46 //! First approximation algorithm is based on usual least square criterium:
47 //! minimization of square distance between samplimg points and result surface.
48 //! Second approximation algorithm uses least square criterium and additional
49 //! minimization of some local characteristic of surface (first, second and third
50 //! partial derivative), which allows managing shape of surface.
51 //! Interpolation algorithm produces surface, which passes through sampling points.
53 //! There is accordance between parametrization of result surface S(U, V) and
54 //! indexes of array Points(i, j): first index corresponds U parameter of surface,
55 //! second - V parameter of surface.
56 //! So, points of any j-th column Points(*, j) represent any V isoline of surface,
57 //! points of any i-th row Point(i, *) represent any U isoline of surface.
59 //! For each sampling point parameters U, V are calculated according to
60 //! type of parametrization, which can be Approx_ChordLength, Approx_Centripetal
61 //! or Approx_IsoParametric. Default value is Approx_ChordLength.
62 //! For ChordLength parametrisation U(i) = U(i-1) + P(i).Distance(P(i-1)),
63 //! For Centripetal type U(i) = U(i-1) + Sqrt(P(i).Distance(P(i-1))).
64 //! Centripetal type can get better result for irregular distances between points.
66 //! Approximation and interpolation algorithms can build periodical surface along U
67 //! direction, which corresponds colums of array Points(i, j),
68 //! if corresponding parameter (thePeriodic, see comments below) of called
69 //! methods is set to True. Algorithm uses first row Points(1, *) as periodic boundary,
70 //! so to avoid getting wrong surface it is necessary to keep distance between
71 //! corresponding points of first and last rows of Points:
72 //! Points(1, *) != Points(Upper, *).
74 class GeomAPI_PointsToBSplineSurface
81 //! Constructs an empty algorithm for
82 //! approximation or interpolation of a surface.
84 //! - an Init function to define and build the
85 //! BSpline surface by approximation, or
86 //! - an Interpolate function to define and build
87 //! the BSpline surface by interpolation.
88 Standard_EXPORT GeomAPI_PointsToBSplineSurface();
90 //! Approximates a BSpline Surface passing through an
91 //! array of Points. The resulting BSpline will have
92 //! the following properties:
93 //! 1- his degree will be in the range [Degmin,Degmax]
94 //! 2- his continuity will be at least <Continuity>
95 //! 3- the distance from the point <Points> to the
96 //! BSpline will be lower to Tol3D.
98 Standard_EXPORT GeomAPI_PointsToBSplineSurface(const TColgp_Array2OfPnt& Points,
99 const Standard_Integer DegMin = 3, const Standard_Integer DegMax = 8,
100 const GeomAbs_Shape Continuity = GeomAbs_C2, const Standard_Real Tol3D = 1.0e-3);
102 //! Approximates a BSpline Surface passing through an
103 //! array of Points. The resulting BSpline will have
104 //! the following properties:
105 //! 1- his degree will be in the range [Degmin,Degmax]
106 //! 2- his continuity will be at least <Continuity>
107 //! 3- the distance from the point <Points> to the
108 //! BSpline will be lower to Tol3D.
110 Standard_EXPORT GeomAPI_PointsToBSplineSurface(const TColgp_Array2OfPnt& Points,
111 const Approx_ParametrizationType ParType,
112 const Standard_Integer DegMin = 3, const Standard_Integer DegMax = 8,
113 const GeomAbs_Shape Continuity = GeomAbs_C2, const Standard_Real Tol3D = 1.0e-3);
115 //! Approximates a BSpline Surface passing through an
116 //! array of points using variational smoothing algorithm,
117 //! which tries to minimize additional criterium:
118 //! Weight1*CurveLength + Weight2*Curvature + Weight3*Torsion.
120 Standard_EXPORT GeomAPI_PointsToBSplineSurface(const TColgp_Array2OfPnt& Points,
121 const Standard_Real Weight1, const Standard_Real Weight2, const Standard_Real Weight3,
122 const Standard_Integer DegMax = 8, const GeomAbs_Shape Continuity = GeomAbs_C2,
123 const Standard_Real Tol3D = 1.0e-3);
125 //! Approximates a BSpline Surface passing through an
128 //! The points will be constructed as follow:
129 //! P(i,j) = gp_Pnt( X0 + (i-1)*dX ,
133 //! The resulting BSpline will have the following
135 //! 1- his degree will be in the range [Degmin,Degmax]
136 //! 2- his continuity will be at least <Continuity>
137 //! 3- the distance from the point <Points> to the
138 //! BSpline will be lower to Tol3D
139 //! 4- the parametrization of the surface will verify:
140 //! S->Value( U, V) = gp_Pnt( U, V, Z(U,V) );
142 Standard_EXPORT GeomAPI_PointsToBSplineSurface(const TColStd_Array2OfReal& ZPoints,
143 const Standard_Real X0, const Standard_Real dX,
144 const Standard_Real Y0, const Standard_Real dY,
145 const Standard_Integer DegMin = 3, const Standard_Integer DegMax = 8,
146 const GeomAbs_Shape Continuity = GeomAbs_C2, const Standard_Real Tol3D = 1.0e-3);
148 //! Approximates a BSpline Surface passing through an
149 //! array of Point. The resulting BSpline will have
150 //! the following properties:
151 //! 1- his degree will be in the range [Degmin,Degmax]
152 //! 2- his continuity will be at least <Continuity>
153 //! 3- the distance from the point <Points> to the
154 //! BSpline will be lower to Tol3D.
156 Standard_EXPORT void Init (const TColgp_Array2OfPnt& Points,
157 const Standard_Integer DegMin = 3, const Standard_Integer DegMax = 8,
158 const GeomAbs_Shape Continuity = GeomAbs_C2, const Standard_Real Tol3D = 1.0e-3);
160 //! Interpolates a BSpline Surface passing through an
161 //! array of Point. The resulting BSpline will have
162 //! the following properties:
163 //! 1- his degree will be 3.
164 //! 2- his continuity will be C2.
166 Standard_EXPORT void Interpolate (const TColgp_Array2OfPnt& Points,
167 const Standard_Boolean thePeriodic = Standard_False);
169 //! Interpolates a BSpline Surface passing through an
170 //! array of Point. The resulting BSpline will have
171 //! the following properties:
172 //! 1- his degree will be 3.
173 //! 2- his continuity will be C2.
175 Standard_EXPORT void Interpolate (const TColgp_Array2OfPnt& Points, const Approx_ParametrizationType ParType,
176 const Standard_Boolean thePeriodic = Standard_False);
178 //! Approximates a BSpline Surface passing through an
181 //! The points will be constructed as follow:
182 //! P(i,j) = gp_Pnt( X0 + (i-1)*dX ,
186 //! The resulting BSpline will have the following
188 //! 1- his degree will be in the range [Degmin,Degmax]
189 //! 2- his continuity will be at least <Continuity>
190 //! 3- the distance from the point <Points> to the
191 //! BSpline will be lower to Tol3D
192 //! 4- the parametrization of the surface will verify:
193 //! S->Value( U, V) = gp_Pnt( U, V, Z(U,V) );
195 Standard_EXPORT void Init (const TColStd_Array2OfReal& ZPoints,
196 const Standard_Real X0, const Standard_Real dX,
197 const Standard_Real Y0, const Standard_Real dY,
198 const Standard_Integer DegMin = 3, const Standard_Integer DegMax = 8,
199 const GeomAbs_Shape Continuity = GeomAbs_C2, const Standard_Real Tol3D = 1.0e-3);
201 //! Interpolates a BSpline Surface passing through an
204 //! The points will be constructed as follow:
205 //! P(i,j) = gp_Pnt( X0 + (i-1)*dX ,
209 //! The resulting BSpline will have the following
211 //! 1- his degree will be 3
212 //! 2- his continuity will be C2.
213 //! 4- the parametrization of the surface will verify:
214 //! S->Value( U, V) = gp_Pnt( U, V, Z(U,V) );
216 Standard_EXPORT void Interpolate (const TColStd_Array2OfReal& ZPoints,
217 const Standard_Real X0, const Standard_Real dX, const Standard_Real Y0, const Standard_Real dY);
219 //! Approximates a BSpline Surface passing through an
220 //! array of Point. The resulting BSpline will have
221 //! the following properties:
222 //! 1- his degree will be in the range [Degmin,Degmax]
223 //! 2- his continuity will be at least <Continuity>
224 //! 3- the distance from the point <Points> to the
225 //! BSpline will be lower to Tol3D.
227 Standard_EXPORT void Init (const TColgp_Array2OfPnt& Points,
228 const Approx_ParametrizationType ParType,
229 const Standard_Integer DegMin = 3, const Standard_Integer DegMax = 8,
230 const GeomAbs_Shape Continuity = GeomAbs_C2,
231 const Standard_Real Tol3D = 1.0e-3, const Standard_Boolean thePeriodic = Standard_False);
233 //! Approximates a BSpline Surface passing through an
234 //! array of point using variational smoothing algorithm,
235 //! which tries to minimize additional criterium:
236 //! Weight1*CurveLength + Weight2*Curvature + Weight3*Torsion.
238 Standard_EXPORT void Init (const TColgp_Array2OfPnt& Points,
239 const Standard_Real Weight1, const Standard_Real Weight2, const Standard_Real Weight3,
240 const Standard_Integer DegMax = 8,
241 const GeomAbs_Shape Continuity = GeomAbs_C2, const Standard_Real Tol3D = 1.0e-3);
243 //! Returns the approximate BSpline Surface
244 Standard_EXPORT const Handle(Geom_BSplineSurface)& Surface() const;
245 Standard_EXPORT operator Handle(Geom_BSplineSurface)() const;
247 Standard_EXPORT Standard_Boolean IsDone() const;
262 Standard_Boolean myIsDone;
263 Handle(Geom_BSplineSurface) mySurface;
274 #endif // _GeomAPI_PointsToBSplineSurface_HeaderFile