Salome HOME
f7743014f3056b5a5a9ad508ea55b76c2cba0d05
[modules/homard.git] / src / HOMARD / HOMARD_Boundary.cxx
1 //  HOMARD HOMARD : implementation of HOMARD idl descriptions
2 //
3 // Copyright (C) 2011-2013  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.
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 : Paul RASCLE, 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 0:
81     {
82       aScript << "discrete boundary " << _Name << "\n";
83       aScript << "\t" << _Name << " = homard.CreateBoundaryDi(\"" << _Name << "\", ";
84       aScript << "\"" << _MeshName << "\", ";
85       aScript << "\"" << _MeshFile << "\")\n";
86       break ;
87     }
88     case 1:
89     {
90       aScript << "cylinder " << _Name << "\n";
91       aScript << "\t" << _Name << " = homard.CreateBoundaryCylinder(\"" << _Name << "\", ";
92       aScript << _Xcentre << ", " << _Ycentre << ", " << _Zcentre << ", " << _Xaxe << ", " << _Yaxe << ", " << _Zaxe << ", " << _rayon << ")\n";
93       break ;
94     }
95     case 2:
96     {
97       aScript << "sphere " << _Name << "\n";
98       aScript << "\t" << _Name << " = homard.CreateBoundarySphere(\"" << _Name << "\", ";
99       aScript << _Xcentre << ", " << _Ycentre << ", " << _Zcentre << ", " << _rayon << ")\n";
100       break ;
101     }
102     case 3:
103     {
104       aScript << "cone " << _Name << "\n";
105       aScript << "\t" << _Name << " = homard.CreateBoundaryConeA(\"" << _Name << "\", ";
106       aScript << _Xaxe << ", " << _Yaxe << ", " << _Zaxe << ", " << _Angle << ", " << _Xcentre << ", " << _Ycentre << ", " << _Zcentre << ")\n";
107       break ;
108     }
109     case 4:
110     {
111       aScript << "cone " << _Name << "\n";
112       aScript << "\t" << _Name << " = homard.CreateBoundaryConeR(\"" << _Name << "\", ";
113       aScript << _Xcentre1 << ", " << _Ycentre1 << ", " << _Zcentre1 << ", " << _Rayon1 << ", " << _Xcentre2 << ", " << _Ycentre2 << ", " << _Zcentre2 << ", " << _Rayon2 << ")\n";
114       break ;
115     }
116   }
117
118   return aScript.str();
119 }
120 //=============================================================================
121 //=============================================================================
122 // Caracteristiques
123 //=============================================================================
124 //=============================================================================
125 void HOMARD_Boundary::SetType( int Type )
126 {
127   _Type = Type;
128 }
129 //=============================================================================
130 int HOMARD_Boundary::GetType() const
131 {
132   return _Type;
133 }
134 //=============================================================================
135 void HOMARD_Boundary::SetMeshName( const char* MeshName )
136 {
137   _MeshName = std::string( MeshName );
138 }
139 //=============================================================================
140 std::string HOMARD_Boundary::GetMeshName() const
141 {
142   return _MeshName;
143 }
144 //=============================================================================
145 void HOMARD_Boundary::SetMeshFile( const char* MeshFile )
146 {
147   _MeshFile = std::string( MeshFile );
148 }
149 //=============================================================================
150 std::string HOMARD_Boundary::GetMeshFile() const
151 {
152   return _MeshFile;
153 }
154 //=======================================================================================
155 void HOMARD_Boundary::SetCylinder( double X0, double X1, double X2,
156                                    double X3, double X4, double X5, double X6 )
157 {
158   _Xcentre = X0; _Ycentre = X1; _Zcentre = X2;
159   _Xaxe = X3; _Yaxe = X4; _Zaxe = X5;
160   _rayon = X6;
161 }
162 //======================================================================
163 void HOMARD_Boundary::SetSphere( double X0, double X1, double X2, double X3 )
164 {
165   _Xcentre = X0; _Ycentre = X1; _Zcentre = X2;
166   _rayon = X3;
167 }
168 //======================================================================
169 void HOMARD_Boundary::SetConeR( double Xcentre1, double Ycentre1, double Zcentre1, double Rayon1,
170                                 double Xcentre2, double Ycentre2, double Zcentre2, double Rayon2)
171 {
172   _Xcentre1 = Xcentre1; _Ycentre1 = Ycentre1; _Zcentre1 = Zcentre1;
173   _Rayon1 = Rayon1;
174   _Xcentre2 = Xcentre2; _Ycentre2 = Ycentre2; _Zcentre2 = Zcentre2;
175   _Rayon2 = Rayon2;
176 }
177 //======================================================================
178 void HOMARD_Boundary::SetConeA( double Xaxe, double Yaxe, double Zaxe, double Angle,
179                                 double Xcentre, double Ycentre, double Zcentre)
180 {
181   _Xaxe = Xaxe; _Yaxe = Yaxe; _Zaxe = Zaxe;
182   _Angle = Angle;
183   _Xcentre = Xcentre; _Ycentre = Ycentre; _Zcentre = Zcentre;
184 }
185 //=======================================================================================
186 std::vector<double> HOMARD_Boundary::GetCoords() const
187 {
188   std::vector<double> mesCoor;
189 //
190   switch (_Type)
191   {
192 //  Cylindre
193     case 1:
194     {
195       mesCoor.push_back( _Xcentre );
196       mesCoor.push_back( _Ycentre );
197       mesCoor.push_back( _Zcentre );
198       mesCoor.push_back( _Xaxe );
199       mesCoor.push_back( _Yaxe );
200       mesCoor.push_back( _Zaxe );
201       mesCoor.push_back( _rayon );
202       break ;
203     }
204 //  Sphere
205     case 2:
206     {
207       mesCoor.push_back( _Xcentre );
208       mesCoor.push_back( _Ycentre );
209       mesCoor.push_back( _Zcentre );
210       mesCoor.push_back( _rayon );
211       break ;
212     }
213 //  Cone defini par un axe et un angle
214     case 3:
215     {
216       mesCoor.push_back( _Xaxe );
217       mesCoor.push_back( _Yaxe );
218       mesCoor.push_back( _Zaxe );
219       mesCoor.push_back( _Angle );
220       mesCoor.push_back( _Xcentre );
221       mesCoor.push_back( _Ycentre );
222       mesCoor.push_back( _Zcentre );
223       break ;
224     }
225 //  Cone defini par les 2 rayons
226     case 4:
227     {
228       mesCoor.push_back( _Xcentre1 );
229       mesCoor.push_back( _Ycentre1 );
230       mesCoor.push_back( _Zcentre1 );
231       mesCoor.push_back( _Rayon1 );
232       mesCoor.push_back( _Xcentre2 );
233       mesCoor.push_back( _Ycentre2 );
234       mesCoor.push_back( _Zcentre2 );
235       mesCoor.push_back( _Rayon2 );
236       break ;
237     }
238     VERIFICATION( (_Type>=1) && (_Type<=4) ) ;
239   }
240   return mesCoor;
241 }
242 //======================================================================
243 void HOMARD_Boundary::SetLimit( double X0, double X1, double X2 )
244 {
245   _Xincr = X0; _Yincr = X1; _Zincr = X2;
246 }
247 //=======================================================================================
248 std::vector<double> HOMARD_Boundary::GetLimit() const
249 {
250   std::vector<double> mesLimit;
251   mesLimit.push_back( _Xincr );
252   mesLimit.push_back( _Yincr );
253   mesLimit.push_back( _Zincr );
254   return mesLimit;
255 }
256 //=============================================================================
257 void HOMARD_Boundary::AddGroup( const char* Group)
258 {
259   _ListGroupSelected.push_back(Group);
260 }
261 //=============================================================================
262 void HOMARD_Boundary::SetGroups( const std::list<std::string>& ListGroup )
263 {
264   _ListGroupSelected.clear();
265   std::list<std::string>::const_iterator it = ListGroup.begin();
266   while(it != ListGroup.end())
267     _ListGroupSelected.push_back((*it++));
268 }
269 //=============================================================================
270 const std::list<std::string>& HOMARD_Boundary::GetGroups() const
271 {
272   return _ListGroupSelected;
273 }
274 //=============================================================================
275 //=============================================================================
276 // Liens avec les autres structures
277 //=============================================================================
278 //=============================================================================
279 void HOMARD_Boundary::SetCaseCreation( const char* NomCasCreation )
280 {
281   _NomCasCreation = std::string( NomCasCreation );
282 }
283 //=============================================================================
284 std::string HOMARD_Boundary::GetCaseCreation() const
285 {
286   return _NomCasCreation;
287 }
288 //=============================================================================