Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-06-06 08:35:25

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