Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-23 09:17:12

0001 // Created on: 1991-02-27
0002 // Created by: Jean Claude Vauthier
0003 // Copyright (c) 1991-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 _CPnts_UniformDeflection_HeaderFile
0018 #define _CPnts_UniformDeflection_HeaderFile
0019 
0020 #include <Standard.hxx>
0021 #include <Standard_DefineAlloc.hxx>
0022 
0023 #include <Standard_Integer.hxx>
0024 #include <gp_Pnt.hxx>
0025 class Adaptor3d_Curve;
0026 class Adaptor2d_Curve2d;
0027 
0028 //! This class defines an algorithm to create a set of points
0029 //! (with a given chordal deviation) at the
0030 //! positions of constant deflection of a given parametrized curve or a trimmed
0031 //! circle.
0032 //! The continuity of the curve must be at least C2.
0033 //!
0034 //! the usage of the is the following.
0035 //!
0036 //! class myUniformDFeflection instantiates
0037 //! UniformDeflection(Curve, Tool);
0038 //!
0039 //! Curve C; // Curve inherits from Curve or Curve2d from Adaptor2d
0040 //! myUniformDeflection Iter1;
0041 //! DefPntOfmyUniformDeflection P;
0042 //!
0043 //! for(Iter1.Initialize(C, Deflection, EPSILON, True);
0044 //! Iter1.More();
0045 //! Iter1.Next()) {
0046 //! P = Iter1.Value();
0047 //! ... make something with P
0048 //! }
0049 //! if(!Iter1.IsAllDone()) {
0050 //! ... something wrong happened
0051 //! }
0052 class CPnts_UniformDeflection
0053 {
0054 public:
0055   DEFINE_STANDARD_ALLOC
0056 
0057   //! creation of a indefinite UniformDeflection
0058   Standard_EXPORT CPnts_UniformDeflection();
0059 
0060   //! Computes a uniform deflection distribution of points
0061   //! on the curve <C>.
0062   //! <Deflection> defines the constant deflection value.
0063   //! The algorithm computes the number of points and the points.
0064   //! The curve <C> must be at least C2 else the computation can fail.
0065   //! If just some parts of the curve is C2 it is better to give the
0066   //! parameters bounds and to use the below constructor .
0067   //! if <WithControl> is True, the algorithm controls the estimate
0068   //! deflection
0069   //! when the curve is singular at the point P(u),the algorithm
0070   //! computes the next point as
0071   //! P(u + std::max(CurrentStep,std::abs(LastParameter-FirstParameter)))
0072   //! if the singularity is at the first point ,the next point
0073   //! calculated is the P(LastParameter)
0074   Standard_EXPORT CPnts_UniformDeflection(const Adaptor3d_Curve& C,
0075                                           const double           Deflection,
0076                                           const double           Resolution,
0077                                           const bool             WithControl);
0078 
0079   //! As above with 2d curve
0080   Standard_EXPORT CPnts_UniformDeflection(const Adaptor2d_Curve2d& C,
0081                                           const double             Deflection,
0082                                           const double             Resolution,
0083                                           const bool               WithControl);
0084 
0085   //! Computes an uniform deflection distribution of points on a part of
0086   //! the curve <C>. Deflection defines the step between the points.
0087   //! <U1> and <U2> define the distribution span.
0088   //! <U1> and <U2> must be in the parametric range of the curve.
0089   Standard_EXPORT CPnts_UniformDeflection(const Adaptor3d_Curve& C,
0090                                           const double           Deflection,
0091                                           const double           U1,
0092                                           const double           U2,
0093                                           const double           Resolution,
0094                                           const bool             WithControl);
0095 
0096   //! As above with 2d curve
0097   Standard_EXPORT CPnts_UniformDeflection(const Adaptor2d_Curve2d& C,
0098                                           const double             Deflection,
0099                                           const double             U1,
0100                                           const double             U2,
0101                                           const double             Resolution,
0102                                           const bool               WithControl);
0103 
0104   //! Initialize the algorithms with <C>, <Deflection>, <UStep>,
0105   //! <Resolution> and <WithControl>
0106   Standard_EXPORT void Initialize(const Adaptor3d_Curve& C,
0107                                   const double           Deflection,
0108                                   const double           Resolution,
0109                                   const bool             WithControl);
0110 
0111   //! Initialize the algorithms with <C>, <Deflection>, <UStep>,
0112   //! <Resolution> and <WithControl>
0113   Standard_EXPORT void Initialize(const Adaptor2d_Curve2d& C,
0114                                   const double             Deflection,
0115                                   const double             Resolution,
0116                                   const bool               WithControl);
0117 
0118   //! Initialize the algorithms with <C>, <Deflection>, <UStep>,
0119   //! <U1>, <U2> and <WithControl>
0120   Standard_EXPORT void Initialize(const Adaptor3d_Curve& C,
0121                                   const double           Deflection,
0122                                   const double           U1,
0123                                   const double           U2,
0124                                   const double           Resolution,
0125                                   const bool             WithControl);
0126 
0127   //! Initialize the algorithms with <C>, <Deflection>, <UStep>,
0128   //! <U1>, <U2> and <WithControl>
0129   Standard_EXPORT void Initialize(const Adaptor2d_Curve2d& C,
0130                                   const double             Deflection,
0131                                   const double             U1,
0132                                   const double             U2,
0133                                   const double             Resolution,
0134                                   const bool               WithControl);
0135 
0136   //! To know if all the calculus were done successfully
0137   //! (ie all the points have been computed). The calculus can fail if
0138   //! the Curve is not C1 in the considered domain.
0139   //! Returns True if the calculus was successful.
0140   bool IsAllDone() const;
0141 
0142   //! go to the next Point.
0143   void Next();
0144 
0145   //! returns True if it exists a next Point.
0146   Standard_EXPORT bool More();
0147 
0148   //! return the computed parameter
0149   double Value() const;
0150 
0151   //! return the computed parameter
0152   gp_Pnt Point() const;
0153 
0154 private:
0155   //! algorithm
0156   Standard_EXPORT void Perform();
0157 
0158   bool   myDone;
0159   bool   my3d;
0160   void*  myCurve;
0161   bool   myFinish;
0162   double myTolCur;
0163   bool   myControl;
0164   int    myIPoint;
0165   int    myNbPoints;
0166   double myParams[3];
0167   gp_Pnt myPoints[3];
0168   double myDwmax;
0169   double myDeflection;
0170   double myFirstParam;
0171   double myLastParam;
0172   double myDu;
0173 };
0174 
0175 #include <CPnts_UniformDeflection.lxx>
0176 
0177 #endif // _CPnts_UniformDeflection_HeaderFile