]> SALOME platform Git repositories - modules/homard.git/blob - src/HOMARD/HOMARD_Cas.cxx
Salome HOME
83403f6ffb5792809847f53b34a5c18522fa93ce
[modules/homard.git] / src / HOMARD / HOMARD_Cas.cxx
1 //  HOMARD HOMARD : implementaion of HOMARD idl descriptions
2 //
3 // Copyright (C) 2011  CEA/DEN, EDF R&D
4 //
5 // This library is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU Lesser General Public
7 // License as published by the Free Software Foundation; either
8 // version 2.1 of the License.
9 //
10 // This library is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13 // Lesser General Public License for more details.
14 //
15 // You should have received a copy of the GNU Lesser General Public
16 // License along with this library; if not, write to the Free Software
17 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
18 //
19 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 //
21 //  File   : HOMARD_Cas.cxx
22 //  Author : Paul RASCLE, EDF
23 //  Module : HOMARD
24
25 #include "HOMARD_Cas.hxx"
26 #include "utilities.h"
27 #include <iostream>
28
29 //=============================================================================
30 /*!
31  *  default constructor:
32  *  Par defaut, l'adaptation est conforme, sans suivi de frontiere
33  */
34 //=============================================================================
35 HOMARD_Cas::HOMARD_Cas():
36   _NomCas(""), _NomDir("/tmp"), _ConfType(1)
37 {
38   MESSAGE("HOMARD_Cas");
39 }
40 //=============================================================================
41 HOMARD_Cas::~HOMARD_Cas()
42 //=============================================================================
43 {
44   MESSAGE("~HOMARD_Cas");
45 }
46
47 //=============================================================================
48 void HOMARD_Cas::SetDirName( const char* NomDir )
49 //=============================================================================
50 {
51      MESSAGE("SetDirName, NomDir :  "<<NomDir);
52      if (chdir(NomDir) == 0)
53      {
54        _NomDir = std::string( NomDir );
55      }
56     else 
57     {
58        // GERALD -- QMESSAGE BOX
59        // std::cerr << "Pb pour entrer dans le repertoire :  "<<NomDir << std::endl;
60        _NomDir = "/tmp";
61     };
62 }
63
64 //=============================================================================
65 std::string HOMARD_Cas::GetDirName() const
66 //=============================================================================
67 {
68   return _NomDir;
69 }
70
71 //=============================================================================
72 void HOMARD_Cas::SetName( const char* NomCas )
73 //=============================================================================
74 {
75   _NomCas = std::string( NomCas );
76 }
77
78 //=============================================================================
79 std::string HOMARD_Cas::GetName() const
80 //=============================================================================
81 {
82   return _NomCas;
83 }
84
85
86 //=============================================================================
87 std::string HOMARD_Cas::GetDumpPython() const
88 //=============================================================================
89 {
90   std::ostringstream aScript;
91   aScript << "\t" <<_NomCas << ".SetDirName('";
92   aScript << _NomDir << "')\n";
93   aScript << "\t" <<_NomCas << ".SetConfType(";
94   aScript << _ConfType << ")\n";
95 // Suivi de frontieres
96   std::list<std::string>::const_iterator it = _ListBoundaryGroup.begin();
97   while(it != _ListBoundaryGroup.end())
98   {
99     aScript << "\t" <<_NomCas << ".AddBoundaryGroup('";
100     aScript << *it << "', '";
101     it++;
102     aScript << *it << "')\n";
103     it++;
104   }
105   if ( _NivMax > 0 )
106   {
107     aScript << "\t" <<_NomCas << ".SetNivMax(";
108     aScript << _NivMax << ")\n";
109     aScript << "\t" <<_NomCas << ".SetDiamMin(";
110     aScript << _DiamMin << ")\n";
111   }
112   return aScript.str();
113 }
114 //=============================================================================
115 void HOMARD_Cas::AddIteration( const char* NomIteration )
116 //=============================================================================
117 {
118   _ListIter.push_back( std::string( NomIteration ) );
119 }
120
121 //=============================================================================
122 const std::list<std::string>& HOMARD_Cas::GetIterations() const
123 //=============================================================================
124 {
125   return _ListIter;
126 }
127
128 //=============================================================================
129 void HOMARD_Cas::SupprIterations()
130 //=============================================================================
131 {
132   _ListIter.clear();
133 }
134
135 //=============================================================================
136 std::string HOMARD_Cas::GetIter0Name() const
137 //=============================================================================
138 {
139 // Par construction de la liste, l'iteration a ete mise en tete.
140   return (*(_ListIter.begin()));
141 }
142
143 //=============================================================================
144 void HOMARD_Cas::SetConfType( int Conftype )
145 //=============================================================================
146 {
147   _ConfType = Conftype;
148 }
149 //=============================================================================
150 const int HOMARD_Cas::GetConfType() const
151 //=============================================================================
152 {
153   return _ConfType;
154 }
155 //=============================================================================
156 int HOMARD_Cas::GetNumber() 
157 //=============================================================================
158
159 {
160   return _ListIter.size();
161 }
162 //
163 // La boite englobante
164 //
165 //=============================================================================
166 void HOMARD_Cas::SetBoundingBox( const std::vector<double>& extremas )
167 //=============================================================================
168 {
169   _Boite.clear();
170   _Boite.resize( extremas.size() );
171   for ( int i = 0; i < extremas.size(); i++ )
172     _Boite[i] = extremas[i];
173 }
174
175 //=============================================================================
176 const std::vector<double>& HOMARD_Cas::GetBoundingBox() const
177 //=============================================================================
178 {
179   return _Boite;
180 }
181 //
182 // Les groupes
183 //
184 //=============================================================================
185 const std::list<std::string>& HOMARD_Cas::GetGroups() const
186 //=============================================================================
187 {
188   return _ListGroup;
189 }
190 //=============================================================================
191 void HOMARD_Cas::SupprGroups()
192 //=============================================================================
193 {
194   _ListGroup.clear();
195 }
196 //=============================================================================
197 void HOMARD_Cas::SetGroups( const std::list<std::string>& ListGroup )
198 //=============================================================================
199 {
200   _ListGroup.clear();
201   std::list<std::string>::const_iterator it = ListGroup.begin();
202   while(it != ListGroup.end())
203   {
204     _ListGroup.push_back((*it++));
205   }
206 }
207 //=============================================================================
208 void HOMARD_Cas::AddGroup( const char* Group )
209 {
210   _ListGroup.push_back(Group);
211 }
212 //
213 // Les frontieres
214 //
215 //=============================================================================
216 const std::list<std::string>& HOMARD_Cas::GetBoundaryGroup() const
217 //=============================================================================
218 {
219   return _ListBoundaryGroup;
220 }
221 //=============================================================================
222 void HOMARD_Cas::AddBoundaryGroup( const char* Boundary, const char* Group )
223 {
224   _ListBoundaryGroup.push_back( Boundary );
225   _ListBoundaryGroup.push_back( Group    );
226 }
227 //=============================================================================
228 void HOMARD_Cas::SupprBoundaryGroup()
229 //=============================================================================
230 {
231   _ListBoundaryGroup.clear();
232 }
233 //=============================================================================
234 void HOMARD_Cas::SetNivMax( int NivMax )
235 //=============================================================================
236 {
237   _NivMax = NivMax;
238 }
239 //=============================================================================
240 const int HOMARD_Cas::GetNivMax() const
241 //=============================================================================
242 {
243   return _NivMax;
244 }
245 //=============================================================================
246 void HOMARD_Cas::SetDiamMin( double DiamMin )
247 //=============================================================================
248 {
249   _DiamMin = DiamMin;
250 }
251 //=============================================================================
252 const double HOMARD_Cas::GetDiamMin() const
253 //=============================================================================
254 {
255   return _DiamMin;
256 }
257