Salome HOME
73c279e97fcca76e7f8756a0750535c6634472f0
[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   int TypeRaff, TypeDera ;
120   if ( TypeRaffDera == 1 )
121   {
122     TypeRaff = 1 ;
123     TypeDera = 0 ;
124   }
125   else if ( TypeRaffDera == -1 )
126   {
127     TypeRaff = 0 ;
128     TypeDera = 1 ;
129   }
130   else
131   {
132     ASSERT( "TypeRaffDera should be 1 or -1" == 0 );
133   }
134   myHomardHypothesis->SetAdapType( -1 );
135   myHomardHypothesis->SetRefinTypeDera( TypeRaff, TypeDera );
136 }
137 //=============================================================================
138 HOMARD::listeTypes* HOMARD_Hypothesis_i::GetAdapRefinUnRef()
139 {
140   ASSERT( myHomardHypothesis );
141   HOMARD::listeTypes_var aResult = new HOMARD::listeTypes;
142   aResult->length( 3 );
143   aResult[0] = CORBA::Long( myHomardHypothesis->GetAdapType() );
144   aResult[1] = CORBA::Long( myHomardHypothesis->GetRefinType() );
145   aResult[2] = CORBA::Long( myHomardHypothesis->GetUnRefType() );
146   return aResult._retn();
147 }
148 //=============================================================================
149 CORBA::Long HOMARD_Hypothesis_i::GetAdapType()
150 {
151   ASSERT( myHomardHypothesis );
152   return CORBA::Long( myHomardHypothesis->GetAdapType() );
153 }
154 //=============================================================================
155 CORBA::Long HOMARD_Hypothesis_i::GetRefinType()
156 {
157   ASSERT( myHomardHypothesis );
158   return CORBA::Long( myHomardHypothesis->GetRefinType() );
159 }
160 //=============================================================================
161 CORBA::Long HOMARD_Hypothesis_i::GetUnRefType()
162 {
163   ASSERT( myHomardHypothesis );
164   return CORBA::Long( myHomardHypothesis->GetUnRefType() );
165 }
166 //=============================================================================
167 void HOMARD_Hypothesis_i::SetField( const char* FieldName )
168 {
169   myHomardHypothesis->SetField( FieldName );
170 }
171 //=============================================================================
172 char* HOMARD_Hypothesis_i::GetFieldName()
173 {
174   ASSERT( myHomardHypothesis );
175   return CORBA::string_dup( myHomardHypothesis->GetFieldName().c_str() );
176 }
177 //=============================================================================
178 void HOMARD_Hypothesis_i::SetUseField( CORBA::Long UsField )
179 {
180   myHomardHypothesis->SetUseField( UsField );
181 }
182 //=============================================================================
183 HOMARD::InfosHypo* HOMARD_Hypothesis_i::GetField()
184 {
185   ASSERT( myHomardHypothesis );
186   HOMARD::InfosHypo* aInfosHypo = new HOMARD::InfosHypo();
187   aInfosHypo->FieldName  = CORBA::string_dup( myHomardHypothesis->GetFieldName().c_str() );
188   aInfosHypo->TypeThR    = CORBA::Long( myHomardHypothesis->GetRefinThrType() );
189   aInfosHypo->ThreshR    = CORBA::Double( myHomardHypothesis->GetThreshR() );
190   aInfosHypo->TypeThC    = CORBA::Long( myHomardHypothesis->GetUnRefThrType() );
191   aInfosHypo->ThreshC    = CORBA::Double( myHomardHypothesis->GetThreshC() );
192   aInfosHypo->UsField    = CORBA::Long( myHomardHypothesis->GetUseField() );
193   aInfosHypo->UsCmpI     = CORBA::Long( myHomardHypothesis->GetUseComp() );
194   return aInfosHypo;
195 }
196 //=============================================================================
197 void HOMARD_Hypothesis_i::SetUseComp( CORBA::Long UsCmpI )
198 {
199   myHomardHypothesis->SetUseComp( UsCmpI );
200 }
201 //=============================================================================
202 void HOMARD_Hypothesis_i::AddComp( const char* NomComp )
203 {
204   ASSERT( myHomardHypothesis );
205   myHomardHypothesis->AddComp( NomComp );
206 }
207 //=============================================================================
208 void HOMARD_Hypothesis_i::SupprComp( const char* NomComp )
209 {
210   ASSERT( myHomardHypothesis );
211   myHomardHypothesis->SupprComp(NomComp);
212 }
213 //=============================================================================
214 void HOMARD_Hypothesis_i::SupprComps()
215 {
216   ASSERT( myHomardHypothesis );
217   myHomardHypothesis->SupprComps();
218 }
219 //=============================================================================
220 HOMARD::listeComposantsHypo* HOMARD_Hypothesis_i::GetComps()
221 {
222   ASSERT( myHomardHypothesis );
223   const std::list<std::string>& ListString = myHomardHypothesis->GetComps();
224   HOMARD::listeComposantsHypo_var aResult = new HOMARD::listeComposantsHypo;
225   aResult->length( ListString.size() );
226   std::list<std::string>::const_iterator it;
227   int i = 0;
228   for ( it = ListString.begin(); it != ListString.end(); it++ )
229   {
230     aResult[i++] = CORBA::string_dup( (*it).c_str() );
231   }
232   return aResult._retn();
233 }
234 //=============================================================================
235 void HOMARD_Hypothesis_i::SetRefinThr( CORBA::Long TypeThR, CORBA::Double ThreshR )
236 {
237   myHomardHypothesis->SetAdapType( 1 );
238   if ( TypeThR > 0 )
239   {
240     int TypeDera = myHomardHypothesis->GetUnRefType() ;
241     myHomardHypothesis->SetRefinTypeDera( 1, TypeDera );
242   }
243   myHomardHypothesis->SetRefinThr( TypeThR, ThreshR );
244 }
245 //=============================================================================
246 CORBA::Long HOMARD_Hypothesis_i::GetRefinThrType()
247 {
248   ASSERT( myHomardHypothesis );
249   return CORBA::Long( myHomardHypothesis->GetRefinThrType() );
250 }
251 //=============================================================================
252 void HOMARD_Hypothesis_i::SetUnRefThr( CORBA::Long TypeThC, CORBA::Double ThreshC )
253 {
254   myHomardHypothesis->SetAdapType( 1 );
255   if ( TypeThC > 0 )
256   {
257     int TypeRaff = myHomardHypothesis->GetRefinType() ;
258     myHomardHypothesis->SetRefinTypeDera( TypeRaff, 1 );
259   }
260   myHomardHypothesis->SetUnRefThr( TypeThC, ThreshC );
261 }
262 //=============================================================================
263 CORBA::Long HOMARD_Hypothesis_i::GetUnRefThrType()
264 {
265   ASSERT( myHomardHypothesis );
266   return CORBA::Long( myHomardHypothesis->GetUnRefThrType() );
267 }
268 //=============================================================================
269 void HOMARD_Hypothesis_i::SetNivMax( CORBA::Long NivMax )
270 {
271   ASSERT( myHomardHypothesis );
272   myHomardHypothesis->SetNivMax( NivMax );
273 }
274 //=============================================================================
275 CORBA::Long HOMARD_Hypothesis_i::GetNivMax()
276 {
277   ASSERT( myHomardHypothesis );
278   return myHomardHypothesis->GetNivMax();
279 }
280 //=============================================================================
281 void HOMARD_Hypothesis_i::SetDiamMin( CORBA::Double DiamMin )
282 {
283   ASSERT( myHomardHypothesis );
284   myHomardHypothesis->SetDiamMin( DiamMin );
285 }
286 //=============================================================================
287 CORBA::Double HOMARD_Hypothesis_i::GetDiamMin()
288 {
289   ASSERT( myHomardHypothesis );
290   return myHomardHypothesis->GetDiamMin();
291 }
292 //=============================================================================
293 void HOMARD_Hypothesis_i::SetAdapInit( CORBA::Long AdapInit )
294 {
295   ASSERT( myHomardHypothesis );
296   myHomardHypothesis->SetAdapInit( AdapInit );
297 }
298 //=============================================================================
299 CORBA::Long HOMARD_Hypothesis_i::GetAdapInit()
300 {
301   ASSERT( myHomardHypothesis );
302   return myHomardHypothesis->GetAdapInit();
303 }
304 //=============================================================================
305 void HOMARD_Hypothesis_i::SetLevelOutput( CORBA::Long LevelOutput )
306 {
307   ASSERT( myHomardHypothesis );
308   myHomardHypothesis->SetLevelOutput( LevelOutput );
309 }
310 //=============================================================================
311 CORBA::Long HOMARD_Hypothesis_i::GetLevelOutput()
312 {
313   ASSERT( myHomardHypothesis );
314   return myHomardHypothesis->GetLevelOutput();
315 }
316 //=============================================================================
317 void HOMARD_Hypothesis_i::AddGroup( const char* Group)
318 {
319   ASSERT( myHomardHypothesis );
320   myHomardHypothesis->AddGroup( Group );
321 }
322 //=============================================================================
323 void HOMARD_Hypothesis_i::SetGroups(const HOMARD::ListGroupType& ListGroup)
324 {
325   ASSERT( myHomardHypothesis );
326   std::list<std::string> ListString;
327   for ( int i = 0; i < ListGroup.length(); i++ )
328   {
329     ListString.push_back(std::string(ListGroup[i]));
330   }
331   myHomardHypothesis->SetGroups( ListString );
332 }
333 //=============================================================================
334 HOMARD::ListGroupType*  HOMARD_Hypothesis_i::GetGroups()
335 {
336   ASSERT( myHomardHypothesis );
337   const std::list<std::string>& ListString = myHomardHypothesis->GetGroups();
338   HOMARD::ListGroupType_var aResult = new HOMARD::ListGroupType;
339   aResult->length( ListString.size() );
340   std::list<std::string>::const_iterator it;
341   int i = 0;
342   for ( it = ListString.begin(); it != ListString.end(); it++ )
343   {
344     aResult[i++] = CORBA::string_dup( (*it).c_str() );
345   }
346   return aResult._retn();
347 }
348 //=============================================================================
349 void HOMARD_Hypothesis_i::SetTypeFieldInterp( CORBA::Long TypeFieldInterp )
350 {
351   ASSERT( myHomardHypothesis );
352   myHomardHypothesis->SetTypeFieldInterp( TypeFieldInterp );
353 }
354 //=============================================================================
355 CORBA::Long HOMARD_Hypothesis_i::GetTypeFieldInterp()
356 {
357   ASSERT( myHomardHypothesis );
358   return CORBA::Long( myHomardHypothesis->GetTypeFieldInterp() );
359 }
360 //=============================================================================
361 void HOMARD_Hypothesis_i::AddFieldInterp( const char* FieldInterp )
362 {
363   ASSERT( myHomardHypothesis );
364   myHomardHypothesis->AddFieldInterpType( FieldInterp, 0 );
365 }
366 //=============================================================================
367 void HOMARD_Hypothesis_i::AddFieldInterpType( const char* FieldInterp, CORBA::Long TypeInterp )
368 {
369   ASSERT( myHomardHypothesis );
370   myHomardHypothesis->AddFieldInterpType( FieldInterp, TypeInterp );
371 }
372 //=============================================================================
373 void HOMARD_Hypothesis_i::SupprFieldInterp( const char* FieldInterp )
374 {
375   ASSERT( myHomardHypothesis );
376   myHomardHypothesis->SupprFieldInterp(FieldInterp);
377 }
378 //=============================================================================
379 void HOMARD_Hypothesis_i::SupprFieldInterps()
380 {
381   ASSERT( myHomardHypothesis );
382   myHomardHypothesis->SupprFieldInterps();
383 }
384 //=============================================================================
385 HOMARD::listeFieldInterpsHypo* HOMARD_Hypothesis_i::GetFieldInterps()
386 {
387   ASSERT( myHomardHypothesis );
388   const std::list<std::string>& ListString = myHomardHypothesis->GetFieldInterps();
389   HOMARD::listeFieldInterpsHypo_var aResult = new HOMARD::listeFieldInterpsHypo;
390   aResult->length( ListString.size() );
391   std::list<std::string>::const_iterator it;
392   int i = 0;
393   for ( it = ListString.begin(); it != ListString.end(); it++ )
394   {
395     aResult[i++] = CORBA::string_dup( (*it).c_str() );
396   }
397   return aResult._retn();
398 }
399 //=============================================================================
400 //=============================================================================
401 // Liens avec les autres structures
402 //=============================================================================
403 //=============================================================================
404 void HOMARD_Hypothesis_i::SetCaseCreation( const char* NomCaseCreation )
405 {
406   ASSERT( myHomardHypothesis );
407   myHomardHypothesis->SetCaseCreation( NomCaseCreation );
408 }
409 //=============================================================================
410 char* HOMARD_Hypothesis_i::GetCaseCreation()
411 {
412   ASSERT( myHomardHypothesis );
413   return CORBA::string_dup( myHomardHypothesis->GetCaseCreation().c_str() );
414 }
415 //=============================================================================
416 void HOMARD_Hypothesis_i::LinkIteration( const char* NomIteration )
417 {
418   ASSERT( myHomardHypothesis );
419   myHomardHypothesis->LinkIteration( NomIteration );
420 }
421 //=============================================================================
422 void HOMARD_Hypothesis_i::UnLinkIteration( const char* NomIteration )
423 {
424   ASSERT( myHomardHypothesis );
425   myHomardHypothesis->UnLinkIteration( NomIteration );
426 }
427 //=============================================================================
428 HOMARD::listeIters* HOMARD_Hypothesis_i::GetIterations()
429 {
430   ASSERT( myHomardHypothesis );
431   const std::list<std::string>& ListString = myHomardHypothesis->GetIterations();
432   HOMARD::listeIters_var aResult = new HOMARD::listeIters;
433   aResult->length( ListString.size() );
434   std::list<std::string>::const_iterator it;
435   int i = 0;
436   for ( it = ListString.begin(); it != ListString.end(); it++ )
437   {
438     aResult[i++] = CORBA::string_dup( (*it).c_str() );
439   }
440   return aResult._retn();
441 }
442 //=============================================================================
443 void HOMARD_Hypothesis_i::AddZone( const char* NomZone, CORBA::Long TypeUse )
444 {
445   MESSAGE ("Dans AddZone pour " << NomZone << " et TypeUse = " << TypeUse ) ;
446   ASSERT( myHomardHypothesis );
447   myHomardHypothesis->SetAdapType( 0 );
448   int TypeRaff, TypeDera ;
449   if ( TypeUse == 1 )
450   {
451     TypeRaff = 1 ;
452     TypeDera = myHomardHypothesis->GetUnRefType() ;
453   }
454   else if ( TypeUse == -1 )
455   {
456     TypeRaff = myHomardHypothesis->GetRefinType() ;
457     TypeDera = 1 ;
458   }
459   else
460   {
461     ASSERT( "TypeUse should be 1 or -1" == 0 );
462   }
463   myHomardHypothesis->SetRefinTypeDera( TypeRaff, TypeDera );
464   char* NomHypo = GetName() ;
465   return _gen_i->AssociateHypoZone(NomHypo, NomZone, TypeUse) ;
466 }
467 //=============================================================================
468 void HOMARD_Hypothesis_i::AddZone0( const char* NomZone, CORBA::Long TypeUse )
469 {
470   MESSAGE ("Dans AddZone0 pour " << NomZone) ;
471   ASSERT( myHomardHypothesis );
472   myHomardHypothesis->AddZone( NomZone, TypeUse );
473 }
474 //=============================================================================
475 void HOMARD_Hypothesis_i::SupprZone(const char * NomZone)
476 {
477   ASSERT( myHomardHypothesis );
478   myHomardHypothesis->SupprZone( NomZone);
479 }
480 //=============================================================================
481 void HOMARD_Hypothesis_i::SupprZones()
482 {
483   ASSERT( myHomardHypothesis );
484   myHomardHypothesis->SupprZones();
485 }
486 //=============================================================================
487 HOMARD::listeZonesHypo* HOMARD_Hypothesis_i::GetZones()
488 {
489   ASSERT( myHomardHypothesis );
490   const std::list<std::string>& ListString = myHomardHypothesis->GetZones();
491   HOMARD::listeZonesHypo_var aResult = new HOMARD::listeZonesHypo;
492   aResult->length( ListString.size() );
493   std::list<std::string>::const_iterator it;
494   int i = 0;
495   for ( it = ListString.begin(); it != ListString.end(); it++ )
496   {
497     aResult[i++] = CORBA::string_dup( (*it).c_str() );
498   }
499   return aResult._retn();
500 }