Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-08-13 09:17:45

0001 // Created on: 1993-01-26
0002 // Created by: Laurent PAINNOT
0003 // Copyright (c) 1993-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 _Approx_FitAndDivide_HeaderFile
0018 #define _Approx_FitAndDivide_HeaderFile
0019 
0020 #include <Standard.hxx>
0021 #include <Standard_DefineAlloc.hxx>
0022 
0023 #include <AppCont_Function.hxx>
0024 #include <AppParCurves_Constraint.hxx>
0025 #include <AppParCurves_MultiCurve.hxx>
0026 #include <AppParCurves_SequenceOfMultiCurve.hxx>
0027 #include <Standard_Integer.hxx>
0028 #include <TColStd_SequenceOfReal.hxx>
0029 class AppParCurves_MultiCurve;
0030 
0031 class Approx_FitAndDivide
0032 {
0033 public:
0034   DEFINE_STANDARD_ALLOC
0035 
0036   //! The MultiLine <Line> will be approximated until tolerances
0037   //! will be reached.
0038   //! The approximation will be done from degreemin to degreemax
0039   //! with a cutting if the corresponding boolean is True.
0040   Standard_EXPORT Approx_FitAndDivide(
0041     const AppCont_Function&       Line,
0042     const Standard_Integer        degreemin   = 3,
0043     const Standard_Integer        degreemax   = 8,
0044     const Standard_Real           Tolerance3d = 1.0e-5,
0045     const Standard_Real           Tolerance2d = 1.0e-5,
0046     const Standard_Boolean        cutting     = Standard_False,
0047     const AppParCurves_Constraint FirstC      = AppParCurves_TangencyPoint,
0048     const AppParCurves_Constraint LastC       = AppParCurves_TangencyPoint);
0049 
0050   //! Initializes the fields of the algorithm.
0051   Standard_EXPORT Approx_FitAndDivide(
0052     const Standard_Integer        degreemin   = 3,
0053     const Standard_Integer        degreemax   = 8,
0054     const Standard_Real           Tolerance3d = 1.0e-05,
0055     const Standard_Real           Tolerance2d = 1.0e-05,
0056     const Standard_Boolean        cutting     = Standard_False,
0057     const AppParCurves_Constraint FirstC      = AppParCurves_TangencyPoint,
0058     const AppParCurves_Constraint LastC       = AppParCurves_TangencyPoint);
0059 
0060   //! runs the algorithm after having initialized the fields.
0061   Standard_EXPORT void Perform(const AppCont_Function& Line);
0062 
0063   //! changes the degrees of the approximation.
0064   Standard_EXPORT void SetDegrees(const Standard_Integer degreemin,
0065                                   const Standard_Integer degreemax);
0066 
0067   //! Changes the tolerances of the approximation.
0068   Standard_EXPORT void SetTolerances(const Standard_Real Tolerance3d,
0069                                      const Standard_Real Tolerance2d);
0070 
0071   //! Changes the constraints of the approximation.
0072   Standard_EXPORT void SetConstraints(const AppParCurves_Constraint FirstC,
0073                                       const AppParCurves_Constraint LastC);
0074 
0075   //! Changes the max number of segments, which is allowed for cutting.
0076   Standard_EXPORT void SetMaxSegments(const Standard_Integer theMaxSegments);
0077 
0078   //! Set inverse order of degree selection:
0079   //! if theInvOrdr = true, current degree is chosen by inverse order -
0080   //! from maxdegree to mindegree.
0081   //! By default inverse order is used.
0082   Standard_EXPORT void SetInvOrder(const Standard_Boolean theInvOrder);
0083 
0084   //! Set value of hang checking flag
0085   //! if this flag = true, possible hang of algorithm is checked
0086   //! and algorithm is forced to stop.
0087   //! By default hang checking is used.
0088   Standard_EXPORT void SetHangChecking(const Standard_Boolean theHangChecking);
0089 
0090   //! returns False if at a moment of the approximation,
0091   //! the status NoApproximation has been sent by the user
0092   //! when more points were needed.
0093   Standard_EXPORT Standard_Boolean IsAllApproximated() const;
0094 
0095   //! returns False if the status NoPointsAdded has been sent.
0096   Standard_EXPORT Standard_Boolean IsToleranceReached() const;
0097 
0098   //! returns the tolerances 2d and 3d of the <Index> MultiCurve.
0099   Standard_EXPORT void Error(const Standard_Integer Index,
0100                              Standard_Real&         tol3d,
0101                              Standard_Real&         tol2d) const;
0102 
0103   //! Returns the number of MultiCurve doing the approximation
0104   //! of the MultiLine.
0105   Standard_EXPORT Standard_Integer NbMultiCurves() const;
0106 
0107   //! returns the approximation MultiCurve of range <Index>.
0108   Standard_EXPORT AppParCurves_MultiCurve Value(const Standard_Integer Index = 1) const;
0109 
0110   Standard_EXPORT void Parameters(const Standard_Integer Index,
0111                                   Standard_Real&         firstp,
0112                                   Standard_Real&         lastp) const;
0113 
0114 protected:
0115 private:
0116   //! is internally used by the algorithms.
0117   Standard_EXPORT Standard_Boolean Compute(const AppCont_Function& Line,
0118                                            const Standard_Real     Ufirst,
0119                                            const Standard_Real     Ulast,
0120                                            Standard_Real&          TheTol3d,
0121                                            Standard_Real&          TheTol2d);
0122 
0123   AppParCurves_SequenceOfMultiCurve myMultiCurves;
0124   TColStd_SequenceOfReal            myfirstparam;
0125   TColStd_SequenceOfReal            mylastparam;
0126   AppParCurves_MultiCurve           TheMultiCurve;
0127   Standard_Boolean                  alldone;
0128   Standard_Boolean                  tolreached;
0129   TColStd_SequenceOfReal            Tolers3d;
0130   TColStd_SequenceOfReal            Tolers2d;
0131   Standard_Integer                  mydegremin;
0132   Standard_Integer                  mydegremax;
0133   Standard_Real                     mytol3d;
0134   Standard_Real                     mytol2d;
0135   Standard_Real                     currenttol3d;
0136   Standard_Real                     currenttol2d;
0137   Standard_Boolean                  mycut;
0138   AppParCurves_Constraint           myfirstC;
0139   AppParCurves_Constraint           mylastC;
0140   Standard_Integer                  myMaxSegments;
0141   Standard_Boolean                  myInvOrder;
0142   Standard_Boolean                  myHangChecking;
0143 };
0144 
0145 #endif // _Approx_FitAndDivide_HeaderFile