1 // SMESH SMESH : implementaion of SMESH idl descriptions
3 // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
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.
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.
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
20 // See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
24 // File : StdMeshers_NumberOfSegments.hxx
25 // Moved here from SMESH_NumberOfSegments.hxx
26 // Author : Paul RASCLE, EDF
30 #ifndef _SMESH_NUMBEROFSEGMENTS_HXX_
31 #define _SMESH_NUMBEROFSEGMENTS_HXX_
33 #include "SMESH_Hypothesis.hxx"
34 #include "Utils_SALOME_Exception.hxx"
38 * \brief This class represents hypothesis for 1d algorithm
40 * It provides parameters for subdivision an edge by various
41 * distribution types, considering the given number of resulting segments
43 class StdMeshers_NumberOfSegments:
44 public SMESH_Hypothesis
47 StdMeshers_NumberOfSegments(int hypId, int studyId, SMESH_Gen* gen);
48 virtual ~StdMeshers_NumberOfSegments();
51 * \brief Set the number of segments
52 * \param segmentsNumber - must be greater than zero
54 void SetNumberOfSegments(int segmentsNumber)
55 throw (SALOME_Exception);
58 * \brief Get the number of segments
60 int GetNumberOfSegments() const;
63 * \brief This enumeration presents available types of distribution
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
74 * \brief Set distribution type
76 void SetDistrType(DistrType typ)
77 throw (SALOME_Exception);
80 * \brief Get distribution type
82 DistrType GetDistrType() const;
85 * \brief Set scale factor for scale distribution
86 * \param scaleFactor - positive value different from 1
88 * Throws SALOME_Exception if distribution type is not DT_Scale,
89 * or scaleFactor is not a positive value different from 1
91 virtual void SetScaleFactor(double scaleFactor)
92 throw (SALOME_Exception);
95 * \brief Get scale factor for scale distribution
97 * Throws SALOME_Exception if distribution type is not DT_Scale
99 double GetScaleFactor() const
100 throw (SALOME_Exception);
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.
109 * Throws SALOME_Exception if distribution type is not DT_TabFunc
111 void SetTableFunction(const std::vector<double>& table)
112 throw (SALOME_Exception);
115 * \brief Get table function for distribution DT_TabFunc
117 * Throws SALOME_Exception if distribution type is not DT_TabFunc
119 const std::vector<double>& GetTableFunction() const
120 throw (SALOME_Exception);
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)"
127 * Throws SALOME_Exception if distribution type is not DT_ExprFunc
129 void SetExpressionFunction(const char* expr)
130 throw (SALOME_Exception);
133 * \brief Get expression function for distribution DT_ExprFunc
135 * Throws SALOME_Exception if distribution type is not DT_ExprFunc
137 const char* GetExpressionFunction() const
138 throw (SALOME_Exception);
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
146 * Throws SALOME_Exception if distribution type is not functional
148 void SetExponentMode(bool isExp)
149 throw (SALOME_Exception);
152 * \brief Returns true if the exponent mode is set
154 * Throws SALOME_Exception if distribution type is not functional
156 bool IsExponentMode() const
157 throw (SALOME_Exception);
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);
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