Back to home page

EIC code displayed by LXR

 
 

    


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

0001 // Created on: 1996-08-22
0002 // Created by: Stagiaire Mary FABIEN
0003 // Copyright (c) 1996-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 _GCPnts_QuasiUniformAbscissa_HeaderFile
0018 #define _GCPnts_QuasiUniformAbscissa_HeaderFile
0019 
0020 #include <StdFail_NotDone.hxx>
0021 #include <TColStd_HArray1OfReal.hxx>
0022 
0023 class Adaptor3d_Curve;
0024 class Adaptor2d_Curve2d;
0025 
0026 //! This class provides an algorithm to compute a uniform abscissa
0027 //! distribution of points on a curve, i.e. a sequence of equidistant points.
0028 //! The distance between two consecutive points is measured along the curve.
0029 //!
0030 //! The distribution is defined by a number of points.
0031 class GCPnts_QuasiUniformAbscissa 
0032 {
0033 public:
0034 
0035   DEFINE_STANDARD_ALLOC
0036 
0037   //! Constructs an empty algorithm.
0038   //! To define the problem to be solved, use the function Initialize.
0039   Standard_EXPORT GCPnts_QuasiUniformAbscissa();
0040 
0041   //! Computes a uniform abscissa distribution of points
0042   //! -   on the curve where Abscissa is the curvilinear distance between
0043   //! two consecutive points of the distribution.
0044   Standard_EXPORT GCPnts_QuasiUniformAbscissa (const Adaptor3d_Curve& theC,
0045                                                const Standard_Integer theNbPoints);
0046 
0047   //! Computes a uniform abscissa distribution of points
0048   //! on the part of curve limited by the two parameter values theU1 and theU2,
0049   //! where Abscissa is the curvilinear distance between
0050   //! two consecutive points of the distribution.
0051   //! The first point of the distribution is either the origin of
0052   //! curve or the point of parameter theU1.
0053   //! The following points are computed such that the curvilinear
0054   //! distance between two consecutive points is equal to Abscissa.
0055   //! The last point of the distribution is either the end
0056   //! point of curve or the point of parameter theU2.
0057   //! However the curvilinear distance between this last
0058   //! point and the point just preceding it in the distribution is,
0059   //! of course, generally not equal to Abscissa.
0060   //! Use the function IsDone() to verify that the computation was successful,
0061   //! the function NbPoints() to obtain the number of points of the computed distribution,
0062   //! and the function Parameter() to read the parameter of each point.
0063   //!
0064   //! Warning
0065   //! The roles of theU1 and theU2 are inverted if theU1 > theU2.
0066   //! Warning
0067   //! theC is an adapted curve, that is, an object which is an interface between:
0068   //! -   the services provided by either a 2D curve from
0069   //!     the package Geom2d (in the case of an Adaptor2d_Curve2d curve)
0070   //!     or a 3D curve from the package Geom (in the case of an Adaptor3d_Curve curve),
0071   //! -   and those required on the curve by the computation algorithm.
0072   //! @param theC [in] input 3D curve
0073   //! @param theNbPoints [in] defines the number of desired points
0074   //! @param theU1 [in] first parameter on curve
0075   //! @param theU2 [in] last  parameter on curve
0076   Standard_EXPORT GCPnts_QuasiUniformAbscissa (const Adaptor3d_Curve& theC,
0077                                                const Standard_Integer theNbPoints,
0078                                                const Standard_Real theU1, const Standard_Real theU2);
0079 
0080   //! Initialize the algorithms with 3D curve and target number of points.
0081   //! @param theC [in] input 3D curve
0082   //! @param theNbPoints [in] defines the number of desired points
0083   Standard_EXPORT void Initialize (const Adaptor3d_Curve& theC,
0084                                    const Standard_Integer theNbPoints);
0085 
0086   //! Initialize the algorithms with 3D curve, target number of points and curve parameter range.
0087   //! @param theC [in] input 3D curve
0088   //! @param theNbPoints [in] defines the number of desired points
0089   //! @param theU1 [in] first parameter on curve
0090   //! @param theU2 [in] last  parameter on curve
0091   Standard_EXPORT void Initialize (const Adaptor3d_Curve& theC,
0092                                    const Standard_Integer theNbPoints,
0093                                    const Standard_Real theU1, const Standard_Real theU2);
0094 
0095   //! Computes a uniform abscissa distribution of points on the 2D curve.
0096   //! @param theC [in] input 2D curve
0097   //! @param theNbPoints [in] defines the number of desired points
0098   Standard_EXPORT GCPnts_QuasiUniformAbscissa (const Adaptor2d_Curve2d& theC,
0099                                                const Standard_Integer theNbPoints);
0100 
0101   //! Computes a Uniform abscissa distribution of points on a part of the 2D curve.
0102   //! @param theC [in] input 2D curve
0103   //! @param theNbPoints [in] defines the number of desired points
0104   //! @param theU1 [in] first parameter on curve
0105   //! @param theU2 [in] last  parameter on curve
0106   Standard_EXPORT GCPnts_QuasiUniformAbscissa (const Adaptor2d_Curve2d& theC,
0107                                                const Standard_Integer theNbPoints,
0108                                                const Standard_Real theU1, const Standard_Real theU2);
0109 
0110   //! Initialize the algorithms with 2D curve and target number of points.
0111   //! @param theC [in] input 2D curve
0112   //! @param theNbPoints [in] defines the number of desired points
0113   Standard_EXPORT void Initialize (const Adaptor2d_Curve2d& theC,
0114                                    const Standard_Integer theNbPoints);
0115   
0116   //! Initialize the algorithms with 2D curve, target number of points and curve parameter range.
0117   //! @param theC [in] input 2D curve
0118   //! @param theNbPoints [in] defines the number of desired points
0119   //! @param theU1 [in] first parameter on curve
0120   //! @param theU2 [in] last  parameter on curve
0121   Standard_EXPORT void Initialize (const Adaptor2d_Curve2d& theC,
0122                                    const Standard_Integer theNbPoints,
0123                                    const Standard_Real theU1, const Standard_Real theU2);
0124 
0125   //! Returns true if the computation was successful.
0126   //! IsDone is a protection against:
0127   //! -   non-convergence of the algorithm
0128   //! -   querying the results before computation.
0129   Standard_Boolean IsDone () const
0130   {
0131     return myDone;
0132   }
0133 
0134   //! Returns the number of points of the distribution
0135   //! computed by this algorithm.
0136   //! This value is either:
0137   //! -   the one imposed on the algorithm at the time of
0138   //! construction (or initialization), or
0139   //! -   the one computed by the algorithm when the
0140   //! curvilinear distance between two consecutive
0141   //! points of the distribution is imposed on the
0142   //! algorithm at the time of construction (or initialization).
0143   //! Exceptions
0144   //! StdFail_NotDone if this algorithm has not been
0145   //! initialized, or if the computation was not successful.
0146   Standard_Integer NbPoints () const
0147   {
0148     StdFail_NotDone_Raise_if (!myDone, "GCPnts_QuasiUniformAbscissa::NbPoints()");
0149     return myNbPoints;
0150   }
0151   
0152   //! Returns the parameter of the point of index Index in
0153   //! the distribution computed by this algorithm.
0154   //! Warning
0155   //! Index must be greater than or equal to 1, and less
0156   //! than or equal to the number of points of the
0157   //! distribution. However, pay particular attention as this
0158   //! condition is not checked by this function.
0159   //! Exceptions
0160   //! StdFail_NotDone if this algorithm has not been
0161   //! initialized, or if the computation was not successful.
0162   Standard_Real Parameter (const Standard_Integer Index) const
0163   {
0164     StdFail_NotDone_Raise_if (!myDone, "GCPnts_QuasiUniformAbscissa::Parameter()");
0165     return myParams->Value (Index);
0166   }
0167 
0168 private:
0169 
0170   //! This function divides given curve on the several parts with equal length.
0171   //! It returns array of parameters in the control points.
0172   template<class TheCurve>
0173   void initialize (const TheCurve& theC,
0174                    const Standard_Integer theNbPoints,
0175                    const Standard_Real theU1, const Standard_Real theU2);
0176 
0177 private:
0178   Standard_Boolean myDone;
0179   Standard_Integer myNbPoints;
0180   Handle(TColStd_HArray1OfReal) myParams;
0181 };
0182 
0183 #endif // _GCPnts_QuasiUniformAbscissa_HeaderFile