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