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 // VERIFICATION( (Conftype>=1) && (Conftype<=4) );
149 _ConfType = Conftype;
151 //=============================================================================
152 const int HOMARD_Cas::GetConfType() const
157 // La boite englobante
159 //=============================================================================
160 void HOMARD_Cas::SetBoundingBox( const std::vector<double>& extremas )
163 _Boite.resize( extremas.size() );
164 for ( int i = 0; i < extremas.size(); i++ )
165 _Boite[i] = extremas[i];
167 //=============================================================================
168 const std::vector<double>& HOMARD_Cas::GetBoundingBox() const
175 //=============================================================================
176 void HOMARD_Cas::AddGroup( const char* Group )
178 _ListGroup.push_back(Group);
180 //=============================================================================
181 void HOMARD_Cas::SetGroups( const std::list<std::string>& ListGroup )
184 std::list<std::string>::const_iterator it = ListGroup.begin();
185 while(it != ListGroup.end())
187 _ListGroup.push_back((*it++));
190 //=============================================================================
191 const std::list<std::string>& HOMARD_Cas::GetGroups() const
195 //=============================================================================
196 void HOMARD_Cas::SupprGroups()
203 //=============================================================================
204 void HOMARD_Cas::AddBoundaryGroup( const char* Boundary, const char* Group )
206 _ListBoundaryGroup.push_back( Boundary );
207 _ListBoundaryGroup.push_back( Group );
209 //=============================================================================
210 const std::list<std::string>& HOMARD_Cas::GetBoundaryGroup() const
212 return _ListBoundaryGroup;
214 //=============================================================================
215 void HOMARD_Cas::SupprBoundaryGroup()
217 _ListBoundaryGroup.clear();
219 //=============================================================================
220 void HOMARD_Cas::SetPyram( int Pyram )
224 //=============================================================================
225 const int HOMARD_Cas::GetPyram() const
229 //=============================================================================
230 //=============================================================================
231 // Liens avec les autres structures
232 //=============================================================================
233 //=============================================================================
234 std::string HOMARD_Cas::GetIter0Name() const
236 // Par construction de la liste, l'iteration a ete mise en tete.
237 return (*(_ListIter.begin()));
239 //=============================================================================
240 void HOMARD_Cas::AddIteration( const char* NomIteration )
242 _ListIter.push_back( std::string( NomIteration ) );
244 //=============================================================================
245 const std::list<std::string>& HOMARD_Cas::GetIterations() const
249 //=============================================================================
250 void HOMARD_Cas::SupprIterations()