Salome HOME
Nouvelles icones
[modules/homard.git] / src / HOMARD_I / HOMARD_Zone_i.cxx
1 // Copyright (C) 2011-2013  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 // Remarques :
20 // L'ordre de description des fonctions est le meme dans tous les fichiers
21 // HOMARD_aaaa.idl, HOMARD_aaaa.hxx, HOMARD_aaaa.cxx, HOMARD_aaaa_i.hxx, HOMARD_aaaa_i.cxx :
22 // 1. Les generalites : Name, Delete, DumpPython, Dump, Restore
23 // 2. Les caracteristiques
24 // 3. Le lien avec les autres structures
25 //
26 // Quand les 2 fonctions Setxxx et Getxxx sont presentes, Setxxx est decrit en premier
27 //
28
29 #include "HOMARD_Zone_i.hxx"
30 #include "HOMARD_Gen_i.hxx"
31 #include "HOMARD_Zone.hxx"
32 #include "HOMARD_DriverTools.hxx"
33
34 #include "utilities.h"
35
36 //=============================================================================
37 /*!
38  *  standard constructor
39  */
40 //=============================================================================
41 HOMARD_Zone_i::HOMARD_Zone_i()
42 {
43   MESSAGE( "Default constructor, not for use" );
44   ASSERT( 0 );
45 }
46
47 //=============================================================================
48 /*!
49  *  standard constructor
50  */
51 //=============================================================================
52 HOMARD_Zone_i::HOMARD_Zone_i( CORBA::ORB_ptr orb,
53                               HOMARD::HOMARD_Gen_var engine )
54 {
55   MESSAGE( "HOMARD_Zone_i" );
56   _gen_i = engine;
57   _orb = orb;
58   myHomardZone = new ::HOMARD_Zone();
59   ASSERT( myHomardZone );
60 }
61 //=============================================================================
62 /*!
63  *  standard destructor
64  */
65 //=============================================================================
66
67 HOMARD_Zone_i::~HOMARD_Zone_i()
68 {
69 }
70 //=============================================================================
71 //=============================================================================
72 // Generalites
73 //=============================================================================
74 //=============================================================================
75 void HOMARD_Zone_i::SetName( const char* Name )
76 {
77   ASSERT( myHomardZone );
78   myHomardZone->SetName( Name );
79 }
80 //=============================================================================
81 char* HOMARD_Zone_i::GetName()
82 {
83   ASSERT( myHomardZone );
84   return CORBA::string_dup( myHomardZone->GetName().c_str() );
85 }
86 //=============================================================================
87 CORBA::Long HOMARD_Zone_i::Delete()
88 {
89   ASSERT( myHomardZone );
90   char* ZoneName = GetName() ;
91   MESSAGE ( "Delete : destruction de la zone " << ZoneName );
92   return _gen_i->DeleteZone(ZoneName) ;
93 }
94 //=============================================================================
95 char* HOMARD_Zone_i::GetDumpPython()
96 {
97   ASSERT( myHomardZone );
98   return CORBA::string_dup( myHomardZone->GetDumpPython().c_str() );
99 }
100 //=============================================================================
101 std::string HOMARD_Zone_i::Dump() const
102 {
103   return HOMARD::Dump( *myHomardZone );
104 }
105 //=============================================================================
106 bool HOMARD_Zone_i::Restore( const std::string& stream )
107 {
108   return HOMARD::Restore( *myHomardZone, stream );
109 }
110 //=============================================================================
111 //=============================================================================
112 // Caracteristiques
113 //=============================================================================
114 //=============================================================================
115 void HOMARD_Zone_i::SetType( CORBA::Long Type )
116 {
117   ASSERT( myHomardZone );
118   myHomardZone->SetType( Type );
119 }
120 //=============================================================================
121 CORBA::Long HOMARD_Zone_i::GetType()
122 {
123   ASSERT( myHomardZone );
124   return  CORBA::Long( myHomardZone->GetType() );
125 }
126 //=============================================================================
127 void HOMARD_Zone_i::SetBox( double X0, double X1, double X2, double X3, double X4, double X5 )
128 {
129   ASSERT( myHomardZone );
130   myHomardZone->SetBox( X0, X1, X2, X3, X4, X5 );
131 }
132 //=============================================================================
133 void HOMARD_Zone_i::SetCylinder( double Xcentre, double Ycentre, double Zcentre,
134                                  double Xaxis, double Yaxis, double Zaxis,
135                                  double Rayon, double Haut )
136 {
137   ASSERT( myHomardZone );
138   myHomardZone->SetCylinder( Xcentre, Ycentre, Zcentre, Xaxis, Yaxis, Zaxis, Rayon, Haut );
139 }
140 //=============================================================================
141 void HOMARD_Zone_i::SetPipe( double Xcentre, double Ycentre, double Zcentre,
142                              double Xaxis, double Yaxis, double Zaxis,
143                              double Rayon, double Haut, double Rayonint )
144 {
145   ASSERT( myHomardZone );
146   myHomardZone->SetPipe( Xcentre, Ycentre, Zcentre, Xaxis, Yaxis, Zaxis, Rayon, Haut, Rayonint );
147 }
148 //=============================================================================
149 void HOMARD_Zone_i::SetSphere( double Xcentre, double Ycentre, double Zcentre, double Rayon )
150 {
151   ASSERT( myHomardZone );
152   myHomardZone->SetSphere( Xcentre, Ycentre, Zcentre, Rayon );
153 }
154 //=============================================================================
155 HOMARD::double_array* HOMARD_Zone_i::GetCoords()
156 {
157   ASSERT( myHomardZone );
158   HOMARD::double_array_var aResult = new HOMARD::double_array();
159   std::vector<double> mesCoor = myHomardZone->GetCoords();
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 void HOMARD_Zone_i::SetLimit( double Xincr, double Yincr, double Zincr )
169 {
170   MESSAGE ("SetLimit, Xincr : " << Xincr << ", Yincr : " << Yincr << ", Zincr : " << Zincr) ;
171   ASSERT( myHomardZone );
172   myHomardZone->SetLimit( Xincr, Yincr, Zincr );
173 }
174 //=============================================================================
175 HOMARD::double_array* HOMARD_Zone_i::GetLimit()
176 {
177   ASSERT( myHomardZone );
178   HOMARD::double_array_var aResult = new HOMARD::double_array();
179   std::vector<double> mesCoor = myHomardZone->GetLimit();
180   aResult->length( mesCoor .size() );
181   std::vector<double>::const_iterator it;
182   int i = 0;
183   for ( it = mesCoor.begin(); it != mesCoor.end(); it++ )
184     aResult[i++] = (*it);
185   return aResult._retn();
186 }
187 //=============================================================================
188 //=============================================================================
189 // Liens avec les autres structures
190 //=============================================================================
191 //=============================================================================
192 void HOMARD_Zone_i::AddHypo( const char* NomHypo )
193 {
194   MESSAGE ( " AddHypo, NomHypo= " << NomHypo);
195   ASSERT( myHomardZone );
196   myHomardZone->AddHypo( NomHypo );
197 }
198 //=============================================================================
199 HOMARD::listeHypo* HOMARD_Zone_i::GetHypo()
200 {
201   ASSERT( myHomardZone );
202   const std::list<std::string>& maListe = myHomardZone->GetHypo();
203   HOMARD::listeHypo_var aResult = new HOMARD::listeHypo;
204   aResult->length( maListe.size() );
205   std:: list<std::string>::const_iterator it;
206   int i = 0;
207   for ( it = maListe.begin(); it != maListe.end(); it++ )
208     aResult[i++] = CORBA::string_dup( (*it).c_str() );
209   return aResult._retn();
210 }
211 //=============================================================================
212 void HOMARD_Zone_i::SupprHypo( const char* NomHypo )
213 {
214   ASSERT( myHomardZone );
215   myHomardZone->SupprHypo( NomHypo );
216 }
217