Salome HOME
version 5_1_4 HOMARD_SRC
[modules/homard.git] / src / HOMARD / HOMARD_Zone.cxx
1 //  HOMARD HOMARD : implementaion of HOMARD idl descriptions
2 //
3 //  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
6 //  This library is free software; you can redistribute it and/or
7 //  modify it under the terms of the GNU Lesser General Public
8 //  License as published by the Free Software Foundation; either
9 //  version 2.1 of the License.
10 //
11 //  This library is distributed in the hope that it will be useful,
12 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
13 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 //  Lesser General Public License for more details.
15 //
16 //  You should have received a copy of the GNU Lesser General Public
17 //  License along with this library; if not, write to the Free Software
18 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19 //
20 //  See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
21 //
22 //
23 //
24 //  File   : HOMARD_Zone.cxx
25 //  Author : Paul RASCLE, EDF
26 //  Module : HOMARD
27
28 #include "HOMARD_Zone.hxx"
29 #include "utilities.h"
30
31 //=============================================================================
32 /*!
33  *  default constructor:
34  */
35 //=============================================================================
36 HOMARD_Zone::HOMARD_Zone():
37   _NomZone( "" ),_ZoneType( 2 ),
38   _Xmin( 0 ), _Xmax( 0 ), _Ymin( 0 ), _Ymax( 0 ), _Zmin( 0 ), _Zmax( 0 ),
39   _Xcentre( 0 ), _Ycentre( 0 ), _Zcentre( 0 ), _rayon( 0 ),
40   _Xincr( 0 ), _Yincr( 0 ), _Zincr( 0 )
41 {
42   MESSAGE("HOMARD_Zone");
43 }
44
45 //=============================================================================
46 HOMARD_Zone::~HOMARD_Zone()
47 {
48   MESSAGE("~HOMARD_Zone");
49 }
50
51 //=============================================================================
52 void HOMARD_Zone::SetName( const char* NomZone )
53 {
54   _NomZone = std::string( NomZone );
55 }
56
57 //=============================================================================
58 std::string HOMARD_Zone::GetName() const
59 {
60   return _NomZone;
61 }
62
63 //=============================================================================
64 std::string HOMARD_Zone::GetDumpPython() const
65 {
66   std::ostringstream aScript;
67   aScript << "\n# Creation of the ";
68   if ( _ZoneType == 2 ) { aScript << "box "  << _NomZone << "\n";}
69   if ( _ZoneType == 4 ) { aScript << "sphere " << _NomZone << "\n"; }
70
71   aScript << "\t" << _NomZone << " = homard.CreateZone('" << _NomZone ;
72   aScript << "', " << _ZoneType << ")\n";
73 //
74   switch (_ZoneType)
75   {
76     case 2:
77     {
78       aScript << "\t" << _NomZone << ".SetBox(" ;
79       aScript << _Xmin << ", " << _Xmax << ", " << _Ymin << ", " << _Ymax << ", " << _Zmin << ", " << _Zmax << ")\n";
80       break;
81     }
82
83     case 4:
84     {
85       aScript << "\t" << _NomZone << ".SetSphere(" ;
86       aScript << _Xcentre << ", " << _Ycentre << ", " << _Zcentre << ", " << _rayon << ")\n";
87       break;
88     }
89   }
90
91   return aScript.str();
92 }
93
94
95 //=============================================================================
96 void HOMARD_Zone::SetZoneType( int ZoneType )
97 {
98   _ZoneType = ZoneType;
99 }
100
101 //=============================================================================
102 int HOMARD_Zone::GetZoneType() const
103 {
104   return _ZoneType;
105 }
106
107 //======================================================================
108 void HOMARD_Zone::SetLimit( double X0, double X1, double X2 )
109 {
110   _Xincr = X0; _Yincr = X1; _Zincr = X2;
111 }
112 //=======================================================================================
113 void HOMARD_Zone::SetBox( double X0, double X1, double X2, double X3, double X4, double X5 )
114 {
115   _Xmin = X0; _Xmax = X1;
116   _Ymin = X2; _Ymax = X3;
117   _Zmin = X4; _Zmax = X5;
118 }
119
120 //======================================================================
121 void HOMARD_Zone::SetSphere( double X0, double X1, double X2, double X3 )
122 {
123   _Xcentre = X0; _Ycentre = X1; _Zcentre = X2;
124   _rayon = X3;
125 }
126
127 //=======================================================================================
128 std::vector<double> HOMARD_Zone::GetLimit() const
129 {
130   std::vector<double> mesLimit;
131   mesLimit.push_back( _Xincr );
132   mesLimit.push_back( _Yincr );
133   mesLimit.push_back( _Zincr );
134   return mesLimit;
135 }
136
137 //=======================================================================================
138 std::vector<double> HOMARD_Zone::GetBox() const
139 {
140   std::vector<double> mesCoor;
141   mesCoor.push_back( _Xmin ); mesCoor.push_back( _Xmax );
142   mesCoor.push_back( _Ymin ); mesCoor.push_back( _Ymax );
143   mesCoor.push_back( _Zmin ); mesCoor.push_back( _Zmax );
144   return mesCoor;
145 }
146
147 //=======================================================================================
148 std::vector<double> HOMARD_Zone::GetSphere() const
149 {
150   std::vector<double> mesCoor;
151   mesCoor.push_back( _Xcentre );
152   mesCoor.push_back( _Ycentre );
153   mesCoor.push_back( _Zcentre ); 
154   mesCoor.push_back( _rayon );
155   return mesCoor;
156 }
157
158 //=============================================================================
159 void HOMARD_Zone::AddHypo( const char* NomHypo )
160 {
161   _ListHypo.push_back( std::string( NomHypo ) );
162 }
163
164 //=============================================================================
165 void HOMARD_Zone::SupprHypo( const char* NomHypo )
166 {
167   std::list<std::string>::iterator it = find( _ListHypo.begin(), _ListHypo.end(), NomHypo );
168   if ( it != _ListHypo.end() ) 
169   {
170     MESSAGE ("Dans SupprHypo pour " << NomHypo);
171     _ListHypo.erase( it );
172   }
173 }
174
175 //=============================================================================
176 const std::list<std::string>& HOMARD_Zone::GetHypo() const
177 {
178   return _ListHypo;
179 }
180
181 //=============================================================================
182 void HOMARD_Zone::SupprHypos()
183 {
184   _ListHypo.clear();
185 }