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"
35 #include "utilities.h"
37 //=============================================================================
39 * default constructor:
41 //=============================================================================
42 HOMARD_Hypothesis::HOMARD_Hypothesis():
43 _Name(""), _NomCasCreation(""),
44 _TypeAdap(-1), _TypeRaff(0), _TypeDera(0),
46 _TypeThR(0), _ThreshR(0),
47 _TypeThC(0), _ThreshC(0),
48 _UsField(0), _UsCmpI(0), _TypeFieldInterp(0)
50 MESSAGE("HOMARD_Hypothesis");
53 //=============================================================================
56 //=============================================================================
57 HOMARD_Hypothesis::~HOMARD_Hypothesis()
59 MESSAGE("~HOMARD_Hypothesis");
61 //=============================================================================
62 //=============================================================================
64 //=============================================================================
65 //=============================================================================
66 void HOMARD_Hypothesis::SetName( const char* Name )
68 _Name = std::string( Name );
70 //=============================================================================
71 std::string HOMARD_Hypothesis::GetName() const
75 //=============================================================================
76 std::string HOMARD_Hypothesis::GetDumpPython() const
78 std::ostringstream aScript;
79 aScript << "\n# Creation of the hypothesis " << _Name << "\n" ;
80 aScript << "\t" << _Name << " = homard.CreateHypothesis(\"" << _Name << "\")\n";
81 aScript << "\t" << _Name << ".SetAdapRefinUnRef(" << _TypeAdap << ", " << _TypeRaff << ", " << _TypeDera << ")\n";
83 // Raffinement selon des zones geometriques
84 std::list<std::string>::const_iterator it = _ListZone.begin();
86 while(it != _ListZone.end())
88 aScript << "\t" << _Name << ".AddZone(\"" << *it;
90 if ( *it == "1" ) { TypeUse = 1 ; }
91 else { TypeUse = -1 ; }
92 aScript << "\", " << TypeUse << ")\n";
96 // Raffinement selon un champ
99 aScript << "\t" << _Name << ".SetField(\"" << _Field << "\")\n";
100 aScript << "\t" << _Name << ".SetUseField(" << _UsField << ")\n";
101 aScript << "\t" << _Name << ".SetUseComp(" << _UsCmpI << ")\n";
102 std::list<std::string>::const_iterator it_comp = _ListComp.begin();
103 while(it_comp != _ListComp.end())
105 aScript << "\t" << _Name << ".AddComp(\"" << *it_comp << "\")\n";
108 if ( _TypeRaff == 1 )
110 aScript << "\t" << _Name << ".SetRefinThr(" << _TypeThR << ", " << _ThreshR << ")\n";
112 if ( _TypeDera == 1 )
114 aScript << "\t" << _Name << ".SetUnRefThr(" << _TypeThC << ", " << _ThreshC << ")\n";
118 // Filtrage du raffinement par des groupes
119 for ( it=_ListGroupSelected.begin(); it!=_ListGroupSelected.end();it++)
120 aScript << "\t" << _Name << ".AddGroup(\"" << (*it) << "\")\n" ;
122 // Interpolation champ
123 aScript << "\t" << _Name << ".SetTypeFieldInterp(" << _TypeFieldInterp << ")\n";
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 << ".AddFieldInterp(\"" << *it_champ << "\")\n";
135 aScript << "\t" <<_Name << ".SetNivMax(" << _NivMax << ")\n";
139 aScript << "\t" <<_Name << ".SetDiamMin(" << _DiamMin << ")\n";
141 if ( _AdapInit != 0 )
143 aScript << "\t" <<_Name << ".SetAdapInit(" << _AdapInit << ")\n";
145 if ( _LevelOutput != 0 )
147 aScript << "\t" <<_Name << ".SetLevelOutput(" << _LevelOutput << ")\n";
150 return aScript.str();
152 //=============================================================================
153 //=============================================================================
155 //=============================================================================
156 //=============================================================================
157 void HOMARD_Hypothesis::SetAdapType( int TypeAdap )
159 ASSERT (!((TypeAdap < -1) or (TypeAdap > 1)));
160 _TypeAdap = TypeAdap;
162 //=============================================================================
163 int HOMARD_Hypothesis::GetAdapType() const
167 //=============================================================================
168 void HOMARD_Hypothesis::SetRefinTypeDera( int TypeRaff, int TypeDera )
170 ASSERT(!(( TypeRaff < 0) or (TypeRaff > 1)));
171 _TypeRaff = TypeRaff;
172 ASSERT(! ((TypeDera < 0) or (TypeDera > 1)));
173 _TypeDera = TypeDera;
175 //=============================================================================
176 int HOMARD_Hypothesis::GetRefinType() const
180 //=============================================================================
181 int HOMARD_Hypothesis::GetUnRefType() const
185 //=============================================================================
186 void HOMARD_Hypothesis::SetField( const char* FieldName )
188 _Field = std::string( FieldName );
189 MESSAGE( "SetField : FieldName = " << FieldName );
191 //=============================================================================
192 std::string HOMARD_Hypothesis::GetFieldName() const
196 //=============================================================================
197 void HOMARD_Hypothesis::SetUseField( int UsField )
199 ASSERT(!((UsField < 0) or (UsField > 1 )));
202 //=============================================================================
203 int HOMARD_Hypothesis::GetUseField() const
207 //=============================================================================
208 void HOMARD_Hypothesis::SetUseComp( int UsCmpI )
210 ASSERT(!((UsCmpI < 0) or (UsCmpI > 2)));
213 //=============================================================================
214 int HOMARD_Hypothesis::GetUseComp() const
218 //=============================================================================
219 void HOMARD_Hypothesis::AddComp( const char* NomComp )
221 // On commence par la supprimer au cas ou elle aurait deja ete inseree
222 // Cela peut se produire dans un schema YACS quand on repasse plusieurs fois par la
223 // definition de l'hypothese
224 SupprComp( NomComp ) ;
225 // Insertion veritable
226 _ListComp.push_back( std::string( NomComp ) );
228 //=============================================================================
229 void HOMARD_Hypothesis::SupprComp( const char* NomComp )
231 MESSAGE ("SupprComp pour "<<NomComp) ;
232 std::list<std::string>::iterator it = find( _ListComp.begin(), _ListComp.end(), NomComp );
233 if ( it != _ListComp.end() ) { it = _ListComp.erase( it ); }
235 //=============================================================================
236 void HOMARD_Hypothesis::SupprComps()
240 //=============================================================================
241 const std::list<std::string>& HOMARD_Hypothesis::GetComps() const
245 //=============================================================================
246 void HOMARD_Hypothesis::SetRefinThr( int TypeThR, double ThreshR )
248 MESSAGE( "SetRefinThr : TypeThR = " << TypeThR << ", ThreshR = " << ThreshR );
249 ASSERT(!(( TypeThR < 0) or (TypeThR > 4 )));
253 //=============================================================================
254 int HOMARD_Hypothesis::GetRefinThrType() const
258 //=============================================================================
259 double HOMARD_Hypothesis::GetThreshR() const
263 //=============================================================================
264 void HOMARD_Hypothesis::SetUnRefThr( int TypeThC, double ThreshC )
266 ASSERT(!((TypeThC < 0) or (TypeThC > 4)));
270 //=============================================================================
271 int HOMARD_Hypothesis::GetUnRefThrType() const
275 //=============================================================================
276 double HOMARD_Hypothesis::GetThreshC() const
280 //=============================================================================
281 void HOMARD_Hypothesis::SetNivMax( int NivMax )
282 //=============================================================================
286 //=============================================================================
287 const int HOMARD_Hypothesis::GetNivMax() const
288 //=============================================================================
292 //=============================================================================
293 void HOMARD_Hypothesis::SetDiamMin( double DiamMin )
294 //=============================================================================
298 //=============================================================================
299 const double HOMARD_Hypothesis::GetDiamMin() const
300 //=============================================================================
304 //=============================================================================
305 void HOMARD_Hypothesis::SetAdapInit( int AdapInit )
306 //=============================================================================
308 _AdapInit = AdapInit;
310 //=============================================================================
311 const int HOMARD_Hypothesis::GetAdapInit() const
312 //=============================================================================
316 //=============================================================================
317 void HOMARD_Hypothesis::SetLevelOutput( int LevelOutput )
318 //=============================================================================
320 _LevelOutput = LevelOutput;
322 //=============================================================================
323 const int HOMARD_Hypothesis::GetLevelOutput() const
324 //=============================================================================
328 //=============================================================================
329 void HOMARD_Hypothesis::AddGroup( const char* Group)
331 _ListGroupSelected.push_back(Group);
333 //=============================================================================
334 void HOMARD_Hypothesis::SetGroups( const std::list<std::string>& ListGroup )
336 _ListGroupSelected.clear();
337 std::list<std::string>::const_iterator it = ListGroup.begin();
338 while(it != ListGroup.end())
339 _ListGroupSelected.push_back((*it++));
341 //=============================================================================
342 const std::list<std::string>& HOMARD_Hypothesis::GetGroups() const
344 return _ListGroupSelected;
346 //=============================================================================
347 void HOMARD_Hypothesis::SetTypeFieldInterp( int TypeFieldInterp )
349 ASSERT (!((TypeFieldInterp < -1) or (TypeFieldInterp > 2)));
350 _TypeFieldInterp = TypeFieldInterp;
352 //=============================================================================
353 int HOMARD_Hypothesis::GetTypeFieldInterp() const
355 return _TypeFieldInterp;
357 //=============================================================================
358 void HOMARD_Hypothesis::AddFieldInterp( const char* FieldInterp )
360 _ListFieldInterp.push_back( std::string( FieldInterp ) );
362 //=============================================================================
363 void HOMARD_Hypothesis::SupprFieldInterp()
365 MESSAGE ("SupprFieldInterp") ;
366 _ListFieldInterp.clear();
368 //=============================================================================
369 const std::list<std::string>& HOMARD_Hypothesis::GetListFieldInterp() const
371 return _ListFieldInterp;
373 //=============================================================================
374 //=============================================================================
375 // Liens avec les autres structures
376 //=============================================================================
377 //=============================================================================
378 void HOMARD_Hypothesis::SetCaseCreation( const char* NomCasCreation )
380 _NomCasCreation = std::string( NomCasCreation );
382 //=============================================================================
383 std::string HOMARD_Hypothesis::GetCaseCreation() const
385 return _NomCasCreation;
387 //=============================================================================
388 void HOMARD_Hypothesis::LinkIteration( const char* NomIteration )
390 _ListIter.push_back( std::string( NomIteration ) );
392 //=============================================================================
393 void HOMARD_Hypothesis::UnLinkIteration( const char* NomIteration )
395 std::list<std::string>::iterator it = find( _ListIter.begin(), _ListIter.end(), NomIteration ) ;
396 if ( it != _ListIter.end() )
398 MESSAGE ("Dans UnLinkIteration pour " << NomIteration) ;
399 it = _ListIter.erase( it ) ;
402 //=============================================================================
403 void HOMARD_Hypothesis::UnLinkIterations()
407 //=============================================================================
408 const std::list<std::string>& HOMARD_Hypothesis::GetIterations() const
412 //=============================================================================
413 void HOMARD_Hypothesis::AddZone( const char* NomZone, int TypeUse )
415 MESSAGE ("Dans AddZone pour " << NomZone) ;
416 // On commence par la supprimer au cas ou elle aurait deja ete inseree
417 // Cela peut se produire dans un schema YACS quand on repasse plusieurs fois par la
418 // definition de l'hypothese
419 SupprZone( NomZone ) ;
420 // Insertion veritable
422 _ListZone.push_back( std::string( NomZone ) );
423 // . Usage de la zone
424 std::stringstream saux1 ;
426 _ListZone.push_back( saux1.str() );
428 //=============================================================================
429 void HOMARD_Hypothesis::SupprZone( const char* NomZone )
431 MESSAGE ("Dans SupprZone pour " << NomZone) ;
432 std::list<std::string>::iterator it = find( _ListZone.begin(), _ListZone.end(), NomZone );
433 // Attention a supprimer le nom de zone et le type d'usage
434 if ( it != _ListZone.end() )
436 it = _ListZone.erase( it );
437 it = _ListZone.erase( it );
440 //=============================================================================
441 void HOMARD_Hypothesis::SupprZones()
445 //=============================================================================
446 const std::list<std::string>& HOMARD_Hypothesis::GetZones() const