1 // HOMARD HOMARD : implementaion of HOMARD idl descriptions
3 // Copyright (C) 2011-2012 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() ;
141 //=============================================================================
142 void HOMARD_Zone::SetZoneType( int ZoneType )
144 _ZoneType = ZoneType;
147 //=============================================================================
148 int HOMARD_Zone::GetZoneType() const
153 //======================================================================
154 void HOMARD_Zone::SetLimit( double X0, double X1, double X2 )
156 _Xincr = X0; _Yincr = X1; _Zincr = X2;
158 //=======================================================================================
159 void HOMARD_Zone::SetBox( double X0, double X1, double X2, double X3, double X4, double X5 )
161 _Xmin = X0; _Xmax = X1;
162 _Ymin = X2; _Ymax = X3;
163 _Zmin = X4; _Zmax = X5;
166 //======================================================================
167 void HOMARD_Zone::SetSphere( double X0, double X1, double X2, double X3 )
175 //=======================================================================================
176 void HOMARD_Zone::SetCylinder( double X0, double X1, double X2,
177 double X3, double X4, double X5, double X6, double X7 )
188 //=======================================================================================
189 void HOMARD_Zone::SetPipe( double X0, double X1, double X2,
190 double X3, double X4, double X5, double X6, double X7, double X8 )
203 //=======================================================================================
204 std::vector<double> HOMARD_Zone::GetLimit() const
206 std::vector<double> mesLimit;
207 mesLimit.push_back( _Xincr ) ;
208 mesLimit.push_back( _Yincr ) ;
209 mesLimit.push_back( _Zincr ) ;
213 //=======================================================================================
214 std::vector<double> HOMARD_Zone::GetCoords() const
216 std::vector<double> mesCoor;
220 // Rectangle ou parallelepipede
229 mesCoor.push_back( _Xmin ) ;
230 mesCoor.push_back( _Xmax ) ;
231 mesCoor.push_back( _Ymin ) ;
232 mesCoor.push_back( _Ymax ) ;
233 mesCoor.push_back( _Zmin ) ;
234 mesCoor.push_back( _Zmax ) ;
240 mesCoor.push_back( _Xcentre ) ;
241 mesCoor.push_back( _Ycentre ) ;
242 mesCoor.push_back( _Zcentre ) ;
243 mesCoor.push_back( _Rayon ) ;
246 // Disque ou cylindre
255 mesCoor.push_back( _Xcentre ) ;
256 mesCoor.push_back( _Ycentre ) ;
257 mesCoor.push_back( _Zcentre ) ;
258 mesCoor.push_back( _Xaxe ) ;
259 mesCoor.push_back( _Yaxe ) ;
260 mesCoor.push_back( _Zaxe ) ;
261 mesCoor.push_back( _Rayon ) ;
262 mesCoor.push_back( _Haut ) ;
265 // Disque avec trou ou tuyau
274 mesCoor.push_back( _Xcentre ) ;
275 mesCoor.push_back( _Ycentre ) ;
276 mesCoor.push_back( _Zcentre ) ;
277 mesCoor.push_back( _Xaxe ) ;
278 mesCoor.push_back( _Yaxe ) ;
279 mesCoor.push_back( _Zaxe ) ;
280 mesCoor.push_back( _Rayon ) ;
281 mesCoor.push_back( _Haut ) ;
282 mesCoor.push_back( _Rayonint ) ;
285 ASSERT ( _ZoneType == -1 ) ;
290 //=============================================================================
291 void HOMARD_Zone::AddHypo( const char* NomHypo )
293 _ListHypo.push_back( std::string( NomHypo ) ) ;
296 //=============================================================================
297 void HOMARD_Zone::SupprHypo( const char* NomHypo )
299 std::list<std::string>::iterator it = find( _ListHypo.begin(), _ListHypo.end(), NomHypo ) ;
300 if ( it != _ListHypo.end() )
302 MESSAGE ("Dans SupprHypo pour " << NomHypo) ;
303 _ListHypo.erase( it ) ;
307 //=============================================================================
308 const std::list<std::string>& HOMARD_Zone::GetHypo() const
313 //=============================================================================
314 void HOMARD_Zone::SupprHypos()