Salome HOME
Merge from V6_main (04/10/2012)
[plugins/hexoticplugin.git] / src / HexoticPlugin / HexoticPlugin_Hypothesis_i.cxx
1 // Copyright (C) 2007-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 // ---
21 // File   : HexoticPlugin_Hypothesis_i.cxx
22 // Author : Lioka RAZAFINDRAZAKA (CEA)
23 // ---
24 //
25 #include "HexoticPlugin_Hypothesis_i.hxx"
26 #include "SMESH_Mesh_i.hxx"
27 #include "SMESH_Gen.hxx"
28 #include "SMESH_PythonDump.hxx"
29
30 #include "Utils_CorbaException.hxx"
31 #include "utilities.h"
32
33 //=============================================================================
34 /*!
35  *  HexoticPlugin_Hypothesis_i::HexoticPlugin_Hypothesis_i
36  *
37  *  Constructor
38  */
39 //=============================================================================
40 HexoticPlugin_Hypothesis_i::
41 HexoticPlugin_Hypothesis_i (PortableServer::POA_ptr thePOA,
42                            int                     theStudyId,
43                            ::SMESH_Gen*            theGenImpl)
44   : SALOME::GenericObj_i( thePOA ), 
45     SMESH_Hypothesis_i( thePOA )
46 {
47   MESSAGE( "HexoticPlugin_Hypothesis_i::HexoticPlugin_Hypothesis_i" );
48   myBaseImpl = new ::HexoticPlugin_Hypothesis (theGenImpl->GetANewId(),
49                                               theStudyId,
50                                               theGenImpl);
51 }
52
53 //=============================================================================
54 /*!
55  *  HexoticPlugin_Hypothesis_i::~HexoticPlugin_Hypothesis_i
56  *
57  *  Destructor
58  */
59 //=============================================================================
60 HexoticPlugin_Hypothesis_i::~HexoticPlugin_Hypothesis_i()
61 {
62   MESSAGE( "HexoticPlugin_Hypothesis_i::~HexoticPlugin_Hypothesis_i" );
63 }
64
65 //=============================================================================
66 /*!
67  *  HexoticPlugin_Hypothesis_i::SetHexesMinLevel
68  *  HexoticPlugin_Hypothesis_i::SetHexesMaxLevel
69  *  HexoticPlugin_Hypothesis_i::SetMinSize
70  *  HexoticPlugin_Hypothesis_i::SetMaxSize
71  *  HexoticPlugin_Hypothesis_i::SetHexoticIgnoreRidges
72  *  HexoticPlugin_Hypothesis_i::SetHexoticInvalidElements
73  *  HexoticPlugin_Hypothesis_i::SetHexoticSharpAngleThreshold
74  *  HexoticPlugin_Hypothesis_i::SetHexoticNbProc 
75  *  HexoticPlugin_Hypothesis_i::SetHexoticWorkingDirectory 
76  *  HexoticPlugin_Hypothesis_i::SetHexoticSdMode
77  *  HexoticPlugin_Hypothesis_i::SetVerbosity
78  */
79 //=============================================================================
80
81 void HexoticPlugin_Hypothesis_i::SetHexesMinLevel (CORBA::Long theValue)
82 {
83   // MESSAGE("HexoticPlugin_Hypothesis_i::SetHexesMinLevel");
84   ASSERT(myBaseImpl);
85   CORBA::Long oldValue = GetHexesMinLevel();
86   this->GetImpl()->SetHexesMinLevel(theValue);
87   if (theValue != oldValue)
88     SMESH::TPythonDump() << _this() << ".SetHexesMinLevel( " << theValue << " )";
89 }
90
91 void HexoticPlugin_Hypothesis_i::SetHexesMaxLevel (CORBA::Long theValue)
92 {
93   // MESSAGE("HexoticPlugin_Hypothesis_i::SetHexesMaxLevel");
94   ASSERT(myBaseImpl);
95   CORBA::Long oldValue = GetHexesMaxLevel();
96   this->GetImpl()->SetHexesMaxLevel(theValue);
97   if (theValue != oldValue)
98     SMESH::TPythonDump() << _this() << ".SetHexesMaxLevel( " << theValue << " )";
99 }
100
101 void HexoticPlugin_Hypothesis_i::SetMinSize (CORBA::Double theValue)
102 {
103   // MESSAGE("HexoticPlugin_Hypothesis_i::SetHexesMaxLevel");
104   ASSERT(myBaseImpl);
105   CORBA::Double oldValue = GetMinSize();
106   this->GetImpl()->SetMinSize(theValue);
107   if (theValue != oldValue)
108     SMESH::TPythonDump() << _this() << ".SetMinSize( " << theValue << " )";
109 }
110
111 void HexoticPlugin_Hypothesis_i::SetMaxSize (CORBA::Double theValue)
112 {
113   // MESSAGE("HexoticPlugin_Hypothesis_i::SetHexesMaxLevel");
114   ASSERT(myBaseImpl);
115   CORBA::Double oldValue = GetMaxSize();
116   this->GetImpl()->SetMaxSize(theValue);
117   if (theValue != oldValue)
118     SMESH::TPythonDump() << _this() << ".SetMaxSize( " << theValue << " )";
119 }
120
121 void HexoticPlugin_Hypothesis_i::SetHexoticIgnoreRidges (CORBA::Boolean theValue)
122 {
123   // MESSAGE("HexoticPlugin_Hypothesis_i::SetHexoticIgnoreRidges");
124   ASSERT(myBaseImpl);
125   CORBA::Boolean oldValue = GetHexoticIgnoreRidges();
126   this->GetImpl()->SetHexoticIgnoreRidges(theValue);
127   if (theValue != oldValue)
128     SMESH::TPythonDump() << _this() << ".SetHexoticIgnoreRidges( " << theValue << " )";
129 }
130
131 void HexoticPlugin_Hypothesis_i::SetHexoticInvalidElements (CORBA::Boolean theValue)
132 {
133   // MESSAGE("HexoticPlugin_Hypothesis_i::SetHexoticInvalidElements");
134   ASSERT(myBaseImpl);
135   CORBA::Boolean oldValue = GetHexoticInvalidElements();
136   this->GetImpl()->SetHexoticInvalidElements(theValue);
137   if (theValue != oldValue)
138     SMESH::TPythonDump() << _this() << ".SetHexoticInvalidElements( " << theValue << " )";
139 }
140
141 void HexoticPlugin_Hypothesis_i::SetHexoticSharpAngleThreshold (CORBA::Double theValue)
142 {
143   // MESSAGE("HexoticPlugin_Hypothesis_i::SetHexoticSharpAngleThreshold");
144   ASSERT(myBaseImpl);
145   CORBA::Double oldValue = GetHexoticSharpAngleThreshold();
146   this->GetImpl()->SetHexoticSharpAngleThreshold(theValue);
147   if (theValue != oldValue)
148     SMESH::TPythonDump() << _this() << ".SetHexoticSharpAngleThreshold( " << theValue << " )";
149 }
150
151 void HexoticPlugin_Hypothesis_i::SetHexoticNbProc (CORBA::Long theValue)
152 {
153   // MESSAGE("HexoticPlugin_Hypothesis_i::SetHexoticNbProc");
154   ASSERT(myBaseImpl);
155   CORBA::Long oldValue = GetHexoticNbProc();
156   this->GetImpl()->SetHexoticNbProc(theValue);
157   if (theValue != oldValue)
158     SMESH::TPythonDump() << _this() << ".SetHexoticNbProc( " << theValue << " )";
159 }
160
161 void HexoticPlugin_Hypothesis_i::SetHexoticWorkingDirectory(const char* path) throw ( SALOME::SALOME_Exception )
162 {
163   if (!path )
164     THROW_SALOME_CORBA_EXCEPTION( "Null working directory",SALOME::BAD_PARAM );
165
166   ASSERT(myBaseImpl);
167   string file(path);
168   string oldValue(GetHexoticWorkingDirectory());
169   bool doDump = false;
170   if (oldValue != file)
171     doDump = true;
172
173   const char lastChar = *file.rbegin();
174 #ifdef WIN32
175   if ( lastChar != '\\' ) file += '\\';
176 #else
177   if ( lastChar != '/' ) file += '/';
178 #endif
179   file += "Hexotic_In.mesh";
180   SMESH_Mesh_i::PrepareForWriting (file.c_str());
181
182   this->GetImpl()->SetHexoticWorkingDirectory(path);
183   if (doDump)
184     SMESH::TPythonDump() << _this() << ".SetHexoticWorkingDirectory( '" << path << "' )";
185 }
186
187 void HexoticPlugin_Hypothesis_i::SetHexoticSdMode (CORBA::Long theValue)
188 {
189   // MESSAGE("HexoticPlugin_Hypothesis_i::SetHexoticSdMode");
190   ASSERT(myBaseImpl);
191   CORBA::Long oldValue = GetHexoticSdMode();
192   this->GetImpl()->SetHexoticSdMode(theValue);
193   if (theValue != oldValue)
194     SMESH::TPythonDump() << _this() << ".SetHexoticSdMode( " << theValue << " )";
195 }
196
197 void HexoticPlugin_Hypothesis_i::SetHexoticVerbosity (CORBA::Long theValue)
198 {
199   // MESSAGE("HexoticPlugin_Hypothesis_i::SetVerbosity");
200   ASSERT(myBaseImpl);
201   CORBA::Long oldValue = GetHexoticVerbosity();
202   this->GetImpl()->SetHexoticVerbosity(theValue);
203   if (theValue != oldValue)
204     SMESH::TPythonDump() << _this() << ".SetHexoticVerbosity( " << theValue << " )";
205 }
206
207 //=============================================================================
208 /*!
209  *  HexoticPlugin_Hypothesis_i::GetHexesMinLevel
210  *  HexoticPlugin_Hypothesis_i::GetHexesMaxLevel
211  *  HexoticPlugin_Hypothesis_i::GetMinSize
212  *  HexoticPlugin_Hypothesis_i::GetMaxSize
213  *  HexoticPlugin_Hypothesis_i::GetHexoticIgnoreRidges
214  *  HexoticPlugin_Hypothesis_i::GetHexoticInvalidElements
215  *  HexoticPlugin_Hypothesis_i::GetHexoticSharpAngleThreshold 
216  *  HexoticPlugin_Hypothesis_i::GetHexoticNbProc 
217  *  HexoticPlugin_Hypothesis_i::GetHexoticWorkingDirectory 
218  *  HexoticPlugin_Hypothesis_i::GetHexoticSdMode
219  *  HexoticPlugin_Hypothesis_i::GetVerbosity
220  */
221 //=============================================================================
222
223 CORBA::Long HexoticPlugin_Hypothesis_i::GetHexesMinLevel()
224 {
225   // MESSAGE("HexoticPlugin_Hypothesis_i::GetHexesMinLevel");
226   ASSERT(myBaseImpl);
227   return this->GetImpl()->GetHexesMinLevel();
228 }
229
230 CORBA::Long HexoticPlugin_Hypothesis_i::GetHexesMaxLevel()
231 {
232   // MESSAGE("HexoticPlugin_Hypothesis_i::GetHexesMaxLevel");
233   ASSERT(myBaseImpl);
234   return this->GetImpl()->GetHexesMaxLevel();
235 }
236
237 CORBA::Double HexoticPlugin_Hypothesis_i::GetMinSize()
238 {
239   // MESSAGE("HexoticPlugin_Hypothesis_i::GetMinSize");
240   ASSERT(myBaseImpl);
241   return this->GetImpl()->GetMinSize();
242 }
243
244 CORBA::Double HexoticPlugin_Hypothesis_i::GetMaxSize()
245 {
246   // MESSAGE("HexoticPlugin_Hypothesis_i::GetMaxSize");
247   ASSERT(myBaseImpl);
248   return this->GetImpl()->GetMaxSize();
249 }
250
251 CORBA::Boolean HexoticPlugin_Hypothesis_i::GetHexoticIgnoreRidges()
252 {
253   // MESSAGE("HexoticPlugin_Hypothesis_i::GetHexoticIgnoreRidges");
254   ASSERT(myBaseImpl);
255   return this->GetImpl()->GetHexoticIgnoreRidges();
256 }
257
258 CORBA::Boolean HexoticPlugin_Hypothesis_i::GetHexoticInvalidElements()
259 {
260   // MESSAGE("HexoticPlugin_Hypothesis_i::GetHexoticInvalidElements");
261   ASSERT(myBaseImpl);
262   return this->GetImpl()->GetHexoticInvalidElements();
263 }
264
265 CORBA::Double HexoticPlugin_Hypothesis_i::GetHexoticSharpAngleThreshold()
266 {
267   // MESSAGE("HexoticPlugin_Hypothesis_i::GetHexoticSharpAngleThreshold");
268   ASSERT(myBaseImpl);
269   return this->GetImpl()->GetHexoticSharpAngleThreshold();
270 }
271
272 CORBA::Long HexoticPlugin_Hypothesis_i::GetHexoticNbProc()
273 {
274   // MESSAGE("HexoticPlugin_Hypothesis_i::GetHexoticNbProc");
275   ASSERT(myBaseImpl);
276   return this->GetImpl()->GetHexoticNbProc();
277 }
278
279 char* HexoticPlugin_Hypothesis_i::GetHexoticWorkingDirectory()
280 {
281   ASSERT(myBaseImpl);
282   return CORBA::string_dup( this->GetImpl()->GetHexoticWorkingDirectory().c_str() );
283 }
284
285 CORBA::Long HexoticPlugin_Hypothesis_i::GetHexoticSdMode ()
286 {
287   // MESSAGE("HexoticPlugin_Hypothesis_i::GetHexoticSdMode");
288   ASSERT(myBaseImpl);
289   return this->GetImpl()->GetHexoticSdMode();
290 }
291
292 CORBA::Long HexoticPlugin_Hypothesis_i::GetHexoticVerbosity()
293 {
294   // MESSAGE("HexoticPlugin_Hypothesis_i::GetVerbosity");
295   ASSERT(myBaseImpl);
296   return this->GetImpl()->GetHexoticVerbosity();
297 }
298
299 //=============================================================================
300 /*!
301  *  HexoticPlugin_Hypothesis_i::GetImpl
302  *
303  *  Get implementation
304  */
305 //=============================================================================
306 ::HexoticPlugin_Hypothesis* HexoticPlugin_Hypothesis_i::GetImpl()
307 {
308   // MESSAGE("HexoticPlugin_Hypothesis_i::GetImpl");
309   return (::HexoticPlugin_Hypothesis*)myBaseImpl;
310 }
311
312 //================================================================================
313 /*!
314  * \brief Verify whether hypothesis supports given entity type 
315   * \param type - dimension (see SMESH::Dimension enumeration)
316   * \retval CORBA::Boolean - TRUE if dimension is supported, FALSE otherwise
317  * 
318  * Verify whether hypothesis supports given entity type (see SMESH::Dimension enumeration)
319  */
320 //================================================================================  
321 CORBA::Boolean HexoticPlugin_Hypothesis_i::IsDimSupported( SMESH::Dimension type )
322 {
323   return type == SMESH::DIM_3D;
324 }