Back to index

salome-smesh  6.5.0
StdMeshers_Distribution.hxx
Go to the documentation of this file.
00001 // Copyright (C) 2007-2012  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 
00023 //  SMESH StdMeshers : implementaion of point distribution algorithm
00024 //  File   : StdMeshers_Distribution.hxx
00025 //  Author : Alexandre SOLOVYOV
00026 //  Module : SMESH
00027 //  $Header: /home/server/cvs/SMESH/SMESH_SRC/src/StdMeshers/StdMeshers_Distribution.hxx,v 1.5.2.1.6.2.8.1 2012-04-13 09:31:19 vsr Exp $
00028 //
00029 #ifndef _STD_MESHERS_DISTRIBUTION_HXX_
00030 #define _STD_MESHERS_DISTRIBUTION_HXX_
00031 
00032 #include "SMESH_StdMeshers.hxx"
00033 
00034 #include <vector>
00035 #include <math_Function.hxx>
00036 #include <ExprIntrp_GenExp.hxx>
00037 #include <Expr_Array1OfNamedUnknown.hxx>
00038 #include <TColStd_Array1OfReal.hxx>
00039 
00040 
00041 class STDMESHERS_EXPORT Function 
00042 {
00043 public:
00044   Function( const int );
00045   virtual ~Function();
00046   virtual bool   value( const double, double& ) const;
00047   virtual double integral( const double, const double ) const = 0;
00048 
00049 private:
00050   int myConv;
00051 };
00052 
00053 class STDMESHERS_EXPORT FunctionIntegral : public Function
00054 {
00055 public:
00056   FunctionIntegral( const Function*, const double );
00057   virtual ~FunctionIntegral();
00058   virtual bool   value( const double, double& ) const;
00059   virtual double integral( const double, const double ) const;
00060 
00061 private:
00062   Function* myFunc;
00063   double    myStart;
00064 };
00065 
00066 class STDMESHERS_EXPORT FunctionTable : public Function
00067 {
00068 public:
00069   FunctionTable( const std::vector<double>&, const int );
00070   virtual ~FunctionTable();
00071   virtual bool   value( const double, double& ) const;
00072   virtual double integral( const double, const double ) const;
00073 
00074 private:
00075   bool    findBounds( const double, int&, int& ) const;
00076 
00077   //integral from x[i] to x[i+1]
00078   double  integral( const int i ) const;
00079 
00080   //integral from x[i] to x[i]+d
00081   //warning: function is presented as linear on interaval from x[i] to x[i]+d,
00082   //         for correct result d must be >=0 and <=x[i+1]-x[i]
00083   double  integral( const int i, const double d ) const;
00084 
00085 private:
00086   std::vector<double>  myData;
00087 };
00088 
00089 class STDMESHERS_EXPORT FunctionExpr : public Function, public math_Function
00090 {
00091 public:
00092   FunctionExpr( const char*, const int );
00093   virtual ~FunctionExpr();
00094   virtual Standard_Boolean Value( const Standard_Real, Standard_Real& );
00095   virtual bool   value( const double, double& ) const;
00096   virtual double integral( const double, const double ) const;
00097 
00098 private:
00099   Handle(ExprIntrp_GenExp)    myExpr;
00100   Expr_Array1OfNamedUnknown   myVars;
00101   TColStd_Array1OfReal        myValues;
00102 };
00103 
00104 STDMESHERS_EXPORT
00105 bool buildDistribution( const Function& f,
00106                         const double start, const double end,
00107                         const int nbSeg,
00108                         std::vector<double>& data,
00109                         const double eps );
00110 
00111 STDMESHERS_EXPORT
00112 bool buildDistribution( const TCollection_AsciiString& f, const int conv, const double start, const double end,
00113                         const int nbSeg, std::vector<double>& data, const double eps );
00114 STDMESHERS_EXPORT
00115 bool buildDistribution( const std::vector<double>& f, const int conv, const double start, const double end,
00116                         const int nbSeg, std::vector<double>& data, const double eps );
00117 
00118 #endif