Salome HOME
Merge with version on tag OCC-V2_1_0d
[modules/smesh.git] / src / StdMeshers / StdMeshers_Arithmetic1D.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_Arithmetic1D.cxx
25 //  Author : Damien COQUERET, OCC
26 //  Module : SMESH
27 //  $Header$
28
29 using namespace std;
30 #include "StdMeshers_Arithmetic1D.hxx"
31
32 //=============================================================================
33 /*!
34  *  
35  */
36 //=============================================================================
37
38 StdMeshers_Arithmetic1D::StdMeshers_Arithmetic1D(int hypId, int studyId,
39         SMESH_Gen * gen):SMESH_Hypothesis(hypId, studyId, gen)
40 {
41   _begLength = 1.;
42   _endLength = 1.;
43   _name = "Arithmetic1D";
44   _param_algo_dim = 1; 
45 }
46
47 //=============================================================================
48 /*!
49  *  
50  */
51 //=============================================================================
52
53 StdMeshers_Arithmetic1D::~StdMeshers_Arithmetic1D()
54 {
55 }
56
57 //=============================================================================
58 /*!
59  *  
60  */
61 //=============================================================================
62
63 void StdMeshers_Arithmetic1D::SetLength(double length, bool isStartLength)
64      throw(SALOME_Exception)
65 {
66   if ( (isStartLength ? _begLength : _endLength) != length ) {
67     if (length <= 0)
68       throw SALOME_Exception(LOCALIZED("length must be positive"));
69     if ( isStartLength )
70       _begLength = length;
71     else
72       _endLength = length;
73
74     NotifySubMeshesHypothesisModification();
75   }
76 }
77
78 //=============================================================================
79 /*!
80  *  
81  */
82 //=============================================================================
83
84 double StdMeshers_Arithmetic1D::GetLength(bool isStartLength) const
85 {
86   return isStartLength ? _begLength : _endLength;
87 }
88
89 //=============================================================================
90 /*!
91  *  
92  */
93 //=============================================================================
94
95 ostream & StdMeshers_Arithmetic1D::SaveTo(ostream & save)
96 {
97   save << _begLength << _endLength;
98   return save;
99 }
100
101 //=============================================================================
102 /*!
103  *  
104  */
105 //=============================================================================
106
107 istream & StdMeshers_Arithmetic1D::LoadFrom(istream & load)
108 {
109   bool isOK = true;
110   isOK = (load >> _begLength);
111   if (!isOK)
112     load.clear(ios::badbit | load.rdstate());
113   isOK = (load >> _endLength);
114   if (!isOK)
115     load.clear(ios::badbit | load.rdstate());
116   return load;
117 }
118
119 //=============================================================================
120 /*!
121  *  
122  */
123 //=============================================================================
124
125 ostream & operator <<(ostream & save, StdMeshers_Arithmetic1D & hyp)
126 {
127   return hyp.SaveTo( save );
128 }
129
130 //=============================================================================
131 /*!
132  *  
133  */
134 //=============================================================================
135
136 istream & operator >>(istream & load, StdMeshers_Arithmetic1D & hyp)
137 {
138   return hyp.LoadFrom( load );
139 }