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