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