]> SALOME platform Git repositories - modules/homard.git/blob - src/HOMARD/HOMARD_Hypothesis.cxx
Salome HOME
Merge from V6_main 13/12/2012
[modules/homard.git] / src / HOMARD / HOMARD_Hypothesis.cxx
1 //  HOMARD HOMARD : implementaion of HOMARD idl descriptions
2 //
3 // Copyright (C) 2011-2012  CEA/DEN, EDF R&D
4 //
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.
9 //
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.
14 //
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
18 //
19 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 //
21 //  File   : HOMARD_Hypothesis.cxx
22 //  Author : Paul RASCLE, EDF
23 //  Module : HOMARD
24
25 #include "HOMARD_Hypothesis.hxx"
26 #include "utilities.h"
27
28 //=============================================================================
29 /*!
30  *  default constructor:
31  */
32 //=============================================================================
33 HOMARD_Hypothesis::HOMARD_Hypothesis():
34   _NomHypo(""), _NomCasCreation(""),
35   _TypeAdap(-1), _TypeRaff(0), _TypeDera(0),
36   _Field(""),
37   _TypeThR(0), _ThreshR(0),
38   _TypeThC(0), _ThreshC(0),
39   _UsField(0), _UsCmpI(0),  _TypeFieldInterp(0)
40 {
41   MESSAGE("HOMARD_Hypothesis");
42 }
43
44 //=============================================================================
45 /*!
46  */
47 //=============================================================================
48 HOMARD_Hypothesis::~HOMARD_Hypothesis()
49 {
50   MESSAGE("~HOMARD_Hypothesis");
51 }
52
53 //=============================================================================
54 /*!
55  */
56 //=============================================================================
57 void HOMARD_Hypothesis::SetCaseCreation( const char* NomCasCreation )
58 {
59   _NomCasCreation = std::string( NomCasCreation );
60 }
61
62 //=============================================================================
63 /*!
64 */
65 //=============================================================================
66 std::string HOMARD_Hypothesis::GetCaseCreation() const
67 {
68   return _NomCasCreation;
69 }
70 //=============================================================================
71 /*!
72 */
73 //=============================================================================
74 void HOMARD_Hypothesis::SetName( const char* NomHypo )
75 {
76   _NomHypo = std::string( NomHypo );
77 }
78
79 //=============================================================================
80 /*!
81 */
82 //=============================================================================
83 std::string HOMARD_Hypothesis::GetName() const
84 {
85   return _NomHypo;
86 }
87 //=============================================================================
88 std::string HOMARD_Hypothesis::GetDumpPython() const
89 {
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";
94
95 // Raffinement selon des zones geometriques
96   std::list<std::string>::const_iterator it = _ListZone.begin();
97   int TypeUse ;
98   while(it != _ListZone.end())
99   {
100       aScript << "\thomard.AssociateHypoZone(\""<< _NomHypo << "\", \"" << *it;
101       it++;
102       if ( *it == "1" ) { TypeUse =  1 ; }
103       else              { TypeUse = -1 ; }
104       aScript << "\", " << TypeUse << ")\n";
105       it++;
106   }
107
108 // Raffinement selon un champ
109   if ( _TypeAdap == 1 )
110   {
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())
116     {
117       aScript << "\t" << _NomHypo << ".AddComp(\"" << *it_comp << "\")\n";
118       it_comp++;
119     }
120     if ( _TypeRaff == 1 )
121     {
122       aScript << "\t" << _NomHypo << ".SetRefinThr(" << _TypeThR << ", " << _ThreshR << ")\n";
123     }
124     if ( _TypeDera == 1 )
125     {
126       aScript << "\t" << _NomHypo << ".SetUnRefThr(" << _TypeThC << ", " << _ThreshC << ")\n";
127     }
128   }
129
130 // Filtrage du raffinement par des groupes
131    for ( it=_ListGroupSelected.begin(); it!=_ListGroupSelected.end();it++)
132        aScript << "\t" << _NomHypo << ".AddGroup(\""  << (*it) <<  "\")\n" ;
133
134 // Interpolation champ
135   aScript << "\t" << _NomHypo << ".SetTypeFieldInterp(" << _TypeFieldInterp << ")\n";
136   if ( _TypeFieldInterp == 2 )
137   {
138     std::list<std::string>::const_iterator it_champ = _ListFieldInterp.begin();
139     while(it_champ != _ListFieldInterp.end())
140     {
141       aScript << "\t" << _NomHypo << ".AddFieldInterp(\"" << *it_champ << "\")\n";
142       it_champ++;
143     }
144   }
145   if ( _NivMax > 0 )
146   {
147     aScript << "\t" <<_NomHypo << ".SetNivMax(" << _NivMax << ")\n";
148   }
149   if ( _DiamMin > 0 )
150   {
151     aScript << "\t" <<_NomHypo << ".SetDiamMin(" << _DiamMin << ")\n";
152   }
153   if ( _AdapInit != 0 )
154   {
155     aScript << "\t" <<_NomHypo << ".SetAdapInit(" << _AdapInit << ")\n";
156   }
157   if ( _LevelOutput != 0 )
158   {
159     aScript << "\t" <<_NomHypo << ".SetLevelOutput(" << _LevelOutput << ")\n";
160   }
161
162   return aScript.str();
163 }
164
165
166 //=============================================================================
167 /*!
168 */
169 //=============================================================================
170 void HOMARD_Hypothesis::SetAdapType( int TypeAdap )
171 {
172   ASSERT (!((TypeAdap < -1) or (TypeAdap > 1)));
173   _TypeAdap = TypeAdap;
174 }
175
176 //=============================================================================
177 /*!
178 */
179 //=============================================================================
180 int HOMARD_Hypothesis::GetAdapType() const
181 {
182   return _TypeAdap;
183 }
184
185 //=============================================================================
186 /*!
187 */
188 //=============================================================================
189 void HOMARD_Hypothesis::SetRefinTypeDera( int TypeRaff, int TypeDera )
190 {
191   ASSERT(!(( TypeRaff < 0) or (TypeRaff > 1)));
192   _TypeRaff = TypeRaff;
193   ASSERT(! ((TypeDera < 0) or (TypeDera > 1)));
194   _TypeDera = TypeDera;
195 }
196
197 //=============================================================================
198 /*!
199 */
200 //=============================================================================
201 int HOMARD_Hypothesis::GetRefinType() const
202 {
203   return _TypeRaff;
204 }
205
206 //=============================================================================
207 /*!
208 */
209 //=============================================================================
210 int HOMARD_Hypothesis::GetUnRefType() const
211 {
212   return _TypeDera;
213 }
214
215 //=============================================================================
216 /*!
217 */
218 //=============================================================================
219 void HOMARD_Hypothesis::SetField( const char* FieldName )
220 {
221   _Field = std::string( FieldName );
222   MESSAGE( "SetField : FieldName = " << FieldName );
223 }
224 //=============================================================================
225 void HOMARD_Hypothesis::SetRefinThr( int TypeThR, double ThreshR )
226 {
227   MESSAGE( "SetRefinThr : TypeThR = " << TypeThR << ", ThreshR = " << ThreshR );
228   ASSERT(!(( TypeThR < 0) or (TypeThR > 3 )));
229   _TypeThR = TypeThR;
230   _ThreshR = ThreshR;
231 }
232 //=============================================================================
233 void HOMARD_Hypothesis::SetUnRefThr( int TypeThC, double ThreshC )
234 {
235   ASSERT(!((TypeThC < 0) or (TypeThC > 3)));
236   _TypeThC = TypeThC;
237   _ThreshC = ThreshC;
238 }
239 //=============================================================================
240 void HOMARD_Hypothesis::SetUseComp( int UsCmpI )
241 {
242   ASSERT(!((UsCmpI < 0) or (UsCmpI > 2)));
243   _UsCmpI = UsCmpI;
244 }
245 //=============================================================================
246 void HOMARD_Hypothesis::SetUseField( int UsField )
247 {
248   ASSERT(!((UsField < 0) or (UsField > 1 )));
249   _UsField = UsField;
250 }
251
252 //=============================================================================
253 /*!
254 */
255 //=============================================================================
256 std::string HOMARD_Hypothesis::GetFieldName() const
257 {
258   return _Field;
259 }
260 //=============================================================================
261 int HOMARD_Hypothesis::GetRefinThrType() const
262 {
263   return _TypeThR;
264 }
265 //=============================================================================
266 double HOMARD_Hypothesis::GetThreshR() const
267 {
268   return _ThreshR;
269 }
270 //=============================================================================
271 int HOMARD_Hypothesis::GetUnRefThrType() const
272 {
273   return _TypeThC;
274 }
275
276 //=============================================================================
277 double HOMARD_Hypothesis::GetThreshC() const
278 {
279   return _ThreshC;
280 }
281 //=============================================================================
282 int HOMARD_Hypothesis::GetUseField() const
283 {
284   return _UsField;
285 }
286 //=============================================================================
287 int HOMARD_Hypothesis::GetUseCompI() const
288 {
289   return _UsCmpI;
290 }
291 //=============================================================================
292 /*!
293 */
294 //=============================================================================
295 void HOMARD_Hypothesis::AddIteration( const char* NomIteration )
296 {
297   _ListIter.push_back( std::string( NomIteration ) );
298 }
299 //=============================================================================
300 void HOMARD_Hypothesis::SupprIterations()
301 {
302   _ListIter.clear();
303 }
304 //=============================================================================
305 const std::list<std::string>& HOMARD_Hypothesis::GetIterations() const
306 {
307   return _ListIter;
308 }
309 //=============================================================================
310 /*!
311 */
312 //=============================================================================
313 void HOMARD_Hypothesis::AddZone( const char* NomZone, int TypeUse )
314 {
315   _ListZone.push_back( std::string( NomZone ) );
316   std::stringstream saux1 ;
317   saux1 << TypeUse ;
318   std::string saux2 = saux1.str() ;
319   _ListZone.push_back( saux2 );
320 }
321 //=============================================================================
322 void HOMARD_Hypothesis::SupprZone( const char* NomZone )
323 {
324   std::list<std::string>::iterator it = find( _ListZone.begin(), _ListZone.end(), NomZone );
325   if ( it != _ListZone.end() )
326   {
327     _ListZone.erase( it );
328   }
329 }
330 //=============================================================================
331 void HOMARD_Hypothesis::SupprZones()
332 {
333   _ListZone.clear();
334 }
335 //=============================================================================
336 const std::list<std::string>& HOMARD_Hypothesis::GetZones() const
337 {
338   return _ListZone;
339 }
340 //=============================================================================
341 /*!
342 */
343 //=============================================================================
344 void HOMARD_Hypothesis::AddComp( const char* NomComposant )
345 {
346   _ListComposant.push_back( std::string( NomComposant ) );
347 }
348 //=============================================================================
349 void HOMARD_Hypothesis::SupprComp()
350 {
351   std::cerr << "HOMARD_Hypothesis::SupprComp" << std::endl;
352   _ListComposant.clear();
353 }
354 //=============================================================================
355 const std::list<std::string>& HOMARD_Hypothesis::GetListComp() const
356 {
357   return _ListComposant;
358 }
359 //=============================================================================
360 /*!
361 */
362 //=============================================================================
363 const std::list<std::string>& HOMARD_Hypothesis::GetGroups() const
364 {
365   return _ListGroupSelected;
366 }
367 //=============================================================================
368 void HOMARD_Hypothesis::SetGroups( const std::list<std::string>& ListGroup )
369 {
370   _ListGroupSelected.clear();
371   std::list<std::string>::const_iterator it = ListGroup.begin();
372   while(it != ListGroup.end())
373     _ListGroupSelected.push_back((*it++));
374 }
375 //=============================================================================
376 void HOMARD_Hypothesis::AddGroup( const char* Group)
377 {
378   _ListGroupSelected.push_back(Group);
379 }
380 //=============================================================================
381 /*!
382 */
383 //=============================================================================
384 void HOMARD_Hypothesis::SetTypeFieldInterp( int TypeFieldInterp )
385 {
386   ASSERT (!((TypeFieldInterp < -1) or (TypeFieldInterp > 2)));
387   _TypeFieldInterp = TypeFieldInterp;
388 }
389
390 //=============================================================================
391 /*!
392 */
393 //=============================================================================
394 int HOMARD_Hypothesis::GetTypeFieldInterp() const
395 {
396   return _TypeFieldInterp;
397 }
398 /*!
399 */
400 //=============================================================================
401 void HOMARD_Hypothesis::AddFieldInterp( const char* FieldInterp )
402 {
403   _ListFieldInterp.push_back( std::string( FieldInterp ) );
404 }
405 //=============================================================================
406 void HOMARD_Hypothesis::SupprFieldInterp()
407 {
408   std::cerr << "HOMARD_Hypothesis::SupprFieldInterpp" << std::endl;
409   _ListFieldInterp.clear();
410 }
411 //=============================================================================
412 const std::list<std::string>& HOMARD_Hypothesis::GetListFieldInterp() const
413 {
414   return _ListFieldInterp;
415 }
416 //=============================================================================
417 void HOMARD_Hypothesis::SetNivMax( int NivMax )
418 //=============================================================================
419 {
420   _NivMax = NivMax;
421 }
422 //=============================================================================
423 const int HOMARD_Hypothesis::GetNivMax() const
424 //=============================================================================
425 {
426   return _NivMax;
427 }
428 //=============================================================================
429 void HOMARD_Hypothesis::SetAdapInit( int AdapInit )
430 //=============================================================================
431 {
432   _AdapInit = AdapInit;
433 }
434 //=============================================================================
435 const int HOMARD_Hypothesis::GetAdapInit() const
436 //=============================================================================
437 {
438   return _AdapInit;
439 }
440 //=============================================================================
441 void HOMARD_Hypothesis::SetDiamMin( double DiamMin )
442 //=============================================================================
443 {
444   _DiamMin = DiamMin;
445 }
446 //=============================================================================
447 const double HOMARD_Hypothesis::GetDiamMin() const
448 //=============================================================================
449 {
450   return _DiamMin;
451 }
452 //=============================================================================
453 void HOMARD_Hypothesis::SetLevelOutput( int LevelOutput )
454 //=============================================================================
455 {
456   _LevelOutput = LevelOutput;
457 }
458 //=============================================================================
459 const int HOMARD_Hypothesis::GetLevelOutput() const
460 //=============================================================================
461 {
462   return _LevelOutput;
463 }