Salome HOME
correction du choix d'une valeur relative pour le champ de pilotage
[modules/homard.git] / src / HOMARD_I / HOMARD_Hypothesis_i.cxx
1 // Copyright (C) 2011-2014  CEA/DEN, EDF R&D
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19
20 // Remarques :
21 // L'ordre de description des fonctions est le meme dans tous les fichiers
22 // HOMARD_aaaa.idl, HOMARD_aaaa.hxx, HOMARD_aaaa.cxx, HOMARD_aaaa_i.hxx, HOMARD_aaaa_i.cxx :
23 // 1. Les generalites : Name, Delete, DumpPython, Dump, Restore
24 // 2. Les caracteristiques
25 // 3. Le lien avec les autres structures
26 //
27 // Quand les 2 fonctions Setxxx et Getxxx sont presentes, Setxxx est decrit en premier
28 //
29
30 #include "HOMARD_Hypothesis_i.hxx"
31 #include "HOMARD_Gen_i.hxx"
32 #include "HOMARD_Hypothesis.hxx"
33 #include "HOMARD_DriverTools.hxx"
34
35 #include "utilities.h"
36
37 //=============================================================================
38 /*!
39  *  standard constructor
40  */
41 //=============================================================================
42 HOMARD_Hypothesis_i::HOMARD_Hypothesis_i()
43 {
44   MESSAGE( "Default constructor, not for use" );
45   ASSERT( 0 );
46 }
47
48 //=============================================================================
49 /*!
50  *  standard constructor
51  */
52 //=============================================================================
53 HOMARD_Hypothesis_i::HOMARD_Hypothesis_i( CORBA::ORB_ptr orb,
54                                           HOMARD::HOMARD_Gen_var engine )
55 {
56   MESSAGE( "standard constructor" );
57   _gen_i = engine;
58   _orb = orb;
59   myHomardHypothesis = new ::HOMARD_Hypothesis();
60   ASSERT( myHomardHypothesis );
61 }
62
63 //=============================================================================
64 /*!
65  *  standard destructor
66  */
67 //=============================================================================
68 HOMARD_Hypothesis_i::~HOMARD_Hypothesis_i()
69 {
70 }
71 //=============================================================================
72 //=============================================================================
73 // Generalites
74 //=============================================================================
75 //=============================================================================
76 void HOMARD_Hypothesis_i::SetName( const char* Name )
77 {
78   ASSERT( myHomardHypothesis );
79   myHomardHypothesis->SetName( Name );
80 }
81 //=============================================================================
82 char* HOMARD_Hypothesis_i::GetName()
83 {
84   ASSERT( myHomardHypothesis );
85   return CORBA::string_dup( myHomardHypothesis->GetName().c_str() );
86 }
87 //=============================================================================
88 CORBA::Long  HOMARD_Hypothesis_i::Delete()
89 {
90   ASSERT( myHomardHypothesis );
91   char* HypoName = GetName() ;
92   MESSAGE ( "Delete : destruction de l'hypothese " << HypoName );
93   return _gen_i->DeleteHypo(HypoName) ;
94 }
95 //=============================================================================
96 char* HOMARD_Hypothesis_i::GetDumpPython()
97 {
98   ASSERT( myHomardHypothesis );
99   return CORBA::string_dup( myHomardHypothesis->GetDumpPython().c_str() );
100 }
101 //=============================================================================
102 std::string HOMARD_Hypothesis_i::Dump() const
103 {
104   return HOMARD::Dump( *myHomardHypothesis );
105 }
106 //=============================================================================
107 bool HOMARD_Hypothesis_i::Restore( const std::string& stream )
108 {
109   return HOMARD::Restore( *myHomardHypothesis, stream );
110 }
111 //=============================================================================
112 //=============================================================================
113 // Caracteristiques
114 //=============================================================================
115 //=============================================================================
116 void HOMARD_Hypothesis_i::SetUnifRefinUnRef( CORBA::Long TypeRaffDera )
117 {
118   ASSERT( myHomardHypothesis );
119   VERIFICATION( (TypeRaffDera==1) || (TypeRaffDera==-1) );
120   int TypeRaff, TypeDera ;
121   if ( TypeRaffDera == 1 )
122   {
123     TypeRaff = 1 ;
124     TypeDera = 0 ;
125   }
126   else if ( TypeRaffDera == -1 )
127   {
128     TypeRaff = 0 ;
129     TypeDera = 1 ;
130   }
131   myHomardHypothesis->SetAdapType( -1 );
132   myHomardHypothesis->SetRefinTypeDera( TypeRaff, TypeDera );
133 }
134 //=============================================================================
135 HOMARD::listeTypes* HOMARD_Hypothesis_i::GetAdapRefinUnRef()
136 {
137   ASSERT( myHomardHypothesis );
138   HOMARD::listeTypes_var aResult = new HOMARD::listeTypes;
139   aResult->length( 3 );
140   aResult[0] = CORBA::Long( myHomardHypothesis->GetAdapType() );
141   aResult[1] = CORBA::Long( myHomardHypothesis->GetRefinType() );
142   aResult[2] = CORBA::Long( myHomardHypothesis->GetUnRefType() );
143   return aResult._retn();
144 }
145 //=============================================================================
146 CORBA::Long HOMARD_Hypothesis_i::GetAdapType()
147 {
148   ASSERT( myHomardHypothesis );
149   return CORBA::Long( myHomardHypothesis->GetAdapType() );
150 }
151 //=============================================================================
152 CORBA::Long HOMARD_Hypothesis_i::GetRefinType()
153 {
154   ASSERT( myHomardHypothesis );
155   return CORBA::Long( myHomardHypothesis->GetRefinType() );
156 }
157 //=============================================================================
158 CORBA::Long HOMARD_Hypothesis_i::GetUnRefType()
159 {
160   ASSERT( myHomardHypothesis );
161   return CORBA::Long( myHomardHypothesis->GetUnRefType() );
162 }
163 //=============================================================================
164 void HOMARD_Hypothesis_i::SetField( const char* FieldName )
165 {
166   myHomardHypothesis->SetField( FieldName );
167 }
168 //=============================================================================
169 char* HOMARD_Hypothesis_i::GetFieldName()
170 {
171   ASSERT( myHomardHypothesis );
172   return CORBA::string_dup( myHomardHypothesis->GetFieldName().c_str() );
173 }
174 //=============================================================================
175 void HOMARD_Hypothesis_i::SetUseField( CORBA::Long UsField )
176 {
177   myHomardHypothesis->SetUseField( UsField );
178 }
179 //=============================================================================
180 HOMARD::InfosHypo* HOMARD_Hypothesis_i::GetField()
181 {
182   ASSERT( myHomardHypothesis );
183   HOMARD::InfosHypo* aInfosHypo = new HOMARD::InfosHypo();
184   aInfosHypo->FieldName  = CORBA::string_dup( myHomardHypothesis->GetFieldName().c_str() );
185   aInfosHypo->TypeThR    = CORBA::Long( myHomardHypothesis->GetRefinThrType() );
186   aInfosHypo->ThreshR    = CORBA::Double( myHomardHypothesis->GetThreshR() );
187   aInfosHypo->TypeThC    = CORBA::Long( myHomardHypothesis->GetUnRefThrType() );
188   aInfosHypo->ThreshC    = CORBA::Double( myHomardHypothesis->GetThreshC() );
189   aInfosHypo->UsField    = CORBA::Long( myHomardHypothesis->GetUseField() );
190   aInfosHypo->UsCmpI     = CORBA::Long( myHomardHypothesis->GetUseComp() );
191   return aInfosHypo;
192 }
193 //=============================================================================
194 void HOMARD_Hypothesis_i::SetUseComp( CORBA::Long UsCmpI )
195 {
196   myHomardHypothesis->SetUseComp( UsCmpI );
197 }
198 //=============================================================================
199 void HOMARD_Hypothesis_i::AddComp( const char* NomComp )
200 {
201   ASSERT( myHomardHypothesis );
202   myHomardHypothesis->AddComp( NomComp );
203 }
204 //=============================================================================
205 void HOMARD_Hypothesis_i::SupprComp( const char* NomComp )
206 {
207   ASSERT( myHomardHypothesis );
208   myHomardHypothesis->SupprComp(NomComp);
209 }
210 //=============================================================================
211 void HOMARD_Hypothesis_i::SupprComps()
212 {
213   ASSERT( myHomardHypothesis );
214   myHomardHypothesis->SupprComps();
215 }
216 //=============================================================================
217 HOMARD::listeComposantsHypo* HOMARD_Hypothesis_i::GetComps()
218 {
219   ASSERT( myHomardHypothesis );
220   const std::list<std::string>& ListString = myHomardHypothesis->GetComps();
221   HOMARD::listeComposantsHypo_var aResult = new HOMARD::listeComposantsHypo;
222   aResult->length( ListString.size() );
223   std::list<std::string>::const_iterator it;
224   int i = 0;
225   for ( it = ListString.begin(); it != ListString.end(); it++ )
226   {
227     aResult[i++] = CORBA::string_dup( (*it).c_str() );
228   }
229   return aResult._retn();
230 }
231 //=============================================================================
232 void HOMARD_Hypothesis_i::SetRefinThr( CORBA::Long TypeThR, CORBA::Double ThreshR )
233 {
234   myHomardHypothesis->SetAdapType( 1 );
235   if ( TypeThR > 0 )
236   {
237     int TypeDera = myHomardHypothesis->GetUnRefType() ;
238     myHomardHypothesis->SetRefinTypeDera( 1, TypeDera );
239   }
240   myHomardHypothesis->SetRefinThr( TypeThR, ThreshR );
241 }
242 //=============================================================================
243 CORBA::Long HOMARD_Hypothesis_i::GetRefinThrType()
244 {
245   ASSERT( myHomardHypothesis );
246   return CORBA::Long( myHomardHypothesis->GetRefinThrType() );
247 }
248 //=============================================================================
249 void HOMARD_Hypothesis_i::SetUnRefThr( CORBA::Long TypeThC, CORBA::Double ThreshC )
250 {
251   myHomardHypothesis->SetAdapType( 1 );
252   if ( TypeThC > 0 )
253   {
254     int TypeRaff = myHomardHypothesis->GetRefinType() ;
255     myHomardHypothesis->SetRefinTypeDera( TypeRaff, 1 );
256   }
257   myHomardHypothesis->SetUnRefThr( TypeThC, ThreshC );
258 }
259 //=============================================================================
260 CORBA::Long HOMARD_Hypothesis_i::GetUnRefThrType()
261 {
262   ASSERT( myHomardHypothesis );
263   return CORBA::Long( myHomardHypothesis->GetUnRefThrType() );
264 }
265 //=============================================================================
266 void HOMARD_Hypothesis_i::SetNivMax( CORBA::Long NivMax )
267 {
268   ASSERT( myHomardHypothesis );
269   myHomardHypothesis->SetNivMax( NivMax );
270 }
271 //=============================================================================
272 CORBA::Long HOMARD_Hypothesis_i::GetNivMax()
273 {
274   ASSERT( myHomardHypothesis );
275   return myHomardHypothesis->GetNivMax();
276 }
277 //=============================================================================
278 void HOMARD_Hypothesis_i::SetDiamMin( CORBA::Double DiamMin )
279 {
280   ASSERT( myHomardHypothesis );
281   myHomardHypothesis->SetDiamMin( DiamMin );
282 }
283 //=============================================================================
284 CORBA::Double HOMARD_Hypothesis_i::GetDiamMin()
285 {
286   ASSERT( myHomardHypothesis );
287   return myHomardHypothesis->GetDiamMin();
288 }
289 //=============================================================================
290 void HOMARD_Hypothesis_i::SetAdapInit( CORBA::Long AdapInit )
291 {
292   ASSERT( myHomardHypothesis );
293   myHomardHypothesis->SetAdapInit( AdapInit );
294 }
295 //=============================================================================
296 CORBA::Long HOMARD_Hypothesis_i::GetAdapInit()
297 {
298   ASSERT( myHomardHypothesis );
299   return myHomardHypothesis->GetAdapInit();
300 }
301 //=============================================================================
302 void HOMARD_Hypothesis_i::SetLevelOutput( CORBA::Long LevelOutput )
303 {
304   ASSERT( myHomardHypothesis );
305   myHomardHypothesis->SetLevelOutput( LevelOutput );
306 }
307 //=============================================================================
308 CORBA::Long HOMARD_Hypothesis_i::GetLevelOutput()
309 {
310   ASSERT( myHomardHypothesis );
311   return myHomardHypothesis->GetLevelOutput();
312 }
313 //=============================================================================
314 void HOMARD_Hypothesis_i::AddGroup( const char* Group)
315 {
316   ASSERT( myHomardHypothesis );
317   myHomardHypothesis->AddGroup( Group );
318 }
319 //=============================================================================
320 void HOMARD_Hypothesis_i::SetGroups(const HOMARD::ListGroupType& ListGroup)
321 {
322   ASSERT( myHomardHypothesis );
323   std::list<std::string> ListString;
324   for ( int i = 0; i < ListGroup.length(); i++ )
325   {
326     ListString.push_back(std::string(ListGroup[i]));
327   }
328   myHomardHypothesis->SetGroups( ListString );
329 }
330 //=============================================================================
331 HOMARD::ListGroupType*  HOMARD_Hypothesis_i::GetGroups()
332 {
333   ASSERT( myHomardHypothesis );
334   const std::list<std::string>& ListString = myHomardHypothesis->GetGroups();
335   HOMARD::ListGroupType_var aResult = new HOMARD::ListGroupType;
336   aResult->length( ListString.size() );
337   std::list<std::string>::const_iterator it;
338   int i = 0;
339   for ( it = ListString.begin(); it != ListString.end(); it++ )
340   {
341     aResult[i++] = CORBA::string_dup( (*it).c_str() );
342   }
343   return aResult._retn();
344 }
345 //=============================================================================
346 void HOMARD_Hypothesis_i::SetTypeFieldInterp( CORBA::Long TypeFieldInterp )
347 {
348   ASSERT( myHomardHypothesis );
349   myHomardHypothesis->SetTypeFieldInterp( TypeFieldInterp );
350 }
351 //=============================================================================
352 CORBA::Long HOMARD_Hypothesis_i::GetTypeFieldInterp()
353 {
354   ASSERT( myHomardHypothesis );
355   return CORBA::Long( myHomardHypothesis->GetTypeFieldInterp() );
356 }
357 //=============================================================================
358 void HOMARD_Hypothesis_i::AddFieldInterp( const char* FieldInterp )
359 {
360   ASSERT( myHomardHypothesis );
361   myHomardHypothesis->AddFieldInterpType( FieldInterp, 0 );
362 }
363 //=============================================================================
364 void HOMARD_Hypothesis_i::AddFieldInterpType( const char* FieldInterp, CORBA::Long TypeInterp )
365 {
366   ASSERT( myHomardHypothesis );
367   myHomardHypothesis->AddFieldInterpType( FieldInterp, TypeInterp );
368 }
369 //=============================================================================
370 void HOMARD_Hypothesis_i::SupprFieldInterp( const char* FieldInterp )
371 {
372   ASSERT( myHomardHypothesis );
373   myHomardHypothesis->SupprFieldInterp(FieldInterp);
374 }
375 //=============================================================================
376 void HOMARD_Hypothesis_i::SupprFieldInterps()
377 {
378   ASSERT( myHomardHypothesis );
379   myHomardHypothesis->SupprFieldInterps();
380 }
381 //=============================================================================
382 HOMARD::listeFieldInterpsHypo* HOMARD_Hypothesis_i::GetFieldInterps()
383 {
384   ASSERT( myHomardHypothesis );
385   const std::list<std::string>& ListString = myHomardHypothesis->GetFieldInterps();
386   HOMARD::listeFieldInterpsHypo_var aResult = new HOMARD::listeFieldInterpsHypo;
387   aResult->length( ListString.size() );
388   std::list<std::string>::const_iterator it;
389   int i = 0;
390   for ( it = ListString.begin(); it != ListString.end(); it++ )
391   {
392     aResult[i++] = CORBA::string_dup( (*it).c_str() );
393   }
394   return aResult._retn();
395 }
396 //=============================================================================
397 //=============================================================================
398 // Liens avec les autres structures
399 //=============================================================================
400 //=============================================================================
401 void HOMARD_Hypothesis_i::SetCaseCreation( const char* NomCaseCreation )
402 {
403   ASSERT( myHomardHypothesis );
404   myHomardHypothesis->SetCaseCreation( NomCaseCreation );
405 }
406 //=============================================================================
407 char* HOMARD_Hypothesis_i::GetCaseCreation()
408 {
409   ASSERT( myHomardHypothesis );
410   return CORBA::string_dup( myHomardHypothesis->GetCaseCreation().c_str() );
411 }
412 //=============================================================================
413 void HOMARD_Hypothesis_i::LinkIteration( const char* NomIteration )
414 {
415   ASSERT( myHomardHypothesis );
416   myHomardHypothesis->LinkIteration( NomIteration );
417 }
418 //=============================================================================
419 void HOMARD_Hypothesis_i::UnLinkIteration( const char* NomIteration )
420 {
421   ASSERT( myHomardHypothesis );
422   myHomardHypothesis->UnLinkIteration( NomIteration );
423 }
424 //=============================================================================
425 HOMARD::listeIters* HOMARD_Hypothesis_i::GetIterations()
426 {
427   ASSERT( myHomardHypothesis );
428   const std::list<std::string>& ListString = myHomardHypothesis->GetIterations();
429   HOMARD::listeIters_var aResult = new HOMARD::listeIters;
430   aResult->length( ListString.size() );
431   std::list<std::string>::const_iterator it;
432   int i = 0;
433   for ( it = ListString.begin(); it != ListString.end(); it++ )
434   {
435     aResult[i++] = CORBA::string_dup( (*it).c_str() );
436   }
437   return aResult._retn();
438 }
439 //=============================================================================
440 void HOMARD_Hypothesis_i::AddZone( const char* NomZone, CORBA::Long TypeUse )
441 {
442   MESSAGE ("Dans AddZone pour " << NomZone << " et TypeUse = " << TypeUse ) ;
443   ASSERT( myHomardHypothesis );
444   VERIFICATION( (TypeUse==1) || (TypeUse==-1) );
445   myHomardHypothesis->SetAdapType( 0 );
446   int TypeRaff, TypeDera ;
447   if ( TypeUse == 1 )
448   {
449     TypeRaff = 1 ;
450     TypeDera = myHomardHypothesis->GetUnRefType() ;
451   }
452   else if ( TypeUse == -1 )
453   {
454     TypeRaff = myHomardHypothesis->GetRefinType() ;
455     TypeDera = 1 ;
456   }
457   myHomardHypothesis->SetRefinTypeDera( TypeRaff, TypeDera );
458   char* NomHypo = GetName() ;
459   return _gen_i->AssociateHypoZone(NomHypo, NomZone, TypeUse) ;
460 }
461 //=============================================================================
462 void HOMARD_Hypothesis_i::AddZone0( const char* NomZone, CORBA::Long TypeUse )
463 {
464   MESSAGE ("Dans AddZone0 pour " << NomZone) ;
465   ASSERT( myHomardHypothesis );
466   myHomardHypothesis->AddZone( NomZone, TypeUse );
467 }
468 //=============================================================================
469 void HOMARD_Hypothesis_i::SupprZone(const char * NomZone)
470 {
471   ASSERT( myHomardHypothesis );
472   myHomardHypothesis->SupprZone( NomZone);
473 }
474 //=============================================================================
475 void HOMARD_Hypothesis_i::SupprZones()
476 {
477   ASSERT( myHomardHypothesis );
478   myHomardHypothesis->SupprZones();
479 }
480 //=============================================================================
481 HOMARD::listeZonesHypo* HOMARD_Hypothesis_i::GetZones()
482 {
483   ASSERT( myHomardHypothesis );
484   const std::list<std::string>& ListString = myHomardHypothesis->GetZones();
485   HOMARD::listeZonesHypo_var aResult = new HOMARD::listeZonesHypo;
486   aResult->length( ListString.size() );
487   std::list<std::string>::const_iterator it;
488   int i = 0;
489   for ( it = ListString.begin(); it != ListString.end(); it++ )
490   {
491     aResult[i++] = CORBA::string_dup( (*it).c_str() );
492   }
493   return aResult._retn();
494 }