1 // HOMARD HOMARD : implementation of HOMARD idl descriptions
3 // Copyright (C) 2011-2020 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 : Gerald NICOLAS, 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(0), _ExtType(0)
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 aScript << "\t" <<_Name << ".SetExtType(";
86 aScript << _ExtType << ")\n";
87 // Suivi de frontieres
88 std::list<std::string>::const_iterator it = _ListBoundaryGroup.begin();
89 while(it != _ListBoundaryGroup.end())
91 aScript << "\t" <<_Name << ".AddBoundaryGroup(\"";
92 aScript << *it << "\", \"";
94 aScript << *it << "\")\n";
99 aScript << "\t" <<_Name << ".SetPyram(";
100 aScript << _Pyram << ")\n";
103 return aScript.str();
105 //=============================================================================
106 //=============================================================================
108 //=============================================================================
109 //=============================================================================
110 int HOMARD_Cas::SetDirName( const char* NomDir )
112 // MESSAGE("SetDirName, NomDir : "<<NomDir);
113 // MESSAGE("SetDirName, _NomDir : "<<_NomDir);
115 // On vérifie qu'aucun calcul n'a eu lieu pour ce cas
116 // MESSAGE("SetDirName, _ListIter.size() : "<<_ListIter.size());
117 if ( _ListIter.size() > 1 ) { erreur = 1 ; }
119 if ( CHDIR(NomDir) == 0 )
120 { _NomDir = std::string( NomDir ); }
125 if ( mkdir(NomDir, S_IRWXU|S_IRGRP|S_IXGRP) == 0 )
127 if ( _mkdir(NomDir) == 0 )
130 if ( CHDIR(NomDir) == 0 ) { _NomDir = std::string( NomDir ); }
131 else { erreur = 2 ; }
133 else { erreur = 2 ; }
137 //=============================================================================
138 std::string HOMARD_Cas::GetDirName() const
142 //=============================================================================
143 int HOMARD_Cas::GetNumberofIter()
145 return _ListIter.size();
148 // Le type de conformite ou non conformite
150 //=============================================================================
151 void HOMARD_Cas::SetConfType( int Conftype )
153 // VERIFICATION( (Conftype>=-2) && (Conftype<=3) );
154 _ConfType = Conftype;
156 //=============================================================================
157 const int HOMARD_Cas::GetConfType() const
164 //=============================================================================
165 void HOMARD_Cas::SetExtType( int ExtType )
167 // VERIFICATION( (ExtType>=0) && (ExtType<=2) );
170 //=============================================================================
171 const int HOMARD_Cas::GetExtType() const
176 // La boite englobante
178 //=============================================================================
179 void HOMARD_Cas::SetBoundingBox( const std::vector<double>& extremas )
182 _Boite.resize( extremas.size() );
183 for ( int i = 0; i < extremas.size(); i++ )
184 _Boite[i] = extremas[i];
186 //=============================================================================
187 const std::vector<double>& HOMARD_Cas::GetBoundingBox() const
194 //=============================================================================
195 void HOMARD_Cas::AddGroup( const char* Group )
197 _ListGroup.push_back(Group);
199 //=============================================================================
200 void HOMARD_Cas::SetGroups( const std::list<std::string>& ListGroup )
203 std::list<std::string>::const_iterator it = ListGroup.begin();
204 while(it != ListGroup.end())
206 _ListGroup.push_back((*it++));
209 //=============================================================================
210 const std::list<std::string>& HOMARD_Cas::GetGroups() const
214 //=============================================================================
215 void HOMARD_Cas::SupprGroups()
222 //=============================================================================
223 void HOMARD_Cas::AddBoundary( const char* Boundary )
225 // MESSAGE ( ". HOMARD_Cas::AddBoundary : Boundary = " << Boundary );
226 const char* Group = "";
227 AddBoundaryGroup( Boundary, Group );
229 //=============================================================================
230 void HOMARD_Cas::AddBoundaryGroup( const char* Boundary, const char* Group )
232 // MESSAGE ( ". HOMARD_Cas::AddBoundaryGroup : Boundary = " << Boundary );
233 // MESSAGE ( ". HOMARD_Cas::AddBoundaryGroup : Group = " << Group );
234 _ListBoundaryGroup.push_back( Boundary );
235 _ListBoundaryGroup.push_back( Group );
237 //=============================================================================
238 const std::list<std::string>& HOMARD_Cas::GetBoundaryGroup() const
240 return _ListBoundaryGroup;
242 //=============================================================================
243 void HOMARD_Cas::SupprBoundaryGroup()
245 _ListBoundaryGroup.clear();
247 //=============================================================================
248 void HOMARD_Cas::SetPyram( int Pyram )
252 //=============================================================================
253 const int HOMARD_Cas::GetPyram() const
257 //=============================================================================
258 //=============================================================================
259 // Liens avec les autres structures
260 //=============================================================================
261 //=============================================================================
262 std::string HOMARD_Cas::GetIter0Name() const
264 // Par construction de la liste, l'iteration a ete mise en tete.
265 return (*(_ListIter.begin()));
267 //=============================================================================
268 void HOMARD_Cas::AddIteration( const char* NomIteration )
270 _ListIter.push_back( std::string( NomIteration ) );
272 //=============================================================================
273 const std::list<std::string>& HOMARD_Cas::GetIterations() const
277 //=============================================================================
278 void HOMARD_Cas::SupprIterations()