Salome HOME
f9c5249f7cecfbc40c1d2c08de16d0abcb9ab293
[modules/homard.git] / src / HOMARD_I / HOMARD_Hypothesis_i.cxx
1 // Copyright (C) 2011-2020  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::SetExtraOutput( CORBA::Long ExtraOutput )
303 {
304   ASSERT( myHomardHypothesis );
305   myHomardHypothesis->SetExtraOutput( ExtraOutput );
306 }
307 //=============================================================================
308 CORBA::Long HOMARD_Hypothesis_i::GetExtraOutput()
309 {
310   ASSERT( myHomardHypothesis );
311   return myHomardHypothesis->GetExtraOutput();
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::SupprGroup( const char* Group )
321 {
322   ASSERT( myHomardHypothesis );
323   myHomardHypothesis->SupprGroup(Group);
324 }
325 //=============================================================================
326 void HOMARD_Hypothesis_i::SupprGroups()
327 {
328   ASSERT( myHomardHypothesis );
329   myHomardHypothesis->SupprGroups();
330 }
331 //=============================================================================
332 void HOMARD_Hypothesis_i::SetGroups(const HOMARD::ListGroupType& ListGroup)
333 {
334   ASSERT( myHomardHypothesis );
335   std::list<std::string> ListString;
336   for ( int i = 0; i < ListGroup.length(); i++ )
337   {
338     ListString.push_back(std::string(ListGroup[i]));
339   }
340   myHomardHypothesis->SetGroups( ListString );
341 }
342 //=============================================================================
343 HOMARD::ListGroupType*  HOMARD_Hypothesis_i::GetGroups()
344 {
345   ASSERT( myHomardHypothesis );
346   const std::list<std::string>& ListString = myHomardHypothesis->GetGroups();
347   HOMARD::ListGroupType_var aResult = new HOMARD::ListGroupType;
348   aResult->length( ListString.size() );
349   std::list<std::string>::const_iterator it;
350   int i = 0;
351   for ( it = ListString.begin(); it != ListString.end(); it++ )
352   {
353     aResult[i++] = CORBA::string_dup( (*it).c_str() );
354   }
355   return aResult._retn();
356 }
357 //=============================================================================
358 void HOMARD_Hypothesis_i::SetTypeFieldInterp( CORBA::Long TypeFieldInterp )
359 {
360   ASSERT( myHomardHypothesis );
361   myHomardHypothesis->SetTypeFieldInterp( TypeFieldInterp );
362 }
363 //=============================================================================
364 CORBA::Long HOMARD_Hypothesis_i::GetTypeFieldInterp()
365 {
366   ASSERT( myHomardHypothesis );
367   return CORBA::Long( myHomardHypothesis->GetTypeFieldInterp() );
368 }
369 //=============================================================================
370 void HOMARD_Hypothesis_i::AddFieldInterp( const char* FieldInterp )
371 {
372   ASSERT( myHomardHypothesis );
373   myHomardHypothesis->AddFieldInterpType( FieldInterp, 0 );
374 }
375 //=============================================================================
376 void HOMARD_Hypothesis_i::AddFieldInterpType( const char* FieldInterp, CORBA::Long TypeInterp )
377 {
378   ASSERT( myHomardHypothesis );
379   myHomardHypothesis->AddFieldInterpType( FieldInterp, TypeInterp );
380 }
381 //=============================================================================
382 void HOMARD_Hypothesis_i::SupprFieldInterp( const char* FieldInterp )
383 {
384   ASSERT( myHomardHypothesis );
385   myHomardHypothesis->SupprFieldInterp(FieldInterp);
386 }
387 //=============================================================================
388 void HOMARD_Hypothesis_i::SupprFieldInterps()
389 {
390   ASSERT( myHomardHypothesis );
391   myHomardHypothesis->SupprFieldInterps();
392 }
393 //=============================================================================
394 HOMARD::listeFieldInterpsHypo* HOMARD_Hypothesis_i::GetFieldInterps()
395 {
396   ASSERT( myHomardHypothesis );
397   const std::list<std::string>& ListString = myHomardHypothesis->GetFieldInterps();
398   HOMARD::listeFieldInterpsHypo_var aResult = new HOMARD::listeFieldInterpsHypo;
399   aResult->length( ListString.size() );
400   std::list<std::string>::const_iterator it;
401   int i = 0;
402   for ( it = ListString.begin(); it != ListString.end(); it++ )
403   {
404     aResult[i++] = CORBA::string_dup( (*it).c_str() );
405   }
406   return aResult._retn();
407 }
408 //=============================================================================
409 //=============================================================================
410 // Liens avec les autres structures
411 //=============================================================================
412 //=============================================================================
413 void HOMARD_Hypothesis_i::SetCaseCreation( const char* NomCaseCreation )
414 {
415   ASSERT( myHomardHypothesis );
416   myHomardHypothesis->SetCaseCreation( NomCaseCreation );
417 }
418 //=============================================================================
419 char* HOMARD_Hypothesis_i::GetCaseCreation()
420 {
421   ASSERT( myHomardHypothesis );
422   return CORBA::string_dup( myHomardHypothesis->GetCaseCreation().c_str() );
423 }
424 //=============================================================================
425 void HOMARD_Hypothesis_i::LinkIteration( const char* NomIteration )
426 {
427   ASSERT( myHomardHypothesis );
428   myHomardHypothesis->LinkIteration( NomIteration );
429 }
430 //=============================================================================
431 void HOMARD_Hypothesis_i::UnLinkIteration( const char* NomIteration )
432 {
433   ASSERT( myHomardHypothesis );
434   myHomardHypothesis->UnLinkIteration( NomIteration );
435 }
436 //=============================================================================
437 HOMARD::listeIters* HOMARD_Hypothesis_i::GetIterations()
438 {
439   ASSERT( myHomardHypothesis );
440   const std::list<std::string>& ListString = myHomardHypothesis->GetIterations();
441   HOMARD::listeIters_var aResult = new HOMARD::listeIters;
442   aResult->length( ListString.size() );
443   std::list<std::string>::const_iterator it;
444   int i = 0;
445   for ( it = ListString.begin(); it != ListString.end(); it++ )
446   {
447     aResult[i++] = CORBA::string_dup( (*it).c_str() );
448   }
449   return aResult._retn();
450 }
451 //=============================================================================
452 void HOMARD_Hypothesis_i::AddZone( const char* NomZone, CORBA::Long TypeUse )
453 {
454   MESSAGE ("Dans AddZone pour " << NomZone << " et TypeUse = " << TypeUse ) ;
455   ASSERT( myHomardHypothesis );
456   VERIFICATION( (TypeUse==1) || (TypeUse==-1) );
457   myHomardHypothesis->SetAdapType( 0 );
458   int TypeRaff, TypeDera ;
459   if ( TypeUse == 1 )
460   {
461     TypeRaff = 1 ;
462     TypeDera = myHomardHypothesis->GetUnRefType() ;
463   }
464   else if ( TypeUse == -1 )
465   {
466     TypeRaff = myHomardHypothesis->GetRefinType() ;
467     TypeDera = 1 ;
468   }
469   myHomardHypothesis->SetRefinTypeDera( TypeRaff, TypeDera );
470   char* NomHypo = GetName() ;
471   return _gen_i->AssociateHypoZone(NomHypo, NomZone, TypeUse) ;
472 }
473 //=============================================================================
474 void HOMARD_Hypothesis_i::AddZone0( const char* NomZone, CORBA::Long TypeUse )
475 {
476   MESSAGE ("Dans AddZone0 pour " << NomZone) ;
477   ASSERT( myHomardHypothesis );
478   myHomardHypothesis->AddZone( NomZone, TypeUse );
479 }
480 //=============================================================================
481 void HOMARD_Hypothesis_i::SupprZone(const char * NomZone)
482 {
483   ASSERT( myHomardHypothesis );
484   myHomardHypothesis->SupprZone( NomZone);
485 }
486 //=============================================================================
487 void HOMARD_Hypothesis_i::SupprZones()
488 {
489   ASSERT( myHomardHypothesis );
490   myHomardHypothesis->SupprZones();
491 }
492 //=============================================================================
493 HOMARD::listeZonesHypo* HOMARD_Hypothesis_i::GetZones()
494 {
495   ASSERT( myHomardHypothesis );
496   const std::list<std::string>& ListString = myHomardHypothesis->GetZones();
497   HOMARD::listeZonesHypo_var aResult = new HOMARD::listeZonesHypo;
498   aResult->length( ListString.size() );
499   std::list<std::string>::const_iterator it;
500   int i = 0;
501   for ( it = ListString.begin(); it != ListString.end(); it++ )
502   {
503     aResult[i++] = CORBA::string_dup( (*it).c_str() );
504   }
505   return aResult._retn();
506 }