make GetNumberOfSegments and GetScaleFactor const

This commit is contained in:
jrt 2003-09-04 09:13:24 +00:00
parent 5b889e3e3e
commit 0273fe09c6
2 changed files with 38 additions and 37 deletions

View File

@ -26,7 +26,6 @@
// Module : SMESH // Module : SMESH
// $Header$ // $Header$
using namespace std;
using namespace std; using namespace std;
#include "SMESH_NumberOfSegments.hxx" #include "SMESH_NumberOfSegments.hxx"
@ -36,12 +35,12 @@ using namespace std;
*/ */
//============================================================================= //=============================================================================
SMESH_NumberOfSegments::SMESH_NumberOfSegments(int hypId, int studyId, SMESH_Gen* gen) SMESH_NumberOfSegments::SMESH_NumberOfSegments(int hypId, int studyId,
: SMESH_Hypothesis(hypId, studyId, gen) SMESH_Gen * gen):SMESH_Hypothesis(hypId, studyId, gen)
{ {
_numberOfSegments = 1; _numberOfSegments = 1;
_scaleFactor = 1.0; _scaleFactor = 1.0;
_name = "NumberOfSegments"; _name = "NumberOfSegments";
} }
//============================================================================= //=============================================================================
@ -61,15 +60,16 @@ SMESH_NumberOfSegments::~SMESH_NumberOfSegments()
//============================================================================= //=============================================================================
void SMESH_NumberOfSegments::SetNumberOfSegments(int segmentsNumber) void SMESH_NumberOfSegments::SetNumberOfSegments(int segmentsNumber)
throw (SALOME_Exception) throw(SALOME_Exception)
{ {
int oldNumberOfSegments = _numberOfSegments; int oldNumberOfSegments = _numberOfSegments;
if (segmentsNumber <= 0) if (segmentsNumber <= 0)
throw SALOME_Exception(LOCALIZED("number of segments must be positive")); throw
_numberOfSegments = segmentsNumber; SALOME_Exception(LOCALIZED("number of segments must be positive"));
_numberOfSegments = segmentsNumber;
if (oldNumberOfSegments != _numberOfSegments) if (oldNumberOfSegments != _numberOfSegments)
NotifySubMeshesHypothesisModification(); NotifySubMeshesHypothesisModification();
} }
//============================================================================= //=============================================================================
@ -78,9 +78,9 @@ void SMESH_NumberOfSegments::SetNumberOfSegments(int segmentsNumber)
*/ */
//============================================================================= //=============================================================================
int SMESH_NumberOfSegments::GetNumberOfSegments() int SMESH_NumberOfSegments::GetNumberOfSegments() const
{ {
return _numberOfSegments; return _numberOfSegments;
} }
//============================================================================= //=============================================================================
@ -90,13 +90,13 @@ int SMESH_NumberOfSegments::GetNumberOfSegments()
//============================================================================= //=============================================================================
void SMESH_NumberOfSegments::SetScaleFactor(double scaleFactor) void SMESH_NumberOfSegments::SetScaleFactor(double scaleFactor)
throw (SALOME_Exception) throw(SALOME_Exception)
{ {
if (scaleFactor < 0) if (scaleFactor < 0)
throw SALOME_Exception(LOCALIZED("scale factor must be positive")); throw SALOME_Exception(LOCALIZED("scale factor must be positive"));
_scaleFactor = scaleFactor; _scaleFactor = scaleFactor;
NotifySubMeshesHypothesisModification(); NotifySubMeshesHypothesisModification();
} }
//============================================================================= //=============================================================================
@ -105,9 +105,9 @@ void SMESH_NumberOfSegments::SetScaleFactor(double scaleFactor)
*/ */
//============================================================================= //=============================================================================
double SMESH_NumberOfSegments::GetScaleFactor() double SMESH_NumberOfSegments::GetScaleFactor() const
{ {
return _scaleFactor; return _scaleFactor;
} }
//============================================================================= //=============================================================================
@ -118,7 +118,7 @@ double SMESH_NumberOfSegments::GetScaleFactor()
ostream & SMESH_NumberOfSegments::SaveTo(ostream & save) ostream & SMESH_NumberOfSegments::SaveTo(ostream & save)
{ {
return save << this; return save << this;
} }
//============================================================================= //=============================================================================
@ -129,7 +129,7 @@ ostream & SMESH_NumberOfSegments::SaveTo(ostream & save)
istream & SMESH_NumberOfSegments::LoadFrom(istream & load) istream & SMESH_NumberOfSegments::LoadFrom(istream & load)
{ {
return load >> (*this); return load >> (*this);
} }
//============================================================================= //=============================================================================
@ -138,10 +138,10 @@ istream & SMESH_NumberOfSegments::LoadFrom(istream & load)
*/ */
//============================================================================= //=============================================================================
ostream& operator << (ostream & save, SMESH_NumberOfSegments & hyp) ostream & operator <<(ostream & save, SMESH_NumberOfSegments & hyp)
{ {
save << hyp._numberOfSegments; save << hyp._numberOfSegments;
return save; return save;
} }
//============================================================================= //=============================================================================
@ -150,13 +150,14 @@ ostream& operator << (ostream & save, SMESH_NumberOfSegments & hyp)
*/ */
//============================================================================= //=============================================================================
istream& operator >> (istream & load, SMESH_NumberOfSegments & hyp) istream & operator >>(istream & load, SMESH_NumberOfSegments & hyp)
{ {
bool isOK = true; bool isOK = true;
int a; int a;
isOK = (load >> a); isOK = (load >> a);
if (isOK) hyp._numberOfSegments = a; if (isOK)
else load.clear(ios::badbit | load.rdstate()); hyp._numberOfSegments = a;
return load; else
load.clear(ios::badbit | load.rdstate());
return load;
} }

View File

@ -42,12 +42,12 @@ public:
void SetNumberOfSegments(int segmentsNumber) void SetNumberOfSegments(int segmentsNumber)
throw (SALOME_Exception); throw (SALOME_Exception);
int GetNumberOfSegments(); int GetNumberOfSegments() const;
void SetScaleFactor(double scaleFactor) void SetScaleFactor(double scaleFactor)
throw (SALOME_Exception); throw (SALOME_Exception);
double GetScaleFactor(); double GetScaleFactor() const;
virtual ostream & SaveTo(ostream & save); virtual ostream & SaveTo(ostream & save);
virtual istream & LoadFrom(istream & load); virtual istream & LoadFrom(istream & load);