Salome HOME
66cd160f0695dbe1db2ec49e0591b0d62d8d410a
[modules/homard.git] / src / HOMARD / HOMARD_Boundary.cxx
1 //  HOMARD HOMARD : implementation of HOMARD idl descriptions
2 //
3 // Copyright (C) 2011-2016  CEA/DEN, EDF R&D
4 //
5 // This library is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU Lesser General Public
7 // License as published by the Free Software Foundation; either
8 // version 2.1 of the License, or (at your option) any later version.
9 //
10 // This library is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13 // Lesser General Public License for more details.
14 //
15 // You should have received a copy of the GNU Lesser General Public
16 // License along with this library; if not, write to the Free Software
17 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
18 //
19 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 //
21 //  File   : HOMARD_Boundary.cxx
22 //  Author : Gerald NICOLAS, EDF
23 //  Module : HOMARD
24 //
25 // Remarques :
26 // L'ordre de description des fonctions est le meme dans tous les fichiers
27 // HOMARD_aaaa.idl, HOMARD_aaaa.hxx, HOMARD_aaaa.cxx, HOMARD_aaaa_i.hxx, HOMARD_aaaa_i.cxx :
28 // 1. Les generalites : Name, Delete, DumpPython, Dump, Restore
29 // 2. Les caracteristiques
30 // 3. Le lien avec les autres structures
31 //
32 // Quand les 2 fonctions Setxxx et Getxxx sont presentes, Setxxx est decrit en premier
33
34 #include "HOMARD_Boundary.hxx"
35 #include "HOMARD.hxx"
36 #include "utilities.h"
37
38 //=============================================================================
39 /*!
40  *  default constructor:
41  */
42 //=============================================================================
43 HOMARD_Boundary::HOMARD_Boundary():
44   _Name( "" ),_Type( 1 ),
45   _Xmin( 0 ), _Xmax( 0 ), _Ymin( 0 ), _Ymax( 0 ), _Zmin( 0 ), _Zmax( 0 ),
46   _Xaxe( 0 ), _Yaxe( 0 ), _Zaxe( 0 ),
47   _Xcentre( 0 ), _Ycentre( 0 ), _Zcentre( 0 ), _rayon( 0 ),
48   _Xincr( 0 ), _Yincr( 0 ), _Zincr( 0 )
49 {
50   MESSAGE("HOMARD_Boundary");
51 }
52
53 //=============================================================================
54 HOMARD_Boundary::~HOMARD_Boundary()
55 {
56   MESSAGE("~HOMARD_Boundary");
57 }
58 //=============================================================================
59 //=============================================================================
60 // Generalites
61 //=============================================================================
62 //=============================================================================
63 void HOMARD_Boundary::SetName( const char* Name )
64 {
65   _Name = std::string( Name );
66 }
67 //=============================================================================
68 std::string HOMARD_Boundary::GetName() const
69 {
70   return _Name;
71 }
72 //=============================================================================
73 std::string HOMARD_Boundary::GetDumpPython() const
74 {
75   std::ostringstream aScript;
76   aScript << "\n# Creation of the ";
77 //
78   switch (_Type)
79   {
80     case -1:
81     {
82       aScript << "CAO boundary " << _Name << "\n";
83       aScript << "\t" << _Name << " = homard.CreateBoundaryCAO(\"" << _Name << "\", ";
84       aScript << "\"" << _DataFile << "\")\n";
85       break ;
86     }
87     case 0:
88     {
89       aScript << "discrete boundary " << _Name << "\n";
90       aScript << "\t" << _Name << " = homard.CreateBoundaryDi(\"" << _Name << "\", ";
91       aScript << "\"" << _MeshName << "\", ";
92       aScript << "\"" << _DataFile << "\")\n";
93       break ;
94     }
95     case 1:
96     {
97       aScript << "cylinder " << _Name << "\n";
98       aScript << "\t" << _Name << " = homard.CreateBoundaryCylinder(\"" << _Name << "\", ";
99       aScript << _Xcentre << ", " << _Ycentre << ", " << _Zcentre << ", " << _Xaxe << ", " << _Yaxe << ", " << _Zaxe << ", " << _rayon << ")\n";
100       break ;
101     }
102     case 2:
103     {
104       aScript << "sphere " << _Name << "\n";
105       aScript << "\t" << _Name << " = homard.CreateBoundarySphere(\"" << _Name << "\", ";
106       aScript << _Xcentre << ", " << _Ycentre << ", " << _Zcentre << ", " << _rayon << ")\n";
107       break ;
108     }
109     case 3:
110     {
111       aScript << "cone " << _Name << "\n";
112       aScript << "\t" << _Name << " = homard.CreateBoundaryConeA(\"" << _Name << "\", ";
113       aScript << _Xaxe << ", " << _Yaxe << ", " << _Zaxe << ", " << _Angle << ", " << _Xcentre << ", " << _Ycentre << ", " << _Zcentre << ")\n";
114       break ;
115     }
116     case 4:
117     {
118       aScript << "cone " << _Name << "\n";
119       aScript << "\t" << _Name << " = homard.CreateBoundaryConeR(\"" << _Name << "\", ";
120       aScript << _Xcentre1 << ", " << _Ycentre1 << ", " << _Zcentre1 << ", " << _Rayon1 << ", " << _Xcentre2 << ", " << _Ycentre2 << ", " << _Zcentre2 << ", " << _Rayon2 << ")\n";
121       break ;
122     }
123     case 5:
124     {
125       aScript << "tore " << _Name << "\n";
126       aScript << "\t" << _Name << " = homard.CreateBoundaryTorus(\"" << _Name << "\", ";
127       aScript << _Xcentre << ", " << _Ycentre << ", " << _Zcentre << ", " << _Xaxe << ", " << _Yaxe << ", " << _Zaxe << ", " << _Rayon1 << ", " << _Rayon2 << ")\n";
128       break ;
129     }
130   }
131
132   return aScript.str();
133 }
134 //=============================================================================
135 //=============================================================================
136 // Caracteristiques
137 //=============================================================================
138 //=============================================================================
139 void HOMARD_Boundary::SetType( int Type )
140 {
141   _Type = Type;
142 }
143 //=============================================================================
144 int HOMARD_Boundary::GetType() const
145 {
146   return _Type;
147 }
148 //=============================================================================
149 void HOMARD_Boundary::SetMeshName( const char* MeshName )
150 {
151   _MeshName = std::string( MeshName );
152 }
153 //=============================================================================
154 std::string HOMARD_Boundary::GetMeshName() const
155 {
156   return _MeshName;
157 }
158 //=============================================================================
159 void HOMARD_Boundary::SetDataFile( const char* DataFile )
160 {
161   _DataFile = std::string( DataFile );
162 }
163 //=============================================================================
164 std::string HOMARD_Boundary::GetDataFile() const
165 {
166   return _DataFile;
167 }
168 //=======================================================================================
169 void HOMARD_Boundary::SetCylinder( double X0, double X1, double X2,
170                                    double X3, double X4, double X5, double X6 )
171 {
172   _Xcentre = X0; _Ycentre = X1; _Zcentre = X2;
173   _Xaxe = X3; _Yaxe = X4; _Zaxe = X5;
174   _rayon = X6;
175 }
176 //======================================================================
177 void HOMARD_Boundary::SetSphere( double X0, double X1, double X2, double X3 )
178 {
179   _Xcentre = X0; _Ycentre = X1; _Zcentre = X2;
180   _rayon = X3;
181 }
182 //======================================================================
183 void HOMARD_Boundary::SetConeR( double Xcentre1, double Ycentre1, double Zcentre1, double Rayon1,
184                                 double Xcentre2, double Ycentre2, double Zcentre2, double Rayon2)
185 {
186   _Xcentre1 = Xcentre1; _Ycentre1 = Ycentre1; _Zcentre1 = Zcentre1;
187   _Rayon1 = Rayon1;
188   _Xcentre2 = Xcentre2; _Ycentre2 = Ycentre2; _Zcentre2 = Zcentre2;
189   _Rayon2 = Rayon2;
190 }
191 //======================================================================
192 void HOMARD_Boundary::SetConeA( double Xaxe, double Yaxe, double Zaxe, double Angle,
193                                 double Xcentre, double Ycentre, double Zcentre)
194 {
195   _Xaxe = Xaxe; _Yaxe = Yaxe; _Zaxe = Zaxe;
196   _Angle = Angle;
197   _Xcentre = Xcentre; _Ycentre = Ycentre; _Zcentre = Zcentre;
198 }
199 //=======================================================================================
200 void HOMARD_Boundary::SetTorus( double X0, double X1, double X2,
201                                 double X3, double X4, double X5, double X6, double X7 )
202 {
203   _Xcentre = X0; _Ycentre = X1; _Zcentre = X2;
204   _Xaxe = X3; _Yaxe = X4; _Zaxe = X5;
205   _Rayon1 = X6;
206   _Rayon2 = X7;
207 }
208 //=======================================================================================
209 std::vector<double> HOMARD_Boundary::GetCoords() const
210 {
211   std::vector<double> mesCoor;
212 //
213   switch (_Type)
214   {
215 //  Cylindre
216     case 1:
217     {
218       mesCoor.push_back( _Xcentre );
219       mesCoor.push_back( _Ycentre );
220       mesCoor.push_back( _Zcentre );
221       mesCoor.push_back( _Xaxe );
222       mesCoor.push_back( _Yaxe );
223       mesCoor.push_back( _Zaxe );
224       mesCoor.push_back( _rayon );
225       break ;
226     }
227 //  Sphere
228     case 2:
229     {
230       mesCoor.push_back( _Xcentre );
231       mesCoor.push_back( _Ycentre );
232       mesCoor.push_back( _Zcentre );
233       mesCoor.push_back( _rayon );
234       break ;
235     }
236 //  Cone defini par un axe et un angle
237     case 3:
238     {
239       mesCoor.push_back( _Xaxe );
240       mesCoor.push_back( _Yaxe );
241       mesCoor.push_back( _Zaxe );
242       mesCoor.push_back( _Angle );
243       mesCoor.push_back( _Xcentre );
244       mesCoor.push_back( _Ycentre );
245       mesCoor.push_back( _Zcentre );
246       break ;
247     }
248 //  Cone defini par les 2 rayons
249     case 4:
250     {
251       mesCoor.push_back( _Xcentre1 );
252       mesCoor.push_back( _Ycentre1 );
253       mesCoor.push_back( _Zcentre1 );
254       mesCoor.push_back( _Rayon1 );
255       mesCoor.push_back( _Xcentre2 );
256       mesCoor.push_back( _Ycentre2 );
257       mesCoor.push_back( _Zcentre2 );
258       mesCoor.push_back( _Rayon2 );
259       break ;
260     }
261 //  Tore
262     case 5:
263     {
264       mesCoor.push_back( _Xcentre );
265       mesCoor.push_back( _Ycentre );
266       mesCoor.push_back( _Zcentre );
267       mesCoor.push_back( _Xaxe );
268       mesCoor.push_back( _Yaxe );
269       mesCoor.push_back( _Zaxe );
270       mesCoor.push_back( _Rayon1 );
271       mesCoor.push_back( _Rayon2 );
272       break ;
273     }
274     VERIFICATION( (_Type>=1) && (_Type<=5) ) ;
275   }
276   return mesCoor;
277 }
278 //======================================================================
279 void HOMARD_Boundary::SetLimit( double X0, double X1, double X2 )
280 {
281   _Xincr = X0; _Yincr = X1; _Zincr = X2;
282 }
283 //=======================================================================================
284 std::vector<double> HOMARD_Boundary::GetLimit() const
285 {
286   std::vector<double> mesLimit;
287   mesLimit.push_back( _Xincr );
288   mesLimit.push_back( _Yincr );
289   mesLimit.push_back( _Zincr );
290   return mesLimit;
291 }
292 //=============================================================================
293 void HOMARD_Boundary::AddGroup( const char* Group)
294 {
295   _ListGroupSelected.push_back(Group);
296 }
297 //=============================================================================
298 void HOMARD_Boundary::SetGroups( const std::list<std::string>& ListGroup )
299 {
300   _ListGroupSelected.clear();
301   std::list<std::string>::const_iterator it = ListGroup.begin();
302   while(it != ListGroup.end())
303     _ListGroupSelected.push_back((*it++));
304 }
305 //=============================================================================
306 const std::list<std::string>& HOMARD_Boundary::GetGroups() const
307 {
308   return _ListGroupSelected;
309 }
310 //=============================================================================
311 //=============================================================================
312 // Liens avec les autres structures
313 //=============================================================================
314 //=============================================================================
315 void HOMARD_Boundary::SetCaseCreation( const char* NomCasCreation )
316 {
317   _NomCasCreation = std::string( NomCasCreation );
318 }
319 //=============================================================================
320 std::string HOMARD_Boundary::GetCaseCreation() const
321 {
322   return _NomCasCreation;
323 }
324 //=============================================================================