Warnings on vc14 were eliminated
[occt.git] / src / GeomAPI / GeomAPI_Interpolate.hxx
1 // Created on: 1994-08-18
2 // Created by: Laurent PAINNOT
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 _GeomAPI_Interpolate_HeaderFile
18 #define _GeomAPI_Interpolate_HeaderFile
19
20 #include <Standard.hxx>
21 #include <Standard_DefineAlloc.hxx>
22 #include <Standard_Handle.hxx>
23
24 #include <Standard_Real.hxx>
25 #include <TColgp_HArray1OfPnt.hxx>
26 #include <Standard_Boolean.hxx>
27 #include <TColgp_HArray1OfVec.hxx>
28 #include <TColStd_HArray1OfBoolean.hxx>
29 #include <TColStd_HArray1OfReal.hxx>
30 #include <TColgp_Array1OfVec.hxx>
31 #include <Geom_BSplineCurve.hxx>
32
33 class gp_Vec;
34
35
36 //! This  class  is  used  to  interpolate a  BsplineCurve
37 //! passing   through  an  array  of  points,  with  a  C2
38 //! Continuity if tangency is not requested at the point.
39 //! If tangency is requested at the point the continuity will
40 //! be C1.  If Perodicity is requested the curve will be closed
41 //! and the junction will be the first point given. The curve
42 //! will than be only C1
43 //! Describes functions for building a constrained 3D BSpline curve.
44 //! The curve is defined by a table of points
45 //! through which it passes, and if required:
46 //! -   by a parallel table of reals which gives the
47 //! value of the parameter of each point through
48 //! which the resulting BSpline curve passes, and
49 //! -   by vectors tangential to these points.
50 //! An Interpolate object provides a framework for:
51 //! -   defining the constraints of the BSpline curve,
52 //! -   implementing the interpolation algorithm, and
53 //! -   consulting the results.
54 class GeomAPI_Interpolate 
55 {
56 public:
57
58   DEFINE_STANDARD_ALLOC
59
60   
61   //! Initializes an algorithm for constructing a
62   //! constrained BSpline curve passing through the points of the table   Points.
63   //! Tangential vectors can then be assigned, using the function Load.
64   //! If PeriodicFlag is true, the constrained BSpline
65   //! curve will be periodic and closed. In this case,
66   //! the junction point is the first point of the table Points.
67   //! The tolerance value Tolerance is used to check that:
68   //! -   points are not too close to each other, or
69   //! -   tangential vectors (defined using the
70   //! function Load) are not too small.
71   //! The resulting BSpline curve will be "C2"
72   //! continuous, except where a tangency
73   //! constraint is defined on a point through which
74   //! the curve passes (by using the Load function).
75   //! In this case, it will be only "C1" continuous.
76   //! Once all the constraints are defined, use the
77   //! function Perform to compute the curve.
78   //! Warning
79   //! -   There must be at least 2 points in the table Points.
80   //! -   If PeriodicFlag is false, there must be as
81   //! many parameters in the array Parameters as
82   //! there are points in the array Points.
83   //! -   If PeriodicFlag is true, there must be one
84   //! more parameter in the table Parameters: this
85   //! is used to give the parameter on the
86   //! resulting BSpline curve of the junction point
87   //! of the curve (which is also the first point of the table Points).
88   //! Exceptions
89   //! -   Standard_ConstructionError if the
90   //! distance between two consecutive points in
91   //! the table Points is less than or equal to Tolerance.
92   //! -   Standard_OutOfRange if:
93   //! -   there are less than two points in the table Points, or
94   //! -   conditions relating to the respective
95   //! number of elements in the parallel tables
96   //! Points and Parameters are not respected.
97   Standard_EXPORT GeomAPI_Interpolate(const Handle(TColgp_HArray1OfPnt)& Points, const Standard_Boolean PeriodicFlag, const Standard_Real Tolerance);
98   
99   //! Initializes an algorithm for constructing a
100   //! constrained BSpline curve passing through the points of the table
101   //! Points, where the parameters of each of its
102   //! points are given by the parallel table Parameters.
103   //! Tangential vectors can then be assigned, using the function Load.
104   //! If PeriodicFlag is true, the constrained BSpline
105   //! curve will be periodic and closed. In this case,
106   //! the junction point is the first point of the table Points.
107   //! The tolerance value Tolerance is used to check that:
108   //! -   points are not too close to each other, or
109   //! -   tangential vectors (defined using the
110   //! function Load) are not too small.
111   //! The resulting BSpline curve will be "C2"
112   //! continuous, except where a tangency
113   //! constraint is defined on a point through which
114   //! the curve passes (by using the Load function).
115   //! In this case, it will be only "C1" continuous.
116   //! Once all the constraints are defined, use the
117   //! function Perform to compute the curve.
118   //! Warning
119   //! -   There must be at least 2 points in the table Points.
120   //! -   If PeriodicFlag is false, there must be as
121   //! many parameters in the array Parameters as
122   //! there are points in the array Points.
123   //! -   If PeriodicFlag is true, there must be one
124   //! more parameter in the table Parameters: this
125   //! is used to give the parameter on the
126   //! resulting BSpline curve of the junction point
127   //! of the curve (which is also the first point of the table Points).
128   //! Exceptions
129   //! -   Standard_ConstructionError if the
130   //! distance between two consecutive points in
131   //! the table Points is less than or equal to Tolerance.
132   //! -   Standard_OutOfRange if:
133   //! -   there are less than two points in the table Points, or
134   //! -   conditions relating to the respective
135   //! number of elements in the parallel tables
136   //! Points and Parameters are not respected.
137   Standard_EXPORT GeomAPI_Interpolate(const Handle(TColgp_HArray1OfPnt)& Points, const Handle(TColStd_HArray1OfReal)& Parameters, const Standard_Boolean PeriodicFlag, const Standard_Real Tolerance);
138   
139   //! Assigns this constrained BSpline curve to be
140   //! tangential to vectors InitialTangent and FinalTangent
141   //! at its first and last points respectively (i.e.
142   //! the first and last points of the table of
143   //! points through which the curve passes, as
144   //! defined at the time of initialization).
145   Standard_EXPORT void Load (const gp_Vec& InitialTangent, const gp_Vec& FinalTangent, const Standard_Boolean Scale = Standard_True);
146   
147   //! Assigns this constrained BSpline curve to be
148   //! tangential to vectors defined in the table Tangents,
149   //! which is parallel to the table of points
150   //! through which the curve passes, as
151   //! defined at the time of initialization. Vectors
152   //! in the table Tangents are defined only if
153   //! the flag given in the parallel table
154   //! TangentFlags is true: only these vectors
155   //! are set as tangency constraints.
156   Standard_EXPORT void Load (const TColgp_Array1OfVec& Tangents, const Handle(TColStd_HArray1OfBoolean)& TangentFlags, const Standard_Boolean Scale = Standard_True);
157   
158   //! Clears all tangency constraints on this
159   //! constrained BSpline curve (as initialized by the function Load).
160   Standard_EXPORT void ClearTangents();
161   
162   //! Computes the constrained BSpline curve.
163   //! Use the function IsDone to verify that the
164   //! computation is successful, and then the function Curve to obtain the result.
165   Standard_EXPORT void Perform();
166   
167   //! Returns the computed BSpline curve.
168   //! Raises StdFail_NotDone if the interpolation fails.
169   Standard_EXPORT const Handle(Geom_BSplineCurve)& Curve() const;
170 Standard_EXPORT operator Handle(Geom_BSplineCurve)() const;
171   
172   //! Returns true if the constrained BSpline curve is successfully constructed.
173   //! Note: in this case, the result is given by the function Curve.
174   Standard_EXPORT Standard_Boolean IsDone() const;
175
176
177
178
179 protected:
180
181
182
183
184
185 private:
186
187   
188   //! Interpolates in a non periodic fashion
189   Standard_EXPORT void PerformNonPeriodic();
190   
191   //! Interpolates in a C1 periodic fashion
192   Standard_EXPORT void PerformPeriodic();
193
194
195   Standard_Real myTolerance;
196   Handle(TColgp_HArray1OfPnt) myPoints;
197   Standard_Boolean myIsDone;
198   Handle(Geom_BSplineCurve) myCurve;
199   Handle(TColgp_HArray1OfVec) myTangents;
200   Handle(TColStd_HArray1OfBoolean) myTangentFlags;
201   Handle(TColStd_HArray1OfReal) myParameters;
202   Standard_Boolean myPeriodic;
203   Standard_Boolean myTangentRequest;
204
205
206 };
207
208
209
210
211
212
213
214 #endif // _GeomAPI_Interpolate_HeaderFile