1 // HOMARD HOMARD : implementation of HOMARD idl descriptions
3 // Copyright (C) 2011-2013 CEA/DEN, EDF R&D
5 // This library is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU Lesser General Public
7 // License as published by the Free Software Foundation; either
8 // version 2.1 of the License.
10 // This library is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 // Lesser General Public License for more details.
15 // You should have received a copy of the GNU Lesser General Public
16 // License along with this library; if not, write to the Free Software
17 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 // File : HOMARD_Hypothesis.cxx
22 // Author : Paul RASCLE, EDF
26 // L'ordre de description des fonctions est le meme dans tous les fichiers
27 // HOMARD_aaaa.idl, HOMARD_aaaa.hxx, HOMARD_aaaa.cxx, HOMARD_aaaa_i.hxx, HOMARD_aaaa_i.cxx :
28 // 1. Les generalites : Name, Delete, DumpPython, Dump, Restore
29 // 2. Les caracteristiques
30 // 3. Le lien avec les autres structures
32 // Quand les 2 fonctions Setxxx et Getxxx sont presentes, Setxxx est decrit en premier
34 #include "HOMARD_Hypothesis.hxx"
36 #include "utilities.h"
38 //=============================================================================
40 * default constructor:
42 //=============================================================================
43 HOMARD_Hypothesis::HOMARD_Hypothesis():
44 _Name(""), _NomCasCreation(""),
45 _TypeAdap(-1), _TypeRaff(0), _TypeDera(0),
47 _TypeThR(0), _ThreshR(0),
48 _TypeThC(0), _ThreshC(0),
49 _UsField(0), _UsCmpI(0), _TypeFieldInterp(0)
51 MESSAGE("HOMARD_Hypothesis");
54 //=============================================================================
57 //=============================================================================
58 HOMARD_Hypothesis::~HOMARD_Hypothesis()
60 MESSAGE("~HOMARD_Hypothesis");
62 //=============================================================================
63 //=============================================================================
65 //=============================================================================
66 //=============================================================================
67 void HOMARD_Hypothesis::SetName( const char* Name )
69 _Name = std::string( Name );
71 //=============================================================================
72 std::string HOMARD_Hypothesis::GetName() const
76 //=============================================================================
77 std::string HOMARD_Hypothesis::GetDumpPython() const
79 std::ostringstream aScript;
80 aScript << "\n# Creation of the hypothesis " << _Name << "\n" ;
81 aScript << "\t" << _Name << " = homard.CreateHypothesis(\"" << _Name << "\")\n";
82 aScript << "\t" << _Name << ".SetAdapRefinUnRef(" << _TypeAdap << ", " << _TypeRaff << ", " << _TypeDera << ")\n";
84 // Raffinement selon des zones geometriques
85 std::list<std::string>::const_iterator it = _ListZone.begin();
87 while(it != _ListZone.end())
89 aScript << "\t" << _Name << ".AddZone(\"" << *it;
91 if ( *it == "1" ) { TypeUse = 1 ; }
92 else { TypeUse = -1 ; }
93 aScript << "\", " << TypeUse << ")\n";
97 // Raffinement selon un champ
100 aScript << "\t" << _Name << ".SetField(\"" << _Field << "\")\n";
101 aScript << "\t" << _Name << ".SetUseField(" << _UsField << ")\n";
102 aScript << "\t" << _Name << ".SetUseComp(" << _UsCmpI << ")\n";
103 std::list<std::string>::const_iterator it_comp = _ListComp.begin();
104 while(it_comp != _ListComp.end())
106 aScript << "\t" << _Name << ".AddComp(\"" << *it_comp << "\")\n";
109 if ( _TypeRaff == 1 )
111 aScript << "\t" << _Name << ".SetRefinThr(" << _TypeThR << ", " << _ThreshR << ")\n";
113 if ( _TypeDera == 1 )
115 aScript << "\t" << _Name << ".SetUnRefThr(" << _TypeThC << ", " << _ThreshC << ")\n";
119 // Filtrage du raffinement par des groupes
120 for ( it=_ListGroupSelected.begin(); it!=_ListGroupSelected.end();it++)
121 aScript << "\t" << _Name << ".AddGroup(\"" << (*it) << "\")\n" ;
123 // Interpolation des champs
124 if ( _TypeFieldInterp == 2 )
126 std::list<std::string>::const_iterator it_champ = _ListFieldInterp.begin();
127 while(it_champ != _ListFieldInterp.end())
129 aScript << "\t" << _Name << ".AddFieldInterpType( \"" << *it_champ << "\" " ;
131 aScript << ", " << *it_champ << ")\n";
135 else if ( _TypeFieldInterp != 0 )
137 aScript << "\t" << _Name << ".SetTypeFieldInterp(" << _TypeFieldInterp << ")\n";
141 aScript << "\t" <<_Name << ".SetNivMax(" << _NivMax << ")\n";
145 aScript << "\t" <<_Name << ".SetDiamMin(" << _DiamMin << ")\n";
147 if ( _AdapInit != 0 )
149 aScript << "\t" <<_Name << ".SetAdapInit(" << _AdapInit << ")\n";
151 if ( _LevelOutput != 0 )
153 aScript << "\t" <<_Name << ".SetLevelOutput(" << _LevelOutput << ")\n";
156 return aScript.str();
158 //=============================================================================
159 //=============================================================================
161 //=============================================================================
162 //=============================================================================
163 void HOMARD_Hypothesis::SetAdapType( int TypeAdap )
165 VERIFICATION( (TypeAdap>=-1) && (TypeAdap<=1) );
166 _TypeAdap = TypeAdap;
168 //=============================================================================
169 int HOMARD_Hypothesis::GetAdapType() const
173 //=============================================================================
174 void HOMARD_Hypothesis::SetRefinTypeDera( int TypeRaff, int TypeDera )
176 VERIFICATION( (TypeRaff>=-1) && (TypeRaff<=1) );
177 _TypeRaff = TypeRaff;
178 VERIFICATION( (TypeDera>=-1) && (TypeDera<=1) );
179 _TypeDera = TypeDera;
181 //=============================================================================
182 int HOMARD_Hypothesis::GetRefinType() const
186 //=============================================================================
187 int HOMARD_Hypothesis::GetUnRefType() const
191 //=============================================================================
192 void HOMARD_Hypothesis::SetField( const char* FieldName )
194 _Field = std::string( FieldName );
195 MESSAGE( "SetField : FieldName = " << FieldName );
197 //=============================================================================
198 std::string HOMARD_Hypothesis::GetFieldName() const
202 //=============================================================================
203 void HOMARD_Hypothesis::SetUseField( int UsField )
205 VERIFICATION( (UsField>=0) && (UsField<=1) );
208 //=============================================================================
209 int HOMARD_Hypothesis::GetUseField() const
213 //=============================================================================
214 void HOMARD_Hypothesis::SetUseComp( int UsCmpI )
216 VERIFICATION( (UsCmpI>=0) && (UsCmpI<=2) );
219 //=============================================================================
220 int HOMARD_Hypothesis::GetUseComp() const
224 //=============================================================================
225 void HOMARD_Hypothesis::AddComp( const char* NomComp )
227 // On commence par la supprimer au cas ou elle aurait deja ete inseree
228 // Cela peut se produire dans un schema YACS quand on repasse plusieurs fois par la
229 // definition de l'hypothese
230 SupprComp( NomComp ) ;
231 // Insertion veritable
232 _ListComp.push_back( std::string( NomComp ) );
234 //=============================================================================
235 void HOMARD_Hypothesis::SupprComp( const char* NomComp )
237 MESSAGE ("SupprComp pour "<<NomComp) ;
238 std::list<std::string>::iterator it = find( _ListComp.begin(), _ListComp.end(), NomComp );
239 if ( it != _ListComp.end() ) { it = _ListComp.erase( it ); }
241 //=============================================================================
242 void HOMARD_Hypothesis::SupprComps()
246 //=============================================================================
247 const std::list<std::string>& HOMARD_Hypothesis::GetComps() const
251 //=============================================================================
252 void HOMARD_Hypothesis::SetRefinThr( int TypeThR, double ThreshR )
254 MESSAGE( "SetRefinThr : TypeThR = " << TypeThR << ", ThreshR = " << ThreshR );
255 VERIFICATION( (TypeThR>=0) && (TypeThR<=4) );
259 //=============================================================================
260 int HOMARD_Hypothesis::GetRefinThrType() const
264 //=============================================================================
265 double HOMARD_Hypothesis::GetThreshR() const
269 //=============================================================================
270 void HOMARD_Hypothesis::SetUnRefThr( int TypeThC, double ThreshC )
272 VERIFICATION( (TypeThC>=0) && (TypeThC<=4) );
276 //=============================================================================
277 int HOMARD_Hypothesis::GetUnRefThrType() const
281 //=============================================================================
282 double HOMARD_Hypothesis::GetThreshC() const
286 //=============================================================================
287 void HOMARD_Hypothesis::SetNivMax( int NivMax )
288 //=============================================================================
292 //=============================================================================
293 const int HOMARD_Hypothesis::GetNivMax() const
294 //=============================================================================
298 //=============================================================================
299 void HOMARD_Hypothesis::SetDiamMin( double DiamMin )
300 //=============================================================================
304 //=============================================================================
305 const double HOMARD_Hypothesis::GetDiamMin() const
306 //=============================================================================
310 //=============================================================================
311 void HOMARD_Hypothesis::SetAdapInit( int AdapInit )
312 //=============================================================================
314 _AdapInit = AdapInit;
316 //=============================================================================
317 const int HOMARD_Hypothesis::GetAdapInit() const
318 //=============================================================================
322 //=============================================================================
323 void HOMARD_Hypothesis::SetLevelOutput( int LevelOutput )
324 //=============================================================================
326 _LevelOutput = LevelOutput;
328 //=============================================================================
329 const int HOMARD_Hypothesis::GetLevelOutput() const
330 //=============================================================================
334 //=============================================================================
335 void HOMARD_Hypothesis::AddGroup( const char* Group)
337 _ListGroupSelected.push_back(Group);
339 //=============================================================================
340 void HOMARD_Hypothesis::SetGroups( const std::list<std::string>& ListGroup )
342 _ListGroupSelected.clear();
343 std::list<std::string>::const_iterator it = ListGroup.begin();
344 while(it != ListGroup.end())
345 _ListGroupSelected.push_back((*it++));
347 //=============================================================================
348 const std::list<std::string>& HOMARD_Hypothesis::GetGroups() const
350 return _ListGroupSelected;
352 //=============================================================================
353 // Type d'interpolation des champs :
354 // 0 : aucun champ n'est interpole
355 // 1 : tous les champs sont interpoles
356 // 2 : certains champs sont interpoles
357 void HOMARD_Hypothesis::SetTypeFieldInterp( int TypeFieldInterp )
359 VERIFICATION( (TypeFieldInterp>=0) && (TypeFieldInterp<=2) );
360 _TypeFieldInterp = TypeFieldInterp;
362 //=============================================================================
363 int HOMARD_Hypothesis::GetTypeFieldInterp() const
365 return _TypeFieldInterp;
367 //=============================================================================
368 void HOMARD_Hypothesis::AddFieldInterpType( const char* FieldInterp, int TypeInterp )
370 MESSAGE ("Dans AddFieldInterpType pour " << FieldInterp << " et TypeInterp = " << TypeInterp) ;
371 // On commence par supprimer le champ au cas ou il aurait deja ete insere
372 // Cela peut se produire dans un schema YACS quand on repasse plusieurs fois par la
373 // definition de l'hypothese
374 SupprFieldInterp( FieldInterp ) ;
375 // Insertion veritable
377 _ListFieldInterp.push_back( std::string( FieldInterp ) );
379 std::stringstream saux1 ;
380 saux1 << TypeInterp ;
381 _ListFieldInterp.push_back( saux1.str() );
382 // . Indication generale : certains champs sont a interpoler
383 SetTypeFieldInterp ( 2 ) ;
385 //=============================================================================
386 void HOMARD_Hypothesis::SupprFieldInterp( const char* FieldInterp )
388 MESSAGE ("Dans SupprFieldInterp pour " << FieldInterp) ;
389 std::list<std::string>::iterator it = find( _ListFieldInterp.begin(), _ListFieldInterp.end(), FieldInterp ) ;
390 // Attention a supprimer le nom du champ et le type d'usage
391 if ( it != _ListFieldInterp.end() )
393 it = _ListFieldInterp.erase( it ) ;
394 it = _ListFieldInterp.erase( it ) ;
396 // Decompte du nombre de champs restant a interpoler
397 it = _ListFieldInterp.begin() ;
399 while(it != _ListFieldInterp.end())
404 MESSAGE("Nombre de champ restants = "<<cpt/2);
405 // . Indication generale : aucun champ ne reste a interpoler
408 SetTypeFieldInterp ( 0 ) ;
411 //=============================================================================
412 void HOMARD_Hypothesis::SupprFieldInterps()
414 MESSAGE ("SupprFieldInterps") ;
415 _ListFieldInterp.clear();
416 // . Indication generale : aucun champ ne reste a interpoler
417 SetTypeFieldInterp ( 0 ) ;
419 //=============================================================================
420 const std::list<std::string>& HOMARD_Hypothesis::GetFieldInterps() const
422 return _ListFieldInterp;
424 //=============================================================================
425 //=============================================================================
426 // Liens avec les autres structures
427 //=============================================================================
428 //=============================================================================
429 void HOMARD_Hypothesis::SetCaseCreation( const char* NomCasCreation )
431 _NomCasCreation = std::string( NomCasCreation );
433 //=============================================================================
434 std::string HOMARD_Hypothesis::GetCaseCreation() const
436 return _NomCasCreation;
438 //=============================================================================
439 void HOMARD_Hypothesis::LinkIteration( const char* NomIteration )
441 _ListIter.push_back( std::string( NomIteration ) );
443 //=============================================================================
444 void HOMARD_Hypothesis::UnLinkIteration( const char* NomIteration )
446 std::list<std::string>::iterator it = find( _ListIter.begin(), _ListIter.end(), NomIteration ) ;
447 if ( it != _ListIter.end() )
449 MESSAGE ("Dans UnLinkIteration pour " << NomIteration) ;
450 it = _ListIter.erase( it ) ;
453 //=============================================================================
454 void HOMARD_Hypothesis::UnLinkIterations()
458 //=============================================================================
459 const std::list<std::string>& HOMARD_Hypothesis::GetIterations() const
463 //=============================================================================
464 void HOMARD_Hypothesis::AddZone( const char* NomZone, int TypeUse )
466 MESSAGE ("Dans AddZone pour " << NomZone << " et TypeUse = " << TypeUse) ;
467 // On commence par supprimer la zone au cas ou elle aurait deja ete inseree
468 // Cela peut se produire dans un schema YACS quand on repasse plusieurs fois par la
469 // definition de l'hypothese
470 SupprZone( NomZone ) ;
471 // Insertion veritable
473 _ListZone.push_back( std::string( NomZone ) );
474 // . Usage de la zone
475 std::stringstream saux1 ;
477 _ListZone.push_back( saux1.str() );
479 //=============================================================================
480 void HOMARD_Hypothesis::SupprZone( const char* NomZone )
482 MESSAGE ("Dans SupprZone pour " << NomZone) ;
483 std::list<std::string>::iterator it = find( _ListZone.begin(), _ListZone.end(), NomZone );
484 // Attention a supprimer le nom de zone et le type d'usage
485 if ( it != _ListZone.end() )
487 it = _ListZone.erase( it );
488 it = _ListZone.erase( it );
491 //=============================================================================
492 void HOMARD_Hypothesis::SupprZones()
496 //=============================================================================
497 const std::list<std::string>& HOMARD_Hypothesis::GetZones() const