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]));
189 myHomardCas->SetGroups( ListString );
191 //=============================================================================
192 HOMARD::ListGroupType* HOMARD_Cas_i::GetGroups()
194 ASSERT(myHomardCas );
195 const std::list<std::string>& ListString = myHomardCas->GetGroups();
196 HOMARD::ListGroupType_var aResult = new HOMARD::ListGroupType();
197 aResult->length( ListString.size() );
198 std::list<std::string>::const_iterator it;
200 for ( it = ListString.begin(); it != ListString.end(); it++ )
202 aResult[i++] = CORBA::string_dup( (*it).c_str() );
204 return aResult._retn();
206 //=============================================================================
207 void HOMARD_Cas_i::AddBoundaryGroup( const char* BoundaryName, const char* Group)
209 MESSAGE ("AddBoundaryGroup : BoundaryName = "<< BoundaryName << ", Group = " << Group );
210 ASSERT( myHomardCas );
211 // La frontiere est-elle deja enregistree pour ce cas ?
212 const std::list<std::string>& ListBoundaryGroup = myHomardCas->GetBoundaryGroup();
213 std::list<std::string>::const_iterator it;
215 for ( it = ListBoundaryGroup.begin(); it != ListBoundaryGroup.end(); it++ )
217 if ( *it == BoundaryName )
221 // Enregistrement de la frontiere dans la reference du cas
222 myHomardCas->AddBoundaryGroup( BoundaryName, Group );
223 // Pour une nouvelle frontiere, publication dans l'arbre d'etudes sous le cas
226 char* CaseName = GetName() ;
227 MESSAGE ( "AddBoundaryGroup : insertion de la frontiere dans l'arbre de " << CaseName );
228 _gen_i->PublishBoundaryUnderCase(CaseName, BoundaryName) ;
231 //=============================================================================
232 HOMARD::ListBoundaryGroupType* HOMARD_Cas_i::GetBoundaryGroup()
234 MESSAGE ("GetBoundaryGroup");
235 ASSERT(myHomardCas );
236 const std::list<std::string>& ListBoundaryGroup = myHomardCas->GetBoundaryGroup();
237 HOMARD::ListBoundaryGroupType_var aResult = new HOMARD::ListBoundaryGroupType();
238 aResult->length( ListBoundaryGroup.size() );
239 std::list<std::string>::const_iterator it;
241 for ( it = ListBoundaryGroup.begin(); it != ListBoundaryGroup.end(); it++ )
243 aResult[i++] = CORBA::string_dup( (*it).c_str() );
245 return aResult._retn();
247 //=============================================================================
248 void HOMARD_Cas_i::SetPyram( CORBA::Long Pyram )
250 MESSAGE ("SetPyram, Pyram = " << Pyram );
251 ASSERT( myHomardCas );
252 myHomardCas->SetPyram( Pyram );
254 //=============================================================================
255 CORBA::Long HOMARD_Cas_i::GetPyram()
257 MESSAGE ("GetPyram");
258 ASSERT( myHomardCas );
259 return myHomardCas->GetPyram();
261 //=============================================================================
262 //=============================================================================
263 // Liens avec les autres structures
264 //=============================================================================
265 //=============================================================================
266 char* HOMARD_Cas_i::GetIter0Name()
268 ASSERT( myHomardCas );
269 return CORBA::string_dup( myHomardCas->GetIter0Name().c_str() );
271 //=============================================================================
272 HOMARD::HOMARD_Iteration_ptr HOMARD_Cas_i::GetIter0()
274 // Nom de l'iteration parent
275 char* Iter0Name = GetIter0Name() ;
276 MESSAGE ( "GetIter0 : Iter0Name = " << Iter0Name );
277 return _gen_i->GetIteration(Iter0Name) ;
279 //=============================================================================
280 HOMARD::HOMARD_Iteration_ptr HOMARD_Cas_i::NextIteration( const char* IterName )
282 // Nom de l'iteration parent
283 char* NomIterParent = GetIter0Name() ;
284 MESSAGE ( "NextIteration : IterName = " << IterName );
285 MESSAGE ( "NextIteration : NomIterParent = " << NomIterParent );
286 return _gen_i->CreateIteration(IterName, NomIterParent) ;
288 //=============================================================================
289 HOMARD::HOMARD_Iteration_ptr HOMARD_Cas_i::LastIteration( )
291 HOMARD::HOMARD_Iteration_ptr Iter ;
292 HOMARD::listeIterFilles_var ListeIterFilles ;
294 // Iteration initiale du cas
295 IterName = GetIter0Name() ;
296 // On va explorer la descendance de cette iteration initiale
297 // jusqu'a trouver celle qui n'a pas de filles
298 int nbiterfilles = 1 ;
299 while ( nbiterfilles == 1 )
301 // L'iteration associee
302 // MESSAGE ( ".. IterName = " << IterName );
303 Iter = _gen_i->GetIteration(IterName) ;
304 // Les filles de cette iteration
305 ListeIterFilles = Iter->GetIterations() ;
306 nbiterfilles = ListeIterFilles->length() ;
307 // MESSAGE ( ".. nbiterfilles = " << nbiterfilles );
308 // S'il y a au moins 2 filles, arret : on ne sait pas faire
309 ASSERT( nbiterfilles <= 1 ) ;
310 // S'il y a une fille unique, on recupere le nom de la fille et on recommence
311 if ( nbiterfilles == 1 )
312 { IterName = ListeIterFilles[0] ; }
317 //=============================================================================
318 void HOMARD_Cas_i::AddIteration( const char* NomIteration )
320 ASSERT( myHomardCas );
321 myHomardCas->AddIteration( NomIteration );