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"
43 //=============================================================================
45 * default constructor:
46 * Par defaut, l'adaptation est conforme, sans suivi de frontiere
48 //=============================================================================
49 HOMARD_Cas::HOMARD_Cas():
50 _Name(""), _NomDir("/tmp"), _ConfType(1)
52 MESSAGE("HOMARD_Cas");
54 //=============================================================================
55 HOMARD_Cas::~HOMARD_Cas()
56 //=============================================================================
58 MESSAGE("~HOMARD_Cas");
60 //=============================================================================
61 //=============================================================================
63 //=============================================================================
64 //=============================================================================
65 void HOMARD_Cas::SetName( const char* Name )
67 _Name = std::string( Name );
69 //=============================================================================
70 std::string HOMARD_Cas::GetName() const
74 //=============================================================================
75 std::string HOMARD_Cas::GetDumpPython() const
77 std::ostringstream aScript;
78 aScript << "\t" <<_Name << ".SetDirName(\"";
79 aScript << _NomDir << "\")\n";
80 aScript << "\t" <<_Name << ".SetConfType(";
81 aScript << _ConfType << ")\n";
82 // Suivi de frontieres
83 std::list<std::string>::const_iterator it = _ListBoundaryGroup.begin();
84 while(it != _ListBoundaryGroup.end())
86 aScript << "\t" <<_Name << ".AddBoundaryGroup(\"";
87 aScript << *it << "\", \"";
89 aScript << *it << "\")\n";
94 aScript << "\t" <<_Name << ".SetPyram(";
95 aScript << _Pyram << ")\n";
100 //=============================================================================
101 //=============================================================================
103 //=============================================================================
104 //=============================================================================
105 int HOMARD_Cas::SetDirName( const char* NomDir )
107 MESSAGE("SetDirName, NomDir : "<<NomDir);
108 MESSAGE("SetDirName, _NomDir : "<<_NomDir);
110 // On vérifie qu'aucun calcul n'a eu lieu pour ce cas
111 MESSAGE("SetDirName, _ListIter.size() : "<<_ListIter.size());
112 if ( _ListIter.size() > 1 ) { erreur = 1 ; }
114 if ( chdir(NomDir) == 0 ) { _NomDir = std::string( NomDir ); }
117 if ( mkdir(NomDir, S_IRWXU|S_IRGRP|S_IXGRP) == 0 )
119 if ( chdir(NomDir) == 0 ) { _NomDir = std::string( NomDir ); }
120 else { erreur = 2 ; }
122 else { erreur = 2 ; }
126 //=============================================================================
127 std::string HOMARD_Cas::GetDirName() const
131 //=============================================================================
132 int HOMARD_Cas::GetNumberofIter()
134 return _ListIter.size();
136 //=============================================================================
137 void HOMARD_Cas::SetConfType( int Conftype )
139 _ConfType = Conftype;
141 //=============================================================================
142 const int HOMARD_Cas::GetConfType() const
147 // La boite englobante
149 //=============================================================================
150 void HOMARD_Cas::SetBoundingBox( const std::vector<double>& extremas )
153 _Boite.resize( extremas.size() );
154 for ( int i = 0; i < extremas.size(); i++ )
155 _Boite[i] = extremas[i];
157 //=============================================================================
158 const std::vector<double>& HOMARD_Cas::GetBoundingBox() const
165 //=============================================================================
166 void HOMARD_Cas::AddGroup( const char* Group )
168 _ListGroup.push_back(Group);
170 //=============================================================================
171 void HOMARD_Cas::SetGroups( const std::list<std::string>& ListGroup )
174 std::list<std::string>::const_iterator it = ListGroup.begin();
175 while(it != ListGroup.end())
177 _ListGroup.push_back((*it++));
180 //=============================================================================
181 const std::list<std::string>& HOMARD_Cas::GetGroups() const
185 //=============================================================================
186 void HOMARD_Cas::SupprGroups()
193 //=============================================================================
194 void HOMARD_Cas::AddBoundaryGroup( const char* Boundary, const char* Group )
196 _ListBoundaryGroup.push_back( Boundary );
197 _ListBoundaryGroup.push_back( Group );
199 //=============================================================================
200 const std::list<std::string>& HOMARD_Cas::GetBoundaryGroup() const
202 return _ListBoundaryGroup;
204 //=============================================================================
205 void HOMARD_Cas::SupprBoundaryGroup()
207 _ListBoundaryGroup.clear();
209 //=============================================================================
210 void HOMARD_Cas::SetPyram( int Pyram )
214 //=============================================================================
215 const int HOMARD_Cas::GetPyram() const
219 //=============================================================================
220 //=============================================================================
221 // Liens avec les autres structures
222 //=============================================================================
223 //=============================================================================
224 std::string HOMARD_Cas::GetIter0Name() const
226 // Par construction de la liste, l'iteration a ete mise en tete.
227 return (*(_ListIter.begin()));
229 //=============================================================================
230 void HOMARD_Cas::AddIteration( const char* NomIteration )
232 _ListIter.push_back( std::string( NomIteration ) );
234 //=============================================================================
235 const std::list<std::string>& HOMARD_Cas::GetIterations() const
239 //=============================================================================
240 void HOMARD_Cas::SupprIterations()