1 // HOMARD HOMARD : implementaion of HOMARD idl descriptions
3 // Copyright (C) 2011-2012 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
25 #include "HOMARD_Hypothesis.hxx"
26 #include "utilities.h"
28 //=============================================================================
30 * default constructor:
32 //=============================================================================
33 HOMARD_Hypothesis::HOMARD_Hypothesis():
34 _NomHypo(""), _NomCasCreation(""),
35 _TypeAdap(-1), _TypeRaff(0), _TypeDera(0),
37 _TypeThR(0), _ThreshR(0),
38 _TypeThC(0), _ThreshC(0),
39 _UsField(0), _UsCmpI(0), _TypeFieldInterp(0)
41 MESSAGE("HOMARD_Hypothesis");
44 //=============================================================================
47 //=============================================================================
48 HOMARD_Hypothesis::~HOMARD_Hypothesis()
50 MESSAGE("~HOMARD_Hypothesis");
53 //=============================================================================
56 //=============================================================================
57 void HOMARD_Hypothesis::SetCaseCreation( const char* NomCasCreation )
59 _NomCasCreation = std::string( NomCasCreation );
62 //=============================================================================
65 //=============================================================================
66 std::string HOMARD_Hypothesis::GetCaseCreation() const
68 return _NomCasCreation;
70 //=============================================================================
73 //=============================================================================
74 void HOMARD_Hypothesis::SetName( const char* NomHypo )
76 _NomHypo = std::string( NomHypo );
79 //=============================================================================
82 //=============================================================================
83 std::string HOMARD_Hypothesis::GetName() const
87 //=============================================================================
88 std::string HOMARD_Hypothesis::GetDumpPython() const
90 std::ostringstream aScript;
91 aScript << "\n# Creation of the hypothesis " << _NomHypo << "\n" ;
92 aScript << "\t" << _NomHypo << " = homard.CreateHypothesis(\"" << _NomHypo << "\")\n";
93 aScript << "\t" << _NomHypo << ".SetAdapRefinUnRef(" << _TypeAdap << ", " << _TypeRaff << ", " << _TypeDera << ")\n";
95 // Raffinement selon des zones geometriques
96 std::list<std::string>::const_iterator it = _ListZone.begin();
98 while(it != _ListZone.end())
100 aScript << "\thomard.AssociateHypoZone(\""<< _NomHypo << "\", \"" << *it;
102 if ( *it == "1" ) { TypeUse = 1 ; }
103 else { TypeUse = -1 ; }
104 aScript << "\", " << TypeUse << ")\n";
108 // Raffinement selon un champ
109 if ( _TypeAdap == 1 )
111 aScript << "\t" << _NomHypo << ".SetField(\"" << _Field << "\")\n";
112 aScript << "\t" << _NomHypo << ".SetUseField(" << _UsField << ")\n";
113 aScript << "\t" << _NomHypo << ".SetUseComp(" << _UsCmpI << ")\n";
114 std::list<std::string>::const_iterator it_comp = _ListComposant.begin();
115 while(it_comp != _ListComposant.end())
117 aScript << "\t" << _NomHypo << ".AddComp(\"" << *it_comp << "\")\n";
120 if ( _TypeRaff == 1 )
122 aScript << "\t" << _NomHypo << ".SetRefinThr(" << _TypeThR << ", " << _ThreshR << ")\n";
124 if ( _TypeDera == 1 )
126 aScript << "\t" << _NomHypo << ".SetUnRefThr(" << _TypeThC << ", " << _ThreshC << ")\n";
130 // Filtrage du raffinement par des groupes
131 for ( it=_ListGroupSelected.begin(); it!=_ListGroupSelected.end();it++)
132 aScript << "\t" << _NomHypo << ".AddGroup(\"" << (*it) << "\")\n" ;
134 // Interpolation champ
135 aScript << "\t" << _NomHypo << ".SetTypeFieldInterp(" << _TypeFieldInterp << ")\n";
136 if ( _TypeFieldInterp == 2 )
138 std::list<std::string>::const_iterator it_champ = _ListFieldInterp.begin();
139 while(it_champ != _ListFieldInterp.end())
141 aScript << "\t" << _NomHypo << ".AddFieldInterp(\"" << *it_champ << "\")\n";
147 aScript << "\t" <<_NomHypo << ".SetNivMax(" << _NivMax << ")\n";
151 aScript << "\t" <<_NomHypo << ".SetDiamMin(" << _DiamMin << ")\n";
153 if ( _AdapInit != 0 )
155 aScript << "\t" <<_NomHypo << ".SetAdapInit(" << _AdapInit << ")\n";
157 if ( _LevelOutput != 0 )
159 aScript << "\t" <<_NomHypo << ".SetLevelOutput(" << _LevelOutput << ")\n";
162 return aScript.str();
166 //=============================================================================
169 //=============================================================================
170 void HOMARD_Hypothesis::SetAdapType( int TypeAdap )
172 ASSERT (!((TypeAdap < -1) or (TypeAdap > 1)));
173 _TypeAdap = TypeAdap;
176 //=============================================================================
179 //=============================================================================
180 int HOMARD_Hypothesis::GetAdapType() const
185 //=============================================================================
188 //=============================================================================
189 void HOMARD_Hypothesis::SetRefinTypeDera( int TypeRaff, int TypeDera )
191 ASSERT(!(( TypeRaff < 0) or (TypeRaff > 1)));
192 _TypeRaff = TypeRaff;
193 ASSERT(! ((TypeDera < 0) or (TypeDera > 1)));
194 _TypeDera = TypeDera;
197 //=============================================================================
200 //=============================================================================
201 int HOMARD_Hypothesis::GetRefinType() const
206 //=============================================================================
209 //=============================================================================
210 int HOMARD_Hypothesis::GetUnRefType() const
215 //=============================================================================
218 //=============================================================================
219 void HOMARD_Hypothesis::SetField( const char* FieldName )
221 _Field = std::string( FieldName );
222 MESSAGE( "SetField : FieldName = " << FieldName );
224 //=============================================================================
225 void HOMARD_Hypothesis::SetRefinThr( int TypeThR, double ThreshR )
227 MESSAGE( "SetRefinThr : TypeThR = " << TypeThR << ", ThreshR = " << ThreshR );
228 ASSERT(!(( TypeThR < 0) or (TypeThR > 3 )));
232 //=============================================================================
233 void HOMARD_Hypothesis::SetUnRefThr( int TypeThC, double ThreshC )
235 ASSERT(!((TypeThC < 0) or (TypeThC > 3)));
239 //=============================================================================
240 void HOMARD_Hypothesis::SetUseComp( int UsCmpI )
242 ASSERT(!((UsCmpI < 0) or (UsCmpI > 2)));
245 //=============================================================================
246 void HOMARD_Hypothesis::SetUseField( int UsField )
248 ASSERT(!((UsField < 0) or (UsField > 1 )));
252 //=============================================================================
255 //=============================================================================
256 std::string HOMARD_Hypothesis::GetFieldName() const
260 //=============================================================================
261 int HOMARD_Hypothesis::GetRefinThrType() const
265 //=============================================================================
266 double HOMARD_Hypothesis::GetThreshR() const
270 //=============================================================================
271 int HOMARD_Hypothesis::GetUnRefThrType() const
276 //=============================================================================
277 double HOMARD_Hypothesis::GetThreshC() const
281 //=============================================================================
282 int HOMARD_Hypothesis::GetUseField() const
286 //=============================================================================
287 int HOMARD_Hypothesis::GetUseCompI() const
291 //=============================================================================
294 //=============================================================================
295 void HOMARD_Hypothesis::AddIteration( const char* NomIteration )
297 _ListIter.push_back( std::string( NomIteration ) );
299 //=============================================================================
300 void HOMARD_Hypothesis::SupprIterations()
304 //=============================================================================
305 const std::list<std::string>& HOMARD_Hypothesis::GetIterations() const
309 //=============================================================================
312 //=============================================================================
313 void HOMARD_Hypothesis::AddZone( const char* NomZone, int TypeUse )
315 _ListZone.push_back( std::string( NomZone ) );
316 std::stringstream saux1 ;
318 std::string saux2 = saux1.str() ;
319 _ListZone.push_back( saux2 );
321 //=============================================================================
322 void HOMARD_Hypothesis::SupprZone( const char* NomZone )
324 std::list<std::string>::iterator it = find( _ListZone.begin(), _ListZone.end(), NomZone );
325 if ( it != _ListZone.end() )
327 _ListZone.erase( it );
330 //=============================================================================
331 void HOMARD_Hypothesis::SupprZones()
335 //=============================================================================
336 const std::list<std::string>& HOMARD_Hypothesis::GetZones() const
340 //=============================================================================
343 //=============================================================================
344 void HOMARD_Hypothesis::AddComp( const char* NomComposant )
346 _ListComposant.push_back( std::string( NomComposant ) );
348 //=============================================================================
349 void HOMARD_Hypothesis::SupprComp()
351 std::cerr << "HOMARD_Hypothesis::SupprComp" << std::endl;
352 _ListComposant.clear();
354 //=============================================================================
355 const std::list<std::string>& HOMARD_Hypothesis::GetListComp() const
357 return _ListComposant;
359 //=============================================================================
362 //=============================================================================
363 const std::list<std::string>& HOMARD_Hypothesis::GetGroups() const
365 return _ListGroupSelected;
367 //=============================================================================
368 void HOMARD_Hypothesis::SetGroups( const std::list<std::string>& ListGroup )
370 _ListGroupSelected.clear();
371 std::list<std::string>::const_iterator it = ListGroup.begin();
372 while(it != ListGroup.end())
373 _ListGroupSelected.push_back((*it++));
375 //=============================================================================
376 void HOMARD_Hypothesis::AddGroup( const char* Group)
378 _ListGroupSelected.push_back(Group);
380 //=============================================================================
383 //=============================================================================
384 void HOMARD_Hypothesis::SetTypeFieldInterp( int TypeFieldInterp )
386 ASSERT (!((TypeFieldInterp < -1) or (TypeFieldInterp > 2)));
387 _TypeFieldInterp = TypeFieldInterp;
390 //=============================================================================
393 //=============================================================================
394 int HOMARD_Hypothesis::GetTypeFieldInterp() const
396 return _TypeFieldInterp;
400 //=============================================================================
401 void HOMARD_Hypothesis::AddFieldInterp( const char* FieldInterp )
403 _ListFieldInterp.push_back( std::string( FieldInterp ) );
405 //=============================================================================
406 void HOMARD_Hypothesis::SupprFieldInterp()
408 std::cerr << "HOMARD_Hypothesis::SupprFieldInterpp" << std::endl;
409 _ListFieldInterp.clear();
411 //=============================================================================
412 const std::list<std::string>& HOMARD_Hypothesis::GetListFieldInterp() const
414 return _ListFieldInterp;
416 //=============================================================================
417 void HOMARD_Hypothesis::SetNivMax( int NivMax )
418 //=============================================================================
422 //=============================================================================
423 const int HOMARD_Hypothesis::GetNivMax() const
424 //=============================================================================
428 //=============================================================================
429 void HOMARD_Hypothesis::SetAdapInit( int AdapInit )
430 //=============================================================================
432 _AdapInit = AdapInit;
434 //=============================================================================
435 const int HOMARD_Hypothesis::GetAdapInit() const
436 //=============================================================================
440 //=============================================================================
441 void HOMARD_Hypothesis::SetDiamMin( double DiamMin )
442 //=============================================================================
446 //=============================================================================
447 const double HOMARD_Hypothesis::GetDiamMin() const
448 //=============================================================================
452 //=============================================================================
453 void HOMARD_Hypothesis::SetLevelOutput( int LevelOutput )
454 //=============================================================================
456 _LevelOutput = LevelOutput;
458 //=============================================================================
459 const int HOMARD_Hypothesis::GetLevelOutput() const
460 //=============================================================================