| 1 |
// Copyright (C) 2007-2015 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, or (at your option) any later version. |
| 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 : [email protected] |
| 21 |
// |
| 22 |
|
| 23 |
// SMESH StdMeshers : implementation of point distribution algorithm |
| 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 |
#include "SMESH_StdMeshers.hxx" |
| 33 |
|
| 34 |
#include <vector> |
| 35 |
#include <math_Function.hxx> |
| 36 |
#include <ExprIntrp_GenExp.hxx> |
| 37 |
#include <Expr_Array1OfNamedUnknown.hxx> |
| 38 |
#include <TColStd_Array1OfReal.hxx> |
| 39 |
|
| 40 |
namespace StdMeshers |
| 41 |
{ |
| 42 |
class STDMESHERS_EXPORT Function |
| 43 |
{ |
| 44 |
public: |
| 45 |
Function( const int ); |
| 46 |
virtual ~Function(); |
| 47 |
virtual bool value( const double, double& ) const; |
| 48 |
virtual double integral( const double, const double ) const = 0; |
| 49 |
|
| 50 |
private: |
| 51 |
int myConv; |
| 52 |
}; |
| 53 |
|
| 54 |
class STDMESHERS_EXPORT FunctionIntegral : public Function |
| 55 |
{ |
| 56 |
public: |
| 57 |
FunctionIntegral( const Function*, const double ); |
| 58 |
virtual ~FunctionIntegral(); |
| 59 |
virtual bool value( const double, double& ) const; |
| 60 |
virtual double integral( const double, const double ) const; |
| 61 |
|
| 62 |
private: |
| 63 |
Function* myFunc; |
| 64 |
double myStart; |
| 65 |
}; |
| 66 |
|
| 67 |
class STDMESHERS_EXPORT FunctionTable : public Function |
| 68 |
{ |
| 69 |
public: |
| 70 |
FunctionTable( const std::vector<double>&, const int ); |
| 71 |
virtual ~FunctionTable(); |
| 72 |
virtual bool value( const double, double& ) const; |
| 73 |
virtual double integral( const double, const double ) const; |
| 74 |
|
| 75 |
private: |
| 76 |
bool findBounds( const double, int&, int& ) const; |
| 77 |
|
| 78 |
//integral from x[i] to x[i+1] |
| 79 |
double integral( const int i ) const; |
| 80 |
|
| 81 |
//integral from x[i] to x[i]+d |
| 82 |
//warning: function is presented as linear on interaval from x[i] to x[i]+d, |
| 83 |
// for correct result d must be >=0 and <=x[i+1]-x[i] |
| 84 |
double integral( const int i, const double d ) const; |
| 85 |
|
| 86 |
private: |
| 87 |
std::vector<double> myData; |
| 88 |
}; |
| 89 |
|
| 90 |
class STDMESHERS_EXPORT FunctionExpr : public Function, public math_Function |
| 91 |
{ |
| 92 |
public: |
| 93 |
FunctionExpr( const char*, const int ); |
| 94 |
virtual ~FunctionExpr(); |
| 95 |
virtual Standard_Boolean Value( const Standard_Real, Standard_Real& ); |
| 96 |
virtual bool value( const double, double& ) const; |
| 97 |
virtual double integral( const double, const double ) const; |
| 98 |
|
| 99 |
private: |
| 100 |
Handle(ExprIntrp_GenExp) myExpr; |
| 101 |
Expr_Array1OfNamedUnknown myVars; |
| 102 |
TColStd_Array1OfReal myValues; |
| 103 |
}; |
| 104 |
|
| 105 |
STDMESHERS_EXPORT |
| 106 |
bool buildDistribution( const Function& f, |
| 107 |
const double start, const double end, |
| 108 |
const int nbSeg, |
| 109 |
std::vector<double>& data, |
| 110 |
const double eps ); |
| 111 |
|
| 112 |
STDMESHERS_EXPORT |
| 113 |
bool buildDistribution( const TCollection_AsciiString& f, const int conv, const double start, const double end, |
| 114 |
const int nbSeg, std::vector<double>& data, const double eps ); |
| 115 |
STDMESHERS_EXPORT |
| 116 |
bool buildDistribution( const std::vector<double>& f, const int conv, const double start, const double end, |
| 117 |
const int nbSeg, std::vector<double>& data, const double eps ); |
| 118 |
} |
| 119 |
#endif |