0024002: Overall code and build procedure refactoring -- automatic
[occt.git] / src / Geom2dAPI / Geom2dAPI_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 _Geom2dAPI_Interpolate_HeaderFile
18 #define _Geom2dAPI_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_HArray1OfPnt2d.hxx>
26 #include <Standard_Boolean.hxx>
27 #include <TColgp_HArray1OfVec2d.hxx>
28 #include <TColStd_HArray1OfBoolean.hxx>
29 #include <TColStd_HArray1OfReal.hxx>
30 #include <TColgp_Array1OfVec2d.hxx>
31 class Geom2d_BSplineCurve;
32 class StdFail_NotDone;
33 class Standard_ConstructionError;
34 class gp_Vec2d;
35
36
37 //! This  class  is  used  to  interpolate a  BsplineCurve
38 //! passing   through  an  array  of  points,  with  a  C2
39 //! Continuity if tangency is not requested at the point.
40 //! If tangency is requested at the point the continuity will
41 //! be C1.  If Perodicity is requested the curve will be closed
42 //! and the junction will be the first point given. The curve will than be only C1
43 //! The curve is defined by a table of points through which it passes, and if required
44 //! by a parallel table of reals which gives the value of the parameter of each point through
45 //! which the resulting BSpline curve passes, and by vectors tangential to these points.
46 //! An Interpolate object provides a framework for: defining the constraints of the BSpline curve,
47 //! -   implementing the interpolation algorithm, and consulting the results.
48 class Geom2dAPI_Interpolate 
49 {
50 public:
51
52   DEFINE_STANDARD_ALLOC
53
54   
55   //! Tolerance is to check if the points are not too close to one an other
56   //! It is also used to check if the tangent vector is not too small.
57   //! There should be at least 2 points
58   //! if PeriodicFlag is True then the curve will be periodic.
59   Standard_EXPORT Geom2dAPI_Interpolate(const Handle(TColgp_HArray1OfPnt2d)& Points, const Standard_Boolean PeriodicFlag, const Standard_Real Tolerance);
60   
61   //! if PeriodicFlag is True then the curve will be periodic
62   //! Warning:
63   //! There should be as many parameters as there are points
64   //! except if PeriodicFlag is True : then there should be one more
65   //! parameter to close the curve
66   Standard_EXPORT Geom2dAPI_Interpolate(const Handle(TColgp_HArray1OfPnt2d)& Points, const Handle(TColStd_HArray1OfReal)& Parameters, const Standard_Boolean PeriodicFlag, const Standard_Real Tolerance);
67   
68   //! Assigns this constrained BSpline curve to be
69   //! tangential to vectors InitialTangent and FinalTangent
70   //! at its first and last points respectively (i.e.
71   //! the first and last points of the table of
72   //! points through which the curve passes, as
73   //! defined at the time of initialization).
74   Standard_EXPORT void Load (const gp_Vec2d& InitialTangent, const gp_Vec2d& FinalTangent);
75   
76   //! Assigns this constrained BSpline curve to be
77   //! tangential to vectors defined in the table Tangents,
78   //! which is parallel to the table of points
79   //! through which the curve passes, as
80   //! defined at the time of initialization. Vectors
81   //! in the table Tangents are defined only if
82   //! the flag given in the parallel table
83   //! TangentFlags is true: only these vectors
84   //! are set as tangency constraints.
85   Standard_EXPORT void Load (const TColgp_Array1OfVec2d& Tangents, const Handle(TColStd_HArray1OfBoolean)& TangentFlags);
86   
87   //! Clears all tangency constraints on this
88   //! constrained BSpline curve (as initialized by the function Load).
89   Standard_EXPORT void ClearTangents();
90   
91   //! Computes the constrained BSpline curve. Use the function IsDone to verify that the
92   //! computation is successful, and then the function Curve to obtain the result.
93   Standard_EXPORT void Perform();
94   
95   //! Returns the computed BSpline curve. Raises  StdFail_NotDone if the interpolation fails.
96   Standard_EXPORT const Handle(Geom2d_BSplineCurve)& Curve() const;
97 Standard_EXPORT operator Handle(Geom2d_BSplineCurve)() const;
98   
99   //! Returns true if the constrained BSpline curve is successfully constructed.
100   //! Note: in this case, the result is given by the function Curve.
101   Standard_EXPORT Standard_Boolean IsDone() const;
102
103
104
105
106 protected:
107
108
109
110
111
112 private:
113
114   
115   //! Interpolates in a non periodic fashion
116   Standard_EXPORT void PerformNonPeriodic();
117   
118   //! Interpolates in a C1 periodic fashion
119   Standard_EXPORT void PerformPeriodic();
120
121
122   Standard_Real myTolerance;
123   Handle(TColgp_HArray1OfPnt2d) myPoints;
124   Standard_Boolean myIsDone;
125   Handle(Geom2d_BSplineCurve) myCurve;
126   Handle(TColgp_HArray1OfVec2d) myTangents;
127   Handle(TColStd_HArray1OfBoolean) myTangentFlags;
128   Handle(TColStd_HArray1OfReal) myParameters;
129   Standard_Boolean myPeriodic;
130   Standard_Boolean myTangentRequest;
131
132
133 };
134
135
136
137
138
139
140
141 #endif // _Geom2dAPI_Interpolate_HeaderFile