1 // Copyright (C) 2011-2012 CEA/DEN, EDF R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 // L'ordre de description des fonctions est le meme dans tous les fichiers
21 // HOMARD_aaaa.idl, HOMARD_aaaa.hxx, HOMARD_aaaa.cxx, HOMARD_aaaa_i.hxx, HOMARD_aaaa_i.cxx :
22 // 1. Les generalites : Name, Delete, DumpPython, Dump, Restore
23 // 2. Les caracteristiques
24 // 3. Le lien avec les autres structures
26 // Quand les 2 fonctions Setxxx et Getxxx sont presentes, Setxxx est decrit en premier
29 #include "HOMARD_Cas_i.hxx"
30 #include "HOMARD_Gen_i.hxx"
31 #include "HOMARD_Cas.hxx"
32 #include "HOMARD_DriverTools.hxx"
34 #include "utilities.h"
37 //=============================================================================
39 * standard constructor
41 //=============================================================================
42 HOMARD_Cas_i::HOMARD_Cas_i()
44 MESSAGE( "Default constructor, not for use" );
48 //=============================================================================
50 * standard constructor
52 //=============================================================================
53 HOMARD_Cas_i::HOMARD_Cas_i( CORBA::ORB_ptr orb,
54 HOMARD::HOMARD_Gen_var engine )
56 MESSAGE( "HOMARD_Cas_i" );
59 myHomardCas = new ::HOMARD_Cas();
60 ASSERT( myHomardCas );
63 //=============================================================================
67 //=============================================================================
68 HOMARD_Cas_i::~HOMARD_Cas_i()
71 //=============================================================================
72 //=============================================================================
74 //=============================================================================
75 //=============================================================================
76 void HOMARD_Cas_i::SetName( const char* Name )
78 ASSERT( myHomardCas );
79 myHomardCas->SetName( Name );
81 //=============================================================================
82 char* HOMARD_Cas_i::GetName()
84 ASSERT( myHomardCas );
85 return CORBA::string_dup( myHomardCas->GetName().c_str() );
87 //=============================================================================
88 CORBA::Long HOMARD_Cas_i::Delete()
90 ASSERT( myHomardCas );
91 char* CaseName = GetName() ;
92 MESSAGE ( "Delete : destruction du cas " << CaseName );
93 return _gen_i->DeleteCase(CaseName) ;
95 //=============================================================================
96 char* HOMARD_Cas_i::GetDumpPython()
98 ASSERT( myHomardCas );
99 return CORBA::string_dup( myHomardCas->GetDumpPython().c_str() );
101 //=============================================================================
102 std::string HOMARD_Cas_i::Dump() const
104 return HOMARD::Dump( *myHomardCas );
106 //=============================================================================
107 bool HOMARD_Cas_i::Restore( const std::string& stream )
109 return HOMARD::Restore( *myHomardCas, stream );
111 //=============================================================================
112 //=============================================================================
114 //=============================================================================
115 //=============================================================================
116 void HOMARD_Cas_i::SetDirName( const char* NomDir )
118 ASSERT( myHomardCas );
119 myHomardCas->SetDirName( NomDir );
121 //=============================================================================
122 char* HOMARD_Cas_i::GetDirName()
124 ASSERT( myHomardCas );
125 return CORBA::string_dup( myHomardCas->GetDirName().c_str() );
127 //=============================================================================
128 CORBA::Long HOMARD_Cas_i::GetNumber()
130 ASSERT( myHomardCas );
131 return myHomardCas->GetNumber();
133 //=============================================================================
134 void HOMARD_Cas_i::SetConfType( CORBA::Long ConfType )
136 ASSERT( myHomardCas );
137 myHomardCas->SetConfType( ConfType );
139 //=============================================================================
140 CORBA::Long HOMARD_Cas_i::GetConfType()
142 ASSERT( myHomardCas );
143 return myHomardCas->GetConfType();
145 //=============================================================================
146 void HOMARD_Cas_i::SetBoundingBox( const HOMARD::extrema& LesExtrema )
148 ASSERT( myHomardCas );
149 std::vector<double> VExtrema;
150 ASSERT( LesExtrema.length() == 10 );
151 VExtrema.resize( LesExtrema.length() );
152 for ( int i = 0; i < LesExtrema.length(); i++ )
154 VExtrema[i] = LesExtrema[i];
157 myHomardCas->SetBoundingBox( VExtrema );
159 //=============================================================================
160 HOMARD::extrema* HOMARD_Cas_i::GetBoundingBox()
162 ASSERT(myHomardCas );
163 HOMARD::extrema_var aResult = new HOMARD::extrema();
164 std::vector<double> LesExtremes = myHomardCas->GetBoundingBox();
165 ASSERT( LesExtremes.size() == 10 );
166 aResult->length( 10 );
167 for ( int i = 0; i < LesExtremes.size(); i++ )
169 aResult[i] = LesExtremes[i];
171 return aResult._retn();
173 //=============================================================================
174 void HOMARD_Cas_i::AddGroup( const char* Group)
176 ASSERT( myHomardCas );
177 myHomardCas->AddGroup( Group );
179 //=============================================================================
180 void HOMARD_Cas_i::SetGroups( const HOMARD::ListGroupType& ListGroup )
182 ASSERT( myHomardCas );
183 std::list<std::string> ListString ;
184 for ( int i = 0; i < ListGroup.length(); i++ )
186 ListString.push_back(std::string(ListGroup[i]));
188 myHomardCas->SetGroups( ListString );
190 //=============================================================================
191 HOMARD::ListGroupType* HOMARD_Cas_i::GetGroups()
193 ASSERT(myHomardCas );
194 const std::list<std::string>& ListString = myHomardCas->GetGroups();
195 HOMARD::ListGroupType_var aResult = new HOMARD::ListGroupType();
196 aResult->length( ListString.size() );
197 std::list<std::string>::const_iterator it;
199 for ( it = ListString.begin(); it != ListString.end(); it++ )
201 aResult[i++] = CORBA::string_dup( (*it).c_str() );
203 return aResult._retn();
205 //=============================================================================
206 void HOMARD_Cas_i::AddBoundaryGroup( const char* BoundaryName, const char* Group)
208 MESSAGE ("AddBoundaryGroup : BoundaryName = "<< BoundaryName << ", Group = " << Group );
209 ASSERT( myHomardCas );
210 // La frontiere est-elle deja enregistree pour ce cas ?
211 const std::list<std::string>& ListBoundaryGroup = myHomardCas->GetBoundaryGroup();
212 std::list<std::string>::const_iterator it;
214 for ( it = ListBoundaryGroup.begin(); it != ListBoundaryGroup.end(); it++ )
216 if ( *it == BoundaryName )
220 // Enregistrement de la frontiere dans la reference du cas
221 myHomardCas->AddBoundaryGroup( BoundaryName, Group );
222 // Pour une nouvelle frontiere, publication dans l'arbre d'etudes sous le cas
225 char* CaseName = GetName() ;
226 MESSAGE ( "AddBoundaryGroup : insertion de la frontiere dans l'arbre de " << CaseName );
227 _gen_i->PublishBoundaryUnderCase(CaseName, BoundaryName) ;
230 //=============================================================================
231 HOMARD::ListBoundaryGroupType* HOMARD_Cas_i::GetBoundaryGroup()
233 MESSAGE ("GetBoundaryGroup");
234 ASSERT(myHomardCas );
235 const std::list<std::string>& ListBoundaryGroup = myHomardCas->GetBoundaryGroup();
236 HOMARD::ListBoundaryGroupType_var aResult = new HOMARD::ListBoundaryGroupType();
237 aResult->length( ListBoundaryGroup.size() );
238 std::list<std::string>::const_iterator it;
240 for ( it = ListBoundaryGroup.begin(); it != ListBoundaryGroup.end(); it++ )
242 aResult[i++] = CORBA::string_dup( (*it).c_str() );
244 return aResult._retn();
246 //=============================================================================
247 void HOMARD_Cas_i::SetPyram( CORBA::Long Pyram )
249 MESSAGE ("SetPyram, Pyram = " << Pyram );
250 ASSERT( myHomardCas );
251 myHomardCas->SetPyram( Pyram );
253 //=============================================================================
254 CORBA::Long HOMARD_Cas_i::GetPyram()
256 MESSAGE ("GetPyram");
257 ASSERT( myHomardCas );
258 return myHomardCas->GetPyram();
260 //=============================================================================
261 void HOMARD_Cas_i::MeshInfo(CORBA::Long Qual, CORBA::Long Diam, CORBA::Long Conn, CORBA::Long Tail, CORBA::Long Inte)
263 MESSAGE ( "MeshInfo : information sur le maillage initial du cas" );
264 ASSERT( myHomardCas );
266 // Nom de l'iteration
267 char* IterName = GetIter0Name() ;
268 CORBA::Long etatMenage = -1 ;
269 CORBA::Long modeHOMARD = 7 ;
270 CORBA::Long Option = 1 ;
271 if ( Qual != 0 ) { modeHOMARD = modeHOMARD*5 ; }
272 if ( Diam != 0 ) { modeHOMARD = modeHOMARD*19 ; }
273 if ( Conn != 0 ) { modeHOMARD = modeHOMARD*11 ; }
274 if ( Tail != 0 ) { modeHOMARD = modeHOMARD*13 ; }
275 if ( Inte != 0 ) { modeHOMARD = modeHOMARD*3 ; }
276 CORBA::Long codret = _gen_i->Compute(IterName, etatMenage, modeHOMARD, Option) ;
277 MESSAGE ( "MeshInfo : codret = " << codret );
280 //=============================================================================
281 //=============================================================================
282 // Liens avec les autres structures
283 //=============================================================================
284 //=============================================================================
285 char* HOMARD_Cas_i::GetIter0Name()
287 ASSERT( myHomardCas );
288 return CORBA::string_dup( myHomardCas->GetIter0Name().c_str() );
290 //=============================================================================
291 HOMARD::HOMARD_Iteration_ptr HOMARD_Cas_i::GetIter0()
293 // Nom de l'iteration parent
294 char* Iter0Name = GetIter0Name() ;
295 MESSAGE ( "GetIter0 : Iter0Name = " << Iter0Name );
296 return _gen_i->GetIteration(Iter0Name) ;
298 //=============================================================================
299 HOMARD::HOMARD_Iteration_ptr HOMARD_Cas_i::NextIteration( const char* IterName )
301 // Nom de l'iteration parent
302 char* NomIterParent = GetIter0Name() ;
303 MESSAGE ( "NextIteration : IterName = " << IterName );
304 MESSAGE ( "NextIteration : NomIterParent = " << NomIterParent );
305 return _gen_i->CreateIteration(IterName, NomIterParent) ;
307 //=============================================================================
308 HOMARD::HOMARD_Iteration_ptr HOMARD_Cas_i::LastIteration( )
310 HOMARD::HOMARD_Iteration_ptr Iter ;
311 HOMARD::listeIterFilles_var ListeIterFilles ;
313 // Iteration initiale du cas
314 IterName = GetIter0Name() ;
315 // On va explorer la descendance de cette iteration initiale
316 // jusqu'a trouver celle qui n'a pas de filles
317 int nbiterfilles = 1 ;
318 while ( nbiterfilles == 1 )
320 // L'iteration associee
321 // MESSAGE ( ".. IterName = " << IterName );
322 Iter = _gen_i->GetIteration(IterName) ;
323 // Les filles de cette iteration
324 ListeIterFilles = Iter->GetIterations() ;
325 nbiterfilles = ListeIterFilles->length() ;
326 // MESSAGE ( ".. nbiterfilles = " << nbiterfilles );
327 // S'il y a au moins 2 filles, arret : on ne sait pas faire
328 ASSERT( nbiterfilles <= 1 ) ;
329 // S'il y a une fille unique, on recupere le nom de la fille et on recommence
330 if ( nbiterfilles == 1 )
331 { IterName = ListeIterFilles[0] ; }
336 //=============================================================================
337 void HOMARD_Cas_i::AddIteration( const char* NomIteration )
339 ASSERT( myHomardCas );
340 myHomardCas->AddIteration( NomIteration );