]> SALOME platform Git repositories - modules/homard.git/blob - src/HOMARD/HOMARD_Hypothesis.cxx
Salome HOME
PR: modifs Gerald 20120216
[modules/homard.git] / src / HOMARD / HOMARD_Hypothesis.cxx
1 //  HOMARD HOMARD : implementaion of HOMARD idl descriptions
2 //
3 // Copyright (C) 2011  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   while(it != _ListZone.end())
98   {
99       aScript << "\thomard.AssociateHypoZone(\""<< *it << "\", \"" <<_NomHypo << "\")\n";
100       it++;
101   }
102
103 // Raffinement selon un champ
104   if ( _TypeAdap == 1 )
105   {
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())
111     {
112       aScript << "\t" << _NomHypo << ".AddComp(\"" << *it_comp << "\")\n";
113       it_comp++;
114     }
115     if ( _TypeRaff == 1 )
116     {
117       aScript << "\t" << _NomHypo << ".SetRefinThr(" << _TypeThR;
118       aScript << ", " << _ThreshR << ")\n";
119     }
120     if ( _TypeDera == 1 )
121     {
122       aScript << "\t" << _NomHypo << ".SetUnRefThr(" << _TypeThC;
123       aScript << ", " << _ThreshC << ")\n";
124     }
125   }
126
127 // Filtrage du raffinement par des groupes
128    for ( it=_ListGroupSelected.begin(); it!=_ListGroupSelected.end();it++)
129        aScript << "\t" << _NomHypo << ".AddGroup(\""  << (*it) <<  "\")\n" ;
130
131 // Interpolation champ
132   aScript << "\t" << _NomHypo << ".SetTypeFieldInterp(" << _TypeFieldInterp << ")\n";
133   if ( _TypeFieldInterp == 2 )
134   {
135     std::list<std::string>::const_iterator it_champ = _ListFieldInterp.begin();
136     while(it_champ != _ListFieldInterp.end())
137     {
138       aScript << "\t" << _NomHypo << ".AddFieldInterp(\"" << *it_champ << "\")\n";
139       it_champ++;
140     }
141   }
142   if ( _NivMax > 0 )
143   {
144     aScript << "\t" <<_NomHypo << ".SetNivMax(";
145     aScript << _NivMax << ")\n";
146   }
147   if ( _DiamMin > 0 )
148   {
149     aScript << "\t" <<_NomHypo << ".SetDiamMin(";
150     aScript << _DiamMin << ")\n";
151   }
152
153   return aScript.str();
154 }
155
156
157 //=============================================================================
158 /*!
159 */
160 //=============================================================================
161 void HOMARD_Hypothesis::SetAdapType( int TypeAdap )
162 {
163   ASSERT (!((TypeAdap < -1) or (TypeAdap > 1)));
164   _TypeAdap = TypeAdap;
165 }
166
167 //=============================================================================
168 /*!
169 */
170 //=============================================================================
171 int HOMARD_Hypothesis::GetAdapType() const
172 {
173   return _TypeAdap;
174 }
175
176 //=============================================================================
177 /*!
178 */
179 //=============================================================================
180 void HOMARD_Hypothesis::SetRefinTypeDera( int TypeRaff, int TypeDera )
181 {
182   ASSERT(!(( TypeRaff < 0) or (TypeRaff > 1)));
183   _TypeRaff = TypeRaff;
184   ASSERT(! ((TypeDera < 0) or (TypeDera > 1)));
185   _TypeDera = TypeDera;
186 }
187
188 //=============================================================================
189 /*!
190 */
191 //=============================================================================
192 int HOMARD_Hypothesis::GetRefinType() const
193 {
194   return _TypeRaff;
195 }
196
197 //=============================================================================
198 /*!
199 */
200 //=============================================================================
201 int HOMARD_Hypothesis::GetUnRefType() const
202 {
203   return _TypeDera;
204 }
205
206 //=============================================================================
207 /*!
208 */
209 //=============================================================================
210 void HOMARD_Hypothesis::SetField( const char* FieldName )
211 {
212   _Field = std::string( FieldName );
213   MESSAGE( "SetField : FieldName = " << FieldName );
214 }
215 //=============================================================================
216 void HOMARD_Hypothesis::SetRefinThr( int TypeThR, double ThreshR )
217 {
218   MESSAGE( "SetRefinThr : TypeThR = " << TypeThR << ", ThreshR = " << ThreshR );
219   ASSERT(!(( TypeThR < 0) or (TypeThR > 3 )));
220   _TypeThR = TypeThR;
221   _ThreshR = ThreshR;
222 }
223 //=============================================================================
224 void HOMARD_Hypothesis::SetUnRefThr( int TypeThC, double ThreshC )
225 {
226   ASSERT(!((TypeThC < 0) or (TypeThC > 3)));
227   _TypeThC = TypeThC;
228   _ThreshC = ThreshC;
229 }
230 //=============================================================================
231 void HOMARD_Hypothesis::SetUseComp( int UsCmpI )
232 {
233   ASSERT(!((UsCmpI < 0) or (UsCmpI > 2)));
234   _UsCmpI = UsCmpI;
235 }
236 //=============================================================================
237 void HOMARD_Hypothesis::SetUseField( int UsField )
238 {
239   ASSERT(!((UsField < 0) or (UsField > 1 )));
240   _UsField = UsField;
241 }
242
243 //=============================================================================
244 /*!
245 */
246 //=============================================================================
247 std::string HOMARD_Hypothesis::GetFieldName() const
248 {
249   return _Field;
250 }
251 //=============================================================================
252 int HOMARD_Hypothesis::GetRefinThrType() const
253 {
254   return _TypeThR;
255 }
256 //=============================================================================
257 double HOMARD_Hypothesis::GetThreshR() const
258 {
259   return _ThreshR;
260 }
261 //=============================================================================
262 int HOMARD_Hypothesis::GetUnRefThrType() const
263 {
264   return _TypeThC;
265 }
266
267 //=============================================================================
268 double HOMARD_Hypothesis::GetThreshC() const
269 {
270   return _ThreshC;
271 }
272 //=============================================================================
273 int HOMARD_Hypothesis::GetUseField() const
274 {
275   return _UsField;
276 }
277 //=============================================================================
278 int HOMARD_Hypothesis::GetUseCompI() const
279 {
280   return _UsCmpI;
281 }
282 //=============================================================================
283 /*!
284 */
285 //=============================================================================
286 void HOMARD_Hypothesis::AddIteration( const char* NomIteration )
287 {
288   _ListIter.push_back( std::string( NomIteration ) );
289 }
290 //=============================================================================
291 void HOMARD_Hypothesis::SupprIterations()
292 {
293   _ListIter.clear();
294 }
295 //=============================================================================
296 const std::list<std::string>& HOMARD_Hypothesis::GetIterations() const
297 {
298   return _ListIter;
299 }
300 //=============================================================================
301 /*!
302 */
303 //=============================================================================
304 void HOMARD_Hypothesis::AddZone( const char* NomZone )
305 {
306   _ListZone.push_back( std::string( NomZone ) );
307 }
308 //=============================================================================
309 void HOMARD_Hypothesis::SupprZone( const char* NomZone )
310 {
311   std::list<std::string>::iterator it = find( _ListZone.begin(), _ListZone.end(), NomZone );
312   if ( it != _ListZone.end() )
313   {
314     _ListZone.erase( it );
315   }
316 }
317 //=============================================================================
318 void HOMARD_Hypothesis::SupprZones()
319 {
320   _ListZone.clear();
321 }
322 //=============================================================================
323 const std::list<std::string>& HOMARD_Hypothesis::GetZones() const
324 {
325   return _ListZone;
326 }
327 //=============================================================================
328 /*!
329 */
330 //=============================================================================
331 void HOMARD_Hypothesis::AddComp( const char* NomComposant )
332 {
333   _ListComposant.push_back( std::string( NomComposant ) );
334 }
335 //=============================================================================
336 void HOMARD_Hypothesis::SupprComp()
337 {
338   std::cerr << "HOMARD_Hypothesis::SupprComp" << std::endl;
339   _ListComposant.clear();
340 }
341 //=============================================================================
342 const std::list<std::string>& HOMARD_Hypothesis::GetListComp() const
343 {
344   return _ListComposant;
345 }
346 //=============================================================================
347 /*!
348 */
349 //=============================================================================
350 const std::list<std::string>& HOMARD_Hypothesis::GetGroups() const
351 {
352   return _ListGroupSelected;
353 }
354 //=============================================================================
355 void HOMARD_Hypothesis::SetGroups( const std::list<std::string>& ListGroup )
356 {
357   _ListGroupSelected.clear();
358   std::list<std::string>::const_iterator it = ListGroup.begin();
359   while(it != ListGroup.end())
360     _ListGroupSelected.push_back((*it++));
361 }
362 //=============================================================================
363 void HOMARD_Hypothesis::AddGroup( const char* Group)
364 {
365   _ListGroupSelected.push_back(Group);
366 }
367 //=============================================================================
368 /*!
369 */
370 //=============================================================================
371 void HOMARD_Hypothesis::SetTypeFieldInterp( int TypeFieldInterp )
372 {
373   ASSERT (!((TypeFieldInterp < -1) or (TypeFieldInterp > 2)));
374   _TypeFieldInterp = TypeFieldInterp;
375 }
376
377 //=============================================================================
378 /*!
379 */
380 //=============================================================================
381 int HOMARD_Hypothesis::GetTypeFieldInterp() const
382 {
383   return _TypeFieldInterp;
384 }
385 /*!
386 */
387 //=============================================================================
388 void HOMARD_Hypothesis::AddFieldInterp( const char* FieldInterp )
389 {
390   _ListFieldInterp.push_back( std::string( FieldInterp ) );
391 }
392 //=============================================================================
393 void HOMARD_Hypothesis::SupprFieldInterp()
394 {
395   std::cerr << "HOMARD_Hypothesis::SupprFieldInterpp" << std::endl;
396   _ListFieldInterp.clear();
397 }
398 //=============================================================================
399 const std::list<std::string>& HOMARD_Hypothesis::GetListFieldInterp() const
400 {
401   return _ListFieldInterp;
402 }
403 //=============================================================================
404 void HOMARD_Hypothesis::SetNivMax( int NivMax )
405 //=============================================================================
406 {
407   _NivMax = NivMax;
408 }
409 //=============================================================================
410 const int HOMARD_Hypothesis::GetNivMax() const
411 //=============================================================================
412 {
413   return _NivMax;
414 }
415 //=============================================================================
416 void HOMARD_Hypothesis::SetDiamMin( double DiamMin )
417 //=============================================================================
418 {
419   _DiamMin = DiamMin;
420 /*  if ( _NivMax < 0 )
421   {
422     _NivMax = 99 ;
423   }*/
424 }
425 //=============================================================================
426 const double HOMARD_Hypothesis::GetDiamMin() const
427 //=============================================================================
428 {
429   return _DiamMin;
430 }