1 // HOMARD HOMARD : implementation of HOMARD idl descriptions
3 // Copyright (C) 2011-2013 CEA/DEN, EDF R&D
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.
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.
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
19 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 // File : HOMARD_Cas.cxx
22 // Author : Paul RASCLE, EDF
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
32 // Quand les 2 fonctions Setxxx et Getxxx sont presentes, Setxxx est decrit en premier
34 #include "HOMARD_Cas.hxx"
35 #include "utilities.h"
45 //=============================================================================
47 * default constructor:
48 * Par defaut, l'adaptation est conforme, sans suivi de frontiere
50 //=============================================================================
51 HOMARD_Cas::HOMARD_Cas():
52 _Name(""), _NomDir("/tmp"), _ConfType(1)
54 MESSAGE("HOMARD_Cas");
56 //=============================================================================
57 HOMARD_Cas::~HOMARD_Cas()
58 //=============================================================================
60 MESSAGE("~HOMARD_Cas");
62 //=============================================================================
63 //=============================================================================
65 //=============================================================================
66 //=============================================================================
67 void HOMARD_Cas::SetName( const char* Name )
69 _Name = std::string( Name );
71 //=============================================================================
72 std::string HOMARD_Cas::GetName() const
76 //=============================================================================
77 std::string HOMARD_Cas::GetDumpPython() const
79 std::ostringstream aScript;
80 aScript << "\t" <<_Name << ".SetDirName(\"";
81 aScript << _NomDir << "\")\n";
82 aScript << "\t" <<_Name << ".SetConfType(";
83 aScript << _ConfType << ")\n";
84 // Suivi de frontieres
85 std::list<std::string>::const_iterator it = _ListBoundaryGroup.begin();
86 while(it != _ListBoundaryGroup.end())
88 aScript << "\t" <<_Name << ".AddBoundaryGroup(\"";
89 aScript << *it << "\", \"";
91 aScript << *it << "\")\n";
96 aScript << "\t" <<_Name << ".SetPyram(";
97 aScript << _Pyram << ")\n";
100 return aScript.str();
102 //=============================================================================
103 //=============================================================================
105 //=============================================================================
106 //=============================================================================
107 int HOMARD_Cas::SetDirName( const char* NomDir )
109 MESSAGE("SetDirName, NomDir : "<<NomDir);
110 MESSAGE("SetDirName, _NomDir : "<<_NomDir);
112 // On vérifie qu'aucun calcul n'a eu lieu pour ce cas
113 MESSAGE("SetDirName, _ListIter.size() : "<<_ListIter.size());
114 if ( _ListIter.size() > 1 ) { erreur = 1 ; }
117 if ( chdir(NomDir) == 0 )
119 if ( _chdir(NomDir) == 0 )
121 { _NomDir = std::string( NomDir ); }
126 if ( mkdir(NomDir, S_IRWXU|S_IRGRP|S_IXGRP) == 0 )
128 if ( chdir(NomDir) == 0 )
130 if ( _mkdir(NomDir) == 0 )
132 if ( _chdir(NomDir) == 0 )
134 { _NomDir = std::string( NomDir ); }
135 else { erreur = 2 ; }
137 else { erreur = 2 ; }
141 //=============================================================================
142 std::string HOMARD_Cas::GetDirName() const
146 //=============================================================================
147 int HOMARD_Cas::GetNumberofIter()
149 return _ListIter.size();
151 //=============================================================================
152 void HOMARD_Cas::SetConfType( int Conftype )
154 _ConfType = Conftype;
156 //=============================================================================
157 const int HOMARD_Cas::GetConfType() const
162 // La boite englobante
164 //=============================================================================
165 void HOMARD_Cas::SetBoundingBox( const std::vector<double>& extremas )
168 _Boite.resize( extremas.size() );
169 for ( int i = 0; i < extremas.size(); i++ )
170 _Boite[i] = extremas[i];
172 //=============================================================================
173 const std::vector<double>& HOMARD_Cas::GetBoundingBox() const
180 //=============================================================================
181 void HOMARD_Cas::AddGroup( const char* Group )
183 _ListGroup.push_back(Group);
185 //=============================================================================
186 void HOMARD_Cas::SetGroups( const std::list<std::string>& ListGroup )
189 std::list<std::string>::const_iterator it = ListGroup.begin();
190 while(it != ListGroup.end())
192 _ListGroup.push_back((*it++));
195 //=============================================================================
196 const std::list<std::string>& HOMARD_Cas::GetGroups() const
200 //=============================================================================
201 void HOMARD_Cas::SupprGroups()
208 //=============================================================================
209 void HOMARD_Cas::AddBoundaryGroup( const char* Boundary, const char* Group )
211 _ListBoundaryGroup.push_back( Boundary );
212 _ListBoundaryGroup.push_back( Group );
214 //=============================================================================
215 const std::list<std::string>& HOMARD_Cas::GetBoundaryGroup() const
217 return _ListBoundaryGroup;
219 //=============================================================================
220 void HOMARD_Cas::SupprBoundaryGroup()
222 _ListBoundaryGroup.clear();
224 //=============================================================================
225 void HOMARD_Cas::SetPyram( int Pyram )
229 //=============================================================================
230 const int HOMARD_Cas::GetPyram() const
234 //=============================================================================
235 //=============================================================================
236 // Liens avec les autres structures
237 //=============================================================================
238 //=============================================================================
239 std::string HOMARD_Cas::GetIter0Name() const
241 // Par construction de la liste, l'iteration a ete mise en tete.
242 return (*(_ListIter.begin()));
244 //=============================================================================
245 void HOMARD_Cas::AddIteration( const char* NomIteration )
247 _ListIter.push_back( std::string( NomIteration ) );
249 //=============================================================================
250 const std::list<std::string>& HOMARD_Cas::GetIterations() const
254 //=============================================================================
255 void HOMARD_Cas::SupprIterations()