SALOME - SMESH
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
StdMeshers_Distribution.hxx
Go to the documentation of this file.
00001 //  Copyright (C) 2007-2008  CEA/DEN, EDF R&D, OPEN CASCADE
00002 //
00003 //  Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
00004 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
00005 //
00006 //  This library is free software; you can redistribute it and/or
00007 //  modify it under the terms of the GNU Lesser General Public
00008 //  License as published by the Free Software Foundation; either
00009 //  version 2.1 of the License.
00010 //
00011 //  This library is distributed in the hope that it will be useful,
00012 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014 //  Lesser General Public License for more details.
00015 //
00016 //  You should have received a copy of the GNU Lesser General Public
00017 //  License along with this library; if not, write to the Free Software
00018 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00019 //
00020 //  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00021 //
00022 //  SMESH StdMeshers : implementaion of point distribution algorithm
00023 //  File   : StdMeshers_Distribution.hxx
00024 //  Author : Alexandre SOLOVYOV
00025 //  Module : SMESH
00026 //  $Header$
00027 //
00028 #ifndef _STD_MESHERS_DISTRIBUTION_HXX_
00029 #define _STD_MESHERS_DISTRIBUTION_HXX_
00030 
00031 #include "SMESH_StdMeshers.hxx"
00032 
00033 #include <vector>
00034 #include <math_Function.hxx>
00035 #include <ExprIntrp_GenExp.hxx>
00036 #include <Expr_Array1OfNamedUnknown.hxx>
00037 #include <TColStd_Array1OfReal.hxx>
00038 
00039 
00040 class STDMESHERS_EXPORT Function 
00041 {
00042 public:
00043   Function( const int );
00044   virtual ~Function();
00045   virtual bool   value( const double, double& ) const;
00046   virtual double integral( const double, const double ) const = 0;
00047 
00048 private:
00049   int myConv;
00050 };
00051 
00052 class STDMESHERS_EXPORT FunctionIntegral : public Function
00053 {
00054 public:
00055   FunctionIntegral( const Function*, const double );
00056   virtual ~FunctionIntegral();
00057   virtual bool   value( const double, double& ) const;
00058   virtual double integral( const double, const double ) const;
00059 
00060 private:
00061   Function* myFunc;
00062   double    myStart;
00063 };
00064 
00065 class STDMESHERS_EXPORT FunctionTable : public Function
00066 {
00067 public:
00068   FunctionTable( const std::vector<double>&, const int );
00069   virtual ~FunctionTable();
00070   virtual bool   value( const double, double& ) const;
00071   virtual double integral( const double, const double ) const;
00072 
00073 private:
00074   bool    findBounds( const double, int&, int& ) const;
00075 
00076   //integral from x[i] to x[i+1]
00077   double  integral( const int i ) const;
00078 
00079   //integral from x[i] to x[i]+d
00080   //warning: function is presented as linear on interaval from x[i] to x[i]+d,
00081   //         for correct result d must be >=0 and <=x[i+1]-x[i]
00082   double  integral( const int i, const double d ) const;
00083 
00084 private:
00085   std::vector<double>  myData;
00086 };
00087 
00088 class STDMESHERS_EXPORT FunctionExpr : public Function, public math_Function
00089 {
00090 public:
00091   FunctionExpr( const char*, const int );
00092   virtual ~FunctionExpr();
00093   virtual Standard_Boolean Value( const Standard_Real, Standard_Real& );
00094   virtual bool   value( const double, double& ) const;
00095   virtual double integral( const double, const double ) const;
00096 
00097 private:
00098   Handle(ExprIntrp_GenExp)    myExpr;
00099   Expr_Array1OfNamedUnknown   myVars;
00100   TColStd_Array1OfReal        myValues;
00101 };
00102 
00103 STDMESHERS_EXPORT
00104 bool buildDistribution( const Function& f,
00105                   const double start, const double end,
00106                   const int nbSeg,
00107                   std::vector<double>& data,
00108                   const double eps );
00109 
00110 STDMESHERS_EXPORT
00111 bool buildDistribution( const TCollection_AsciiString& f, const int conv, const double start, const double end,
00112                   const int nbSeg, std::vector<double>& data, const double eps );
00113 STDMESHERS_EXPORT
00114 bool buildDistribution( const std::vector<double>& f, const int conv, const double start, const double end,
00115                   const int nbSeg, std::vector<double>& data, const double eps );
00116 
00117 #endif