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
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_Interpolate_HeaderFile
18 #define _Geom2dAPI_Interpolate_HeaderFile
20 #include <Standard.hxx>
21 #include <Standard_DefineAlloc.hxx>
22 #include <Standard_Handle.hxx>
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;
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
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,
60 const Standard_Boolean PeriodicFlag,
61 const Standard_Real Tolerance);
63 //! if PeriodicFlag is True then the curve will be periodic
65 //! There should be as many parameters as there are points
66 //! except if PeriodicFlag is True : then there should be one more
67 //! parameter to close the curve
68 Standard_EXPORT Geom2dAPI_Interpolate(const Handle(TColgp_HArray1OfPnt2d)& Points,
69 const Handle(TColStd_HArray1OfReal)& Parameters,
70 const Standard_Boolean PeriodicFlag,
71 const Standard_Real Tolerance);
73 //! Assigns this constrained BSpline curve to be
74 //! tangential to vectors InitialTangent and FinalTangent
75 //! at its first and last points respectively (i.e.
76 //! the first and last points of the table of
77 //! points through which the curve passes, as
78 //! defined at the time of initialization).
79 //! <Scale> - boolean flag defining whether tangent vectors are to
80 //! be scaled according to derivatives of lagrange interpolation.
81 Standard_EXPORT void Load(const gp_Vec2d& InitialTangent,
82 const gp_Vec2d& FinalTangent,
83 const Standard_Boolean Scale = Standard_True);
85 //! Assigns this constrained BSpline curve to be
86 //! tangential to vectors defined in the table Tangents,
87 //! which is parallel to the table of points
88 //! through which the curve passes, as
89 //! defined at the time of initialization. Vectors
90 //! in the table Tangents are defined only if
91 //! the flag given in the parallel table
92 //! TangentFlags is true: only these vectors
93 //! are set as tangency constraints.
94 //! <Scale> - boolean flag defining whether tangent vectors are to
95 //! be scaled according to derivatives of lagrange interpolation.
96 Standard_EXPORT void Load(const TColgp_Array1OfVec2d& Tangents,
97 const Handle(TColStd_HArray1OfBoolean)& TangentFlags,
98 const Standard_Boolean Scale = Standard_True);
100 //! Clears all tangency constraints on this
101 //! constrained BSpline curve (as initialized by the function Load).
102 Standard_EXPORT void ClearTangents();
104 //! Computes the constrained BSpline curve. Use the function IsDone to verify that the
105 //! computation is successful, and then the function Curve to obtain the result.
106 Standard_EXPORT void Perform();
108 //! Returns the computed BSpline curve. Raises StdFail_NotDone if the interpolation fails.
109 Standard_EXPORT const Handle(Geom2d_BSplineCurve)& Curve() const;
110 Standard_EXPORT operator Handle(Geom2d_BSplineCurve)() const;
112 //! Returns true if the constrained BSpline curve is successfully constructed.
113 //! Note: in this case, the result is given by the function Curve.
114 Standard_EXPORT Standard_Boolean IsDone() const;
128 //! Interpolates in a non periodic fashion
129 Standard_EXPORT void PerformNonPeriodic();
131 //! Interpolates in a C1 periodic fashion
132 Standard_EXPORT void PerformPeriodic();
135 Standard_Real myTolerance;
136 Handle(TColgp_HArray1OfPnt2d) myPoints;
137 Standard_Boolean myIsDone;
138 Handle(Geom2d_BSplineCurve) myCurve;
139 Handle(TColgp_HArray1OfVec2d) myTangents;
140 Handle(TColStd_HArray1OfBoolean) myTangentFlags;
141 Handle(TColStd_HArray1OfReal) myParameters;
142 Standard_Boolean myPeriodic;
143 Standard_Boolean myTangentRequest;
154 #endif // _Geom2dAPI_Interpolate_HeaderFile