Salome HOME
PAL8238 - Hypothesis for non-regular 1D meshing
[modules/smesh.git] / src / StdMeshers / StdMeshers_NumberOfSegments.hxx
1 //  SMESH SMESH : implementaion of SMESH idl descriptions
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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
21 //
22 //
23 //
24 //  File   : StdMeshers_NumberOfSegments.hxx
25 //           Moved here from SMESH_NumberOfSegments.hxx
26 //  Author : Paul RASCLE, EDF
27 //  Module : SMESH
28 //  $Header$
29
30 #ifndef _SMESH_NUMBEROFSEGMENTS_HXX_
31 #define _SMESH_NUMBEROFSEGMENTS_HXX_
32
33 #include "SMESH_Hypothesis.hxx"
34 #include "Utils_SALOME_Exception.hxx"
35 #include <vector>
36
37 /*!
38  * \brief This class represents hypothesis for 1d algorithm
39  * 
40  * It provides parameters for subdivision an edge by various
41  * distribution types, considering the given number of resulting segments
42  */
43 class StdMeshers_NumberOfSegments:
44   public SMESH_Hypothesis
45 {
46 public:
47   StdMeshers_NumberOfSegments(int hypId, int studyId, SMESH_Gen* gen);
48   virtual ~StdMeshers_NumberOfSegments();
49
50   /*!
51    * \brief Set the number of segments
52     * \param segmentsNumber - must be greater than zero
53    */
54   void SetNumberOfSegments(int segmentsNumber)
55     throw (SALOME_Exception);
56
57   /*!
58    * \brief Get the number of segments
59    */
60   int GetNumberOfSegments() const;
61
62   /*!
63    * \brief This enumeration presents available types of distribution
64    */
65   enum DistrType
66   {
67     DT_Regular, //!< equidistant distribution
68     DT_Scale,   //!< scale distribution
69     DT_TabFunc, //!< distribution with density function presented by table
70     DT_ExprFunc //!< distribution with density function presented by expression
71   };
72
73   /*!
74    * \brief Set distribution type
75    */
76   void SetDistrType(DistrType typ)
77     throw (SALOME_Exception);
78
79   /*!
80    * \brief Get distribution type
81    */
82   DistrType GetDistrType() const;
83
84   /*!
85    * \brief Set scale factor for scale distribution
86    * \param scaleFactor - positive value different from 1
87    * 
88    * Throws SALOME_Exception if distribution type is not DT_Scale,
89    * or scaleFactor is not a positive value different from 1
90    */
91   virtual void SetScaleFactor(double scaleFactor)
92     throw (SALOME_Exception);
93
94   /*!
95    * \brief Get scale factor for scale distribution
96    * 
97    * Throws SALOME_Exception if distribution type is not DT_Scale
98    */
99   double GetScaleFactor() const
100     throw (SALOME_Exception);
101
102   /*!
103    * \brief Set table function for distribution DT_TabFunc
104     * \param table - this vector contains the pairs (parameter, value)
105    * following each by other, so the number of elements in the vector
106    * must be even. The parameters must be in range [0,1] and sorted in
107    * increase order. The values of function must be positive.
108    * 
109    * Throws SALOME_Exception if distribution type is not DT_TabFunc
110    */
111   void SetTableFunction(const std::vector<double>& table)
112     throw (SALOME_Exception);
113
114   /*!
115    * \brief Get table function for distribution DT_TabFunc
116    * 
117    * Throws SALOME_Exception if distribution type is not DT_TabFunc
118    */
119   const std::vector<double>& GetTableFunction() const
120     throw (SALOME_Exception);
121
122   /*!
123    * \brief Set expression function for distribution DT_ExprFunc
124     * \param expr - string containing the expression of the function
125     *               f(t), e.g. "sin(t)"
126    * 
127    * Throws SALOME_Exception if distribution type is not DT_ExprFunc
128    */
129   void SetExpressionFunction( const char* expr)
130     throw (SALOME_Exception);
131
132   /*!
133    * \brief Get expression function for distribution DT_ExprFunc
134    * 
135    * Throws SALOME_Exception if distribution type is not DT_ExprFunc
136    */
137   const char* GetExpressionFunction() const
138     throw (SALOME_Exception);
139
140   /*!
141    * \brief When exponent mode is set, the function of distribution of density
142    * is used as an exponent of 10, i,e, 10^f(t). This mode is sensible only when
143    * function distribution is used (DT_TabFunc or DT_ExprFunc)
144     * \param isExp - boolean switching on/off the mode
145    * 
146    * Throws SALOME_Exception if distribution type is not functional
147    */
148   void SetExponentMode(bool isExp)
149     throw (SALOME_Exception);
150
151   /*!
152    * \brief Returns true if the exponent mode is set
153    * 
154    * Throws SALOME_Exception if distribution type is not functional
155    */
156   bool IsExponentMode() const
157     throw (SALOME_Exception);
158
159   virtual ostream & SaveTo(ostream & save);
160   virtual istream & LoadFrom(istream & load);
161   friend ostream& operator << (ostream & save, StdMeshers_NumberOfSegments & hyp);
162   friend istream& operator >> (istream & load, StdMeshers_NumberOfSegments & hyp);
163
164 protected:
165   int                 _numberOfSegments; //!< an edge will be split on to this number of segments
166   DistrType           _distrType;        //!< the type of distribution of density function
167   double              _scaleFactor;      //!< the scale parameter for DT_Scale
168   std::vector<double> _table;            //!< the table for DT_TabFunc, a sequence of pairs of numbers
169   std::string         _func;             //!< the expression of the function for DT_ExprFunc
170   bool                _expMode;          //!< flag of exponent mode
171 };
172
173 #endif