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