Salome HOME
mise a jour pour la poursuite d'iterations
[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 "utilities.h"
36
37 //=============================================================================
38 /*!
39  *  default constructor:
40  */
41 //=============================================================================
42 HOMARD_Boundary::HOMARD_Boundary():
43   _Name( "" ),_Type( 1 ),
44   _Xmin( 0 ), _Xmax( 0 ), _Ymin( 0 ), _Ymax( 0 ), _Zmin( 0 ), _Zmax( 0 ),
45   _Xaxe( 0 ), _Yaxe( 0 ), _Zaxe( 0 ),
46   _Xcentre( 0 ), _Ycentre( 0 ), _Zcentre( 0 ), _rayon( 0 ),
47   _Xincr( 0 ), _Yincr( 0 ), _Zincr( 0 )
48 {
49   MESSAGE("HOMARD_Boundary");
50 }
51
52 //=============================================================================
53 HOMARD_Boundary::~HOMARD_Boundary()
54 {
55   MESSAGE("~HOMARD_Boundary");
56 }
57 //=============================================================================
58 //=============================================================================
59 // Generalites
60 //=============================================================================
61 //=============================================================================
62 void HOMARD_Boundary::SetName( const char* Name )
63 {
64   _Name = std::string( Name );
65 }
66 //=============================================================================
67 std::string HOMARD_Boundary::GetName() const
68 {
69   return _Name;
70 }
71 //=============================================================================
72 std::string HOMARD_Boundary::GetDumpPython() const
73 {
74   std::ostringstream aScript;
75   aScript << "\n# Creation of the ";
76 //
77   switch (_Type)
78   {
79     case 0:
80     {
81       aScript << "discrete boundary " << _Name << "\n";
82       aScript << "\t" << _Name << " = homard.CreateBoundaryDi(\"" << _Name << "\", ";
83       aScript << "\"" << _MeshName << "\", ";
84       aScript << "\"" << _MeshFile << "\")\n";
85       break ;
86     }
87     case 1:
88     {
89       aScript << "cylinder " << _Name << "\n";
90       aScript << "\t" << _Name << " = homard.CreateBoundaryCylinder(\"" << _Name << "\", ";
91       aScript << _Xcentre << ", " << _Ycentre << ", " << _Zcentre << ", " << _Xaxe << ", " << _Yaxe << ", " << _Zaxe << ", " << _rayon << ")\n";
92       break ;
93     }
94     case 2:
95     {
96       aScript << "sphere " << _Name << "\n";
97       aScript << "\t" << _Name << " = homard.CreateBoundarySphere(\"" << _Name << "\", ";
98       aScript << _Xcentre << ", " << _Ycentre << ", " << _Zcentre << ", " << _rayon << ")\n";
99       break ;
100     }
101     case 3:
102     {
103       aScript << "cone " << _Name << "\n";
104       aScript << "\t" << _Name << " = homard.CreateBoundaryConeA(\"" << _Name << "\", ";
105       aScript << _Xaxe << ", " << _Yaxe << ", " << _Zaxe << ", " << _Angle << ", " << _Xcentre << ", " << _Ycentre << ", " << _Zcentre << ")\n";
106       break ;
107     }
108     case 4:
109     {
110       aScript << "cone " << _Name << "\n";
111       aScript << "\t" << _Name << " = homard.CreateBoundaryConeR(\"" << _Name << "\", ";
112       aScript << _Xcentre1 << ", " << _Ycentre1 << ", " << _Zcentre1 << ", " << _Rayon1 << ", " << _Xcentre2 << ", " << _Ycentre2 << ", " << _Zcentre2 << ", " << _Rayon2 << ")\n";
113       break ;
114     }
115   }
116
117   return aScript.str();
118 }
119 //=============================================================================
120 //=============================================================================
121 // Caracteristiques
122 //=============================================================================
123 //=============================================================================
124 void HOMARD_Boundary::SetType( int Type )
125 {
126   _Type = Type;
127 }
128 //=============================================================================
129 int HOMARD_Boundary::GetType() const
130 {
131   return _Type;
132 }
133 //=============================================================================
134 void HOMARD_Boundary::SetMeshName( const char* MeshName )
135 {
136   _MeshName = std::string( MeshName );
137 }
138 //=============================================================================
139 std::string HOMARD_Boundary::GetMeshName() const
140 {
141   return _MeshName;
142 }
143 //=============================================================================
144 void HOMARD_Boundary::SetMeshFile( const char* MeshFile )
145 {
146   _MeshFile = std::string( MeshFile );
147 }
148 //=============================================================================
149 std::string HOMARD_Boundary::GetMeshFile() const
150 {
151   return _MeshFile;
152 }
153 //=======================================================================================
154 void HOMARD_Boundary::SetCylinder( double X0, double X1, double X2,
155                                    double X3, double X4, double X5, double X6 )
156 {
157   _Xcentre = X0; _Ycentre = X1; _Zcentre = X2;
158   _Xaxe = X3; _Yaxe = X4; _Zaxe = X5;
159   _rayon = X6;
160 }
161 //======================================================================
162 void HOMARD_Boundary::SetSphere( double X0, double X1, double X2, double X3 )
163 {
164   _Xcentre = X0; _Ycentre = X1; _Zcentre = X2;
165   _rayon = X3;
166 }
167 //======================================================================
168 void HOMARD_Boundary::SetConeR( double Xcentre1, double Ycentre1, double Zcentre1, double Rayon1,
169                                 double Xcentre2, double Ycentre2, double Zcentre2, double Rayon2)
170 {
171   _Xcentre1 = Xcentre1; _Ycentre1 = Ycentre1; _Zcentre1 = Zcentre1;
172   _Rayon1 = Rayon1;
173   _Xcentre2 = Xcentre2; _Ycentre2 = Ycentre2; _Zcentre2 = Zcentre2;
174   _Rayon2 = Rayon2;
175 }
176 //======================================================================
177 void HOMARD_Boundary::SetConeA( double Xaxe, double Yaxe, double Zaxe, double Angle,
178                                 double Xcentre, double Ycentre, double Zcentre)
179 {
180   _Xaxe = Xaxe; _Yaxe = Yaxe; _Zaxe = Zaxe;
181   _Angle = Angle;
182   _Xcentre = Xcentre; _Ycentre = Ycentre; _Zcentre = Zcentre;
183 }
184 //=======================================================================================
185 std::vector<double> HOMARD_Boundary::GetCoords() const
186 {
187   std::vector<double> mesCoor;
188 //
189   switch (_Type)
190   {
191 //  Cylindre
192     case 1:
193     {
194       mesCoor.push_back( _Xcentre );
195       mesCoor.push_back( _Ycentre );
196       mesCoor.push_back( _Zcentre );
197       mesCoor.push_back( _Xaxe );
198       mesCoor.push_back( _Yaxe );
199       mesCoor.push_back( _Zaxe );
200       mesCoor.push_back( _rayon );
201       break ;
202     }
203 //  Sphere
204     case 2:
205     {
206       mesCoor.push_back( _Xcentre );
207       mesCoor.push_back( _Ycentre );
208       mesCoor.push_back( _Zcentre );
209       mesCoor.push_back( _rayon );
210       break ;
211     }
212 //  Cone defini par un axe et un angle
213     case 3:
214     {
215       mesCoor.push_back( _Xaxe );
216       mesCoor.push_back( _Yaxe );
217       mesCoor.push_back( _Zaxe );
218       mesCoor.push_back( _Angle );
219       mesCoor.push_back( _Xcentre );
220       mesCoor.push_back( _Ycentre );
221       mesCoor.push_back( _Zcentre );
222       break ;
223     }
224 //  Cone defini par les 2 rayons
225     case 4:
226     {
227       mesCoor.push_back( _Xcentre1 );
228       mesCoor.push_back( _Ycentre1 );
229       mesCoor.push_back( _Zcentre1 );
230       mesCoor.push_back( _Rayon1 );
231       mesCoor.push_back( _Xcentre2 );
232       mesCoor.push_back( _Ycentre2 );
233       mesCoor.push_back( _Zcentre2 );
234       mesCoor.push_back( _Rayon2 );
235       break ;
236     }
237     ASSERT ( _Type == -1 ) ;
238   }
239   return mesCoor;
240 }
241 //======================================================================
242 void HOMARD_Boundary::SetLimit( double X0, double X1, double X2 )
243 {
244   _Xincr = X0; _Yincr = X1; _Zincr = X2;
245 }
246 //=======================================================================================
247 std::vector<double> HOMARD_Boundary::GetLimit() const
248 {
249   std::vector<double> mesLimit;
250   mesLimit.push_back( _Xincr );
251   mesLimit.push_back( _Yincr );
252   mesLimit.push_back( _Zincr );
253   return mesLimit;
254 }
255 //=============================================================================
256 void HOMARD_Boundary::AddGroup( const char* Group)
257 {
258   _ListGroupSelected.push_back(Group);
259 }
260 //=============================================================================
261 void HOMARD_Boundary::SetGroups( const std::list<std::string>& ListGroup )
262 {
263   _ListGroupSelected.clear();
264   std::list<std::string>::const_iterator it = ListGroup.begin();
265   while(it != ListGroup.end())
266     _ListGroupSelected.push_back((*it++));
267 }
268 //=============================================================================
269 const std::list<std::string>& HOMARD_Boundary::GetGroups() const
270 {
271   return _ListGroupSelected;
272 }
273 //=============================================================================
274 //=============================================================================
275 // Liens avec les autres structures
276 //=============================================================================
277 //=============================================================================
278 void HOMARD_Boundary::SetCaseCreation( const char* NomCasCreation )
279 {
280   _NomCasCreation = std::string( NomCasCreation );
281 }
282 //=============================================================================
283 std::string HOMARD_Boundary::GetCaseCreation() const
284 {
285   return _NomCasCreation;
286 }
287 //=============================================================================