-// Copyright (C) 2007-2021 CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2024 CEA, EDF, OPEN CASCADE
//
// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
*/
//=============================================================================
-void StdMeshers_NumberOfSegments::SetNumberOfSegments(int segmentsNumber)
+void StdMeshers_NumberOfSegments::SetNumberOfSegments(smIdType segmentsNumber)
{
- int oldNumberOfSegments = _numberOfSegments;
+ smIdType oldNumberOfSegments = _numberOfSegments;
if (segmentsNumber <= 0)
throw SALOME_Exception(LOCALIZED("number of segments must be positive"));
_numberOfSegments = segmentsNumber;
*/
//=============================================================================
-int StdMeshers_NumberOfSegments::GetNumberOfSegments() const
+smIdType StdMeshers_NumberOfSegments::GetNumberOfSegments() const
{
return _numberOfSegments;
}
void StdMeshers_NumberOfSegments::SetDistrType(DistrType typ)
{
- if (typ < DT_Regular || typ > DT_ExprFunc)
+ if (!IsValidDistrType(typ))
throw SALOME_Exception(LOCALIZED("distribution type is out of range"));
if (typ != _distrType)
*/
//================================================================================
+bool StdMeshers_NumberOfSegments::IsValidDistrType(int distrType) const
+{
+ // DistrType is sequential, so we can just check against its first and last values
+ return distrType >= DT_Regular && distrType <= DT_BetaLaw;
+}
+
+//================================================================================
+/*!
+ *
+ */
+//================================================================================
+
void StdMeshers_NumberOfSegments::SetScaleFactor(double scaleFactor)
{
if (scaleFactor < PRECISION)
return _scaleFactor;
}
+//================================================================================
+/*!
+ *
+ */
+//================================================================================
+
+void StdMeshers_NumberOfSegments::SetBeta(double beta)
+{
+ if (_distrType != DT_BetaLaw)
+ throw SALOME_Exception(LOCALIZED("not a Beta Law distribution"));
+
+ const double diff = fabs(fabs(_beta) - fabs(beta));
+ if (diff <= PRECISION)
+ {
+ // Check for a special case where we have values with
+ // equal base but opposite signs like -1.01 and 1.01
+ if (std::signbit(_beta) == std::signbit(beta))
+ return;
+ }
+
+ _beta = beta;
+ NotifySubMeshesHypothesisModification();
+}
+
+//================================================================================
+/*!
+ *
+ */
+//================================================================================
+
+double StdMeshers_NumberOfSegments::GetBeta() const
+{
+ if (_distrType != DT_BetaLaw)
+ throw SALOME_Exception(LOCALIZED("not a Beta Law distribution"));
+ return _beta;
+}
+
//================================================================================
/*!
*
ostream & StdMeshers_NumberOfSegments::SaveTo(ostream & save)
{
- int listSize = _edgeIDs.size();
+ size_t listSize = _edgeIDs.size();
save << _numberOfSegments << " " << (int)_distrType;
switch (_distrType)
{
case DT_ExprFunc:
save << " " << _func;
break;
+ case DT_BetaLaw:
+ save << " " << _beta;
+ break;
case DT_Regular:
default:
break;
if ( _distrType != DT_Regular && listSize > 0 ) {
save << " " << listSize;
- for ( int i = 0; i < listSize; i++ )
+ for ( size_t i = 0; i < listSize; i++ )
save << " " << _edgeIDs[i];
save << " " << _objEntry;
}
// supposing that this hypothesis was written in the new format
if (isOK)
{
- if (a < DT_Regular || a > DT_ExprFunc)
+ if (!IsValidDistrType(a))
_distrType = DT_Regular;
else
_distrType = (DistrType) a;
}
}
break;
+
+ case DT_BetaLaw:
+ {
+ isOK = static_cast<bool>(load >> b);
+ if (isOK)
+ _beta = 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_Regular:
default:
break;