Salome HOME
Join modifications from BR_Dev_For_4_0 tag V4_1_1.
[modules/smesh.git] / src / StdMeshers / StdMeshers_Distribution.hxx
1 //  SMESH StdMeshers : implementaion of point distribution algorithm
2 //
3 //  Copyright (C) 2003  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 //
23 //
24 //  File   : StdMeshers_Distribution.hxx
25 //  Author : Alexandre SOLOVYOV
26 //  Module : SMESH
27 //  $Header$
28
29 #ifndef _STD_MESHERS_DISTRIBUTION_HXX_
30 #define _STD_MESHERS_DISTRIBUTION_HXX_
31
32 using namespace std;
33
34 #include "SMESH_StdMeshers.hxx"
35
36 #include <vector>
37 #include <math_Function.hxx>
38 #include <ExprIntrp_GenExp.hxx>
39 #include <Expr_Array1OfNamedUnknown.hxx>
40 #include <TColStd_Array1OfReal.hxx>
41
42
43 class STDMESHERS_EXPORT Function 
44 {
45 public:
46   Function( const int );
47   virtual ~Function();
48   virtual bool   value( const double, double& ) const;
49   virtual double integral( const double, const double ) const = 0;
50
51 private:
52   int myConv;
53 };
54
55 class STDMESHERS_EXPORT FunctionIntegral : public Function
56 {
57 public:
58   FunctionIntegral( const Function*, const double );
59   virtual ~FunctionIntegral();
60   virtual bool   value( const double, double& ) const;
61   virtual double integral( const double, const double ) const;
62
63 private:
64   Function* myFunc;
65   double    myStart;
66 };
67
68 class STDMESHERS_EXPORT FunctionTable : public Function
69 {
70 public:
71   FunctionTable( const std::vector<double>&, const int );
72   virtual ~FunctionTable();
73   virtual bool   value( const double, double& ) const;
74   virtual double integral( const double, const double ) const;
75
76 private:
77   bool    findBounds( const double, int&, int& ) const;
78
79   //integral from x[i] to x[i+1]
80   double  integral( const int i ) const;
81
82   //integral from x[i] to x[i]+d
83   //warning: function is presented as linear on interaval from x[i] to x[i]+d,
84   //         for correct result d must be >=0 and <=x[i+1]-x[i]
85   double  integral( const int i, const double d ) const;
86
87 private:
88   std::vector<double>  myData;
89 };
90
91 class STDMESHERS_EXPORT FunctionExpr : public Function, public math_Function
92 {
93 public:
94   FunctionExpr( const char*, const int );
95   virtual ~FunctionExpr();
96   virtual Standard_Boolean Value( const Standard_Real, Standard_Real& );
97   virtual bool   value( const double, double& ) const;
98   virtual double integral( const double, const double ) const;
99
100 private:
101   Handle(ExprIntrp_GenExp)    myExpr;
102   Expr_Array1OfNamedUnknown   myVars;
103   TColStd_Array1OfReal        myValues;
104 };
105
106 STDMESHERS_EXPORT
107 bool buildDistribution( const Function& f,
108                         const double start, const double end,
109                         const int nbSeg,
110                         vector<double>& data,
111                         const double eps );
112
113 STDMESHERS_EXPORT
114 bool buildDistribution( const TCollection_AsciiString& f, const int conv, const double start, const double end,
115                         const int nbSeg, vector<double>& data, const double eps );
116 STDMESHERS_EXPORT
117 bool buildDistribution( const std::vector<double>& f, const int conv, const double start, const double end,
118                         const int nbSeg, vector<double>& data, const double eps );
119
120 #endif