Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/opencascade/Geom2dAPI_Interpolate.hxx was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 // Created on: 1994-08-18
0002 // Created by: Laurent PAINNOT
0003 // Copyright (c) 1994-1999 Matra Datavision
0004 // Copyright (c) 1999-2014 OPEN CASCADE SAS
0005 //
0006 // This file is part of Open CASCADE Technology software library.
0007 //
0008 // This library is free software; you can redistribute it and/or modify it under
0009 // the terms of the GNU Lesser General Public License version 2.1 as published
0010 // by the Free Software Foundation, with special exception defined in the file
0011 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0012 // distribution for complete text of the license and disclaimer of any warranty.
0013 //
0014 // Alternatively, this file may be used under the terms of Open CASCADE
0015 // commercial license or contractual agreement.
0016 
0017 #ifndef _Geom2dAPI_Interpolate_HeaderFile
0018 #define _Geom2dAPI_Interpolate_HeaderFile
0019 
0020 #include <Standard.hxx>
0021 #include <Standard_DefineAlloc.hxx>
0022 #include <Standard_Handle.hxx>
0023 
0024 #include <TColgp_HArray1OfPnt2d.hxx>
0025 #include <TColgp_HArray1OfVec2d.hxx>
0026 #include <TColStd_HArray1OfBoolean.hxx>
0027 #include <TColStd_HArray1OfReal.hxx>
0028 #include <TColgp_Array1OfVec2d.hxx>
0029 class Geom2d_BSplineCurve;
0030 class gp_Vec2d;
0031 
0032 //! This  class  is  used  to  interpolate a  BsplineCurve
0033 //! passing   through  an  array  of  points,  with  a  C2
0034 //! Continuity if tangency is not requested at the point.
0035 //! If tangency is requested at the point the continuity will
0036 //! be C1.  If Perodicity is requested the curve will be closed
0037 //! and the junction will be the first point given. The curve will than be only C1
0038 //! The curve is defined by a table of points through which it passes, and if required
0039 //! by a parallel table of reals which gives the value of the parameter of each point through
0040 //! which the resulting BSpline curve passes, and by vectors tangential to these points.
0041 //! An Interpolate object provides a framework for: defining the constraints of the BSpline curve,
0042 //! -   implementing the interpolation algorithm, and consulting the results.
0043 class Geom2dAPI_Interpolate
0044 {
0045 public:
0046   DEFINE_STANDARD_ALLOC
0047 
0048   //! Tolerance is to check if the points are not too close to one an other
0049   //! It is also used to check if the tangent vector is not too small.
0050   //! There should be at least 2 points
0051   //! if PeriodicFlag is True then the curve will be periodic.
0052   Standard_EXPORT Geom2dAPI_Interpolate(const Handle(TColgp_HArray1OfPnt2d)& Points,
0053                                         const Standard_Boolean               PeriodicFlag,
0054                                         const Standard_Real                  Tolerance);
0055 
0056   //! if PeriodicFlag is True then the curve will be periodic
0057   //! Warning:
0058   //! There should be as many parameters as there are points
0059   //! except if PeriodicFlag is True : then there should be one more
0060   //! parameter to close the curve
0061   Standard_EXPORT Geom2dAPI_Interpolate(const Handle(TColgp_HArray1OfPnt2d)& Points,
0062                                         const Handle(TColStd_HArray1OfReal)& Parameters,
0063                                         const Standard_Boolean               PeriodicFlag,
0064                                         const Standard_Real                  Tolerance);
0065 
0066   //! Assigns this constrained BSpline curve to be
0067   //! tangential to vectors InitialTangent and FinalTangent
0068   //! at its first and last points respectively (i.e.
0069   //! the first and last points of the table of
0070   //! points through which the curve passes, as
0071   //! defined at the time of initialization).
0072   //! <Scale> - boolean flag defining whether tangent vectors are to
0073   //! be scaled according to derivatives of lagrange interpolation.
0074   Standard_EXPORT void Load(const gp_Vec2d&        InitialTangent,
0075                             const gp_Vec2d&        FinalTangent,
0076                             const Standard_Boolean Scale = Standard_True);
0077 
0078   //! Assigns this constrained BSpline curve to be
0079   //! tangential to vectors defined in the table Tangents,
0080   //! which is parallel to the table of points
0081   //! through which the curve passes, as
0082   //! defined at the time of initialization. Vectors
0083   //! in the table Tangents are defined only if
0084   //! the flag given in the parallel table
0085   //! TangentFlags is true: only these vectors
0086   //! are set as tangency constraints.
0087   //! <Scale> - boolean flag defining whether tangent vectors are to
0088   //! be scaled according to derivatives of lagrange interpolation.
0089   Standard_EXPORT void Load(const TColgp_Array1OfVec2d&             Tangents,
0090                             const Handle(TColStd_HArray1OfBoolean)& TangentFlags,
0091                             const Standard_Boolean                  Scale = Standard_True);
0092 
0093   //! Clears all tangency constraints on this
0094   //! constrained BSpline curve (as initialized by the function Load).
0095   Standard_EXPORT void ClearTangents();
0096 
0097   //! Computes the constrained BSpline curve. Use the function IsDone to verify that the
0098   //! computation is successful, and then the function Curve to obtain the result.
0099   Standard_EXPORT void Perform();
0100 
0101   //! Returns the computed BSpline curve. Raises  StdFail_NotDone if the interpolation fails.
0102   Standard_EXPORT const Handle(Geom2d_BSplineCurve)& Curve() const;
0103   Standard_EXPORT                                    operator Handle(Geom2d_BSplineCurve)() const;
0104 
0105   //! Returns true if the constrained BSpline curve is successfully constructed.
0106   //! Note: in this case, the result is given by the function Curve.
0107   Standard_EXPORT Standard_Boolean IsDone() const;
0108 
0109 protected:
0110 private:
0111   //! Interpolates in a non periodic fashion
0112   Standard_EXPORT void PerformNonPeriodic();
0113 
0114   //! Interpolates in a C1 periodic fashion
0115   Standard_EXPORT void PerformPeriodic();
0116 
0117   Standard_Real                    myTolerance;
0118   Handle(TColgp_HArray1OfPnt2d)    myPoints;
0119   Standard_Boolean                 myIsDone;
0120   Handle(Geom2d_BSplineCurve)      myCurve;
0121   Handle(TColgp_HArray1OfVec2d)    myTangents;
0122   Handle(TColStd_HArray1OfBoolean) myTangentFlags;
0123   Handle(TColStd_HArray1OfReal)    myParameters;
0124   Standard_Boolean                 myPeriodic;
0125   Standard_Boolean                 myTangentRequest;
0126 };
0127 
0128 #endif // _Geom2dAPI_Interpolate_HeaderFile