Salome HOME
version V6_main 20110308
[modules/homard.git] / src / HOMARD / HOMARD_Boundary.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_Boundary.cxx
25 //  Author : Paul RASCLE, EDF
26 //  Module : HOMARD
27
28 #include "HOMARD_Boundary.hxx"
29 #include "utilities.h"
30
31 //=============================================================================
32 /*!
33  *  default constructor:
34  */
35 //=============================================================================
36 HOMARD_Boundary::HOMARD_Boundary():
37   _NomBoundary( "" ),_BoundaryType( 1 ),
38   _Xmin( 0 ), _Xmax( 0 ), _Ymin( 0 ), _Ymax( 0 ), _Zmin( 0 ), _Zmax( 0 ),
39   _Xaxe( 0 ), _Yaxe( 0 ), _Zaxe( 0 ),
40   _Xcentre( 0 ), _Ycentre( 0 ), _Zcentre( 0 ), _rayon( 0 ),
41   _Xincr( 0 ), _Yincr( 0 ), _Zincr( 0 )
42 {
43   MESSAGE("HOMARD_Boundary");
44 }
45
46 //=============================================================================
47 HOMARD_Boundary::~HOMARD_Boundary()
48 {
49   MESSAGE("~HOMARD_Boundary");
50 }
51
52 //=============================================================================
53 void HOMARD_Boundary::SetName( const char* NomBoundary )
54 {
55   MESSAGE("SetName = "<<NomBoundary);
56   _NomBoundary = std::string( NomBoundary );
57 }
58
59 //=============================================================================
60 std::string HOMARD_Boundary::GetName() const
61 {
62   return _NomBoundary;
63 }
64
65 //=============================================================================
66 std::string HOMARD_Boundary::GetDumpPython() const
67 {
68   std::ostringstream aScript;
69   aScript << "\n# Creation of the ";
70   if ( _BoundaryType == 0 ) { aScript << "discrete boundary " << _NomBoundary << "\n";}
71   if ( _BoundaryType == 1 ) { aScript << "cylinder " << _NomBoundary << "\n";}
72   if ( _BoundaryType == 2 ) { aScript << "sphere " << _NomBoundary << "\n"; }
73
74   aScript << "\t" << _NomBoundary << " = homard.CreateBoundary('" << _NomBoundary ;
75   aScript << "', " << _BoundaryType << ")\n";
76 //
77   switch (_BoundaryType)
78   {
79     case 0:
80     {
81       aScript << "\t" <<_NomBoundary << ".SetMeshFile('";
82       aScript << _MeshFile << "')\n";
83       aScript << "\t" <<_NomBoundary << ".SetMeshName('";
84       aScript << _MeshName << "')\n";
85       break;
86     }
87
88     case 1:
89     {
90       aScript << "\t" << _NomBoundary << ".SetCylinder(" ;
91       aScript << _Xcentre << ", " << _Ycentre << ", " << _Zcentre << ", " << _Xaxe << ", " << _Yaxe << ", " << _Zaxe << ", " << _rayon << ")\n";
92       break;
93     }
94
95     case 2:
96     {
97       aScript << "\t" << _NomBoundary << ".SetSphere(" ;
98       aScript << _Xcentre << ", " << _Ycentre << ", " << _Zcentre << ", " << _rayon << ")\n";
99       break;
100     }
101   }
102
103   return aScript.str();
104 }
105
106
107 //=============================================================================
108 void HOMARD_Boundary::SetBoundaryType( int BoundaryType )
109 {
110   MESSAGE("SetBoundaryType = "<<BoundaryType);
111   _BoundaryType = BoundaryType;
112 }
113
114 //=============================================================================
115 int HOMARD_Boundary::GetBoundaryType() const
116 {
117   return _BoundaryType;
118 }
119
120 //=============================================================================
121 void HOMARD_Boundary::SetMeshFile( const char* MeshFile )
122 {
123   _MeshFile = std::string( MeshFile );
124 }
125 //=============================================================================
126 std::string HOMARD_Boundary::GetMeshFile() const
127 {
128   return _MeshFile;
129 }
130 //=============================================================================
131 void HOMARD_Boundary::SetMeshName( const char* MeshName )
132 {
133   _MeshName = std::string( MeshName );
134 }
135 //=============================================================================
136 std::string HOMARD_Boundary::GetMeshName() const
137 {
138   return _MeshName;
139 }
140 //======================================================================
141 void HOMARD_Boundary::SetLimit( double X0, double X1, double X2 )
142 {
143   _Xincr = X0; _Yincr = X1; _Zincr = X2;
144 }
145 //=======================================================================================
146 void HOMARD_Boundary::SetCylinder( double X0, double X1, double X2,
147                                    double X3, double X4, double X5, double X6 )
148 {
149   _Xcentre = X0; _Ycentre = X1;
150   _Zcentre = X2; _Xaxe = X3;
151   _Yaxe = X4; _Zaxe = X5;
152   _rayon = X6;
153 }
154
155 //======================================================================
156 void HOMARD_Boundary::SetSphere( double X0, double X1, double X2, double X3 )
157 {
158   _Xcentre = X0; _Ycentre = X1; _Zcentre = X2;
159   _rayon = X3;
160 }
161
162 //=======================================================================================
163 std::vector<double> HOMARD_Boundary::GetLimit() const
164 {
165   std::vector<double> mesLimit;
166   mesLimit.push_back( _Xincr );
167   mesLimit.push_back( _Yincr );
168   mesLimit.push_back( _Zincr );
169   return mesLimit;
170 }
171
172 //=======================================================================================
173 std::vector<double> HOMARD_Boundary::GetCylinder() const
174 {
175   std::vector<double> mesCoor;
176   mesCoor.push_back( _Xcentre );
177   mesCoor.push_back( _Ycentre );
178   mesCoor.push_back( _Zcentre );
179   mesCoor.push_back( _Xaxe );
180   mesCoor.push_back( _Yaxe );
181   mesCoor.push_back( _Zaxe );
182   mesCoor.push_back( _rayon );
183   return mesCoor;
184 }
185
186 //=======================================================================================
187 std::vector<double> HOMARD_Boundary::GetSphere() const
188 {
189   std::vector<double> mesCoor;
190   mesCoor.push_back( _Xcentre );
191   mesCoor.push_back( _Ycentre );
192   mesCoor.push_back( _Zcentre );
193   mesCoor.push_back( _rayon );
194   return mesCoor;
195 }
196 //=============================================================================
197 /*!
198  */
199 //=============================================================================
200 void HOMARD_Boundary::SetCaseCreation( const char* NomCasCreation )
201 {
202   _NomCasCreation = std::string( NomCasCreation );
203 }
204
205 //=============================================================================
206 /*!
207 */
208 //=============================================================================
209 const std::list<std::string>& HOMARD_Boundary::GetGroups() const
210 {
211   return _ListGroupSelected;
212 }
213 //=============================================================================
214 void HOMARD_Boundary::SetGroups( const std::list<std::string>& ListGroup )
215 {
216   _ListGroupSelected.clear();
217   std::list<std::string>::const_iterator it = ListGroup.begin();
218   while(it != ListGroup.end())
219     _ListGroupSelected.push_back((*it++));
220 }
221 //=============================================================================
222 void HOMARD_Boundary::AddGroup( const char* Group)
223 {
224   _ListGroupSelected.push_back(Group);
225 }
226
227 //=============================================================================
228 /*!
229 */
230 //=============================================================================
231 std::string HOMARD_Boundary::GetCaseCreation() const
232 {
233   return _NomCasCreation;
234 }
235 //=============================================================================