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