Salome HOME
916b1b0a6b162fdca8adb76da756cbd8d2fa1987
[modules/homard.git] / src / HOMARD / HOMARD_Cas.cxx
1 //  HOMARD HOMARD : implementaion of HOMARD idl descriptions
2 //
3 // Copyright (C) 2011-2012  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 #ifndef WIN32
30 # include <unistd.h>
31 #endif
32
33 //=============================================================================
34 /*!
35  *  default constructor:
36  *  Par defaut, l'adaptation est conforme, sans suivi de frontiere
37  */
38 //=============================================================================
39 HOMARD_Cas::HOMARD_Cas():
40   _Name(""), _NomDir("/tmp"), _ConfType(1)
41 {
42   MESSAGE("HOMARD_Cas");
43 }
44 //=============================================================================
45 HOMARD_Cas::~HOMARD_Cas()
46 //=============================================================================
47 {
48   MESSAGE("~HOMARD_Cas");
49 }
50
51 //=============================================================================
52 void HOMARD_Cas::SetDirName( const char* NomDir )
53 //=============================================================================
54 {
55      MESSAGE("SetDirName, NomDir :  "<<NomDir);
56      if (chdir(NomDir) == 0)
57      {
58        _NomDir = std::string( NomDir );
59      }
60     else
61     {
62        // GERALD -- QMESSAGE BOX
63        // std::cerr << "Pb pour entrer dans le repertoire :  "<<NomDir << std::endl;
64        _NomDir = "/tmp";
65     };
66 }
67
68 //=============================================================================
69 std::string HOMARD_Cas::GetDirName() const
70 //=============================================================================
71 {
72   return _NomDir;
73 }
74
75 //=============================================================================
76 void HOMARD_Cas::SetName( const char* Name )
77 //=============================================================================
78 {
79   _Name = std::string( Name );
80 }
81
82 //=============================================================================
83 std::string HOMARD_Cas::GetName() const
84 //=============================================================================
85 {
86   return _Name;
87 }
88
89
90 //=============================================================================
91 std::string HOMARD_Cas::GetDumpPython() const
92 //=============================================================================
93 {
94   std::ostringstream aScript;
95   aScript << "\t" <<_Name << ".SetDirName(\"";
96   aScript << _NomDir << "\")\n";
97   aScript << "\t" <<_Name << ".SetConfType(";
98   aScript << _ConfType << ")\n";
99 // Suivi de frontieres
100   std::list<std::string>::const_iterator it = _ListBoundaryGroup.begin();
101   while(it != _ListBoundaryGroup.end())
102   {
103     aScript << "\t" <<_Name << ".AddBoundaryGroup(\"";
104     aScript << *it << "\", \"";
105     it++;
106     aScript << *it << "\")\n";
107     it++;
108   }
109   if ( _Pyram > 0 )
110   {
111     aScript << "\t" <<_Name << ".SetPyram(";
112     aScript << _Pyram << ")\n";
113   }
114
115   return aScript.str();
116 }
117 //=============================================================================
118 void HOMARD_Cas::AddIteration( const char* NomIteration )
119 //=============================================================================
120 {
121   _ListIter.push_back( std::string( NomIteration ) );
122 }
123
124 //=============================================================================
125 const std::list<std::string>& HOMARD_Cas::GetIterations() const
126 //=============================================================================
127 {
128   return _ListIter;
129 }
130
131 //=============================================================================
132 void HOMARD_Cas::SupprIterations()
133 //=============================================================================
134 {
135   _ListIter.clear();
136 }
137
138 //=============================================================================
139 std::string HOMARD_Cas::GetIter0Name() const
140 //=============================================================================
141 {
142 // Par construction de la liste, l'iteration a ete mise en tete.
143   return (*(_ListIter.begin()));
144 }
145
146 //=============================================================================
147 void HOMARD_Cas::SetConfType( int Conftype )
148 //=============================================================================
149 {
150   _ConfType = Conftype;
151 }
152 //=============================================================================
153 const int HOMARD_Cas::GetConfType() const
154 //=============================================================================
155 {
156   return _ConfType;
157 }
158 //=============================================================================
159 int HOMARD_Cas::GetNumber()
160 //=============================================================================
161
162 {
163   return _ListIter.size();
164 }
165 //
166 // La boite englobante
167 //
168 //=============================================================================
169 void HOMARD_Cas::SetBoundingBox( const std::vector<double>& extremas )
170 //=============================================================================
171 {
172   _Boite.clear();
173   _Boite.resize( extremas.size() );
174   for ( int i = 0; i < extremas.size(); i++ )
175     _Boite[i] = extremas[i];
176 }
177
178 //=============================================================================
179 const std::vector<double>& HOMARD_Cas::GetBoundingBox() const
180 //=============================================================================
181 {
182   return _Boite;
183 }
184 //
185 // Les groupes
186 //
187 //=============================================================================
188 const std::list<std::string>& HOMARD_Cas::GetGroups() const
189 //=============================================================================
190 {
191   return _ListGroup;
192 }
193 //=============================================================================
194 void HOMARD_Cas::SupprGroups()
195 //=============================================================================
196 {
197   _ListGroup.clear();
198 }
199 //=============================================================================
200 void HOMARD_Cas::SetGroups( const std::list<std::string>& ListGroup )
201 //=============================================================================
202 {
203   _ListGroup.clear();
204   std::list<std::string>::const_iterator it = ListGroup.begin();
205   while(it != ListGroup.end())
206   {
207     _ListGroup.push_back((*it++));
208   }
209 }
210 //=============================================================================
211 void HOMARD_Cas::AddGroup( const char* Group )
212 {
213   _ListGroup.push_back(Group);
214 }
215 //
216 // Les frontieres
217 //
218 //=============================================================================
219 const std::list<std::string>& HOMARD_Cas::GetBoundaryGroup() const
220 //=============================================================================
221 {
222   return _ListBoundaryGroup;
223 }
224 //=============================================================================
225 void HOMARD_Cas::AddBoundaryGroup( const char* Boundary, const char* Group )
226 {
227   _ListBoundaryGroup.push_back( Boundary );
228   _ListBoundaryGroup.push_back( Group    );
229 }
230 //=============================================================================
231 void HOMARD_Cas::SupprBoundaryGroup()
232 //=============================================================================
233 {
234   _ListBoundaryGroup.clear();
235 }
236 //=============================================================================
237 void HOMARD_Cas::SetPyram( int Pyram )
238 //=============================================================================
239 {
240   _Pyram = Pyram;
241 }
242 //=============================================================================
243 const int HOMARD_Cas::GetPyram() const
244 //=============================================================================
245 {
246   return _Pyram;
247 }