Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-22 08:57:49

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