]> SALOME platform Git repositories - modules/homard.git/blob - src/HOMARD/HOMARD_Hypothesis.cxx
Salome HOME
e5640d6fc1bdb15f826b5d9fc1a096662e96eab6
[modules/homard.git] / src / HOMARD / HOMARD_Hypothesis.cxx
1 //  HOMARD HOMARD : implementation of HOMARD idl descriptions
2 //
3 // Copyright (C) 2011-2013  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 // Remarques :
26 // L'ordre de description des fonctions est le meme dans tous les fichiers
27 // HOMARD_aaaa.idl, HOMARD_aaaa.hxx, HOMARD_aaaa.cxx, HOMARD_aaaa_i.hxx, HOMARD_aaaa_i.cxx :
28 // 1. Les generalites : Name, Delete, DumpPython, Dump, Restore
29 // 2. Les caracteristiques
30 // 3. Le lien avec les autres structures
31 //
32 // Quand les 2 fonctions Setxxx et Getxxx sont presentes, Setxxx est decrit en premier
33
34 #include "HOMARD_Hypothesis.hxx"
35 #include "utilities.h"
36
37 //=============================================================================
38 /*!
39  *  default constructor:
40  */
41 //=============================================================================
42 HOMARD_Hypothesis::HOMARD_Hypothesis():
43   _Name(""), _NomCasCreation(""),
44   _TypeAdap(-1), _TypeRaff(0), _TypeDera(0),
45   _Field(""),
46   _TypeThR(0), _ThreshR(0),
47   _TypeThC(0), _ThreshC(0),
48   _UsField(0), _UsCmpI(0),  _TypeFieldInterp(0)
49 {
50   MESSAGE("HOMARD_Hypothesis");
51 }
52
53 //=============================================================================
54 /*!
55  */
56 //=============================================================================
57 HOMARD_Hypothesis::~HOMARD_Hypothesis()
58 {
59   MESSAGE("~HOMARD_Hypothesis");
60 }
61 //=============================================================================
62 //=============================================================================
63 // Generalites
64 //=============================================================================
65 //=============================================================================
66 void HOMARD_Hypothesis::SetName( const char* Name )
67 {
68   _Name = std::string( Name );
69 }
70 //=============================================================================
71 std::string HOMARD_Hypothesis::GetName() const
72 {
73   return _Name;
74 }
75 //=============================================================================
76 std::string HOMARD_Hypothesis::GetDumpPython() const
77 {
78   std::ostringstream aScript;
79   aScript << "\n# Creation of the hypothesis " << _Name << "\n" ;
80   aScript << "\t" << _Name << " = homard.CreateHypothesis(\"" << _Name << "\")\n";
81   aScript << "\t" << _Name << ".SetAdapRefinUnRef(" << _TypeAdap << ", " << _TypeRaff << ", " << _TypeDera << ")\n";
82
83 // Raffinement selon des zones geometriques
84   std::list<std::string>::const_iterator it = _ListZone.begin();
85   int TypeUse ;
86   while(it != _ListZone.end())
87   {
88       aScript << "\t" << _Name << ".AddZone(\"" << *it;
89       it++;
90       if ( *it == "1" ) { TypeUse =  1 ; }
91       else              { TypeUse = -1 ; }
92       aScript << "\", " << TypeUse << ")\n";
93       it++;
94   }
95
96 // Raffinement selon un champ
97   if ( _TypeAdap == 1 )
98   {
99     aScript << "\t" << _Name << ".SetField(\"" << _Field << "\")\n";
100     aScript << "\t" << _Name << ".SetUseField(" << _UsField << ")\n";
101     aScript << "\t" << _Name << ".SetUseComp(" << _UsCmpI << ")\n";
102     std::list<std::string>::const_iterator it_comp = _ListComp.begin();
103     while(it_comp != _ListComp.end())
104     {
105       aScript << "\t" << _Name << ".AddComp(\"" << *it_comp << "\")\n";
106       it_comp++;
107     }
108     if ( _TypeRaff == 1 )
109     {
110       aScript << "\t" << _Name << ".SetRefinThr(" << _TypeThR << ", " << _ThreshR << ")\n";
111     }
112     if ( _TypeDera == 1 )
113     {
114       aScript << "\t" << _Name << ".SetUnRefThr(" << _TypeThC << ", " << _ThreshC << ")\n";
115     }
116   }
117
118 // Filtrage du raffinement par des groupes
119    for ( it=_ListGroupSelected.begin(); it!=_ListGroupSelected.end();it++)
120        aScript << "\t" << _Name << ".AddGroup(\""  << (*it) <<  "\")\n" ;
121
122 // Interpolation champ
123   aScript << "\t" << _Name << ".SetTypeFieldInterp(" << _TypeFieldInterp << ")\n";
124   if ( _TypeFieldInterp == 2 )
125   {
126     std::list<std::string>::const_iterator it_champ = _ListFieldInterp.begin();
127     while(it_champ != _ListFieldInterp.end())
128     {
129       aScript << "\t" << _Name << ".AddFieldInterp(\"" << *it_champ << "\")\n";
130       it_champ++;
131     }
132   }
133   if ( _NivMax > 0 )
134   {
135     aScript << "\t" <<_Name << ".SetNivMax(" << _NivMax << ")\n";
136   }
137   if ( _DiamMin > 0 )
138   {
139     aScript << "\t" <<_Name << ".SetDiamMin(" << _DiamMin << ")\n";
140   }
141   if ( _AdapInit != 0 )
142   {
143     aScript << "\t" <<_Name << ".SetAdapInit(" << _AdapInit << ")\n";
144   }
145   if ( _LevelOutput != 0 )
146   {
147     aScript << "\t" <<_Name << ".SetLevelOutput(" << _LevelOutput << ")\n";
148   }
149
150   return aScript.str();
151 }
152 //=============================================================================
153 //=============================================================================
154 // Caracteristiques
155 //=============================================================================
156 //=============================================================================
157 void HOMARD_Hypothesis::SetAdapType( int TypeAdap )
158 {
159   ASSERT (!((TypeAdap < -1) or (TypeAdap > 1)));
160   _TypeAdap = TypeAdap;
161 }
162 //=============================================================================
163 int HOMARD_Hypothesis::GetAdapType() const
164 {
165   return _TypeAdap;
166 }
167 //=============================================================================
168 void HOMARD_Hypothesis::SetRefinTypeDera( int TypeRaff, int TypeDera )
169 {
170   ASSERT(!(( TypeRaff < 0) or (TypeRaff > 1)));
171   _TypeRaff = TypeRaff;
172   ASSERT(! ((TypeDera < 0) or (TypeDera > 1)));
173   _TypeDera = TypeDera;
174 }
175 //=============================================================================
176 int HOMARD_Hypothesis::GetRefinType() const
177 {
178   return _TypeRaff;
179 }
180 //=============================================================================
181 int HOMARD_Hypothesis::GetUnRefType() const
182 {
183   return _TypeDera;
184 }
185 //=============================================================================
186 void HOMARD_Hypothesis::SetField( const char* FieldName )
187 {
188   _Field = std::string( FieldName );
189   MESSAGE( "SetField : FieldName = " << FieldName );
190 }
191 //=============================================================================
192 std::string HOMARD_Hypothesis::GetFieldName() const
193 {
194   return _Field;
195 }
196 //=============================================================================
197 void HOMARD_Hypothesis::SetUseField( int UsField )
198 {
199   ASSERT(!((UsField < 0) or (UsField > 1 )));
200   _UsField = UsField;
201 }
202 //=============================================================================
203 int HOMARD_Hypothesis::GetUseField() const
204 {
205   return _UsField;
206 }
207 //=============================================================================
208 void HOMARD_Hypothesis::SetUseComp( int UsCmpI )
209 {
210   ASSERT(!((UsCmpI < 0) or (UsCmpI > 2)));
211   _UsCmpI = UsCmpI;
212 }
213 //=============================================================================
214 int HOMARD_Hypothesis::GetUseComp() const
215 {
216   return _UsCmpI;
217 }
218 //=============================================================================
219 void HOMARD_Hypothesis::AddComp( const char* NomComp )
220 {
221 // On commence par la supprimer au cas ou elle aurait deja ete inseree
222 // Cela peut se produire dans un schema YACS quand on repasse plusieurs fois par la
223 // definition de l'hypothese
224   SupprComp( NomComp ) ;
225 // Insertion veritable
226   _ListComp.push_back( std::string( NomComp ) );
227 }
228 //=============================================================================
229 void HOMARD_Hypothesis::SupprComp( const char* NomComp )
230 {
231   MESSAGE ("SupprComp pour "<<NomComp) ;
232   std::list<std::string>::iterator it = find( _ListComp.begin(), _ListComp.end(), NomComp );
233   if ( it != _ListComp.end() ) { it = _ListComp.erase( it ); }
234 }
235 //=============================================================================
236 void HOMARD_Hypothesis::SupprComps()
237 {
238   _ListComp.clear();
239 }
240 //=============================================================================
241 const std::list<std::string>& HOMARD_Hypothesis::GetComps() const
242 {
243   return _ListComp;
244 }
245 //=============================================================================
246 void HOMARD_Hypothesis::SetRefinThr( int TypeThR, double ThreshR )
247 {
248   MESSAGE( "SetRefinThr : TypeThR = " << TypeThR << ", ThreshR = " << ThreshR );
249   ASSERT(!(( TypeThR < 0) or (TypeThR > 4 )));
250   _TypeThR = TypeThR;
251   _ThreshR = ThreshR;
252 }
253 //=============================================================================
254 int HOMARD_Hypothesis::GetRefinThrType() const
255 {
256   return _TypeThR;
257 }
258 //=============================================================================
259 double HOMARD_Hypothesis::GetThreshR() const
260 {
261   return _ThreshR;
262 }
263 //=============================================================================
264 void HOMARD_Hypothesis::SetUnRefThr( int TypeThC, double ThreshC )
265 {
266   ASSERT(!((TypeThC < 0) or (TypeThC > 4)));
267   _TypeThC = TypeThC;
268   _ThreshC = ThreshC;
269 }
270 //=============================================================================
271 int HOMARD_Hypothesis::GetUnRefThrType() const
272 {
273   return _TypeThC;
274 }
275 //=============================================================================
276 double HOMARD_Hypothesis::GetThreshC() const
277 {
278   return _ThreshC;
279 }
280 //=============================================================================
281 void HOMARD_Hypothesis::SetNivMax( int NivMax )
282 //=============================================================================
283 {
284   _NivMax = NivMax;
285 }
286 //=============================================================================
287 const int HOMARD_Hypothesis::GetNivMax() const
288 //=============================================================================
289 {
290   return _NivMax;
291 }
292 //=============================================================================
293 void HOMARD_Hypothesis::SetDiamMin( double DiamMin )
294 //=============================================================================
295 {
296   _DiamMin = DiamMin;
297 }
298 //=============================================================================
299 const double HOMARD_Hypothesis::GetDiamMin() const
300 //=============================================================================
301 {
302   return _DiamMin;
303 }
304 //=============================================================================
305 void HOMARD_Hypothesis::SetAdapInit( int AdapInit )
306 //=============================================================================
307 {
308   _AdapInit = AdapInit;
309 }
310 //=============================================================================
311 const int HOMARD_Hypothesis::GetAdapInit() const
312 //=============================================================================
313 {
314   return _AdapInit;
315 }
316 //=============================================================================
317 void HOMARD_Hypothesis::SetLevelOutput( int LevelOutput )
318 //=============================================================================
319 {
320   _LevelOutput = LevelOutput;
321 }
322 //=============================================================================
323 const int HOMARD_Hypothesis::GetLevelOutput() const
324 //=============================================================================
325 {
326   return _LevelOutput;
327 }
328 //=============================================================================
329 void HOMARD_Hypothesis::AddGroup( const char* Group)
330 {
331   _ListGroupSelected.push_back(Group);
332 }
333 //=============================================================================
334 void HOMARD_Hypothesis::SetGroups( const std::list<std::string>& ListGroup )
335 {
336   _ListGroupSelected.clear();
337   std::list<std::string>::const_iterator it = ListGroup.begin();
338   while(it != ListGroup.end())
339     _ListGroupSelected.push_back((*it++));
340 }
341 //=============================================================================
342 const std::list<std::string>& HOMARD_Hypothesis::GetGroups() const
343 {
344   return _ListGroupSelected;
345 }
346 //=============================================================================
347 void HOMARD_Hypothesis::SetTypeFieldInterp( int TypeFieldInterp )
348 {
349   ASSERT (!((TypeFieldInterp < -1) or (TypeFieldInterp > 2)));
350   _TypeFieldInterp = TypeFieldInterp;
351 }
352 //=============================================================================
353 int HOMARD_Hypothesis::GetTypeFieldInterp() const
354 {
355   return _TypeFieldInterp;
356 }
357 //=============================================================================
358 void HOMARD_Hypothesis::AddFieldInterp( const char* FieldInterp )
359 {
360   _ListFieldInterp.push_back( std::string( FieldInterp ) );
361 }
362 //=============================================================================
363 void HOMARD_Hypothesis::SupprFieldInterp()
364 {
365   MESSAGE ("SupprFieldInterp") ;
366   _ListFieldInterp.clear();
367 }
368 //=============================================================================
369 const std::list<std::string>& HOMARD_Hypothesis::GetListFieldInterp() const
370 {
371   return _ListFieldInterp;
372 }
373 //=============================================================================
374 //=============================================================================
375 // Liens avec les autres structures
376 //=============================================================================
377 //=============================================================================
378 void HOMARD_Hypothesis::SetCaseCreation( const char* NomCasCreation )
379 {
380   _NomCasCreation = std::string( NomCasCreation );
381 }
382 //=============================================================================
383 std::string HOMARD_Hypothesis::GetCaseCreation() const
384 {
385   return _NomCasCreation;
386 }
387 //=============================================================================
388 void HOMARD_Hypothesis::LinkIteration( const char* NomIteration )
389 {
390   _ListIter.push_back( std::string( NomIteration ) );
391 }
392 //=============================================================================
393 void HOMARD_Hypothesis::UnLinkIteration( const char* NomIteration )
394 {
395   std::list<std::string>::iterator it = find( _ListIter.begin(), _ListIter.end(), NomIteration ) ;
396   if ( it != _ListIter.end() )
397   {
398     MESSAGE ("Dans UnLinkIteration pour " << NomIteration) ;
399     it = _ListIter.erase( it ) ;
400   }
401 }
402 //=============================================================================
403 void HOMARD_Hypothesis::UnLinkIterations()
404 {
405   _ListIter.clear();
406 }
407 //=============================================================================
408 const std::list<std::string>& HOMARD_Hypothesis::GetIterations() const
409 {
410   return _ListIter;
411 }
412 //=============================================================================
413 void HOMARD_Hypothesis::AddZone( const char* NomZone, int TypeUse )
414 {
415   MESSAGE ("Dans AddZone pour " << NomZone) ;
416 // On commence par la supprimer au cas ou elle aurait deja ete inseree
417 // Cela peut se produire dans un schema YACS quand on repasse plusieurs fois par la
418 // definition de l'hypothese
419   SupprZone( NomZone ) ;
420 // Insertion veritable
421 // . Nom de la zone
422   _ListZone.push_back( std::string( NomZone ) );
423 // . Usage de la zone
424   std::stringstream saux1 ;
425   saux1 << TypeUse ;
426   _ListZone.push_back( saux1.str() );
427 }
428 //=============================================================================
429 void HOMARD_Hypothesis::SupprZone( const char* NomZone )
430 {
431   MESSAGE ("Dans SupprZone pour " << NomZone) ;
432   std::list<std::string>::iterator it = find( _ListZone.begin(), _ListZone.end(), NomZone );
433 // Attention a supprimer le nom de zone et le type d'usage
434   if ( it != _ListZone.end() )
435   {
436     it = _ListZone.erase( it );
437     it = _ListZone.erase( it );
438   }
439 }
440 //=============================================================================
441 void HOMARD_Hypothesis::SupprZones()
442 {
443   _ListZone.clear();
444 }
445 //=============================================================================
446 const std::list<std::string>& HOMARD_Hypothesis::GetZones() const
447 {
448   return _ListZone;
449 }