Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:03:37

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 _GeomAPI_Interpolate_HeaderFile
0018 #define _GeomAPI_Interpolate_HeaderFile
0019 
0020 #include <Standard.hxx>
0021 #include <Standard_DefineAlloc.hxx>
0022 #include <Standard_Handle.hxx>
0023 
0024 #include <TColgp_HArray1OfVec.hxx>
0025 #include <TColStd_HArray1OfBoolean.hxx>
0026 #include <TColStd_HArray1OfReal.hxx>
0027 #include <TColgp_Array1OfVec.hxx>
0028 #include <Geom_BSplineCurve.hxx>
0029 
0030 class gp_Vec;
0031 
0032 
0033 //! This  class  is  used  to  interpolate a  BsplineCurve
0034 //! passing   through  an  array  of  points,  with  a  C2
0035 //! Continuity if tangency is not requested at the point.
0036 //! If tangency is requested at the point the continuity will
0037 //! be C1.  If Perodicity is requested the curve will be closed
0038 //! and the junction will be the first point given. The curve
0039 //! will than be only C1
0040 //! Describes functions for building a constrained 3D BSpline curve.
0041 //! The curve is defined by a table of points
0042 //! through which it passes, and if required:
0043 //! -   by a parallel table of reals which gives the
0044 //! value of the parameter of each point through
0045 //! which the resulting BSpline curve passes, and
0046 //! -   by vectors tangential to these points.
0047 //! An Interpolate object provides a framework for:
0048 //! -   defining the constraints of the BSpline curve,
0049 //! -   implementing the interpolation algorithm, and
0050 //! -   consulting the results.
0051 class GeomAPI_Interpolate 
0052 {
0053 public:
0054 
0055   DEFINE_STANDARD_ALLOC
0056 
0057   
0058   //! Initializes an algorithm for constructing a
0059   //! constrained BSpline curve passing through the points of the table   Points.
0060   //! Tangential vectors can then be assigned, using the function Load.
0061   //! If PeriodicFlag is true, the constrained BSpline
0062   //! curve will be periodic and closed. In this case,
0063   //! the junction point is the first point of the table Points.
0064   //! The tolerance value Tolerance is used to check that:
0065   //! -   points are not too close to each other, or
0066   //! -   tangential vectors (defined using the
0067   //! function Load) are not too small.
0068   //! The resulting BSpline curve will be "C2"
0069   //! continuous, except where a tangency
0070   //! constraint is defined on a point through which
0071   //! the curve passes (by using the Load function).
0072   //! In this case, it will be only "C1" continuous.
0073   //! Once all the constraints are defined, use the
0074   //! function Perform to compute the curve.
0075   //! Warning
0076   //! -   There must be at least 2 points in the table Points.
0077   //! -   If PeriodicFlag is false, there must be as
0078   //! many parameters in the array Parameters as
0079   //! there are points in the array Points.
0080   //! -   If PeriodicFlag is true, there must be one
0081   //! more parameter in the table Parameters: this
0082   //! is used to give the parameter on the
0083   //! resulting BSpline curve of the junction point
0084   //! of the curve (which is also the first point of the table Points).
0085   //! Exceptions
0086   //! -   Standard_ConstructionError if the
0087   //! distance between two consecutive points in
0088   //! the table Points is less than or equal to Tolerance.
0089   //! -   Standard_OutOfRange if:
0090   //! -   there are less than two points in the table Points, or
0091   //! -   conditions relating to the respective
0092   //! number of elements in the parallel tables
0093   //! Points and Parameters are not respected.
0094   Standard_EXPORT GeomAPI_Interpolate(const Handle(TColgp_HArray1OfPnt)& Points, const Standard_Boolean PeriodicFlag, const Standard_Real Tolerance);
0095   
0096   //! Initializes an algorithm for constructing a
0097   //! constrained BSpline curve passing through the points of the table
0098   //! Points, where the parameters of each of its
0099   //! points are given by the parallel table Parameters.
0100   //! Tangential vectors can then be assigned, using the function Load.
0101   //! If PeriodicFlag is true, the constrained BSpline
0102   //! curve will be periodic and closed. In this case,
0103   //! the junction point is the first point of the table Points.
0104   //! The tolerance value Tolerance is used to check that:
0105   //! -   points are not too close to each other, or
0106   //! -   tangential vectors (defined using the
0107   //! function Load) are not too small.
0108   //! The resulting BSpline curve will be "C2"
0109   //! continuous, except where a tangency
0110   //! constraint is defined on a point through which
0111   //! the curve passes (by using the Load function).
0112   //! In this case, it will be only "C1" continuous.
0113   //! Once all the constraints are defined, use the
0114   //! function Perform to compute the curve.
0115   //! Warning
0116   //! -   There must be at least 2 points in the table Points.
0117   //! -   If PeriodicFlag is false, there must be as
0118   //! many parameters in the array Parameters as
0119   //! there are points in the array Points.
0120   //! -   If PeriodicFlag is true, there must be one
0121   //! more parameter in the table Parameters: this
0122   //! is used to give the parameter on the
0123   //! resulting BSpline curve of the junction point
0124   //! of the curve (which is also the first point of the table Points).
0125   //! Exceptions
0126   //! -   Standard_ConstructionError if the
0127   //! distance between two consecutive points in
0128   //! the table Points is less than or equal to Tolerance.
0129   //! -   Standard_OutOfRange if:
0130   //! -   there are less than two points in the table Points, or
0131   //! -   conditions relating to the respective
0132   //! number of elements in the parallel tables
0133   //! Points and Parameters are not respected.
0134   Standard_EXPORT GeomAPI_Interpolate(const Handle(TColgp_HArray1OfPnt)& Points, const Handle(TColStd_HArray1OfReal)& Parameters, const Standard_Boolean PeriodicFlag, const Standard_Real Tolerance);
0135   
0136   //! Assigns this constrained BSpline curve to be
0137   //! tangential to vectors InitialTangent and FinalTangent
0138   //! at its first and last points respectively (i.e.
0139   //! the first and last points of the table of
0140   //! points through which the curve passes, as
0141   //! defined at the time of initialization).
0142   Standard_EXPORT void Load (const gp_Vec& InitialTangent, const gp_Vec& FinalTangent, const Standard_Boolean Scale = Standard_True);
0143   
0144   //! Assigns this constrained BSpline curve to be
0145   //! tangential to vectors defined in the table Tangents,
0146   //! which is parallel to the table of points
0147   //! through which the curve passes, as
0148   //! defined at the time of initialization. Vectors
0149   //! in the table Tangents are defined only if
0150   //! the flag given in the parallel table
0151   //! TangentFlags is true: only these vectors
0152   //! are set as tangency constraints.
0153   Standard_EXPORT void Load (const TColgp_Array1OfVec& Tangents, const Handle(TColStd_HArray1OfBoolean)& TangentFlags, const Standard_Boolean Scale = Standard_True);
0154   
0155   //! Clears all tangency constraints on this
0156   //! constrained BSpline curve (as initialized by the function Load).
0157   Standard_EXPORT void ClearTangents();
0158   
0159   //! Computes the constrained BSpline curve.
0160   //! Use the function IsDone to verify that the
0161   //! computation is successful, and then the function Curve to obtain the result.
0162   Standard_EXPORT void Perform();
0163   
0164   //! Returns the computed BSpline curve.
0165   //! Raises StdFail_NotDone if the interpolation fails.
0166   Standard_EXPORT const Handle(Geom_BSplineCurve)& Curve() const;
0167 Standard_EXPORT operator Handle(Geom_BSplineCurve)() const;
0168   
0169   //! Returns true if the constrained BSpline curve is successfully constructed.
0170   //! Note: in this case, the result is given by the function Curve.
0171   Standard_EXPORT Standard_Boolean IsDone() const;
0172 
0173 
0174 
0175 
0176 protected:
0177 
0178 
0179 
0180 
0181 
0182 private:
0183 
0184   
0185   //! Interpolates in a non periodic fashion
0186   Standard_EXPORT void PerformNonPeriodic();
0187   
0188   //! Interpolates in a C1 periodic fashion
0189   Standard_EXPORT void PerformPeriodic();
0190 
0191 
0192   Standard_Real myTolerance;
0193   Handle(TColgp_HArray1OfPnt) myPoints;
0194   Standard_Boolean myIsDone;
0195   Handle(Geom_BSplineCurve) myCurve;
0196   Handle(TColgp_HArray1OfVec) myTangents;
0197   Handle(TColStd_HArray1OfBoolean) myTangentFlags;
0198   Handle(TColStd_HArray1OfReal) myParameters;
0199   Standard_Boolean myPeriodic;
0200   Standard_Boolean myTangentRequest;
0201 
0202 
0203 };
0204 
0205 
0206 
0207 
0208 
0209 
0210 
0211 #endif // _GeomAPI_Interpolate_HeaderFile