Back to home page

EIC code displayed by LXR

 
 

    


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

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