Salome HOME
c16c1373ba4bca2d1bb8caa65d758a1a68c7be50
[modules/smesh.git] / src / StdMeshers / StdMeshers_NumberOfSegments.cxx
1 //  SMESH SMESH : implementaion of SMESH idl descriptions
2 //
3 //  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS 
5 // 
6 //  This library is free software; you can redistribute it and/or 
7 //  modify it under the terms of the GNU Lesser General Public 
8 //  License as published by the Free Software Foundation; either 
9 //  version 2.1 of the License. 
10 // 
11 //  This library is distributed in the hope that it will be useful, 
12 //  but WITHOUT ANY WARRANTY; without even the implied warranty of 
13 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
14 //  Lesser General Public License for more details. 
15 // 
16 //  You should have received a copy of the GNU Lesser General Public 
17 //  License along with this library; if not, write to the Free Software 
18 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA 
19 // 
20 //  See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
21 //
22 //
23 //
24 //  File   : StdMeshers_NumberOfSegments.cxx
25 //           Moved here from SMESH_NumberOfSegments.cxx
26 //  Author : Paul RASCLE, EDF
27 //  Module : SMESH
28 //  $Header$
29
30 using namespace std;
31 #include "StdMeshers_NumberOfSegments.hxx"
32
33 //=============================================================================
34 /*!
35  *  
36  */
37 //=============================================================================
38
39 StdMeshers_NumberOfSegments::StdMeshers_NumberOfSegments(int hypId, int studyId,
40         SMESH_Gen * gen):SMESH_Hypothesis(hypId, studyId, gen)
41 {
42         _numberOfSegments = 1;
43         _scaleFactor = 1.0;
44         _name = "NumberOfSegments";
45         _param_algo_dim = 1; 
46 }
47
48 //=============================================================================
49 /*!
50  *  
51  */
52 //=============================================================================
53
54 StdMeshers_NumberOfSegments::~StdMeshers_NumberOfSegments()
55 {
56 }
57
58 //=============================================================================
59 /*!
60  *  
61  */
62 //=============================================================================
63
64 void StdMeshers_NumberOfSegments::SetNumberOfSegments(int segmentsNumber)
65 throw(SALOME_Exception)
66 {
67         int oldNumberOfSegments = _numberOfSegments;
68         if (segmentsNumber <= 0)
69                 throw
70                         SALOME_Exception(LOCALIZED("number of segments must be positive"));
71         _numberOfSegments = segmentsNumber;
72
73         if (oldNumberOfSegments != _numberOfSegments)
74                 NotifySubMeshesHypothesisModification();
75 }
76
77 //=============================================================================
78 /*!
79  *  
80  */
81 //=============================================================================
82
83 int StdMeshers_NumberOfSegments::GetNumberOfSegments() const
84 {
85         return _numberOfSegments;
86 }
87
88 //=============================================================================
89 /*!
90  *  
91  */
92 //=============================================================================
93
94 void StdMeshers_NumberOfSegments::SetScaleFactor(double scaleFactor)
95 throw(SALOME_Exception)
96 {
97         if (scaleFactor < 0)
98                 throw SALOME_Exception(LOCALIZED("scale factor must be positive"));
99         _scaleFactor = scaleFactor;
100
101         NotifySubMeshesHypothesisModification();
102 }
103
104 //=============================================================================
105 /*!
106  *  
107  */
108 //=============================================================================
109
110 double StdMeshers_NumberOfSegments::GetScaleFactor() const
111 {
112         return _scaleFactor;
113 }
114
115 //=============================================================================
116 /*!
117  *  
118  */
119 //=============================================================================
120
121 ostream & StdMeshers_NumberOfSegments::SaveTo(ostream & save)
122 {
123   save << this->_numberOfSegments << " " << this->_scaleFactor;
124   return save;
125 }
126
127 //=============================================================================
128 /*!
129  *  
130  */
131 //=============================================================================
132
133 istream & StdMeshers_NumberOfSegments::LoadFrom(istream & load)
134 {
135   bool isOK = true;
136   int a;
137   isOK = (load >> a);
138   if (isOK)
139     this->_numberOfSegments = a;
140   else
141     load.clear(ios::badbit | load.rdstate());
142   double b;
143   isOK = (load >> b);
144   if (isOK)
145     this->_scaleFactor = b;
146   else
147     load.clear(ios::badbit | load.rdstate());
148   return load;
149 }
150
151 //=============================================================================
152 /*!
153  *  
154  */
155 //=============================================================================
156
157 ostream & operator <<(ostream & save, StdMeshers_NumberOfSegments & hyp)
158 {
159   return hyp.SaveTo( save );
160 }
161
162 //=============================================================================
163 /*!
164  *  
165  */
166 //=============================================================================
167
168 istream & operator >>(istream & load, StdMeshers_NumberOfSegments & hyp)
169 {
170   return hyp.LoadFrom( load );
171 }