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;
123 aScript << ", " << _ThreshR << ")\n";
125 if ( _TypeDera == 1 )
127 aScript << "\t" << _NomHypo << ".SetUnRefThr(" << _TypeThC;
128 aScript << ", " << _ThreshC << ")\n";
132 // Filtrage du raffinement par des groupes
133 for ( it=_ListGroupSelected.begin(); it!=_ListGroupSelected.end();it++)
134 aScript << "\t" << _NomHypo << ".AddGroup(\"" << (*it) << "\")\n" ;
136 // Interpolation champ
137 aScript << "\t" << _NomHypo << ".SetTypeFieldInterp(" << _TypeFieldInterp << ")\n";
138 if ( _TypeFieldInterp == 2 )
140 std::list<std::string>::const_iterator it_champ = _ListFieldInterp.begin();
141 while(it_champ != _ListFieldInterp.end())
143 aScript << "\t" << _NomHypo << ".AddFieldInterp(\"" << *it_champ << "\")\n";
149 aScript << "\tNivMax = " << _NivMax << "\n";
150 aScript << "\t" <<_NomHypo << ".SetNivMax(NivMax)\n";
154 aScript << "\tDiamMin = " << _DiamMin << "\n";
155 aScript << "\t" <<_NomHypo << ".SetDiamMin(DiamMin)\n";
157 if ( _AdapInit != 0 )
159 aScript << "\tAdapInit = " << _AdapInit << "\n";
160 aScript << "\t" <<_NomHypo << ".SetAdapInit(AdapInit)\n";
163 return aScript.str();
167 //=============================================================================
170 //=============================================================================
171 void HOMARD_Hypothesis::SetAdapType( int TypeAdap )
173 ASSERT (!((TypeAdap < -1) or (TypeAdap > 1)));
174 _TypeAdap = TypeAdap;
177 //=============================================================================
180 //=============================================================================
181 int HOMARD_Hypothesis::GetAdapType() const
186 //=============================================================================
189 //=============================================================================
190 void HOMARD_Hypothesis::SetRefinTypeDera( int TypeRaff, int TypeDera )
192 ASSERT(!(( TypeRaff < 0) or (TypeRaff > 1)));
193 _TypeRaff = TypeRaff;
194 ASSERT(! ((TypeDera < 0) or (TypeDera > 1)));
195 _TypeDera = TypeDera;
198 //=============================================================================
201 //=============================================================================
202 int HOMARD_Hypothesis::GetRefinType() const
207 //=============================================================================
210 //=============================================================================
211 int HOMARD_Hypothesis::GetUnRefType() const
216 //=============================================================================
219 //=============================================================================
220 void HOMARD_Hypothesis::SetField( const char* FieldName )
222 _Field = std::string( FieldName );
223 MESSAGE( "SetField : FieldName = " << FieldName );
225 //=============================================================================
226 void HOMARD_Hypothesis::SetRefinThr( int TypeThR, double ThreshR )
228 MESSAGE( "SetRefinThr : TypeThR = " << TypeThR << ", ThreshR = " << ThreshR );
229 ASSERT(!(( TypeThR < 0) or (TypeThR > 3 )));
233 //=============================================================================
234 void HOMARD_Hypothesis::SetUnRefThr( int TypeThC, double ThreshC )
236 ASSERT(!((TypeThC < 0) or (TypeThC > 3)));
240 //=============================================================================
241 void HOMARD_Hypothesis::SetUseComp( int UsCmpI )
243 ASSERT(!((UsCmpI < 0) or (UsCmpI > 2)));
246 //=============================================================================
247 void HOMARD_Hypothesis::SetUseField( int UsField )
249 ASSERT(!((UsField < 0) or (UsField > 1 )));
253 //=============================================================================
256 //=============================================================================
257 std::string HOMARD_Hypothesis::GetFieldName() const
261 //=============================================================================
262 int HOMARD_Hypothesis::GetRefinThrType() const
266 //=============================================================================
267 double HOMARD_Hypothesis::GetThreshR() const
271 //=============================================================================
272 int HOMARD_Hypothesis::GetUnRefThrType() const
277 //=============================================================================
278 double HOMARD_Hypothesis::GetThreshC() const
282 //=============================================================================
283 int HOMARD_Hypothesis::GetUseField() const
287 //=============================================================================
288 int HOMARD_Hypothesis::GetUseCompI() const
292 //=============================================================================
295 //=============================================================================
296 void HOMARD_Hypothesis::AddIteration( const char* NomIteration )
298 _ListIter.push_back( std::string( NomIteration ) );
300 //=============================================================================
301 void HOMARD_Hypothesis::SupprIterations()
305 //=============================================================================
306 const std::list<std::string>& HOMARD_Hypothesis::GetIterations() const
310 //=============================================================================
313 //=============================================================================
314 void HOMARD_Hypothesis::AddZone( const char* NomZone, int TypeUse )
316 _ListZone.push_back( std::string( NomZone ) );
317 std::stringstream saux1 ;
319 std::string saux2 = saux1.str() ;
320 _ListZone.push_back( saux2 );
322 //=============================================================================
323 void HOMARD_Hypothesis::SupprZone( const char* NomZone )
325 std::list<std::string>::iterator it = find( _ListZone.begin(), _ListZone.end(), NomZone );
326 if ( it != _ListZone.end() )
328 _ListZone.erase( it );
331 //=============================================================================
332 void HOMARD_Hypothesis::SupprZones()
336 //=============================================================================
337 const std::list<std::string>& HOMARD_Hypothesis::GetZones() const
341 //=============================================================================
344 //=============================================================================
345 void HOMARD_Hypothesis::AddComp( const char* NomComposant )
347 _ListComposant.push_back( std::string( NomComposant ) );
349 //=============================================================================
350 void HOMARD_Hypothesis::SupprComp()
352 std::cerr << "HOMARD_Hypothesis::SupprComp" << std::endl;
353 _ListComposant.clear();
355 //=============================================================================
356 const std::list<std::string>& HOMARD_Hypothesis::GetListComp() const
358 return _ListComposant;
360 //=============================================================================
363 //=============================================================================
364 const std::list<std::string>& HOMARD_Hypothesis::GetGroups() const
366 return _ListGroupSelected;
368 //=============================================================================
369 void HOMARD_Hypothesis::SetGroups( const std::list<std::string>& ListGroup )
371 _ListGroupSelected.clear();
372 std::list<std::string>::const_iterator it = ListGroup.begin();
373 while(it != ListGroup.end())
374 _ListGroupSelected.push_back((*it++));
376 //=============================================================================
377 void HOMARD_Hypothesis::AddGroup( const char* Group)
379 _ListGroupSelected.push_back(Group);
381 //=============================================================================
384 //=============================================================================
385 void HOMARD_Hypothesis::SetTypeFieldInterp( int TypeFieldInterp )
387 ASSERT (!((TypeFieldInterp < -1) or (TypeFieldInterp > 2)));
388 _TypeFieldInterp = TypeFieldInterp;
391 //=============================================================================
394 //=============================================================================
395 int HOMARD_Hypothesis::GetTypeFieldInterp() const
397 return _TypeFieldInterp;
401 //=============================================================================
402 void HOMARD_Hypothesis::AddFieldInterp( const char* FieldInterp )
404 _ListFieldInterp.push_back( std::string( FieldInterp ) );
406 //=============================================================================
407 void HOMARD_Hypothesis::SupprFieldInterp()
409 std::cerr << "HOMARD_Hypothesis::SupprFieldInterpp" << std::endl;
410 _ListFieldInterp.clear();
412 //=============================================================================
413 const std::list<std::string>& HOMARD_Hypothesis::GetListFieldInterp() const
415 return _ListFieldInterp;
417 //=============================================================================
418 void HOMARD_Hypothesis::SetNivMax( int NivMax )
419 //=============================================================================
423 //=============================================================================
424 const int HOMARD_Hypothesis::GetNivMax() const
425 //=============================================================================
429 //=============================================================================
430 void HOMARD_Hypothesis::SetAdapInit( int AdapInit )
431 //=============================================================================
433 _AdapInit = AdapInit;
435 //=============================================================================
436 const int HOMARD_Hypothesis::GetAdapInit() const
437 //=============================================================================
441 //=============================================================================
442 void HOMARD_Hypothesis::SetDiamMin( double DiamMin )
443 //=============================================================================
447 //=============================================================================
448 const double HOMARD_Hypothesis::GetDiamMin() const
449 //=============================================================================