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;
35 //! This class is used to interpolate a BsplineCurve
36 //! passing through an array of points, with a C2
37 //! Continuity if tangency is not requested at the point.
38 //! If tangency is requested at the point the continuity will
39 //! be C1. If Perodicity is requested the curve will be closed
40 //! and the junction will be the first point given. The curve will than be only C1
41 //! The curve is defined by a table of points through which it passes, and if required
42 //! by a parallel table of reals which gives the value of the parameter of each point through
43 //! which the resulting BSpline curve passes, and by vectors tangential to these points.
44 //! An Interpolate object provides a framework for: defining the constraints of the BSpline curve,
45 //! - implementing the interpolation algorithm, and consulting the results.
46 class Geom2dAPI_Interpolate
53 //! Tolerance is to check if the points are not too close to one an other
54 //! It is also used to check if the tangent vector is not too small.
55 //! There should be at least 2 points
56 //! if PeriodicFlag is True then the curve will be periodic.
57 Standard_EXPORT Geom2dAPI_Interpolate(const Handle(TColgp_HArray1OfPnt2d)& Points,
58 const Standard_Boolean PeriodicFlag,
59 const Standard_Real Tolerance);
61 //! if PeriodicFlag is True then the curve will be periodic
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,
67 const Handle(TColStd_HArray1OfReal)& Parameters,
68 const Standard_Boolean PeriodicFlag,
69 const Standard_Real Tolerance);
71 //! Assigns this constrained BSpline curve to be
72 //! tangential to vectors InitialTangent and FinalTangent
73 //! at its first and last points respectively (i.e.
74 //! the first and last points of the table of
75 //! points through which the curve passes, as
76 //! defined at the time of initialization).
77 //! <Scale> - boolean flag defining whether tangent vectors are to
78 //! be scaled according to derivatives of lagrange interpolation.
79 Standard_EXPORT void Load(const gp_Vec2d& InitialTangent,
80 const gp_Vec2d& FinalTangent,
81 const Standard_Boolean Scale = Standard_True);
83 //! Assigns this constrained BSpline curve to be
84 //! tangential to vectors defined in the table Tangents,
85 //! which is parallel to the table of points
86 //! through which the curve passes, as
87 //! defined at the time of initialization. Vectors
88 //! in the table Tangents are defined only if
89 //! the flag given in the parallel table
90 //! TangentFlags is true: only these vectors
91 //! are set as tangency constraints.
92 //! <Scale> - boolean flag defining whether tangent vectors are to
93 //! be scaled according to derivatives of lagrange interpolation.
94 Standard_EXPORT void Load(const TColgp_Array1OfVec2d& Tangents,
95 const Handle(TColStd_HArray1OfBoolean)& TangentFlags,
96 const Standard_Boolean Scale = Standard_True);
98 //! Clears all tangency constraints on this
99 //! constrained BSpline curve (as initialized by the function Load).
100 Standard_EXPORT void ClearTangents();
102 //! Computes the constrained BSpline curve. Use the function IsDone to verify that the
103 //! computation is successful, and then the function Curve to obtain the result.
104 Standard_EXPORT void Perform();
106 //! Returns the computed BSpline curve. Raises StdFail_NotDone if the interpolation fails.
107 Standard_EXPORT const Handle(Geom2d_BSplineCurve)& Curve() const;
108 Standard_EXPORT operator Handle(Geom2d_BSplineCurve)() const;
110 //! Returns true if the constrained BSpline curve is successfully constructed.
111 //! Note: in this case, the result is given by the function Curve.
112 Standard_EXPORT Standard_Boolean IsDone() const;
126 //! Interpolates in a non periodic fashion
127 Standard_EXPORT void PerformNonPeriodic();
129 //! Interpolates in a C1 periodic fashion
130 Standard_EXPORT void PerformPeriodic();
133 Standard_Real myTolerance;
134 Handle(TColgp_HArray1OfPnt2d) myPoints;
135 Standard_Boolean myIsDone;
136 Handle(Geom2d_BSplineCurve) myCurve;
137 Handle(TColgp_HArray1OfVec2d) myTangents;
138 Handle(TColStd_HArray1OfBoolean) myTangentFlags;
139 Handle(TColStd_HArray1OfReal) myParameters;
140 Standard_Boolean myPeriodic;
141 Standard_Boolean myTangentRequest;
152 #endif // _Geom2dAPI_Interpolate_HeaderFile