Salome HOME
Add some comments
[modules/smesh.git] / src / SMESH / SMESH_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   : SMESH_NumberOfSegments.cxx
25 //  Author : Paul RASCLE, EDF
26 //  Module : SMESH
27 //  $Header$
28
29 using namespace std;
30 #include "SMESH_NumberOfSegments.hxx"
31
32 //=============================================================================
33 /*!
34  *  
35  */
36 //=============================================================================
37
38 SMESH_NumberOfSegments::SMESH_NumberOfSegments(int hypId, int studyId,
39         SMESH_Gen * gen):SMESH_Hypothesis(hypId, studyId, gen)
40 {
41         _numberOfSegments = 1;
42         _scaleFactor = 1.0;
43         _name = "NumberOfSegments";
44 }
45
46 //=============================================================================
47 /*!
48  *  
49  */
50 //=============================================================================
51
52 SMESH_NumberOfSegments::~SMESH_NumberOfSegments()
53 {
54 }
55
56 //=============================================================================
57 /*!
58  *  
59  */
60 //=============================================================================
61
62 void SMESH_NumberOfSegments::SetNumberOfSegments(int segmentsNumber)
63 throw(SALOME_Exception)
64 {
65         int oldNumberOfSegments = _numberOfSegments;
66         if (segmentsNumber <= 0)
67                 throw
68                         SALOME_Exception(LOCALIZED("number of segments must be positive"));
69         _numberOfSegments = segmentsNumber;
70
71         if (oldNumberOfSegments != _numberOfSegments)
72                 NotifySubMeshesHypothesisModification();
73 }
74
75 //=============================================================================
76 /*!
77  *  
78  */
79 //=============================================================================
80
81 int SMESH_NumberOfSegments::GetNumberOfSegments() const
82 {
83         return _numberOfSegments;
84 }
85
86 //=============================================================================
87 /*!
88  *  
89  */
90 //=============================================================================
91
92 void SMESH_NumberOfSegments::SetScaleFactor(double scaleFactor)
93 throw(SALOME_Exception)
94 {
95         if (scaleFactor < 0)
96                 throw SALOME_Exception(LOCALIZED("scale factor must be positive"));
97         _scaleFactor = scaleFactor;
98
99         NotifySubMeshesHypothesisModification();
100 }
101
102 //=============================================================================
103 /*!
104  *  
105  */
106 //=============================================================================
107
108 double SMESH_NumberOfSegments::GetScaleFactor() const
109 {
110         return _scaleFactor;
111 }
112
113 //=============================================================================
114 /*!
115  *  
116  */
117 //=============================================================================
118
119 ostream & SMESH_NumberOfSegments::SaveTo(ostream & save)
120 {
121         return save << this;
122 }
123
124 //=============================================================================
125 /*!
126  *  
127  */
128 //=============================================================================
129
130 istream & SMESH_NumberOfSegments::LoadFrom(istream & load)
131 {
132         return load >> (*this);
133 }
134
135 //=============================================================================
136 /*!
137  *  
138  */
139 //=============================================================================
140
141 ostream & operator <<(ostream & save, SMESH_NumberOfSegments & hyp)
142 {
143         save << hyp._numberOfSegments;
144         return save;
145 }
146
147 //=============================================================================
148 /*!
149  *  
150  */
151 //=============================================================================
152
153 istream & operator >>(istream & load, SMESH_NumberOfSegments & hyp)
154 {
155         bool isOK = true;
156         int a;
157         isOK = (load >> a);
158         if (isOK)
159                 hyp._numberOfSegments = a;
160         else
161                 load.clear(ios::badbit | load.rdstate());
162         return load;
163 }