1 // HOMARD HOMARD : implementation of HOMARD idl descriptions
3 // Copyright (C) 2011-2014 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, or (at your option) any later version.
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"
46 //=============================================================================
48 * default constructor:
49 * Par defaut, l'adaptation est conforme, sans suivi de frontiere
51 //=============================================================================
52 HOMARD_Cas::HOMARD_Cas():
53 _Name(""), _NomDir("/tmp"), _ConfType(1)
55 MESSAGE("HOMARD_Cas");
57 //=============================================================================
58 HOMARD_Cas::~HOMARD_Cas()
59 //=============================================================================
61 MESSAGE("~HOMARD_Cas");
63 //=============================================================================
64 //=============================================================================
66 //=============================================================================
67 //=============================================================================
68 void HOMARD_Cas::SetName( const char* Name )
70 _Name = std::string( Name );
72 //=============================================================================
73 std::string HOMARD_Cas::GetName() const
77 //=============================================================================
78 std::string HOMARD_Cas::GetDumpPython() const
80 std::ostringstream aScript;
81 aScript << "\t" <<_Name << ".SetDirName(\"";
82 aScript << _NomDir << "\")\n";
83 aScript << "\t" <<_Name << ".SetConfType(";
84 aScript << _ConfType << ")\n";
85 // Suivi de frontieres
86 std::list<std::string>::const_iterator it = _ListBoundaryGroup.begin();
87 while(it != _ListBoundaryGroup.end())
89 aScript << "\t" <<_Name << ".AddBoundaryGroup(\"";
90 aScript << *it << "\", \"";
92 aScript << *it << "\")\n";
97 aScript << "\t" <<_Name << ".SetPyram(";
98 aScript << _Pyram << ")\n";
101 return aScript.str();
103 //=============================================================================
104 //=============================================================================
106 //=============================================================================
107 //=============================================================================
108 int HOMARD_Cas::SetDirName( const char* NomDir )
110 MESSAGE("SetDirName, NomDir : "<<NomDir);
111 MESSAGE("SetDirName, _NomDir : "<<_NomDir);
113 // On vérifie qu'aucun calcul n'a eu lieu pour ce cas
114 MESSAGE("SetDirName, _ListIter.size() : "<<_ListIter.size());
115 if ( _ListIter.size() > 1 ) { erreur = 1 ; }
117 if ( CHDIR(NomDir) == 0 )
118 { _NomDir = std::string( NomDir ); }
123 if ( mkdir(NomDir, S_IRWXU|S_IRGRP|S_IXGRP) == 0 )
125 if ( _mkdir(NomDir) == 0 )
128 if ( CHDIR(NomDir) == 0 ) { _NomDir = std::string( NomDir ); }
129 else { erreur = 2 ; }
131 else { erreur = 2 ; }
135 //=============================================================================
136 std::string HOMARD_Cas::GetDirName() const
140 //=============================================================================
141 int HOMARD_Cas::GetNumberofIter()
143 return _ListIter.size();
145 //=============================================================================
146 void HOMARD_Cas::SetConfType( int Conftype )
148 _ConfType = Conftype;
150 //=============================================================================
151 const int HOMARD_Cas::GetConfType() const
156 // La boite englobante
158 //=============================================================================
159 void HOMARD_Cas::SetBoundingBox( const std::vector<double>& extremas )
162 _Boite.resize( extremas.size() );
163 for ( int i = 0; i < extremas.size(); i++ )
164 _Boite[i] = extremas[i];
166 //=============================================================================
167 const std::vector<double>& HOMARD_Cas::GetBoundingBox() const
174 //=============================================================================
175 void HOMARD_Cas::AddGroup( const char* Group )
177 _ListGroup.push_back(Group);
179 //=============================================================================
180 void HOMARD_Cas::SetGroups( const std::list<std::string>& ListGroup )
183 std::list<std::string>::const_iterator it = ListGroup.begin();
184 while(it != ListGroup.end())
186 _ListGroup.push_back((*it++));
189 //=============================================================================
190 const std::list<std::string>& HOMARD_Cas::GetGroups() const
194 //=============================================================================
195 void HOMARD_Cas::SupprGroups()
202 //=============================================================================
203 void HOMARD_Cas::AddBoundaryGroup( const char* Boundary, const char* Group )
205 _ListBoundaryGroup.push_back( Boundary );
206 _ListBoundaryGroup.push_back( Group );
208 //=============================================================================
209 const std::list<std::string>& HOMARD_Cas::GetBoundaryGroup() const
211 return _ListBoundaryGroup;
213 //=============================================================================
214 void HOMARD_Cas::SupprBoundaryGroup()
216 _ListBoundaryGroup.clear();
218 //=============================================================================
219 void HOMARD_Cas::SetPyram( int Pyram )
223 //=============================================================================
224 const int HOMARD_Cas::GetPyram() const
228 //=============================================================================
229 //=============================================================================
230 // Liens avec les autres structures
231 //=============================================================================
232 //=============================================================================
233 std::string HOMARD_Cas::GetIter0Name() const
235 // Par construction de la liste, l'iteration a ete mise en tete.
236 return (*(_ListIter.begin()));
238 //=============================================================================
239 void HOMARD_Cas::AddIteration( const char* NomIteration )
241 _ListIter.push_back( std::string( NomIteration ) );
243 //=============================================================================
244 const std::list<std::string>& HOMARD_Cas::GetIterations() const
248 //=============================================================================
249 void HOMARD_Cas::SupprIterations()