1 // HOMARD HOMARD : implementation of HOMARD idl descriptions
3 // Copyright (C) 2011-2014 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, or (at your option) any later version.
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"
36 #include "utilities.h"
38 //=============================================================================
40 * default constructor:
42 //=============================================================================
43 HOMARD_Zone::HOMARD_Zone():
44 _Name( "" ),_Type( 2 ),
45 _Xmin( 0 ), _Xmax( 0 ), _Ymin( 0 ), _Ymax( 0 ), _Zmin( 0 ), _Zmax( 0 ),
46 _Xcentre( 0 ), _Ycentre( 0 ), _Zcentre( 0 ), _Rayon( 0 ),
47 _Xaxe( 0 ), _Yaxe( 0 ), _Zaxe( 0 ), _Haut( 0 ),
48 _Xincr( 0 ), _Yincr( 0 ), _Zincr( 0 )
50 MESSAGE("HOMARD_Zone") ;
53 //=============================================================================
54 HOMARD_Zone::~HOMARD_Zone()
56 MESSAGE("~HOMARD_Zone") ;
58 //=============================================================================
59 //=============================================================================
61 //=============================================================================
62 //=============================================================================
63 void HOMARD_Zone::SetName( const char* Name )
65 _Name = std::string( Name );
67 //=============================================================================
68 std::string HOMARD_Zone::GetName() const
72 //=============================================================================
73 std::string HOMARD_Zone::GetDumpPython() const
75 // MESSAGE("GetDumpPython avec _Type " << _Type) ;
76 // MESSAGE("GetDumpPython avec _Name " << _Name) ;
77 std::ostringstream aScript;
78 aScript << "\n# Creation of the ";
79 if ( _Type >= 11 && _Type <= 13 ) { aScript << "rectangle " ; }
80 else if ( _Type == 2 ) { aScript << "box " ;}
81 else if ( _Type >= 31 && _Type <= 33 ) { aScript << "disk " ;}
82 else if ( _Type == 4 ) { aScript << "sphere " ; }
83 else if ( _Type == 5 ) { aScript << "cylinder " ; }
84 else if ( _Type >= 61 && _Type <= 63 ) { aScript << "disk with hole " ;}
85 else if ( _Type == 7 ) { aScript << "pipe " ; }
86 aScript << _Name << "\n" ;
88 aScript << "\t" << _Name << " = homard.CreateZone" ;
93 { aScript << "Box2D( \"" << _Name << "\", " << _Xmin << ", " << _Xmax << ", " << _Ymin << ", " << _Ymax << ", 1 )\n";
97 { aScript << "Box2D( \"" << _Name << "\", " << _Ymin << ", " << _Ymax << ", " << _Zmin << ", " << _Zmax << ", 2 )\n";
101 { aScript << "Box2D( \"" << _Name << "\", " << _Zmin << ", " << _Zmax << ", " << _Xmin << ", " << _Xmax << ", 3 )\n";
105 { aScript << "Box( \"" << _Name << "\", " << _Xmin << ", " << _Xmax << ", " << _Ymin << ", " << _Ymax << ", " << _Zmin << ", " << _Zmax << ")\n";
110 { aScript << "Sphere( \"" << _Name << "\", " << _Xcentre << ", " << _Ycentre << ", " << _Zcentre << ", " << _Rayon << ")\n";
115 { aScript << "Disk( \"" << _Name << "\", " << _Xcentre << ", " << _Ycentre << ", " << _Rayon << ", 1 )\n";
119 { aScript << "Disk( \"" << _Name << "\", " << _Ycentre << ", " << _Zcentre << ", " << _Rayon << ", 2 )\n";
123 { aScript << "Disk( \"" << _Name << "\", " << _Zcentre << ", " << _Xcentre << ", " << _Rayon << ", 3 )\n";
127 { aScript << "Cylinder( \"" << _Name << "\", " << _Xcentre << ", " << _Ycentre << ", " << _Zcentre << ", " << _Xaxe << ", " << _Yaxe << ", " << _Zaxe << ", " << _Rayon << ", " << _Haut << ")\n";
132 { aScript << "DiskWithHole( \"" << _Name << "\", " << _Xcentre << ", " << _Ycentre << ", " << _Rayon << ", " << _Rayonint << ", 1 )\n";
136 { aScript << "DiskWithHole( \"" << _Name << "\", " << _Ycentre << ", " << _Zcentre << ", " << _Rayon << ", " << _Rayonint << ", 2 )\n";
140 { aScript << "DiskWithHole( \"" << _Name << "\", " << _Zcentre << ", " << _Xcentre << ", " << _Rayon << ", " << _Rayonint << ", 3 )\n";
144 { aScript << "Pipe( \"" << _Name << "\", " << _Xcentre << ", " << _Ycentre << ", " << _Zcentre << ", " << _Xaxe << ", " << _Yaxe << ", " << _Zaxe << ", " << _Rayon << ", " << _Haut << ", " << _Rayonint << ")\n";
149 return aScript.str() ;
151 //=============================================================================
152 //=============================================================================
154 //=============================================================================
155 //=============================================================================
156 void HOMARD_Zone::SetType( int Type )
160 //=============================================================================
161 int HOMARD_Zone::GetType() const
165 //=======================================================================================
166 void HOMARD_Zone::SetBox( double X0, double X1, double X2, double X3, double X4, double X5 )
168 _Xmin = X0; _Xmax = X1;
169 _Ymin = X2; _Ymax = X3;
170 _Zmin = X4; _Zmax = X5;
172 //=======================================================================================
173 void HOMARD_Zone::SetCylinder( double X0, double X1, double X2,
174 double X3, double X4, double X5, double X6, double X7 )
185 //=======================================================================================
186 void HOMARD_Zone::SetPipe( double X0, double X1, double X2,
187 double X3, double X4, double X5, double X6, double X7, double X8 )
199 //======================================================================
200 void HOMARD_Zone::SetSphere( double X0, double X1, double X2, double X3 )
207 //=======================================================================================
208 std::vector<double> HOMARD_Zone::GetCoords() const
210 std::vector<double> mesCoor;
214 // Rectangle ou parallelepipede
223 mesCoor.push_back( _Xmin ) ;
224 mesCoor.push_back( _Xmax ) ;
225 mesCoor.push_back( _Ymin ) ;
226 mesCoor.push_back( _Ymax ) ;
227 mesCoor.push_back( _Zmin ) ;
228 mesCoor.push_back( _Zmax ) ;
234 mesCoor.push_back( _Xcentre ) ;
235 mesCoor.push_back( _Ycentre ) ;
236 mesCoor.push_back( _Zcentre ) ;
237 mesCoor.push_back( _Rayon ) ;
240 // Disque ou cylindre
249 mesCoor.push_back( _Xcentre ) ;
250 mesCoor.push_back( _Ycentre ) ;
251 mesCoor.push_back( _Zcentre ) ;
252 mesCoor.push_back( _Xaxe ) ;
253 mesCoor.push_back( _Yaxe ) ;
254 mesCoor.push_back( _Zaxe ) ;
255 mesCoor.push_back( _Rayon ) ;
256 mesCoor.push_back( _Haut ) ;
259 // Disque avec trou ou tuyau
268 mesCoor.push_back( _Xcentre ) ;
269 mesCoor.push_back( _Ycentre ) ;
270 mesCoor.push_back( _Zcentre ) ;
271 mesCoor.push_back( _Xaxe ) ;
272 mesCoor.push_back( _Yaxe ) ;
273 mesCoor.push_back( _Zaxe ) ;
274 mesCoor.push_back( _Rayon ) ;
275 mesCoor.push_back( _Haut ) ;
276 mesCoor.push_back( _Rayonint ) ;
279 VERIFICATION ( ( (_Type>10) && (_Type<14) ) || (_Type==2) || ( (_Type>30) && (_Type<34) ) || (_Type==4) || (_Type==5) || ( (_Type>60) && (_Type<64) ) || (_Type==7) ) ;
283 //======================================================================
284 void HOMARD_Zone::SetLimit( double X0, double X1, double X2 )
286 _Xincr = X0; _Yincr = X1; _Zincr = X2;
288 //=======================================================================================
289 std::vector<double> HOMARD_Zone::GetLimit() const
291 std::vector<double> mesLimit;
292 mesLimit.push_back( _Xincr ) ;
293 mesLimit.push_back( _Yincr ) ;
294 mesLimit.push_back( _Zincr ) ;
297 //=============================================================================
298 //=============================================================================
299 // Liens avec les autres structures
300 //=============================================================================
301 //=============================================================================
302 void HOMARD_Zone::AddHypo( const char* NomHypo )
304 _ListHypo.push_back( std::string( NomHypo ) ) ;
306 //=============================================================================
307 const std::list<std::string>& HOMARD_Zone::GetHypo() const
311 //=============================================================================
312 void HOMARD_Zone::SupprHypo( const char* NomHypo )
314 std::list<std::string>::iterator it = find( _ListHypo.begin(), _ListHypo.end(), NomHypo ) ;
315 if ( it != _ListHypo.end() )
317 MESSAGE ("Dans SupprHypo pour " << NomHypo) ;
318 it = _ListHypo.erase( it ) ;
321 //=============================================================================
322 void HOMARD_Zone::SupprHypos()