Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-12-03 10:53:50

0001 // Created on: 1995-05-29
0002 // Created by: Xavier BENVENISTE
0003 // Copyright (c) 1995-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 _AdvApprox_ApproxAFunction_HeaderFile
0018 #define _AdvApprox_ApproxAFunction_HeaderFile
0019 
0020 #include <Standard.hxx>
0021 #include <Standard_DefineAlloc.hxx>
0022 #include <Standard_Handle.hxx>
0023 
0024 #include <Standard_Integer.hxx>
0025 #include <NCollection_Array1.hxx>
0026 #include <NCollection_HArray1.hxx>
0027 #include <Standard_Real.hxx>
0028 #include <GeomAbs_Shape.hxx>
0029 #include <Standard_Boolean.hxx>
0030 #include <NCollection_Array2.hxx>
0031 #include <NCollection_HArray2.hxx>
0032 #include <gp_Pnt2d.hxx>
0033 #include <gp_Pnt.hxx>
0034 #include <AdvApprox_EvaluatorFunction.hxx>
0035 #include <Standard_OStream.hxx>
0036 class AdvApprox_Cutting;
0037 
0038 //! this approximate a given function
0039 class AdvApprox_ApproxAFunction
0040 {
0041 public:
0042   DEFINE_STANDARD_ALLOC
0043 
0044   //! Constructs approximator tool.
0045   //!
0046   //! Warning:
0047   //! the Func should be valid reference to object of type
0048   //! inherited from class EvaluatorFunction from Approx
0049   //! with life time longer than that of the approximator tool;
0050   //!
0051   //! the result should be formatted in the following way :
0052   //! <--Num1DSS--> <--2 * Num2DSS--> <--3 * Num3DSS-->
0053   //! R[0] ....     R[Num1DSS].....                   R[Dimension-1]
0054   //!
0055   //! the order in which each Subspace appears should be consistent
0056   //! with the tolerances given in the create function and the
0057   //! results will be given in that order as well that is :
0058   //! Curve2d(n) will correspond to the nth entry
0059   //! described by Num2DSS, Curve(n) will correspond to
0060   //! the nth entry described by Num3DSS
0061   //! The same type of schema applies to the Poles1d, Poles2d and
0062   //! Poles.
0063   Standard_EXPORT AdvApprox_ApproxAFunction(
0064     const int                                       Num1DSS,
0065     const int                                       Num2DSS,
0066     const int                                       Num3DSS,
0067     const occ::handle<NCollection_HArray1<double>>& OneDTol,
0068     const occ::handle<NCollection_HArray1<double>>& TwoDTol,
0069     const occ::handle<NCollection_HArray1<double>>& ThreeDTol,
0070     const double                                    First,
0071     const double                                    Last,
0072     const GeomAbs_Shape                             Continuity,
0073     const int                                       MaxDeg,
0074     const int                                       MaxSeg,
0075     const AdvApprox_EvaluatorFunction&              Func);
0076 
0077   //! Approximation with user method of cutting
0078   Standard_EXPORT AdvApprox_ApproxAFunction(
0079     const int                                       Num1DSS,
0080     const int                                       Num2DSS,
0081     const int                                       Num3DSS,
0082     const occ::handle<NCollection_HArray1<double>>& OneDTol,
0083     const occ::handle<NCollection_HArray1<double>>& TwoDTol,
0084     const occ::handle<NCollection_HArray1<double>>& ThreeDTol,
0085     const double                                    First,
0086     const double                                    Last,
0087     const GeomAbs_Shape                             Continuity,
0088     const int                                       MaxDeg,
0089     const int                                       MaxSeg,
0090     const AdvApprox_EvaluatorFunction&              Func,
0091     const AdvApprox_Cutting&                        CutTool);
0092 
0093   Standard_EXPORT static void Approximation(const int                         TotalDimension,
0094                                             const int                         TotalNumSS,
0095                                             const NCollection_Array1<int>&    LocalDimension,
0096                                             const double                      First,
0097                                             const double                      Last,
0098                                             AdvApprox_EvaluatorFunction&      Evaluator,
0099                                             const AdvApprox_Cutting&          CutTool,
0100                                             const int                         ContinuityOrder,
0101                                             const int                         NumMaxCoeffs,
0102                                             const int                         MaxSegments,
0103                                             const NCollection_Array1<double>& TolerancesArray,
0104                                             const int                         code_precis,
0105                                             int&                              NumCurves,
0106                                             NCollection_Array1<int>&          NumCoeffPerCurveArray,
0107                                             NCollection_Array1<double>&       LocalCoefficientArray,
0108                                             NCollection_Array1<double>&       IntervalsArray,
0109                                             NCollection_Array1<double>&       ErrorMaxArray,
0110                                             NCollection_Array1<double>&       AverageErrorArray,
0111                                             int&                              ErrorCode);
0112 
0113   bool IsDone() const;
0114 
0115   bool HasResult() const;
0116 
0117   //! returns the poles from the algorithms as is
0118   occ::handle<NCollection_HArray2<double>> Poles1d() const;
0119 
0120   //! returns the poles from the algorithms as is
0121   occ::handle<NCollection_HArray2<gp_Pnt2d>> Poles2d() const;
0122 
0123   //! -- returns the poles from the algorithms as is
0124   occ::handle<NCollection_HArray2<gp_Pnt>> Poles() const;
0125 
0126   //! as the name says
0127   Standard_EXPORT int NbPoles() const;
0128 
0129   //! returns the poles at Index from the 1d subspace
0130   Standard_EXPORT void Poles1d(const int Index, NCollection_Array1<double>& P) const;
0131 
0132   //! returns the poles at Index from the 2d subspace
0133   Standard_EXPORT void Poles2d(const int Index, NCollection_Array1<gp_Pnt2d>& P) const;
0134 
0135   //! returns the poles at Index from the 3d subspace
0136   Standard_EXPORT void Poles(const int Index, NCollection_Array1<gp_Pnt>& P) const;
0137 
0138   int Degree() const;
0139 
0140   int NbKnots() const;
0141 
0142   int NumSubSpaces(const int Dimension) const;
0143 
0144   occ::handle<NCollection_HArray1<double>> Knots() const;
0145 
0146   occ::handle<NCollection_HArray1<int>> Multiplicities() const;
0147 
0148   //! returns the error as is in the algorithms
0149   Standard_EXPORT occ::handle<NCollection_HArray1<double>> MaxError(const int Dimension) const;
0150 
0151   //! returns the error as is in the algorithms
0152   Standard_EXPORT occ::handle<NCollection_HArray1<double>> AverageError(const int Dimension) const;
0153 
0154   Standard_EXPORT double MaxError(const int Dimension, const int Index) const;
0155 
0156   Standard_EXPORT double AverageError(const int Dimension, const int Index) const;
0157 
0158   //! display information on approximation.
0159   Standard_EXPORT void Dump(Standard_OStream& o) const;
0160 
0161 private:
0162   Standard_EXPORT void Perform(const int                Num1DSS,
0163                                const int                Num2DSS,
0164                                const int                Num3DSS,
0165                                const AdvApprox_Cutting& CutTool);
0166 
0167   int                                        myNumSubSpaces[3];
0168   occ::handle<NCollection_HArray1<double>>   my1DTolerances;
0169   occ::handle<NCollection_HArray1<double>>   my2DTolerances;
0170   occ::handle<NCollection_HArray1<double>>   my3DTolerances;
0171   double                                     myFirst;
0172   double                                     myLast;
0173   GeomAbs_Shape                              myContinuity;
0174   int                                        myMaxDegree;
0175   int                                        myMaxSegments;
0176   bool                                       myDone;
0177   bool                                       myHasResult;
0178   occ::handle<NCollection_HArray2<double>>   my1DPoles;
0179   occ::handle<NCollection_HArray2<gp_Pnt2d>> my2DPoles;
0180   occ::handle<NCollection_HArray2<gp_Pnt>>   my3DPoles;
0181   occ::handle<NCollection_HArray1<double>>   myKnots;
0182   occ::handle<NCollection_HArray1<int>>      myMults;
0183   int                                        myDegree;
0184   void*                                      myEvaluator;
0185   occ::handle<NCollection_HArray1<double>>   my1DMaxError;
0186   occ::handle<NCollection_HArray1<double>>   my1DAverageError;
0187   occ::handle<NCollection_HArray1<double>>   my2DMaxError;
0188   occ::handle<NCollection_HArray1<double>>   my2DAverageError;
0189   occ::handle<NCollection_HArray1<double>>   my3DMaxError;
0190   occ::handle<NCollection_HArray1<double>>   my3DAverageError;
0191 };
0192 
0193 #include <AdvApprox_ApproxAFunction.lxx>
0194 
0195 #endif // _AdvApprox_ApproxAFunction_HeaderFile