Salome HOME
PAL8238
authorasl <asl@opencascade.com>
Tue, 16 Aug 2005 12:26:35 +0000 (12:26 +0000)
committerasl <asl@opencascade.com>
Tue, 16 Aug 2005 12:26:35 +0000 (12:26 +0000)
15 files changed:
idl/SMESH_BasicHypothesis.idl
src/SMESH_SWIG/Makefile.in
src/StdMeshers/Makefile.in
src/StdMeshers/StdMeshers_NumberOfSegments.cxx
src/StdMeshers/StdMeshers_NumberOfSegments.hxx
src/StdMeshers/StdMeshers_Regular_1D.cxx
src/StdMeshers/StdMeshers_Regular_1D.hxx
src/StdMeshersGUI/StdMeshersGUI.cxx
src/StdMeshersGUI/StdMeshersGUI_CreateHypothesisDlg.cxx
src/StdMeshersGUI/StdMeshersGUI_CreateHypothesisDlg.h
src/StdMeshersGUI/StdMeshersGUI_Parameters.cxx
src/StdMeshersGUI/StdMeshersGUI_Parameters.h
src/StdMeshersGUI/StdMeshers_msg_en.po
src/StdMeshers_I/StdMeshers_NumberOfSegments_i.cxx
src/StdMeshers_I/StdMeshers_NumberOfSegments_i.hxx

index cd23d24313ed50369f8f94b45a41f7155c616e61..78ca9b77eccd179a01be28249e1b5bda39a0074d 100644 (file)
@@ -28,6 +28,7 @@
 
 #include "SALOME_Exception.idl"
 #include "SMESH_Hypothesis.idl"
 
 #include "SALOME_Exception.idl"
 #include "SMESH_Hypothesis.idl"
+#include "SMESH_Mesh.idl"
 
 
 /*!
 
 
 /*!
@@ -68,6 +69,17 @@ module StdMeshers
      */
     long GetNumberOfSegments();
 
      */
     long GetNumberOfSegments();
 
+    /*!
+     * Sets <distribution type> parameter value
+     */
+    void SetDistrType(in long typ)
+      raises (SALOME::SALOME_Exception);
+
+    /*!
+     * Returns <distribution type> parameter value
+     */
+    long GetDistrType();
+
     /*!
      * Sets <scale factor> parameter value
      */
     /*!
      * Sets <scale factor> parameter value
      */
@@ -77,7 +89,44 @@ module StdMeshers
     /*!
      * Returns <scale factor> parameter value
      */
     /*!
      * Returns <scale factor> parameter value
      */
-    double GetScaleFactor();
+    double GetScaleFactor()
+      raises (SALOME::SALOME_Exception);
+
+    /*!
+     * Sets <table function> parameter value for distribution DT_TabFunc
+     */
+    void SetTableFunction(in SMESH::double_array table)
+      raises (SALOME::SALOME_Exception);
+
+    /*!
+     * Returns <table function> parameter value for distribution DT_TabFunc
+     */
+    SMESH::double_array GetTableFunction()
+      raises (SALOME::SALOME_Exception);
+
+    /*!
+     * Sets <expression function> parameter value for distribution DT_ExprFunc
+     */
+    void SetExpressionFunction(in string expr)
+      raises (SALOME::SALOME_Exception);
+
+    /*!
+     * Returns <expression function> parameter value for distribution DT_ExprFunc
+     */
+    string GetExpressionFunction()
+      raises (SALOME::SALOME_Exception);
+
+    /*!
+     * Sets <exponent mode> parameter value for functional distributions
+     */
+    void SetExponentMode(in boolean isExponent)
+      raises (SALOME::SALOME_Exception);
+
+    /*!
+     * Returns <exponent mode> parameter value for functional distributions
+     */
+    boolean IsExponentMode()
+      raises (SALOME::SALOME_Exception);
   };
 
   /*!
   };
 
   /*!
index a6c0165aa2d26220a77df989976627c7018a106f..df7e19a1766eca1131d49a87f32cf1218ab90dab 100644 (file)
@@ -94,7 +94,8 @@ EXPORT_PYSCRIPTS = libSMESH_Swig.py \
                   SMESH_GroupLyingOnGeom.py \
                   PAL_MESH_041_mesh.py \
                   PAL_MESH_043_2D.py \
                   SMESH_GroupLyingOnGeom.py \
                   PAL_MESH_041_mesh.py \
                   PAL_MESH_043_2D.py \
-                  PAL_MESH_043_3D.py
+                  PAL_MESH_043_3D.py \
+                  SMESH_reg.py
 
 LIB_CLIENT_IDL = SALOMEDS.idl \
                 SALOME_Exception.idl \
 
 LIB_CLIENT_IDL = SALOMEDS.idl \
                 SALOME_Exception.idl \
index caa83337881d5a7cf0dacb286f633b542175f98c..88661b551a35eeaa5c18d32be92044654b5c0708 100644 (file)
@@ -71,7 +71,7 @@ LIB_SRC = \
        StdMeshers_Quadrangle_2D.cxx \
        StdMeshers_MEFISTO_2D.cxx \
        StdMeshers_Penta_3D.cxx \
        StdMeshers_Quadrangle_2D.cxx \
        StdMeshers_MEFISTO_2D.cxx \
        StdMeshers_Penta_3D.cxx \
-       StdMeshers_Hexa_3D.cxx
+       StdMeshers_Hexa_3D.cxx 
 
 LIB_SERVER_IDL = 
 
 
 LIB_SERVER_IDL = 
 
@@ -85,6 +85,6 @@ BIN_SRC =
 CPPFLAGS+= $(OCC_INCLUDES) -I${KERNEL_ROOT_DIR}/include/salome $(BOOST_CPPFLAGS)
 CXXFLAGS+= $(OCC_CXXFLAGS) -I${KERNEL_ROOT_DIR}/include/salome -I${GEOM_ROOT_DIR}/include/salome
 
 CPPFLAGS+= $(OCC_INCLUDES) -I${KERNEL_ROOT_DIR}/include/salome $(BOOST_CPPFLAGS)
 CXXFLAGS+= $(OCC_CXXFLAGS) -I${KERNEL_ROOT_DIR}/include/salome -I${GEOM_ROOT_DIR}/include/salome
 
-LDFLAGS+= -lSMESHimpl -lMEFISTO2D -L${KERNEL_ROOT_DIR}/lib/salome -L${GEOM_ROOT_DIR}/lib/salome
+LDFLAGS+= -lSMESHimpl -lMEFISTO2D -L${CASROOT}/Linux/lib -lTKAdvTools -L${KERNEL_ROOT_DIR}/lib/salome -L${GEOM_ROOT_DIR}/lib/salome
 
 @CONCLUDE@
 
 @CONCLUDE@
index c16c1373ba4bca2d1bb8caa65d758a1a68c7be50..44ac15909556441460b8eb169bfee02e39b2ad42 100644 (file)
 
 using namespace std;
 #include "StdMeshers_NumberOfSegments.hxx"
 
 using namespace std;
 #include "StdMeshers_NumberOfSegments.hxx"
+#include <Standard_ErrorHandler.hxx>
+#include <TCollection_AsciiString.hxx>
+#include <ExprIntrp_GenExp.hxx>
+#include <Expr_NamedUnknown.hxx>
+
+const double PRECISION = 1e-7;
 
 //=============================================================================
 /*!
 
 //=============================================================================
 /*!
@@ -37,12 +43,15 @@ using namespace std;
 //=============================================================================
 
 StdMeshers_NumberOfSegments::StdMeshers_NumberOfSegments(int hypId, int studyId,
 //=============================================================================
 
 StdMeshers_NumberOfSegments::StdMeshers_NumberOfSegments(int hypId, int studyId,
-       SMESH_Gen * gen):SMESH_Hypothesis(hypId, studyId, gen)
+       SMESH_Gen * gen)
+  : SMESH_Hypothesis(hypId, studyId, gen),
+    _numberOfSegments(1),
+    _distrType(DT_Regular),
+    _scaleFactor(1.),
+    _expMode(false)
 {
 {
-       _numberOfSegments = 1;
-       _scaleFactor = 1.0;
-       _name = "NumberOfSegments";
-        _param_algo_dim = 1; 
+  _name = "NumberOfSegments";
+  _param_algo_dim = 1; 
 }
 
 //=============================================================================
 }
 
 //=============================================================================
@@ -85,31 +94,261 @@ int StdMeshers_NumberOfSegments::GetNumberOfSegments() const
        return _numberOfSegments;
 }
 
        return _numberOfSegments;
 }
 
-//=============================================================================
+//================================================================================
 /*!
 /*!
- *  
+ * 
  */
  */
-//=============================================================================
+//================================================================================
+
+void StdMeshers_NumberOfSegments::SetDistrType(DistrType typ)
+  throw(SALOME_Exception)
+{
+  if (typ < DT_Regular || typ > DT_ExprFunc)
+    throw SALOME_Exception(LOCALIZED("distribution type is out of range"));
+
+  if (typ != _distrType)
+  {
+    _distrType = typ;
+    NotifySubMeshesHypothesisModification();
+  }
+}
+
+//================================================================================
+/*!
+ * 
+ */
+//================================================================================
+
+StdMeshers_NumberOfSegments::DistrType StdMeshers_NumberOfSegments::GetDistrType() const
+{
+  return _distrType;
+}
+
+//================================================================================
+/*!
+ * 
+ */
+//================================================================================
 
 void StdMeshers_NumberOfSegments::SetScaleFactor(double scaleFactor)
 
 void StdMeshers_NumberOfSegments::SetScaleFactor(double scaleFactor)
-throw(SALOME_Exception)
+  throw(SALOME_Exception)
 {
 {
-       if (scaleFactor < 0)
-               throw SALOME_Exception(LOCALIZED("scale factor must be positive"));
-       _scaleFactor = scaleFactor;
+  if (_distrType != DT_Scale)
+    throw SALOME_Exception(LOCALIZED("not a scale distribution"));
+  if (scaleFactor < PRECISION)
+    throw SALOME_Exception(LOCALIZED("scale factor must be positive"));
+  if (fabs(scaleFactor - 1.0) < PRECISION)
+    throw SALOME_Exception(LOCALIZED("scale factor must not be equal to 1"));
 
 
-       NotifySubMeshesHypothesisModification();
+  if (fabs(_scaleFactor - scaleFactor) > PRECISION)
+  {
+    _scaleFactor = scaleFactor;
+    NotifySubMeshesHypothesisModification();
+  }
 }
 
 }
 
-//=============================================================================
+//================================================================================
 /*!
 /*!
- *  
+ * 
  */
  */
-//=============================================================================
+//================================================================================
 
 double StdMeshers_NumberOfSegments::GetScaleFactor() const
 
 double StdMeshers_NumberOfSegments::GetScaleFactor() const
+  throw(SALOME_Exception)
 {
 {
-       return _scaleFactor;
+  if (_distrType != DT_Scale)
+    throw SALOME_Exception(LOCALIZED("not a scale distribution"));
+  return _scaleFactor;
+}
+
+//================================================================================
+/*!
+ * 
+ */
+//================================================================================
+
+void StdMeshers_NumberOfSegments::SetTableFunction(const std::vector<double>& table)
+  throw(SALOME_Exception)
+{
+  if (_distrType != DT_TabFunc)
+    throw SALOME_Exception(LOCALIZED("not a table function distribution"));
+  if ( (table.size() % 2) != 0 )
+    throw SALOME_Exception(LOCALIZED("odd size of vector of table function"));
+
+  int i;
+  double prev = -PRECISION;
+  bool isSame = table.size() == _table.size();
+
+  for (i=0; i < table.size()/2; i++) {
+    double par = table[i*2];
+    double val = table[i*2+1];
+    if ( par<0 || par > 1)
+      throw SALOME_Exception(LOCALIZED("parameter of table function is out of range [0,1]"));
+    if ( fabs(par-prev)<PRECISION )
+      throw SALOME_Exception(LOCALIZED("two parameters are the same"));
+    if (val < PRECISION)
+      throw SALOME_Exception(LOCALIZED("value of table function is not positive"));
+    if (isSame)
+    {
+      double oldpar = _table[i*2];
+      double oldval = _table[i*2+1];
+      if (fabs(par - oldpar) > PRECISION || fabs(val - oldval) > PRECISION)
+        isSame = false;
+    }
+    prev = par;
+  }
+
+  if (!isSame)
+  {
+    _table = table;
+    NotifySubMeshesHypothesisModification();
+  }
+}
+
+//================================================================================
+/*!
+ * 
+ */
+//================================================================================
+
+const std::vector<double>& StdMeshers_NumberOfSegments::GetTableFunction() const
+  throw(SALOME_Exception)
+{
+  if (_distrType != DT_TabFunc)
+    throw SALOME_Exception(LOCALIZED("not a table function distribution"));
+  return _table;
+}
+
+//================================================================================
+/*! check if only 't' is unknown variable in expression
+ */
+//================================================================================
+bool isCorrect( const Handle( Expr_GeneralExpression )& expr )
+{
+  if( expr.IsNull() )
+    return true;
+    
+  bool res = true;
+  for( int i=1, n=expr->NbSubExpressions(); i<=n && res; i++ )
+  {
+    Handle( Expr_GeneralExpression ) subexpr = expr->SubExpression( i );
+    Handle( Expr_NamedUnknown ) name = Handle( Expr_NamedUnknown )::DownCast( subexpr );
+    if( !name.IsNull() )
+    {
+      if( name->GetName()!="t" )
+        res = false;
+    }
+    else
+      res = isCorrect( subexpr );
+  }
+  return res;
+}
+
+//================================================================================
+/*! this function parses the expression 'str' in order to check if syntax is correct
+ *  ( result in 'syntax' ) and if only 't' is unknown variable in expression ( result in 'args' )
+ */
+//================================================================================
+void casProcess( const TCollection_AsciiString& str, bool& syntax, bool& args )
+{
+  // check validity of expression
+  syntax = false;
+  args = false;
+  try
+  {
+    Handle( ExprIntrp_GenExp ) gen = ExprIntrp_GenExp::Create();
+    gen->Process( str );
+        
+    if( gen->IsDone() ) 
+    {
+      syntax = true;
+      args = isCorrect( gen->Expression() );
+    }
+  }
+  catch (Standard_Failure)
+  {
+  }
+}
+
+//================================================================================
+/*!
+ * 
+ */
+//================================================================================
+
+void StdMeshers_NumberOfSegments::SetExpressionFunction(const char* expr)
+  throw(SALOME_Exception)
+{
+  if (_distrType != DT_ExprFunc)
+    throw SALOME_Exception(LOCALIZED("not an expression function distribution"));
+
+  // remove white spaces
+  TCollection_AsciiString str((Standard_CString)expr);
+  str.RemoveAll(' ');
+  str.RemoveAll('\t');
+  str.RemoveAll('\r');
+  str.RemoveAll('\n');
+
+  bool syntax, args;
+  casProcess( str, syntax, args );
+  if( !syntax )
+    throw SALOME_Exception(LOCALIZED("invalid expression syntax"));
+  if( !args )
+    throw SALOME_Exception(LOCALIZED("only 't' may be used as function argument"));
+
+  string func(str.ToCString());
+  if (_func != func)
+  {
+    _func = func;
+    NotifySubMeshesHypothesisModification();
+  }
+}
+
+//================================================================================
+/*!
+ * 
+ */
+//================================================================================
+
+const char* StdMeshers_NumberOfSegments::GetExpressionFunction() const
+  throw(SALOME_Exception)
+{
+  if (_distrType != DT_ExprFunc)
+    throw SALOME_Exception(LOCALIZED("not an expression function distribution"));
+  return _func.c_str();
+}
+
+//================================================================================
+/*!
+ * 
+ */
+//================================================================================
+
+void StdMeshers_NumberOfSegments::SetExponentMode(bool isExp)
+  throw(SALOME_Exception)
+{
+  if (_distrType != DT_TabFunc && _distrType != DT_ExprFunc)
+    throw SALOME_Exception(LOCALIZED("not a functional distribution"));
+
+  if (isExp != _expMode)
+  {
+    _expMode = isExp;
+    NotifySubMeshesHypothesisModification();
+  }
+}
+
+//================================================================================
+/*!
+ * 
+ */
+//================================================================================
+
+bool StdMeshers_NumberOfSegments::IsExponentMode() const
+  throw(SALOME_Exception)
+{
+  if (_distrType != DT_TabFunc && _distrType != DT_ExprFunc)
+    throw SALOME_Exception(LOCALIZED("not a functional distribution"));
+  return _expMode;
 }
 
 //=============================================================================
 }
 
 //=============================================================================
@@ -120,7 +359,29 @@ double StdMeshers_NumberOfSegments::GetScaleFactor() const
 
 ostream & StdMeshers_NumberOfSegments::SaveTo(ostream & save)
 {
 
 ostream & StdMeshers_NumberOfSegments::SaveTo(ostream & save)
 {
-  save << this->_numberOfSegments << " " << this->_scaleFactor;
+  save << _numberOfSegments << " " << (int)_distrType;
+  switch (_distrType)
+  {
+  case DT_Scale:
+    save << " " << _scaleFactor;
+    break;
+  case DT_TabFunc:
+    int i;
+    save << " " << _table.size();
+    for (i=0; i < _table.size(); i++)
+      save << " " << _table[i];
+    break;
+  case DT_ExprFunc:
+    save << " " << _func;
+    break;
+  case DT_Regular:
+  default:
+    break;
+  }
+
+  if (_distrType == DT_TabFunc || _distrType == DT_ExprFunc)
+    save << " " << (int)_expMode;
+  
   return save;
 }
 
   return save;
 }
 
@@ -134,17 +395,81 @@ istream & StdMeshers_NumberOfSegments::LoadFrom(istream & load)
 {
   bool isOK = true;
   int a;
 {
   bool isOK = true;
   int a;
+
+  // read number of segments
   isOK = (load >> a);
   if (isOK)
   isOK = (load >> a);
   if (isOK)
-    this->_numberOfSegments = a;
+    _numberOfSegments = a;
   else
     load.clear(ios::badbit | load.rdstate());
   else
     load.clear(ios::badbit | load.rdstate());
-  double b;
-  isOK = (load >> b);
+
+  // read ditribution type
+  isOK = (load >> a);
   if (isOK)
   if (isOK)
-    this->_scaleFactor = b;
+  {
+    if (a < DT_Regular || a > DT_ExprFunc)
+      _distrType = DT_Regular;
+    else
+      _distrType = (DistrType) a;
+  }
   else
     load.clear(ios::badbit | load.rdstate());
   else
     load.clear(ios::badbit | load.rdstate());
+
+  // parameters of distribution
+  double b;
+  switch (_distrType)
+  {
+  case DT_Scale:
+    {
+      isOK = (load >> b);
+      if (isOK)
+        _scaleFactor = b;
+      else
+        load.clear(ios::badbit | load.rdstate());
+    }
+    break;
+  case DT_TabFunc:
+    {
+      isOK = (load >> a);
+      if (isOK)
+        _table.resize(a, 0.);
+      else
+        load.clear(ios::badbit | load.rdstate());
+      int i;
+      for (i=0; i < _table.size(); i++)
+      {
+        isOK = (load >> b);
+        if (isOK)
+          _table[i] = b;
+        else
+          load.clear(ios::badbit | load.rdstate());
+      }
+    }
+    break;
+  case DT_ExprFunc:
+    {
+      string str;
+      isOK = (load >> str);
+      if (isOK)
+        _func = str;
+      else
+        load.clear(ios::badbit | load.rdstate());
+    }
+    break;
+  case DT_Regular:
+  default:
+    break;
+  }
+
+  if (_distrType == DT_TabFunc || _distrType == DT_ExprFunc)
+  {
+    isOK = (load >> a);
+    if (isOK)
+      _expMode = (bool) a;
+    else
+      load.clear(ios::badbit | load.rdstate());
+  }
+
   return load;
 }
 
   return load;
 }
 
index 5ae8dc918e819c4637c3818de9afda375c7a8bf2..2f559fb040d6bd325d46bd591fc6b5681197a506 100644 (file)
 
 #include "SMESH_Hypothesis.hxx"
 #include "Utils_SALOME_Exception.hxx"
 
 #include "SMESH_Hypothesis.hxx"
 #include "Utils_SALOME_Exception.hxx"
+#include <vector>
 
 
+/*!
+ * \brief This class represents hypothesis for 1d algorithm
+ * 
+ * It provides parameters for subdivision an edge by various
+ * distribution types, considering the given number of resulting segments
+ */
 class StdMeshers_NumberOfSegments:
   public SMESH_Hypothesis
 {
 class StdMeshers_NumberOfSegments:
   public SMESH_Hypothesis
 {
@@ -40,15 +47,114 @@ public:
   StdMeshers_NumberOfSegments(int hypId, int studyId, SMESH_Gen* gen);
   virtual ~StdMeshers_NumberOfSegments();
 
   StdMeshers_NumberOfSegments(int hypId, int studyId, SMESH_Gen* gen);
   virtual ~StdMeshers_NumberOfSegments();
 
+  /*!
+   * \brief Set the number of segments
+    * \param segmentsNumber - must be greater than zero
+   */
   void SetNumberOfSegments(int segmentsNumber)
     throw (SALOME_Exception);
 
   void SetNumberOfSegments(int segmentsNumber)
     throw (SALOME_Exception);
 
+  /*!
+   * \brief Get the number of segments
+   */
   int GetNumberOfSegments() const;
 
   int GetNumberOfSegments() const;
 
+  /*!
+   * \brief This enumeration presents available types of distribution
+   */
+  enum DistrType
+  {
+    DT_Regular, //!< equidistant distribution
+    DT_Scale,   //!< scale distribution
+    DT_TabFunc, //!< distribution with density function presented by table
+    DT_ExprFunc //!< distribution with density function presented by expression
+  };
+
+  /*!
+   * \brief Set distribution type
+   */
+  void SetDistrType(DistrType typ)
+    throw (SALOME_Exception);
+
+  /*!
+   * \brief Get distribution type
+   */
+  DistrType GetDistrType() const;
+
+  /*!
+   * \brief Set scale factor for scale distribution
+   * \param scaleFactor - positive value different from 1
+   * 
+   * Throws SALOME_Exception if distribution type is not DT_Scale,
+   * or scaleFactor is not a positive value different from 1
+   */
   virtual void SetScaleFactor(double scaleFactor)
     throw (SALOME_Exception);
 
   virtual void SetScaleFactor(double scaleFactor)
     throw (SALOME_Exception);
 
-  double GetScaleFactor() const;
+  /*!
+   * \brief Get scale factor for scale distribution
+   * 
+   * Throws SALOME_Exception if distribution type is not DT_Scale
+   */
+  double GetScaleFactor() const
+    throw (SALOME_Exception);
+
+  /*!
+   * \brief Set table function for distribution DT_TabFunc
+    * \param table - this vector contains the pairs (parameter, value)
+   * following each by other, so the number of elements in the vector
+   * must be even. The parameters must be in range [0,1] and sorted in
+   * increase order. The values of function must be positive.
+   * 
+   * Throws SALOME_Exception if distribution type is not DT_TabFunc
+   */
+  void SetTableFunction(const std::vector<double>& table)
+    throw (SALOME_Exception);
+
+  /*!
+   * \brief Get table function for distribution DT_TabFunc
+   * 
+   * Throws SALOME_Exception if distribution type is not DT_TabFunc
+   */
+  const std::vector<double>& GetTableFunction() const
+    throw (SALOME_Exception);
+
+  /*!
+   * \brief Set expression function for distribution DT_ExprFunc
+    * \param expr - string containing the expression of the function
+    *               f(t), e.g. "sin(t)"
+   * 
+   * Throws SALOME_Exception if distribution type is not DT_ExprFunc
+   */
+  void SetExpressionFunction(const char* expr)
+    throw (SALOME_Exception);
+
+  /*!
+   * \brief Get expression function for distribution DT_ExprFunc
+   * 
+   * Throws SALOME_Exception if distribution type is not DT_ExprFunc
+   */
+  const char* GetExpressionFunction() const
+    throw (SALOME_Exception);
+
+  /*!
+   * \brief When exponent mode is set, the function of distribution of density
+   * is used as an exponent of 10, i,e, 10^f(t). This mode is sensible only when
+   * function distribution is used (DT_TabFunc or DT_ExprFunc)
+    * \param isExp - boolean switching on/off the mode
+   * 
+   * Throws SALOME_Exception if distribution type is not functional
+   */
+  void SetExponentMode(bool isExp)
+    throw (SALOME_Exception);
+
+  /*!
+   * \brief Returns true if the exponent mode is set
+   * 
+   * Throws SALOME_Exception if distribution type is not functional
+   */
+  bool IsExponentMode() const
+    throw (SALOME_Exception);
 
   virtual ostream & SaveTo(ostream & save);
   virtual istream & LoadFrom(istream & load);
 
   virtual ostream & SaveTo(ostream & save);
   virtual istream & LoadFrom(istream & load);
@@ -56,8 +162,12 @@ public:
   friend istream& operator >> (istream & load, StdMeshers_NumberOfSegments & hyp);
 
 protected:
   friend istream& operator >> (istream & load, StdMeshers_NumberOfSegments & hyp);
 
 protected:
-  int _numberOfSegments;
-  double _scaleFactor;
+  int                 _numberOfSegments; //!< an edge will be split on to this number of segments
+  DistrType           _distrType;        //!< the type of distribution of density function
+  double              _scaleFactor;      //!< the scale parameter for DT_Scale
+  std::vector<double> _table;            //!< the table for DT_TabFunc, a sequence of pairs of numbers
+  std::string         _func;             //!< the expression of the function for DT_ExprFunc
+  bool                _expMode;          //!< flag of exponent mode
 };
 
 #endif
 };
 
 #endif
index 017af4544b42d5b05d5f3e79ecf9c7b4e67bcd66..be3e69f1d9fcc6549ec165fc5308af920f886309 100644 (file)
@@ -44,6 +44,7 @@ using namespace std;
 #include "SMDS_EdgePosition.hxx"
 #include "SMESH_subMesh.hxx"
 
 #include "SMDS_EdgePosition.hxx"
 #include "SMESH_subMesh.hxx"
 
+#include "Utils_SALOME_Exception.hxx"
 #include "utilities.h"
 
 #include <BRep_Tool.hxx>
 #include "utilities.h"
 
 #include <BRep_Tool.hxx>
@@ -56,9 +57,14 @@ using namespace std;
 #include <GCPnts_UniformDeflection.hxx>
 #include <Standard_ErrorHandler.hxx>
 #include <Precision.hxx>
 #include <GCPnts_UniformDeflection.hxx>
 #include <Standard_ErrorHandler.hxx>
 #include <Precision.hxx>
+#include <Expr_GeneralExpression.hxx>
+#include <Expr_NamedUnknown.hxx>
+#include <Expr_Array1OfNamedUnknown.hxx>
+#include <TColStd_Array1OfReal.hxx>
+#include <ExprIntrp_GenExp.hxx>
 
 #include <string>
 
 #include <string>
-//#include <algorithm>
+#include <math.h>
 
 //=============================================================================
 /*!
 
 //=============================================================================
 /*!
@@ -131,9 +137,29 @@ bool StdMeshers_Regular_1D::CheckHypothesis
     const StdMeshers_NumberOfSegments * hyp =
       dynamic_cast <const StdMeshers_NumberOfSegments * >(theHyp);
     ASSERT(hyp);
     const StdMeshers_NumberOfSegments * hyp =
       dynamic_cast <const StdMeshers_NumberOfSegments * >(theHyp);
     ASSERT(hyp);
-    _value[ NB_SEGMENTS_IND  ] = hyp->GetNumberOfSegments();
-    _value[ SCALE_FACTOR_IND ] = hyp->GetScaleFactor();
-    ASSERT( _value[ NB_SEGMENTS_IND ] > 0 );
+    _ivalue[ NB_SEGMENTS_IND  ] = hyp->GetNumberOfSegments();
+    ASSERT( _ivalue[ NB_SEGMENTS_IND ] > 0 );
+    _ivalue[ DISTR_TYPE_IND ] = (int) hyp->GetDistrType();
+    switch (_ivalue[ DISTR_TYPE_IND ])
+    {
+    case StdMeshers_NumberOfSegments::DT_Scale:
+      _value[ SCALE_FACTOR_IND ] = hyp->GetScaleFactor();
+      break;
+    case StdMeshers_NumberOfSegments::DT_TabFunc:
+      _vvalue[ TAB_FUNC_IND ] = hyp->GetTableFunction();
+      break;
+    case StdMeshers_NumberOfSegments::DT_ExprFunc:
+      _svalue[ EXPR_FUNC_IND ] = hyp->GetExpressionFunction();
+      break;
+    case StdMeshers_NumberOfSegments::DT_Regular:
+      break;
+    default:
+      ASSERT(0);
+      break;
+    }
+    if (_ivalue[ DISTR_TYPE_IND ] == StdMeshers_NumberOfSegments::DT_TabFunc ||
+        _ivalue[ DISTR_TYPE_IND ] == StdMeshers_NumberOfSegments::DT_ExprFunc)
+      _ivalue[ EXP_MODE_IND ] = (int) hyp->IsExponentMode();
     _hypType = NB_SEGMENTS;
     aStatus = SMESH_Hypothesis::HYP_OK;
   }
     _hypType = NB_SEGMENTS;
     aStatus = SMESH_Hypothesis::HYP_OK;
   }
@@ -221,6 +247,265 @@ static void compensateError(double a1, double an,
   }
 }
 
   }
 }
 
+/*!
+ * \brief This class provides interface for a density function
+ */
+class Function
+{
+public:
+  Function(bool expMode) : _expMode(expMode) {}
+  double operator() (double t) const;
+  virtual bool IsReady() const = 0;
+protected:
+  virtual double compute(double t) const = 0;
+private:
+  bool _expMode;
+};
+
+/*!
+ * \brief This class provides computation of density function given by a table
+ */
+class TabFunction: public Function
+{
+public:
+  TabFunction(const vector<double>& table, bool expMode);
+  virtual bool IsReady() const;
+protected:
+  virtual double compute(double t) const;
+private:
+  const vector<double>& _table;
+};
+
+/*!
+ * \brief This class provides computation of density function given by an expression
+ */
+class ExprFunction: public Function
+{
+public:
+  ExprFunction(const char* expr, bool expMode);
+  virtual bool IsReady() const;
+protected:
+  virtual double compute(double t) const;
+private:
+  Handle(Expr_GeneralExpression) _expression;
+  Expr_Array1OfNamedUnknown _var;
+  mutable TColStd_Array1OfReal _val;
+};
+
+double Function::operator() (double t) const
+{
+  double res = compute(t);
+  if (_expMode)
+    res = pow(10, res);
+  return res;
+}
+
+TabFunction::TabFunction(const vector<double>& table, bool expMode)
+  : Function(expMode),
+    _table(table)
+{
+}
+
+bool TabFunction::IsReady() const
+{
+  return true;
+}
+
+double TabFunction::compute (double t) const
+{
+  //find place of <t> in table
+  int i;
+  for (i=0; i < _table.size()/2; i++)
+    if (_table[i*2] > t)
+      break;
+  if (i >= _table.size()/2)
+    i = _table.size()/2 - 1;
+
+  if (i == 0)
+    return _table[1];
+
+  // interpolate function value on found interval
+  // (t - x[i-1]) / (x[i] - x[i-1]) = (y - f[i-1]) / (f[i] - f[i-1])
+  // => y = f[i-1] + (f[i] - f[i-1]) * (t - x[i-1]) / (x[i] - x[i-1])
+  double x1 = _table[(i-1)*2];
+  double x2 = _table[i*2];
+  double y1 = _table[(i-1)*2+1];
+  double y2 = _table[i*2+1];
+  if (x2 - x1 < Precision::Confusion())
+    throw SALOME_Exception("TabFunction::compute : confused points");
+  return y1 + (y2 - y1) * ((t - x1) / (x2 - x1));
+}
+
+ExprFunction::ExprFunction(const char* expr, bool expMode)
+  : Function(expMode),
+    _var(1,1),
+    _val(1,1)
+{
+  Handle( ExprIntrp_GenExp ) gen = ExprIntrp_GenExp::Create();
+  gen->Process(TCollection_AsciiString((char*)expr));
+  if (gen->IsDone())
+  {
+    _expression = gen->Expression();
+    _var(1) = new Expr_NamedUnknown("t");
+  }
+}
+
+bool ExprFunction::IsReady() const
+{
+  return !_expression.IsNull();
+}
+
+double ExprFunction::compute (double t) const
+{
+  ASSERT(!_expression.IsNull());
+  _val(1) = t;
+  return _expression->Evaluate(_var, _val);
+}
+
+//================================================================================
+/*!
+ * \brief Compute next abscissa when two previous ones are given
+  * \param sm2 - before previous abscissa
+  * \param sm1 - previous abscissa
+  * \param func - function of density
+  * \param reverse - the direction of next abscissa, increase (0) or decrease (1)
+  * \retval double - the new abscissa
+ * 
+ * The abscissa s is given by the formulae
+ *
+ * ....|--------|----------------|.....
+ *    sm2      sm1               s
+ *
+ *    func(sm2) / func(sm1)  = (sm1-sm2) / (s-sm1)
+ * => (s-sm1) * func(sm2) = (sm1-sm2) * func(sm1)
+ * => s = sm1 + (sm1-sm2) * func(sm1) / func(sm2)
+ */
+//================================================================================
+
+static double nextAbscissa(double sm2, double sm1, const Function& func, int reverse)
+{
+  if (reverse)
+  {
+    sm1 = 1.0 - sm1;
+    sm2 = 1.0 - sm2;
+  }
+  return sm1 + (sm1-sm2) * func(sm1) / func(sm2);
+}
+
+//================================================================================
+/*!
+ * \brief Compute distribution of points on a curve following the law of a function
+  * \param C3d - the curve to discretize
+  * \param first - the first parameter on the curve 
+  * \param last - the last parameter on the curve 
+  * \param theReverse - flag indicating that the curve must be reversed
+  * \param nbSeg - number of output segments
+  * \param func - the function f(t)
+  * \param theParams - output points
+  * \retval bool  - true if success
+ */
+//================================================================================
+
+static bool computeParamByFunc(Adaptor3d_Curve& C3d, double first, double last,
+                               double length, bool theReverse, 
+                               int nbSeg, const Function& func,
+                               list<double>& theParams)
+{
+  if (!func.IsReady())
+    return false;
+  vector<double> xxx[2];
+  int nbPnt = 1 + nbSeg;
+  int rev, i;
+  for (rev=0; rev < 2; rev++)
+  {
+    // curv abscisses initialisation
+    vector<double> x(nbPnt, 0.);
+    // the first abscissa is 0.0
+
+    // The aim of the algorithm is to find a second abscisse x[1] such as the last
+    // one x[nbSeg] is very close to 1.0 with the epsilon precision
+
+    double x1_too_small = 0.0;
+    double x1_too_large = RealLast();
+    double x1 = 1.0/nbSeg;
+    while (1)
+    {
+      x[1] = x1;
+
+      // Check if the abscissa of the point 2 to N-1
+      // are in the segment ...
+
+      bool ok = true;
+      for (i=2; i <= nbSeg; i++)
+      {
+        x[i] = nextAbscissa(x[i-2], x[i-1], func, rev);
+        if (x[i] - 1.0 > Precision::Confusion())
+        {
+          x[nbSeg] = x[i];
+          ok = false;
+          break;
+        }
+      }
+      if (!ok)
+      {
+        // The segments are to large
+        // Decrease x1 ...
+        x1_too_large = x1;
+        x1 = (x1_too_small+x1_too_large)/2;
+        continue;
+      }
+
+      // Look at the abscissa of the point N
+      // which is to be close to 1.0
+
+      // break condition --> algo converged !!
+
+      if (1.0 - x[nbSeg] < Precision::Confusion())
+        break;
+
+      // not ok ...
+
+      x1_too_small = x1;
+
+      // Modify x1 value
+
+      if (x1_too_large > 1e100)
+        x1 = 2*x1;
+      else
+        x1 = (x1_too_small+x1_too_large)/2;
+    }
+    xxx[rev] = x;
+  }
+
+  // average
+  vector<double> x(nbPnt, 0.);
+  for (i=0; i < nbPnt; i++)
+    x[i] = (xxx[0][i] + (1.0 - xxx[1][nbPnt-i])) / 2;
+
+  // apply parameters in range [0,1] to the space of the curve
+  double prevU = first;
+  double sign = 1.;
+  if (theReverse)
+  {
+    prevU = last;
+    sign = -1.;
+  }
+  for (i = 1; i < nbSeg; i++)
+  {
+    double curvLength = length * (x[i] - x[i-1]) * sign;
+    GCPnts_AbscissaPoint Discret( C3d, curvLength, prevU );
+    if ( !Discret.IsDone() )
+      return false;
+    double U = Discret.Parameter();
+    if ( U > first && U < last )
+      theParams.push_back( U );
+    else
+      return false;
+    prevU = U;
+  }
+  return false;
+}
+
 //=============================================================================
 /*!
  *  
 //=============================================================================
 /*!
  *  
@@ -246,6 +531,7 @@ bool StdMeshers_Regular_1D::computeInternalParameters(const TopoDS_Edge& theEdge
     double eltSize = 1;
     if ( _hypType == LOCAL_LENGTH )
     {
     double eltSize = 1;
     if ( _hypType == LOCAL_LENGTH )
     {
+      // Local Length hypothesis
       double nbseg = ceil(length / _value[ BEG_LENGTH_IND ]); // integer sup
       if (nbseg <= 0)
         nbseg = 1;                        // degenerated edge
       double nbseg = ceil(length / _value[ BEG_LENGTH_IND ]); // integer sup
       if (nbseg <= 0)
         nbseg = 1;                        // degenerated edge
@@ -253,26 +539,47 @@ bool StdMeshers_Regular_1D::computeInternalParameters(const TopoDS_Edge& theEdge
     }
     else
     {
     }
     else
     {
-      double epsilon = 0.001;
-      if (fabs(_value[ SCALE_FACTOR_IND ] - 1.0) > epsilon)
+      // Number Of Segments hypothesis
+      switch (_ivalue[ DISTR_TYPE_IND ])
       {
       {
-        double scale = _value[ SCALE_FACTOR_IND ];
-        if ( theReverse )
-          scale = 1. / scale;
-        double alpha = pow( scale , 1.0 / (_value[ NB_SEGMENTS_IND ] - 1));
-        double factor = (l - f) / (1 - pow( alpha,_value[ NB_SEGMENTS_IND ]));
-
-        int i, NbPoints = 1 + (int) _value[ NB_SEGMENTS_IND ];
-        for ( i = 2; i < NbPoints; i++ )
+      case StdMeshers_NumberOfSegments::DT_Scale:
         {
         {
-          double param = f + factor * (1 - pow(alpha, i - 1));
-          theParams.push_back( param );
+          double scale = _value[ SCALE_FACTOR_IND ];
+          if ( theReverse )
+            scale = 1. / scale;
+          double alpha = pow( scale , 1.0 / (_ivalue[ NB_SEGMENTS_IND ] - 1));
+          double factor = (l - f) / (1 - pow( alpha,_ivalue[ NB_SEGMENTS_IND ]));
+
+          int i, NbPoints = 1 + _ivalue[ NB_SEGMENTS_IND ];
+          for ( i = 2; i < NbPoints; i++ )
+          {
+            double param = f + factor * (1 - pow(alpha, i - 1));
+            theParams.push_back( param );
+          }
+          return true;
         }
         }
-        return true;
-      }
-      else
-      {
-        eltSize = length / _value[ NB_SEGMENTS_IND ];
+        break;
+      case StdMeshers_NumberOfSegments::DT_TabFunc:
+        {
+          TabFunction func(_vvalue[ TAB_FUNC_IND ], (bool)_ivalue[ EXP_MODE_IND ]);
+          return computeParamByFunc(C3d, f, l, length, theReverse,
+                                    _ivalue[ NB_SEGMENTS_IND ], func,
+                                    theParams);
+        }
+        break;
+      case StdMeshers_NumberOfSegments::DT_ExprFunc:
+        {
+          ExprFunction func(_svalue[ EXPR_FUNC_IND ].c_str(), (bool)_ivalue[ EXP_MODE_IND ]);
+          return computeParamByFunc(C3d, f, l, length, theReverse,
+                                    _ivalue[ NB_SEGMENTS_IND ], func,
+                                    theParams);
+        }
+        break;
+      case StdMeshers_NumberOfSegments::DT_Regular:
+        eltSize = length / _ivalue[ NB_SEGMENTS_IND ];
+        break;
+      default:
+        return false;
       }
     }
 
       }
     }
 
index b9d61432b11189afdac127515b61ba5ab215c537..b02e21028ca105a94df59526151481cc92433248 100644 (file)
@@ -65,16 +65,32 @@ protected:
   enum HypothesisType { LOCAL_LENGTH, NB_SEGMENTS, BEG_END_LENGTH, DEFLECTION, ARITHMETIC_1D, NONE };
 
   enum ValueIndex {
   enum HypothesisType { LOCAL_LENGTH, NB_SEGMENTS, BEG_END_LENGTH, DEFLECTION, ARITHMETIC_1D, NONE };
 
   enum ValueIndex {
-    NB_SEGMENTS_IND  = 0,
-    SCALE_FACTOR_IND = 1,
+    SCALE_FACTOR_IND = 0,
     BEG_LENGTH_IND   = 0,
     END_LENGTH_IND   = 1,
     DEFLECTION_IND   = 0
     };
 
     BEG_LENGTH_IND   = 0,
     END_LENGTH_IND   = 1,
     DEFLECTION_IND   = 0
     };
 
+  enum IValueIndex {
+    NB_SEGMENTS_IND  = 0,
+    DISTR_TYPE_IND   = 1,
+    EXP_MODE_IND     = 2
+  };
+
+  enum VValueIndex {
+    TAB_FUNC_IND  = 0
+  };
+
+  enum SValueIndex {
+    EXPR_FUNC_IND  = 0
+  };
+
   HypothesisType _hypType;
 
   double _value[2];
   HypothesisType _hypType;
 
   double _value[2];
+  int    _ivalue[3];
+  std::vector<double> _vvalue[1];
+  std::string         _svalue[1];
 
   // a source of propagated hypothesis, is set by CheckHypothesis()
   // always called before Compute()
 
   // a source of propagated hypothesis, is set by CheckHypothesis()
   // always called before Compute()
index 93322c3e76b3255dd93e481f1e3bd45ddf2d953b..a5acb3b0637a954d88b195cbbc65675dc987dc94 100644 (file)
@@ -40,6 +40,8 @@
 #include "SUIT_Desktop.h"
 #include "SUIT_ResourceMgr.h"
 
 #include "SUIT_Desktop.h"
 #include "SUIT_ResourceMgr.h"
 
+#include <SalomeApp_Tools.h>
+
 #include <qobject.h>
 
 #include "utilities.h"
 #include <qobject.h>
 
 #include "utilities.h"
@@ -122,7 +124,17 @@ void StdMeshersGUI_HypothesisCreator::EditHypothesis
 
   bool modified = false;
   if ( SMESHGUI_aParameterDlg::Parameters( SMESHGUI::GetSMESHGUI(), paramList, QObject::tr("SMESH_VALUE")) )
 
   bool modified = false;
   if ( SMESHGUI_aParameterDlg::Parameters( SMESHGUI::GetSMESHGUI(), paramList, QObject::tr("SMESH_VALUE")) )
-    modified = StdMeshersGUI_Parameters::SetParameters( theHyp, paramList );
+  {
+    try
+    {
+      modified = StdMeshersGUI_Parameters::SetParameters( theHyp, paramList );
+    }
+    catch (const SALOME::SALOME_Exception& S_ex)
+    {
+      SalomeApp_Tools::QtCatchCorbaException(S_ex);
+      return;
+    }    
+  }
 
   if ( modified ) {
     //set new Attribute Comment for hypothesis which parameters were modified
 
   if ( modified ) {
     //set new Attribute Comment for hypothesis which parameters were modified
index b68b6d24c1008f527892c4f11ec5139e8324a8eb..d399b595c901ff70d6edfc5b5cf5129e6a386d95 100644 (file)
@@ -55,6 +55,8 @@
 #include <qpixmap.h>
 #include <qspinbox.h>
 #include <qtextedit.h>
 #include <qpixmap.h>
 #include <qspinbox.h>
 #include <qtextedit.h>
+#include <qcombobox.h>
+#include <qcheckbox.h>
 
 using namespace std;
 
 
 using namespace std;
 
@@ -86,19 +88,25 @@ void StdMeshersGUI_CreateHypothesisDlg::CreateDlgLayout(const QString & theCapti
   setCaption( theCaption );
 
   setSizeGripEnabled( TRUE );
   setCaption( theCaption );
 
   setSizeGripEnabled( TRUE );
-  QGridLayout* StdMeshersGUI_CreateHypothesisDlgLayout = new QGridLayout( this ); 
+  QVBoxLayout* StdMeshersGUI_CreateHypothesisDlgLayout = new QVBoxLayout( this ); 
   StdMeshersGUI_CreateHypothesisDlgLayout->setSpacing( 6 );
   StdMeshersGUI_CreateHypothesisDlgLayout->setMargin( 11 );
 
   /***************************************************************/
   StdMeshersGUI_CreateHypothesisDlgLayout->setSpacing( 6 );
   StdMeshersGUI_CreateHypothesisDlgLayout->setMargin( 11 );
 
   /***************************************************************/
-  iconLabel = new QLabel( this );
+  QFrame* titFrame = new QFrame( this );
+  QHBoxLayout* titLay = new QHBoxLayout( titFrame, 0, 0 );
+  
+  iconLabel = new QLabel( titFrame );
   iconLabel->setPixmap( theHypIcon );
   iconLabel->setScaledContents( false );
   iconLabel->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed ) );
   iconLabel->setPixmap( theHypIcon );
   iconLabel->setScaledContents( false );
   iconLabel->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed ) );
-  typeLabel = new QLabel( this );
+  typeLabel = new QLabel( titFrame );
   typeLabel->setText( theHypTypeName );
   typeLabel->setText( theHypTypeName );
-  StdMeshersGUI_CreateHypothesisDlgLayout->addWidget( iconLabel, 0, 0 );
-  StdMeshersGUI_CreateHypothesisDlgLayout->addWidget( typeLabel, 0, 1 );
+  titLay->addWidget( iconLabel, 0 );
+  titLay->addWidget( typeLabel, 0 );
+  titLay->addStretch( 1 );
+  
+  StdMeshersGUI_CreateHypothesisDlgLayout->addWidget( titFrame, 0);
     
   /***************************************************************/
   GroupC1 = new QGroupBox( this, "GroupC1" );
     
   /***************************************************************/
   GroupC1 = new QGroupBox( this, "GroupC1" );
@@ -118,51 +126,42 @@ void StdMeshersGUI_CreateHypothesisDlg::CreateDlgLayout(const QString & theCapti
   LineEdit_NameHypothesis = new QLineEdit( GroupC1, "LineEdit_NameHypothesis" );
   GroupC1Layout->addWidget( LineEdit_NameHypothesis, 0, 1 );
 
   LineEdit_NameHypothesis = new QLineEdit( GroupC1, "LineEdit_NameHypothesis" );
   GroupC1Layout->addWidget( LineEdit_NameHypothesis, 0, 1 );
 
-  myParamList.clear();
-  GetParameters( myHypType, myParamList );
-  ASSERT( !myParamList.empty() );
+  myParamMap.clear();
+  std::list<SMESHGUI_aParameterPtr> aParamList;
+  GetParameters( myHypType, aParamList );
+  ASSERT( !aParamList.empty() );
 
   /* Spin boxes with labels */
 
   /* Spin boxes with labels */
-  list<SMESHGUI_aParameterPtr>::iterator paramIt = myParamList.begin();
-  for ( int row = 1; paramIt != myParamList.end(); paramIt++ , row++ )
+  list<SMESHGUI_aParameterPtr>::iterator paramIt = aParamList.begin();
+  for ( int row = 1; paramIt != aParamList.end(); paramIt++ , row++ )
   {
     SMESHGUI_aParameterPtr param = (*paramIt);
     QLabel * label = new QLabel( GroupC1, "TextLabel" );
     GroupC1Layout->addWidget( label, row, 0 );
     label->setText( param->Label() );
   {
     SMESHGUI_aParameterPtr param = (*paramIt);
     QLabel * label = new QLabel( GroupC1, "TextLabel" );
     GroupC1Layout->addWidget( label, row, 0 );
     label->setText( param->Label() );
-    QWidget* aSpinWidget = 0;
-    switch ( param->GetType() ) {
-    case SMESHGUI_aParameter::DOUBLE: {
-      SMESHGUI_SpinBox* spin = new SMESHGUI_SpinBox( GroupC1 );
-      aSpinWidget = spin;
-      spin->setPrecision( 12 );
-      break;
-    }
-    case SMESHGUI_aParameter::INT: {
-      QSpinBox* spin = new QSpinBox( GroupC1 );
-      aSpinWidget = spin;
-      break;
-    }
-    case SMESHGUI_aParameter::TEXT: {
-      QTextEdit* edit = new QTextEdit( GroupC1 );
-      edit->setWordWrap( QTextEdit::NoWrap );
-      edit->setTextFormat( Qt::PlainText );
-      aSpinWidget = edit;
-      break;
-    }
-    default:;
-    }
-
-    if ( aSpinWidget ) {
-      GroupC1Layout->addWidget( aSpinWidget, row, 1 );
-      aSpinWidget->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Minimum ) );
-      aSpinWidget->setMinimumSize( 150, 0 );
-      param->InitializeWidget( aSpinWidget );
-      mySpinList.push_back( aSpinWidget );
+    QWidget* aWidget = param->CreateWidget( GroupC1 );
+
+    if ( aWidget ) {
+      GroupC1Layout->addWidget( aWidget, row, 1 );
+      aWidget->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Minimum ) );
+      aWidget->setMinimumSize( 150, 0 );
+
+      QString sig = param->sigValueChanged();
+      if( !sig.isEmpty() && param->GetType()!=SMESHGUI_aParameter::TABLE )
+        connect( aWidget, sig.latin1(), this, SLOT( onValueChanged() ) );
+         
+      param->InitializeWidget( aWidget );
+
+      ParamInfo info;
+      info.editor = aWidget;
+      info.label = label;
+      info.order = row-1;
+      
+      myParamMap.insert( param, info );
     }
   }
   
     }
   }
   
-  StdMeshersGUI_CreateHypothesisDlgLayout->addMultiCellWidget(GroupC1 , 1, 1, 0, 1 );
+  StdMeshersGUI_CreateHypothesisDlgLayout->addWidget( GroupC1, 1 );
 
   /***************************************************************/
   GroupButtons = new QGroupBox( this, "GroupButtons" );
 
   /***************************************************************/
   GroupButtons = new QGroupBox( this, "GroupButtons" );
@@ -188,7 +187,7 @@ void StdMeshersGUI_CreateHypothesisDlg::CreateDlgLayout(const QString & theCapti
   buttonCancel->setText( tr( "SMESH_BUT_CLOSE"  ) );
   buttonCancel->setAutoDefault( TRUE );
   GroupButtonsLayout->addWidget( buttonCancel, 0, 3 );
   buttonCancel->setText( tr( "SMESH_BUT_CLOSE"  ) );
   buttonCancel->setAutoDefault( TRUE );
   GroupButtonsLayout->addWidget( buttonCancel, 0, 3 );
-  StdMeshersGUI_CreateHypothesisDlgLayout->addMultiCellWidget( GroupButtons, 2, 2, 0, 1 );
+  StdMeshersGUI_CreateHypothesisDlgLayout->addWidget( GroupButtons, 0 );
 
   /***************************************************************/
   Init() ;
 
   /***************************************************************/
   Init() ;
@@ -211,6 +210,11 @@ StdMeshersGUI_CreateHypothesisDlg::~StdMeshersGUI_CreateHypothesisDlg()
 //=================================================================================
 void StdMeshersGUI_CreateHypothesisDlg::Init()
 {
 //=================================================================================
 void StdMeshersGUI_CreateHypothesisDlg::Init()
 {
+  ParameterMap::const_iterator anIt = myParamMap.begin(),
+                               aLast = myParamMap.end();
+  for( ; anIt!=aLast; anIt++ )
+    UpdateShown( anIt.key() );
+   
   mySMESHGUI = SMESHGUI::GetSMESHGUI() ;
 
   char* sHypType = const_cast<char*>(myHypType.latin1());
   mySMESHGUI = SMESHGUI::GetSMESHGUI() ;
 
   char* sHypType = const_cast<char*>(myHypType.latin1());
@@ -263,33 +267,49 @@ bool StdMeshersGUI_CreateHypothesisDlg::ClickOnApply()
 
   SUIT_OverrideCursor wc;
 
 
   SUIT_OverrideCursor wc;
 
+  SMESH::SMESH_Hypothesis_var Hyp = SMESH::SMESH_Hypothesis::_narrow
+      ( SMESH::CreateHypothesis( myHypType, myHypName, false ) ); // isAlgorithm
+  
   try {
   try {
-    SMESH::SMESH_Hypothesis_var Hyp = SMESH::SMESH_Hypothesis::_narrow
-      ( SMESH::CreateHypothesis (myHypType,
-                                myHypName,
-                                false )); // isAlgorithm
-    
-    list<SMESHGUI_aParameterPtr>::iterator paramIt = myParamList.begin();
-    list<QWidget*>::iterator              widgetIt = mySpinList.begin();
-    for ( ;
-         paramIt != myParamList.end() && widgetIt != mySpinList.end();
-         paramIt++ , widgetIt++ )
-      (*paramIt)->TakeValue( *widgetIt );
 
 
-    SetParameters( Hyp, myParamList );
+    list<SMESHGUI_aParameterPtr> aParamList;
+    ParameterMap::const_iterator anIt = myParamMap.begin(),
+                                 aLast = myParamMap.end();
+    for( int i=0; i<myParamMap.count(); i++ )
+      for( anIt=myParamMap.begin(); anIt!=aLast; anIt++ )
+        if( (*anIt).order==i )
+        {
+          anIt.key()->TakeValue( anIt.data().editor );
+          aParamList.push_back( anIt.key() );
+         break;
+        }
+
+    SetParameters( Hyp, aParamList );
 
     //set new Attribute Comment for hypothesis which parameters were set
     QString aParams = "";
 
     //set new Attribute Comment for hypothesis which parameters were set
     QString aParams = "";
-    StdMeshersGUI_Parameters::GetParameters( Hyp.in(), myParamList, aParams );
+    StdMeshersGUI_Parameters::GetParameters( Hyp.in(), aParamList, aParams );
     _PTR(SObject) SHyp = SMESH::FindSObject(Hyp.in());
     if (SHyp)
     _PTR(SObject) SHyp = SMESH::FindSObject(Hyp.in());
     if (SHyp)
-      if (!aParams.isEmpty()) {
-       SMESH::SetValue(SHyp, aParams);
-       mySMESHGUI->getApp()->objectBrowser()->updateTree();
+      if (!aParams.isEmpty())
+      {
+        SMESH::SetValue(SHyp, aParams);
+        mySMESHGUI->getApp()->objectBrowser()->updateTree();
       }
   }
       }
   }
-  catch (const SALOME::SALOME_Exception& S_ex) {
+  catch (const SALOME::SALOME_Exception& S_ex)
+  {
     wc.suspend();
     wc.suspend();
+
+    _PTR(SObject) SHyp = SMESH::FindSObject(Hyp.in());
+    _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
+    if( aStudy && !aStudy->GetProperties()->IsLocked() )
+    {
+      _PTR(StudyBuilder) aBuilder = aStudy->NewBuilder();
+      aBuilder->RemoveObjectWithChildren( SHyp );
+      mySMESHGUI->updateObjBrowser( true, 0 );
+    }
+    
     SalomeApp_Tools::QtCatchCorbaException(S_ex);
     return false;
   }
     SalomeApp_Tools::QtCatchCorbaException(S_ex);
     return false;
   }
@@ -355,3 +375,61 @@ void StdMeshersGUI_CreateHypothesisDlg::closeEvent( QCloseEvent* e )
   mySMESHGUI->ResetState();
   QDialog::closeEvent( e );
 }
   mySMESHGUI->ResetState();
   QDialog::closeEvent( e );
 }
+
+//=================================================================================
+// function : onValueChanged()
+// purpose  :
+//=================================================================================
+void StdMeshersGUI_CreateHypothesisDlg::onValueChanged()
+{
+  if( sender()->inherits( "QWidget" ) )
+  {
+    QWidget* w = ( QWidget* )sender();
+
+    SMESHGUI_aParameterPtr param;
+
+    ParameterMap::const_iterator anIt = myParamMap.begin(),
+                                 aLast = myParamMap.end();
+    for( ; anIt!=aLast; anIt++ )
+      if( anIt.data().editor == w )
+      {
+        param = anIt.key();
+        param->TakeValue( w );
+        UpdateShown( param );
+        break;
+      }
+  }
+}
+
+//=================================================================================
+// function : UpdateShown()
+// purpose  :
+//=================================================================================
+void StdMeshersGUI_CreateHypothesisDlg::UpdateShown( const SMESHGUI_aParameterPtr param )
+{
+  SMESHGUI_dependParameter* depPar = dynamic_cast<SMESHGUI_enumParameter*>( param.get() );
+  if( !depPar )
+    depPar = dynamic_cast<SMESHGUI_boolParameter*>( param.get() );
+
+  if( !depPar )
+    return;
+
+  SMESHGUI_dependParameter::ShownMap& map = depPar->shownMap();
+  if( map.isEmpty() )
+    return;
+
+  int val;
+  depPar->TakeValue( myParamMap[ param ].editor );
+  depPar->GetNewInt( val );
+  
+  bool hasValue = map.contains( val );
+
+  ParameterMap::const_iterator anIt = myParamMap.begin(),
+                                aLast = myParamMap.end();
+  for( ; anIt!=aLast; anIt++ )
+  {
+    bool shown = hasValue && map[ val ].contains( (*anIt).order );
+    (*anIt).editor->setShown( shown );
+    (*anIt).label->setShown( shown );
+  }
+}
index aa2a3eda9d21b1f99663ddeba35b3672161dc116..3230f8eefdca0d68b8c116501b13e050068e6adb 100644 (file)
 
 // QT Includes
 #include <qdialog.h>
 
 // QT Includes
 #include <qdialog.h>
+#include <qmap.h>
+#include <qpair.h>
 
 #include <SALOMEconfig.h>
 #include CORBA_SERVER_HEADER(SMESH_BasicHypothesis)
 
 #include "SMESHGUI_aParameter.h"
 
 
 #include <SALOMEconfig.h>
 #include CORBA_SERVER_HEADER(SMESH_BasicHypothesis)
 
 #include "SMESHGUI_aParameter.h"
 
-#include <list>
-
 class QGroupBox;
 class QLabel;
 class QLineEdit;
 class QGroupBox;
 class QLabel;
 class QLineEdit;
@@ -67,23 +67,34 @@ protected:
                         const QPixmap & hypIcon,
                         const QString & hypTypeName);
 
                         const QPixmap & hypIcon,
                         const QString & hypTypeName);
 
-    virtual void GetParameters(const QString & hypType,
-                               std::list<SMESHGUI_aParameterPtr> & params) = 0;
+    virtual void GetParameters( const QString& hypType,
+                                std::list<SMESHGUI_aParameterPtr>& ) = 0;
 
 
-    virtual bool SetParameters(SMESH::SMESH_Hypothesis_ptr theHyp,
-                              const std::list<SMESHGUI_aParameterPtr> & params) = 0;
+    virtual bool SetParameters( SMESH::SMESH_Hypothesis_ptr theHyp,
+                                                 const std::list<SMESHGUI_aParameterPtr> & params ) = 0;
 
 
+protected slots:
+    virtual void onValueChanged();
+    
 private:
 private:
-
+    void UpdateShown( const SMESHGUI_aParameterPtr );
     void Init() ;
     void closeEvent( QCloseEvent* e ) ;
     void enterEvent ( QEvent * ) ;
 
     void Init() ;
     void closeEvent( QCloseEvent* e ) ;
     void enterEvent ( QEvent * ) ;
 
-    SMESHGUI*  mySMESHGUI ;
-    QString    myHypType ;
-
-    std::list<QWidget*>               mySpinList;
-    std::list<SMESHGUI_aParameterPtr> myParamList;
+    SMESHGUI*  mySMESHGUI;
+    QString    myHypType;
+
+    typedef struct 
+    {
+      QWidget* editor;
+      QLabel*  label;
+      int      order;
+      
+    } ParamInfo;
+    
+    typedef QMap< SMESHGUI_aParameterPtr, ParamInfo > ParameterMap;
+    ParameterMap      myParamMap;
 
     QLabel*           iconLabel;
     QLabel*           typeLabel;
 
     QLabel*           iconLabel;
     QLabel*           typeLabel;
index b7e447b3e46c7258c33391da8d0df08126a859de..7d52876d96b7567e8858da08939ee21e5a823b59 100644 (file)
@@ -65,7 +65,25 @@ void StdMeshersGUI_Parameters::SetInitValue(SMESHGUI_aParameterPtr param,
                                             int                    initValue)
 {
   SMESHGUI_intParameter* p = dynamic_cast<SMESHGUI_intParameter*>(param.get());
                                             int                    initValue)
 {
   SMESHGUI_intParameter* p = dynamic_cast<SMESHGUI_intParameter*>(param.get());
-  if ( p ) p->InitValue() = initValue;
+  if ( p )
+  {
+    p->InitValue() = initValue;
+    return;
+  }
+  
+  SMESHGUI_enumParameter* q = dynamic_cast<SMESHGUI_enumParameter*>(param.get());
+  if( q )
+  {
+    q->InitValue() = initValue;
+    return;
+  }
+
+  SMESHGUI_boolParameter* b = dynamic_cast<SMESHGUI_boolParameter*>(param.get());
+  if( b )
+  {
+    b->InitValue() = (bool)initValue;
+    return;
+  }
 }
 
 //=======================================================================
 }
 
 //=======================================================================
@@ -92,6 +110,21 @@ void StdMeshersGUI_Parameters::SetInitValue(SMESHGUI_aParameterPtr param,
   if ( p ) p->InitValue() = initValue;
 }
 
   if ( p ) p->InitValue() = initValue;
 }
 
+//=======================================================================
+//function : SetInitValue
+//purpose  :
+//=======================================================================
+void StdMeshersGUI_Parameters::SetInitValue( SMESHGUI_aParameterPtr param,
+                                             SMESH::double_array&   initValue)
+{
+  SMESHGUI_tableParameter* p = dynamic_cast<SMESHGUI_tableParameter*>(param.get());
+  if( p )
+  {
+    p->setRowCount( initValue.length()/2 );
+    p->setData( initValue );
+  }
+}
+
 //=======================================================================
 //function : GetParameters
 //purpose  : 
 //=======================================================================
 //function : GetParameters
 //purpose  : 
@@ -100,6 +133,9 @@ void StdMeshersGUI_Parameters::SetInitValue(SMESHGUI_aParameterPtr param,
 // SMESHGUI_doubleParameter( initValue, label, bottom, top, step, decimals )
 #define DOUBLE_PARAM(v,l,b,t,s,d) SMESHGUI_aParameterPtr(new SMESHGUI_doubleParameter(v,l,b,t,s,d))
 #define INT_PARAM(v,l,b,t) SMESHGUI_aParameterPtr(new SMESHGUI_intParameter(v,l,b,t))
 // SMESHGUI_doubleParameter( initValue, label, bottom, top, step, decimals )
 #define DOUBLE_PARAM(v,l,b,t,s,d) SMESHGUI_aParameterPtr(new SMESHGUI_doubleParameter(v,l,b,t,s,d))
 #define INT_PARAM(v,l,b,t) SMESHGUI_aParameterPtr(new SMESHGUI_intParameter(v,l,b,t))
+#define ENUM_PARAM(v,i,l) SMESHGUI_aParameterPtr(new SMESHGUI_enumParameter(v,i,l))
+#define STR_PARAM(i,l) SMESHGUI_aParameterPtr(new SMESHGUI_strParameter(i,l))
+#define BOOL_PARAM(i,l) SMESHGUI_aParameterPtr(new SMESHGUI_boolParameter(i,l))
 
 void StdMeshersGUI_Parameters::GetParameters (const QString&                 hypType,
                                               list<SMESHGUI_aParameterPtr> & paramList )
 
 void StdMeshersGUI_Parameters::GetParameters (const QString&                 hypType,
                                               list<SMESHGUI_aParameterPtr> & paramList )
@@ -114,12 +150,58 @@ void StdMeshersGUI_Parameters::GetParameters (const QString&                 hyp
   }
   else if (hypType.compare("NumberOfSegments") == 0)
   {
   }
   else if (hypType.compare("NumberOfSegments") == 0)
   {
+    //0-th parameter in list
     paramList.push_back ( INT_PARAM (3,
                                      QObject::tr("SMESH_NB_SEGMENTS_PARAM"),
                                      1, 9999 ));
     paramList.push_back ( INT_PARAM (3,
                                      QObject::tr("SMESH_NB_SEGMENTS_PARAM"),
                                      1, 9999 ));
+    QStringList types;
+    types.append( QObject::tr( "SMESH_DISTR_REGULAR" ) );
+    types.append( QObject::tr( "SMESH_DISTR_SCALE"   ) );
+    types.append( QObject::tr( "SMESH_DISTR_TAB"     ) );
+    types.append( QObject::tr( "SMESH_DISTR_EXPR"    ) );
+    //string description of distribution types
+
+    SMESHGUI_enumParameter* type = new SMESHGUI_enumParameter( types, 0, QObject::tr( "SMESH_DISTR_TYPE" ) );
+    SMESHGUI_dependParameter::ShownMap& aMap = type->shownMap();
+    aMap[0].append( 0 ); // if DistrType=0 (regular), then number of segments and types are shown (0-th and 1-th)
+    aMap[0].append( 1 );
+    aMap[1].append( 0 ); // if DistrType=1 (scale), then number of segments, types and scale are shown
+    aMap[1].append( 1 );
+    aMap[1].append( 2 );
+    aMap[2].append( 0 ); // if DistrType=2 (table), then number of segments, types, table and exponent are shown
+    aMap[2].append( 1 );
+    aMap[2].append( 3 );
+    aMap[2].append( 5 );
+    aMap[3].append( 0 ); // if DistrType=3 (expression), then number of segments, types, expression and exponent are shown
+    aMap[3].append( 1 );
+    aMap[3].append( 4 );
+    aMap[3].append( 5 );
+    //1-th parameter in list
+    paramList.push_back ( SMESHGUI_aParameterPtr( type ) );
+
+    //2-th parameter in list
     paramList.push_back ( DOUBLE_PARAM (1.0,
                                      QObject::tr("SMESH_NB_SEGMENTS_SCALE_PARAM"),
                                      VALUE_SMALL, VALUE_MAX, 0.1, 6 ));
     paramList.push_back ( DOUBLE_PARAM (1.0,
                                      QObject::tr("SMESH_NB_SEGMENTS_SCALE_PARAM"),
                                      VALUE_SMALL, VALUE_MAX, 0.1, 6 ));
+    SMESHGUI_tableParameter* tab = new SMESHGUI_tableParameter( 0.0, QObject::tr( "SMESH_TAB_FUNC" ) );
+    tab->setRowCount( 5 );
+    tab->setColCount( 2 );
+    //default size of table: 5x2
+    
+    tab->setColName( 0, "t" );
+    tab->setColName( 1, "f(t)" );    
+    tab->setValidator( 0, 0.0, 1.0, 3 );
+    tab->setValidator( 1, 1E-7, 1E+300, 3 );
+    tab->setEditRows( true );
+
+    //3-th parameter in list
+    paramList.push_back ( SMESHGUI_aParameterPtr( tab ) );
+
+    //4-th parameter in list
+    paramList.push_back ( STR_PARAM ( "", QObject::tr( "SMESH_EXPR_FUNC" ) ) );
+
+    //5-th parameter in list
+    paramList.push_back ( BOOL_PARAM ( false, QObject::tr( "SMESH_EXP_MODE" ) ) );
   }
   else if (hypType.compare("Arithmetic1D") == 0)
   {
   }
   else if (hypType.compare("Arithmetic1D") == 0)
   {
@@ -187,8 +269,34 @@ void StdMeshersGUI_Parameters::GetParameters (SMESH::SMESH_Hypothesis_ptr    the
   {
     StdMeshers::StdMeshers_NumberOfSegments_var NOS =
       StdMeshers::StdMeshers_NumberOfSegments::_narrow(theHyp);
   {
     StdMeshers::StdMeshers_NumberOfSegments_var NOS =
       StdMeshers::StdMeshers_NumberOfSegments::_narrow(theHyp);
-    SetInitValue( paramList.front(), (int) NOS->GetNumberOfSegments());
-    SetInitValue( paramList.back(), NOS->GetScaleFactor());
+      
+    list<SMESHGUI_aParameterPtr>::iterator anIt = paramList.begin();
+    SetInitValue( *anIt, (int) NOS->GetNumberOfSegments()); anIt++;
+    int DType = (int) NOS->GetDistrType();
+    SetInitValue( *anIt, DType ); anIt++;
+    
+    if( DType==1 )
+      SetInitValue( *anIt, NOS->GetScaleFactor());
+    anIt++;
+
+    if( DType==2 )
+    {
+      SMESH::double_array* tab_func = NOS->GetTableFunction();
+      SetInitValue( *anIt, *tab_func );
+      delete tab_func;
+    }
+    anIt++;
+
+    if( DType==3 )
+    {
+      char* expr_func = NOS->GetExpressionFunction();
+      SetInitValue( *anIt, expr_func );
+      delete expr_func;
+    }
+    anIt++;
+
+    if( DType==2 || DType==3 )
+      SetInitValue( *anIt, (bool)NOS->IsExponentMode());
   }
   else if (hypType.compare("Arithmetic1D") == 0)
   {
   }
   else if (hypType.compare("Arithmetic1D") == 0)
   {
@@ -237,17 +345,25 @@ void StdMeshersGUI_Parameters::GetParameters (SMESH::SMESH_Hypothesis_ptr
   for ( ; paramIt != paramList.end(); paramIt++) {
     if (params.compare("")) params += " ; ";
 
   for ( ; paramIt != paramList.end(); paramIt++) {
     if (params.compare("")) params += " ; ";
 
-    if ((*paramIt)->GetType() == SMESHGUI_aParameter::DOUBLE ) {
+    SMESHGUI_aParameter::Type t = (*paramIt)->GetType();
+    if( t==SMESHGUI_aParameter::DOUBLE )
+    {
       double aDoubleValue = 0.;
       (*paramIt)->GetNewDouble(aDoubleValue);
       params += QString::number(aDoubleValue);
     }
       double aDoubleValue = 0.;
       (*paramIt)->GetNewDouble(aDoubleValue);
       params += QString::number(aDoubleValue);
     }
-    else if ((*paramIt)->GetType() == SMESHGUI_aParameter::TEXT ) {
+    else if( t==SMESHGUI_aParameter::STRING || t==SMESHGUI_aParameter::ENUM )
+    {
       QString aStrValue( "" );
       (*paramIt)->GetNewText(aStrValue);
       params += aStrValue.simplifyWhiteSpace();
     }
       QString aStrValue( "" );
       (*paramIt)->GetNewText(aStrValue);
       params += aStrValue.simplifyWhiteSpace();
     }
-    else {
+    else if( t==SMESHGUI_aParameter::TABLE )
+    {
+      params += "TABLE";
+    }
+    else
+    {
       int aIntValue = 0;
       (*paramIt)->GetNewInt(aIntValue);
       params += QString::number(aIntValue);
       int aIntValue = 0;
       (*paramIt)->GetNewInt(aIntValue);
       params += QString::number(aIntValue);
@@ -281,12 +397,32 @@ bool StdMeshersGUI_Parameters::SetParameters(SMESH::SMESH_Hypothesis_ptr
   {
     StdMeshers::StdMeshers_NumberOfSegments_var NOS =
       StdMeshers::StdMeshers_NumberOfSegments::_narrow(theHyp);
   {
     StdMeshers::StdMeshers_NumberOfSegments_var NOS =
       StdMeshers::StdMeshers_NumberOfSegments::_narrow(theHyp);
-    int NbSeg = NOS->GetNumberOfSegments();
-    double Scale = NOS->GetScaleFactor() ;
-    modified = paramList.front()->GetNewInt( NbSeg );
-    modified = paramList.back()->GetNewDouble( Scale ) || modified;
-    NOS->SetNumberOfSegments(NbSeg);
-    NOS->SetScaleFactor( Scale );
+
+    list<SMESHGUI_aParameterPtr>::const_iterator anIt = paramList.begin();
+    int NbSeg, DType;
+    double Scale;
+    SMESH::double_array TabF;
+    QString exprF;
+    int expType;
+
+    modified = (*anIt)->GetNewInt( NbSeg ); anIt++;
+    modified = (*anIt)->GetNewInt( DType ) || modified; anIt++;
+    modified = (*anIt)->GetNewDouble( Scale ) || modified; anIt++;
+    SMESHGUI_aParameterPtr p = *anIt;
+    ((SMESHGUI_tableParameter*)p.get())->data( TabF ); anIt++; modified = true;
+    modified = (*anIt)->GetNewText( exprF ) || modified; anIt++;
+    modified = (*anIt)->GetNewInt( expType ) || modified;
+    
+    NOS->SetNumberOfSegments( NbSeg );
+    NOS->SetDistrType( DType );
+    if( DType==1 )
+      NOS->SetScaleFactor( Scale );
+    if( DType==2 )
+      NOS->SetTableFunction( TabF );
+    if( DType==3 )
+      NOS->SetExpressionFunction( CORBA::string_dup( exprF.latin1() ) );
+    if( DType==2 || DType==3 )
+      NOS->SetExponentMode( (bool)expType );
   }
   else if (hypType.compare("Arithmetic1D") == 0)
   {
   }
   else if (hypType.compare("Arithmetic1D") == 0)
   {
index 24fa2f70ceb11e479620fdd8db08558e697541d0..40be46f46e87e82efdd62013e90748c705015eb5 100644 (file)
 
 #include <SALOMEconfig.h>
 #include CORBA_SERVER_HEADER(SMESH_BasicHypothesis)
 
 #include <SALOMEconfig.h>
 #include CORBA_SERVER_HEADER(SMESH_BasicHypothesis)
+#include CORBA_SERVER_HEADER(SMESH_Mesh)
 
 #include "SMESHGUI_aParameter.h"
 
 #include <list>
 
 #include "SMESHGUI_aParameter.h"
 
 #include <list>
+#include <vector>
 
 class StdMeshersGUI_Parameters
 {
 
 class StdMeshersGUI_Parameters
 {
@@ -57,5 +59,7 @@ class StdMeshersGUI_Parameters
                            double                 initValue);
   static void SetInitValue(SMESHGUI_aParameterPtr param,
                            const char*            initValue);
                            double                 initValue);
   static void SetInitValue(SMESHGUI_aParameterPtr param,
                            const char*            initValue);
+  static void SetInitValue(SMESHGUI_aParameterPtr param,
+                           SMESH::double_array&   initValue);
 };
 #endif
 };
 #endif
index eef692b3bc14f45f7cd921a134ccca2770bc3e57..177b701890fa8515a8219b45eea9ae27c7aa92e8 100644 (file)
@@ -29,9 +29,33 @@ msgstr "Number of Segments"
 msgid "SMESH_NB_SEGMENTS_PARAM"
 msgstr "Number of Segments"
 
 msgid "SMESH_NB_SEGMENTS_PARAM"
 msgstr "Number of Segments"
 
+msgid "SMESH_DISTR_TYPE"
+msgstr "Type of distribution"
+
+msgid "SMESH_DISTR_REGULAR"
+msgstr "Equidistant distribution"
+
+msgid "SMESH_DISTR_SCALE"
+msgstr "Scale distribution"
+
+msgid "SMESH_DISTR_TAB"
+msgstr "Distribution with table density"
+
+msgid "SMESH_DISTR_EXPR"
+msgstr "Distribution with analitic density"
+
 msgid "SMESH_NB_SEGMENTS_SCALE_PARAM"
 msgstr "Scale Factor"
 
 msgid "SMESH_NB_SEGMENTS_SCALE_PARAM"
 msgstr "Scale Factor"
 
+msgid "SMESH_TAB_FUNC"
+msgstr "Table function"
+
+msgid "SMESH_EXPR_FUNC"
+msgstr "Density function f(t) = "
+
+msgid "SMESH_EXP_MODE"
+msgstr "Exponent mode "
+
 msgid "SMESH_NB_SEGMENTS_TITLE"
 msgstr "Hypothesis Construction"
 
 msgid "SMESH_NB_SEGMENTS_TITLE"
 msgstr "Hypothesis Construction"
 
index 356d19ad30900cd069a534f0dd4bb6c6312148bc..b4355a2ecfe90fe1fe3517d9432290a6ca01561f 100644 (file)
@@ -114,6 +114,37 @@ CORBA::Long StdMeshers_NumberOfSegments_i::GetNumberOfSegments()
   return this->GetImpl()->GetNumberOfSegments();
 }
 
   return this->GetImpl()->GetNumberOfSegments();
 }
 
+//=============================================================================
+/*!
+ */
+//=============================================================================
+
+void StdMeshers_NumberOfSegments_i::SetDistrType(CORBA::Long typ)
+  throw ( SALOME::SALOME_Exception )
+{
+  MESSAGE( "StdMeshers_NumberOfSegments_i::SetDistrType" );
+  ASSERT( myBaseImpl );
+  try {
+    this->GetImpl()->SetDistrType( (::StdMeshers_NumberOfSegments::DistrType) typ );
+  }
+  catch ( SALOME_Exception& S_ex ) {
+    THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
+                                 SALOME::BAD_PARAM );
+  }
+}
+
+//=============================================================================
+/*!
+ */
+//=============================================================================
+
+CORBA::Long StdMeshers_NumberOfSegments_i::GetDistrType()
+{
+  MESSAGE( "StdMeshers_NumberOfSegments_i::GetDistrType" );
+  ASSERT( myBaseImpl );
+  return this->GetImpl()->GetDistrType();
+}
+
 //=============================================================================
 /*!
  *  StdMeshers_NumberOfSegments_i::SetScaleFactor
 //=============================================================================
 /*!
  *  StdMeshers_NumberOfSegments_i::SetScaleFactor
@@ -145,10 +176,146 @@ void StdMeshers_NumberOfSegments_i::SetScaleFactor( CORBA::Double theScaleFactor
 //=============================================================================
 
 CORBA::Double StdMeshers_NumberOfSegments_i::GetScaleFactor()
 //=============================================================================
 
 CORBA::Double StdMeshers_NumberOfSegments_i::GetScaleFactor()
+  throw ( SALOME::SALOME_Exception )
 {
   MESSAGE( "StdMeshers_NumberOfSegments_i::GetScaleFactor" );
   ASSERT( myBaseImpl );
 {
   MESSAGE( "StdMeshers_NumberOfSegments_i::GetScaleFactor" );
   ASSERT( myBaseImpl );
-  return this->GetImpl()->GetScaleFactor();
+  double scale;
+  try {
+    scale = this->GetImpl()->GetScaleFactor();
+  }
+  catch ( SALOME_Exception& S_ex ) {
+    THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
+                                 SALOME::BAD_PARAM );
+  }
+  return scale;
+}
+
+//=============================================================================
+/*!
+ */
+//=============================================================================
+
+void StdMeshers_NumberOfSegments_i::SetTableFunction(const SMESH::double_array& table)
+  throw ( SALOME::SALOME_Exception )
+{
+  MESSAGE( "StdMeshers_NumberOfSegments_i::SetTableFunction" );
+  ASSERT( myBaseImpl );
+  std::vector<double> tbl( table.length() );
+  for (int i = 0; i < table.length(); i++)
+    tbl[i] = table[i];
+  try {
+    this->GetImpl()->SetTableFunction( tbl );
+  }
+  catch ( SALOME_Exception& S_ex ) {
+    THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
+                                 SALOME::BAD_PARAM );
+  }
+}
+
+//=============================================================================
+/*!
+ */
+//=============================================================================
+
+SMESH::double_array* StdMeshers_NumberOfSegments_i::GetTableFunction()
+  throw ( SALOME::SALOME_Exception )
+{
+  MESSAGE( "StdMeshers_NumberOfSegments_i::GetTableFunction" );
+  ASSERT( myBaseImpl );
+  const std::vector<double>* tbl;
+  try {
+    tbl = &this->GetImpl()->GetTableFunction();
+  }
+  catch ( SALOME_Exception& S_ex ) {
+    THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
+                                 SALOME::BAD_PARAM );
+  }
+  SMESH::double_array_var aRes = new SMESH::double_array();
+  aRes->length(tbl->size());
+  for (int i = 0; i < tbl->size(); i++)
+    aRes[i] = (*tbl)[i];
+  return aRes._retn();
+}
+
+//=============================================================================
+/*!
+ */
+//=============================================================================
+
+void StdMeshers_NumberOfSegments_i::SetExpressionFunction(const char* expr)
+  throw ( SALOME::SALOME_Exception )
+{
+  MESSAGE( "StdMeshers_NumberOfSegments_i::SetExpressionFunction" );
+  ASSERT( myBaseImpl );
+  try {
+    this->GetImpl()->SetExpressionFunction( expr );
+  }
+  catch ( SALOME_Exception& S_ex ) {
+    THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
+                                 SALOME::BAD_PARAM );
+  }
+}
+
+//=============================================================================
+/*!
+ */
+//=============================================================================
+
+char* StdMeshers_NumberOfSegments_i::GetExpressionFunction()
+  throw ( SALOME::SALOME_Exception )
+{
+  MESSAGE( "StdMeshers_NumberOfSegments_i::GetExpressionFunction" );
+  ASSERT( myBaseImpl );
+  const char* expr;
+  try {
+    expr = this->GetImpl()->GetExpressionFunction();
+  }
+  catch ( SALOME_Exception& S_ex ) {
+    THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
+                                 SALOME::BAD_PARAM );
+  }
+  return CORBA::string_dup(expr);
+}
+
+//=============================================================================
+/*!
+ */
+//=============================================================================
+
+void StdMeshers_NumberOfSegments_i::SetExponentMode(CORBA::Boolean isExp)
+  throw ( SALOME::SALOME_Exception )
+{
+  MESSAGE( "StdMeshers_NumberOfSegments_i::SetExponentMode" );
+  ASSERT( myBaseImpl );
+  try {
+    this->GetImpl()->SetExponentMode( isExp );
+  }
+  catch ( SALOME_Exception& S_ex ) {
+    THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
+                                 SALOME::BAD_PARAM );
+  }
+}
+
+//=============================================================================
+/*!
+ */
+//=============================================================================
+
+CORBA::Boolean StdMeshers_NumberOfSegments_i::IsExponentMode()
+  throw ( SALOME::SALOME_Exception )
+{
+  MESSAGE( "StdMeshers_NumberOfSegments_i::IsExponentMode" );
+  ASSERT( myBaseImpl );
+  bool isExp;
+  try {
+    isExp = this->GetImpl()->IsExponentMode();
+  }
+  catch ( SALOME_Exception& S_ex ) {
+    THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
+                                 SALOME::BAD_PARAM );
+  }
+  return isExp;
 }
 
 //=============================================================================
 }
 
 //=============================================================================
index e8a5030b140441743ea2b18a7d4a2b6ec5a1bd40..22e19d75f059acf4b667132888e09241c8e87465 100644 (file)
@@ -31,6 +31,7 @@
 #define _SMESH_NUMBEROFSEGMENTS_I_HXX_
 
 #include <SALOMEconfig.h>
 #define _SMESH_NUMBEROFSEGMENTS_I_HXX_
 
 #include <SALOMEconfig.h>
+#include CORBA_SERVER_HEADER(SMESH_Mesh)
 #include CORBA_SERVER_HEADER(SMESH_BasicHypothesis)
 
 #include "SMESH_Hypothesis_i.hxx"
 #include CORBA_SERVER_HEADER(SMESH_BasicHypothesis)
 
 #include "SMESH_Hypothesis_i.hxx"
@@ -57,11 +58,39 @@ public:
   // Get number of segments
   CORBA::Long GetNumberOfSegments();
 
   // Get number of segments
   CORBA::Long GetNumberOfSegments();
 
+  // Set distribution type
+  void SetDistrType(CORBA::Long typ)
+    throw ( SALOME::SALOME_Exception );
+  // Get distribution type
+  CORBA::Long GetDistrType();
+
   // Set scalar factor
   void SetScaleFactor( CORBA::Double theScaleFactor )
     throw ( SALOME::SALOME_Exception );
   // Get scalar factor
   // Set scalar factor
   void SetScaleFactor( CORBA::Double theScaleFactor )
     throw ( SALOME::SALOME_Exception );
   // Get scalar factor
-  CORBA::Double GetScaleFactor();
+  CORBA::Double GetScaleFactor()
+    throw ( SALOME::SALOME_Exception );
+
+  // Set table function for distribution DT_TabFunc
+  void SetTableFunction(const SMESH::double_array& table)
+    throw ( SALOME::SALOME_Exception );
+  // Get table function for distribution DT_TabFunc
+  SMESH::double_array* GetTableFunction()
+    throw ( SALOME::SALOME_Exception );
+
+  // Set expression function for distribution DT_ExprFunc
+  void SetExpressionFunction(const char* expr)
+    throw ( SALOME::SALOME_Exception );
+  // Get expression function for distribution DT_ExprFunc
+  char* GetExpressionFunction()
+    throw ( SALOME::SALOME_Exception );
+
+  // Set the exponent mode on/off
+  void SetExponentMode(CORBA::Boolean isExp)
+    throw ( SALOME::SALOME_Exception );
+  // Returns true if the exponent mode is set
+  CORBA::Boolean IsExponentMode()
+    throw ( SALOME::SALOME_Exception );
 
   // Get implementation
   ::StdMeshers_NumberOfSegments* GetImpl();
 
   // Get implementation
   ::StdMeshers_NumberOfSegments* GetImpl();