1 // HOMARD HOMARD : implementaion 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 = _ListComposant.begin();
103 while(it_comp != _ListComposant.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* NomComposant )
221 _ListComposant.push_back( std::string( NomComposant ) );
223 //=============================================================================
224 void HOMARD_Hypothesis::SupprComp()
226 MESSAGE ("SupprComp") ;
227 _ListComposant.clear();
229 //=============================================================================
230 const std::list<std::string>& HOMARD_Hypothesis::GetListComp() const
232 return _ListComposant;
234 //=============================================================================
235 void HOMARD_Hypothesis::SetRefinThr( int TypeThR, double ThreshR )
237 MESSAGE( "SetRefinThr : TypeThR = " << TypeThR << ", ThreshR = " << ThreshR );
238 ASSERT(!(( TypeThR < 0) or (TypeThR > 4 )));
242 //=============================================================================
243 int HOMARD_Hypothesis::GetRefinThrType() const
247 //=============================================================================
248 double HOMARD_Hypothesis::GetThreshR() const
252 //=============================================================================
253 void HOMARD_Hypothesis::SetUnRefThr( int TypeThC, double ThreshC )
255 ASSERT(!((TypeThC < 0) or (TypeThC > 4)));
259 //=============================================================================
260 int HOMARD_Hypothesis::GetUnRefThrType() const
264 //=============================================================================
265 double HOMARD_Hypothesis::GetThreshC() const
269 //=============================================================================
270 void HOMARD_Hypothesis::SetNivMax( int NivMax )
271 //=============================================================================
275 //=============================================================================
276 const int HOMARD_Hypothesis::GetNivMax() const
277 //=============================================================================
281 //=============================================================================
282 void HOMARD_Hypothesis::SetDiamMin( double DiamMin )
283 //=============================================================================
287 //=============================================================================
288 const double HOMARD_Hypothesis::GetDiamMin() const
289 //=============================================================================
293 //=============================================================================
294 void HOMARD_Hypothesis::SetAdapInit( int AdapInit )
295 //=============================================================================
297 _AdapInit = AdapInit;
299 //=============================================================================
300 const int HOMARD_Hypothesis::GetAdapInit() const
301 //=============================================================================
305 //=============================================================================
306 void HOMARD_Hypothesis::SetLevelOutput( int LevelOutput )
307 //=============================================================================
309 _LevelOutput = LevelOutput;
311 //=============================================================================
312 const int HOMARD_Hypothesis::GetLevelOutput() const
313 //=============================================================================
317 //=============================================================================
318 void HOMARD_Hypothesis::AddGroup( const char* Group)
320 _ListGroupSelected.push_back(Group);
322 //=============================================================================
323 void HOMARD_Hypothesis::SetGroups( const std::list<std::string>& ListGroup )
325 _ListGroupSelected.clear();
326 std::list<std::string>::const_iterator it = ListGroup.begin();
327 while(it != ListGroup.end())
328 _ListGroupSelected.push_back((*it++));
330 //=============================================================================
331 const std::list<std::string>& HOMARD_Hypothesis::GetGroups() const
333 return _ListGroupSelected;
335 //=============================================================================
336 void HOMARD_Hypothesis::SetTypeFieldInterp( int TypeFieldInterp )
338 ASSERT (!((TypeFieldInterp < -1) or (TypeFieldInterp > 2)));
339 _TypeFieldInterp = TypeFieldInterp;
341 //=============================================================================
342 int HOMARD_Hypothesis::GetTypeFieldInterp() const
344 return _TypeFieldInterp;
346 //=============================================================================
347 void HOMARD_Hypothesis::AddFieldInterp( const char* FieldInterp )
349 _ListFieldInterp.push_back( std::string( FieldInterp ) );
351 //=============================================================================
352 void HOMARD_Hypothesis::SupprFieldInterp()
354 MESSAGE ("SupprFieldInterp") ;
355 _ListFieldInterp.clear();
357 //=============================================================================
358 const std::list<std::string>& HOMARD_Hypothesis::GetListFieldInterp() const
360 return _ListFieldInterp;
362 //=============================================================================
363 //=============================================================================
364 // Liens avec les autres structures
365 //=============================================================================
366 //=============================================================================
367 void HOMARD_Hypothesis::SetCaseCreation( const char* NomCasCreation )
369 _NomCasCreation = std::string( NomCasCreation );
371 //=============================================================================
372 std::string HOMARD_Hypothesis::GetCaseCreation() const
374 return _NomCasCreation;
376 //=============================================================================
377 void HOMARD_Hypothesis::LinkIteration( const char* NomIteration )
379 _ListIter.push_back( std::string( NomIteration ) );
381 //=============================================================================
382 void HOMARD_Hypothesis::UnLinkIteration( const char* NomIteration )
384 std::list<std::string>::iterator it = find( _ListIter.begin(), _ListIter.end(), NomIteration ) ;
385 if ( it != _ListIter.end() )
387 MESSAGE ("Dans UnLinkIteration pour " << NomIteration) ;
388 _ListIter.erase( it ) ;
391 //=============================================================================
392 void HOMARD_Hypothesis::UnLinkIterations()
396 //=============================================================================
397 const std::list<std::string>& HOMARD_Hypothesis::GetIterations() const
401 //=============================================================================
402 void HOMARD_Hypothesis::AddZone( const char* NomZone, int TypeUse )
404 MESSAGE ("Dans AddZone pour " << NomZone) ;
405 _ListZone.push_back( std::string( NomZone ) );
406 std::stringstream saux1 ;
408 std::string saux2 = saux1.str() ;
409 _ListZone.push_back( saux2 );
411 //=============================================================================
412 void HOMARD_Hypothesis::SupprZone( const char* NomZone )
414 MESSAGE ("Dans SupprZone pour " << NomZone) ;
415 std::list<std::string>::iterator it = find( _ListZone.begin(), _ListZone.end(), NomZone );
416 if ( it != _ListZone.end() )
418 _ListZone.erase( it );
421 //=============================================================================
422 void HOMARD_Hypothesis::SupprZones()
426 //=============================================================================
427 const std::list<std::string>& HOMARD_Hypothesis::GetZones() const