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