1 // HOMARD HOMARD : implementaion of HOMARD idl descriptions
3 // Copyright (C) 2011 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();
97 while(it != _ListZone.end())
99 aScript << "\thomard.AssociateHypoZone('"<< *it << "', '" <<_NomHypo << "')\n";
103 // Raffinement selon un champ
104 if ( _TypeAdap == 1 )
106 aScript << "\t" << _NomHypo << ".SetField('" << _Field << "')\n";
107 aScript << "\t" << _NomHypo << ".SetUseField(" << _UsField << ")\n";
108 aScript << "\t" << _NomHypo << ".SetUseComp(" << _UsCmpI << ")\n";
109 std::list<std::string>::const_iterator it_comp = _ListComposant.begin();
110 while(it_comp != _ListComposant.end())
112 aScript << "\t" << _NomHypo << ".AddComp('" << *it_comp << "')\n";
115 if ( _TypeRaff == 1 )
117 aScript << "\t" << _NomHypo << ".SetRefinThr(" << _TypeThR;
118 aScript << ", " << _ThreshR << ")\n";
120 if ( _TypeDera == 1 )
122 aScript << "\t" << _NomHypo << ".SetUnRefThr(" << _TypeThC;
123 aScript << ", " << _ThreshC << ")\n";
127 // Filtrage du raffinement par des groupes
128 for ( it=_ListGroupSelected.begin(); it!=_ListGroupSelected.end();it++)
129 aScript << "\t" << _NomHypo << ".AddGroup('" << (*it) << "')\n" ;
131 // Interpolation champ
132 aScript << "\t" << _NomHypo << ".SetTypeFieldInterp(" << _TypeFieldInterp << ")\n";
133 if ( _TypeFieldInterp == 2 )
135 std::list<std::string>::const_iterator it_champ = _ListFieldInterp.begin();
136 while(it_champ != _ListFieldInterp.end())
138 aScript << "\t" << _NomHypo << ".AddFieldInterp('" << *it_champ << "')\n";
144 aScript << "\t" <<_NomHypo << ".SetNivMax(";
145 aScript << _NivMax << ")\n";
146 aScript << "\t" <<_NomHypo << ".SetDiamMin(";
147 aScript << _DiamMin << ")\n";
150 return aScript.str();
154 //=============================================================================
157 //=============================================================================
158 void HOMARD_Hypothesis::SetAdapType( int TypeAdap )
160 ASSERT (!((TypeAdap < -1) or (TypeAdap > 1)));
161 _TypeAdap = TypeAdap;
164 //=============================================================================
167 //=============================================================================
168 int HOMARD_Hypothesis::GetAdapType() const
173 //=============================================================================
176 //=============================================================================
177 void HOMARD_Hypothesis::SetRefinTypeDera( int TypeRaff, int TypeDera )
179 ASSERT(!(( TypeRaff < 0) or (TypeRaff > 1)));
180 _TypeRaff = TypeRaff;
181 ASSERT(! ((TypeDera < 0) or (TypeDera > 1)));
182 _TypeDera = TypeDera;
185 //=============================================================================
188 //=============================================================================
189 int HOMARD_Hypothesis::GetRefinType() const
194 //=============================================================================
197 //=============================================================================
198 int HOMARD_Hypothesis::GetUnRefType() const
203 //=============================================================================
206 //=============================================================================
207 void HOMARD_Hypothesis::SetField( const char* FieldName )
209 _Field = std::string( FieldName );
210 MESSAGE( "SetField : FieldName = " << FieldName );
212 //=============================================================================
213 void HOMARD_Hypothesis::SetRefinThr( int TypeThR, double ThreshR )
215 MESSAGE( "SetRefinThr : TypeThR = " << TypeThR << ", ThreshR = " << ThreshR );
216 ASSERT(!(( TypeThR < 0) or (TypeThR > 3 )));
220 //=============================================================================
221 void HOMARD_Hypothesis::SetUnRefThr( int TypeThC, double ThreshC )
223 ASSERT(!((TypeThC < 0) or (TypeThC > 3)));
227 //=============================================================================
228 void HOMARD_Hypothesis::SetUseComp( int UsCmpI )
230 ASSERT(!((UsCmpI < 0) or (UsCmpI > 2)));
233 //=============================================================================
234 void HOMARD_Hypothesis::SetUseField( int UsField )
236 ASSERT(!((UsField < 0) or (UsField > 1 )));
240 //=============================================================================
243 //=============================================================================
244 std::string HOMARD_Hypothesis::GetFieldName() const
248 //=============================================================================
249 int HOMARD_Hypothesis::GetRefinThrType() const
253 //=============================================================================
254 double HOMARD_Hypothesis::GetThreshR() const
258 //=============================================================================
259 int HOMARD_Hypothesis::GetUnRefThrType() const
264 //=============================================================================
265 double HOMARD_Hypothesis::GetThreshC() const
269 //=============================================================================
270 int HOMARD_Hypothesis::GetUseField() const
274 //=============================================================================
275 int HOMARD_Hypothesis::GetUseCompI() const
279 //=============================================================================
282 //=============================================================================
283 void HOMARD_Hypothesis::AddIteration( const char* NomIteration )
285 _ListIter.push_back( std::string( NomIteration ) );
287 //=============================================================================
288 void HOMARD_Hypothesis::SupprIterations()
292 //=============================================================================
293 const std::list<std::string>& HOMARD_Hypothesis::GetIterations() const
297 //=============================================================================
300 //=============================================================================
301 void HOMARD_Hypothesis::AddZone( const char* NomZone )
303 _ListZone.push_back( std::string( NomZone ) );
305 //=============================================================================
306 void HOMARD_Hypothesis::SupprZone( const char* NomZone )
308 std::list<std::string>::iterator it = find( _ListZone.begin(), _ListZone.end(), NomZone );
309 if ( it != _ListZone.end() )
311 _ListZone.erase( it );
314 //=============================================================================
315 void HOMARD_Hypothesis::SupprZones()
319 //=============================================================================
320 const std::list<std::string>& HOMARD_Hypothesis::GetZones() const
324 //=============================================================================
327 //=============================================================================
328 void HOMARD_Hypothesis::AddComp( const char* NomComposant )
330 _ListComposant.push_back( std::string( NomComposant ) );
332 //=============================================================================
333 void HOMARD_Hypothesis::SupprComp()
335 std::cerr << "HOMARD_Hypothesis::SupprComp" << std::endl;
336 _ListComposant.clear();
338 //=============================================================================
339 const std::list<std::string>& HOMARD_Hypothesis::GetListComp() const
341 return _ListComposant;
343 //=============================================================================
346 //=============================================================================
347 const std::list<std::string>& HOMARD_Hypothesis::GetGroups() const
349 return _ListGroupSelected;
351 //=============================================================================
352 void HOMARD_Hypothesis::SetGroups( const std::list<std::string>& ListGroup )
354 _ListGroupSelected.clear();
355 std::list<std::string>::const_iterator it = ListGroup.begin();
356 while(it != ListGroup.end())
357 _ListGroupSelected.push_back((*it++));
359 //=============================================================================
360 void HOMARD_Hypothesis::AddGroup( const char* Group)
362 _ListGroupSelected.push_back(Group);
364 //=============================================================================
367 //=============================================================================
368 void HOMARD_Hypothesis::SetTypeFieldInterp( int TypeFieldInterp )
370 ASSERT (!((TypeFieldInterp < -1) or (TypeFieldInterp > 2)));
371 _TypeFieldInterp = TypeFieldInterp;
374 //=============================================================================
377 //=============================================================================
378 int HOMARD_Hypothesis::GetTypeFieldInterp() const
380 return _TypeFieldInterp;
384 //=============================================================================
385 void HOMARD_Hypothesis::AddFieldInterp( const char* FieldInterp )
387 _ListFieldInterp.push_back( std::string( FieldInterp ) );
389 //=============================================================================
390 void HOMARD_Hypothesis::SupprFieldInterp()
392 std::cerr << "HOMARD_Hypothesis::SupprFieldInterpp" << std::endl;
393 _ListFieldInterp.clear();
395 //=============================================================================
396 const std::list<std::string>& HOMARD_Hypothesis::GetListFieldInterp() const
398 return _ListFieldInterp;
400 //=============================================================================
401 void HOMARD_Hypothesis::SetNivMax( int NivMax )
402 //=============================================================================
406 //=============================================================================
407 const int HOMARD_Hypothesis::GetNivMax() const
408 //=============================================================================
412 //=============================================================================
413 void HOMARD_Hypothesis::SetDiamMin( double DiamMin )
414 //=============================================================================
422 //=============================================================================
423 const double HOMARD_Hypothesis::GetDiamMin() const
424 //=============================================================================