]> SALOME platform Git repositories - modules/homard.git/blob - src/HOMARD/HOMARD_Zone.cxx
Salome HOME
PR: patch Andre Ribes (probleme link Ubuntu 11.10)
[modules/homard.git] / src / HOMARD / HOMARD_Zone.cxx
1 //  HOMARD HOMARD : implementaion of HOMARD idl descriptions
2 //
3 // Copyright (C) 2011  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_Zone.cxx
22 //  Author : Paul RASCLE, EDF
23 //  Module : HOMARD
24
25 #include "HOMARD_Zone.hxx"
26 #include "utilities.h"
27
28 //=============================================================================
29 /*!
30  *  default constructor:
31  */
32 //=============================================================================
33 HOMARD_Zone::HOMARD_Zone():
34   _NomZone( "" ),_ZoneType( 2 ),
35   _Xmin( 0 ), _Xmax( 0 ), _Ymin( 0 ), _Ymax( 0 ), _Zmin( 0 ), _Zmax( 0 ),
36   _Xcentre( 0 ), _Ycentre( 0 ), _Zcentre( 0 ), _Rayon( 0 ),
37   _Xaxe( 0 ), _Yaxe( 0 ), _Zaxe( 0 ), _Haut( 0 ),
38   _Xincr( 0 ), _Yincr( 0 ), _Zincr( 0 )
39 {
40   MESSAGE("HOMARD_Zone") ;
41 }
42
43 //=============================================================================
44 HOMARD_Zone::~HOMARD_Zone()
45 {
46   MESSAGE("~HOMARD_Zone") ;
47 }
48
49 //=============================================================================
50 void HOMARD_Zone::SetName( const char* NomZone )
51 {
52   _NomZone = std::string( NomZone ) ;
53 }
54
55 //=============================================================================
56 std::string HOMARD_Zone::GetName() const
57 {
58   return _NomZone;
59 }
60
61 //=============================================================================
62 std::string HOMARD_Zone::GetDumpPython() const
63 {
64 //   MESSAGE("GetDumpPython avec _ZoneType " << _ZoneType) ;
65 //   MESSAGE("GetDumpPython avec _NomZone " << _NomZone) ;
66   std::ostringstream aScript;
67   aScript << "\n# Creation of the ";
68   if ( _ZoneType >= 11 and _ZoneType <= 13 ) { aScript << "rectangle " ; }
69   else if ( _ZoneType == 2 ) { aScript << "box " ;}
70   else if ( _ZoneType >= 31 and _ZoneType <= 33 ) { aScript << "disk " ;}
71   else if ( _ZoneType == 4 ) { aScript << "sphere " ; }
72   else if ( _ZoneType == 5 ) { aScript << "cylinder " ; }
73   else if ( _ZoneType >= 61 and _ZoneType <= 63 ) { aScript << "disk with hole " ;}
74   else if ( _ZoneType == 7 ) { aScript << "pipe " ; }
75   aScript << _NomZone << "\n" ;
76 //
77   aScript << "\t" << _NomZone << " = homard.CreateZone" ;
78 //
79   switch (_ZoneType)
80   {
81     case 11:
82     { aScript << "Box2D( \"" << _NomZone << "\", " << _Xmin << ", " << _Xmax << ", " << _Ymin << ", " << _Ymax << ", 1 )\n";
83       break ;
84     }
85     case 12:
86     { aScript << "Box2D( \"" << _NomZone << "\", " << _Ymin << ", " << _Ymax << ", " << _Zmin << ", " << _Zmax << ", 2 )\n";
87       break ;
88     }
89     case 13:
90     { aScript << "Box2D( \"" << _NomZone << "\", " << _Zmin << ", " << _Zmax << ", " << _Xmin << ", " << _Xmax << ", 3 )\n";
91       break ;
92     }
93     case 2:
94     { aScript << "Box( \""  << _NomZone << "\", " << _Xmin << ", " << _Xmax << ", " << _Ymin << ", " << _Ymax << ", " << _Zmin << ", " << _Zmax << ")\n";
95       break ;
96     }
97
98     case 4:
99     { aScript << "Sphere( \"" << _NomZone << "\", " << _Xcentre << ", " << _Ycentre << ", " << _Zcentre << ", " << _Rayon << ")\n";
100       break ;
101     }
102
103     case 31:
104     { aScript << "Disk( \"" << _NomZone << "\", " << _Xcentre << ", " << _Ycentre << ", " << _Rayon << ", 1 )\n";
105       break ;
106     }
107     case 32:
108     { aScript << "Disk( \"" << _NomZone << "\", " << _Ycentre << ", " << _Zcentre << ", " << _Rayon << ", 2 )\n";
109       break ;
110     }
111     case 33:
112     { aScript << "Disk( \"" << _NomZone << "\", " << _Zcentre << ", " << _Xcentre << ", " << _Rayon << ", 3 )\n";
113       break ;
114     }
115     case 5:
116     { aScript << "Cylinder( \"" << _NomZone << "\", " << _Xcentre << ", " << _Ycentre << ", " << _Zcentre << ", " << _Xaxe << ", " << _Yaxe << ", " << _Zaxe << ", " << _Rayon << ", " << _Haut << ")\n";
117       break ;
118     }
119
120     case 61:
121     { aScript << "DiskWithHole( \"" << _NomZone << "\", " << _Xcentre << ", " << _Ycentre << ", " << _Rayon << ", " << _Rayonint << ", 1 )\n";
122       break ;
123     }
124     case 62:
125     { aScript << "DiskWithHole( \"" << _NomZone << "\", " << _Ycentre << ", " << _Zcentre << ", " << _Rayon << ", " << _Rayonint << ", 2 )\n";
126       break ;
127     }
128     case 63:
129     { aScript << "DiskWithHole( \"" << _NomZone << "\", " << _Zcentre << ", " << _Xcentre << ", " << _Rayon << ", " << _Rayonint << ", 3 )\n";
130       break ;
131     }
132     case 7:
133     { aScript << "Pipe( \"" << _NomZone << "\", " << _Xcentre << ", " << _Ycentre << ", " << _Zcentre << ", " << _Xaxe << ", " << _Yaxe << ", " << _Zaxe << ", " << _Rayon << ", " << _Haut << ", " << _Rayonint << ")\n";
134       break ;
135     }
136   }
137
138   return aScript.str() ;
139 }
140
141
142 //=============================================================================
143 void HOMARD_Zone::SetZoneType( int ZoneType )
144 {
145   _ZoneType = ZoneType;
146 }
147
148 //=============================================================================
149 int HOMARD_Zone::GetZoneType() const
150 {
151   return _ZoneType;
152 }
153
154 //======================================================================
155 void HOMARD_Zone::SetLimit( double X0, double X1, double X2 )
156 {
157   _Xincr = X0; _Yincr = X1; _Zincr = X2;
158 }
159 //=======================================================================================
160 void HOMARD_Zone::SetBox( double X0, double X1, double X2, double X3, double X4, double X5 )
161 {
162   _Xmin = X0; _Xmax = X1;
163   _Ymin = X2; _Ymax = X3;
164   _Zmin = X4; _Zmax = X5;
165 }
166
167 //======================================================================
168 void HOMARD_Zone::SetSphere( double X0, double X1, double X2, double X3 )
169 {
170   _Xcentre = X0;
171   _Ycentre = X1;
172   _Zcentre = X2;
173   _Rayon = X3;
174 }
175
176 //=======================================================================================
177 void HOMARD_Zone::SetCylinder( double X0, double X1, double X2,
178                                double X3, double X4, double X5, double X6, double X7 )
179 {
180   _Xcentre = X0;
181   _Ycentre = X1;
182   _Zcentre = X2;
183   _Xaxe = X3;
184   _Yaxe = X4;
185   _Zaxe = X5;
186   _Rayon = X6;
187   _Haut = X7;
188 }
189 //=======================================================================================
190 void HOMARD_Zone::SetPipe( double X0, double X1, double X2,
191                            double X3, double X4, double X5, double X6, double X7, double X8 )
192 {
193   _Xcentre = X0;
194   _Ycentre = X1;
195   _Zcentre = X2;
196   _Xaxe = X3;
197   _Yaxe = X4;
198   _Zaxe = X5;
199   _Rayon = X6;
200   _Haut = X7;
201   _Rayonint = X8;
202 }
203
204 //=======================================================================================
205 std::vector<double> HOMARD_Zone::GetLimit() const
206 {
207   std::vector<double> mesLimit;
208   mesLimit.push_back( _Xincr ) ;
209   mesLimit.push_back( _Yincr ) ;
210   mesLimit.push_back( _Zincr ) ;
211   return mesLimit;
212 }
213
214 //=======================================================================================
215 std::vector<double> HOMARD_Zone::GetCoords() const
216 {
217   std::vector<double> mesCoor;
218 //
219   switch (_ZoneType)
220   {
221 //  Rectangle ou parallelepipede
222     case 11:
223     { }
224     case 12:
225     { }
226     case 13:
227     { }
228     case 2:
229     {
230       mesCoor.push_back( _Xmin ) ;
231       mesCoor.push_back( _Xmax ) ;
232       mesCoor.push_back( _Ymin ) ;
233       mesCoor.push_back( _Ymax ) ;
234       mesCoor.push_back( _Zmin ) ;
235       mesCoor.push_back( _Zmax ) ;
236       break ;
237     }
238 //  Sphere
239     case 4:
240     {
241       mesCoor.push_back( _Xcentre ) ;
242       mesCoor.push_back( _Ycentre ) ;
243       mesCoor.push_back( _Zcentre ) ;
244       mesCoor.push_back( _Rayon ) ;
245       break ;
246     }
247 //  Disque ou cylindre
248     case 31:
249     { }
250     case 32:
251     { }
252     case 33:
253     { }
254     case 5:
255     {
256       mesCoor.push_back( _Xcentre ) ;
257       mesCoor.push_back( _Ycentre ) ;
258       mesCoor.push_back( _Zcentre ) ;
259       mesCoor.push_back( _Xaxe ) ;
260       mesCoor.push_back( _Yaxe ) ;
261       mesCoor.push_back( _Zaxe ) ;
262       mesCoor.push_back( _Rayon ) ;
263       mesCoor.push_back( _Haut ) ;
264       break ;
265     }
266 //  Disque avec trou ou tuyau
267     case 61:
268     { }
269     case 62:
270     { }
271     case 63:
272     { }
273     case 7:
274     {
275       mesCoor.push_back( _Xcentre ) ;
276       mesCoor.push_back( _Ycentre ) ;
277       mesCoor.push_back( _Zcentre ) ;
278       mesCoor.push_back( _Xaxe ) ;
279       mesCoor.push_back( _Yaxe ) ;
280       mesCoor.push_back( _Zaxe ) ;
281       mesCoor.push_back( _Rayon ) ;
282       mesCoor.push_back( _Haut ) ;
283       mesCoor.push_back( _Rayonint ) ;
284       break ;
285     }
286     ASSERT ( _ZoneType == -1 ) ;
287   }
288   return mesCoor;
289 }
290
291 //=============================================================================
292 void HOMARD_Zone::AddHypo( const char* NomHypo )
293 {
294   _ListHypo.push_back( std::string( NomHypo ) ) ;
295 }
296
297 //=============================================================================
298 void HOMARD_Zone::SupprHypo( const char* NomHypo )
299 {
300   std::list<std::string>::iterator it = find( _ListHypo.begin(), _ListHypo.end(), NomHypo ) ;
301   if ( it != _ListHypo.end() )
302   {
303     MESSAGE ("Dans SupprHypo pour " << NomHypo) ;
304     _ListHypo.erase( it ) ;
305   }
306 }
307
308 //=============================================================================
309 const std::list<std::string>& HOMARD_Zone::GetHypo() const
310 {
311   return _ListHypo;
312 }
313
314 //=============================================================================
315 void HOMARD_Zone::SupprHypos()
316 {
317   _ListHypo.clear() ;
318 }