Salome HOME
Update copyright information
[modules/smesh.git] / src / StdMeshers / StdMeshers_Distribution.hxx
1 //  Copyright (C) 2007-2008  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 //  Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
6 //  This library is free software; you can redistribute it and/or
7 //  modify it under the terms of the GNU Lesser General Public
8 //  License as published by the Free Software Foundation; either
9 //  version 2.1 of the License.
10 //
11 //  This library is distributed in the hope that it will be useful,
12 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
13 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 //  Lesser General Public License for more details.
15 //
16 //  You should have received a copy of the GNU Lesser General Public
17 //  License along with this library; if not, write to the Free Software
18 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19 //
20 //  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22 //  SMESH StdMeshers : implementaion of point distribution algorithm
23 //  File   : StdMeshers_Distribution.hxx
24 //  Author : Alexandre SOLOVYOV
25 //  Module : SMESH
26 //  $Header$
27 //
28 #ifndef _STD_MESHERS_DISTRIBUTION_HXX_
29 #define _STD_MESHERS_DISTRIBUTION_HXX_
30
31 #include "SMESH_StdMeshers.hxx"
32
33 #include <vector>
34 #include <math_Function.hxx>
35 #include <ExprIntrp_GenExp.hxx>
36 #include <Expr_Array1OfNamedUnknown.hxx>
37 #include <TColStd_Array1OfReal.hxx>
38
39
40 class STDMESHERS_EXPORT Function 
41 {
42 public:
43   Function( const int );
44   virtual ~Function();
45   virtual bool   value( const double, double& ) const;
46   virtual double integral( const double, const double ) const = 0;
47
48 private:
49   int myConv;
50 };
51
52 class STDMESHERS_EXPORT FunctionIntegral : public Function
53 {
54 public:
55   FunctionIntegral( const Function*, const double );
56   virtual ~FunctionIntegral();
57   virtual bool   value( const double, double& ) const;
58   virtual double integral( const double, const double ) const;
59
60 private:
61   Function* myFunc;
62   double    myStart;
63 };
64
65 class STDMESHERS_EXPORT FunctionTable : public Function
66 {
67 public:
68   FunctionTable( const std::vector<double>&, const int );
69   virtual ~FunctionTable();
70   virtual bool   value( const double, double& ) const;
71   virtual double integral( const double, const double ) const;
72
73 private:
74   bool    findBounds( const double, int&, int& ) const;
75
76   //integral from x[i] to x[i+1]
77   double  integral( const int i ) const;
78
79   //integral from x[i] to x[i]+d
80   //warning: function is presented as linear on interaval from x[i] to x[i]+d,
81   //         for correct result d must be >=0 and <=x[i+1]-x[i]
82   double  integral( const int i, const double d ) const;
83
84 private:
85   std::vector<double>  myData;
86 };
87
88 class STDMESHERS_EXPORT FunctionExpr : public Function, public math_Function
89 {
90 public:
91   FunctionExpr( const char*, const int );
92   virtual ~FunctionExpr();
93   virtual Standard_Boolean Value( const Standard_Real, Standard_Real& );
94   virtual bool   value( const double, double& ) const;
95   virtual double integral( const double, const double ) const;
96
97 private:
98   Handle(ExprIntrp_GenExp)    myExpr;
99   Expr_Array1OfNamedUnknown   myVars;
100   TColStd_Array1OfReal        myValues;
101 };
102
103 STDMESHERS_EXPORT
104 bool buildDistribution( const Function& f,
105                         const double start, const double end,
106                         const int nbSeg,
107                         std::vector<double>& data,
108                         const double eps );
109
110 STDMESHERS_EXPORT
111 bool buildDistribution( const TCollection_AsciiString& f, const int conv, const double start, const double end,
112                         const int nbSeg, std::vector<double>& data, const double eps );
113 STDMESHERS_EXPORT
114 bool buildDistribution( const std::vector<double>& f, const int conv, const double start, const double end,
115                         const int nbSeg, std::vector<double>& data, const double eps );
116
117 #endif