Salome HOME
6414f6bc7c50cb3c2faa890f16c3a78fb926de03
[modules/homard.git] / src / HOMARD / HOMARD_Boundary.cxx
1 //  HOMARD HOMARD : implementaion of HOMARD idl descriptions
2 //
3 // Copyright (C) 2011-2012  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 //
68   switch (_BoundaryType)
69   {
70     case 0:
71     {
72       aScript << "discrete boundary " << _NomBoundary << "\n";
73       aScript << "\t" << _NomBoundary << " = homard.CreateBoundaryDi(\"" << _NomBoundary << "\", ";
74       aScript << "\"" << _MeshName << "\", ";
75       aScript << "\"" << _MeshFile << "\")\n";
76       break ;
77     }
78     case 1:
79     {
80       aScript << "cylinder " << _NomBoundary << "\n";
81       aScript << "\t" << _NomBoundary << " = homard.CreateBoundaryCylinder(\"" << _NomBoundary << "\", ";
82       aScript << _Xcentre << ", " << _Ycentre << ", " << _Zcentre << ", " << _Xaxe << ", " << _Yaxe << ", " << _Zaxe << ", " << _rayon << ")\n";
83       break ;
84     }
85     case 2:
86     {
87       aScript << "sphere" << _NomBoundary << "\n";
88       aScript << "\t" << _NomBoundary << " = homard.CreateBoundarySphere(\"" << _NomBoundary << "\", ";
89       aScript << _Xcentre << ", " << _Ycentre << ", " << _Zcentre << ", " << _rayon << ")\n";
90       break ;
91     }
92   }
93
94   return aScript.str();
95 }
96
97
98 //=============================================================================
99 void HOMARD_Boundary::SetBoundaryType( int BoundaryType )
100 {
101   MESSAGE("SetBoundaryType = "<<BoundaryType);
102   _BoundaryType = BoundaryType;
103 }
104
105 //=============================================================================
106 int HOMARD_Boundary::GetBoundaryType() const
107 {
108   return _BoundaryType;
109 }
110
111 //=============================================================================
112 void HOMARD_Boundary::SetMeshFile( const char* MeshFile )
113 {
114   _MeshFile = std::string( MeshFile );
115 }
116 //=============================================================================
117 std::string HOMARD_Boundary::GetMeshFile() const
118 {
119   return _MeshFile;
120 }
121 //=============================================================================
122 void HOMARD_Boundary::SetMeshName( const char* MeshName )
123 {
124   _MeshName = std::string( MeshName );
125 }
126 //=============================================================================
127 std::string HOMARD_Boundary::GetMeshName() const
128 {
129   return _MeshName;
130 }
131 //======================================================================
132 void HOMARD_Boundary::SetLimit( double X0, double X1, double X2 )
133 {
134   _Xincr = X0; _Yincr = X1; _Zincr = X2;
135 }
136 //=======================================================================================
137 void HOMARD_Boundary::SetCylinder( double X0, double X1, double X2,
138                                    double X3, double X4, double X5, double X6 )
139 {
140   _Xcentre = X0; _Ycentre = X1;
141   _Zcentre = X2; _Xaxe = X3;
142   _Yaxe = X4; _Zaxe = X5;
143   _rayon = X6;
144 }
145
146 //======================================================================
147 void HOMARD_Boundary::SetSphere( double X0, double X1, double X2, double X3 )
148 {
149   _Xcentre = X0; _Ycentre = X1; _Zcentre = X2;
150   _rayon = X3;
151 }
152
153 //=======================================================================================
154 std::vector<double> HOMARD_Boundary::GetLimit() const
155 {
156   std::vector<double> mesLimit;
157   mesLimit.push_back( _Xincr );
158   mesLimit.push_back( _Yincr );
159   mesLimit.push_back( _Zincr );
160   return mesLimit;
161 }
162
163 //=======================================================================================
164 std::vector<double> HOMARD_Boundary::GetCoords() const
165 {
166   std::vector<double> mesCoor;
167 //
168   switch (_BoundaryType)
169   {
170 //  Cylindre
171     case 1:
172     {
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       break ;
181     }
182 //  Sphere
183     case 2:
184     {
185       mesCoor.push_back( _Xcentre );
186       mesCoor.push_back( _Ycentre );
187       mesCoor.push_back( _Zcentre );
188       mesCoor.push_back( _rayon );
189       break ;
190     }
191     ASSERT ( _BoundaryType == -1 ) ;
192   }
193   return mesCoor;
194 }
195 //=============================================================================
196 /*!
197  */
198 //=============================================================================
199 void HOMARD_Boundary::SetCaseCreation( const char* NomCasCreation )
200 {
201   _NomCasCreation = std::string( NomCasCreation );
202 }
203
204 //=============================================================================
205 /*!
206 */
207 //=============================================================================
208 const std::list<std::string>& HOMARD_Boundary::GetGroups() const
209 {
210   return _ListGroupSelected;
211 }
212 //=============================================================================
213 void HOMARD_Boundary::SetGroups( const std::list<std::string>& ListGroup )
214 {
215   _ListGroupSelected.clear();
216   std::list<std::string>::const_iterator it = ListGroup.begin();
217   while(it != ListGroup.end())
218     _ListGroupSelected.push_back((*it++));
219 }
220 //=============================================================================
221 void HOMARD_Boundary::AddGroup( const char* Group)
222 {
223   _ListGroupSelected.push_back(Group);
224 }
225
226 //=============================================================================
227 /*!
228 */
229 //=============================================================================
230 std::string HOMARD_Boundary::GetCaseCreation() const
231 {
232   return _NomCasCreation;
233 }
234 //=============================================================================