Back to home page

EIC code displayed by LXR

 
 

    


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

0001 // Created on: 1996-02-14
0002 // Created by: Joelle CHAUVET
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 _AdvApp2Var_ApproxAFunc2Var_HeaderFile
0018 #define _AdvApp2Var_ApproxAFunc2Var_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 <AdvApp2Var_Context.hxx>
0029 #include <AdvApp2Var_Network.hxx>
0030 #include <AdvApp2Var_Framework.hxx>
0031 #include <Standard_Boolean.hxx>
0032 #include <Geom_Surface.hxx>
0033 #include <AdvApp2Var_EvaluatorFunc2Var.hxx>
0034 #include <Standard_OStream.hxx>
0035 class AdvApprox_Cutting;
0036 class AdvApp2Var_Criterion;
0037 class Geom_BSplineSurface;
0038 
0039 //! Perform the approximation of <Func> F(U,V)
0040 //! Arguments are :
0041 //! Num1DSS, Num2DSS, Num3DSS :The numbers of 1,2,3 dimensional subspaces
0042 //! OneDTol, TwoDTol, ThreeDTol: The tolerance of approximation in each
0043 //! subspaces
0044 //! OneDTolFr, TwoDTolFr, ThreeDTolFr: The tolerance of approximation on
0045 //! the boundaries in each subspaces
0046 //! [FirstInU, LastInU]: The Bounds in U of the Approximation
0047 //! [FirstInV, LastInV]: The Bounds in V of the Approximation
0048 //! FavorIso : Give preference to extract u-iso or v-iso on F(U,V)
0049 //! This can be useful to optimize the <Func> method
0050 //! ContInU, ContInV : Continuity waiting in u and v
0051 //! PrecisCode : Precision on approximation's error measurement
0052 //! 1 : Fast computation and average precision
0053 //! 2 : Average computation and good precision
0054 //! 3 : Slow computation and very good precision
0055 //! MaxDegInU : Maximum u-degree waiting in U
0056 //! MaxDegInV : Maximum u-degree waiting in V
0057 //! Warning:
0058 //! MaxDegInU (resp. MaxDegInV) must be >= 2*iu (resp. iv) + 1,
0059 //! where iu (resp. iv) = 0 if ContInU (resp. ContInV) = GeomAbs_C0,
0060 //! = 1 if = GeomAbs_C1,
0061 //! = 2 if = GeomAbs_C2.
0062 //! MaxPatch  : Maximum number of Patch waiting
0063 //! number of Patch is number of u span * number of v span
0064 //! Func      : The external method to evaluate F(U,V)
0065 //! Crit      : To (re)defined condition of convergence
0066 //! UChoice, VChoice : To define the way in U (or V) Knot insertion
0067 //! Warning:
0068 //! for the moment, the result is a 3D Surface
0069 //! so Num1DSS and Num2DSS must be equals to 0
0070 //! and Num3DSS must be equal to 1.
0071 //! Warning:
0072 //! the Function of type EvaluatorFunc2Var from Approx
0073 //! must be a subclass of AdvApp2Var_EvaluatorFunc2Var
0074 //!
0075 //! the result should be formatted in the following way :
0076 //! <--Num1DSS--> <--2 * Num2DSS--> <--3 * Num3DSS-->
0077 //! R[0,0] ....   R[Num1DSS,0].....  R[Dimension-1,0] for the 1st parameter
0078 //! R[0,i] ....   R[Num1DSS,i].....  R[Dimension-1,i] for the ith parameter
0079 //! R[0,N-1] .... R[Num1DSS,N-1].... R[Dimension-1,N-1] for the Nth parameter
0080 //!
0081 //! the order in which each Subspace appears should be consistent
0082 //! with the tolerances given in the create function and the
0083 //! results will be given in that order as well that is :
0084 //! Surface(n) will correspond to the nth entry described by Num3DSS
0085 class AdvApp2Var_ApproxAFunc2Var
0086 {
0087 public:
0088   DEFINE_STANDARD_ALLOC
0089 
0090   Standard_EXPORT AdvApp2Var_ApproxAFunc2Var(
0091     const int                                       Num1DSS,
0092     const int                                       Num2DSS,
0093     const int                                       Num3DSS,
0094     const occ::handle<NCollection_HArray1<double>>& OneDTol,
0095     const occ::handle<NCollection_HArray1<double>>& TwoDTol,
0096     const occ::handle<NCollection_HArray1<double>>& ThreeDTol,
0097     const occ::handle<NCollection_HArray2<double>>& OneDTolFr,
0098     const occ::handle<NCollection_HArray2<double>>& TwoDTolFr,
0099     const occ::handle<NCollection_HArray2<double>>& ThreeDTolFr,
0100     const double                                    FirstInU,
0101     const double                                    LastInU,
0102     const double                                    FirstInV,
0103     const double                                    LastInV,
0104     const GeomAbs_IsoType                           FavorIso,
0105     const GeomAbs_Shape                             ContInU,
0106     const GeomAbs_Shape                             ContInV,
0107     const int                                       PrecisCode,
0108     const int                                       MaxDegInU,
0109     const int                                       MaxDegInV,
0110     const int                                       MaxPatch,
0111     const AdvApp2Var_EvaluatorFunc2Var&             Func,
0112     AdvApprox_Cutting&                              UChoice,
0113     AdvApprox_Cutting&                              VChoice);
0114 
0115   Standard_EXPORT AdvApp2Var_ApproxAFunc2Var(
0116     const int                                       Num1DSS,
0117     const int                                       Num2DSS,
0118     const int                                       Num3DSS,
0119     const occ::handle<NCollection_HArray1<double>>& OneDTol,
0120     const occ::handle<NCollection_HArray1<double>>& TwoDTol,
0121     const occ::handle<NCollection_HArray1<double>>& ThreeDTol,
0122     const occ::handle<NCollection_HArray2<double>>& OneDTolFr,
0123     const occ::handle<NCollection_HArray2<double>>& TwoDTolFr,
0124     const occ::handle<NCollection_HArray2<double>>& ThreeDTolFr,
0125     const double                                    FirstInU,
0126     const double                                    LastInU,
0127     const double                                    FirstInV,
0128     const double                                    LastInV,
0129     const GeomAbs_IsoType                           FavorIso,
0130     const GeomAbs_Shape                             ContInU,
0131     const GeomAbs_Shape                             ContInV,
0132     const int                                       PrecisCode,
0133     const int                                       MaxDegInU,
0134     const int                                       MaxDegInV,
0135     const int                                       MaxPatch,
0136     const AdvApp2Var_EvaluatorFunc2Var&             Func,
0137     const AdvApp2Var_Criterion&                     Crit,
0138     AdvApprox_Cutting&                              UChoice,
0139     AdvApprox_Cutting&                              VChoice);
0140 
0141   //! True if the approximation succeeded within the imposed
0142   //! tolerances and the wished continuities
0143   bool IsDone() const;
0144 
0145   //! True if the approximation did come out with a result that
0146   //! is not NECESSARELY within the required tolerance or a result
0147   //! that is not recognized with the wished continuities
0148   bool HasResult() const;
0149 
0150   //! returns the BSplineSurface of range Index
0151   occ::handle<Geom_BSplineSurface> Surface(const int Index) const;
0152 
0153   int UDegree() const;
0154 
0155   int VDegree() const;
0156 
0157   int NumSubSpaces(const int Dimension) const;
0158 
0159   //! returns the errors max
0160   Standard_EXPORT occ::handle<NCollection_HArray1<double>> MaxError(const int Dimension) const;
0161 
0162   //! returns the average errors
0163   Standard_EXPORT occ::handle<NCollection_HArray1<double>> AverageError(const int Dimension) const;
0164 
0165   //! returns the errors max on UFrontiers
0166   //! Warning:
0167   //! Dimension must be equal to 3.
0168   Standard_EXPORT occ::handle<NCollection_HArray1<double>> UFrontError(const int Dimension) const;
0169 
0170   //! returns the errors max on VFrontiers
0171   //! Warning:
0172   //! Dimension must be equal to 3.
0173   Standard_EXPORT occ::handle<NCollection_HArray1<double>> VFrontError(const int Dimension) const;
0174 
0175   //! returns the error max of the BSplineSurface of range Index
0176   Standard_EXPORT double MaxError(const int Dimension, const int Index) const;
0177 
0178   //! returns the average error of the BSplineSurface of range Index
0179   Standard_EXPORT double AverageError(const int Dimension, const int Index) const;
0180 
0181   //! returns the error max of the BSplineSurface of range Index on a UFrontier
0182   Standard_EXPORT double UFrontError(const int Dimension, const int Index) const;
0183 
0184   //! returns the error max of the BSplineSurface of range Index on a VFrontier
0185   Standard_EXPORT double VFrontError(const int Dimension, const int Index) const;
0186 
0187   Standard_EXPORT double CritError(const int Dimension, const int Index) const;
0188 
0189   //! Prints on the stream 'o' information on the current state
0190   //! of the object.
0191   Standard_EXPORT void Dump(Standard_OStream& o) const;
0192 
0193 private:
0194   //! Initialisation of the approximation ; used by Create
0195   Standard_EXPORT void Init();
0196 
0197   //! Initialisation of the approximation with a grid of regular cuttings ;
0198   //! used by Init and Perform
0199   Standard_EXPORT void InitGrid(const int NbInt);
0200 
0201   //! Computation of the approximation result ; used by Create
0202   Standard_EXPORT void Perform(const AdvApprox_Cutting&            UChoice,
0203                                const AdvApprox_Cutting&            VChoice,
0204                                const AdvApp2Var_EvaluatorFunc2Var& Func);
0205 
0206   //! Computation of the approximation result ; used by Create
0207   Standard_EXPORT void Perform(const AdvApprox_Cutting&            UChoice,
0208                                const AdvApprox_Cutting&            VChoice,
0209                                const AdvApp2Var_EvaluatorFunc2Var& Func,
0210                                const AdvApp2Var_Criterion&         Crit);
0211 
0212   //! Computation of the polynomial approximations ; used by Perform
0213   Standard_EXPORT void ComputePatches(const AdvApprox_Cutting&            UChoice,
0214                                       const AdvApprox_Cutting&            VChoice,
0215                                       const AdvApp2Var_EvaluatorFunc2Var& Func);
0216 
0217   //! Computation of the polynomial approximations ; used by Perform
0218   Standard_EXPORT void ComputePatches(const AdvApprox_Cutting&            UChoice,
0219                                       const AdvApprox_Cutting&            VChoice,
0220                                       const AdvApp2Var_EvaluatorFunc2Var& Func,
0221                                       const AdvApp2Var_Criterion&         Crit);
0222 
0223   //! Approximation of the constraints ; used by ComputePatches
0224   Standard_EXPORT void ComputeConstraints(const AdvApprox_Cutting&            UChoice,
0225                                           const AdvApprox_Cutting&            VChoice,
0226                                           const AdvApp2Var_EvaluatorFunc2Var& Func);
0227 
0228   //! Approximation of the constraints ; used by ComputePatches
0229   Standard_EXPORT void ComputeConstraints(const AdvApprox_Cutting&            UChoice,
0230                                           const AdvApprox_Cutting&            VChoice,
0231                                           const AdvApp2Var_EvaluatorFunc2Var& Func,
0232                                           const AdvApp2Var_Criterion&         Crit);
0233 
0234   //! Computation of the 3D errors on the approximation result ; used by Perform
0235   Standard_EXPORT void Compute3DErrors();
0236 
0237   //! Computation of the max value of the criterion on the approximation result ;
0238   //! used by Perform
0239   Standard_EXPORT void ComputeCritError();
0240 
0241   //! Conversion of the approximation result in BSpline; used by Create
0242   Standard_EXPORT void ConvertBS();
0243 
0244   int                                                         myNumSubSpaces[3];
0245   occ::handle<NCollection_HArray1<double>>                    my1DTolerances;
0246   occ::handle<NCollection_HArray1<double>>                    my2DTolerances;
0247   occ::handle<NCollection_HArray1<double>>                    my3DTolerances;
0248   occ::handle<NCollection_HArray2<double>>                    my1DTolOnFront;
0249   occ::handle<NCollection_HArray2<double>>                    my2DTolOnFront;
0250   occ::handle<NCollection_HArray2<double>>                    my3DTolOnFront;
0251   double                                                      myFirstParInU;
0252   double                                                      myLastParInU;
0253   double                                                      myFirstParInV;
0254   double                                                      myLastParInV;
0255   GeomAbs_IsoType                                             myFavoriteIso;
0256   GeomAbs_Shape                                               myContInU;
0257   GeomAbs_Shape                                               myContInV;
0258   int                                                         myPrecisionCode;
0259   int                                                         myMaxDegInU;
0260   int                                                         myMaxDegInV;
0261   int                                                         myMaxPatches;
0262   AdvApp2Var_Context                                          myConditions;
0263   AdvApp2Var_Network                                          myResult;
0264   AdvApp2Var_Framework                                        myConstraints;
0265   bool                                                        myDone;
0266   bool                                                        myHasResult;
0267   occ::handle<NCollection_HArray1<occ::handle<Geom_Surface>>> mySurfaces;
0268   int                                                         myDegreeInU;
0269   int                                                         myDegreeInV;
0270   occ::handle<NCollection_HArray1<double>>                    my1DMaxError;
0271   occ::handle<NCollection_HArray1<double>>                    my1DAverageError;
0272   occ::handle<NCollection_HArray1<double>>                    my1DUFrontError;
0273   occ::handle<NCollection_HArray1<double>>                    my1DVFrontError;
0274   occ::handle<NCollection_HArray1<double>>                    my2DMaxError;
0275   occ::handle<NCollection_HArray1<double>>                    my2DAverageError;
0276   occ::handle<NCollection_HArray1<double>>                    my2DUFrontError;
0277   occ::handle<NCollection_HArray1<double>>                    my2DVFrontError;
0278   occ::handle<NCollection_HArray1<double>>                    my3DMaxError;
0279   occ::handle<NCollection_HArray1<double>>                    my3DAverageError;
0280   occ::handle<NCollection_HArray1<double>>                    my3DUFrontError;
0281   occ::handle<NCollection_HArray1<double>>                    my3DVFrontError;
0282   double                                                      myCriterionError;
0283 };
0284 
0285 #include <AdvApp2Var_ApproxAFunc2Var.lxx>
0286 
0287 #endif // _AdvApp2Var_ApproxAFunc2Var_HeaderFile