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