1 // HOMARD HOMARD : implementation of HOMARD idl descriptions
3 // Copyright (C) 2011-2014 CEA/DEN, EDF R&D
5 // This library is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU Lesser General Public
7 // License as published by the Free Software Foundation; either
8 // version 2.1 of the License, or (at your option) any later version.
10 // This library is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 // Lesser General Public License for more details.
15 // You should have received a copy of the GNU Lesser General Public
16 // License along with this library; if not, write to the Free Software
17 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 // File : HOMARD_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 if ( _TypeAdap == -1 )
85 if ( _TypeRaff == 1 ) { TypeRaffDera = 1 ; }
86 else { TypeRaffDera = -1 ; }
87 aScript << "\t" << _Name << ".SetUnifRefinUnRef(" << TypeRaffDera << ")\n";
90 // Raffinement selon des zones geometriques
91 std::list<std::string>::const_iterator it = _ListZone.begin();
93 while(it != _ListZone.end())
95 aScript << "\t" << _Name << ".AddZone(\"" << *it;
97 if ( *it == "1" ) { TypeUse = 1 ; }
98 else { TypeUse = -1 ; }
99 aScript << "\", " << TypeUse << ")\n";
103 // Raffinement selon un champ
104 if ( _TypeAdap == 1 )
106 aScript << "\t" << _Name << ".SetField(\"" << _Field << "\")\n";
107 aScript << "\t" << _Name << ".SetUseField(" << _UsField << ")\n";
108 aScript << "\t" << _Name << ".SetUseComp(" << _UsCmpI << ")\n";
109 std::list<std::string>::const_iterator it_comp = _ListComp.begin();
110 while(it_comp != _ListComp.end())
112 aScript << "\t" << _Name << ".AddComp(\"" << *it_comp << "\")\n";
115 if ( _TypeRaff == 1 )
117 aScript << "\t" << _Name << ".SetRefinThr(" << _TypeThR << ", " << _ThreshR << ")\n";
119 if ( _TypeDera == 1 )
121 aScript << "\t" << _Name << ".SetUnRefThr(" << _TypeThC << ", " << _ThreshC << ")\n";
125 // Filtrage du raffinement par des groupes
126 for ( it=_ListGroupSelected.begin(); it!=_ListGroupSelected.end();it++)
127 aScript << "\t" << _Name << ".AddGroup(\"" << (*it) << "\")\n" ;
129 // Interpolation des champs
130 if ( _TypeFieldInterp == 2 )
132 std::list<std::string>::const_iterator it_champ = _ListFieldInterp.begin();
133 while(it_champ != _ListFieldInterp.end())
135 aScript << "\t" << _Name << ".AddFieldInterpType( \"" << *it_champ << "\" " ;
137 aScript << ", " << *it_champ << ")\n";
141 else if ( _TypeFieldInterp != 0 )
143 aScript << "\t" << _Name << ".SetTypeFieldInterp(" << _TypeFieldInterp << ")\n";
147 aScript << "\t" <<_Name << ".SetNivMax(" << _NivMax << ")\n";
151 aScript << "\t" <<_Name << ".SetDiamMin(" << _DiamMin << ")\n";
153 if ( _AdapInit != 0 )
155 aScript << "\t" <<_Name << ".SetAdapInit(" << _AdapInit << ")\n";
157 if ( _LevelOutput != 0 )
159 aScript << "\t" <<_Name << ".SetLevelOutput(" << _LevelOutput << ")\n";
162 return aScript.str();
164 //=============================================================================
165 //=============================================================================
167 //=============================================================================
168 //=============================================================================
169 void HOMARD_Hypothesis::SetAdapType( int TypeAdap )
171 VERIFICATION( (TypeAdap>=-1) && (TypeAdap<=1) );
172 _TypeAdap = TypeAdap;
174 //=============================================================================
175 int HOMARD_Hypothesis::GetAdapType() const
179 //=============================================================================
180 void HOMARD_Hypothesis::SetRefinTypeDera( int TypeRaff, int TypeDera )
182 VERIFICATION( (TypeRaff>=-1) && (TypeRaff<=1) );
183 _TypeRaff = TypeRaff;
184 VERIFICATION( (TypeDera>=-1) && (TypeDera<=1) );
185 _TypeDera = TypeDera;
187 //=============================================================================
188 int HOMARD_Hypothesis::GetRefinType() const
192 //=============================================================================
193 int HOMARD_Hypothesis::GetUnRefType() const
197 //=============================================================================
198 void HOMARD_Hypothesis::SetField( const char* FieldName )
200 _Field = std::string( FieldName );
201 MESSAGE( "SetField : FieldName = " << FieldName );
203 //=============================================================================
204 std::string HOMARD_Hypothesis::GetFieldName() const
208 //=============================================================================
209 void HOMARD_Hypothesis::SetUseField( int UsField )
211 VERIFICATION( (UsField>=0) && (UsField<=1) );
214 //=============================================================================
215 int HOMARD_Hypothesis::GetUseField() const
219 //=============================================================================
220 void HOMARD_Hypothesis::SetUseComp( int UsCmpI )
222 VERIFICATION( (UsCmpI>=0) && (UsCmpI<=2) );
225 //=============================================================================
226 int HOMARD_Hypothesis::GetUseComp() const
230 //=============================================================================
231 void HOMARD_Hypothesis::AddComp( const char* NomComp )
233 // On commence par la supprimer au cas ou elle aurait deja ete inseree
234 // Cela peut se produire dans un schema YACS quand on repasse plusieurs fois par la
235 // definition de l'hypothese
236 SupprComp( NomComp ) ;
237 // Insertion veritable
238 _ListComp.push_back( std::string( NomComp ) );
240 //=============================================================================
241 void HOMARD_Hypothesis::SupprComp( const char* NomComp )
243 MESSAGE ("SupprComp pour "<<NomComp) ;
244 std::list<std::string>::iterator it = find( _ListComp.begin(), _ListComp.end(), NomComp );
245 if ( it != _ListComp.end() ) { it = _ListComp.erase( it ); }
247 //=============================================================================
248 void HOMARD_Hypothesis::SupprComps()
252 //=============================================================================
253 const std::list<std::string>& HOMARD_Hypothesis::GetComps() const
257 //=============================================================================
258 void HOMARD_Hypothesis::SetRefinThr( int TypeThR, double ThreshR )
260 MESSAGE( "SetRefinThr : TypeThR = " << TypeThR << ", ThreshR = " << ThreshR );
261 VERIFICATION( (TypeThR>=0) && (TypeThR<=4) );
265 //=============================================================================
266 int HOMARD_Hypothesis::GetRefinThrType() const
270 //=============================================================================
271 double HOMARD_Hypothesis::GetThreshR() const
275 //=============================================================================
276 void HOMARD_Hypothesis::SetUnRefThr( int TypeThC, double ThreshC )
278 VERIFICATION( (TypeThC>=0) && (TypeThC<=4) );
282 //=============================================================================
283 int HOMARD_Hypothesis::GetUnRefThrType() const
287 //=============================================================================
288 double HOMARD_Hypothesis::GetThreshC() const
292 //=============================================================================
293 void HOMARD_Hypothesis::SetNivMax( int NivMax )
294 //=============================================================================
298 //=============================================================================
299 const int HOMARD_Hypothesis::GetNivMax() const
300 //=============================================================================
304 //=============================================================================
305 void HOMARD_Hypothesis::SetDiamMin( double DiamMin )
306 //=============================================================================
310 //=============================================================================
311 const double HOMARD_Hypothesis::GetDiamMin() const
312 //=============================================================================
316 //=============================================================================
317 void HOMARD_Hypothesis::SetAdapInit( int AdapInit )
318 //=============================================================================
320 _AdapInit = AdapInit;
322 //=============================================================================
323 const int HOMARD_Hypothesis::GetAdapInit() const
324 //=============================================================================
328 //=============================================================================
329 void HOMARD_Hypothesis::SetLevelOutput( int LevelOutput )
330 //=============================================================================
332 _LevelOutput = LevelOutput;
334 //=============================================================================
335 const int HOMARD_Hypothesis::GetLevelOutput() const
336 //=============================================================================
340 //=============================================================================
341 void HOMARD_Hypothesis::AddGroup( const char* Group)
343 _ListGroupSelected.push_back(Group);
345 //=============================================================================
346 void HOMARD_Hypothesis::SetGroups( const std::list<std::string>& ListGroup )
348 _ListGroupSelected.clear();
349 std::list<std::string>::const_iterator it = ListGroup.begin();
350 while(it != ListGroup.end())
351 _ListGroupSelected.push_back((*it++));
353 //=============================================================================
354 const std::list<std::string>& HOMARD_Hypothesis::GetGroups() const
356 return _ListGroupSelected;
358 //=============================================================================
359 // Type d'interpolation des champs :
360 // 0 : aucun champ n'est interpole
361 // 1 : tous les champs sont interpoles
362 // 2 : certains champs sont interpoles
363 void HOMARD_Hypothesis::SetTypeFieldInterp( int TypeFieldInterp )
365 VERIFICATION( (TypeFieldInterp>=0) && (TypeFieldInterp<=2) );
366 _TypeFieldInterp = TypeFieldInterp;
368 //=============================================================================
369 int HOMARD_Hypothesis::GetTypeFieldInterp() const
371 return _TypeFieldInterp;
373 //=============================================================================
374 void HOMARD_Hypothesis::AddFieldInterpType( const char* FieldInterp, int TypeInterp )
376 MESSAGE ("Dans AddFieldInterpType pour " << FieldInterp << " et TypeInterp = " << TypeInterp) ;
377 // On commence par supprimer le champ au cas ou il aurait deja ete insere
378 // Cela peut se produire dans un schema YACS quand on repasse plusieurs fois par la
379 // definition de l'hypothese
380 SupprFieldInterp( FieldInterp ) ;
381 // Insertion veritable
383 _ListFieldInterp.push_back( std::string( FieldInterp ) );
385 std::stringstream saux1 ;
386 saux1 << TypeInterp ;
387 _ListFieldInterp.push_back( saux1.str() );
388 // . Indication generale : certains champs sont a interpoler
389 SetTypeFieldInterp ( 2 ) ;
391 //=============================================================================
392 void HOMARD_Hypothesis::SupprFieldInterp( const char* FieldInterp )
394 MESSAGE ("Dans SupprFieldInterp pour " << FieldInterp) ;
395 std::list<std::string>::iterator it = find( _ListFieldInterp.begin(), _ListFieldInterp.end(), FieldInterp ) ;
396 // Attention a supprimer le nom du champ et le type d'usage
397 if ( it != _ListFieldInterp.end() )
399 it = _ListFieldInterp.erase( it ) ;
400 it = _ListFieldInterp.erase( it ) ;
402 // Decompte du nombre de champs restant a interpoler
403 it = _ListFieldInterp.begin() ;
405 while(it != _ListFieldInterp.end())
410 MESSAGE("Nombre de champ restants = "<<cpt/2);
411 // . Indication generale : aucun champ ne reste a interpoler
414 SetTypeFieldInterp ( 0 ) ;
417 //=============================================================================
418 void HOMARD_Hypothesis::SupprFieldInterps()
420 MESSAGE ("SupprFieldInterps") ;
421 _ListFieldInterp.clear();
422 // . Indication generale : aucun champ ne reste a interpoler
423 SetTypeFieldInterp ( 0 ) ;
425 //=============================================================================
426 const std::list<std::string>& HOMARD_Hypothesis::GetFieldInterps() const
428 return _ListFieldInterp;
430 //=============================================================================
431 //=============================================================================
432 // Liens avec les autres structures
433 //=============================================================================
434 //=============================================================================
435 void HOMARD_Hypothesis::SetCaseCreation( const char* NomCasCreation )
437 _NomCasCreation = std::string( NomCasCreation );
439 //=============================================================================
440 std::string HOMARD_Hypothesis::GetCaseCreation() const
442 return _NomCasCreation;
444 //=============================================================================
445 void HOMARD_Hypothesis::LinkIteration( const char* NomIteration )
447 _ListIter.push_back( std::string( NomIteration ) );
449 //=============================================================================
450 void HOMARD_Hypothesis::UnLinkIteration( const char* NomIteration )
452 std::list<std::string>::iterator it = find( _ListIter.begin(), _ListIter.end(), NomIteration ) ;
453 if ( it != _ListIter.end() )
455 MESSAGE ("Dans UnLinkIteration pour " << NomIteration) ;
456 it = _ListIter.erase( it ) ;
459 //=============================================================================
460 void HOMARD_Hypothesis::UnLinkIterations()
464 //=============================================================================
465 const std::list<std::string>& HOMARD_Hypothesis::GetIterations() const
469 //=============================================================================
470 void HOMARD_Hypothesis::AddZone( const char* NomZone, int TypeUse )
472 MESSAGE ("Dans AddZone pour " << NomZone << " et TypeUse = " << TypeUse) ;
473 // On commence par supprimer la zone au cas ou elle aurait deja ete inseree
474 // Cela peut se produire dans un schema YACS quand on repasse plusieurs fois par la
475 // definition de l'hypothese
476 SupprZone( NomZone ) ;
477 // Insertion veritable
479 _ListZone.push_back( std::string( NomZone ) );
480 // . Usage de la zone
481 std::stringstream saux1 ;
483 _ListZone.push_back( saux1.str() );
485 //=============================================================================
486 void HOMARD_Hypothesis::SupprZone( const char* NomZone )
488 MESSAGE ("Dans SupprZone pour " << NomZone) ;
489 std::list<std::string>::iterator it = find( _ListZone.begin(), _ListZone.end(), NomZone );
490 // Attention a supprimer le nom de zone et le type d'usage
491 if ( it != _ListZone.end() )
493 it = _ListZone.erase( it );
494 it = _ListZone.erase( it );
497 //=============================================================================
498 void HOMARD_Hypothesis::SupprZones()
502 //=============================================================================
503 const std::list<std::string>& HOMARD_Hypothesis::GetZones() const