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