Salome HOME
Merge from V6_main_20120808 08Aug12
[modules/homard.git] / src / HOMARD_I / HOMARD_Boundary_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_Boundary_i.hxx"
21 #include "HOMARD_Gen_i.hxx"
22 #include "HOMARD_Boundary.hxx"
23 #include "HOMARD_DriverTools.hxx"
24
25 #include "utilities.h"
26
27 //=============================================================================
28 /*!
29  *  standard constructor
30  */
31 //=============================================================================
32 HOMARD_Boundary_i::HOMARD_Boundary_i()
33 {
34   MESSAGE( "Default constructor, not for use" );
35   ASSERT( 0 );
36 }
37
38 //=============================================================================
39 /*!
40  *  standard constructor
41  */
42 //=============================================================================
43 HOMARD_Boundary_i::HOMARD_Boundary_i( CORBA::ORB_ptr orb,
44                               HOMARD::HOMARD_Gen_var engine )
45 {
46   MESSAGE( "HOMARD_Boundary_i" );
47   _gen_i = engine;
48   _orb = orb;
49   myHomardBoundary = new ::HOMARD_Boundary();
50   ASSERT( myHomardBoundary );
51 }
52 //=============================================================================
53 /*!
54  *  standard destructor
55  */
56 //=============================================================================
57
58 HOMARD_Boundary_i::~HOMARD_Boundary_i()
59 {
60 }
61
62 //=============================================================================
63 /*!
64  */
65 //=============================================================================
66 void HOMARD_Boundary_i::SetName( const char* NomBoundary )
67 {
68   ASSERT( myHomardBoundary );
69   myHomardBoundary->SetName( NomBoundary );
70 }
71
72 //=============================================================================
73 char* HOMARD_Boundary_i::GetName()
74 {
75   ASSERT( myHomardBoundary );
76   return CORBA::string_dup( myHomardBoundary->GetName().c_str() );
77 }
78
79 //=============================================================================
80 char* HOMARD_Boundary_i::GetDumpPython()
81 {
82   ASSERT( myHomardBoundary );
83   return CORBA::string_dup( myHomardBoundary->GetDumpPython().c_str() );
84 }
85
86
87 //=============================================================================
88 void HOMARD_Boundary_i::SetBoundaryType( CORBA::Long BoundaryType )
89 {
90   ASSERT( myHomardBoundary );
91   myHomardBoundary->SetBoundaryType( BoundaryType );
92 }
93
94 //=============================================================================
95 CORBA::Long HOMARD_Boundary_i::GetBoundaryType()
96 {
97   ASSERT( myHomardBoundary );
98   return  CORBA::Long( myHomardBoundary->GetBoundaryType() );
99 }
100
101 //=============================================================================
102 void HOMARD_Boundary_i::SetMeshFile( const char* MeshFile )
103 {
104   ASSERT( myHomardBoundary );
105   myHomardBoundary->SetMeshFile( MeshFile );
106   _gen_i->PublishResultInSmesh(MeshFile, 0);
107 }
108 //=============================================================================
109 char* HOMARD_Boundary_i::GetMeshFile()
110 {
111   ASSERT( myHomardBoundary );
112   return CORBA::string_dup( myHomardBoundary->GetMeshFile().c_str() );
113 }
114
115 //=============================================================================
116 void HOMARD_Boundary_i::SetMeshName( const char* MeshName )
117 {
118   ASSERT( myHomardBoundary );
119   myHomardBoundary->SetMeshName( MeshName );
120 }
121
122 //=============================================================================
123 char* HOMARD_Boundary_i::GetMeshName()
124 {
125   ASSERT( myHomardBoundary );
126   return CORBA::string_dup( myHomardBoundary->GetMeshName().c_str() );
127 }
128
129
130 //=============================================================================
131 void HOMARD_Boundary_i::SetCylinder( double X0, double X1, double X2, double X3, double X4, double X5, double X6 )
132 {
133   ASSERT( myHomardBoundary );
134   myHomardBoundary->SetCylinder( X0, X1, X2, X3, X4, X5, X6 );
135 }
136 //=============================================================================
137 void HOMARD_Boundary_i::SetSphere( double Xcentre, double Ycentre, double ZCentre, double rayon )
138 {
139   ASSERT( myHomardBoundary );
140   myHomardBoundary->SetSphere( Xcentre, Ycentre, ZCentre, rayon );
141 }
142
143 //=============================================================================
144 HOMARD::double_array* HOMARD_Boundary_i::GetCoords()
145 {
146   ASSERT( myHomardBoundary );
147   HOMARD::double_array_var aResult = new HOMARD::double_array();
148   std::vector<double> mesCoor = myHomardBoundary->GetCoords();
149   aResult->length( mesCoor .size() );
150   std::vector<double>::const_iterator it;
151   int i = 0;
152   for ( it = mesCoor.begin(); it != mesCoor.end(); it++ )
153     aResult[i++] = (*it);
154   return aResult._retn();
155 }
156
157 //=============================================================================
158 void HOMARD_Boundary_i::SetLimit( double Xincr, double Yincr, double Zincr )
159 {
160   ASSERT( myHomardBoundary );
161   myHomardBoundary->SetLimit( Xincr, Yincr, Zincr );
162 }
163
164 //=============================================================================
165 HOMARD::double_array* HOMARD_Boundary_i::GetLimit()
166 {
167   ASSERT( myHomardBoundary );
168   HOMARD::double_array_var aResult = new HOMARD::double_array();
169   std::vector<double> mesCoor = myHomardBoundary->GetLimit();
170   aResult->length( mesCoor .size() );
171   std::vector<double>::const_iterator it;
172   int i = 0;
173   for ( it = mesCoor.begin(); it != mesCoor.end(); it++ )
174     aResult[i++] = (*it);
175   return aResult._retn();
176 }
177 //=============================================================================
178 /*!
179  */
180 //=============================================================================
181 void HOMARD_Boundary_i::SetCaseCreation( const char* NomCaseCreation )
182 {
183   ASSERT( myHomardBoundary );
184   myHomardBoundary->SetCaseCreation( NomCaseCreation );
185 }
186
187 //=============================================================================
188 char* HOMARD_Boundary_i::GetCaseCreation()
189 {
190   ASSERT( myHomardBoundary );
191   return CORBA::string_dup( myHomardBoundary->GetCaseCreation().c_str() );
192 }
193 //=============================================================================
194 void HOMARD_Boundary_i::AddGroup( const char* Group)
195 {
196   ASSERT( myHomardBoundary );
197   myHomardBoundary->AddGroup( Group );
198 }
199 //=============================================================================
200 void HOMARD_Boundary_i::SetGroups(const HOMARD::ListGroupType& ListGroup)
201 {
202   ASSERT( myHomardBoundary );
203   std::list<std::string> ListString;
204   for ( int i = 0; i < ListGroup.length(); i++ )
205   {
206       ListString.push_back(std::string(ListGroup[i]));
207   }
208   myHomardBoundary->SetGroups( ListString );
209 }
210 //=============================================================================
211 HOMARD::ListGroupType*  HOMARD_Boundary_i::GetGroups()
212 {
213   ASSERT( myHomardBoundary );
214   const std::list<std::string>& ListString = myHomardBoundary->GetGroups();
215   HOMARD::ListGroupType_var aResult = new HOMARD::ListGroupType;
216   aResult->length( ListString.size() );
217   std::list<std::string>::const_iterator it;
218   int i = 0;
219   for ( it = ListString.begin(); it != ListString.end(); it++ )
220   {
221     aResult[i++] = CORBA::string_dup( (*it).c_str() );
222   }
223   return aResult._retn();
224 }
225
226
227
228 //=============================================================================
229 std::string HOMARD_Boundary_i::Dump() const
230 {
231   return HOMARD::Dump( *myHomardBoundary );
232 }
233
234 //=============================================================================
235 bool HOMARD_Boundary_i::Restore( const std::string& stream )
236 {
237   return HOMARD::Restore( *myHomardBoundary, stream );
238 }