Salome HOME
version 5_1_4 HOMARD_SRC
[modules/homard.git] / src / HOMARD_I / HOMARD_Cas_i.cxx
1 #include "HOMARD_Cas_i.hxx"
2 #include "HOMARD_Gen_i.hxx"
3 #include "HOMARD_Cas.hxx"
4 #include "HOMARD_DriverTools.hxx"
5
6 #include "utilities.h"
7 #include <vector>
8
9 //=============================================================================
10 /*!
11  *  standard constructor
12  */
13 //=============================================================================
14 HOMARD_Cas_i::HOMARD_Cas_i()
15 {
16   MESSAGE( "Default constructor, not for use" );
17   ASSERT( 0 );
18 }
19
20 //=============================================================================
21 /*!
22  *  standard constructor
23  */
24 //=============================================================================
25 HOMARD_Cas_i::HOMARD_Cas_i( CORBA::ORB_ptr orb,
26                             HOMARD::HOMARD_Gen_var engine )
27 {
28   MESSAGE( "HOMARD_Cas_i" );
29   _gen_i = engine;
30   _orb = orb;
31   myHomardCas = new ::HOMARD_Cas();
32   ASSERT( myHomardCas );
33 }
34
35 //=============================================================================
36 /*!
37  *  standard destructor
38  */
39 //=============================================================================
40 HOMARD_Cas_i::~HOMARD_Cas_i()
41 {
42 }
43
44 //=============================================================================
45 /*!
46  */
47 //=============================================================================
48 void HOMARD_Cas_i::SetDirName( const char* NomDir )
49 {
50   ASSERT( myHomardCas );
51   myHomardCas->SetDirName( NomDir );
52 }
53
54 //=============================================================================
55 /*!
56  */
57 //=============================================================================
58 void HOMARD_Cas_i::SetName( const char* NomCas )
59 {
60   ASSERT( myHomardCas );
61   myHomardCas->SetName( NomCas );
62 }
63
64 //=============================================================================
65 /*!
66  */
67 //=============================================================================
68 char* HOMARD_Cas_i::GetName()
69 {
70   ASSERT( myHomardCas );
71   return CORBA::string_dup( myHomardCas->GetName().c_str() );
72 }
73
74 //=============================================================================
75 /*!
76  */
77 //=============================================================================
78 char* HOMARD_Cas_i::GetDumpPython()
79 {
80   ASSERT( myHomardCas );
81   return CORBA::string_dup( myHomardCas->GetDumpPython().c_str() );
82 }
83
84 //=============================================================================
85 char* HOMARD_Cas_i::GetDirName()
86 {
87   ASSERT( myHomardCas );
88   return CORBA::string_dup( myHomardCas->GetDirName().c_str() );
89 }
90
91 //=============================================================================
92 void HOMARD_Cas_i::SetConfType( CORBA::Long ConfType )
93 {
94   ASSERT( myHomardCas );
95   myHomardCas->SetConfType( ConfType );
96 }
97 //=============================================================================
98 CORBA::Long HOMARD_Cas_i::GetNumber()
99 {
100   ASSERT( myHomardCas );
101   return myHomardCas->GetNumber();
102 }
103
104 //=============================================================================
105 CORBA::Long HOMARD_Cas_i::GetConfType()
106 {
107   ASSERT( myHomardCas );
108   return myHomardCas->GetConfType();
109 }
110
111 //=============================================================================
112 void HOMARD_Cas_i::AddIteration( const char* NomIteration )
113 {
114   ASSERT( myHomardCas );
115   myHomardCas->AddIteration( NomIteration );
116 }
117
118 //=============================================================================
119 char* HOMARD_Cas_i::GetIter0Name()
120 {
121   ASSERT( myHomardCas );
122   return CORBA::string_dup( myHomardCas->GetIter0Name().c_str() );
123 }
124 //=============================================================================
125 HOMARD::extrema* HOMARD_Cas_i::GetBoundingBox()
126 {
127   ASSERT(myHomardCas );
128   HOMARD::extrema_var aResult = new HOMARD::extrema();
129   std::vector<double> LesExtremes = myHomardCas->GetBoundingBox();
130   ASSERT( LesExtremes.size() == 10 );
131   aResult->length( 10 );
132   for ( int i = 0; i < LesExtremes.size(); i++ )
133   {
134     aResult[i] = LesExtremes[i];
135   }
136   return aResult._retn();
137 }
138 //=============================================================================
139 void HOMARD_Cas_i::SetBoundingBox( const HOMARD::extrema& LesExtrema )
140 {
141   ASSERT( myHomardCas );
142   std::vector<double> VExtrema;
143   ASSERT( LesExtrema.length() == 10 );
144   VExtrema.resize( LesExtrema.length() );
145   for ( int i = 0; i < LesExtrema.length(); i++ )
146   {
147     VExtrema[i] = LesExtrema[i];
148   }
149   
150   myHomardCas->SetBoundingBox( VExtrema );
151 }
152 //=============================================================================
153 void HOMARD_Cas_i::AddGroup( const char* Group)
154 {
155   ASSERT( myHomardCas );
156   myHomardCas->AddGroup( Group );
157 }
158 //=============================================================================
159 void HOMARD_Cas_i::SetGroups( const HOMARD::ListGroupType& ListGroup )
160 {
161   ASSERT( myHomardCas );
162   std::list<std::string> ListString ;
163   for ( int i = 0; i < ListGroup.length(); i++ )
164   {
165     ListString.push_back(std::string(ListGroup[i]));
166   }
167
168   myHomardCas->SetGroups( ListString );
169 }
170 //=============================================================================
171 HOMARD::ListGroupType* HOMARD_Cas_i::GetGroups()
172 {
173   ASSERT(myHomardCas );
174   const std::list<std::string>& ListString = myHomardCas->GetGroups();
175   HOMARD::ListGroupType_var aResult = new HOMARD::ListGroupType();
176   aResult->length( ListString.size() );
177   std::list<std::string>::const_iterator it;
178   int i = 0;
179   for ( it = ListString.begin(); it != ListString.end(); it++ )
180   {
181     aResult[i++] = CORBA::string_dup( (*it).c_str() );
182   }
183   return aResult._retn();
184 }
185
186 //=============================================================================
187 void HOMARD_Cas_i::AddBoundaryGroup( const char* Boundary, const char* Group)
188 {
189   MESSAGE ("Dans AddBoundaryGroup");
190   ASSERT( myHomardCas );
191   myHomardCas->AddBoundaryGroup( Boundary, Group );
192 }
193 //=============================================================================
194 HOMARD::ListBoundaryGroupType* HOMARD_Cas_i::GetBoundaryGroup()
195 {
196   MESSAGE ("Dans GetBoundaryGroup");
197   ASSERT(myHomardCas );
198   const std::list<std::string>& ListString = myHomardCas->GetBoundaryGroup();
199   HOMARD::ListBoundaryGroupType_var aResult = new HOMARD::ListBoundaryGroupType();
200   aResult->length( ListString.size() );
201   std::list<std::string>::const_iterator it;
202   int i = 0;
203   for ( it = ListString.begin(); it != ListString.end(); it++ )
204   {
205     aResult[i++] = CORBA::string_dup( (*it).c_str() );
206   }
207   return aResult._retn();
208 }
209
210 //=============================================================================
211 std::string HOMARD_Cas_i::Dump() const
212 {
213   return HOMARD::Dump( *myHomardCas );
214 }
215
216 //=============================================================================
217 bool HOMARD_Cas_i::Restore( const std::string& stream )
218 {
219   return HOMARD::Restore( *myHomardCas, stream );
220 }