Salome HOME
Merge from V6_main_20120808 08Aug12
[modules/homard.git] / src / HOMARD_I / HOMARD_Zone_i.cxx
1 // Copyright (C) 2011-2012  CEA/DEN, EDF R&D
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19
20 #include "HOMARD_Zone_i.hxx"
21 #include "HOMARD_Gen_i.hxx"
22 #include "HOMARD_Zone.hxx"
23 #include "HOMARD_DriverTools.hxx"
24
25 #include "utilities.h"
26
27 //=============================================================================
28 /*!
29  *  standard constructor
30  */
31 //=============================================================================
32 HOMARD_Zone_i::HOMARD_Zone_i()
33 {
34   MESSAGE( "Default constructor, not for use" );
35   ASSERT( 0 );
36 }
37
38 //=============================================================================
39 /*!
40  *  standard constructor
41  */
42 //=============================================================================
43 HOMARD_Zone_i::HOMARD_Zone_i( CORBA::ORB_ptr orb,
44                               HOMARD::HOMARD_Gen_var engine )
45 {
46   MESSAGE( "HOMARD_Zone_i" );
47   _gen_i = engine;
48   _orb = orb;
49   myHomardZone = new ::HOMARD_Zone();
50   ASSERT( myHomardZone );
51 }
52 //=============================================================================
53 /*!
54  *  standard destructor
55  */
56 //=============================================================================
57
58 HOMARD_Zone_i::~HOMARD_Zone_i()
59 {
60 }
61
62 //=============================================================================
63 /*!
64  */
65 //=============================================================================
66 void HOMARD_Zone_i::SetName( const char* NomZone )
67 {
68   ASSERT( myHomardZone );
69   myHomardZone->SetName( NomZone );
70 }
71
72 //=============================================================================
73 char* HOMARD_Zone_i::GetName()
74 {
75   ASSERT( myHomardZone );
76   return CORBA::string_dup( myHomardZone->GetName().c_str() );
77 }
78
79 //=============================================================================
80 char* HOMARD_Zone_i::GetDumpPython()
81 {
82   ASSERT( myHomardZone );
83   return CORBA::string_dup( myHomardZone->GetDumpPython().c_str() );
84 }
85
86
87 //=============================================================================
88 void HOMARD_Zone_i::SetZoneType( CORBA::Long ZoneType )
89 {
90   ASSERT( myHomardZone );
91   myHomardZone->SetZoneType( ZoneType );
92 }
93
94 //=============================================================================
95 CORBA::Long HOMARD_Zone_i::GetZoneType()
96 {
97   ASSERT( myHomardZone );
98   return  CORBA::Long( myHomardZone->GetZoneType() );
99 }
100
101 //=============================================================================
102 void HOMARD_Zone_i::SetBox( double X0, double X1, double X2, double X3, double X4, double X5 )
103 {
104   ASSERT( myHomardZone );
105   myHomardZone->SetBox( X0, X1, X2, X3, X4, X5 );
106 }
107
108 //=============================================================================
109 HOMARD::double_array* HOMARD_Zone_i::GetCoords()
110 {
111   ASSERT( myHomardZone );
112   HOMARD::double_array_var aResult = new HOMARD::double_array();
113   std::vector<double> mesCoor = myHomardZone->GetCoords();
114   aResult->length( mesCoor .size() );
115   std::vector<double>::const_iterator it;
116   int i = 0;
117   for ( it = mesCoor.begin(); it != mesCoor.end(); it++ )
118     aResult[i++] = (*it);
119   return aResult._retn();
120 }
121
122 //=============================================================================
123 void HOMARD_Zone_i::SetSphere( double Xcentre, double Ycentre, double Zcentre, double Rayon )
124 {
125   ASSERT( myHomardZone );
126   myHomardZone->SetSphere( Xcentre, Ycentre, Zcentre, Rayon );
127 }
128
129 //=============================================================================
130 void HOMARD_Zone_i::SetCylinder( double Xcentre, double Ycentre, double Zcentre,
131                                  double Xaxis, double Yaxis, double Zaxis,
132                                  double Rayon, double Haut )
133 {
134   ASSERT( myHomardZone );
135   myHomardZone->SetCylinder( Xcentre, Ycentre, Zcentre, Xaxis, Yaxis, Zaxis, Rayon, Haut );
136 }
137 //=============================================================================
138 void HOMARD_Zone_i::SetPipe( double Xcentre, double Ycentre, double Zcentre,
139                              double Xaxis, double Yaxis, double Zaxis,
140                              double Rayon, double Haut, double Rayonint )
141 {
142   ASSERT( myHomardZone );
143   myHomardZone->SetPipe( Xcentre, Ycentre, Zcentre, Xaxis, Yaxis, Zaxis, Rayon, Haut, Rayonint );
144 }
145
146 //=============================================================================
147 void HOMARD_Zone_i::SetLimit( double Xincr, double Yincr, double Zincr )
148 {
149   MESSAGE ("SetLimit, Xincr : " << Xincr << ", Yincr : " << Yincr << ", Zincr : " << Zincr) ;
150   ASSERT( myHomardZone );
151   myHomardZone->SetLimit( Xincr, Yincr, Zincr );
152 }
153
154 //=============================================================================
155 HOMARD::double_array* HOMARD_Zone_i::GetLimit()
156 {
157   ASSERT( myHomardZone );
158   HOMARD::double_array_var aResult = new HOMARD::double_array();
159   std::vector<double> mesCoor = myHomardZone->GetLimit();
160   aResult->length( mesCoor .size() );
161   std::vector<double>::const_iterator it;
162   int i = 0;
163   for ( it = mesCoor.begin(); it != mesCoor.end(); it++ )
164     aResult[i++] = (*it);
165   return aResult._retn();
166 }
167
168 //=============================================================================
169 void HOMARD_Zone_i::AddHypo( const char* NomHypo )
170 {
171   MESSAGE ( " AddHypo, NomHypo= " << NomHypo);
172   ASSERT( myHomardZone );
173   myHomardZone->AddHypo( NomHypo );
174   MESSAGE ( " FIn de AddHypo");
175 }
176
177 //=============================================================================
178 void HOMARD_Zone_i::SupprHypo( const char* NomHypo )
179 {
180   ASSERT( myHomardZone );
181   myHomardZone->SupprHypo( NomHypo );
182 }
183 //=============================================================================
184 HOMARD::listeHypo* HOMARD_Zone_i::GetHypo()
185 {
186   ASSERT( myHomardZone );
187   const std::list<std::string>& maListe = myHomardZone->GetHypo();
188   HOMARD::listeHypo_var aResult = new HOMARD::listeHypo;
189   aResult->length( maListe.size() );
190   std:: list<std::string>::const_iterator it;
191   int i = 0;
192   for ( it = maListe.begin(); it != maListe.end(); it++ )
193     aResult[i++] = CORBA::string_dup( (*it).c_str() );
194   return aResult._retn();
195 }
196
197 //=============================================================================
198 std::string HOMARD_Zone_i::Dump() const
199 {
200   return HOMARD::Dump( *myHomardZone );
201 }
202
203 //=============================================================================
204 bool HOMARD_Zone_i::Restore( const std::string& stream )
205 {
206   return HOMARD::Restore( *myHomardZone, stream );
207 }