1 // HOMARD HOMARD : implementation of HOMARD idl descriptions
3 // Copyright (C) 2011-2013 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
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
32 // Quand les 2 fonctions Setxxx et Getxxx sont presentes, Setxxx est decrit en premier
34 #include "HOMARD_Zone.hxx"
35 #include "utilities.h"
37 //=============================================================================
39 * default constructor:
41 //=============================================================================
42 HOMARD_Zone::HOMARD_Zone():
43 _Name( "" ),_Type( 2 ),
44 _Xmin( 0 ), _Xmax( 0 ), _Ymin( 0 ), _Ymax( 0 ), _Zmin( 0 ), _Zmax( 0 ),
45 _Xcentre( 0 ), _Ycentre( 0 ), _Zcentre( 0 ), _Rayon( 0 ),
46 _Xaxe( 0 ), _Yaxe( 0 ), _Zaxe( 0 ), _Haut( 0 ),
47 _Xincr( 0 ), _Yincr( 0 ), _Zincr( 0 )
49 MESSAGE("HOMARD_Zone") ;
52 //=============================================================================
53 HOMARD_Zone::~HOMARD_Zone()
55 MESSAGE("~HOMARD_Zone") ;
57 //=============================================================================
58 //=============================================================================
60 //=============================================================================
61 //=============================================================================
62 void HOMARD_Zone::SetName( const char* Name )
64 _Name = std::string( Name );
66 //=============================================================================
67 std::string HOMARD_Zone::GetName() const
71 //=============================================================================
72 std::string HOMARD_Zone::GetDumpPython() const
74 // MESSAGE("GetDumpPython avec _Type " << _Type) ;
75 // MESSAGE("GetDumpPython avec _Name " << _Name) ;
76 std::ostringstream aScript;
77 aScript << "\n# Creation of the ";
78 if ( _Type >= 11 and _Type <= 13 ) { aScript << "rectangle " ; }
79 else if ( _Type == 2 ) { aScript << "box " ;}
80 else if ( _Type >= 31 and _Type <= 33 ) { aScript << "disk " ;}
81 else if ( _Type == 4 ) { aScript << "sphere " ; }
82 else if ( _Type == 5 ) { aScript << "cylinder " ; }
83 else if ( _Type >= 61 and _Type <= 63 ) { aScript << "disk with hole " ;}
84 else if ( _Type == 7 ) { aScript << "pipe " ; }
85 aScript << _Name << "\n" ;
87 aScript << "\t" << _Name << " = homard.CreateZone" ;
92 { aScript << "Box2D( \"" << _Name << "\", " << _Xmin << ", " << _Xmax << ", " << _Ymin << ", " << _Ymax << ", 1 )\n";
96 { aScript << "Box2D( \"" << _Name << "\", " << _Ymin << ", " << _Ymax << ", " << _Zmin << ", " << _Zmax << ", 2 )\n";
100 { aScript << "Box2D( \"" << _Name << "\", " << _Zmin << ", " << _Zmax << ", " << _Xmin << ", " << _Xmax << ", 3 )\n";
104 { aScript << "Box( \"" << _Name << "\", " << _Xmin << ", " << _Xmax << ", " << _Ymin << ", " << _Ymax << ", " << _Zmin << ", " << _Zmax << ")\n";
109 { aScript << "Sphere( \"" << _Name << "\", " << _Xcentre << ", " << _Ycentre << ", " << _Zcentre << ", " << _Rayon << ")\n";
114 { aScript << "Disk( \"" << _Name << "\", " << _Xcentre << ", " << _Ycentre << ", " << _Rayon << ", 1 )\n";
118 { aScript << "Disk( \"" << _Name << "\", " << _Ycentre << ", " << _Zcentre << ", " << _Rayon << ", 2 )\n";
122 { aScript << "Disk( \"" << _Name << "\", " << _Zcentre << ", " << _Xcentre << ", " << _Rayon << ", 3 )\n";
126 { aScript << "Cylinder( \"" << _Name << "\", " << _Xcentre << ", " << _Ycentre << ", " << _Zcentre << ", " << _Xaxe << ", " << _Yaxe << ", " << _Zaxe << ", " << _Rayon << ", " << _Haut << ")\n";
131 { aScript << "DiskWithHole( \"" << _Name << "\", " << _Xcentre << ", " << _Ycentre << ", " << _Rayon << ", " << _Rayonint << ", 1 )\n";
135 { aScript << "DiskWithHole( \"" << _Name << "\", " << _Ycentre << ", " << _Zcentre << ", " << _Rayon << ", " << _Rayonint << ", 2 )\n";
139 { aScript << "DiskWithHole( \"" << _Name << "\", " << _Zcentre << ", " << _Xcentre << ", " << _Rayon << ", " << _Rayonint << ", 3 )\n";
143 { aScript << "Pipe( \"" << _Name << "\", " << _Xcentre << ", " << _Ycentre << ", " << _Zcentre << ", " << _Xaxe << ", " << _Yaxe << ", " << _Zaxe << ", " << _Rayon << ", " << _Haut << ", " << _Rayonint << ")\n";
148 return aScript.str() ;
150 //=============================================================================
151 //=============================================================================
153 //=============================================================================
154 //=============================================================================
155 void HOMARD_Zone::SetType( int Type )
159 //=============================================================================
160 int HOMARD_Zone::GetType() const
164 //=======================================================================================
165 void HOMARD_Zone::SetBox( double X0, double X1, double X2, double X3, double X4, double X5 )
167 _Xmin = X0; _Xmax = X1;
168 _Ymin = X2; _Ymax = X3;
169 _Zmin = X4; _Zmax = X5;
171 //=======================================================================================
172 void HOMARD_Zone::SetCylinder( double X0, double X1, double X2,
173 double X3, double X4, double X5, double X6, double X7 )
184 //=======================================================================================
185 void HOMARD_Zone::SetPipe( double X0, double X1, double X2,
186 double X3, double X4, double X5, double X6, double X7, double X8 )
198 //======================================================================
199 void HOMARD_Zone::SetSphere( double X0, double X1, double X2, double X3 )
206 //=======================================================================================
207 std::vector<double> HOMARD_Zone::GetCoords() const
209 std::vector<double> mesCoor;
213 // Rectangle ou parallelepipede
222 mesCoor.push_back( _Xmin ) ;
223 mesCoor.push_back( _Xmax ) ;
224 mesCoor.push_back( _Ymin ) ;
225 mesCoor.push_back( _Ymax ) ;
226 mesCoor.push_back( _Zmin ) ;
227 mesCoor.push_back( _Zmax ) ;
233 mesCoor.push_back( _Xcentre ) ;
234 mesCoor.push_back( _Ycentre ) ;
235 mesCoor.push_back( _Zcentre ) ;
236 mesCoor.push_back( _Rayon ) ;
239 // Disque ou cylindre
248 mesCoor.push_back( _Xcentre ) ;
249 mesCoor.push_back( _Ycentre ) ;
250 mesCoor.push_back( _Zcentre ) ;
251 mesCoor.push_back( _Xaxe ) ;
252 mesCoor.push_back( _Yaxe ) ;
253 mesCoor.push_back( _Zaxe ) ;
254 mesCoor.push_back( _Rayon ) ;
255 mesCoor.push_back( _Haut ) ;
258 // Disque avec trou ou tuyau
267 mesCoor.push_back( _Xcentre ) ;
268 mesCoor.push_back( _Ycentre ) ;
269 mesCoor.push_back( _Zcentre ) ;
270 mesCoor.push_back( _Xaxe ) ;
271 mesCoor.push_back( _Yaxe ) ;
272 mesCoor.push_back( _Zaxe ) ;
273 mesCoor.push_back( _Rayon ) ;
274 mesCoor.push_back( _Haut ) ;
275 mesCoor.push_back( _Rayonint ) ;
278 ASSERT ( _Type == -1 ) ;
282 //======================================================================
283 void HOMARD_Zone::SetLimit( double X0, double X1, double X2 )
285 _Xincr = X0; _Yincr = X1; _Zincr = X2;
287 //=======================================================================================
288 std::vector<double> HOMARD_Zone::GetLimit() const
290 std::vector<double> mesLimit;
291 mesLimit.push_back( _Xincr ) ;
292 mesLimit.push_back( _Yincr ) ;
293 mesLimit.push_back( _Zincr ) ;
296 //=============================================================================
297 //=============================================================================
298 // Liens avec les autres structures
299 //=============================================================================
300 //=============================================================================
301 void HOMARD_Zone::AddHypo( const char* NomHypo )
303 _ListHypo.push_back( std::string( NomHypo ) ) ;
305 //=============================================================================
306 const std::list<std::string>& HOMARD_Zone::GetHypo() const
310 //=============================================================================
311 void HOMARD_Zone::SupprHypo( const char* NomHypo )
313 std::list<std::string>::iterator it = find( _ListHypo.begin(), _ListHypo.end(), NomHypo ) ;
314 if ( it != _ListHypo.end() )
316 MESSAGE ("Dans SupprHypo pour " << NomHypo) ;
317 it = _ListHypo.erase( it ) ;
320 //=============================================================================
321 void HOMARD_Zone::SupprHypos()