Version: 6.3.1
Public Types | Public Member Functions | Static Public Member Functions | Protected Attributes | Friends

StdMeshers_NumberOfSegments Class Reference

This class represents hypothesis for 1d algorithm. More...

#include <StdMeshers_NumberOfSegments.hxx>

Inheritance diagram for StdMeshers_NumberOfSegments:
Inheritance graph
[legend]

Public Types

enum  DistrType { DT_Regular, DT_Scale, DT_TabFunc, DT_ExprFunc }
 

This enumeration presents available types of distribution.

More...
enum  Hypothesis_Status {
  HYP_OK = 0, HYP_MISSING, HYP_CONCURENT, HYP_BAD_PARAMETER,
  HYP_HIDDEN_ALGO, HYP_HIDING_ALGO, HYP_UNKNOWN_FATAL, HYP_INCOMPATIBLE,
  HYP_NOTCONFORM, HYP_ALREADY_EXIST, HYP_BAD_DIM, HYP_BAD_SUBSHAPE,
  HYP_BAD_GEOMETRY, HYP_NEED_SHAPE
}
enum  hypothesis_type {
  PARAM_ALGO, ALGO_0D, ALGO_1D, ALGO_2D,
  ALGO_3D
}

Public Member Functions

 StdMeshers_NumberOfSegments (int hypId, int studyId, SMESH_Gen *gen)
virtual ~StdMeshers_NumberOfSegments ()
const std::vector< double > & BuildDistributionExpr (const char *, int, int) throw ( SALOME_Exception )
const std::vector< double > & BuildDistributionTab (const std::vector< double > &, int, int) throw ( SALOME_Exception )
void SetNumberOfSegments (int segmentsNumber) throw (SALOME_Exception)
 Set the number of segments.
int GetNumberOfSegments () const
 Get the number of segments.
void SetDistrType (DistrType typ) throw (SALOME_Exception)
 Set distribution type.
DistrType GetDistrType () const
 Get distribution type.
virtual void SetScaleFactor (double scaleFactor) throw (SALOME_Exception)
 Set scale factor for scale distribution.
double GetScaleFactor () const throw (SALOME_Exception)
 Get scale factor for scale distribution.
void SetTableFunction (const std::vector< double > &table) throw (SALOME_Exception)
 Set table function for distribution DT_TabFunc.
const std::vector< double > & GetTableFunction () const throw (SALOME_Exception)
 Get table function for distribution DT_TabFunc.
void SetExpressionFunction (const char *expr) throw (SALOME_Exception)
 Set expression function for distribution DT_ExprFunc.
const char * GetExpressionFunction () const throw (SALOME_Exception)
 Get expression function for distribution DT_ExprFunc.
void SetConversionMode (int conv) throw (SALOME_Exception)
 Set conversion mode.
int ConversionMode () const throw (SALOME_Exception)
 Returns conversion mode.
void SetReversedEdges (std::vector< int > &ids)
void SetObjectEntry (const char *entry)
const char * GetObjectEntry ()
const std::vector< int > & GetReversedEdges () const
virtual bool SetParametersByMesh (const SMESH_Mesh *theMesh, const TopoDS_Shape &theShape)
 Initialize number of segments by the mesh built on the geometry.
virtual bool SetParametersByDefaults (const TDefaults &dflts, const SMESH_Mesh *theMesh=0)
 Initialize my parameter values by default parameters.
virtual std::ostream & SaveTo (std::ostream &save)
virtual std::istream & LoadFrom (std::istream &load)
virtual int GetDim () const
int GetStudyId () const
virtual void NotifySubMeshesHypothesisModification ()
virtual int GetShapeType () const
virtual const char * GetLibName () const
void SetLibName (const char *theLibName)
void SetParameters (const char *theParameters)
char * GetParameters () const
void SetLastParameters (const char *theParameters)
char * GetLastParameters () const
void ClearParameters ()
virtual bool IsAuxiliary () const
 Return true if me is an auxiliary hypothesis.
SMESH_MeshGetMeshByPersistentID (int id)
 Find a mesh with given persistent ID.
const char * GetName () const
int GetID () const
int GetType () const
virtual bool operator== (const SMESHDS_Hypothesis &other) const
 Equality.
bool operator!= (const SMESHDS_Hypothesis &other) const

Static Public Member Functions

static bool IsStatusFatal (Hypothesis_Status theStatus)

Protected Attributes

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
std::vector< double > _distr
 the table for DT_TabFunc, a sequence of pairs of numbers
std::string _func
 the expression of the function for DT_ExprFunc
int _convMode
 flag of conversion mode: 0=exponent, 1=cut negative
std::vector< int_edgeIDs
 list of reversed edges ids
std::string _objEntry
 Entry of the main object to reverse edges.
SMESH_Gen_gen
int _studyId
int _shapeType
int _param_algo_dim
std::string _name
int _hypId
int _type

Friends

std::ostream & operator<< (std::ostream &save, StdMeshers_NumberOfSegments &hyp)
std::istream & operator>> (std::istream &load, StdMeshers_NumberOfSegments &hyp)

Detailed Description

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

Definition at line 44 of file StdMeshers_NumberOfSegments.hxx.


Member Enumeration Documentation

This enumeration presents available types of distribution.

Enumerator:
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

Definition at line 70 of file StdMeshers_NumberOfSegments.hxx.

Enumerator:
HYP_OK 
HYP_MISSING 
HYP_CONCURENT 
HYP_BAD_PARAMETER 
HYP_HIDDEN_ALGO 
HYP_HIDING_ALGO 
HYP_UNKNOWN_FATAL 
HYP_INCOMPATIBLE 
HYP_NOTCONFORM 
HYP_ALREADY_EXIST 
HYP_BAD_DIM 
HYP_BAD_SUBSHAPE 
HYP_BAD_GEOMETRY 
HYP_NEED_SHAPE 

Definition at line 50 of file SMESH_Hypothesis.hxx.

  {
    HYP_OK = 0,
    HYP_MISSING,      // algo misses a hypothesis
    HYP_CONCURENT,    // several applicable hypotheses
    HYP_BAD_PARAMETER,// hypothesis has a bad parameter value
    HYP_HIDDEN_ALGO,  // an algo is hidden by an upper dim algo generating all-dim elements
    HYP_HIDING_ALGO,  // an algo hides lower dim algos by generating all-dim elements
    HYP_UNKNOWN_FATAL,//  --- all statuses below should be considered as fatal
                      //      for Add/RemoveHypothesis operations
    HYP_INCOMPATIBLE, // hypothesis does not fit algo
    HYP_NOTCONFORM,   // not conform mesh is produced appling a hypothesis
    HYP_ALREADY_EXIST,// such hypothesis already exist
    HYP_BAD_DIM,      // bad dimension
    HYP_BAD_SUBSHAPE, // shape is neither the main one, nor its subshape, nor a group
    HYP_BAD_GEOMETRY, // shape geometry mismatches algorithm's expectation
    HYP_NEED_SHAPE    // algorithm can work on shape only
  };
Enumerator:
PARAM_ALGO 
ALGO_0D 
ALGO_1D 
ALGO_2D 
ALGO_3D 

Definition at line 53 of file SMESHDS_Hypothesis.hxx.


Constructor & Destructor Documentation

StdMeshers_NumberOfSegments::StdMeshers_NumberOfSegments ( int  hypId,
int  studyId,
SMESH_Gen gen 
)

Definition at line 65 of file StdMeshers_NumberOfSegments.cxx.

References SMESHDS_Hypothesis._name, and SMESH_Hypothesis._param_algo_dim.

  : SMESH_Hypothesis(hypId, studyId, gen),
    _numberOfSegments(15),//issue 19923
    _distrType(DT_Regular),
    _scaleFactor(1.),
    _convMode(1)  //cut negative by default
{
  _name = "NumberOfSegments";
  _param_algo_dim = 1;
}
StdMeshers_NumberOfSegments::~StdMeshers_NumberOfSegments ( ) [virtual]

Definition at line 84 of file StdMeshers_NumberOfSegments.cxx.

{
}

Member Function Documentation

const vector< double > & StdMeshers_NumberOfSegments::BuildDistributionExpr ( const char *  expr,
int  nbSeg,
int  conv 
) throw ( SALOME_Exception )

Definition at line 94 of file StdMeshers_NumberOfSegments.cxx.

References buildDistribution().

{
  if( !buildDistribution( TCollection_AsciiString( ( Standard_CString )expr ), conv, 0.0, 1.0, nbSeg, _distr, 1E-4 ) )
    _distr.resize( 0 );
  return _distr;
}
const vector< double > & StdMeshers_NumberOfSegments::BuildDistributionTab ( const std::vector< double > &  tab,
int  nbSeg,
int  conv 
) throw ( SALOME_Exception )

Definition at line 103 of file StdMeshers_NumberOfSegments.cxx.

References buildDistribution().

{
  if( !buildDistribution( tab, conv, 0.0, 1.0, nbSeg, _distr, 1E-4 ) )
    _distr.resize( 0 );
  return _distr;
}
void SMESH_Hypothesis.ClearParameters ( ) [inherited]
int StdMeshers_NumberOfSegments::ConversionMode ( ) const throw (SALOME_Exception)

Returns conversion mode.

Throws SALOME_Exception if distribution type is not functional

Definition at line 474 of file StdMeshers_NumberOfSegments.cxx.

References _convMode.

{
//   if (_distrType != DT_TabFunc && _distrType != DT_ExprFunc)
//     throw SALOME_Exception(LOCALIZED("not a functional distribution"));
  return _convMode;
}
int SMESH_Hypothesis::GetDim ( ) const [virtual, inherited]

Definition at line 74 of file SMESH_Hypothesis.cxx.

{
  int dim = 0;
  switch (_type)
    {
    case ALGO_1D: dim = 1; break;
    case ALGO_2D: dim = 2; break;
    case ALGO_3D: dim = 3; break;
    case PARAM_ALGO:
      dim = ( _param_algo_dim < 0 ) ? -_param_algo_dim : _param_algo_dim; break;
    }
  return dim;
}
StdMeshers_NumberOfSegments::DistrType StdMeshers_NumberOfSegments::GetDistrType ( ) const

Get distribution type.

Definition at line 167 of file StdMeshers_NumberOfSegments.cxx.

References _distrType.

{
  return _distrType;
}
const char * StdMeshers_NumberOfSegments::GetExpressionFunction ( ) const throw (SALOME_Exception)

Get expression function for distribution DT_ExprFunc.

Throws SALOME_Exception if distribution type is not DT_ExprFunc

Definition at line 441 of file StdMeshers_NumberOfSegments.cxx.

References _distrType, _func, and DT_ExprFunc.

{
  if (_distrType != DT_ExprFunc)
    throw SALOME_Exception(LOCALIZED("not an expression function distribution"));
  return _func.c_str();
}
int SMESHDS_Hypothesis::GetID ( ) const [inherited]

Definition at line 73 of file SMESHDS_Hypothesis.cxx.

Referenced by SMESHDS_Document.AddHypothesis(), and SMESH_Mesh_i.GetHypothesisList().

{
  return _hypId;
}
char* SMESH_Hypothesis.GetLastParameters ( ) const [inherited]
virtual const char* SMESH_Hypothesis.GetLibName ( ) const [virtual, inherited]
SMESH_Mesh * SMESH_Hypothesis::GetMeshByPersistentID ( int  id) [inherited]

Find a mesh with given persistent ID.

Definition at line 160 of file SMESH_Hypothesis.cxx.

References studyContextStruct.mapMesh, and PAL_MESH_041_mesh.mesh.

{
  StudyContextStruct* myStudyContext = _gen->GetStudyContext(_studyId);
  map<int, SMESH_Mesh*>::iterator itm = itm = myStudyContext->mapMesh.begin();
  for ( ; itm != myStudyContext->mapMesh.end(); itm++)
  {
    SMESH_Mesh* mesh = (*itm).second;
    if ( mesh->GetMeshDS()->GetPersistentId() == id )
      return mesh;
  }
  return 0;
}
const char * SMESHDS_Hypothesis::GetName ( ) const [inherited]
int StdMeshers_NumberOfSegments::GetNumberOfSegments ( ) const

Get the number of segments.

Definition at line 137 of file StdMeshers_NumberOfSegments.cxx.

References _numberOfSegments.

{
  return _numberOfSegments;
}
const char* StdMeshers_NumberOfSegments.GetObjectEntry ( )

Definition at line 169 of file StdMeshers_NumberOfSegments.hxx.

{ return _objEntry.c_str(); }
char* SMESH_Hypothesis.GetParameters ( ) const [inherited]
const std::vector<int>& StdMeshers_NumberOfSegments.GetReversedEdges ( ) const

Definition at line 171 of file StdMeshers_NumberOfSegments.hxx.

{ return _edgeIDs; }
double StdMeshers_NumberOfSegments::GetScaleFactor ( ) const throw (SALOME_Exception)

Get scale factor for scale distribution.

Throws SALOME_Exception if distribution type is not DT_Scale

Definition at line 202 of file StdMeshers_NumberOfSegments.cxx.

References _distrType, _scaleFactor, and DT_Scale.

{
  if (_distrType != DT_Scale)
    throw SALOME_Exception(LOCALIZED("not a scale distribution"));
  return _scaleFactor;
}
int SMESH_Hypothesis::GetShapeType ( ) const [virtual, inherited]

Definition at line 94 of file SMESH_Hypothesis.cxx.

{
  return _shapeType;
}
int SMESH_Hypothesis.GetStudyId ( ) const [inherited]
const vector< double > & StdMeshers_NumberOfSegments::GetTableFunction ( ) const throw (SALOME_Exception)

Get table function for distribution DT_TabFunc.

Throws SALOME_Exception if distribution type is not DT_TabFunc

Definition at line 283 of file StdMeshers_NumberOfSegments.cxx.

References _distrType, _table, and DT_TabFunc.

{
  if (_distrType != DT_TabFunc)
    throw SALOME_Exception(LOCALIZED("not a table function distribution"));
  return _table;
}
int SMESHDS_Hypothesis::GetType ( ) const [inherited]
virtual bool SMESH_Hypothesis.IsAuxiliary ( ) const [virtual, inherited]

Return true if me is an auxiliary hypothesis.

Return values:
bool- auxiliary or not

An auxiliary hypothesis is optional, i.e. an algorithm can work without it and another hypothesis of the same dimention can be assigned to the shape

Definition at line 114 of file SMESH_Hypothesis.hxx.

References SMESHDS_Hypothesis.GetType().

  { return GetType() == PARAM_ALGO && _param_algo_dim < 0; }
static bool SMESH_Hypothesis.IsStatusFatal ( Hypothesis_Status  theStatus) [static, inherited]
istream & StdMeshers_NumberOfSegments::LoadFrom ( std::istream &  load) [virtual]

Implements SMESHDS_Hypothesis.

Definition at line 530 of file StdMeshers_NumberOfSegments.cxx.

References _convMode, _distrType, _edgeIDs, _func, _numberOfSegments, _objEntry, _scaleFactor, _table, SMESH_demo_hexa2_upd.a, DT_ExprFunc, DT_Regular, DT_Scale, and DT_TabFunc.

Referenced by operator>>().

{
  bool isOK = true;
  int a;

  // read number of segments
  isOK = (load >> a);
  if (isOK)
    _numberOfSegments = a;
  else
    load.clear(ios::badbit | load.rdstate());

  // read second stored value. It can be two variants here:
  // 1. If the hypothesis is stored in old format (nb.segments and scale factor),
  //    we wait here the scale factor, which is double.
  // 2. If the hypothesis is stored in new format
  //    (nb.segments, distr.type, some other params.),
  //    we wait here the ditribution type, which is integer
  double scale_factor;
  isOK = (load >> scale_factor);
  a = (int)scale_factor;

  // try to interprete ditribution type,
  // supposing that this hypothesis was written in the new format
  if (isOK)
  {
    if (a < DT_Regular || a > DT_ExprFunc)
      _distrType = DT_Regular;
    else
      _distrType = (DistrType) a;
  }
  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());
        // this can mean, that the hypothesis is stored in old format
        _distrType = DT_Regular;
        _scaleFactor = scale_factor;
      }
    }
    break;
  case DT_TabFunc:
    {
      isOK = (load >> a);
      if (isOK)
      {
        _table.resize(a, 0.);
        int i;
        for (i=0; i < _table.size(); i++)
        {
          isOK = (load >> b);
          if (isOK)
            _table[i] = b;
          else
            load.clear(ios::badbit | load.rdstate());
        }
      }
      else
      {
        load.clear(ios::badbit | load.rdstate());
        // this can mean, that the hypothesis is stored in old format
        _distrType = DT_Regular;
        _scaleFactor = scale_factor;
      }
    }
    break;
  case DT_ExprFunc:
    {
      string str;
      isOK = (load >> str);
      if (isOK)
        _func = str;
      else
      {
        load.clear(ios::badbit | load.rdstate());
        // this can mean, that the hypothesis is stored in old format
        _distrType = DT_Regular;
        _scaleFactor = scale_factor;
      }
    }
    break;
  case DT_Regular:
  default:
    break;
  }

  if (_distrType == DT_TabFunc || _distrType == DT_ExprFunc)
  {
    isOK = (load >> a);
    if (isOK)
      _convMode = a;
    else
      load.clear(ios::badbit | load.rdstate());
  }

  // load reversed edges IDs
  int intVal;
  isOK = (load >> intVal);
  if ( isOK && _distrType != DT_Regular && intVal > 0 ) {
    _edgeIDs.reserve( intVal );
    for (int i = 0; i < _edgeIDs.capacity() && isOK; i++) {
      isOK = (load >> intVal);
      if ( isOK ) _edgeIDs.push_back( intVal );
    }
    isOK = (load >> _objEntry);
  }

  return load;
}
virtual void SMESH_Hypothesis.NotifySubMeshesHypothesisModification ( ) [virtual, inherited]
bool SMESHDS_Hypothesis.operator!= ( const SMESHDS_Hypothesis other) const [inherited]

Definition at line 51 of file SMESHDS_Hypothesis.hxx.

{ return !(*this==other); }
bool SMESHDS_Hypothesis::operator== ( const SMESHDS_Hypothesis other) const [virtual, inherited]

Equality.

Definition at line 95 of file SMESHDS_Hypothesis.cxx.

References SMESHDS_Hypothesis._name.

{
  if ( this == &other )
    return true;
  if ( _name != other._name )
    return false;
  ostringstream mySave, otherSave;
  ((SMESHDS_Hypothesis*)this  )->SaveTo(mySave);
  ((SMESHDS_Hypothesis*)&other)->SaveTo(otherSave);
  return mySave.str() == otherSave.str();
}
ostream & StdMeshers_NumberOfSegments::SaveTo ( std::ostream &  save) [virtual]

Implements SMESHDS_Hypothesis.

Definition at line 488 of file StdMeshers_NumberOfSegments.cxx.

References _convMode, _distrType, _edgeIDs, _func, _numberOfSegments, _objEntry, _scaleFactor, _table, DT_ExprFunc, DT_Regular, DT_Scale, and DT_TabFunc.

Referenced by operator<<().

{
  int listSize = _edgeIDs.size();
  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 << " " << _convMode;

  if ( _distrType != DT_Regular && listSize > 0 ) {
    save << " " << listSize;
    for ( int i = 0; i < listSize; i++ )
      save << " " << _edgeIDs[i];
    save << " " << _objEntry;
  }
  
  return save;
}
void StdMeshers_NumberOfSegments::SetConversionMode ( int  conv) throw (SALOME_Exception)

Set conversion mode.

When it is 0, it means "exponent mode": the function of distribution of density is used as an exponent of 10, i,e, 10^f(t). When it is 1, it means "cut negative mode". The function of distribution is used as F(t), where F(t0)=f(t0), if f(t0)>=0, otherwise F(t0) = 0. This mode is sensible only when function distribution is used (DT_TabFunc or DT_ExprFunc)

Throws SALOME_Exception if distribution type is not functional

Definition at line 455 of file StdMeshers_NumberOfSegments.cxx.

{
//   if (_distrType != DT_TabFunc && _distrType != DT_ExprFunc)
//     throw SALOME_Exception(LOCALIZED("not a functional distribution"));

  if( conv != _convMode )
  {
    _convMode = conv;
    NotifySubMeshesHypothesisModification();
  }
}
void StdMeshers_NumberOfSegments::SetDistrType ( DistrType  typ) throw (SALOME_Exception)

Set distribution type.

Definition at line 148 of file StdMeshers_NumberOfSegments.cxx.

{
  if (typ < DT_Regular || typ > DT_ExprFunc)
    throw SALOME_Exception(LOCALIZED("distribution type is out of range"));

  if (typ != _distrType)
  {
    _distrType = typ;
    NotifySubMeshesHypothesisModification();
  }
}
void StdMeshers_NumberOfSegments::SetExpressionFunction ( const char *  expr) throw (SALOME_Exception)

Set expression function for distribution DT_ExprFunc.

Parameters:
expr- string containing the expression of the function f(t), e.g. "sin(t)"

Throws SALOME_Exception if distribution type is not DT_ExprFunc

Definition at line 390 of file StdMeshers_NumberOfSegments.cxx.

References process(), and SMESH_AdvancedEditor.res.

{
  if (_distrType != DT_ExprFunc)
    _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, non_neg, singulars, non_zero;
  double sing_point;
  bool res = process( str, _convMode, syntax, args, non_neg, non_zero, singulars, sing_point );
  if( !res )
  {
    if( !syntax )
      throw SALOME_Exception(LOCALIZED("invalid expression syntax"));
    if( !args )
      throw SALOME_Exception(LOCALIZED("only 't' may be used as function argument"));
    if( !non_neg )
      throw SALOME_Exception(LOCALIZED("only non-negative function can be used as density"));
    if( singulars )
    {
      char buf[1024];
      sprintf( buf, "Function has singular point in %.3f", sing_point );
      throw SALOME_Exception( buf );
    }
    if( !non_zero )
      throw SALOME_Exception(LOCALIZED("f(t)=0 cannot be used as density"));

    return;
  }
  
  string func = expr;
  if( _func != func )
  {
    _func = func;
    NotifySubMeshesHypothesisModification();
  }
}
void SMESH_Hypothesis::SetLastParameters ( const char *  theParameters) [inherited]

Definition at line 224 of file SMESH_Hypothesis.cxx.

{
  _lastParameters = string(theParameters);
}
void SMESH_Hypothesis.SetLibName ( const char *  theLibName) [inherited]
void StdMeshers_NumberOfSegments::SetNumberOfSegments ( int  segmentsNumber) throw (SALOME_Exception)

Set the number of segments.

Parameters:
segmentsNumber- must be greater than zero

Definition at line 119 of file StdMeshers_NumberOfSegments.cxx.

{
  int oldNumberOfSegments = _numberOfSegments;
  if (segmentsNumber <= 0)
    throw SALOME_Exception(LOCALIZED("number of segments must be positive"));
  _numberOfSegments = segmentsNumber;

  if (oldNumberOfSegments != _numberOfSegments)
    NotifySubMeshesHypothesisModification();
}
void StdMeshers_NumberOfSegments.SetObjectEntry ( const char *  entry)

Definition at line 167 of file StdMeshers_NumberOfSegments.hxx.

{ _objEntry = entry; }
void SMESH_Hypothesis::SetParameters ( const char *  theParameters) [inherited]

Definition at line 178 of file SMESH_Hypothesis.cxx.

{
  string aNewParameters(theParameters);
  if(aNewParameters.size()==0 && _parameters.size()==0)
    aNewParameters = " ";
  if(_parameters.size()>0)
    _parameters +="|";
  _parameters +=aNewParameters;
  SetLastParameters(theParameters);
}
bool StdMeshers_NumberOfSegments::SetParametersByDefaults ( const TDefaults dflts,
const SMESH_Mesh theMesh = 0 
) [virtual]

Initialize my parameter values by default parameters.

Return values:
bool- true if parameter values have been successfully defined

Implements SMESH_Hypothesis.

Definition at line 718 of file StdMeshers_NumberOfSegments.cxx.

References SMESH_Hypothesis.TDefaults._nbSegments, and _numberOfSegments.

{
  return (_numberOfSegments = dflts._nbSegments );
}
bool StdMeshers_NumberOfSegments::SetParametersByMesh ( const SMESH_Mesh theMesh,
const TopoDS_Shape &  theShape 
) [virtual]

Initialize number of segments by the mesh built on the geometry.

Parameters:
theMesh- the built mesh
theShape- the geometry of interest
Return values:
bool- true if parameter values have been successfully defined

Implements SMESH_Hypothesis.

Definition at line 682 of file StdMeshers_NumberOfSegments.cxx.

References _distrType, _numberOfSegments, DT_Regular, SMESHDS_Mesh.MeshElements(), and SMESHDS_SubMesh.NbElements().

{
  if ( !theMesh || theShape.IsNull() )
    return false;

  _numberOfSegments = 0;
  _distrType = DT_Regular;

  int nbEdges = 0;
  TopTools_IndexedMapOfShape edgeMap;
  TopExp::MapShapes( theShape, TopAbs_EDGE, edgeMap );
  SMESHDS_Mesh* aMeshDS = const_cast< SMESH_Mesh* >( theMesh )->GetMeshDS();
  for ( int i = 1; i <= edgeMap.Extent(); ++i )
  {
    // get current segment length
    SMESHDS_SubMesh * eSubMesh = aMeshDS->MeshElements( edgeMap( i ));
    if ( eSubMesh && eSubMesh->NbElements())
      _numberOfSegments += eSubMesh->NbElements();

    ++nbEdges;
  }
  if ( nbEdges )
    _numberOfSegments /= nbEdges;

  if (_numberOfSegments == 0) _numberOfSegments = 1;

  return nbEdges;
}
void StdMeshers_NumberOfSegments::SetReversedEdges ( std::vector< int > &  ids)
void StdMeshers_NumberOfSegments::SetScaleFactor ( double  scaleFactor) throw (SALOME_Exception) [virtual]

Set scale factor for scale distribution.

Parameters:
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

Definition at line 178 of file StdMeshers_NumberOfSegments.cxx.

References PRECISION.

{
  if (_distrType != DT_Scale)
    _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"));

  if (fabs(_scaleFactor - scaleFactor) > PRECISION)
  {
    _scaleFactor = scaleFactor;
    NotifySubMeshesHypothesisModification();
  }
}
void StdMeshers_NumberOfSegments::SetTableFunction ( const std::vector< double > &  table) throw (SALOME_Exception)

Set table function for distribution DT_TabFunc.

Parameters:
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

Definition at line 216 of file StdMeshers_NumberOfSegments.cxx.

References Handle(), and PRECISION.

{
  if (_distrType != DT_TabFunc)
    _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();

  bool pos = false;
  for (i=0; i < table.size()/2; i++) {
    double par = table[i*2];
    double val = table[i*2+1];
    if( _convMode==0 )
    {
      try {
#ifdef NO_CAS_CATCH
        OCC_CATCH_SIGNALS;
#endif
        val = pow( 10.0, val );
      } catch(Standard_Failure) {
        Handle(Standard_Failure) aFail = Standard_Failure::Caught();
        throw SALOME_Exception( LOCALIZED( "invalid value"));
        return;
      }
    }
    else if( _convMode==1 && val<0.0 )
      val = 0.0;

    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 < 0 )
      throw SALOME_Exception(LOCALIZED("value of table function is not positive"));
    if( val>PRECISION )
      pos = true;
    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( !pos )
    throw SALOME_Exception(LOCALIZED("value of table function is not positive"));

  if( pos && !isSame )
  {
    _table = table;
    NotifySubMeshesHypothesisModification();
  }
}

Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  save,
StdMeshers_NumberOfSegments hyp 
) [friend]

Definition at line 657 of file StdMeshers_NumberOfSegments.cxx.

{
  return hyp.SaveTo( save );
}
std::istream& operator>> ( std::istream &  load,
StdMeshers_NumberOfSegments hyp 
) [friend]

Definition at line 668 of file StdMeshers_NumberOfSegments.cxx.

{
  return hyp.LoadFrom( load );
}

Field Documentation

flag of conversion mode: 0=exponent, 1=cut negative

Definition at line 198 of file StdMeshers_NumberOfSegments.hxx.

Referenced by ConversionMode(), LoadFrom(), and SaveTo().

std::vector<double> StdMeshers_NumberOfSegments._distr [protected]

the table for DT_TabFunc, a sequence of pairs of numbers

Definition at line 196 of file StdMeshers_NumberOfSegments.hxx.

the type of distribution of density function

Definition at line 194 of file StdMeshers_NumberOfSegments.hxx.

Referenced by GetDistrType(), GetExpressionFunction(), GetScaleFactor(), GetTableFunction(), LoadFrom(), SaveTo(), and SetParametersByMesh().

std::vector<int> StdMeshers_NumberOfSegments._edgeIDs [protected]

list of reversed edges ids

Definition at line 199 of file StdMeshers_NumberOfSegments.hxx.

Referenced by LoadFrom(), SaveTo(), and SetReversedEdges().

std::string StdMeshers_NumberOfSegments._func [protected]

the expression of the function for DT_ExprFunc

Definition at line 197 of file StdMeshers_NumberOfSegments.hxx.

Referenced by GetExpressionFunction(), LoadFrom(), and SaveTo().

SMESH_Gen* SMESH_Hypothesis._gen [protected, inherited]

Definition at line 123 of file SMESH_Hypothesis.hxx.

Referenced by SMESH_Hypothesis.SMESH_Hypothesis().

int SMESHDS_Hypothesis._hypId [protected, inherited]

Definition at line 57 of file SMESHDS_Hypothesis.hxx.

Referenced by SMESH_Hypothesis.SMESH_Hypothesis().

std::string SMESHDS_Hypothesis._name [protected, inherited]

Definition at line 56 of file SMESHDS_Hypothesis.hxx.

Referenced by SMESHDS_Hypothesis.operator==(), StdMeshers_Arithmetic1D.StdMeshers_Arithmetic1D(), StdMeshers_AutomaticLength.StdMeshers_AutomaticLength(), StdMeshers_Deflection1D.StdMeshers_Deflection1D(), StdMeshers_FixedPoints1D.StdMeshers_FixedPoints1D(), StdMeshers_ImportSource1D.StdMeshers_ImportSource1D(), StdMeshers_ImportSource2D.StdMeshers_ImportSource2D(), StdMeshers_LayerDistribution.StdMeshers_LayerDistribution(), StdMeshers_LayerDistribution2D.StdMeshers_LayerDistribution2D(), StdMeshers_LengthFromEdges.StdMeshers_LengthFromEdges(), StdMeshers_LocalLength.StdMeshers_LocalLength(), StdMeshers_MaxElementArea.StdMeshers_MaxElementArea(), StdMeshers_MaxElementVolume.StdMeshers_MaxElementVolume(), StdMeshers_MaxLength.StdMeshers_MaxLength(), StdMeshers_NotConformAllowed.StdMeshers_NotConformAllowed(), StdMeshers_NumberOfLayers.StdMeshers_NumberOfLayers(), StdMeshers_NumberOfLayers2D.StdMeshers_NumberOfLayers2D(), StdMeshers_NumberOfSegments(), StdMeshers_ProjectionSource1D.StdMeshers_ProjectionSource1D(), StdMeshers_ProjectionSource2D.StdMeshers_ProjectionSource2D(), StdMeshers_ProjectionSource3D.StdMeshers_ProjectionSource3D(), StdMeshers_Propagation.StdMeshers_Propagation(), StdMeshers_QuadrangleParams.StdMeshers_QuadrangleParams(), StdMeshers_QuadranglePreference.StdMeshers_QuadranglePreference(), StdMeshers_QuadraticMesh.StdMeshers_QuadraticMesh(), StdMeshers_StartEndLength.StdMeshers_StartEndLength(), StdMeshers_TrianglePreference.StdMeshers_TrianglePreference(), and StdMeshers_ViscousLayers.StdMeshers_ViscousLayers().

an edge will be split on to this number of segments

Definition at line 193 of file StdMeshers_NumberOfSegments.hxx.

Referenced by GetNumberOfSegments(), LoadFrom(), SaveTo(), SetParametersByDefaults(), and SetParametersByMesh().

std::string StdMeshers_NumberOfSegments._objEntry [protected]

Entry of the main object to reverse edges.

Definition at line 200 of file StdMeshers_NumberOfSegments.hxx.

Referenced by LoadFrom(), and SaveTo().

int SMESH_Hypothesis._param_algo_dim [protected, inherited]

Definition at line 126 of file SMESH_Hypothesis.hxx.

Referenced by SMESH_Hypothesis.SMESH_Hypothesis(), StdMeshers_Arithmetic1D.StdMeshers_Arithmetic1D(), StdMeshers_AutomaticLength.StdMeshers_AutomaticLength(), StdMeshers_Deflection1D.StdMeshers_Deflection1D(), StdMeshers_FixedPoints1D.StdMeshers_FixedPoints1D(), StdMeshers_ImportSource1D.StdMeshers_ImportSource1D(), StdMeshers_ImportSource2D.StdMeshers_ImportSource2D(), StdMeshers_LayerDistribution.StdMeshers_LayerDistribution(), StdMeshers_LayerDistribution2D.StdMeshers_LayerDistribution2D(), StdMeshers_LengthFromEdges.StdMeshers_LengthFromEdges(), StdMeshers_LocalLength.StdMeshers_LocalLength(), StdMeshers_MaxElementArea.StdMeshers_MaxElementArea(), StdMeshers_MaxElementVolume.StdMeshers_MaxElementVolume(), StdMeshers_MaxLength.StdMeshers_MaxLength(), StdMeshers_NotConformAllowed.StdMeshers_NotConformAllowed(), StdMeshers_NumberOfLayers.StdMeshers_NumberOfLayers(), StdMeshers_NumberOfLayers2D.StdMeshers_NumberOfLayers2D(), StdMeshers_NumberOfSegments(), StdMeshers_ProjectionSource1D.StdMeshers_ProjectionSource1D(), StdMeshers_ProjectionSource2D.StdMeshers_ProjectionSource2D(), StdMeshers_ProjectionSource3D.StdMeshers_ProjectionSource3D(), StdMeshers_Propagation.StdMeshers_Propagation(), StdMeshers_QuadrangleParams.StdMeshers_QuadrangleParams(), StdMeshers_QuadranglePreference.StdMeshers_QuadranglePreference(), StdMeshers_QuadraticMesh.StdMeshers_QuadraticMesh(), StdMeshers_StartEndLength.StdMeshers_StartEndLength(), StdMeshers_TrianglePreference.StdMeshers_TrianglePreference(), and StdMeshers_ViscousLayers.StdMeshers_ViscousLayers().

the scale parameter for DT_Scale

Definition at line 195 of file StdMeshers_NumberOfSegments.hxx.

Referenced by GetScaleFactor(), LoadFrom(), and SaveTo().

int SMESH_Hypothesis._shapeType [protected, inherited]

Definition at line 125 of file SMESH_Hypothesis.hxx.

Referenced by SMESH_Hypothesis.SMESH_Hypothesis().

int SMESH_Hypothesis._studyId [protected, inherited]

Definition at line 124 of file SMESH_Hypothesis.hxx.

Referenced by SMESH_Hypothesis.SMESH_Hypothesis().

std::vector<double> StdMeshers_NumberOfSegments._table [protected]

Definition at line 196 of file StdMeshers_NumberOfSegments.hxx.

Referenced by GetTableFunction(), LoadFrom(), and SaveTo().

int SMESHDS_Hypothesis._type [protected, inherited]

Definition at line 58 of file SMESHDS_Hypothesis.hxx.

Referenced by SMESH_Hypothesis.SMESH_Hypothesis().

Copyright © 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE
Copyright © 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS