1 // Copyright (C) 2011-2021 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, or (at your option) any later version.
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
21 // L'ordre de description des fonctions est le meme dans tous les fichiers
22 // HOMARD_aaaa.idl, HOMARD_aaaa.hxx, HOMARD_aaaa.cxx, HOMARD_aaaa_i.hxx, HOMARD_aaaa_i.cxx :
23 // 1. Les generalites : Name, Delete, DumpPython, Dump, Restore
24 // 2. Les caracteristiques
25 // 3. Le lien avec les autres structures
27 // Quand les 2 fonctions Setxxx et Getxxx sont presentes, Setxxx est decrit en premier
30 #include "SMESH_Homard_i.hxx"
31 #include "SMESH_Homard.hxx"
33 #include <SMESH_Gen_i.hxx>
35 //#include "FrontTrack.hxx"
37 #include "utilities.h"
38 #include "Basics_Utils.hxx"
39 #include "Basics_DirUtils.hxx"
40 #include "Utils_SINGLETON.hxx"
41 #include "Utils_CorbaException.hxx"
42 #include "SALOMEDS_Tool.hxx"
43 #include "SALOME_LifeCycleCORBA.hxx"
44 #include "SALOMEconfig.h"
72 SMESHHOMARD::HOMARD_Gen_ptr SMESH_Gen_i::CreateHOMARD_ADAPT()
74 SMESHHOMARD_I::HOMARD_Gen_i* aHomardGen = new SMESHHOMARD_I::HOMARD_Gen_i();
75 SMESHHOMARD::HOMARD_Gen_var anObj = aHomardGen->_this();
79 namespace SMESHHOMARD_I
82 //=============================================================================
84 * standard constructor
86 //=============================================================================
87 HOMARD_Boundary_i::HOMARD_Boundary_i()
89 MESSAGE( "Default constructor, not for use" );
92 //=============================================================================
94 * standard constructor
96 //=============================================================================
97 HOMARD_Boundary_i::HOMARD_Boundary_i( CORBA::ORB_ptr orb,
98 SMESHHOMARD::HOMARD_Gen_var engine )
100 MESSAGE( "HOMARD_Boundary_i" );
103 myHomardBoundary = new SMESHHOMARDImpl::HOMARD_Boundary();
104 ASSERT( myHomardBoundary );
106 //=============================================================================
108 * standard destructor
110 //=============================================================================
111 HOMARD_Boundary_i::~HOMARD_Boundary_i()
114 //=============================================================================
115 //=============================================================================
117 //=============================================================================
118 //=============================================================================
119 void HOMARD_Boundary_i::SetName( const char* Name )
121 ASSERT( myHomardBoundary );
122 myHomardBoundary->SetName( Name );
124 //=============================================================================
125 char* HOMARD_Boundary_i::GetName()
127 ASSERT( myHomardBoundary );
128 return CORBA::string_dup( myHomardBoundary->GetName().c_str() );
130 //=============================================================================
131 CORBA::Long HOMARD_Boundary_i::Delete()
133 ASSERT( myHomardBoundary );
134 char* BoundaryName = GetName();
135 MESSAGE ( "Delete : destruction de la frontiere " << BoundaryName );
136 return _gen_i->DeleteBoundary(BoundaryName);
138 //=============================================================================
139 char* HOMARD_Boundary_i::GetDumpPython()
141 ASSERT( myHomardBoundary );
142 return CORBA::string_dup( myHomardBoundary->GetDumpPython().c_str() );
144 //=============================================================================
145 std::string HOMARD_Boundary_i::Dump() const
147 return SMESHHOMARDImpl::Dump( *myHomardBoundary );
149 //=============================================================================
150 bool HOMARD_Boundary_i::Restore( const std::string& stream )
152 return SMESHHOMARDImpl::Restore( *myHomardBoundary, stream );
154 //=============================================================================
155 //=============================================================================
157 //=============================================================================
158 //=============================================================================
159 void HOMARD_Boundary_i::SetType( CORBA::Long Type )
161 ASSERT( myHomardBoundary );
162 myHomardBoundary->SetType( Type );
164 //=============================================================================
165 CORBA::Long HOMARD_Boundary_i::GetType()
167 ASSERT( myHomardBoundary );
168 return CORBA::Long( myHomardBoundary->GetType() );
170 //=============================================================================
171 void HOMARD_Boundary_i::SetMeshName( const char* MeshName )
173 ASSERT( myHomardBoundary );
174 myHomardBoundary->SetMeshName( MeshName );
176 //=============================================================================
177 char* HOMARD_Boundary_i::GetMeshName()
179 ASSERT( myHomardBoundary );
180 return CORBA::string_dup( myHomardBoundary->GetMeshName().c_str() );
182 //=============================================================================
183 void HOMARD_Boundary_i::SetDataFile( const char* DataFile )
185 ASSERT( myHomardBoundary );
186 myHomardBoundary->SetDataFile( DataFile );
187 int PublisMeshIN = _gen_i->GetPublisMeshIN ();
188 if ( PublisMeshIN != 0 ) { _gen_i->PublishResultInSmesh(DataFile, 0); }
190 //=============================================================================
191 char* HOMARD_Boundary_i::GetDataFile()
193 ASSERT( myHomardBoundary );
194 return CORBA::string_dup( myHomardBoundary->GetDataFile().c_str() );
196 //=============================================================================
197 void HOMARD_Boundary_i::SetCylinder( double X0, double X1, double X2, double X3, double X4, double X5, double X6 )
199 ASSERT( myHomardBoundary );
200 myHomardBoundary->SetCylinder( X0, X1, X2, X3, X4, X5, X6 );
202 //=============================================================================
203 void HOMARD_Boundary_i::SetSphere( double Xcentre, double Ycentre, double ZCentre, double rayon )
205 ASSERT( myHomardBoundary );
206 myHomardBoundary->SetSphere( Xcentre, Ycentre, ZCentre, rayon );
208 //=============================================================================
209 void HOMARD_Boundary_i::SetConeR( double Xcentre1, double Ycentre1, double Zcentre1, double Rayon1, double Xcentre2, double Ycentre2, double Zcentre2, double Rayon2)
211 ASSERT( myHomardBoundary );
212 myHomardBoundary->SetConeR( Xcentre1, Ycentre1, Zcentre1, Rayon1, Xcentre2, Ycentre2, Zcentre2, Rayon2 );
214 //=============================================================================
215 void HOMARD_Boundary_i::SetConeA( double Xaxe, double Yaxe, double Zaxe, double Angle, double Xcentre, double Ycentre, double Zcentre)
217 ASSERT( myHomardBoundary );
218 myHomardBoundary->SetConeA( Xaxe, Yaxe, Zaxe, Angle, Xcentre, Ycentre, Zcentre );
220 //=============================================================================
221 void HOMARD_Boundary_i::SetTorus( double X0, double X1, double X2, double X3, double X4, double X5, double X6, double X7 )
223 ASSERT( myHomardBoundary );
224 myHomardBoundary->SetTorus( X0, X1, X2, X3, X4, X5, X6, X7 );
226 //=============================================================================
227 SMESHHOMARD::double_array* HOMARD_Boundary_i::GetCoords()
229 ASSERT( myHomardBoundary );
230 SMESHHOMARD::double_array_var aResult = new SMESHHOMARD::double_array();
231 std::vector<double> mesCoor = myHomardBoundary->GetCoords();
232 aResult->length( mesCoor .size() );
233 std::vector<double>::const_iterator it;
235 for ( it = mesCoor.begin(); it != mesCoor.end(); it++ )
236 aResult[i++] = (*it);
237 return aResult._retn();
239 //=============================================================================
240 void HOMARD_Boundary_i::SetLimit( double Xincr, double Yincr, double Zincr )
242 ASSERT( myHomardBoundary );
243 myHomardBoundary->SetLimit( Xincr, Yincr, Zincr );
245 //=============================================================================
246 SMESHHOMARD::double_array* HOMARD_Boundary_i::GetLimit()
248 ASSERT( myHomardBoundary );
249 SMESHHOMARD::double_array_var aResult = new SMESHHOMARD::double_array();
250 std::vector<double> mesCoor = myHomardBoundary->GetLimit();
251 aResult->length( mesCoor .size() );
252 std::vector<double>::const_iterator it;
254 for ( it = mesCoor.begin(); it != mesCoor.end(); it++ )
255 aResult[i++] = (*it);
256 return aResult._retn();
258 //=============================================================================
259 void HOMARD_Boundary_i::AddGroup( const char* Group)
261 ASSERT( myHomardBoundary );
262 myHomardBoundary->AddGroup( Group );
264 //=============================================================================
265 void HOMARD_Boundary_i::SetGroups(const SMESHHOMARD::ListGroupType& ListGroup)
267 ASSERT( myHomardBoundary );
268 std::list<std::string> ListString;
269 for ( int i = 0; i < ListGroup.length(); i++ )
271 ListString.push_back(std::string(ListGroup[i]));
273 myHomardBoundary->SetGroups( ListString );
275 //=============================================================================
276 SMESHHOMARD::ListGroupType* HOMARD_Boundary_i::GetGroups()
278 ASSERT( myHomardBoundary );
279 const std::list<std::string>& ListString = myHomardBoundary->GetGroups();
280 SMESHHOMARD::ListGroupType_var aResult = new SMESHHOMARD::ListGroupType;
281 aResult->length( ListString.size() );
282 std::list<std::string>::const_iterator it;
284 for ( it = ListString.begin(); it != ListString.end(); it++ )
286 aResult[i++] = CORBA::string_dup( (*it).c_str() );
288 return aResult._retn();
290 //=============================================================================
291 //=============================================================================
292 // Liens avec les autres structures
293 //=============================================================================
294 //=============================================================================
295 void HOMARD_Boundary_i::SetCaseCreation( const char* NomCaseCreation )
297 ASSERT( myHomardBoundary );
298 myHomardBoundary->SetCaseCreation( NomCaseCreation );
300 //=============================================================================
301 char* HOMARD_Boundary_i::GetCaseCreation()
303 ASSERT( myHomardBoundary );
304 return CORBA::string_dup( myHomardBoundary->GetCaseCreation().c_str() );
307 //=============================================================================
309 * standard constructor
311 //=============================================================================
312 HOMARD_Cas_i::HOMARD_Cas_i()
314 MESSAGE( "Default constructor, not for use" );
318 //=============================================================================
320 * standard constructor
322 //=============================================================================
323 HOMARD_Cas_i::HOMARD_Cas_i( CORBA::ORB_ptr orb,
324 SMESHHOMARD::HOMARD_Gen_var engine )
326 MESSAGE( "HOMARD_Cas_i" );
329 myHomardCas = new SMESHHOMARDImpl::HOMARD_Cas();
330 ASSERT( myHomardCas );
333 //=============================================================================
335 * standard destructor
337 //=============================================================================
338 HOMARD_Cas_i::~HOMARD_Cas_i()
341 //=============================================================================
342 //=============================================================================
344 //=============================================================================
345 //=============================================================================
346 void HOMARD_Cas_i::SetName( const char* Name )
348 ASSERT( myHomardCas );
349 myHomardCas->SetName( Name );
351 //=============================================================================
352 char* HOMARD_Cas_i::GetName()
354 ASSERT( myHomardCas );
355 return CORBA::string_dup( myHomardCas->GetName().c_str() );
357 //=============================================================================
358 CORBA::Long HOMARD_Cas_i::Delete( CORBA::Long Option )
360 ASSERT( myHomardCas );
361 char* CaseName = GetName();
362 MESSAGE ( "Delete : destruction du cas " << CaseName << ", Option = " << Option );
363 return _gen_i->DeleteCase(CaseName, Option);
365 //=============================================================================
366 char* HOMARD_Cas_i::GetDumpPython()
368 ASSERT( myHomardCas );
369 return CORBA::string_dup( myHomardCas->GetDumpPython().c_str() );
371 //=============================================================================
372 std::string HOMARD_Cas_i::Dump() const
374 return SMESHHOMARDImpl::Dump( *myHomardCas );
376 //=============================================================================
377 bool HOMARD_Cas_i::Restore( const std::string& stream )
379 return SMESHHOMARDImpl::Restore( *myHomardCas, stream );
381 //=============================================================================
382 //=============================================================================
384 //=============================================================================
385 //=============================================================================
386 void HOMARD_Cas_i::SetDirName( const char* NomDir )
388 ASSERT( myHomardCas );
390 // A. recuperation du nom; on ne fait rien si c'est le meme
391 char* oldrep = GetDirName();
392 if ( strcmp(oldrep,NomDir) == 0 ) return;
393 MESSAGE ( "SetDirName : passage de oldrep = "<< oldrep << " a NomDir = "<<NomDir);
394 // B. controle de l'usage du repertoire
395 char* CaseName = GetName();
396 char* casenamedir = _gen_i->VerifieDir(NomDir);
397 if ( ( std::string(casenamedir).size() > 0 ) & ( strcmp(CaseName,casenamedir)!=0 ) )
399 INFOS ( "Le repertoire " << NomDir << " est deja utilise pour le cas "<< casenamedir );
400 SALOME::ExceptionStruct es;
401 es.type = SALOME::BAD_PARAM;
403 text = "The directory " + std::string(NomDir) + " is already used for the case " + std::string(casenamedir);
404 es.text = CORBA::string_dup(text.c_str());
405 throw SALOME::SALOME_Exception(es);
407 // C. Changement/creation du repertoire
408 codret = myHomardCas->SetDirName( NomDir );
411 SALOME::ExceptionStruct es;
412 es.type = SALOME::BAD_PARAM;
414 if ( codret == 1 ) { text = "The directory for the case cannot be modified because some iterations are already defined."; }
415 else { text = "The directory for the case cannot be reached."; }
416 es.text = CORBA::string_dup(text.c_str());
417 throw SALOME::SALOME_Exception(es);
419 // D. En cas de reprise, deplacement du point de depart
420 if ( GetState() != 0 )
422 MESSAGE ( "etat : " << GetState() );
423 // D.1. Nom local du repertoire de l'iteration de depart dans le repertoire actuel du cas
424 SMESHHOMARD::HOMARD_Iteration_ptr Iter = GetIter0();
425 char* DirNameIter = Iter->GetDirNameLoc();
426 MESSAGE ( "SetDirName : nom actuel pour le repertoire de l iteration, DirNameIter = "<< DirNameIter);
427 // D.2. Recherche d'un nom local pour l'iteration de depart dans le futur repertoire du cas
428 char* nomDirIter = _gen_i->CreateDirNameIter(NomDir, 0 );
429 MESSAGE ( "SetDirName : nom futur pour le repertoire de l iteration, nomDirIter = "<< nomDirIter);
430 // D.3. Creation du futur repertoire local pour l'iteration de depart
431 std::string nomDirIterTotal;
432 nomDirIterTotal = std::string(NomDir) + "/" + std::string(nomDirIter);
434 if (mkdir(nomDirIterTotal.c_str(), S_IRWXU|S_IRGRP|S_IXGRP) != 0)
436 if (_mkdir(nomDirIterTotal.c_str()) != 0)
439 MESSAGE ( "nomDirIterTotal : " << nomDirIterTotal );
440 SALOME::ExceptionStruct es;
441 es.type = SALOME::BAD_PARAM;
442 std::string text = "The directory for the starting iteration cannot be created.";
443 es.text = CORBA::string_dup(text.c_str());
444 throw SALOME::SALOME_Exception(es);
446 // D.4. Deplacement du contenu du repertoire
447 std::string oldnomDirIterTotal;
448 oldnomDirIterTotal = std::string(oldrep) + "/" + std::string(DirNameIter);
449 std::string commande = "mv " + std::string(oldnomDirIterTotal) + "/*" + " " + std::string(nomDirIterTotal);
450 codret = system(commande.c_str());
453 SALOME::ExceptionStruct es;
454 es.type = SALOME::BAD_PARAM;
455 std::string text = "The starting point for the case cannot be moved into the new directory.";
456 es.text = CORBA::string_dup(text.c_str());
457 throw SALOME::SALOME_Exception(es);
459 commande = "rm -rf " + std::string(oldnomDirIterTotal);
460 codret = system(commande.c_str());
463 SALOME::ExceptionStruct es;
464 es.type = SALOME::BAD_PARAM;
465 std::string text = "The starting point for the case cannot be deleted.";
466 es.text = CORBA::string_dup(text.c_str());
467 throw SALOME::SALOME_Exception(es);
469 // D.5. Memorisation du nom du repertoire de l'iteration
470 Iter->SetDirNameLoc(nomDirIter);
473 //=============================================================================
474 char* HOMARD_Cas_i::GetDirName()
476 ASSERT( myHomardCas );
477 return CORBA::string_dup( myHomardCas->GetDirName().c_str() );
479 //=============================================================================
480 CORBA::Long HOMARD_Cas_i::GetState()
482 ASSERT( myHomardCas );
483 // Nom de l'iteration initiale
484 char* Iter0Name = GetIter0Name();
485 SMESHHOMARD::HOMARD_Iteration_ptr Iter = _gen_i->GetIteration(Iter0Name);
486 int state = Iter->GetNumber();
489 //=============================================================================
490 CORBA::Long HOMARD_Cas_i::GetNumberofIter()
492 ASSERT( myHomardCas );
493 return myHomardCas->GetNumberofIter();
495 //=============================================================================
496 void HOMARD_Cas_i::SetConfType( CORBA::Long ConfType )
498 ASSERT( myHomardCas );
499 // VERIFICATION( (ConfType>=-2) && (ConfType<=3) );
500 myHomardCas->SetConfType( ConfType );
502 //=============================================================================
503 CORBA::Long HOMARD_Cas_i::GetConfType()
505 ASSERT( myHomardCas );
506 return myHomardCas->GetConfType();
508 //=============================================================================
509 void HOMARD_Cas_i::SetExtType( CORBA::Long ExtType )
511 ASSERT( myHomardCas );
512 // VERIFICATION( (ExtType>=0) && (ExtType<=2) );
513 myHomardCas->SetExtType( ExtType );
515 //=============================================================================
516 CORBA::Long HOMARD_Cas_i::GetExtType()
518 ASSERT( myHomardCas );
519 return myHomardCas->GetExtType();
521 //=============================================================================
522 void HOMARD_Cas_i::SetBoundingBox( const SMESHHOMARD::extrema& LesExtrema )
524 ASSERT( myHomardCas );
525 std::vector<double> VExtrema;
526 ASSERT( LesExtrema.length() == 10 );
527 VExtrema.resize( LesExtrema.length() );
528 for ( int i = 0; i < LesExtrema.length(); i++ )
530 VExtrema[i] = LesExtrema[i];
532 myHomardCas->SetBoundingBox( VExtrema );
534 //=============================================================================
535 SMESHHOMARD::extrema* HOMARD_Cas_i::GetBoundingBox()
537 ASSERT(myHomardCas );
538 SMESHHOMARD::extrema_var aResult = new SMESHHOMARD::extrema();
539 std::vector<double> LesExtremes = myHomardCas->GetBoundingBox();
540 ASSERT( LesExtremes.size() == 10 );
541 aResult->length( 10 );
542 for ( int i = 0; i < LesExtremes.size(); i++ )
544 aResult[i] = LesExtremes[i];
546 return aResult._retn();
548 //=============================================================================
549 void HOMARD_Cas_i::AddGroup( const char* Group)
551 ASSERT( myHomardCas );
552 myHomardCas->AddGroup( Group );
554 //=============================================================================
555 void HOMARD_Cas_i::SetGroups( const SMESHHOMARD::ListGroupType& ListGroup )
557 ASSERT( myHomardCas );
558 std::list<std::string> ListString;
559 for ( int i = 0; i < ListGroup.length(); i++ )
561 ListString.push_back(std::string(ListGroup[i]));
563 myHomardCas->SetGroups( ListString );
565 //=============================================================================
566 SMESHHOMARD::ListGroupType* HOMARD_Cas_i::GetGroups()
568 ASSERT(myHomardCas );
569 const std::list<std::string>& ListString = myHomardCas->GetGroups();
570 SMESHHOMARD::ListGroupType_var aResult = new SMESHHOMARD::ListGroupType();
571 aResult->length( ListString.size() );
572 std::list<std::string>::const_iterator it;
574 for ( it = ListString.begin(); it != ListString.end(); it++ )
576 aResult[i++] = CORBA::string_dup( (*it).c_str() );
578 return aResult._retn();
580 //=============================================================================
581 void HOMARD_Cas_i::AddBoundary(const char* BoundaryName)
583 MESSAGE ("HOMARD_Cas_i::AddBoundary : BoundaryName = "<< BoundaryName );
584 const char * Group = "";
585 AddBoundaryGroup( BoundaryName, Group);
587 //=============================================================================
588 void HOMARD_Cas_i::AddBoundaryGroup( const char* BoundaryName, const char* Group)
590 MESSAGE ("HOMARD_Cas_i::AddBoundaryGroup : BoundaryName = "<< BoundaryName << ", Group = " << Group );
591 ASSERT( myHomardCas );
593 // A.1. Caractéristiques de la frontière à ajouter
594 SMESHHOMARD::HOMARD_Boundary_ptr myBoundary = _gen_i->GetBoundary(BoundaryName);
595 ASSERT(!CORBA::is_nil(myBoundary));
596 int BoundaryType = myBoundary->GetType();
597 MESSAGE ( ". BoundaryType = " << BoundaryType );
598 // A.2. La liste des frontiere+groupes
599 const std::list<std::string>& ListBoundaryGroup = myHomardCas->GetBoundaryGroup();
600 std::list<std::string>::const_iterator it;
604 while ( erreur == 0 )
606 // B.1. Si on ajoute une frontière CAO, elle doit être la seule frontière
607 if ( BoundaryType == -1 )
609 for ( it = ListBoundaryGroup.begin(); it != ListBoundaryGroup.end(); it++ )
611 boun = (*it).c_str();
612 MESSAGE (".. Frontiere enregistrée : "<< boun );
613 if ( *it != BoundaryName )
616 // On saute le nom du groupe
620 if ( erreur != 0 ) { break; }
621 // B.2. Si on ajoute une frontière non CAO, il ne doit pas y avoir de frontière CAO
622 if ( BoundaryType != -1 )
624 for ( it = ListBoundaryGroup.begin(); it != ListBoundaryGroup.end(); it++ )
626 boun = (*it).c_str();
627 MESSAGE (".. Frontiere enregistrée : "<< boun );
628 SMESHHOMARD::HOMARD_Boundary_ptr myBoundary_0 = _gen_i->GetBoundary(boun);
629 int BoundaryType_0 = myBoundary_0->GetType();
630 MESSAGE ( ".. BoundaryType_0 = " << BoundaryType_0 );
631 if ( BoundaryType_0 == -1 )
634 // On saute le nom du groupe
637 if ( erreur != 0 ) { break; }
639 // B.3. Si on ajoute une frontière discrète, il ne doit pas y avoir d'autre frontière discrète
640 if ( BoundaryType == 0 )
642 for ( it = ListBoundaryGroup.begin(); it != ListBoundaryGroup.end(); it++ )
644 boun = (*it).c_str();
645 MESSAGE (".. Frontiere enregistrée : "<< boun );
646 if ( boun != BoundaryName )
648 SMESHHOMARD::HOMARD_Boundary_ptr myBoundary_0 = _gen_i->GetBoundary(boun);
649 int BoundaryType_0 = myBoundary_0->GetType();
650 MESSAGE ( ".. BoundaryType_0 = " << BoundaryType_0 );
651 if ( BoundaryType_0 == 0 )
655 // On saute le nom du groupe
658 if ( erreur != 0 ) { break; }
660 // B.4. Pour une nouvelle frontiere, publication dans l'arbre d'etudes sous le cas
662 for ( it = ListBoundaryGroup.begin(); it != ListBoundaryGroup.end(); it++ )
664 MESSAGE (".. Frontiere : "<< *it );
665 if ( *it == BoundaryName ) { existe = true; }
666 // On saute le nom du groupe
669 // B.5. Le groupe est-il deja enregistre pour une frontiere de ce cas ?
670 for ( it = ListBoundaryGroup.begin(); it != ListBoundaryGroup.end(); it++ )
672 boun = (*it).c_str();
674 MESSAGE (".. Groupe enregistré : "<< *it );
679 if ( erreur != 0 ) { break; }
683 // F. Si aucune erreur, enregistrement du couple (frontiere,groupe) dans la reference du cas
686 { myHomardCas->AddBoundaryGroup( BoundaryName, Group ); }
689 std::stringstream ss;
691 std::string str = ss.str();
693 texte = "Erreur numéro " + str + " pour la frontière à enregistrer : " + std::string(BoundaryName);
694 if ( erreur == 1 ) { texte += "\nIl existe déjà la frontière "; }
695 else if ( erreur == 2 ) { texte += "\nIl existe déjà la frontière CAO "; }
696 else if ( erreur == 3 ) { texte += "\nIl existe déjà une frontière discrète : "; }
697 else if ( erreur == 5 ) { texte += "\nLe groupe " + std::string(Group) + " est déjà enregistré pour la frontière "; }
698 texte += std::string(boun);
700 SALOME::ExceptionStruct es;
701 es.type = SALOME::BAD_PARAM;
703 texte += "\nInvalid AddBoundaryGroup";
706 es.text = CORBA::string_dup(texte.c_str());
707 throw SALOME::SALOME_Exception(es);
710 //=============================================================================
711 SMESHHOMARD::ListBoundaryGroupType* HOMARD_Cas_i::GetBoundaryGroup()
713 MESSAGE ("GetBoundaryGroup");
714 ASSERT(myHomardCas );
715 const std::list<std::string>& ListBoundaryGroup = myHomardCas->GetBoundaryGroup();
716 SMESHHOMARD::ListBoundaryGroupType_var aResult = new SMESHHOMARD::ListBoundaryGroupType();
717 aResult->length( ListBoundaryGroup.size() );
718 std::list<std::string>::const_iterator it;
720 for ( it = ListBoundaryGroup.begin(); it != ListBoundaryGroup.end(); it++ )
722 aResult[i++] = CORBA::string_dup( (*it).c_str() );
724 return aResult._retn();
726 //=============================================================================
727 void HOMARD_Cas_i::SupprBoundaryGroup()
729 MESSAGE ("SupprBoundaryGroup");
730 ASSERT(myHomardCas );
731 myHomardCas->SupprBoundaryGroup();
733 //=============================================================================
734 void HOMARD_Cas_i::SetPyram( CORBA::Long Pyram )
736 MESSAGE ("SetPyram, Pyram = " << Pyram );
737 ASSERT( myHomardCas );
738 myHomardCas->SetPyram( Pyram );
740 //=============================================================================
741 CORBA::Long HOMARD_Cas_i::GetPyram()
743 MESSAGE ("GetPyram");
744 ASSERT( myHomardCas );
745 return myHomardCas->GetPyram();
747 //=============================================================================
748 void HOMARD_Cas_i::MeshInfo(CORBA::Long Qual, CORBA::Long Diam, CORBA::Long Conn, CORBA::Long Tail, CORBA::Long Inte)
750 MESSAGE ( "MeshInfo : information sur le maillage initial du cas" );
751 ASSERT( myHomardCas );
753 // Nom de l'iteration
754 char* IterName = GetIter0Name();
755 CORBA::Long etatMenage = -1;
756 CORBA::Long modeHOMARD = 7;
757 CORBA::Long Option1 = 1;
758 CORBA::Long Option2 = 1;
759 if ( Qual != 0 ) { modeHOMARD = modeHOMARD*5; }
760 if ( Diam != 0 ) { modeHOMARD = modeHOMARD*19; }
761 if ( Conn != 0 ) { modeHOMARD = modeHOMARD*11; }
762 if ( Tail != 0 ) { modeHOMARD = modeHOMARD*13; }
763 if ( Inte != 0 ) { modeHOMARD = modeHOMARD*3; }
764 CORBA::Long codret = _gen_i->Compute(IterName, etatMenage, modeHOMARD, Option1, Option2);
765 MESSAGE ( "MeshInfo : codret = " << codret );
767 //=============================================================================
768 //=============================================================================
769 // Liens avec les autres structures
770 //=============================================================================
771 //=============================================================================
772 char* HOMARD_Cas_i::GetIter0Name()
774 ASSERT( myHomardCas );
775 return CORBA::string_dup( myHomardCas->GetIter0Name().c_str() );
777 //=============================================================================
778 SMESHHOMARD::HOMARD_Iteration_ptr HOMARD_Cas_i::GetIter0()
780 // Nom de l'iteration initiale
781 char* Iter0Name = GetIter0Name();
782 MESSAGE ( "GetIter0 : Iter0Name = " << Iter0Name );
783 return _gen_i->GetIteration(Iter0Name);
785 //=============================================================================
786 SMESHHOMARD::HOMARD_Iteration_ptr HOMARD_Cas_i::NextIteration( const char* IterName )
788 MESSAGE ( "NextIteration : IterName = " << IterName );
789 // Nom de l'iteration parent
790 char* NomIterParent = GetIter0Name();
791 MESSAGE ( "NextIteration : NomIterParent = " << NomIterParent );
792 return _gen_i->CreateIteration(IterName, NomIterParent);
794 //=============================================================================
795 SMESHHOMARD::HOMARD_Iteration_ptr HOMARD_Cas_i::LastIteration( )
797 SMESHHOMARD::HOMARD_Iteration_ptr Iter;
798 SMESHHOMARD::listeIterFilles_var ListeIterFilles;
800 // Iteration initiale du cas
801 IterName = GetIter0Name();
802 // On va explorer la descendance de cette iteration initiale
803 // jusqu'a trouver celle qui n'a pas de filles
804 int nbiterfilles = 1;
805 while ( nbiterfilles == 1 )
807 // L'iteration associee
808 // MESSAGE ( ".. IterName = " << IterName );
809 Iter = _gen_i->GetIteration(IterName);
810 // Les filles de cette iteration
811 ListeIterFilles = Iter->GetIterations();
812 nbiterfilles = ListeIterFilles->length();
813 // MESSAGE ( ".. nbiterfilles = " << nbiterfilles );
814 // S'il y a au moins 2 filles, arret : on ne sait pas faire
815 VERIFICATION( nbiterfilles <= 1 );
816 // S'il y a une fille unique, on recupere le nom de la fille et on recommence
817 if ( nbiterfilles == 1 )
818 { IterName = ListeIterFilles[0]; }
823 //=============================================================================
824 void HOMARD_Cas_i::AddIteration( const char* NomIteration )
826 ASSERT( myHomardCas );
827 myHomardCas->AddIteration( NomIteration );
830 //=============================================================================
832 * standard constructor
834 //=============================================================================
835 HOMARD_Hypothesis_i::HOMARD_Hypothesis_i()
837 MESSAGE( "Default constructor, not for use" );
841 //=============================================================================
843 * standard constructor
845 //=============================================================================
846 HOMARD_Hypothesis_i::HOMARD_Hypothesis_i( CORBA::ORB_ptr orb,
847 SMESHHOMARD::HOMARD_Gen_var engine )
849 MESSAGE( "standard constructor" );
852 myHomardHypothesis = new SMESHHOMARDImpl::HOMARD_Hypothesis();
853 ASSERT( myHomardHypothesis );
856 //=============================================================================
858 * standard destructor
860 //=============================================================================
861 HOMARD_Hypothesis_i::~HOMARD_Hypothesis_i()
864 //=============================================================================
865 //=============================================================================
867 //=============================================================================
868 //=============================================================================
869 void HOMARD_Hypothesis_i::SetName( const char* Name )
871 ASSERT( myHomardHypothesis );
872 myHomardHypothesis->SetName( Name );
874 //=============================================================================
875 char* HOMARD_Hypothesis_i::GetName()
877 ASSERT( myHomardHypothesis );
878 return CORBA::string_dup( myHomardHypothesis->GetName().c_str() );
880 //=============================================================================
881 CORBA::Long HOMARD_Hypothesis_i::Delete()
883 ASSERT( myHomardHypothesis );
884 char* HypoName = GetName();
885 MESSAGE ( "Delete : destruction de l'hypothese " << HypoName );
886 return _gen_i->DeleteHypo(HypoName);
888 //=============================================================================
889 char* HOMARD_Hypothesis_i::GetDumpPython()
891 ASSERT( myHomardHypothesis );
892 return CORBA::string_dup( myHomardHypothesis->GetDumpPython().c_str() );
894 //=============================================================================
895 std::string HOMARD_Hypothesis_i::Dump() const
897 return SMESHHOMARDImpl::Dump( *myHomardHypothesis );
899 //=============================================================================
900 bool HOMARD_Hypothesis_i::Restore( const std::string& stream )
902 return SMESHHOMARDImpl::Restore( *myHomardHypothesis, stream );
904 //=============================================================================
905 //=============================================================================
907 //=============================================================================
908 //=============================================================================
909 void HOMARD_Hypothesis_i::SetUnifRefinUnRef( CORBA::Long TypeRaffDera )
911 ASSERT( myHomardHypothesis );
912 VERIFICATION( (TypeRaffDera==1) || (TypeRaffDera==-1) );
913 int TypeRaff, TypeDera;
914 if ( TypeRaffDera == 1 )
919 else if ( TypeRaffDera == -1 )
924 myHomardHypothesis->SetAdapType( -1 );
925 myHomardHypothesis->SetRefinTypeDera( TypeRaff, TypeDera );
927 //=============================================================================
928 SMESHHOMARD::listeTypes* HOMARD_Hypothesis_i::GetAdapRefinUnRef()
930 ASSERT( myHomardHypothesis );
931 SMESHHOMARD::listeTypes_var aResult = new SMESHHOMARD::listeTypes;
932 aResult->length( 3 );
933 aResult[0] = CORBA::Long( myHomardHypothesis->GetAdapType() );
934 aResult[1] = CORBA::Long( myHomardHypothesis->GetRefinType() );
935 aResult[2] = CORBA::Long( myHomardHypothesis->GetUnRefType() );
936 return aResult._retn();
938 //=============================================================================
939 CORBA::Long HOMARD_Hypothesis_i::GetAdapType()
941 ASSERT( myHomardHypothesis );
942 return CORBA::Long( myHomardHypothesis->GetAdapType() );
944 //=============================================================================
945 CORBA::Long HOMARD_Hypothesis_i::GetRefinType()
947 ASSERT( myHomardHypothesis );
948 return CORBA::Long( myHomardHypothesis->GetRefinType() );
950 //=============================================================================
951 CORBA::Long HOMARD_Hypothesis_i::GetUnRefType()
953 ASSERT( myHomardHypothesis );
954 return CORBA::Long( myHomardHypothesis->GetUnRefType() );
956 //=============================================================================
957 void HOMARD_Hypothesis_i::SetField( const char* FieldName )
959 myHomardHypothesis->SetField( FieldName );
961 //=============================================================================
962 char* HOMARD_Hypothesis_i::GetFieldName()
964 ASSERT( myHomardHypothesis );
965 return CORBA::string_dup( myHomardHypothesis->GetFieldName().c_str() );
967 //=============================================================================
968 void HOMARD_Hypothesis_i::SetUseField( CORBA::Long UsField )
970 myHomardHypothesis->SetUseField( UsField );
972 //=============================================================================
973 SMESHHOMARD::InfosHypo* HOMARD_Hypothesis_i::GetField()
975 ASSERT( myHomardHypothesis );
976 SMESHHOMARD::InfosHypo* aInfosHypo = new SMESHHOMARD::InfosHypo();
977 aInfosHypo->FieldName = CORBA::string_dup( myHomardHypothesis->GetFieldName().c_str() );
978 aInfosHypo->TypeThR = CORBA::Long( myHomardHypothesis->GetRefinThrType() );
979 aInfosHypo->ThreshR = CORBA::Double( myHomardHypothesis->GetThreshR() );
980 aInfosHypo->TypeThC = CORBA::Long( myHomardHypothesis->GetUnRefThrType() );
981 aInfosHypo->ThreshC = CORBA::Double( myHomardHypothesis->GetThreshC() );
982 aInfosHypo->UsField = CORBA::Long( myHomardHypothesis->GetUseField() );
983 aInfosHypo->UsCmpI = CORBA::Long( myHomardHypothesis->GetUseComp() );
986 //=============================================================================
987 void HOMARD_Hypothesis_i::SetUseComp( CORBA::Long UsCmpI )
989 myHomardHypothesis->SetUseComp( UsCmpI );
991 //=============================================================================
992 void HOMARD_Hypothesis_i::AddComp( const char* NomComp )
994 ASSERT( myHomardHypothesis );
995 myHomardHypothesis->AddComp( NomComp );
997 //=============================================================================
998 void HOMARD_Hypothesis_i::SupprComp( const char* NomComp )
1000 ASSERT( myHomardHypothesis );
1001 myHomardHypothesis->SupprComp(NomComp);
1003 //=============================================================================
1004 void HOMARD_Hypothesis_i::SupprComps()
1006 ASSERT( myHomardHypothesis );
1007 myHomardHypothesis->SupprComps();
1009 //=============================================================================
1010 SMESHHOMARD::listeComposantsHypo* HOMARD_Hypothesis_i::GetComps()
1012 ASSERT( myHomardHypothesis );
1013 const std::list<std::string>& ListString = myHomardHypothesis->GetComps();
1014 SMESHHOMARD::listeComposantsHypo_var aResult = new SMESHHOMARD::listeComposantsHypo;
1015 aResult->length( ListString.size() );
1016 std::list<std::string>::const_iterator it;
1018 for ( it = ListString.begin(); it != ListString.end(); it++ )
1020 aResult[i++] = CORBA::string_dup( (*it).c_str() );
1022 return aResult._retn();
1024 //=============================================================================
1025 void HOMARD_Hypothesis_i::SetRefinThr( CORBA::Long TypeThR, CORBA::Double ThreshR )
1027 myHomardHypothesis->SetAdapType( 1 );
1030 int TypeDera = myHomardHypothesis->GetUnRefType();
1031 myHomardHypothesis->SetRefinTypeDera( 1, TypeDera );
1033 myHomardHypothesis->SetRefinThr( TypeThR, ThreshR );
1035 //=============================================================================
1036 CORBA::Long HOMARD_Hypothesis_i::GetRefinThrType()
1038 ASSERT( myHomardHypothesis );
1039 return CORBA::Long( myHomardHypothesis->GetRefinThrType() );
1041 //=============================================================================
1042 void HOMARD_Hypothesis_i::SetUnRefThr( CORBA::Long TypeThC, CORBA::Double ThreshC )
1044 myHomardHypothesis->SetAdapType( 1 );
1047 int TypeRaff = myHomardHypothesis->GetRefinType();
1048 myHomardHypothesis->SetRefinTypeDera( TypeRaff, 1 );
1050 myHomardHypothesis->SetUnRefThr( TypeThC, ThreshC );
1052 //=============================================================================
1053 CORBA::Long HOMARD_Hypothesis_i::GetUnRefThrType()
1055 ASSERT( myHomardHypothesis );
1056 return CORBA::Long( myHomardHypothesis->GetUnRefThrType() );
1058 //=============================================================================
1059 void HOMARD_Hypothesis_i::SetNivMax( CORBA::Long NivMax )
1061 ASSERT( myHomardHypothesis );
1062 myHomardHypothesis->SetNivMax( NivMax );
1064 //=============================================================================
1065 CORBA::Long HOMARD_Hypothesis_i::GetNivMax()
1067 ASSERT( myHomardHypothesis );
1068 return myHomardHypothesis->GetNivMax();
1070 //=============================================================================
1071 void HOMARD_Hypothesis_i::SetDiamMin( CORBA::Double DiamMin )
1073 ASSERT( myHomardHypothesis );
1074 myHomardHypothesis->SetDiamMin( DiamMin );
1076 //=============================================================================
1077 CORBA::Double HOMARD_Hypothesis_i::GetDiamMin()
1079 ASSERT( myHomardHypothesis );
1080 return myHomardHypothesis->GetDiamMin();
1082 //=============================================================================
1083 void HOMARD_Hypothesis_i::SetAdapInit( CORBA::Long AdapInit )
1085 ASSERT( myHomardHypothesis );
1086 myHomardHypothesis->SetAdapInit( AdapInit );
1088 //=============================================================================
1089 CORBA::Long HOMARD_Hypothesis_i::GetAdapInit()
1091 ASSERT( myHomardHypothesis );
1092 return myHomardHypothesis->GetAdapInit();
1094 //=============================================================================
1095 void HOMARD_Hypothesis_i::SetExtraOutput( CORBA::Long ExtraOutput )
1097 ASSERT( myHomardHypothesis );
1098 myHomardHypothesis->SetExtraOutput( ExtraOutput );
1100 //=============================================================================
1101 CORBA::Long HOMARD_Hypothesis_i::GetExtraOutput()
1103 ASSERT( myHomardHypothesis );
1104 return myHomardHypothesis->GetExtraOutput();
1106 //=============================================================================
1107 void HOMARD_Hypothesis_i::AddGroup( const char* Group)
1109 ASSERT( myHomardHypothesis );
1110 myHomardHypothesis->AddGroup( Group );
1112 //=============================================================================
1113 void HOMARD_Hypothesis_i::SupprGroup( const char* Group )
1115 ASSERT( myHomardHypothesis );
1116 myHomardHypothesis->SupprGroup(Group);
1118 //=============================================================================
1119 void HOMARD_Hypothesis_i::SupprGroups()
1121 ASSERT( myHomardHypothesis );
1122 myHomardHypothesis->SupprGroups();
1124 //=============================================================================
1125 void HOMARD_Hypothesis_i::SetGroups(const SMESHHOMARD::ListGroupType& ListGroup)
1127 ASSERT( myHomardHypothesis );
1128 std::list<std::string> ListString;
1129 for ( int i = 0; i < ListGroup.length(); i++ )
1131 ListString.push_back(std::string(ListGroup[i]));
1133 myHomardHypothesis->SetGroups( ListString );
1135 //=============================================================================
1136 SMESHHOMARD::ListGroupType* HOMARD_Hypothesis_i::GetGroups()
1138 ASSERT( myHomardHypothesis );
1139 const std::list<std::string>& ListString = myHomardHypothesis->GetGroups();
1140 SMESHHOMARD::ListGroupType_var aResult = new SMESHHOMARD::ListGroupType;
1141 aResult->length( ListString.size() );
1142 std::list<std::string>::const_iterator it;
1144 for ( it = ListString.begin(); it != ListString.end(); it++ )
1146 aResult[i++] = CORBA::string_dup( (*it).c_str() );
1148 return aResult._retn();
1150 //=============================================================================
1151 void HOMARD_Hypothesis_i::SetTypeFieldInterp( CORBA::Long TypeFieldInterp )
1153 ASSERT( myHomardHypothesis );
1154 myHomardHypothesis->SetTypeFieldInterp( TypeFieldInterp );
1156 //=============================================================================
1157 CORBA::Long HOMARD_Hypothesis_i::GetTypeFieldInterp()
1159 ASSERT( myHomardHypothesis );
1160 return CORBA::Long( myHomardHypothesis->GetTypeFieldInterp() );
1162 //=============================================================================
1163 void HOMARD_Hypothesis_i::AddFieldInterp( const char* FieldInterp )
1165 ASSERT( myHomardHypothesis );
1166 myHomardHypothesis->AddFieldInterpType( FieldInterp, 0 );
1168 //=============================================================================
1169 void HOMARD_Hypothesis_i::AddFieldInterpType( const char* FieldInterp, CORBA::Long TypeInterp )
1171 ASSERT( myHomardHypothesis );
1172 myHomardHypothesis->AddFieldInterpType( FieldInterp, TypeInterp );
1174 //=============================================================================
1175 void HOMARD_Hypothesis_i::SupprFieldInterp( const char* FieldInterp )
1177 ASSERT( myHomardHypothesis );
1178 myHomardHypothesis->SupprFieldInterp(FieldInterp);
1180 //=============================================================================
1181 void HOMARD_Hypothesis_i::SupprFieldInterps()
1183 ASSERT( myHomardHypothesis );
1184 myHomardHypothesis->SupprFieldInterps();
1186 //=============================================================================
1187 SMESHHOMARD::listeFieldInterpsHypo* HOMARD_Hypothesis_i::GetFieldInterps()
1189 ASSERT( myHomardHypothesis );
1190 const std::list<std::string>& ListString = myHomardHypothesis->GetFieldInterps();
1191 SMESHHOMARD::listeFieldInterpsHypo_var aResult = new SMESHHOMARD::listeFieldInterpsHypo;
1192 aResult->length( ListString.size() );
1193 std::list<std::string>::const_iterator it;
1195 for ( it = ListString.begin(); it != ListString.end(); it++ )
1197 aResult[i++] = CORBA::string_dup( (*it).c_str() );
1199 return aResult._retn();
1201 //=============================================================================
1202 //=============================================================================
1203 // Liens avec les autres structures
1204 //=============================================================================
1205 //=============================================================================
1206 void HOMARD_Hypothesis_i::SetCaseCreation( const char* NomCaseCreation )
1208 ASSERT( myHomardHypothesis );
1209 myHomardHypothesis->SetCaseCreation( NomCaseCreation );
1211 //=============================================================================
1212 char* HOMARD_Hypothesis_i::GetCaseCreation()
1214 ASSERT( myHomardHypothesis );
1215 return CORBA::string_dup( myHomardHypothesis->GetCaseCreation().c_str() );
1217 //=============================================================================
1218 void HOMARD_Hypothesis_i::LinkIteration( const char* NomIteration )
1220 ASSERT( myHomardHypothesis );
1221 myHomardHypothesis->LinkIteration( NomIteration );
1223 //=============================================================================
1224 void HOMARD_Hypothesis_i::UnLinkIteration( const char* NomIteration )
1226 ASSERT( myHomardHypothesis );
1227 myHomardHypothesis->UnLinkIteration( NomIteration );
1229 //=============================================================================
1230 SMESHHOMARD::listeIters* HOMARD_Hypothesis_i::GetIterations()
1232 ASSERT( myHomardHypothesis );
1233 const std::list<std::string>& ListString = myHomardHypothesis->GetIterations();
1234 SMESHHOMARD::listeIters_var aResult = new SMESHHOMARD::listeIters;
1235 aResult->length( ListString.size() );
1236 std::list<std::string>::const_iterator it;
1238 for ( it = ListString.begin(); it != ListString.end(); it++ )
1240 aResult[i++] = CORBA::string_dup( (*it).c_str() );
1242 return aResult._retn();
1245 //=============================================================================
1247 * standard constructor
1249 //=============================================================================
1250 HOMARD_Iteration_i::HOMARD_Iteration_i()
1252 MESSAGE( "Default constructor, not for use" );
1255 //=============================================================================
1257 * standard constructor
1259 //=============================================================================
1260 HOMARD_Iteration_i::HOMARD_Iteration_i( CORBA::ORB_ptr orb,
1261 SMESHHOMARD::HOMARD_Gen_var engine )
1263 MESSAGE("constructor");
1266 myHomardIteration = new SMESHHOMARDImpl::HOMARD_Iteration();
1267 ASSERT( myHomardIteration );
1269 //=============================================================================
1271 * standard destructor
1273 //=============================================================================
1274 HOMARD_Iteration_i::~HOMARD_Iteration_i()
1277 //=============================================================================
1278 //=============================================================================
1280 //=============================================================================
1281 //=============================================================================
1282 void HOMARD_Iteration_i::SetName( const char* Name )
1284 ASSERT( myHomardIteration );
1285 myHomardIteration->SetName( Name );
1287 //=============================================================================
1288 char* HOMARD_Iteration_i::GetName()
1290 ASSERT( myHomardIteration );
1291 return CORBA::string_dup( myHomardIteration->GetName().c_str() );
1294 //=============================================================================
1295 CORBA::Long HOMARD_Iteration_i::Delete( CORBA::Long Option, bool doRemoveWorkingFiles )
1297 ASSERT( myHomardIteration );
1298 char* IterName = GetName();
1299 MESSAGE ( "Delete : destruction de l'iteration " << IterName << ", Option = " << Option );
1300 return _gen_i->DeleteIteration(IterName, Option, doRemoveWorkingFiles);
1303 //=============================================================================
1304 char* HOMARD_Iteration_i::GetDumpPython()
1306 ASSERT( myHomardIteration );
1307 return CORBA::string_dup( myHomardIteration->GetDumpPython().c_str() );
1309 //=============================================================================
1310 std::string HOMARD_Iteration_i::Dump() const
1312 return SMESHHOMARDImpl::Dump( *myHomardIteration );
1314 //=============================================================================
1315 bool HOMARD_Iteration_i::Restore( const std::string& stream )
1317 return SMESHHOMARDImpl::Restore( *myHomardIteration, stream );
1319 //=============================================================================
1320 //=============================================================================
1322 //=============================================================================
1323 //=============================================================================
1324 void HOMARD_Iteration_i::SetDirNameLoc( const char* NomDir )
1326 ASSERT( myHomardIteration );
1327 myHomardIteration->SetDirNameLoc( NomDir );
1329 //=============================================================================
1330 char* HOMARD_Iteration_i::GetDirNameLoc()
1332 ASSERT( myHomardIteration );
1333 return CORBA::string_dup( myHomardIteration->GetDirNameLoc().c_str() );
1335 //=============================================================================
1336 char* HOMARD_Iteration_i::GetDirName()
1338 ASSERT( myHomardIteration );
1339 std::string casename = myHomardIteration->GetCaseName();
1340 SMESHHOMARD::HOMARD_Cas_ptr caseiter = _gen_i->GetCase(casename.c_str());
1341 std::string dirnamecase = caseiter->GetDirName();
1342 std::string dirname = dirnamecase + "/" + GetDirNameLoc();
1343 return CORBA::string_dup( dirname.c_str() );
1345 //=============================================================================
1346 void HOMARD_Iteration_i::SetNumber( CORBA::Long NumIter )
1348 ASSERT( myHomardIteration );
1349 myHomardIteration->SetNumber( NumIter );
1351 //=============================================================================
1352 CORBA::Long HOMARD_Iteration_i::GetNumber()
1354 ASSERT( myHomardIteration );
1355 return myHomardIteration->GetNumber();
1357 //=============================================================================
1358 void HOMARD_Iteration_i::SetState( CORBA::Long Etat )
1360 ASSERT( myHomardIteration );
1361 myHomardIteration->SetState( Etat );
1363 //=============================================================================
1364 CORBA::Long HOMARD_Iteration_i::GetState()
1366 ASSERT( myHomardIteration );
1367 return myHomardIteration->GetState();
1369 //=============================================================================
1370 void HOMARD_Iteration_i::SetMeshName( const char* NomMesh )
1372 ASSERT( myHomardIteration );
1373 myHomardIteration->SetMeshName( NomMesh );
1375 //=============================================================================
1376 char* HOMARD_Iteration_i::GetMeshName()
1378 ASSERT( myHomardIteration );
1379 return CORBA::string_dup( myHomardIteration->GetMeshName().c_str() );
1381 //=============================================================================
1382 void HOMARD_Iteration_i::SetMeshFile( const char* MeshFile )
1384 ASSERT( myHomardIteration );
1385 myHomardIteration->SetMeshFile( MeshFile );
1387 //=============================================================================
1388 char* HOMARD_Iteration_i::GetMeshFile()
1390 ASSERT( myHomardIteration );
1391 return CORBA::string_dup( myHomardIteration->GetMeshFile().c_str() );
1393 //=============================================================================
1394 void HOMARD_Iteration_i::SetFieldFile( const char* FieldFile )
1396 ASSERT( myHomardIteration );
1397 myHomardIteration->SetFieldFile( FieldFile );
1399 //=============================================================================
1400 char* HOMARD_Iteration_i::GetFieldFile()
1402 ASSERT( myHomardIteration );
1403 return CORBA::string_dup( myHomardIteration->GetFieldFile().c_str() );
1405 //=============================================================================
1406 // Instants pour le champ de pilotage
1407 //=============================================================================
1408 void HOMARD_Iteration_i::SetTimeStep( CORBA::Long TimeStep )
1410 ASSERT( myHomardIteration );
1411 myHomardIteration->SetTimeStep( TimeStep );
1413 //=============================================================================
1414 void HOMARD_Iteration_i::SetTimeStepRank( CORBA::Long TimeStep, CORBA::Long Rank )
1416 ASSERT( myHomardIteration );
1417 myHomardIteration->SetTimeStepRank( TimeStep, Rank );
1419 //=============================================================================
1420 void HOMARD_Iteration_i::SetTimeStepRankLast()
1422 ASSERT( myHomardIteration );
1423 myHomardIteration->SetTimeStepRankLast();
1425 //=============================================================================
1426 CORBA::Long HOMARD_Iteration_i::GetTimeStep()
1428 ASSERT( myHomardIteration );
1429 return CORBA::Long( myHomardIteration->GetTimeStep() );
1431 //=============================================================================
1432 CORBA::Long HOMARD_Iteration_i::GetRank()
1434 ASSERT( myHomardIteration );
1435 return CORBA::Long( myHomardIteration->GetRank() );
1437 //=============================================================================
1438 // Instants pour un champ a interpoler
1439 //=============================================================================
1440 void HOMARD_Iteration_i::SetFieldInterpTimeStep( const char* FieldInterp, CORBA::Long TimeStep )
1442 SetFieldInterpTimeStepRank( FieldInterp, TimeStep, TimeStep );
1444 //=============================================================================
1445 void HOMARD_Iteration_i::SetFieldInterpTimeStepRank( const char* FieldInterp, CORBA::Long TimeStep, CORBA::Long Rank )
1447 ASSERT( myHomardIteration );
1448 myHomardIteration->SetFieldInterpTimeStepRank( FieldInterp, TimeStep, Rank );
1450 //=============================================================================
1451 SMESHHOMARD::listeFieldInterpTSRsIter* HOMARD_Iteration_i::GetFieldInterpsTimeStepRank()
1453 ASSERT( myHomardIteration );
1454 const std::list<std::string>& ListString = myHomardIteration->GetFieldInterpsTimeStepRank();
1455 SMESHHOMARD::listeFieldInterpTSRsIter_var aResult = new SMESHHOMARD::listeFieldInterpTSRsIter;
1456 aResult->length( ListString.size() );
1457 std::list<std::string>::const_iterator it;
1459 for ( it = ListString.begin(); it != ListString.end(); it++ )
1461 aResult[i++] = CORBA::string_dup( (*it).c_str() );
1463 return aResult._retn();
1465 //=============================================================================
1466 void HOMARD_Iteration_i::SetFieldInterp( const char* FieldInterp )
1468 myHomardIteration->SetFieldInterp( FieldInterp );
1470 //=============================================================================
1471 SMESHHOMARD::listeFieldInterpsIter* HOMARD_Iteration_i::GetFieldInterps()
1473 ASSERT( myHomardIteration );
1474 const std::list<std::string>& ListString = myHomardIteration->GetFieldInterps();
1475 SMESHHOMARD::listeFieldInterpsIter_var aResult = new SMESHHOMARD::listeFieldInterpsIter;
1476 aResult->length( ListString.size() );
1477 std::list<std::string>::const_iterator it;
1479 for ( it = ListString.begin(); it != ListString.end(); it++ )
1481 aResult[i++] = CORBA::string_dup( (*it).c_str() );
1483 return aResult._retn();
1485 //=============================================================================
1486 void HOMARD_Iteration_i::SupprFieldInterps()
1488 ASSERT( myHomardIteration );
1489 myHomardIteration->SupprFieldInterps();
1491 //=============================================================================
1492 void HOMARD_Iteration_i::SetLogFile( const char* LogFile )
1494 ASSERT( myHomardIteration );
1495 myHomardIteration->SetLogFile( LogFile );
1497 //=============================================================================
1498 char* HOMARD_Iteration_i::GetLogFile()
1500 ASSERT( myHomardIteration );
1501 return CORBA::string_dup( myHomardIteration->GetLogFile().c_str() );
1503 //=============================================================================
1504 CORBA::Long HOMARD_Iteration_i::Compute(CORBA::Long etatMenage, CORBA::Long Option)
1506 MESSAGE ( "Compute : calcul d'une iteration, etatMenage = "<<etatMenage<<", Option = "<<Option );
1507 ASSERT( myHomardIteration );
1509 // Nom de l'iteration
1510 char* IterName = GetName();
1511 CORBA::Long modeHOMARD = 1;
1512 CORBA::Long Option1 = 1;
1513 MESSAGE ( "Compute : calcul de l'teration " << IterName );
1514 return _gen_i->Compute(IterName, etatMenage, modeHOMARD, Option1, Option);
1516 //=============================================================================
1517 void HOMARD_Iteration_i::MeshInfo(CORBA::Long Qual, CORBA::Long Diam, CORBA::Long Conn, CORBA::Long Tail, CORBA::Long Inte)
1519 MESSAGE ( "MeshInfo : information sur le maillage associe a une iteration" );
1520 ASSERT( myHomardIteration );
1523 MeshInfoOption( Qual, Diam, Conn, Tail, Inte, Option );
1525 //=============================================================================
1526 void HOMARD_Iteration_i::MeshInfoOption(CORBA::Long Qual, CORBA::Long Diam, CORBA::Long Conn, CORBA::Long Tail, CORBA::Long Inte, CORBA::Long Option)
1528 MESSAGE ( "MeshInfoOption : information sur le maillage associe a une iteration" );
1529 ASSERT( myHomardIteration );
1531 // Nom de l'iteration
1532 char* IterName = GetName();
1533 CORBA::Long etatMenage = -1;
1534 CORBA::Long modeHOMARD = 7;
1535 if ( Qual != 0 ) { modeHOMARD = modeHOMARD*5; }
1536 if ( Diam != 0 ) { modeHOMARD = modeHOMARD*19; }
1537 if ( Conn != 0 ) { modeHOMARD = modeHOMARD*11; }
1538 if ( Tail != 0 ) { modeHOMARD = modeHOMARD*13; }
1539 if ( Inte != 0 ) { modeHOMARD = modeHOMARD*3; }
1540 MESSAGE ( "MeshInfoOption : information sur le maillage de l'iteration " << IterName );
1541 CORBA::Long Option2 = 1;
1542 CORBA::Long codret = _gen_i->Compute(IterName, etatMenage, modeHOMARD, Option, Option2);
1543 MESSAGE ( "MeshInfoOption : codret = " << codret );
1545 //=============================================================================
1546 void HOMARD_Iteration_i::SetFileInfo( const char* FileInfo )
1548 ASSERT( myHomardIteration );
1549 myHomardIteration->SetFileInfo( FileInfo );
1551 //=============================================================================
1552 char* HOMARD_Iteration_i::GetFileInfo()
1554 ASSERT( myHomardIteration );
1555 return CORBA::string_dup( myHomardIteration->GetFileInfo().c_str() );
1557 //=============================================================================
1558 //=============================================================================
1559 // Liens avec les autres iterations
1560 //=============================================================================
1561 //=============================================================================
1562 SMESHHOMARD::HOMARD_Iteration_ptr HOMARD_Iteration_i::NextIteration( const char* IterName )
1564 // Nom de l'iteration parent
1565 char* NomIterParent = GetName();
1566 MESSAGE ( "NextIteration : creation de l'iteration " << IterName << " comme fille de " << NomIterParent );
1567 return _gen_i->CreateIteration(IterName, NomIterParent);
1569 //=============================================================================
1570 void HOMARD_Iteration_i::LinkNextIteration( const char* NomIteration )
1572 ASSERT( myHomardIteration );
1573 myHomardIteration->LinkNextIteration( NomIteration );
1575 //=============================================================================
1576 void HOMARD_Iteration_i::UnLinkNextIteration( const char* NomIteration )
1578 ASSERT( myHomardIteration );
1579 myHomardIteration->UnLinkNextIteration( NomIteration );
1581 //=============================================================================
1582 SMESHHOMARD::listeIterFilles* HOMARD_Iteration_i::GetIterations()
1584 ASSERT( myHomardIteration );
1585 const std::list<std::string>& maListe = myHomardIteration->GetIterations();
1586 SMESHHOMARD::listeIterFilles_var aResult = new SMESHHOMARD::listeIterFilles;
1587 aResult->length( maListe.size() );
1588 std::list<std::string>::const_iterator it;
1590 for ( it = maListe.begin(); it != maListe.end(); it++ )
1592 aResult[i++] = CORBA::string_dup( (*it).c_str() );
1594 return aResult._retn();
1596 //=============================================================================
1597 void HOMARD_Iteration_i::SetIterParentName( const char* NomIterParent )
1599 ASSERT( myHomardIteration );
1600 myHomardIteration->SetIterParentName( NomIterParent );
1602 //=============================================================================
1603 char* HOMARD_Iteration_i::GetIterParentName()
1605 ASSERT( myHomardIteration );
1606 return CORBA::string_dup( myHomardIteration->GetIterParentName().c_str() );
1608 //=============================================================================
1609 SMESHHOMARD::HOMARD_Iteration_ptr HOMARD_Iteration_i::GetIterParent()
1611 // Nom de l'iteration parent
1612 char* NomIterParent = GetIterParentName();
1613 MESSAGE ( "GetIterParent : NomIterParent = " << NomIterParent );
1614 return _gen_i->GetIteration(NomIterParent);
1616 //=============================================================================
1617 //=============================================================================
1618 // Liens avec les autres structures
1619 //=============================================================================
1620 //=============================================================================
1621 void HOMARD_Iteration_i::SetCaseName( const char* NomCas )
1623 ASSERT( myHomardIteration );
1624 myHomardIteration->SetCaseName( NomCas );
1626 //=============================================================================
1627 char* HOMARD_Iteration_i::GetCaseName()
1629 ASSERT( myHomardIteration );
1630 return CORBA::string_dup( myHomardIteration->GetCaseName().c_str() );
1632 //=============================================================================
1633 void HOMARD_Iteration_i::AssociateHypo( const char* NomHypo )
1635 ASSERT( myHomardIteration );
1637 // Nom de l'iteration
1638 char* IterName = GetName();
1639 MESSAGE ( ". IterName = " << IterName );
1640 return _gen_i->AssociateIterHypo(IterName, NomHypo);
1642 //=============================================================================
1643 void HOMARD_Iteration_i::SetHypoName( const char* NomHypo )
1645 ASSERT( myHomardIteration );
1646 myHomardIteration->SetHypoName( NomHypo );
1648 //=============================================================================
1649 char* HOMARD_Iteration_i::GetHypoName()
1651 ASSERT( myHomardIteration );
1652 return CORBA::string_dup( myHomardIteration->GetHypoName().c_str() );
1654 //=============================================================================
1655 //=============================================================================
1657 //=============================================================================
1658 //=============================================================================
1659 void HOMARD_Iteration_i::SetInfoCompute( CORBA::Long MessInfo )
1661 ASSERT( myHomardIteration );
1662 myHomardIteration->SetInfoCompute( MessInfo );
1664 //=============================================================================
1665 CORBA::Long HOMARD_Iteration_i::GetInfoCompute()
1667 ASSERT( myHomardIteration );
1668 return myHomardIteration->GetInfoCompute();
1671 //=============================================================================
1673 //=============================================================================
1674 std::string RemoveTabulation( std::string theScript )
1676 std::string::size_type aPos = 0;
1677 while( aPos < theScript.length() )
1679 aPos = theScript.find( "\n\t", aPos );
1680 if( aPos == std::string::npos )
1682 theScript.replace( aPos, 2, "\n" );
1687 //=============================================================================
1689 * standard constructor
1691 //=============================================================================
1692 HOMARD_Gen_i::HOMARD_Gen_i() :
1693 SALOME::GenericObj_i( SMESH_Gen_i::GetPOA() )
1695 MESSAGE("constructor de HOMARD_Gen_i");
1697 myHomard = new SMESHHOMARDImpl::HOMARD_Gen;
1701 //=================================
1703 * standard destructor
1705 //================================
1706 HOMARD_Gen_i::~HOMARD_Gen_i()
1710 //=============================================================================
1711 //=============================================================================
1712 // Utilitaires pour l'iteration
1713 //=============================================================================
1714 //=============================================================================
1715 void HOMARD_Gen_i::SetEtatIter(const char* nomIter, const CORBA::Long Etat)
1716 //=====================================================================================
1718 MESSAGE( "SetEtatIter : affectation de l'etat " << Etat << " a l'iteration " << nomIter );
1719 SMESHHOMARD::HOMARD_Iteration_var myIteration = myStudyContext._mesIterations[nomIter];
1720 if (CORBA::is_nil(myIteration)) {
1721 SALOME::ExceptionStruct es;
1722 es.type = SALOME::BAD_PARAM;
1723 es.text = "Invalid iteration";
1724 throw SALOME::SALOME_Exception(es);
1727 myIteration->SetState(Etat);
1729 //=============================================================================
1730 //=============================================================================
1732 //=============================================================================
1733 //=============================================================================
1734 // Destruction des structures identifiees par leurs noms
1735 //=============================================================================
1736 //=============================================================================
1737 CORBA::Long HOMARD_Gen_i::DeleteBoundary(const char* BoundaryName)
1739 MESSAGE ( "DeleteBoundary : BoundaryName = " << BoundaryName );
1740 SMESHHOMARD::HOMARD_Boundary_var myBoundary = myStudyContext._mesBoundarys[BoundaryName];
1741 if (CORBA::is_nil(myBoundary))
1743 SALOME::ExceptionStruct es;
1744 es.type = SALOME::BAD_PARAM;
1745 es.text = "Invalid boundary";
1746 throw SALOME::SALOME_Exception(es);
1750 // On verifie que la frontiere n'est plus utilisee
1751 SMESHHOMARD::listeCases* maListe = GetAllCasesName();
1752 int numberOfCases = maListe->length();
1753 MESSAGE ( ".. Nombre de cas = " << numberOfCases );
1754 std::string CaseName;
1755 SMESHHOMARD::ListBoundaryGroupType* ListBoundaryGroupType;
1757 SMESHHOMARD::HOMARD_Cas_var myCase;
1758 for (int NumeCas = 0; NumeCas< numberOfCases; NumeCas++)
1760 CaseName = std::string((*maListe)[NumeCas]);
1761 MESSAGE ( "... Examen du cas = " << CaseName.c_str() );
1762 myCase = myStudyContext._mesCas[CaseName];
1763 ASSERT(!CORBA::is_nil(myCase));
1764 ListBoundaryGroupType = myCase->GetBoundaryGroup();
1765 numberOfitems = ListBoundaryGroupType->length();
1766 MESSAGE ( "... number of string for Boundary+Group = " << numberOfitems);
1767 for (int NumBoundary = 0; NumBoundary< numberOfitems; NumBoundary=NumBoundary+2)
1769 if ( std::string((*ListBoundaryGroupType)[NumBoundary]) == BoundaryName )
1771 SALOME::ExceptionStruct es;
1772 es.type = SALOME::BAD_PARAM;
1773 es.text = "This boundary is used in a case and cannot be deleted.";
1774 throw SALOME::SALOME_Exception(es);
1780 // comme on a un _var comme pointeur CORBA, on ne se preoccupe pas du delete
1781 myStudyContext._mesBoundarys.erase(BoundaryName);
1785 //=============================================================================
1786 CORBA::Long HOMARD_Gen_i::DeleteCase(const char* nomCas, CORBA::Long Option)
1788 // Pour detruire un cas
1789 MESSAGE ( "DeleteCase : nomCas = " << nomCas << ", avec option = " << Option );
1790 SMESHHOMARD::HOMARD_Cas_var myCase = myStudyContext._mesCas[nomCas];
1791 if (CORBA::is_nil(myCase)) {
1792 SALOME::ExceptionStruct es;
1793 es.type = SALOME::BAD_PARAM;
1794 es.text = "Invalid case context";
1795 throw SALOME::SALOME_Exception(es);
1798 // On commence par detruire toutes les iterations en partant de l'initiale et y compris elle
1799 CORBA::String_var nomIter = myCase->GetIter0Name();
1800 CORBA::Long Option1 = 0;
1801 if ( DeleteIterationOption(nomIter, Option1, Option, true) != 0 )
1806 // comme on a un _var comme pointeur CORBA, on ne se preoccupe pas du delete
1807 myStudyContext._mesCas.erase(nomCas);
1811 //=============================================================================
1812 CORBA::Long HOMARD_Gen_i::DeleteHypo(const char* nomHypo)
1814 MESSAGE ( "DeleteHypo : nomHypo = " << nomHypo );
1815 SMESHHOMARD::HOMARD_Hypothesis_var myHypo = myStudyContext._mesHypotheses[nomHypo];
1816 if (CORBA::is_nil(myHypo))
1818 SALOME::ExceptionStruct es;
1819 es.type = SALOME::BAD_PARAM;
1820 es.text = "Invalid hypothesis";
1821 throw SALOME::SALOME_Exception(es);
1825 // On verifie que l'hypothese n'est plus utilisee
1826 SMESHHOMARD::listeIters* maListeIter = myHypo->GetIterations();
1827 int numberOfIter = maListeIter->length();
1828 if ( numberOfIter > 0 )
1830 SALOME::ExceptionStruct es;
1831 es.type = SALOME::BAD_PARAM;
1832 es.text = "This hypothesis is used in an iteration and cannot be deleted.";
1833 throw SALOME::SALOME_Exception(es);
1837 // comme on a un _var comme pointeur CORBA, on ne se preoccupe pas du delete
1838 myStudyContext._mesHypotheses.erase(nomHypo);
1843 //=============================================================================
1844 CORBA::Long HOMARD_Gen_i::DeleteIteration(const char* nomIter, CORBA::Long Option,
1845 bool doRemoveWorkingFiles)
1847 // Option = 0 : On ne supprime pas le fichier du maillage associe
1848 // Option = 1 : On supprime le fichier du maillage associe
1849 MESSAGE ( "DeleteIteration : nomIter = " << nomIter << ", avec option = " << Option );
1850 CORBA::Long Option1 = 1;
1851 return DeleteIterationOption(nomIter, Option1, Option, doRemoveWorkingFiles);
1854 //=============================================================================
1855 CORBA::Long HOMARD_Gen_i::DeleteIterationOption(const char* nomIter,
1856 CORBA::Long Option1,
1857 CORBA::Long Option2,
1858 bool doRemoveWorkingFiles)
1860 // Option1 = 0 : On autorise la destruction de l'iteration 0
1861 // Option1 = 1 : On interdit la destruction de l'iteration 0
1863 // Option2 = 0 : On ne supprime pas le fichier du maillage associe
1864 // Option2 = 1 : On supprime le fichier du maillage associe
1865 MESSAGE ( "DeleteIterationOption : nomIter = " << nomIter << ", avec options = " << Option1<< ", " << Option2 );
1866 SMESHHOMARD::HOMARD_Iteration_var myIteration = myStudyContext._mesIterations[nomIter];
1867 if (CORBA::is_nil(myIteration)) {
1868 SALOME::ExceptionStruct es;
1869 es.type = SALOME::BAD_PARAM;
1870 es.text = "Invalid iteration";
1871 throw SALOME::SALOME_Exception(es);
1874 int numero = myIteration->GetNumber();
1875 MESSAGE ( "DeleteIterationOption : numero = " << numero );
1876 if ( numero == 0 && Option1 == 1 ) {
1877 SALOME::ExceptionStruct es;
1878 es.type = SALOME::BAD_PARAM;
1879 es.text = "This iteration cannot be deleted.";
1880 throw SALOME::SALOME_Exception(es);
1883 // On detruit recursivement toutes les filles
1884 SMESHHOMARD::listeIterFilles* maListe = myIteration->GetIterations();
1885 int numberOfIter = maListe->length();
1886 for (int NumeIter = 0; NumeIter < numberOfIter; NumeIter++) {
1887 std::string nomIterFille = std::string((*maListe)[NumeIter]);
1888 MESSAGE ( ".. appel recursif de DeleteIterationOption pour nomIter = " << nomIterFille.c_str() );
1889 DeleteIterationOption(nomIterFille.c_str(), Option1, Option2, doRemoveWorkingFiles);
1892 // On arrive ici pour une iteration sans fille
1893 MESSAGE ( "Destruction effective de " << nomIter );
1894 // On commence par invalider l'iteration pour faire le menage des dependances
1895 // et eventuellement du maillage associe
1897 if ( numero == 0 ) { option = 0; }
1898 else { option = Option2; }
1899 InvalideIterOption(nomIter, option, doRemoveWorkingFiles);
1901 // Retrait dans la descendance de l'iteration parent
1904 std::string nomIterationParent = myIteration->GetIterParentName();
1905 MESSAGE ( "Retrait dans la descendance de nomIterationParent " << nomIterationParent );
1906 SMESHHOMARD::HOMARD_Iteration_var myIterationParent = myStudyContext._mesIterations[nomIterationParent];
1907 if (CORBA::is_nil(myIterationParent))
1909 SALOME::ExceptionStruct es;
1910 es.type = SALOME::BAD_PARAM;
1911 es.text = "Invalid iteration";
1912 throw SALOME::SALOME_Exception(es);
1915 myIterationParent->UnLinkNextIteration(nomIter);
1918 // suppression du lien avec l'hypothese
1921 std::string nomHypo = myIteration->GetHypoName();
1922 SMESHHOMARD::HOMARD_Hypothesis_var myHypo = myStudyContext._mesHypotheses[nomHypo];
1923 ASSERT(!CORBA::is_nil(myHypo));
1924 myHypo->UnLinkIteration(nomIter);
1927 // comme on a un _var comme pointeur CORBA, on ne se preoccupe pas du delete
1928 myStudyContext._mesIterations.erase(nomIter);
1930 // on peut aussi faire RemoveObject
1931 // MESSAGE ( "Au final" );
1932 // SMESHHOMARD::listeIterations* Liste = GetAllIterationsName();
1933 // numberOfIter = Liste->length();
1934 // for (int NumeIter = 0; NumeIter< numberOfIter; NumeIter++)
1936 // std::string nomIterFille = std::string((*Liste)[NumeIter]);
1937 // MESSAGE ( ".. nomIter = " << nomIterFille.c_str() );
1942 //=============================================================================
1943 //=============================================================================
1944 // Invalidation des structures identifiees par leurs noms
1945 //=============================================================================
1946 //=============================================================================
1947 void HOMARD_Gen_i::InvalideBoundary(const char* BoundaryName)
1949 MESSAGE( "InvalideBoundary : BoundaryName = " << BoundaryName );
1950 SMESHHOMARD::HOMARD_Boundary_var myBoundary = myStudyContext._mesBoundarys[BoundaryName];
1951 if (CORBA::is_nil(myBoundary)) {
1952 SALOME::ExceptionStruct es;
1953 es.type = SALOME::BAD_PARAM;
1954 es.text = "Invalid boundary";
1955 throw SALOME::SALOME_Exception(es);
1958 SALOME::ExceptionStruct es;
1959 es.type = SALOME::BAD_PARAM;
1960 es.text = "No change is allowed in a boundary. Ask for evolution.";
1961 throw SALOME::SALOME_Exception(es);
1964 //=============================================================================
1965 void HOMARD_Gen_i::InvalideHypo(const char* nomHypo)
1967 MESSAGE( "InvalideHypo : nomHypo = " << nomHypo );
1968 SMESHHOMARD::HOMARD_Hypothesis_var myHypo = myStudyContext._mesHypotheses[nomHypo];
1969 if (CORBA::is_nil(myHypo)) {
1970 SALOME::ExceptionStruct es;
1971 es.type = SALOME::BAD_PARAM;
1972 es.text = "Invalid hypothesis";
1973 throw SALOME::SALOME_Exception(es);
1976 SMESHHOMARD::listeIters* maListe = myHypo->GetIterations();
1977 int numberOfIter = maListe->length();
1978 for (int NumeIter = 0; NumeIter< numberOfIter; NumeIter++) {
1979 std::string nomIter = std::string((*maListe)[NumeIter]);
1980 MESSAGE( ".. nomIter = " << nomIter );
1981 InvalideIter(nomIter.c_str());
1984 //=============================================================================
1985 void HOMARD_Gen_i::InvalideIter(const char* nomIter)
1987 MESSAGE("InvalideIter : nomIter = " << nomIter);
1988 // Pour invalider totalement une iteration courante
1989 CORBA::Long Option = 1;
1990 return InvalideIterOption(nomIter, Option, true);
1993 //=============================================================================
1994 void HOMARD_Gen_i::InvalideIterOption(const char* nomIter, CORBA::Long Option,
1995 bool doRemoveWorkingFiles)
1997 // Option = 0 : On ne supprime pas le fichier du maillage associe
1998 // Option = 1 : On supprime le fichier du maillage associe
1999 MESSAGE ( "InvalideIterOption : nomIter = " << nomIter << ", avec option = " << Option );
2000 SMESHHOMARD::HOMARD_Iteration_var myIteration = myStudyContext._mesIterations[nomIter];
2001 if (CORBA::is_nil(myIteration)) {
2002 SALOME::ExceptionStruct es;
2003 es.type = SALOME::BAD_PARAM;
2004 es.text = "Invalid iteration";
2005 throw SALOME::SALOME_Exception(es);
2008 SMESHHOMARD::listeIterFilles* maListe = myIteration->GetIterations();
2009 int numberOfIter = maListe->length();
2010 for (int NumeIter = 0; NumeIter< numberOfIter; NumeIter++) {
2011 std::string nomIterFille = std::string((*maListe)[NumeIter]);
2012 MESSAGE ( ".. appel recursif de InvalideIter pour nomIter = " << nomIterFille.c_str() );
2013 InvalideIter(nomIterFille.c_str());
2016 // On arrive ici pour une iteration sans fille
2017 MESSAGE ( "Invalidation effective de " << nomIter );
2019 int etat = myIteration->GetState();
2021 SetEtatIter(nomIter,1);
2022 //const char * nomCas = myIteration->GetCaseName();
2023 //SMESHHOMARD::HOMARD_Cas_var myCase = myStudyContext._mesCas[nomCas];
2024 //if (CORBA::is_nil(myCase)) {
2025 // SALOME::ExceptionStruct es;
2026 // es.type = SALOME::BAD_PARAM;
2027 // es.text = "Invalid case context";
2028 // throw SALOME::SALOME_Exception(es);
2030 if (doRemoveWorkingFiles) {
2031 std::string nomDir = myIteration->GetDirName();
2032 std::string nomFichier = myIteration->GetMeshFile();
2033 std::string commande = "rm -rf " + std::string(nomDir);
2034 if ( Option == 1 ) { commande = commande + ";rm -rf " + std::string(nomFichier); }
2035 MESSAGE ( "commande = " << commande );
2036 if ((system(commande.c_str())) != 0) {
2037 SALOME::ExceptionStruct es;
2038 es.type = SALOME::BAD_PARAM;
2039 es.text = "The directory for the calculation cannot be cleared.";
2040 throw SALOME::SALOME_Exception(es);
2043 // Suppression du maillage publie dans SMESH
2044 //std::string MeshName = myIteration->GetMeshName();
2045 //DeleteResultInSmesh(nomFichier, MeshName);
2049 //=============================================================================
2050 void HOMARD_Gen_i::InvalideIterInfo(const char* nomIter)
2052 MESSAGE("InvalideIterInfo : nomIter = " << nomIter);
2053 SMESHHOMARD::HOMARD_Iteration_var myIteration = myStudyContext._mesIterations[nomIter];
2054 if (CORBA::is_nil(myIteration)) {
2055 SALOME::ExceptionStruct es;
2056 es.type = SALOME::BAD_PARAM;
2057 es.text = "Invalid iteration";
2058 throw SALOME::SALOME_Exception(es);
2061 const char * nomCas = myIteration->GetCaseName();
2062 SMESHHOMARD::HOMARD_Cas_var myCase = myStudyContext._mesCas[nomCas];
2063 if (CORBA::is_nil(myCase)) {
2064 SALOME::ExceptionStruct es;
2065 es.type = SALOME::BAD_PARAM;
2066 es.text = "Invalid case context";
2067 throw SALOME::SALOME_Exception(es);
2069 const char* nomDir = myIteration->GetDirName();
2070 std::string commande = "rm -f " + std::string(nomDir) + "/info* ";
2071 commande += std::string(nomDir) + "/Liste.*info";
2072 /* MESSAGE ( "commande = " << commande );*/
2073 if ((system(commande.c_str())) != 0)
2075 SALOME::ExceptionStruct es;
2076 es.type = SALOME::BAD_PARAM;
2077 es.text = "The directory for the calculation cannot be cleared.";
2078 throw SALOME::SALOME_Exception(es);
2081 //=============================================================================
2082 //=============================================================================
2083 // Association de lien entre des structures identifiees par leurs noms
2084 //=============================================================================
2085 //=============================================================================
2086 void HOMARD_Gen_i::AssociateCaseIter(const char* nomCas, const char* nomIter, const char* labelIter)
2088 MESSAGE( "AssociateCaseIter : " << nomCas << ", " << nomIter << ", " << labelIter );
2090 SMESHHOMARD::HOMARD_Cas_var myCase = myStudyContext._mesCas[nomCas];
2091 if (CORBA::is_nil(myCase)) {
2092 SALOME::ExceptionStruct es;
2093 es.type = SALOME::BAD_PARAM;
2094 es.text = "Invalid case";
2095 throw SALOME::SALOME_Exception(es);
2098 SMESHHOMARD::HOMARD_Iteration_var myIteration = myStudyContext._mesIterations[nomIter];
2099 if (CORBA::is_nil(myIteration)) {
2100 SALOME::ExceptionStruct es;
2101 es.type = SALOME::BAD_PARAM;
2102 es.text = "Invalid iteration";
2103 throw SALOME::SALOME_Exception(es);
2106 myCase->AddIteration(nomIter);
2107 myIteration->SetCaseName(nomCas);
2109 //=============================================================================
2110 void HOMARD_Gen_i::AssociateIterHypo(const char* nomIter, const char* nomHypo)
2112 MESSAGE("AssociateIterHypo : nomHypo = " << nomHypo << " nomIter = " << nomIter);
2114 // Verification de l'existence de l'hypothese
2115 SMESHHOMARD::HOMARD_Hypothesis_var myHypo = myStudyContext._mesHypotheses[nomHypo];
2116 ASSERT(!CORBA::is_nil(myHypo));
2118 // Verification de l'existence de l'iteration
2119 SMESHHOMARD::HOMARD_Iteration_var myIteration = myStudyContext._mesIterations[nomIter];
2120 ASSERT(!CORBA::is_nil(myIteration));
2122 // Liens reciproques
2123 myIteration->SetHypoName(nomHypo);
2124 myHypo->LinkIteration(nomIter);
2126 // On stocke les noms des champ a interpoler pour
2127 // le futur controle de la donnée des pas de temps
2128 myIteration->SupprFieldInterps();
2129 SMESHHOMARD::listeFieldInterpsHypo* ListField = myHypo->GetFieldInterps();
2130 int numberOfFieldsx2 = ListField->length();
2131 for (int iaux = 0; iaux < numberOfFieldsx2; iaux++) {
2132 std::string FieldName = std::string((*ListField)[iaux]);
2133 myIteration->SetFieldInterp(FieldName.c_str());
2138 //=============================================================================
2139 //=============================================================================
2140 // Recuperation des listes
2141 //=============================================================================
2142 //=============================================================================
2143 SMESHHOMARD::listeBoundarys* HOMARD_Gen_i::GetAllBoundarysName()
2145 MESSAGE("GetAllBoundarysName");
2147 SMESHHOMARD::listeBoundarys_var ret = new SMESHHOMARD::listeBoundarys;
2148 ret->length(myStudyContext._mesBoundarys.size());
2149 std::map<std::string, SMESHHOMARD::HOMARD_Boundary_var>::const_iterator it;
2151 for (it = myStudyContext._mesBoundarys.begin();
2152 it != myStudyContext._mesBoundarys.end(); it++)
2154 ret[i++] = CORBA::string_dup((*it).first.c_str());
2159 //=============================================================================
2160 SMESHHOMARD::listeCases* HOMARD_Gen_i::GetAllCasesName()
2162 MESSAGE("GetAllCasesName");
2164 SMESHHOMARD::listeCases_var ret = new SMESHHOMARD::listeCases;
2165 ret->length(myStudyContext._mesCas.size());
2166 std::map<std::string, SMESHHOMARD::HOMARD_Cas_var>::const_iterator it;
2168 for (it = myStudyContext._mesCas.begin();
2169 it != myStudyContext._mesCas.end(); it++)
2171 ret[i++] = CORBA::string_dup((*it).first.c_str());
2176 //=============================================================================
2177 SMESHHOMARD::listeHypotheses* HOMARD_Gen_i::GetAllHypothesesName()
2179 MESSAGE("GetAllHypothesesName");
2181 SMESHHOMARD::listeHypotheses_var ret = new SMESHHOMARD::listeHypotheses;
2182 ret->length(myStudyContext._mesHypotheses.size());
2183 std::map<std::string, SMESHHOMARD::HOMARD_Hypothesis_var>::const_iterator it;
2185 for (it = myStudyContext._mesHypotheses.begin();
2186 it != myStudyContext._mesHypotheses.end(); it++)
2188 ret[i++] = CORBA::string_dup((*it).first.c_str());
2193 //=============================================================================
2194 SMESHHOMARD::listeIterations* HOMARD_Gen_i::GetAllIterationsName()
2196 MESSAGE("GetAllIterationsName");
2198 SMESHHOMARD::listeIterations_var ret = new SMESHHOMARD::listeIterations;
2199 ret->length(myStudyContext._mesIterations.size());
2200 std::map<std::string, SMESHHOMARD::HOMARD_Iteration_var>::const_iterator it;
2202 for (it = myStudyContext._mesIterations.begin();
2203 it != myStudyContext._mesIterations.end(); it++)
2205 ret[i++] = CORBA::string_dup((*it).first.c_str());
2211 //=============================================================================
2212 //=============================================================================
2213 // Recuperation des structures identifiees par leurs noms
2214 //=============================================================================
2215 //=============================================================================
2216 SMESHHOMARD::HOMARD_Boundary_ptr HOMARD_Gen_i::GetBoundary(const char* nomBoundary)
2218 SMESHHOMARD::HOMARD_Boundary_var myBoundary = myStudyContext._mesBoundarys[nomBoundary];
2219 ASSERT(!CORBA::is_nil(myBoundary));
2220 return SMESHHOMARD::HOMARD_Boundary::_duplicate(myBoundary);
2222 //=============================================================================
2223 SMESHHOMARD::HOMARD_Cas_ptr HOMARD_Gen_i::GetCase(const char* nomCas)
2225 SMESHHOMARD::HOMARD_Cas_var myCase = myStudyContext._mesCas[nomCas];
2226 ASSERT(!CORBA::is_nil(myCase));
2227 return SMESHHOMARD::HOMARD_Cas::_duplicate(myCase);
2229 //=============================================================================
2230 SMESHHOMARD::HOMARD_Hypothesis_ptr HOMARD_Gen_i::GetHypothesis(const char* nomHypothesis)
2232 SMESHHOMARD::HOMARD_Hypothesis_var myHypothesis = myStudyContext._mesHypotheses[nomHypothesis];
2233 ASSERT(!CORBA::is_nil(myHypothesis));
2234 return SMESHHOMARD::HOMARD_Hypothesis::_duplicate(myHypothesis);
2236 //=============================================================================
2237 SMESHHOMARD::HOMARD_Iteration_ptr HOMARD_Gen_i::GetIteration(const char* NomIterationation)
2239 SMESHHOMARD::HOMARD_Iteration_var myIteration = myStudyContext._mesIterations[NomIterationation];
2240 ASSERT(!CORBA::is_nil(myIteration));
2241 return SMESHHOMARD::HOMARD_Iteration::_duplicate(myIteration);
2243 //=============================================================================
2244 //=============================================================================
2246 //=============================================================================
2247 //=============================================================================
2248 void HOMARD_Gen_i::MeshInfo(const char* nomCas, const char* MeshName, const char* MeshFile, const char* DirName, CORBA::Long Qual, CORBA::Long Diam, CORBA::Long Conn, CORBA::Long Tail, CORBA::Long Inte)
2250 MESSAGE ( "MeshInfo : nomCas = " << nomCas << ", MeshName = " << MeshName << ", MeshFile = " << MeshFile );
2251 MESSAGE ( "Qual = " << Qual << ", Diam = " << Diam << ", Conn = " << Conn << ", Tail = " << Tail << ", Inte = " << Inte );
2255 if ( _PublisMeshIN != 0 ) option = 2;
2256 SMESHHOMARD::HOMARD_Cas_ptr myCase = CreateCase0(nomCas, MeshName, MeshFile, 1, 0, option);
2257 myCase->SetDirName(DirName);
2259 myCase->MeshInfo(Qual, Diam, Conn, Tail, Inte);
2261 //=============================================================================
2262 //=============================================================================
2264 //=============================================================================
2265 //=============================================================================
2266 // Recuperation des structures par le contexte
2267 //=============================================================================
2268 //=============================================================================
2269 SMESHHOMARD::HOMARD_Iteration_ptr HOMARD_Gen_i::LastIteration(const char* nomCas)
2271 SMESHHOMARD::HOMARD_Cas_var myCase = myStudyContext._mesCas[nomCas];
2272 ASSERT(!CORBA::is_nil(myCase));
2274 SMESHHOMARD::HOMARD_Iteration_var myIteration = myCase->LastIteration();
2275 ASSERT(!CORBA::is_nil(myIteration));
2277 return SMESHHOMARD::HOMARD_Iteration::_duplicate(myIteration);
2279 //=============================================================================
2280 //=============================================================================
2282 //=============================================================================
2283 //=============================================================================
2284 // Nouvelles structures
2285 //=============================================================================
2286 //=============================================================================
2287 SMESHHOMARD::HOMARD_Cas_ptr HOMARD_Gen_i::newCase()
2289 SMESHHOMARD::HOMARD_Gen_var engine = POA_SMESHHOMARD::HOMARD_Gen::_this();
2290 HOMARD_Cas_i* aServant = new HOMARD_Cas_i(SMESH_Gen_i::GetORB(), engine);
2291 SMESHHOMARD::HOMARD_Cas_var aCase = SMESHHOMARD::HOMARD_Cas::_narrow(aServant->_this());
2292 return aCase._retn();
2294 //=============================================================================
2295 SMESHHOMARD::HOMARD_Hypothesis_ptr HOMARD_Gen_i::newHypothesis()
2297 SMESHHOMARD::HOMARD_Gen_var engine = POA_SMESHHOMARD::HOMARD_Gen::_this();
2298 HOMARD_Hypothesis_i* aServant = new HOMARD_Hypothesis_i(SMESH_Gen_i::GetORB(), engine);
2299 SMESHHOMARD::HOMARD_Hypothesis_var aHypo = SMESHHOMARD::HOMARD_Hypothesis::_narrow(aServant->_this());
2300 return aHypo._retn();
2302 //=============================================================================
2303 SMESHHOMARD::HOMARD_Iteration_ptr HOMARD_Gen_i::newIteration()
2305 SMESHHOMARD::HOMARD_Gen_var engine = POA_SMESHHOMARD::HOMARD_Gen::_this();
2306 HOMARD_Iteration_i* aServant = new HOMARD_Iteration_i(SMESH_Gen_i::GetORB(), engine);
2307 SMESHHOMARD::HOMARD_Iteration_var aIter = SMESHHOMARD::HOMARD_Iteration::_narrow(aServant->_this());
2308 return aIter._retn();
2310 //=============================================================================
2311 SMESHHOMARD::HOMARD_Boundary_ptr HOMARD_Gen_i::newBoundary()
2313 SMESHHOMARD::HOMARD_Gen_var engine = POA_SMESHHOMARD::HOMARD_Gen::_this();
2314 HOMARD_Boundary_i* aServant = new HOMARD_Boundary_i(SMESH_Gen_i::GetORB(), engine);
2315 SMESHHOMARD::HOMARD_Boundary_var aBoundary = SMESHHOMARD::HOMARD_Boundary::_narrow(aServant->_this());
2316 return aBoundary._retn();
2319 //=============================================================================
2320 //=============================================================================
2321 // Creation des structures identifiees par leurs noms
2322 //=============================================================================
2323 //=============================================================================
2324 SMESHHOMARD::HOMARD_Cas_ptr HOMARD_Gen_i::CreateCase(const char* nomCas, const char* MeshName, const char* MeshFile)
2326 // Creation d'un cas initial
2327 // nomCas : nom du cas a creer
2328 // MeshName, MeshFile : nom et fichier du maillage correspondant
2331 INFOS ( "CreateCase : nomCas = " << nomCas << ", MeshName = " << MeshName << ", MeshFile = " << MeshFile );
2334 if ( _PublisMeshIN != 0 ) option = 2;
2335 SMESHHOMARD::HOMARD_Cas_ptr myCase = CreateCase0(nomCas, MeshName, MeshFile, 0, 0, option);
2337 // Valeurs par defaut des filtrages
2338 myCase->SetPyram(0);
2340 return SMESHHOMARD::HOMARD_Cas::_duplicate(myCase);
2342 //=============================================================================
2343 std::string HOMARD_Gen_i::CreateCase1(const char* DirNameStart, CORBA::Long Number)
2345 // Retourne le nom du répertoire ou se trouve l'iteration voulue.
2346 // DirNameStart : nom du répertoire du cas contenant l'iteration de reprise
2347 // Number : numero de l'iteration de depart ou -1 si on cherche la derniere
2350 MESSAGE ( "CreateCase1 : DirNameStart = " << DirNameStart << ", Number = " << Number );
2351 std::string nomDirWork = getenv("PWD");
2352 std::string DirNameStartIter;
2354 int NumeIterMax = -1;
2356 // A.1. Controle du répertoire de depart du cas
2357 codret = CHDIR(DirNameStart);
2360 SALOME::ExceptionStruct es;
2361 es.type = SALOME::BAD_PARAM;
2362 es.text = "The directory of the case for the pursuit does not exist.";
2363 throw SALOME::SALOME_Exception(es);
2366 // A.2. Reperage des sous-répertoire du répertoire de reprise
2367 bool existe = false;
2370 struct dirent *dirp;
2371 dp = opendir(DirNameStart);
2372 while ( (dirp = readdir(dp)) != NULL ) {
2373 std::string DirName_1(dirp->d_name);
2375 HANDLE hFind = INVALID_HANDLE_VALUE;
2376 WIN32_FIND_DATA ffd;
2377 hFind = FindFirstFile(DirNameStart, &ffd);
2378 if (INVALID_HANDLE_VALUE != hFind) {
2379 while (FindNextFile(hFind, &ffd) != 0) {
2380 std::string DirName_1 = "";
2381 if (ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
2382 DirName_1 = std::string(ffd.cFileName);
2385 if ( ( DirName_1 != "." ) && ( DirName_1 != ".." ) )
2387 if ( CHDIR(DirName_1.c_str()) == 0 )
2389 // On cherche le fichier de configuration dans ce sous-répertoire
2390 codret = CHDIR(DirNameStart);
2393 struct dirent *dirp_1;
2394 dp_1 = opendir(DirName_1.c_str());
2395 while ( (dirp_1 = readdir(dp_1)) != NULL )
2397 std::string file_name_1(dirp_1->d_name);
2399 HANDLE hFind1 = INVALID_HANDLE_VALUE;
2400 WIN32_FIND_DATA ffd1;
2401 hFind1 = FindFirstFile(DirName_1.c_str(), &ffd1);
2402 while (FindNextFile(hFind1, &ffd1) != 0)
2404 if (ffd1.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) continue; //skip directories
2405 std::string file_name_1(ffd1.cFileName);
2407 int bilan = file_name_1.find("HOMARD.Configuration.");
2408 if ( bilan != string::npos )
2410 // Decodage du fichier pour trouver le numero d'iteration
2411 CHDIR(DirName_1.c_str());
2413 std::ifstream fichier( file_name_1.c_str() );
2414 if ( fichier ) // ce test échoue si le fichier n'est pas ouvert
2417 std::string ligne; // variable contenant chaque ligne lue
2418 std::string mot_cle;
2419 // cette boucle sur les lignes s'arrête dès qu'une erreur de lecture survient
2420 while ( std::getline( fichier, ligne ) )
2422 // B.1. Pour la ligne courante, on identifie le premier mot : le mot-cle
2423 std::istringstream ligne_bis(ligne); // variable contenant chaque ligne sous forme de flux
2424 ligne_bis >> mot_cle;
2425 if ( mot_cle == "NumeIter" )
2427 ligne_bis >> NumeIter;
2429 // MESSAGE ( "==> NumeIter : " << NumeIter );
2430 if ( Number == - 1 )
2432 if ( NumeIter >= NumeIterMax )
2434 NumeIterMax = NumeIter;
2435 DirNameStartIter = DirName_1;
2440 if ( NumeIter == Number )
2442 DirNameStartIter = DirName_1;
2452 SALOME::ExceptionStruct es;
2453 es.type = SALOME::BAD_PARAM;
2454 std::string text = "The configuration file cannot be read.";
2455 es.text = CORBA::string_dup(text.c_str());
2456 throw SALOME::SALOME_Exception(es);
2458 CHDIR(DirNameStart);
2460 if ( existe ) { break; }
2467 if ( existe ) { break; }
2476 CHDIR(nomDirWork.c_str());
2478 if ( ( Number >= 0 && ( !existe ) ) || ( Number < 0 && ( NumeIterMax == -1 ) ) )
2480 SALOME::ExceptionStruct es;
2481 es.type = SALOME::BAD_PARAM;
2482 es.text = "The directory of the iteration does not exist.";
2483 throw SALOME::SALOME_Exception(es);
2487 return DirNameStartIter;
2489 //=============================================================================
2490 SMESHHOMARD::HOMARD_Cas_ptr HOMARD_Gen_i::CreateCase0(const char* nomCas, const char* MeshName, const char* MeshFile, CORBA::Long MeshOption, CORBA::Long NumeIter, CORBA::Long Option)
2492 // nomCas : nom du cas a creer
2493 // MeshName, MeshFile : nom et fichier du maillage correspondant
2494 // MeshOption : 0 : le maillage fourni est obligatoirement present ==> erreur si absent
2495 // 1 : le maillage fourni peut ne pas exister ==> on continue si absent
2496 // -1 : le maillage n'est pas fourni
2497 // NumeIter : numero de l'iteration correspondante : 0, pour un depart, n>0 pour une poursuite
2498 // Option : multiple de nombres premiers
2499 // 1 : aucune option
2500 // x2 : publication du maillage dans SMESH
2502 MESSAGE ( "CreateCase0 : nomCas = " << nomCas );
2503 MESSAGE ( "CreateCase0 : MeshName = " << MeshName << ", MeshFile = " << MeshFile << ", MeshOption = " << MeshOption );
2504 MESSAGE ( "CreateCase0 : NumeIter = " << NumeIter << ", Option = " << Option );
2507 // A.2. Controle du nom :
2508 if ((myStudyContext._mesCas).find(nomCas)!=(myStudyContext._mesCas).end())
2510 SALOME::ExceptionStruct es;
2511 es.type = SALOME::BAD_PARAM;
2512 es.text = "This case has already been defined.";
2513 throw SALOME::SALOME_Exception(es);
2517 // A.3. Controle du fichier du maillage
2519 if ( MeshOption >= 0 )
2521 existeMeshFile = MEDFileExist ( MeshFile );
2522 MESSAGE ( "CreateCase0 : existeMeshFile = " << existeMeshFile );
2523 if ( ( existeMeshFile == 0 ) && ( MeshOption == 0 ) )
2525 SALOME::ExceptionStruct es;
2526 es.type = SALOME::BAD_PARAM;
2527 es.text = "The mesh file does not exist.";
2528 throw SALOME::SALOME_Exception(es);
2532 else { existeMeshFile = 0; }
2534 // B. Creation de l'objet cas et publication
2535 SMESHHOMARD::HOMARD_Cas_var myCase = newCase();
2536 myCase->SetName(nomCas);
2537 myStudyContext._mesCas[nomCas] = myCase;
2539 // C. Caracteristiques du maillage
2540 if ( existeMeshFile != 0 ) {
2541 // Les valeurs extremes des coordonnées
2542 //MESSAGE ( "CreateCase0 : Les valeurs extremes des coordonnées" );
2543 std::vector<double> LesExtremes =GetBoundingBoxInMedFile(MeshFile);
2544 SMESHHOMARD::extrema_var aSeq = new SMESHHOMARD::extrema();
2545 if (LesExtremes.size()!=10) { return 0; }
2547 for (int i =0; i< LesExtremes.size(); i++)
2548 aSeq[i]=LesExtremes[i];
2549 myCase->SetBoundingBox(aSeq);
2551 //MESSAGE ( "CreateCase0 : Les groupes" );
2552 std::set<std::string> LesGroupes =GetListeGroupesInMedFile(MeshFile);
2553 SMESHHOMARD::ListGroupType_var aSeqGroupe = new SMESHHOMARD::ListGroupType;
2554 aSeqGroupe->length(LesGroupes.size());
2555 std::set<std::string>::const_iterator it;
2557 for (it=LesGroupes.begin(); it != LesGroupes.end(); it++)
2558 aSeqGroupe[i++]=(*it).c_str();
2559 myCase->SetGroups(aSeqGroupe);
2562 // D. L'iteration initiale du cas
2563 MESSAGE ( "CreateCase0 : iteration initiale du cas" );
2564 // D.1. Recherche d'un nom : par defaut, on prend le nom du maillage correspondant.
2565 // Si ce nom d'iteration existe deja, on incremente avec 0, 1, 2, etc.
2567 std::string NomIteration = std::string(MeshName);
2568 while ( (myStudyContext._mesIterations).find(NomIteration) != (myStudyContext._mesIterations.end()) )
2570 std::ostringstream nom;
2571 nom << MeshName << monNum;
2572 NomIteration = nom.str();
2575 MESSAGE ( "CreateCas0 : ==> NomIteration = " << NomIteration );
2577 // D.2. Creation de l'iteration
2578 SMESHHOMARD::HOMARD_Iteration_var anIter = newIteration();
2579 myStudyContext._mesIterations[NomIteration] = anIter;
2580 anIter->SetName(NomIteration.c_str());
2581 AssociateCaseIter (nomCas, NomIteration.c_str(), "IterationHomard");
2583 // D.4. Maillage correspondant
2584 if ( existeMeshFile != 0 )
2586 anIter->SetMeshFile(MeshFile);
2587 if ( Option % 2 == 0 ) { PublishResultInSmesh(MeshFile, 0); }
2589 anIter->SetMeshName(MeshName);
2591 // D.5. Numero d'iteration
2592 anIter->SetNumber(NumeIter);
2595 SetEtatIter(NomIteration.c_str(), -NumeIter);
2598 return SMESHHOMARD::HOMARD_Cas::_duplicate(myCase);
2600 //=============================================================================
2601 SMESHHOMARD::HOMARD_Hypothesis_ptr HOMARD_Gen_i::CreateHypothesis(const char* nomHypothesis)
2603 MESSAGE ( "CreateHypothesis : nomHypothesis = " << nomHypothesis );
2605 // A. Controle du nom :
2606 if ((myStudyContext._mesHypotheses).find(nomHypothesis) != (myStudyContext._mesHypotheses).end())
2608 SALOME::ExceptionStruct es;
2609 es.type = SALOME::BAD_PARAM;
2610 es.text = "This hypothesis has already been defined.";
2611 throw SALOME::SALOME_Exception(es);
2615 // B. Creation de l'objet
2616 SMESHHOMARD::HOMARD_Hypothesis_var myHypothesis = newHypothesis();
2617 if (CORBA::is_nil(myHypothesis))
2619 SALOME::ExceptionStruct es;
2620 es.type = SALOME::BAD_PARAM;
2621 es.text = "Unable to create the hypothesis";
2622 throw SALOME::SALOME_Exception(es);
2625 myHypothesis->SetName(nomHypothesis);
2627 // C. Enregistrement
2628 myStudyContext._mesHypotheses[nomHypothesis] = myHypothesis;
2630 // D. Valeurs par defaut des options avancees
2631 myHypothesis->SetNivMax(-1);
2632 myHypothesis->SetDiamMin(-1.0);
2633 myHypothesis->SetAdapInit(0);
2634 myHypothesis->SetExtraOutput(1);
2636 return SMESHHOMARD::HOMARD_Hypothesis::_duplicate(myHypothesis);
2639 //=============================================================================
2640 SMESHHOMARD::HOMARD_Iteration_ptr HOMARD_Gen_i::CreateIteration(const char* NomIteration, const char* nomIterParent)
2641 //=============================================================================
2643 MESSAGE ("CreateIteration : NomIteration = " << NomIteration << ", nomIterParent = " << nomIterParent);
2645 SMESHHOMARD::HOMARD_Iteration_var myIterationParent = myStudyContext._mesIterations[nomIterParent];
2646 if (CORBA::is_nil(myIterationParent))
2648 SALOME::ExceptionStruct es;
2649 es.type = SALOME::BAD_PARAM;
2650 es.text = "The parent iteration is not defined.";
2651 throw SALOME::SALOME_Exception(es);
2655 const char* nomCas = myIterationParent->GetCaseName();
2656 MESSAGE ("CreateIteration : nomCas = " << nomCas);
2657 SMESHHOMARD::HOMARD_Cas_var myCase = myStudyContext._mesCas[nomCas];
2658 if (CORBA::is_nil(myCase)) {
2659 SALOME::ExceptionStruct es;
2660 es.type = SALOME::BAD_PARAM;
2661 es.text = "Invalid case context";
2662 throw SALOME::SALOME_Exception(es);
2665 const char* nomDirCase = myCase->GetDirName();
2667 // Controle du nom :
2668 if ((myStudyContext._mesIterations).find(NomIteration) !=
2669 (myStudyContext._mesIterations).end())
2671 SALOME::ExceptionStruct es;
2672 es.type = SALOME::BAD_PARAM;
2673 es.text = "This iteration has already been defined.";
2674 throw SALOME::SALOME_Exception(es);
2678 SMESHHOMARD::HOMARD_Iteration_var myIteration = newIteration();
2679 if (CORBA::is_nil(myIteration)) {
2680 SALOME::ExceptionStruct es;
2681 es.type = SALOME::BAD_PARAM;
2682 es.text = "Unable to create the iteration";
2683 throw SALOME::SALOME_Exception(es);
2687 myStudyContext._mesIterations[std::string(NomIteration)] = myIteration;
2688 // Nom de l'iteration et du maillage
2689 myIteration->SetName(NomIteration);
2690 myIteration->SetMeshName(NomIteration);
2691 myIteration->SetState(1);
2693 int numero = myIterationParent->GetNumber() + 1;
2694 myIteration->SetNumber(numero);
2696 // Nombre d'iterations deja connues pour le cas, permettant
2697 // la creation d'un sous-répertoire unique
2698 int nbitercase = myCase->GetNumberofIter();
2699 char* nomDirIter = CreateDirNameIter(nomDirCase, nbitercase );
2700 myIteration->SetDirNameLoc(nomDirIter);
2702 // Le nom du fichier du maillage MED est indice par le nombre d'iterations du cas.
2703 // Si on a une chaine unique depuis le depart, ce nombre est le meme que le
2704 // numero d'iteration dans la sucession : maill.01.med, maill.02.med, etc... C'est la
2705 // situation la plus frequente.
2706 // Si on a plusieurs branches, donc des iterations du meme niveau d'adaptation, utiliser
2707 // le nombre d'iterations du cas permet d'eviter les collisions.
2709 if ( nbitercase < 100 ) { jaux = 2; }
2710 else if ( nbitercase < 1000 ) { jaux = 3; }
2711 else if ( nbitercase < 10000 ) { jaux = 4; }
2712 else if ( nbitercase < 100000 ) { jaux = 5; }
2714 std::ostringstream iaux;
2715 iaux << std::setw(jaux) << std::setfill('0') << nbitercase;
2716 std::stringstream MeshFile;
2717 MeshFile << nomDirCase << "/maill." << iaux.str() << ".med";
2718 myIteration->SetMeshFile(MeshFile.str().c_str());
2720 // Association avec le cas
2721 std::string label = "IterationHomard_" + std::string(nomIterParent);
2722 AssociateCaseIter(nomCas, NomIteration, label.c_str());
2724 // Lien avec l'iteration precedente
2725 myIterationParent->LinkNextIteration(NomIteration);
2726 myIteration->SetIterParentName(nomIterParent);
2728 return SMESHHOMARD::HOMARD_Iteration::_duplicate(myIteration);
2730 //=============================================================================
2731 SMESHHOMARD::HOMARD_Boundary_ptr HOMARD_Gen_i::CreateBoundary(const char* BoundaryName, CORBA::Long BoundaryType)
2733 MESSAGE ("CreateBoundary : BoundaryName = " << BoundaryName << ", BoundaryType = " << BoundaryType);
2735 // Controle du nom :
2736 if ((myStudyContext._mesBoundarys).find(BoundaryName)!=(myStudyContext._mesBoundarys).end())
2738 MESSAGE ("CreateBoundary : la frontiere " << BoundaryName << " existe deja");
2739 SALOME::ExceptionStruct es;
2740 es.type = SALOME::BAD_PARAM;
2741 es.text = "This boundary has already been defined";
2742 throw SALOME::SALOME_Exception(es);
2746 SMESHHOMARD::HOMARD_Boundary_var myBoundary = newBoundary();
2747 myBoundary->SetName(BoundaryName);
2748 myBoundary->SetType(BoundaryType);
2750 myStudyContext._mesBoundarys[BoundaryName] = myBoundary;
2752 return SMESHHOMARD::HOMARD_Boundary::_duplicate(myBoundary);
2754 //=============================================================================
2755 SMESHHOMARD::HOMARD_Boundary_ptr HOMARD_Gen_i::CreateBoundaryCAO(const char* BoundaryName, const char* CAOFile)
2757 MESSAGE ("CreateBoundaryCAO : BoundaryName = " << BoundaryName << ", CAOFile = " << CAOFile );
2758 SMESHHOMARD::HOMARD_Boundary_var myBoundary = CreateBoundary(BoundaryName, -1);
2759 myBoundary->SetDataFile( CAOFile );
2761 return SMESHHOMARD::HOMARD_Boundary::_duplicate(myBoundary);
2763 //=============================================================================
2764 SMESHHOMARD::HOMARD_Boundary_ptr HOMARD_Gen_i::CreateBoundaryDi(const char* BoundaryName, const char* MeshName, const char* MeshFile)
2766 MESSAGE ("CreateBoundaryDi : BoundaryName = " << BoundaryName << ", MeshName = " << MeshName << ", MeshFile = " << MeshFile );
2767 SMESHHOMARD::HOMARD_Boundary_var myBoundary = CreateBoundary(BoundaryName, 0);
2768 myBoundary->SetDataFile( MeshFile );
2769 myBoundary->SetMeshName( MeshName );
2771 return SMESHHOMARD::HOMARD_Boundary::_duplicate(myBoundary);
2773 //=============================================================================
2774 SMESHHOMARD::HOMARD_Boundary_ptr HOMARD_Gen_i::CreateBoundaryCylinder(const char* BoundaryName,
2775 CORBA::Double Xcentre, CORBA::Double Ycentre, CORBA::Double Zcentre,
2776 CORBA::Double Xaxe, CORBA::Double Yaxe, CORBA::Double Zaxe,
2777 CORBA::Double Rayon)
2779 MESSAGE ("CreateBoundaryCylinder : BoundaryName = " << BoundaryName );
2781 SALOME::ExceptionStruct es;
2784 { es.text = "The radius must be positive.";
2786 double daux = fabs(Xaxe) + fabs(Yaxe) + fabs(Zaxe);
2787 if ( daux < 0.0000001 )
2788 { es.text = "The axis must be a non 0 vector.";
2792 es.type = SALOME::BAD_PARAM;
2793 throw SALOME::SALOME_Exception(es);
2797 SMESHHOMARD::HOMARD_Boundary_var myBoundary = CreateBoundary(BoundaryName, 1);
2798 myBoundary->SetCylinder( Xcentre, Ycentre, Zcentre, Xaxe, Yaxe, Zaxe, Rayon );
2800 return SMESHHOMARD::HOMARD_Boundary::_duplicate(myBoundary);
2802 //=============================================================================
2803 SMESHHOMARD::HOMARD_Boundary_ptr HOMARD_Gen_i::CreateBoundarySphere(const char* BoundaryName,
2804 CORBA::Double Xcentre, CORBA::Double Ycentre, CORBA::Double Zcentre,
2805 CORBA::Double Rayon)
2807 MESSAGE ("CreateBoundarySphere : BoundaryName = " << BoundaryName );
2809 SALOME::ExceptionStruct es;
2812 { es.text = "The radius must be positive.";
2816 es.type = SALOME::BAD_PARAM;
2817 throw SALOME::SALOME_Exception(es);
2821 SMESHHOMARD::HOMARD_Boundary_var myBoundary = CreateBoundary(BoundaryName, 2);
2822 myBoundary->SetSphere( Xcentre, Ycentre, Zcentre, Rayon );
2824 return SMESHHOMARD::HOMARD_Boundary::_duplicate(myBoundary);
2826 //=============================================================================
2827 SMESHHOMARD::HOMARD_Boundary_ptr HOMARD_Gen_i::CreateBoundaryConeA(const char* BoundaryName,
2828 CORBA::Double Xaxe, CORBA::Double Yaxe, CORBA::Double Zaxe, CORBA::Double Angle,
2829 CORBA::Double Xcentre, CORBA::Double Ycentre, CORBA::Double Zcentre)
2831 MESSAGE ("CreateBoundaryConeA : BoundaryName = " << BoundaryName );
2833 SALOME::ExceptionStruct es;
2835 if ( Angle <= 0.0 || Angle >= 90.0 )
2836 { es.text = "The angle must be included higher than 0 degree and lower than 90 degrees.";
2838 double daux = fabs(Xaxe) + fabs(Yaxe) + fabs(Zaxe);
2839 if ( daux < 0.0000001 )
2840 { es.text = "The axis must be a non 0 vector.";
2844 es.type = SALOME::BAD_PARAM;
2845 throw SALOME::SALOME_Exception(es);
2849 SMESHHOMARD::HOMARD_Boundary_var myBoundary = CreateBoundary(BoundaryName, 3);
2850 myBoundary->SetConeA( Xaxe, Yaxe, Zaxe, Angle, Xcentre, Ycentre, Zcentre );
2852 return SMESHHOMARD::HOMARD_Boundary::_duplicate(myBoundary);
2854 //=============================================================================
2855 SMESHHOMARD::HOMARD_Boundary_ptr HOMARD_Gen_i::CreateBoundaryConeR(const char* BoundaryName,
2856 CORBA::Double Xcentre1, CORBA::Double Ycentre1, CORBA::Double Zcentre1, CORBA::Double Rayon1,
2857 CORBA::Double Xcentre2, CORBA::Double Ycentre2, CORBA::Double Zcentre2, CORBA::Double Rayon2)
2859 MESSAGE ("CreateBoundaryConeR : BoundaryName = " << BoundaryName );
2861 SALOME::ExceptionStruct es;
2863 if ( Rayon1 < 0.0 || Rayon2 < 0.0 )
2864 { es.text = "The radius must be positive.";
2866 double daux = fabs(Rayon2-Rayon1);
2867 if ( daux < 0.0000001 )
2868 { es.text = "The radius must be different.";
2870 daux = fabs(Xcentre2-Xcentre1) + fabs(Ycentre2-Ycentre1) + fabs(Zcentre2-Zcentre1);
2871 if ( daux < 0.0000001 )
2872 { es.text = "The centers must be different.";
2876 es.type = SALOME::BAD_PARAM;
2877 throw SALOME::SALOME_Exception(es);
2881 SMESHHOMARD::HOMARD_Boundary_var myBoundary = CreateBoundary(BoundaryName, 4);
2882 myBoundary->SetConeR( Xcentre1, Ycentre1, Zcentre1, Rayon1, Xcentre2, Ycentre2, Zcentre2, Rayon2 );
2884 return SMESHHOMARD::HOMARD_Boundary::_duplicate(myBoundary);
2886 //=============================================================================
2887 SMESHHOMARD::HOMARD_Boundary_ptr HOMARD_Gen_i::CreateBoundaryTorus(const char* BoundaryName,
2888 CORBA::Double Xcentre, CORBA::Double Ycentre, CORBA::Double Zcentre,
2889 CORBA::Double Xaxe, CORBA::Double Yaxe, CORBA::Double Zaxe,
2890 CORBA::Double RayonRev, CORBA::Double RayonPri)
2892 MESSAGE ("CreateBoundaryTorus : BoundaryName = " << BoundaryName );
2894 SALOME::ExceptionStruct es;
2896 if ( ( RayonRev <= 0.0 ) || ( RayonPri <= 0.0 ) )
2897 { es.text = "The radius must be positive.";
2899 double daux = fabs(Xaxe) + fabs(Yaxe) + fabs(Zaxe);
2900 if ( daux < 0.0000001 )
2901 { es.text = "The axis must be a non 0 vector.";
2905 es.type = SALOME::BAD_PARAM;
2906 throw SALOME::SALOME_Exception(es);
2910 SMESHHOMARD::HOMARD_Boundary_var myBoundary = CreateBoundary(BoundaryName, 5);
2911 myBoundary->SetTorus( Xcentre, Ycentre, Zcentre, Xaxe, Yaxe, Zaxe, RayonRev, RayonPri );
2913 return SMESHHOMARD::HOMARD_Boundary::_duplicate(myBoundary);
2916 //=============================================================================
2917 //=============================================================================
2918 // Traitement d'une iteration
2919 // etatMenage = 1 : destruction du répertoire d'execution
2920 // modeHOMARD = 1 : adaptation
2921 // != 1 : information avec les options modeHOMARD
2922 // Option1 >0 : appel depuis python
2923 // <0 : appel depuis GUI
2924 // Option2 : multiple de nombres premiers
2925 // 1 : aucune option
2926 // x2 : publication du maillage dans SMESH
2927 //=============================================================================
2928 CORBA::Long HOMARD_Gen_i::Compute(const char* NomIteration, CORBA::Long etatMenage, CORBA::Long modeHOMARD, CORBA::Long Option1, CORBA::Long Option2)
2930 INFOS ( "Compute : traitement de " << NomIteration << ", avec modeHOMARD = " << modeHOMARD << ", Option1 = " << Option1 << ", Option2 = " << Option2 );
2935 // A.1. L'objet iteration
2936 SMESHHOMARD::HOMARD_Iteration_var myIteration = myStudyContext._mesIterations[NomIteration];
2937 ASSERT(!CORBA::is_nil(myIteration));
2939 // A.2. Controle de la possibilite d'agir
2940 // A.2.1. Etat de l'iteration
2941 int etat = myIteration->GetState();
2942 MESSAGE ( "etat = "<<etat );
2943 // A.2.2. On ne calcule pas l'iteration initiale, ni une iteration deja calculee
2944 if ( modeHOMARD == 1 )
2948 SALOME::ExceptionStruct es;
2949 es.type = SALOME::BAD_PARAM;
2950 es.text = "This iteration is the first of the case and cannot be computed.";
2951 throw SALOME::SALOME_Exception(es);
2954 else if ( ( etat == 2 ) & ( modeHOMARD == 1 ) )
2956 SALOME::ExceptionStruct es;
2957 es.type = SALOME::BAD_PARAM;
2958 es.text = "This iteration is already computed.";
2959 throw SALOME::SALOME_Exception(es);
2963 // A.2.3. On n'analyse pas une iteration non calculee
2968 SALOME::ExceptionStruct es;
2969 es.type = SALOME::BAD_PARAM;
2970 es.text = "This iteration is not computed.";
2971 throw SALOME::SALOME_Exception(es);
2976 // A.3. Numero de l'iteration
2977 // siterp1 : numero de l'iteration a traiter
2979 // siter : numero de l'iteration parent, ou 0 si deja au debut mais cela ne servira pas !
2980 // Ou si information :
2982 int NumeIter = myIteration->GetNumber();
2983 std::string siterp1;
2984 std::stringstream saux1;
2986 siterp1 = saux1.str();
2987 if (NumeIter < 10) { siterp1 = "0" + siterp1; }
2990 if ( modeHOMARD==1 )
2992 std::stringstream saux0;
2993 int iaux = max(0, NumeIter-1);
2995 siter = saux0.str();
2996 if (NumeIter < 11) { siter = "0" + siter; }
2999 { siter = siterp1; }
3002 const char* nomCas = myIteration->GetCaseName();
3003 SMESHHOMARD::HOMARD_Cas_var myCase = myStudyContext._mesCas[nomCas];
3004 ASSERT(!CORBA::is_nil(myCase));
3006 // B. Les répertoires
3007 // B.1. Le répertoire courant
3008 std::string nomDirWork = getenv("PWD");
3009 // B.2. Le sous-répertoire de l'iteration a traiter
3010 char* DirCompute = ComputeDirManagement(myCase, myIteration, etatMenage);
3011 MESSAGE( ". DirCompute = " << DirCompute );
3013 // C. Le fichier des messages
3014 // C.1. Le deroulement de l'execution de HOMARD
3015 std::string LogFile = myIteration->GetLogFile();
3016 if (LogFile.empty()) {
3017 LogFile = DirCompute;
3018 LogFile += "/Liste";
3019 if ( modeHOMARD == 1 ) { LogFile += "." + siter + ".vers." + siterp1; }
3021 if ( modeHOMARD == 1 ) myIteration->SetLogFile(LogFile.c_str());
3023 MESSAGE (". LogFile = " << LogFile);
3024 // C.2. Le bilan de l'analyse du maillage
3025 std::string FileInfo = DirCompute;
3027 if ( modeHOMARD == 1 ) { FileInfo += "apad"; }
3029 { if ( NumeIter == 0 ) { FileInfo += "info_av"; }
3030 else { FileInfo += "info_ap"; }
3032 FileInfo += "." + siterp1 + ".bilan";
3033 myIteration->SetFileInfo(FileInfo.c_str());
3035 // D. On passe dans le répertoire de l'iteration a calculer
3036 MESSAGE ( ". On passe dans DirCompute = " << DirCompute );
3039 // E. Les données de l'exécution HOMARD
3040 // E.1. L'objet du texte du fichier de configuration
3041 SMESHHOMARDImpl::HomardDriver* myDriver = new SMESHHOMARDImpl::HomardDriver(siter, siterp1);
3042 myDriver->TexteInit(DirCompute, LogFile, _Langue);
3044 // E.2. Le maillage associe a l'iteration
3045 const char* NomMesh = myIteration->GetMeshName();
3046 MESSAGE ( ". NomMesh = " << NomMesh );
3047 const char* MeshFile = myIteration->GetMeshFile();
3048 MESSAGE ( ". MeshFile = " << MeshFile );
3050 // E.3. Les données du traitement HOMARD
3052 if ( modeHOMARD == 1 )
3055 myDriver->TexteMaillageHOMARD( DirCompute, siterp1, iaux );
3056 myDriver->TexteMaillage(NomMesh, MeshFile, 1);
3057 codret = ComputeAdap(myCase, myIteration, etatMenage, myDriver, Option1, Option2);
3061 InvalideIterInfo(NomIteration);
3062 myDriver->TexteInfo( modeHOMARD, NumeIter );
3064 myDriver->TexteMaillageHOMARD( DirCompute, siterp1, iaux );
3065 myDriver->TexteMaillage(NomMesh, MeshFile, 0);
3066 myDriver->CreeFichierDonn();
3069 // E.4. Ajout des informations liees a l'eventuel suivi de frontiere
3070 int BoundaryOption = DriverTexteBoundary(myCase, myDriver);
3072 // E.5. Ecriture du texte dans le fichier
3073 MESSAGE ( ". Ecriture du texte dans le fichier de configuration; codret = "<<codret );
3075 { myDriver->CreeFichier(); }
3079 int codretexec = 1789;
3082 codretexec = myDriver->ExecuteHomard(Option1);
3084 MESSAGE ( "Erreur en executant HOMARD : " << codretexec );
3085 // En mode adaptation, on ajuste l'etat de l'iteration
3086 if ( modeHOMARD == 1 )
3088 if (codretexec == 0) { SetEtatIter(NomIteration,2); }
3089 else { SetEtatIter(NomIteration,1); }
3090 // GERALD -- QMESSAGE BOX
3094 // H. Gestion des resultats
3097 std::string Commentaire;
3098 // H.1. Le fichier des messages, dans tous les cas
3099 Commentaire = "log";
3100 if ( modeHOMARD == 1 ) { Commentaire += " " + siterp1; }
3101 else { Commentaire += "Info"; }
3103 // H.2. Si tout s'est bien passe :
3104 if (codretexec == 0)
3106 // H.2.1. Le fichier de bilan
3107 Commentaire = "Summary";
3108 if ( modeHOMARD == 1 ) { Commentaire += " " + siterp1; }
3109 else { Commentaire += "Info"; }
3110 // H.2.2. Le fichier de maillage obtenu
3111 if ( modeHOMARD == 1 )
3113 std::stringstream saux0;
3114 Commentaire = "Mesh";
3115 Commentaire += " " + siterp1;
3116 if ( Option2 % 2 == 0 ) { PublishResultInSmesh(MeshFile, 1); }
3119 // H.3 Message d'erreur
3120 if (codretexec != 0) {
3121 std::string text = "";
3122 // Message d'erreur en cas de probleme en adaptation
3123 if ( modeHOMARD == 1 ) {
3124 text = "Error during the adaptation.\n";
3125 bool stopvu = false;
3126 std::ifstream fichier( LogFile.c_str() );
3127 if ( fichier ) // ce test échoue si le fichier n'est pas ouvert
3129 std::string ligne; // variable contenant chaque ligne lue
3130 while ( std::getline( fichier, ligne ) )
3134 { text += ligne+ "\n"; }
3137 int position = ligne.find( "===== HOMARD ===== STOP =====" );
3138 if ( position > 0 ) { stopvu = true; }
3143 text += "\n\nSee the file " + LogFile + "\n";
3145 SALOME::ExceptionStruct es;
3146 es.type = SALOME::BAD_PARAM;
3147 es.text = CORBA::string_dup(text.c_str());
3148 throw SALOME::SALOME_Exception(es);
3150 // En mode information, on force le succes pour pouvoir consulter le fichier log
3151 if ( modeHOMARD != 1 ) { codretexec = 0; }
3155 // I. Menage et retour dans le répertoire du cas
3159 MESSAGE ( ". On retourne dans nomDirWork = " << nomDirWork );
3161 CHDIR(nomDirWork.c_str());
3164 // J. Suivi de la frontière CAO
3165 // std::cout << "- codret : " << codret << std::endl;
3166 // std::cout << "- modeHOMARD : " << modeHOMARD << std::endl;
3167 // std::cout << "- BoundaryOption : " << BoundaryOption << std::endl;
3168 // std::cout << "- codretexec : " << codretexec << std::endl;
3171 if ( ( modeHOMARD == 1 ) && ( BoundaryOption % 5 == 0 ) && (codretexec == 0) )
3173 MESSAGE ( "Suivi de frontière CAO" );
3174 codret = ComputeCAO(myCase, myIteration, Option1, Option2);
3180 //=============================================================================
3181 // Calcul d'une iteration : partie spécifique à l'adaptation
3182 //=============================================================================
3183 CORBA::Long HOMARD_Gen_i::ComputeAdap(SMESHHOMARD::HOMARD_Cas_var myCase,
3184 SMESHHOMARD::HOMARD_Iteration_var myIteration,
3185 CORBA::Long etatMenage,
3186 SMESHHOMARDImpl::HomardDriver* myDriver,
3187 CORBA::Long Option1,
3188 CORBA::Long Option2)
3190 MESSAGE ( "ComputeAdap avec Option1 = " << Option1 << ", Option2 = " << Option2 );
3195 // Numero de l'iteration
3196 int NumeIter = myIteration->GetNumber();
3197 std::stringstream saux0;
3198 saux0 << NumeIter-1;
3199 std::string siter = saux0.str();
3200 if (NumeIter < 11) { siter = "0" + siter; }
3202 // A.2. On verifie qu il y a une hypothese (erreur improbable);
3203 const char* nomHypo = myIteration->GetHypoName();
3204 if (std::string(nomHypo) == std::string(""))
3206 SALOME::ExceptionStruct es;
3207 es.type = SALOME::BAD_PARAM;
3208 es.text = "This iteration does not have any associated hypothesis.";
3209 throw SALOME::SALOME_Exception(es);
3212 SMESHHOMARD::HOMARD_Hypothesis_var myHypo = myStudyContext._mesHypotheses[nomHypo];
3213 ASSERT(!CORBA::is_nil(myHypo));
3215 // B. L'iteration parent
3216 const char* nomIterationParent = myIteration->GetIterParentName();
3217 SMESHHOMARD::HOMARD_Iteration_var myIterationParent = myStudyContext._mesIterations[nomIterationParent];
3218 ASSERT(!CORBA::is_nil(myIterationParent));
3219 // Si l'iteration parent n'est pas calculee, on le fait (recursivite amont)
3220 if ( myIterationParent->GetState() == 1 )
3223 int codret = Compute(nomIterationParent, etatMenage, iaux, Option1, Option2);
3226 // GERALD -- QMESSAGE BOX
3227 VERIFICATION("Pb au calcul de l'iteration precedente" == 0);
3231 // C. Le sous-répertoire de l'iteration precedente
3232 char* DirComputePa = ComputeDirPaManagement(myCase, myIteration);
3233 MESSAGE( ". DirComputePa = " << DirComputePa );
3235 // D. Les données de l'adaptation HOMARD
3236 // D.1. Le type de conformite
3237 int ConfType = myCase->GetConfType();
3238 MESSAGE ( ". ConfType = " << ConfType );
3240 // D.1. Le type externe
3241 int ExtType = myCase->GetExtType();
3242 MESSAGE ( ". ExtType = " << ExtType );
3244 // D.3. Le maillage de depart
3245 const char* NomMeshParent = myIterationParent->GetMeshName();
3246 MESSAGE ( ". NomMeshParent = " << NomMeshParent );
3247 const char* MeshFileParent = myIterationParent->GetMeshFile();
3248 MESSAGE ( ". MeshFileParent = " << MeshFileParent );
3250 // D.4. Le maillage associe a l'iteration
3251 const char* MeshFile = myIteration->GetMeshFile();
3252 MESSAGE ( ". MeshFile = " << MeshFile );
3253 FILE *file = fopen(MeshFile,"r");
3257 if (etatMenage == 0)
3259 SALOME::ExceptionStruct es;
3260 es.type = SALOME::BAD_PARAM;
3261 std::string text = "MeshFile : " + std::string(MeshFile) + " already exists ";
3262 es.text = CORBA::string_dup(text.c_str());
3263 throw SALOME::SALOME_Exception(es);
3268 std::string commande = "rm -f " + std::string(MeshFile);
3269 codret = system(commande.c_str());
3272 SALOME::ExceptionStruct es;
3273 es.type = SALOME::BAD_PARAM;
3274 es.text = "The mesh file cannot be deleted.";
3275 throw SALOME::SALOME_Exception(es);
3281 // D.5. Les types de raffinement et de deraffinement
3282 // Les appels corba sont lourds, il vaut mieux les grouper
3283 SMESHHOMARD::listeTypes* ListTypes = myHypo->GetAdapRefinUnRef();
3284 ASSERT(ListTypes->length() == 3);
3285 int TypeAdap = (*ListTypes)[0];
3286 int TypeRaff = (*ListTypes)[1];
3287 int TypeDera = (*ListTypes)[2];
3288 // MESSAGE ( ". TypeAdap = " << TypeAdap << ", TypeRaff = " << TypeRaff << ", TypeDera = " << TypeDera );
3290 // E. Texte du fichier de configuration
3291 // E.1. Incontournables du texte
3292 myDriver->TexteAdap(ExtType);
3294 myDriver->TexteMaillageHOMARD( DirComputePa, siter, iaux );
3295 myDriver->TexteMaillage(NomMeshParent, MeshFileParent, 0);
3296 myDriver->TexteConfRaffDera(ConfType, TypeAdap, TypeRaff, TypeDera);
3298 // E.3. Ajout des informations liees aux champs eventuels
3299 if ( TypeAdap == 1 )
3300 { DriverTexteField(myIteration, myHypo, myDriver); }
3302 // E.4. Ajout des informations liees au filtrage eventuel par les groupes
3303 SMESHHOMARD::ListGroupType* listeGroupes = myHypo->GetGroups();
3304 int numberOfGroups = listeGroupes->length();
3305 MESSAGE( ". Filtrage par " << numberOfGroups << " groupes");
3306 if (numberOfGroups > 0)
3308 for (int NumGroup = 0; NumGroup< numberOfGroups; NumGroup++)
3310 std::string GroupName = std::string((*listeGroupes)[NumGroup]);
3311 MESSAGE( "... GroupName = " << GroupName );
3312 myDriver->TexteGroup(GroupName);
3316 // E.5. Ajout des informations liees a l'eventuelle interpolation des champs
3317 DriverTexteFieldInterp(myIteration, myHypo, myDriver);
3319 // E.6. Ajout des options avancees
3320 int Pyram = myCase->GetPyram();
3321 MESSAGE ( ". Pyram = " << Pyram );
3322 int NivMax = myHypo->GetNivMax();
3323 MESSAGE ( ". NivMax = " << NivMax );
3324 double DiamMin = myHypo->GetDiamMin();
3325 MESSAGE ( ". DiamMin = " << DiamMin );
3326 int AdapInit = myHypo->GetAdapInit();
3327 MESSAGE ( ". AdapInit = " << AdapInit );
3328 int ExtraOutput = myHypo->GetExtraOutput();
3329 MESSAGE ( ". ExtraOutput = " << ExtraOutput );
3330 myDriver->TexteAdvanced(Pyram, NivMax, DiamMin, AdapInit, ExtraOutput);
3332 // E.7. Ajout des informations sur le deroulement de l'execution
3333 int MessInfo = myIteration->GetInfoCompute();
3334 MESSAGE ( ". MessInfo = " << MessInfo );
3335 myDriver->TexteInfoCompute(MessInfo);
3339 //=============================================================================
3340 // Calcul d'une iteration : partie spécifique au suivi de frontière CAO
3341 //=============================================================================
3342 CORBA::Long HOMARD_Gen_i::ComputeCAO(SMESHHOMARD::HOMARD_Cas_var myCase, SMESHHOMARD::HOMARD_Iteration_var myIteration, CORBA::Long Option1, CORBA::Long Option2)
3344 MESSAGE ( "ComputeCAO avec Option1 = " << Option1 << ", Option2 = " << Option2 );
3349 // A.2. Le sous-répertoire de l'iteration en cours de traitement
3350 char* DirCompute = myIteration->GetDirName();
3351 // A.3. Le maillage résultat de l'iteration en cours de traitement
3352 char* MeshFile = myIteration->GetMeshFile();
3354 // B. Les données pour FrontTrack
3355 // B.1. Le maillage à modifier
3356 const std::string theInputMedFile = MeshFile;
3357 MESSAGE ( ". theInputMedFile = " << theInputMedFile );
3359 // B.2. Le maillage après modification : fichier identique
3360 const std::string theOutputMedFile = MeshFile;
3361 MESSAGE ( ". theOutputMedFile = " << theInputMedFile );
3363 // B.3. La liste des fichiers contenant les numéros des noeuds à bouger
3364 std::vector< std::string > theInputNodeFiles;
3365 MESSAGE ( ". DirCompute = " << DirCompute );
3370 struct dirent *dirp;
3371 dp = opendir(DirCompute);
3372 while ( (dirp = readdir(dp)) != NULL )
3374 std::string file_name(dirp->d_name);
3375 bilan = file_name.find("fr");
3376 if ( bilan != string::npos )
3378 std::stringstream filename_total;
3379 filename_total << DirCompute << "/" << file_name;
3380 theInputNodeFiles.push_back(filename_total.str());
3385 HANDLE hFind = INVALID_HANDLE_VALUE;
3386 WIN32_FIND_DATA ffd;
3387 hFind = FindFirstFile(DirNameStart, &ffd);
3388 if (INVALID_HANDLE_VALUE != hFind) {
3389 while (FindNextFile(hFind, &ffd) != 0) {
3390 std::string file_name(ffd.cFileName);
3391 bilan = file_name.find("fr");
3392 if ( bilan != string::npos )
3394 std::stringstream filename_total;
3395 filename_total << DirCompute << "/" << file_name;
3396 theInputNodeFiles.push_back(filename_total.str());
3403 for ( int i = 0; i < icpt; i++ )
3404 { MESSAGE ( ". theInputNodeFiles["<< i << "] = " << theInputNodeFiles[i] ); }
3406 // B.4. Le fichier de la CAO
3407 SMESHHOMARD::ListBoundaryGroupType* ListBoundaryGroupType = myCase->GetBoundaryGroup();
3408 std::string BoundaryName = std::string((*ListBoundaryGroupType)[0]);
3409 MESSAGE ( ". BoundaryName = " << BoundaryName );
3410 SMESHHOMARD::HOMARD_Boundary_var myBoundary = myStudyContext._mesBoundarys[BoundaryName];
3411 const std::string theXaoFileName = myBoundary->GetDataFile();
3412 MESSAGE ( ". theXaoFileName = " << theXaoFileName );
3414 // B.5. Parallélisme
3415 bool theIsParallel = false;
3417 // C. Lancement des projections
3418 MESSAGE ( ". Lancement des projections" );
3419 //FrontTrack* myFrontTrack = new FrontTrack();
3420 //myFrontTrack->track(theInputMedFile, theOutputMedFile, theInputNodeFiles, theXaoFileName, theIsParallel);
3422 // D. Transfert des coordonnées modifiées dans le fichier historique de HOMARD
3423 // On lance une exécution spéciale de HOMARD en attendant de savoir le faire avec MEDCoupling
3424 MESSAGE ( ". Transfert des coordonnées" );
3425 codret = ComputeCAObis(myIteration, Option1, Option2);
3429 //=============================================================================
3430 //=============================================================================
3431 // Transfert des coordonnées en suivi de frontière CAO
3432 // Option1 >0 : appel depuis python
3433 // <0 : appel depuis GUI
3434 // Option2 : multiple de nombres premiers
3435 // 1 : aucune option
3436 // x2 : publication du maillage dans SMESH
3437 //=============================================================================
3438 CORBA::Long HOMARD_Gen_i::ComputeCAObis(SMESHHOMARD::HOMARD_Iteration_var myIteration, CORBA::Long Option1, CORBA::Long Option2)
3440 MESSAGE ( "ComputeCAObis, avec Option1 = " << Option1 << ", Option2 = " << Option2 );
3445 // A.1. Controle de la possibilite d'agir
3446 // A.1.1. Etat de l'iteration
3447 int etat = myIteration->GetState();
3448 MESSAGE ( "etat = "<<etat );
3449 // A.1.2. L'iteration doit être calculee
3452 SALOME::ExceptionStruct es;
3453 es.type = SALOME::BAD_PARAM;
3454 es.text = "This iteration is not computed.";
3455 throw SALOME::SALOME_Exception(es);
3458 // A.2. Numero de l'iteration
3459 // siterp1 : numero de l'iteration a traiter
3460 int NumeIter = myIteration->GetNumber();
3461 std::string siterp1;
3462 std::stringstream saux1;
3464 siterp1 = saux1.str();
3465 if (NumeIter < 10) { siterp1 = "0" + siterp1; }
3466 MESSAGE ( "siterp1 = "<<siterp1 );
3469 const char* CaseName = myIteration->GetCaseName();
3470 SMESHHOMARD::HOMARD_Cas_var myCase = myStudyContext._mesCas[CaseName];
3471 ASSERT(!CORBA::is_nil(myCase));
3473 // A.4. Le sous-répertoire de l'iteration a traiter
3474 char* DirCompute = myIteration->GetDirName();
3475 MESSAGE( ". DirCompute = " << DirCompute );
3477 // C. Le fichier des messages
3478 std::string LogFile = DirCompute;
3479 LogFile += "/Liste." + siterp1 + ".maj_coords.log";
3480 MESSAGE (". LogFile = " << LogFile);
3481 myIteration->SetFileInfo(LogFile.c_str());
3483 // D. On passe dans le répertoire de l'iteration a calculer
3484 MESSAGE ( ". On passe dans DirCompute = " << DirCompute );
3487 // E. Les données de l'exécution HOMARD
3488 // E.1. L'objet du texte du fichier de configuration
3489 SMESHHOMARDImpl::HomardDriver* myDriver = new SMESHHOMARDImpl::HomardDriver("", siterp1);
3490 myDriver->TexteInit(DirCompute, LogFile, _Langue);
3492 // E.2. Le maillage associe a l'iteration
3493 const char* NomMesh = myIteration->GetMeshName();
3494 MESSAGE ( ". NomMesh = " << NomMesh );
3495 const char* MeshFile = myIteration->GetMeshFile();
3496 MESSAGE ( ". MeshFile = " << MeshFile );
3498 // E.3. Les données du traitement HOMARD
3500 myDriver->TexteMajCoords( NumeIter );
3502 myDriver->TexteMaillageHOMARD( DirCompute, siterp1, iaux );
3503 myDriver->TexteMaillage(NomMesh, MeshFile, 0);
3505 // E.4. Ecriture du texte dans le fichier
3506 MESSAGE ( ". Ecriture du texte dans le fichier de configuration; codret = "<<codret );
3508 { myDriver->CreeFichier(); }
3512 int codretexec = 1789;
3515 codretexec = myDriver->ExecuteHomard(Option1);
3516 MESSAGE ( "Erreur en executant HOMARD : " << codretexec );
3519 // G. Gestion des resultats
3522 // G.1. Le fichier des messages, dans tous les cas
3523 const char* NomIteration = myIteration->GetName();
3524 std::string Commentaire = "logmaj_coords";
3525 // G.2 Message d'erreur
3526 if (codretexec != 0)
3528 std::string text = "\n\nSee the file " + LogFile + "\n";
3530 SALOME::ExceptionStruct es;
3531 es.type = SALOME::BAD_PARAM;
3532 es.text = CORBA::string_dup(text.c_str());
3533 throw SALOME::SALOME_Exception(es);
3535 // On force le succes pour pouvoir consulter le fichier log
3540 // H. Menage et retour dans le répertoire du cas
3541 if (codret == 0) { delete myDriver; }
3545 //=============================================================================
3546 // Creation d'un nom de sous-répertoire pour l'iteration au sein d'un répertoire parent
3547 // nomrep : nom du répertoire parent
3548 // num : le nom du sous-répertoire est sous la forme 'In', n est >= num
3549 //=============================================================================
3550 char* HOMARD_Gen_i::CreateDirNameIter(const char* nomrep, CORBA::Long num )
3552 MESSAGE ( "CreateDirNameIter : nomrep ="<< nomrep << ", num = "<<num);
3553 // On verifie que le répertoire parent existe
3554 int codret = CHDIR(nomrep);
3557 SALOME::ExceptionStruct es;
3558 es.type = SALOME::BAD_PARAM;
3559 es.text = "The directory of the case does not exist.";
3560 throw SALOME::SALOME_Exception(es);
3563 std::string nomDirActuel = getenv("PWD");
3564 std::string DirName;
3565 // On boucle sur tous les noms possibles jusqu'a trouver un nom correspondant a un répertoire inconnu
3566 bool a_chercher = true;
3567 while ( a_chercher )
3569 // On passe dans le répertoire parent
3572 // On recherche un nom sous la forme Iabc, avec abc representant le numero
3574 if ( num < 100 ) { jaux = 2; }
3575 else if ( num < 1000 ) { jaux = 3; }
3576 else if ( num < 10000 ) { jaux = 4; }
3577 else if ( num < 100000 ) { jaux = 5; }
3579 std::ostringstream iaux;
3580 iaux << std::setw(jaux) << std::setfill('0') << num;
3581 std::ostringstream DirNameA;
3582 DirNameA << "I" << iaux.str();
3583 // Si on ne pas peut entrer dans le répertoire, on doit verifier
3584 // que c'est bien un probleme d'absence
3585 if ( CHDIR(DirNameA.str().c_str()) != 0 )
3587 bool existe = false;
3590 struct dirent *dirp;
3591 dp = opendir(nomrep);
3592 while ( (dirp = readdir(dp)) != NULL )
3594 std::string file_name(dirp->d_name);
3596 HANDLE hFind = INVALID_HANDLE_VALUE;
3597 WIN32_FIND_DATA ffd;
3598 hFind = FindFirstFile(nomrep, &ffd);
3599 if (INVALID_HANDLE_VALUE != hFind) {
3600 while (FindNextFile(hFind, &ffd) != 0) {
3601 if (ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) continue; //skip directories
3602 std::string file_name(ffd.cFileName);
3604 if ( file_name == DirNameA.str() ) { existe = true; }
3613 DirName = DirNameA.str();
3621 MESSAGE ( "==> DirName = " << DirName);
3622 MESSAGE ( ". On retourne dans nomDirActuel = " << nomDirActuel );
3623 CHDIR(nomDirActuel.c_str());
3624 return CORBA::string_dup( DirName.c_str() );
3626 //=============================================================================
3627 // Calcul d'une iteration : gestion du répertoire de calcul
3628 // Si le sous-répertoire existe :
3629 // etatMenage = 0 : on sort en erreur si le répertoire n'est pas vide
3630 // etatMenage = 1 : on fait le menage du répertoire
3631 // etatMenage = -1 : on ne fait rien
3632 //=============================================================================
3633 char* HOMARD_Gen_i::ComputeDirManagement(SMESHHOMARD::HOMARD_Cas_var myCase, SMESHHOMARD::HOMARD_Iteration_var myIteration, CORBA::Long etatMenage)
3635 MESSAGE ( "ComputeDirManagement : répertoires pour le calcul" );
3636 // B.2. Le répertoire du cas
3637 const char* nomDirCase = myCase->GetDirName();
3638 MESSAGE ( ". nomDirCase = " << nomDirCase );
3640 // B.3. Le sous-répertoire de l'iteration a calculer, puis le répertoire complet a creer
3641 // B.3.1. Le nom du sous-répertoire
3642 const char* nomDirIt = myIteration->GetDirNameLoc();
3644 // B.3.2. Le nom complet du sous-répertoire
3645 std::stringstream DirCompute;
3646 DirCompute << nomDirCase << "/" << nomDirIt;
3647 MESSAGE (". DirCompute = " << DirCompute.str() );
3649 // B.3.3. Si le sous-répertoire n'existe pas, on le cree
3650 if (CHDIR(DirCompute.str().c_str()) != 0)
3653 if (mkdir(DirCompute.str().c_str(), S_IRWXU|S_IRGRP|S_IXGRP) != 0)
3655 if (_mkdir(DirCompute.str().c_str()) != 0)
3658 // GERALD -- QMESSAGE BOX
3659 std::cerr << "Pb Creation du répertoire DirCompute = " << DirCompute.str() << std::endl;
3660 VERIFICATION("Pb a la creation du répertoire" == 0);
3665 // Le répertoire existe
3666 // On demande de faire le menage de son contenu :
3667 if (etatMenage == 1)
3669 MESSAGE (". Menage du répertoire DirCompute = " << DirCompute.str());
3670 std::string commande = "rm -rf " + DirCompute.str()+"/*";
3671 int codret = system(commande.c_str());
3674 // GERALD -- QMESSAGE BOX
3675 std::cerr << ". Menage du répertoire de calcul" << DirCompute.str() << std::endl;
3676 VERIFICATION("Pb au menage du répertoire de calcul" == 0);
3679 // On n'a pas demande de faire le menage de son contenu : on sort en erreur :
3682 if (etatMenage == 0)
3686 struct dirent *dirp;
3687 dp = opendir(DirCompute.str().c_str());
3689 while ((dirp = readdir(dp)) != NULL && result )
3691 std::string file_name(dirp->d_name);
3692 result = file_name.empty() || file_name == "." || file_name == ".."; //if any file - break and return false
3696 HANDLE hFind = INVALID_HANDLE_VALUE;
3697 WIN32_FIND_DATA ffd;
3698 hFind = FindFirstFile(DirCompute.str().c_str(), &ffd);
3700 if (INVALID_HANDLE_VALUE != hFind) {
3701 while (FindNextFile(hFind, &ffd) != 0) {
3702 if (ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) continue; //skip directories
3703 std::string file_name(ffd.cFileName);
3704 result = file_name.empty() || file_name == "." || file_name == ".."; //if any file - break and return false
3709 if ( result == false)
3711 SALOME::ExceptionStruct es;
3712 es.type = SALOME::BAD_PARAM;
3713 std::string text = "Directory : " + DirCompute.str() + " is not empty";
3714 es.text = CORBA::string_dup(text.c_str());
3715 throw SALOME::SALOME_Exception(es);
3716 VERIFICATION("Directory is not empty" == 0);
3722 return CORBA::string_dup( DirCompute.str().c_str() );
3724 //=============================================================================
3725 // Calcul d'une iteration : gestion du répertoire de calcul de l'iteration parent
3726 //=============================================================================
3727 char* HOMARD_Gen_i::ComputeDirPaManagement(SMESHHOMARD::HOMARD_Cas_var myCase, SMESHHOMARD::HOMARD_Iteration_var myIteration)
3729 MESSAGE ( "ComputeDirPaManagement : répertoires pour le calcul" );
3730 // Le répertoire du cas
3731 const char* nomDirCase = myCase->GetDirName();
3732 MESSAGE ( ". nomDirCase = " << nomDirCase );
3734 // Le sous-répertoire de l'iteration precedente
3736 const char* nomIterationParent = myIteration->GetIterParentName();
3737 SMESHHOMARD::HOMARD_Iteration_var myIterationParent = myStudyContext._mesIterations[nomIterationParent];
3738 const char* nomDirItPa = myIterationParent->GetDirNameLoc();
3739 std::stringstream DirComputePa;
3740 DirComputePa << nomDirCase << "/" << nomDirItPa;
3741 MESSAGE( ". nomDirItPa = " << nomDirItPa);
3742 MESSAGE( ". DirComputePa = " << DirComputePa.str() );
3744 return CORBA::string_dup( DirComputePa.str().c_str() );
3746 //=============================================================================
3747 // Calcul d'une iteration : ecriture des champs dans le fichier de configuration
3748 //=============================================================================
3749 void HOMARD_Gen_i::DriverTexteField(SMESHHOMARD::HOMARD_Iteration_var myIteration, SMESHHOMARD::HOMARD_Hypothesis_var myHypo, SMESHHOMARDImpl::HomardDriver* myDriver)
3751 MESSAGE ( "... DriverTexteField" );
3752 // Le fichier du champ
3753 char* FieldFile = myIteration->GetFieldFile();
3754 MESSAGE ( ". FieldFile = " << FieldFile );
3755 if (strlen(FieldFile) == 0)
3757 // GERALD -- QMESSAGE BOX
3758 std::cerr << "Le fichier du champ n'a pas ete fourni." << std::endl;
3759 VERIFICATION("The file for the field is not given." == 0);
3761 // Les caracteristiques d'instants du champ de pilotage
3762 int TimeStep = myIteration->GetTimeStep();
3763 MESSAGE( ". TimeStep = " << TimeStep );
3764 int Rank = myIteration->GetRank();
3765 MESSAGE( ". Rank = " << Rank );
3766 // Les informations sur les champs
3767 SMESHHOMARD::InfosHypo* aInfosHypo = myHypo->GetField();
3769 const char* FieldName = aInfosHypo->FieldName;
3771 int TypeThR = aInfosHypo->TypeThR;
3772 double ThreshR = aInfosHypo->ThreshR;
3773 int TypeThC = aInfosHypo->TypeThC;
3774 double ThreshC = aInfosHypo->ThreshC;
3775 // Saut entre mailles ou non ?
3776 int UsField = aInfosHypo->UsField;
3777 MESSAGE( ". UsField = " << UsField );
3778 // L'usage des composantes
3779 int UsCmpI = aInfosHypo->UsCmpI;
3780 MESSAGE( ". UsCmpI = " << UsCmpI );
3782 myDriver->TexteField(FieldName, FieldFile, TimeStep, Rank, TypeThR, ThreshR, TypeThC, ThreshC, UsField, UsCmpI);
3785 SMESHHOMARD::listeComposantsHypo* mescompo = myHypo->GetComps();
3786 int numberOfCompos = mescompo->length();
3787 MESSAGE( ". numberOfCompos = " << numberOfCompos );
3788 for (int NumeComp = 0; NumeComp< numberOfCompos; NumeComp++)
3790 std::string nomCompo = std::string((*mescompo)[NumeComp]);
3791 MESSAGE( "... nomCompo = " << nomCompo );
3792 myDriver->TexteCompo(NumeComp, nomCompo);
3795 //=============================================================================
3796 // Calcul d'une iteration : ecriture des frontieres dans le fichier de configuration
3797 // On ecrit dans l'ordre :
3798 // 1. la definition des frontieres
3799 // 2. les liens avec les groupes
3800 // 3. un entier resumant le type de comportement pour les frontieres
3801 //=============================================================================
3802 int HOMARD_Gen_i::DriverTexteBoundary(SMESHHOMARD::HOMARD_Cas_var myCase, SMESHHOMARDImpl::HomardDriver* myDriver)
3804 MESSAGE ( "... DriverTexteBoundary" );
3805 // 1. Recuperation des frontieres
3806 std::list<std::string> ListeBoundaryTraitees;
3807 SMESHHOMARD::ListBoundaryGroupType* ListBoundaryGroupType = myCase->GetBoundaryGroup();
3808 int numberOfitems = ListBoundaryGroupType->length();
3809 MESSAGE ( "... number of string for Boundary+Group = " << numberOfitems);
3810 int BoundaryOption = 1;
3811 // 2. Parcours des frontieres pour ecrire leur description
3812 int NumBoundaryAnalytical = 0;
3813 for (int NumBoundary = 0; NumBoundary< numberOfitems; NumBoundary=NumBoundary+2)
3815 std::string BoundaryName = std::string((*ListBoundaryGroupType)[NumBoundary]);
3816 MESSAGE ( "... BoundaryName = " << BoundaryName);
3817 // 2.1. La frontiere a-t-elle deja ete ecrite ?
3818 // Cela arrive quand elle est liee a plusieurs groupes. Il ne faut l'ecrire que la premiere fois
3820 std::list<std::string>::const_iterator it = ListeBoundaryTraitees.begin();
3821 while (it != ListeBoundaryTraitees.end())
3823 MESSAGE ( "..... BoundaryNameTraitee = " << *it);
3824 if ( BoundaryName == *it ) { A_faire = 0; }
3827 // 2.2. Ecriture de la frontiere
3830 // 2.2.1. Caracteristiques de la frontiere
3831 SMESHHOMARD::HOMARD_Boundary_var myBoundary = myStudyContext._mesBoundarys[BoundaryName];
3832 ASSERT(!CORBA::is_nil(myBoundary));
3833 int BoundaryType = myBoundary->GetType();
3834 MESSAGE ( "... BoundaryType = " << BoundaryType );
3835 // 2.2.2. Ecriture selon le type
3836 // 2.2.2.1. Cas d une frontiere CAO
3837 if (BoundaryType == -1)
3839 // const char* CAOFile = myBoundary->GetDataFile();
3840 // MESSAGE ( ". CAOFile = " << CAOFile );
3841 if ( BoundaryOption % 5 != 0 ) { BoundaryOption = BoundaryOption*5; }
3843 // 2.2.2.2. Cas d une frontiere discrete
3844 else if (BoundaryType == 0)
3846 const char* MeshName = myBoundary->GetMeshName();
3847 MESSAGE ( ". MeshName = " << MeshName );
3848 const char* MeshFile = myBoundary->GetDataFile();
3849 MESSAGE ( ". MeshFile = " << MeshFile );
3850 myDriver->TexteBoundaryDi( MeshName, MeshFile);
3851 if ( BoundaryOption % 2 != 0 ) { BoundaryOption = BoundaryOption*2; }
3853 // 2.2.2.3. Cas d une frontiere analytique
3856 NumBoundaryAnalytical++;
3857 SMESHHOMARD::double_array* coor = myBoundary->GetCoords();
3858 if (BoundaryType == 1) // Cas d un cylindre
3860 myDriver->TexteBoundaryAn(BoundaryName, NumBoundaryAnalytical, BoundaryType, (*coor)[0], (*coor)[1], (*coor)[2], (*coor)[3], (*coor)[4], (*coor)[5], (*coor)[6], 0.);
3861 if ( BoundaryOption % 3 != 0 ) { BoundaryOption = BoundaryOption*3; }
3863 else if (BoundaryType == 2) // Cas d une sphere
3865 myDriver->TexteBoundaryAn(BoundaryName, NumBoundaryAnalytical, BoundaryType, (*coor)[0], (*coor)[1], (*coor)[2], (*coor)[3], 0., 0., 0., 0.);
3866 if ( BoundaryOption % 3 != 0 ) { BoundaryOption = BoundaryOption*3; }
3868 else if (BoundaryType == 3) // Cas d un cone defini par un axe et un angle
3870 myDriver->TexteBoundaryAn(BoundaryName, NumBoundaryAnalytical, BoundaryType, (*coor)[0], (*coor)[1], (*coor)[2], (*coor)[3], (*coor)[4], (*coor)[5], (*coor)[6], 0.);
3871 if ( BoundaryOption % 3 != 0 ) { BoundaryOption = BoundaryOption*3; }
3873 else if (BoundaryType == 4) // Cas d un cone defini par les 2 rayons
3875 myDriver->TexteBoundaryAn(BoundaryName, NumBoundaryAnalytical, BoundaryType, (*coor)[0], (*coor)[1], (*coor)[2], (*coor)[3], (*coor)[4], (*coor)[5], (*coor)[6], (*coor)[7]);
3876 if ( BoundaryOption % 3 != 0 ) { BoundaryOption = BoundaryOption*3; }
3878 else if (BoundaryType == 5) // Cas d un tore
3880 myDriver->TexteBoundaryAn(BoundaryName, NumBoundaryAnalytical, BoundaryType, (*coor)[0], (*coor)[1], (*coor)[2], (*coor)[3], (*coor)[4], (*coor)[5], (*coor)[6], (*coor)[7]);
3881 if ( BoundaryOption % 3 != 0 ) { BoundaryOption = BoundaryOption*3; }
3884 // 2.2.3. Memorisation du traitement
3885 ListeBoundaryTraitees.push_back( BoundaryName );
3888 // 3. Parcours des frontieres pour ecrire les liens avec les groupes
3889 NumBoundaryAnalytical = 0;
3890 for (int NumBoundary = 0; NumBoundary< numberOfitems; NumBoundary=NumBoundary+2)
3892 std::string BoundaryName = std::string((*ListBoundaryGroupType)[NumBoundary]);
3893 MESSAGE ( "... BoundaryName = " << BoundaryName);
3894 SMESHHOMARD::HOMARD_Boundary_var myBoundary = myStudyContext._mesBoundarys[BoundaryName];
3895 ASSERT(!CORBA::is_nil(myBoundary));
3896 int BoundaryType = myBoundary->GetType();
3897 MESSAGE ( "... BoundaryType = " << BoundaryType );
3898 // 3.1. Recuperation du nom du groupe
3899 std::string GroupName = std::string((*ListBoundaryGroupType)[NumBoundary+1]);
3900 MESSAGE ( "... GroupName = " << GroupName);
3901 // 3.2. Cas d une frontiere CAO
3902 if ( BoundaryType == -1 )
3904 if ( GroupName.size() > 0 ) { myDriver->TexteBoundaryCAOGr ( GroupName ); }
3906 // 3.3. Cas d une frontiere discrete
3907 else if ( BoundaryType == 0 )
3909 if ( GroupName.size() > 0 ) { myDriver->TexteBoundaryDiGr ( GroupName ); }
3911 // 3.4. Cas d une frontiere analytique
3914 NumBoundaryAnalytical++;
3915 myDriver->TexteBoundaryAnGr ( BoundaryName, NumBoundaryAnalytical, GroupName );
3918 // 4. Ecriture de l'option finale
3919 myDriver->TexteBoundaryOption(BoundaryOption);
3921 return BoundaryOption;
3923 //=============================================================================
3924 // Calcul d'une iteration : ecriture des interpolations dans le fichier de configuration
3925 //=============================================================================
3926 void HOMARD_Gen_i::DriverTexteFieldInterp(SMESHHOMARD::HOMARD_Iteration_var myIteration, SMESHHOMARD::HOMARD_Hypothesis_var myHypo, SMESHHOMARDImpl::HomardDriver* myDriver)
3928 MESSAGE ( "... DriverTexteFieldInterp" );
3929 int TypeFieldInterp = myHypo->GetTypeFieldInterp();
3930 MESSAGE ( "... TypeFieldInterp = " << TypeFieldInterp);
3931 if (TypeFieldInterp != 0)
3933 // Le fichier des champs
3934 char* FieldFile = myIteration->GetFieldFile();
3935 MESSAGE ( ". FieldFile = " << FieldFile );
3936 if (strlen(FieldFile) == 0)
3938 // GERALD -- QMESSAGE BOX
3939 VERIFICATION("The file for the field is not given." == 0);
3942 const char* MeshFile = myIteration->GetMeshFile();
3943 myDriver->TexteFieldInterp(FieldFile, MeshFile);
3946 // Interpolation de tous les champs
3947 if ( TypeFieldInterp == 1 )
3949 myDriver->TexteFieldInterpAll();
3951 // Interpolation de certains champs
3952 else if (TypeFieldInterp == 2)
3954 // Les champs et leurs instants pour l'iteration
3955 SMESHHOMARD::listeFieldInterpTSRsIter* ListFieldTSR = myIteration->GetFieldInterpsTimeStepRank();
3956 int numberOfFieldsx3 = ListFieldTSR->length();
3957 MESSAGE( ". pour iteration, numberOfFields = " << numberOfFieldsx3/3 );
3958 // Les champs pour l'hypothese
3959 SMESHHOMARD::listeFieldInterpsHypo* ListField = myHypo->GetFieldInterps();
3960 int numberOfFieldsx2 = ListField->length();
3961 MESSAGE( ". pour hypothese, numberOfFields = " << numberOfFieldsx2/2 );
3962 // On parcourt tous les champs de l'hypothese
3964 for (int iaux = 0; iaux< numberOfFieldsx2; iaux++)
3967 std::string FieldName = std::string((*ListField)[iaux]);
3968 // Le type d'interpolation
3969 std::string TypeInterpstr = std::string((*ListField)[iaux+1]);
3970 MESSAGE( "... FieldName = " << FieldName << ", TypeInterp = " << TypeInterpstr );
3971 // On cherche ?? savoir si des instants ont ??t?? pr??cis??s pour cette it??ration
3973 for (int jaux = 0; jaux< numberOfFieldsx3; jaux++)
3976 std::string FieldName2 = std::string((*ListFieldTSR)[jaux]);
3977 MESSAGE( "..... FieldName2 = " << FieldName2 );
3978 // Quand c'est le bon champ, on ecrit le pas de temps
3979 if ( FieldName == FieldName2 )
3983 std::string TimeStepstr = std::string((*ListFieldTSR)[jaux+1]);
3984 // Le numero d'ordre
3985 std::string Rankstr = std::string((*ListFieldTSR)[jaux+2]);
3986 MESSAGE( "..... TimeStepstr = " << TimeStepstr <<", Rankstr = "<<Rankstr );
3988 int TimeStep = atoi( TimeStepstr.c_str() );
3989 int Rank = atoi( Rankstr.c_str() );
3990 myDriver->TexteFieldInterpNameType(NumField, FieldName, TypeInterpstr, TimeStep, Rank);
3994 // Si aucun instant n'a été défini
3998 myDriver->TexteFieldInterpNameType(NumField, FieldName, TypeInterpstr, -1, -1);
4005 //===========================================================================
4006 //===========================================================================
4009 //===========================================================================
4010 //===========================================================================
4012 //===========================================================================
4013 //=====================================================================================
4014 void HOMARD_Gen_i::PublishResultInSmesh(const char* NomFich, CORBA::Long Option)
4015 // Option = 0 : fichier issu d'une importation
4016 // Option = 1 : fichier issu d'une execution HOMARD
4018 MESSAGE( "PublishResultInSmesh " << NomFich << ", avec Option = " << Option);
4019 if (CORBA::is_nil(SMESH_Gen_i::GetSMESHGen()->getStudyServant())) {
4020 SALOME::ExceptionStruct es;
4021 es.type = SALOME::BAD_PARAM;
4022 es.text = "Invalid study context";
4023 throw SALOME::SALOME_Exception(es);
4026 // Le module SMESH est-il actif ?
4027 SALOMEDS::SObject_var aSmeshSO =
4028 SMESH_Gen_i::GetSMESHGen()->getStudyServant()->FindComponent("SMESH");
4030 if (!CORBA::is_nil(aSmeshSO)) {
4031 // On verifie que le fichier n est pas deja publie
4032 SALOMEDS::ChildIterator_var aIter =
4033 SMESH_Gen_i::GetSMESHGen()->getStudyServant()->NewChildIterator(aSmeshSO);
4034 for (; aIter->More(); aIter->Next()) {
4035 SALOMEDS::SObject_var aSO = aIter->Value();
4036 SALOMEDS::GenericAttribute_var aGAttr;
4037 if (aSO->FindAttribute(aGAttr, "AttributeExternalFileDef")) {
4038 SALOMEDS::AttributeExternalFileDef_var anAttr =
4039 SALOMEDS::AttributeExternalFileDef::_narrow(aGAttr);
4040 CORBA::String_var value = anAttr->Value();
4041 if (strcmp((const char*)value, NomFich) == 0) {
4042 MESSAGE ( "PublishResultInSmesh : le fichier " << NomFich << " est deja publie." );
4043 // Pour un fichier importe, on ne republie pas
4044 if ( Option == 0 ) { return; }
4045 // Pour un fichier calcule, on commence par faire la depublication
4047 MESSAGE("PublishResultInSmesh : depublication");
4048 if (aSO->FindAttribute(aGAttr, "AttributeName")) {
4049 SALOMEDS::AttributeName_var anAttr2 = SALOMEDS::AttributeName::_narrow(aGAttr);
4050 CORBA::String_var value2 = anAttr2->Value();
4051 std::string MeshName = string(value2);
4052 MESSAGE("PublishResultInSmesh : depublication de " << MeshName);
4053 DeleteResultInSmesh(NomFich, MeshName);
4061 // On enregistre le fichier
4062 MESSAGE( "Enregistrement du fichier");
4064 //SMESH::SMESH_Gen_var aSmeshEngine = this->retrieveSMESHInst();
4065 SMESH_Gen_i* aSmeshEngine = SMESH_Gen_i::GetSMESHGen();
4067 //ASSERT(!CORBA::is_nil(aSmeshEngine));
4068 aSmeshEngine->UpdateStudy();
4069 SMESH::DriverMED_ReadStatus theStatus;
4071 // On met a jour les attributs AttributeExternalFileDef et AttributePixMap
4072 SMESH::mesh_array* mesMaillages = aSmeshEngine->CreateMeshesFromMED(NomFich, theStatus);
4073 for (int i = 0; i < mesMaillages->length(); i++) {
4074 MESSAGE(". Mise a jour des attributs du maillage");
4075 SMESH::SMESH_Mesh_var monMaillage = (*mesMaillages)[i];
4076 SALOMEDS::SObject_var aSO = SALOMEDS::SObject::_narrow
4077 (SMESH_Gen_i::GetSMESHGen()->getStudyServant()->FindObjectIOR
4078 (SMESH_Gen_i::GetORB()->object_to_string(monMaillage)));
4079 SALOMEDS::StudyBuilder_var aStudyBuilder =
4080 SMESH_Gen_i::GetSMESHGen()->getStudyServant()->NewBuilder();
4081 SALOMEDS::GenericAttribute_var aGAttr =
4082 aStudyBuilder->FindOrCreateAttribute(aSO, "AttributeExternalFileDef");
4083 SALOMEDS::AttributeExternalFileDef_var anAttr =
4084 SALOMEDS::AttributeExternalFileDef::_narrow(aGAttr);
4085 anAttr->SetValue(NomFich);
4086 SALOMEDS::GenericAttribute_var aPixMap =
4087 aStudyBuilder->FindOrCreateAttribute(aSO, "AttributePixMap" );
4088 SALOMEDS::AttributePixMap_var anAttr2 = SALOMEDS::AttributePixMap::_narrow(aPixMap);
4090 if ( Option == 0 ) { icone = "mesh_tree_importedmesh.png"; }
4091 else { icone = "mesh_tree_mesh.png"; }
4092 anAttr2->SetPixMap( icone );
4095 //=============================================================================
4096 void HOMARD_Gen_i::DeleteResultInSmesh(std::string NomFich, std::string MeshName)
4098 MESSAGE ("DeleteResultInSmesh pour le maillage " << MeshName << " dans le fichier " << NomFich );
4099 if (CORBA::is_nil(SMESH_Gen_i::GetSMESHGen()->getStudyServant())) {
4100 SALOME::ExceptionStruct es;
4101 es.type = SALOME::BAD_PARAM;
4102 es.text = "Invalid study context";
4103 throw SALOME::SALOME_Exception(es);
4106 // Le module SMESH est-il actif ?
4107 SALOMEDS::SObject_var aSmeshSO =
4108 SMESH_Gen_i::GetSMESHGen()->getStudyServant()->FindComponent("SMESH");
4110 if (CORBA::is_nil(aSmeshSO)) return;
4111 // On verifie que le fichier est deja publie
4112 SALOMEDS::StudyBuilder_var myBuilder =
4113 SMESH_Gen_i::GetSMESHGen()->getStudyServant()->NewBuilder();
4114 SALOMEDS::ChildIterator_var aIter =
4115 SMESH_Gen_i::GetSMESHGen()->getStudyServant()->NewChildIterator(aSmeshSO);
4116 for (; aIter->More(); aIter->Next()) {
4117 SALOMEDS::SObject_var aSO = aIter->Value();
4118 SALOMEDS::GenericAttribute_var aGAttr;
4119 if (aSO->FindAttribute(aGAttr, "AttributeExternalFileDef")) {
4120 SALOMEDS::AttributeExternalFileDef_var anAttr =
4121 SALOMEDS::AttributeExternalFileDef::_narrow(aGAttr);
4122 CORBA::String_var value = anAttr->Value();
4123 if (strcmp((const char*)value, NomFich.c_str()) == 0) {
4124 if (aSO->FindAttribute(aGAttr, "AttributeName")) {
4125 SALOMEDS::AttributeName_var anAttr2 = SALOMEDS::AttributeName::_narrow(aGAttr);
4126 CORBA::String_var value2 = anAttr2->Value();
4127 if (strcmp((const char*)value2, MeshName.c_str()) == 0) {
4128 myBuilder->RemoveObjectWithChildren( aSO );
4135 //=============================================================================
4136 void HOMARD_Gen_i::PublishMeshIterInSmesh(const char* NomIter)
4138 MESSAGE( "PublishMeshIterInSmesh " << NomIter);
4139 SMESHHOMARD::HOMARD_Iteration_var myIteration = myStudyContext._mesIterations[NomIter];
4141 SALOMEDS::SObject_var aIterSO = SALOMEDS::SObject::_narrow
4142 (SMESH_Gen_i::GetSMESHGen()->getStudyServant()->FindObjectIOR
4143 (SMESH_Gen_i::GetORB()->object_to_string(myIteration)));
4144 if (CORBA::is_nil(myIteration)) {
4145 SALOME::ExceptionStruct es;
4146 es.type = SALOME::BAD_PARAM;
4147 es.text = "Invalid iterationStudy Object";
4148 throw SALOME::SALOME_Exception(es);
4150 const char* MeshFile = myIteration->GetMeshFile();
4151 const char* MeshName = myIteration->GetMeshName();
4152 CORBA::Long Option = -1;
4153 int etat = myIteration->GetState();
4154 // Iteration initiale
4155 if ( etat <= 0 ) { Option = 0; }
4156 // ou iteration calculee
4157 else if ( etat == 2 ) { Option = 1; }
4158 // Publication effective apres menage eventuel
4161 DeleteResultInSmesh(MeshFile, MeshName);
4162 PublishResultInSmesh(MeshFile, Option);
4168 Engines::TMPFile* HOMARD_Gen_i::DumpPython(CORBA::Boolean isPublished,
4169 CORBA::Boolean isMultiFile,
4170 CORBA::Boolean& isValidScript)
4172 MESSAGE ("Entree dans DumpPython");
4174 std::string aScript = "\"\"\"\n";
4176 SALOMEDS::SObject_var aSO = myStudy->FindComponent("HOMARD");
4177 if(CORBA::is_nil(aSO))
4178 return new Engines::TMPFile(0);
4180 aScript += "Python script for HOMARD\n";
4181 aScript += "Copyright 1996, 2011, 2015 EDF\n";
4182 aScript += "\"\"\"\n";
4183 aScript += "__revision__ = \"V1.2\"\n";
4184 aScript += "import HOMARD\n";
4186 aScript += "import salome\n";
4187 aScript += "homard = salome.lcc.FindOrLoadComponent('FactoryServer','HOMARD')\n";
4188 aScript += "\thomard.UpdateStudy()\n";
4189 MESSAGE (". Au depart \n"<<aScript);
4192 if (myStudyContext._mesBoundarys.size() > 0)
4194 MESSAGE (". Ecritures des frontieres");
4195 aScript += "#\n# Creation of the boundaries";
4196 aScript += "\n# ==========================";
4198 std::map<std::string, SMESHHOMARD::HOMARD_Boundary_var>::const_iterator it_boundary;
4199 for (it_boundary = myStudyContext._mesBoundarys.begin();
4200 it_boundary != myStudyContext._mesBoundarys.end(); ++it_boundary)
4202 SMESHHOMARD::HOMARD_Boundary_var maBoundary = (*it_boundary).second;
4203 CORBA::String_var dumpCorbaBoundary = maBoundary->GetDumpPython();
4204 std::string dumpBoundary = dumpCorbaBoundary.in();
4205 MESSAGE (dumpBoundary<<"\n");
4206 aScript += dumpBoundary;
4209 if (myStudyContext._mesHypotheses.size() > 0)
4211 MESSAGE (". Ecritures des hypotheses");
4212 aScript += "#\n# Creation of the hypotheses";
4213 aScript += "\n# ==========================";
4215 std::map<std::string, SMESHHOMARD::HOMARD_Hypothesis_var>::const_iterator it_hypo;
4216 for ( it_hypo = myStudyContext._mesHypotheses.begin();
4217 it_hypo != myStudyContext._mesHypotheses.end(); it_hypo++)
4219 SMESHHOMARD::HOMARD_Hypothesis_var monHypo = (*it_hypo).second;
4220 CORBA::String_var dumpCorbaHypo = monHypo->GetDumpPython();
4221 std::string dumpHypo = dumpCorbaHypo.in();
4222 MESSAGE (dumpHypo<<"\n");
4223 aScript += dumpHypo;
4226 if (myStudyContext._mesCas.size() > 0)
4228 MESSAGE (". Ecritures des cas");
4229 aScript += "#\n# Creation of the cases";
4230 aScript += "\n# =====================";
4232 std::map<std::string, SMESHHOMARD::HOMARD_Cas_var>::const_iterator it_cas;
4233 for (it_cas = myStudyContext._mesCas.begin();
4234 it_cas != myStudyContext._mesCas.end(); it_cas++)
4236 std::string nomCas = (*it_cas).first;
4237 std::string dumpCas = std::string("\n# Creation of the case ");
4238 dumpCas += nomCas + std::string("\n");
4239 dumpCas += std::string("\t") + nomCas;
4240 dumpCas += std::string(" = homard.CreateCase(\"") + nomCas + std::string("\", \"");
4242 SMESHHOMARD::HOMARD_Cas_var myCase = (*it_cas).second;
4243 CORBA::String_var cIter0= myCase->GetIter0Name();
4244 std::string iter0 = cIter0.in();
4246 SMESHHOMARD::HOMARD_Iteration_var myIteration = myStudyContext._mesIterations[iter0];
4247 CORBA::String_var cMesh0= myIteration->GetMeshFile();
4248 std::string mesh0 = cMesh0.in();
4249 CORBA::String_var cMeshName0= myIteration->GetMeshName();
4250 std::string meshName0 = cMeshName0.in();
4251 dumpCas += meshName0 + std::string("\", \"")+ mesh0 + std::string("\")\n");
4252 CORBA::String_var dumpCorbaCase = myCase->GetDumpPython();
4253 std::string dumpCas2= dumpCorbaCase.in();
4255 MESSAGE (dumpCas<<dumpCas2<<"\n");
4256 aScript += dumpCas + dumpCas2;
4260 if (myStudyContext._mesIterations.size() > 0)
4262 MESSAGE (". Ecritures des iterations");
4263 aScript += "#\n# Creation of the iterations";
4264 aScript += "\n# ==========================";
4266 std::map<std::string, SMESHHOMARD::HOMARD_Iteration_var>::const_iterator it_iter;
4267 for (it_iter = myStudyContext._mesIterations.begin();
4268 it_iter != myStudyContext._mesIterations.end(); ++it_iter)
4270 SMESHHOMARD::HOMARD_Iteration_var aIter = (*it_iter).second;
4271 CORBA::String_var dumpCorbaIter = aIter->GetDumpPython();
4272 std::string dumpIter = dumpCorbaIter.in();
4273 MESSAGE (dumpIter<<"\n");
4274 aScript += dumpIter;
4277 MESSAGE (". Ecritures finales");
4279 aScript += "\n\tpass";
4282 if( !isMultiFile ) // remove unnecessary tabulation
4283 aScript = RemoveTabulation( aScript );
4285 const size_t aLen = strlen(aScript.c_str());
4286 char* aBuffer = new char[aLen+1];
4287 strcpy(aBuffer, aScript.c_str());
4289 CORBA::Octet* anOctetBuf = (CORBA::Octet*)aBuffer;
4290 Engines::TMPFile_var aStreamFile = new Engines::TMPFile(aLen+1, aLen+1, anOctetBuf, 1);
4292 MESSAGE ("Sortie de DumpPython");
4293 return aStreamFile._retn();
4297 //=============================================================================
4298 //=============================================================================
4300 //=============================================================================
4301 //=============================================================================
4302 char* HOMARD_Gen_i::VerifieDir(const char* nomDir)
4304 MESSAGE("HOMARD_Gen_i::VerifieDir");
4305 std::string casename = std::string("");
4306 std::map<std::string, SMESHHOMARD::HOMARD_Cas_var>::const_iterator it;
4307 for (it = myStudyContext._mesCas.begin();
4308 it != myStudyContext._mesCas.end(); it++)
4310 if (std::string(nomDir) == std::string(it->second->GetDirName()))
4312 casename = std::string(it->second->GetName());
4316 return CORBA::string_dup( casename.c_str() );
4318 //===============================================================================
4319 // Recuperation de la chaine de caracteres par rapport a l'apparition d'un caractere
4320 // ligne : la ligne a manipuler
4321 // caractere : le caractere a reperer
4322 // option : 0 : la chaine avant la premiere apparition du caractere
4323 // 1 : la chaine apres la premiere apparition du caractere
4324 // 2 : la chaine avant la derniere apparition du caractere
4325 // 3 : la chaine apres la derniere apparition du caractere
4326 // Si le caractere est absent, on retourne la chaine totale
4327 //===============================================================================
4328 std::string HOMARD_Gen_i::GetStringInTexte( const std::string ligne, const std::string caractere, int option )
4330 // MESSAGE("GetStringInTexte, recherche de '"<<caractere<<"' dans '"<<ligne<<"'"<<", option = "<<option);
4332 std::string chaine = ligne;
4334 if ( option < 2 ) { position = ligne.find_first_of( caractere ); }
4335 else { position = ligne.find_last_of( caractere ); }
4336 // MESSAGE("position = "<<position);
4337 // MESSAGE("a = "<<ligne.substr( 0, position ).c_str());
4338 // MESSAGE("b = "<<ligne.substr( position+1 ).c_str());
4340 if ( position != std::string::npos )
4342 if ( ( option == 0 ) || ( option == 2 ) ) { chaine = ligne.substr( 0, position ); }
4343 else { chaine = ligne.substr( position+1 ); }
4348 //=============================================================================
4349 //=============================================================================
4350 // Gestion des preferences
4351 //=============================================================================
4352 //=============================================================================
4353 // Decodage du fichier d'arcihvage des preferences
4355 void HOMARD_Gen_i::SetPreferences( )
4357 MESSAGE ( "SetPreferences" );
4359 std::string ligne, mot_cle, salome_version;
4362 // A. Les valeurs par defaut; elles doivent etre coherentes
4363 std::string LanguageShort = "en";
4364 int PublisMeshIN = 0;
4365 int PublisMeshOUT = 0;
4367 // B. La version de salome
4368 // Cela se presente sous la forme :
4369 // [SALOME KERNEL] : 7.3.0
4371 File = getenv("KERNEL_ROOT_DIR");
4372 File += "/bin/salome/VERSION";
4373 MESSAGE ( "File = "<<File );
4374 std::ifstream fichier0( File.c_str() );
4375 if ( fichier0 ) // ce test échoue si le fichier n'est pas ouvert
4377 std::string ligne; // variable contenant chaque ligne lue
4378 while ( std::getline( fichier0, ligne ) )
4380 std::istringstream ligne_bis(ligne); // variable contenant chaque ligne sous forme de flux
4381 ligne_bis >> mot_cle;
4382 if ( mot_cle == "[SALOME" )
4384 salome_version = GetStringInTexte ( ligne, " ", 3 );
4385 // MESSAGE ( "salome_version = "<<salome_version<<"|||");
4390 else { ok = false; }
4392 // B. Decodage du fichier de preferences
4395 std::string PrefFile;
4396 PrefFile = Kernel_Utils::HomePath();
4397 PrefFile += "/.config/salome/SalomeApprc." + salome_version;
4398 MESSAGE ( "PrefFile = "<<PrefFile );
4400 std::ifstream fichier( PrefFile.c_str() );
4401 if ( fichier ) // ce test échoue si le fichier n'est pas ouvert
4403 bool section_langue = false;
4404 bool section_homard = false;
4405 while ( std::getline( fichier, ligne ) )
4408 // 1. Pour la ligne courante, on identifie le premier mot : le mot-cle eventuel
4409 std::istringstream ligne_bis(ligne); // variable contenant chaque ligne sous forme de flux
4410 ligne_bis >> mot_cle;
4413 // 2.1. Debut d'une section
4414 // MESSAGE(mot_cle);
4415 if ( mot_cle == "<section" )
4416 { /*MESSAGE ( "Debut de la section : "<< ligne);*/
4417 ligne_bis >> mot_cle;
4418 chaine = GetStringInTexte ( mot_cle, "\"", 1 );
4419 chaine = GetStringInTexte ( chaine, "\"", 0 );
4420 if ( chaine == "language" ) { section_langue = true; }
4421 if ( chaine == "HOMARD" ) { section_homard = true; }
4422 // MESSAGE ( "section_langue = "<<section_langue<<", section_homard = "<<section_homard);
4424 // 2.2. Fin d'une section
4425 else if ( mot_cle == "</section>" )
4426 { /*MESSAGE ( "Fin de la section : "<< ligne<<", section_langue = "<<section_langue<<", section_homard = "<<section_homard);*/
4427 section_langue = false;
4428 section_homard = false; }
4432 else if ( section_langue || section_homard )
4433 { MESSAGE ( "a decoder : "<< ligne);
4434 // La valeur : entre les deux premieres quotes
4435 chaine = GetStringInTexte ( ligne, "\"", 1 );
4436 // MESSAGE("chaine 1 = |"<<chaine<<"|");
4437 chaine = GetStringInTexte ( chaine, "\"", 0 );
4438 // MESSAGE("chaine = |"<<chaine<<"|");
4439 // Le mot_cle : entre les deux dernieres quotes
4440 std::string chaine2 = GetStringInTexte ( ligne, "\"", 2 );
4441 // MESSAGE("chaine2 1 = |"<<chaine2<<"|");
4442 chaine2 = GetStringInTexte ( chaine2, "\"", 3 );
4443 // MESSAGE("chaine2 = |"<<chaine2<<"|");
4445 if ( section_langue )
4446 { if ( chaine2 == "language" ) { LanguageShort = chaine; } }
4448 if ( section_homard )
4450 std::istringstream chainebis( chaine );
4451 // 3.2.1. Les publications
4452 if ( chaine2 == "publish_mesh_in" ) { chainebis >> PublisMeshIN; }
4453 if ( chaine2 == "publish_mesh_out" ) { chainebis >> PublisMeshOUT; }
4460 // C. Enregistrements
4461 MESSAGE ("Enregistrement de LanguageShort = " << LanguageShort );
4462 SetLanguageShort( LanguageShort.c_str() );
4464 MESSAGE ("Enregistrement de PublisMeshIN = " << PublisMeshIN<<", PublisMeshOUT = "<< PublisMeshOUT);
4465 SetPublisMesh(PublisMeshIN, PublisMeshOUT);
4467 //===============================================================================
4469 //===============================================================================
4470 void HOMARD_Gen_i::SetLanguageShort(const char* LanguageShort)
4472 //MESSAGE ("SetLanguageShort pour LanguageShort = " << LanguageShort );
4473 _LangueShort = LanguageShort;
4474 if ( _LangueShort == "fr" ) { _Langue = "Francais"; }
4475 else { _Langue = "English"; }
4477 char* HOMARD_Gen_i::GetLanguageShort()
4479 //MESSAGE ("GetLanguageShort");
4480 return CORBA::string_dup( _LangueShort.c_str() );
4482 //===============================================================================
4483 // Options de publications
4484 //===============================================================================
4485 void HOMARD_Gen_i::SetPublisMesh(CORBA::Long PublisMeshIN, CORBA::Long PublisMeshOUT)
4487 _PublisMeshIN = PublisMeshIN;
4488 _PublisMeshOUT = PublisMeshOUT;
4490 CORBA::Long HOMARD_Gen_i::GetPublisMeshIN()
4492 return _PublisMeshIN;
4494 CORBA::Long HOMARD_Gen_i::GetPublisMeshOUT()
4496 return _PublisMeshOUT;
4499 // =======================================================================
4500 int MEDFileExist( const char * aFile )
4501 // Retourne 1 si le fichier existe, 0 sinon
4502 // =======================================================================
4505 med_idt medIdt = MEDfileOpen(aFile,MED_ACC_RDONLY);
4506 if ( medIdt < 0 ) { existe = 0; }
4507 else { MEDfileClose(medIdt);
4511 // =======================================================================
4512 std::set<std::string> GetListeGroupesInMedFile(const char * aFile)
4513 // =======================================================================
4515 std::set<std::string> ListeGroupes;
4518 while ( erreur == 0 )
4520 // Ouverture du fichier
4521 medIdt = MEDfileOpen(aFile,MED_ACC_RDONLY);
4527 // Caracteristiques du maillage
4528 char meshname[MED_NAME_SIZE+1];
4529 med_int spacedim,meshdim;
4530 med_mesh_type meshtype;
4531 char descriptionription[MED_COMMENT_SIZE+1];
4532 char dtunit[MED_SNAME_SIZE+1];
4533 med_sorting_type sortingtype;
4535 med_axis_type axistype;
4536 int naxis = MEDmeshnAxis(medIdt,1);
4537 char *axisname=new char[naxis*MED_SNAME_SIZE+1];
4538 char *axisunit=new char[naxis*MED_SNAME_SIZE+1];
4539 erreur = MEDmeshInfo(medIdt,
4554 if ( erreur < 0 ) { break; }
4555 // Nombre de familles
4557 nfam = MEDnFamily(medIdt,meshname);
4563 // Lecture des caracteristiques des familles
4564 for (int i=0;i<nfam;i++)
4566 // Lecture du nombre de groupes
4567 med_int ngro = MEDnFamilyGroup(medIdt,meshname,i+1);
4573 // Lecture de la famille
4574 else if ( ngro > 0 )
4576 char familyname[MED_NAME_SIZE+1];
4578 char* gro = (char*) malloc(MED_LNAME_SIZE*ngro+1);
4579 erreur = MEDfamilyInfo(medIdt,
4590 // Lecture des groupes pour une famille de mailles
4593 for (int j=0;j<ngro;j++)
4595 char str2[MED_LNAME_SIZE+1];
4596 strncpy(str2,gro+j*MED_LNAME_SIZE,MED_LNAME_SIZE);
4597 str2[MED_LNAME_SIZE] = '\0';
4598 ListeGroupes.insert(std::string(str2));
4606 // Fermeture du fichier
4607 if ( medIdt > 0 ) MEDfileClose(medIdt);
4609 return ListeGroupes;
4612 // =======================================================================
4613 std::vector<double> GetBoundingBoxInMedFile(const char * aFile)
4614 // =======================================================================
4616 // Le vecteur en retour contiendra les informations suivantes :
4617 // en position 0 et 1 Xmin, Xmax et en position 2 Dx si < 0 2D
4618 // en position 3 et 4 Ymin, Ymax et en position 5 Dy si < 0 2D
4619 // en position 6 et 7 Zmin, Zmax et en position 8 Dz si < 0 2D
4620 // 9 distance max dans le maillage
4622 std::vector<double> LesExtremes;
4625 while ( erreur == 0 )
4627 // Ouverture du fichier
4628 medIdt = MEDfileOpen(aFile,MED_ACC_RDONLY);
4634 //Nombre de maillage : on ne peut en lire qu'un seul
4635 med_int numberOfMeshes = MEDnMesh(medIdt);
4636 if (numberOfMeshes != 1 )
4641 // Caracteristiques du maillage
4642 char meshname[MED_NAME_SIZE+1];
4643 med_int spacedim,meshdim;
4644 med_mesh_type meshtype;
4645 char descriptionription[MED_COMMENT_SIZE+1];
4646 char dtunit[MED_SNAME_SIZE+1];
4647 med_sorting_type sortingtype;
4649 med_axis_type axistype;
4650 int naxis = MEDmeshnAxis(medIdt,1);
4651 char *axisname=new char[naxis*MED_SNAME_SIZE+1];
4652 char *axisunit=new char[naxis*MED_SNAME_SIZE+1];
4653 erreur = MEDmeshInfo(medIdt,
4668 if ( erreur < 0 ) { break; }
4672 med_int nnoe = MEDmeshnEntity(medIdt,
4689 med_float* coo = (med_float*) malloc(sizeof(med_float)*nnoe*spacedim);
4691 erreur = MEDmeshNodeCoordinateRd(medIdt,
4703 // Calcul des extremes
4704 med_float xmin,xmax,ymin,ymax,zmin,zmax;
4708 for (int i=1;i<nnoe;i++)
4710 xmin = std::min(xmin,coo[i]);
4711 xmax = std::max(xmax,coo[i]);
4716 ymin=coo[nnoe]; ymax=coo[nnoe];
4717 for (int i=nnoe+1;i<2*nnoe;i++)
4719 ymin = std::min(ymin,coo[i]);
4720 ymax = std::max(ymax,coo[i]);
4733 zmin=coo[2*nnoe]; zmax=coo[2*nnoe];
4734 for (int i=2*nnoe+1;i<3*nnoe;i++)
4736 zmin = std::min(zmin,coo[i]);
4737 zmax = std::max(zmax,coo[i]);
4746 MESSAGE( "_______________________________________");
4747 MESSAGE( "xmin : " << xmin << " xmax : " << xmax );
4748 MESSAGE( "ymin : " << ymin << " ymax : " << ymax );
4749 MESSAGE( "zmin : " << zmin << " zmax : " << zmax );
4750 MESSAGE( "_______________________________________" );
4751 double epsilon = 1.e-6;
4752 LesExtremes.push_back(xmin);
4753 LesExtremes.push_back(xmax);
4754 LesExtremes.push_back(0);
4755 LesExtremes.push_back(ymin);
4756 LesExtremes.push_back(ymax);
4757 LesExtremes.push_back(0);
4758 LesExtremes.push_back(zmin);
4759 LesExtremes.push_back(zmax);
4760 LesExtremes.push_back(0);
4763 double max1=std::max ( LesExtremes[1] - LesExtremes[0] , LesExtremes[4] - LesExtremes[3] );
4764 double max2=std::max ( max1 , LesExtremes[7] - LesExtremes[6] );
4765 LesExtremes.push_back(max2);
4767 // LesExtremes[0] = Xmini du maillage
4768 // LesExtremes[1] = Xmaxi du maillage
4769 // LesExtremes[2] = increment de progression en X
4770 // LesExtremes[3,4,5] : idem pour Y
4771 // LesExtremes[6,7,8] : idem pour Z
4772 // LesExtremes[9] = ecart maximal entre coordonnees
4773 // On fait un traitement pour dans le cas d'une coordonnee constante
4774 // inhiber ce cas en mettant un increment negatif
4776 double diff = LesExtremes[1] - LesExtremes[0];
4777 if ( fabs(diff) > epsilon*max2 ) { LesExtremes[2] = diff/100.; }
4778 else { LesExtremes[2] = -1.; }
4780 diff = LesExtremes[4] - LesExtremes[3];
4781 if ( fabs(diff) > epsilon*max2 ) { LesExtremes[5]=diff/100.; }
4782 else { LesExtremes[5] = -1.; }
4784 diff = LesExtremes[7] - LesExtremes[6];
4785 if ( fabs(diff) > epsilon*max2 ) { LesExtremes[8]=diff/100.; }
4786 else { LesExtremes[8] = -1.; }
4788 MESSAGE ( "_______________________________________" );
4789 MESSAGE ( "xmin : " << LesExtremes[0] << " xmax : " << LesExtremes[1] << " xincr : " << LesExtremes[2] );
4790 MESSAGE ( "ymin : " << LesExtremes[3] << " ymax : " << LesExtremes[4] << " yincr : " << LesExtremes[5] );
4791 MESSAGE ( "zmin : " << LesExtremes[6] << " zmax : " << LesExtremes[7] << " zincr : " << LesExtremes[8] );
4792 MESSAGE ( "dmax : " << LesExtremes[9] );
4793 MESSAGE ( "_______________________________________" );
4798 // Fermeture du fichier
4799 if ( medIdt > 0 ) MEDfileClose(medIdt);
4804 }; // namespace SMESHHOMARD_I