1 // Copyright (C) 2011-2012 CEA/DEN, EDF R&D
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.
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.
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
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 #include "HOMARD_Cas_i.hxx"
21 #include "HOMARD_Gen_i.hxx"
22 #include "HOMARD_Cas.hxx"
23 #include "HOMARD_DriverTools.hxx"
25 #include "utilities.h"
28 //=============================================================================
30 * standard constructor
32 //=============================================================================
33 HOMARD_Cas_i::HOMARD_Cas_i()
35 MESSAGE( "Default constructor, not for use" );
39 //=============================================================================
41 * standard constructor
43 //=============================================================================
44 HOMARD_Cas_i::HOMARD_Cas_i( CORBA::ORB_ptr orb,
45 HOMARD::HOMARD_Gen_var engine )
47 MESSAGE( "HOMARD_Cas_i" );
50 myHomardCas = new ::HOMARD_Cas();
51 ASSERT( myHomardCas );
54 //=============================================================================
58 //=============================================================================
59 HOMARD_Cas_i::~HOMARD_Cas_i()
63 //=============================================================================
66 //=============================================================================
67 void HOMARD_Cas_i::SetDirName( const char* NomDir )
69 ASSERT( myHomardCas );
70 myHomardCas->SetDirName( NomDir );
73 //=============================================================================
76 //=============================================================================
77 void HOMARD_Cas_i::SetName( const char* Name )
79 ASSERT( myHomardCas );
80 myHomardCas->SetName( Name );
83 //=============================================================================
86 //=============================================================================
87 char* HOMARD_Cas_i::GetName()
89 ASSERT( myHomardCas );
90 return CORBA::string_dup( myHomardCas->GetName().c_str() );
93 //=============================================================================
96 //=============================================================================
97 char* HOMARD_Cas_i::GetDumpPython()
99 ASSERT( myHomardCas );
100 return CORBA::string_dup( myHomardCas->GetDumpPython().c_str() );
103 //=============================================================================
104 char* HOMARD_Cas_i::GetDirName()
106 ASSERT( myHomardCas );
107 return CORBA::string_dup( myHomardCas->GetDirName().c_str() );
110 //=============================================================================
111 void HOMARD_Cas_i::SetConfType( CORBA::Long ConfType )
113 ASSERT( myHomardCas );
114 myHomardCas->SetConfType( ConfType );
116 //=============================================================================
117 CORBA::Long HOMARD_Cas_i::GetNumber()
119 ASSERT( myHomardCas );
120 return myHomardCas->GetNumber();
123 //=============================================================================
124 CORBA::Long HOMARD_Cas_i::GetConfType()
126 ASSERT( myHomardCas );
127 return myHomardCas->GetConfType();
130 //=============================================================================
131 char* HOMARD_Cas_i::GetIter0Name()
133 ASSERT( myHomardCas );
134 return CORBA::string_dup( myHomardCas->GetIter0Name().c_str() );
136 //=============================================================================
137 HOMARD::HOMARD_Iteration_ptr HOMARD_Cas_i::GetIter0()
139 // Nom de l'iteration parent
140 char* Iter0Name = GetIter0Name() ;
141 MESSAGE ( "GetIter0 : Iter0Name = " << Iter0Name );
142 // On passe par la methode sur l'objet HOMARD
143 // Il serait plus elegant de tout faire ici, mais il est complexe de passer tout le contexte
144 return _gen_i->GetIteration(Iter0Name) ;
147 //=============================================================================
148 HOMARD::HOMARD_Iteration_ptr HOMARD_Cas_i::NextIteration( const char* IterName )
150 // Nom de l'iteration parent
151 char* NomIterParent = GetIter0Name() ;
152 MESSAGE ( "NextIteration : IterName = " << IterName );
153 MESSAGE ( "NextIteration : NomIterParent = " << NomIterParent );
154 // On passe par la methode sur l'objet HOMARD
155 // Il serait plus elegant de tout faire ici, mais il est complexe de passer tout le contexte
156 return _gen_i->CreateIteration(IterName, NomIterParent) ;
159 //=============================================================================
160 void HOMARD_Cas_i::AddIteration( const char* NomIteration )
162 ASSERT( myHomardCas );
163 myHomardCas->AddIteration( NomIteration );
165 //=============================================================================
166 HOMARD::extrema* HOMARD_Cas_i::GetBoundingBox()
168 ASSERT(myHomardCas );
169 HOMARD::extrema_var aResult = new HOMARD::extrema();
170 std::vector<double> LesExtremes = myHomardCas->GetBoundingBox();
171 ASSERT( LesExtremes.size() == 10 );
172 aResult->length( 10 );
173 for ( int i = 0; i < LesExtremes.size(); i++ )
175 aResult[i] = LesExtremes[i];
177 return aResult._retn();
179 //=============================================================================
180 void HOMARD_Cas_i::SetBoundingBox( const HOMARD::extrema& LesExtrema )
182 ASSERT( myHomardCas );
183 std::vector<double> VExtrema;
184 ASSERT( LesExtrema.length() == 10 );
185 VExtrema.resize( LesExtrema.length() );
186 for ( int i = 0; i < LesExtrema.length(); i++ )
188 VExtrema[i] = LesExtrema[i];
191 myHomardCas->SetBoundingBox( VExtrema );
193 //=============================================================================
194 void HOMARD_Cas_i::AddGroup( const char* Group)
196 ASSERT( myHomardCas );
197 myHomardCas->AddGroup( Group );
199 //=============================================================================
200 void HOMARD_Cas_i::SetGroups( const HOMARD::ListGroupType& ListGroup )
202 ASSERT( myHomardCas );
203 std::list<std::string> ListString ;
204 for ( int i = 0; i < ListGroup.length(); i++ )
206 ListString.push_back(std::string(ListGroup[i]));
209 myHomardCas->SetGroups( ListString );
211 //=============================================================================
212 HOMARD::ListGroupType* HOMARD_Cas_i::GetGroups()
214 ASSERT(myHomardCas );
215 const std::list<std::string>& ListString = myHomardCas->GetGroups();
216 HOMARD::ListGroupType_var aResult = new HOMARD::ListGroupType();
217 aResult->length( ListString.size() );
218 std::list<std::string>::const_iterator it;
220 for ( it = ListString.begin(); it != ListString.end(); it++ )
222 aResult[i++] = CORBA::string_dup( (*it).c_str() );
224 return aResult._retn();
227 //=============================================================================
228 void HOMARD_Cas_i::AddBoundaryGroup( const char* Boundary, const char* Group)
230 MESSAGE ("AddBoundaryGroup");
231 ASSERT( myHomardCas );
232 myHomardCas->AddBoundaryGroup( Boundary, Group );
234 //=============================================================================
235 HOMARD::ListBoundaryGroupType* HOMARD_Cas_i::GetBoundaryGroup()
237 MESSAGE ("GetBoundaryGroup");
238 ASSERT(myHomardCas );
239 const std::list<std::string>& ListString = myHomardCas->GetBoundaryGroup();
240 HOMARD::ListBoundaryGroupType_var aResult = new HOMARD::ListBoundaryGroupType();
241 aResult->length( ListString.size() );
242 std::list<std::string>::const_iterator it;
244 for ( it = ListString.begin(); it != ListString.end(); it++ )
246 aResult[i++] = CORBA::string_dup( (*it).c_str() );
248 return aResult._retn();
251 //=============================================================================
252 void HOMARD_Cas_i::SetPyram( CORBA::Long Pyram )
254 MESSAGE ("SetPyram, Pyram = " << Pyram );
255 ASSERT( myHomardCas );
256 myHomardCas->SetPyram( Pyram );
258 //=============================================================================
259 CORBA::Long HOMARD_Cas_i::GetPyram()
261 MESSAGE ("GetPyram");
262 ASSERT( myHomardCas );
263 return myHomardCas->GetPyram();
265 //=============================================================================
266 std::string HOMARD_Cas_i::Dump() const
268 return HOMARD::Dump( *myHomardCas );
271 //=============================================================================
272 bool HOMARD_Cas_i::Restore( const std::string& stream )
274 return HOMARD::Restore( *myHomardCas, stream );