1 // HOMARD HOMARD : implementaion of HOMARD idl descriptions
3 // Copyright (C) 2011 CEA/DEN, EDF R&D
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.
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.
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
19 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 // File : HOMARD_Zone.cxx
22 // Author : Paul RASCLE, EDF
25 #include "HOMARD_Zone.hxx"
26 #include "utilities.h"
28 //=============================================================================
30 * default constructor:
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 )
40 MESSAGE("HOMARD_Zone") ;
43 //=============================================================================
44 HOMARD_Zone::~HOMARD_Zone()
46 MESSAGE("~HOMARD_Zone") ;
49 //=============================================================================
50 void HOMARD_Zone::SetName( const char* NomZone )
52 _NomZone = std::string( NomZone ) ;
55 //=============================================================================
56 std::string HOMARD_Zone::GetName() const
61 //=============================================================================
62 std::string HOMARD_Zone::GetDumpPython() const
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" ;
77 aScript << "\t" << _NomZone << " = homard.CreateZone" ;
82 { aScript << "Box2D( \"" << _NomZone << "\", " << _Xmin << ", " << _Xmax << ", " << _Ymin << ", " << _Ymax << ", 1 )\n";
86 { aScript << "Box2D( \"" << _NomZone << "\", " << _Ymin << ", " << _Ymax << ", " << _Zmin << ", " << _Zmax << ", 2 )\n";
90 { aScript << "Box2D( \"" << _NomZone << "\", " << _Zmin << ", " << _Zmax << ", " << _Xmin << ", " << _Xmax << ", 3 )\n";
94 { aScript << "Box( \"" << _NomZone << "\", " << _Xmin << ", " << _Xmax << ", " << _Ymin << ", " << _Ymax << ", " << _Zmin << ", " << _Zmax << ")\n";
99 { aScript << "Sphere( \"" << _NomZone << "\", " << _Xcentre << ", " << _Ycentre << ", " << _Zcentre << ", " << _Rayon << ")\n";
104 { aScript << "Disk( \"" << _NomZone << "\", " << _Xcentre << ", " << _Ycentre << ", " << _Rayon << ", 1 )\n";
108 { aScript << "Disk( \"" << _NomZone << "\", " << _Ycentre << ", " << _Zcentre << ", " << _Rayon << ", 2 )\n";
112 { aScript << "Disk( \"" << _NomZone << "\", " << _Zcentre << ", " << _Xcentre << ", " << _Rayon << ", 3 )\n";
116 { aScript << "Cylinder( \"" << _NomZone << "\", " << _Xcentre << ", " << _Ycentre << ", " << _Zcentre << ", " << _Xaxe << ", " << _Yaxe << ", " << _Zaxe << ", " << _Rayon << ", " << _Haut << ")\n";
121 { aScript << "DiskWithHole( \"" << _NomZone << "\", " << _Xcentre << ", " << _Ycentre << ", " << _Rayon << ", " << _Rayonint << ", 1 )\n";
125 { aScript << "DiskWithHole( \"" << _NomZone << "\", " << _Ycentre << ", " << _Zcentre << ", " << _Rayon << ", " << _Rayonint << ", 2 )\n";
129 { aScript << "DiskWithHole( \"" << _NomZone << "\", " << _Zcentre << ", " << _Xcentre << ", " << _Rayon << ", " << _Rayonint << ", 3 )\n";
133 { aScript << "Pipe( \"" << _NomZone << "\", " << _Xcentre << ", " << _Ycentre << ", " << _Zcentre << ", " << _Xaxe << ", " << _Yaxe << ", " << _Zaxe << ", " << _Rayon << ", " << _Haut << ", " << _Rayonint << ")\n";
138 return aScript.str() ;
142 //=============================================================================
143 void HOMARD_Zone::SetZoneType( int ZoneType )
145 _ZoneType = ZoneType;
148 //=============================================================================
149 int HOMARD_Zone::GetZoneType() const
154 //======================================================================
155 void HOMARD_Zone::SetLimit( double X0, double X1, double X2 )
157 _Xincr = X0; _Yincr = X1; _Zincr = X2;
159 //=======================================================================================
160 void HOMARD_Zone::SetBox( double X0, double X1, double X2, double X3, double X4, double X5 )
162 _Xmin = X0; _Xmax = X1;
163 _Ymin = X2; _Ymax = X3;
164 _Zmin = X4; _Zmax = X5;
167 //======================================================================
168 void HOMARD_Zone::SetSphere( double X0, double X1, double X2, double X3 )
176 //=======================================================================================
177 void HOMARD_Zone::SetCylinder( double X0, double X1, double X2,
178 double X3, double X4, double X5, double X6, double X7 )
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 )
204 //=======================================================================================
205 std::vector<double> HOMARD_Zone::GetLimit() const
207 std::vector<double> mesLimit;
208 mesLimit.push_back( _Xincr ) ;
209 mesLimit.push_back( _Yincr ) ;
210 mesLimit.push_back( _Zincr ) ;
214 //=======================================================================================
215 std::vector<double> HOMARD_Zone::GetCoords() const
217 std::vector<double> mesCoor;
221 // Rectangle ou parallelepipede
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 ) ;
241 mesCoor.push_back( _Xcentre ) ;
242 mesCoor.push_back( _Ycentre ) ;
243 mesCoor.push_back( _Zcentre ) ;
244 mesCoor.push_back( _Rayon ) ;
247 // Disque ou cylindre
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 ) ;
266 // Disque avec trou ou tuyau
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 ) ;
286 ASSERT ( _ZoneType == -1 ) ;
291 //=============================================================================
292 void HOMARD_Zone::AddHypo( const char* NomHypo )
294 _ListHypo.push_back( std::string( NomHypo ) ) ;
297 //=============================================================================
298 void HOMARD_Zone::SupprHypo( const char* NomHypo )
300 std::list<std::string>::iterator it = find( _ListHypo.begin(), _ListHypo.end(), NomHypo ) ;
301 if ( it != _ListHypo.end() )
303 MESSAGE ("Dans SupprHypo pour " << NomHypo) ;
304 _ListHypo.erase( it ) ;
308 //=============================================================================
309 const std::list<std::string>& HOMARD_Zone::GetHypo() const
314 //=============================================================================
315 void HOMARD_Zone::SupprHypos()