1 // Copyright (C) 2004-2010 CEA/DEN, EDF R&D
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.
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.
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
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 // File : GHS3DPlugin_Hypothesis_i.cxx
21 // Created : Wed Apr 2 13:53:01 2008
22 // Author : Edward AGAPOV (eap)
24 #include "GHS3DPlugin_Hypothesis_i.hxx"
26 #include <SMESH_Gen.hxx>
27 #include <SMESH_PythonDump.hxx>
29 #include <Utils_CorbaException.hxx>
30 #include <utilities.h>
31 #include <SMESH_Mesh_i.hxx>
33 //=======================================================================
34 //function : GHS3DPlugin_Hypothesis_i
35 //=======================================================================
37 GHS3DPlugin_Hypothesis_i::GHS3DPlugin_Hypothesis_i (PortableServer::POA_ptr thePOA,
39 ::SMESH_Gen* theGenImpl)
40 : SALOME::GenericObj_i( thePOA ),
41 SMESH_Hypothesis_i( thePOA )
43 MESSAGE( "GHS3DPlugin_Hypothesis_i::GHS3DPlugin_Hypothesis_i" );
44 myBaseImpl = new ::GHS3DPlugin_Hypothesis (theGenImpl->GetANewId(),
49 //=======================================================================
50 //function : ~GHS3DPlugin_Hypothesis_i
51 //=======================================================================
53 GHS3DPlugin_Hypothesis_i::~GHS3DPlugin_Hypothesis_i()
55 MESSAGE( "GHS3DPlugin_Hypothesis_i::~GHS3DPlugin_Hypothesis_i" );
58 //=======================================================================
59 //function : SetToMeshHoles
60 //=======================================================================
62 void GHS3DPlugin_Hypothesis_i::SetToMeshHoles(CORBA::Boolean toMesh)
65 this->GetImpl()->SetToMeshHoles(toMesh);
66 SMESH::TPythonDump() << _this() << ".SetToMeshHoles( " << toMesh << " )";
69 //=======================================================================
70 //function : GetToMeshHoles
71 //=======================================================================
73 CORBA::Boolean GHS3DPlugin_Hypothesis_i::GetToMeshHoles()
76 return this->GetImpl()->GetToMeshHoles();
79 //=======================================================================
80 //function : SetMaximumMemory
81 //=======================================================================
83 void GHS3DPlugin_Hypothesis_i::SetMaximumMemory(CORBA::Short MB)
84 throw ( SALOME::SALOME_Exception )
87 THROW_SALOME_CORBA_EXCEPTION( "Invalid memory size",SALOME::BAD_PARAM );
89 this->GetImpl()->SetMaximumMemory(MB);
90 SMESH::TPythonDump() << _this() << ".SetMaximumMemory( " << MB << " )";
93 //=======================================================================
94 //function : GetMaximumMemory
95 //=======================================================================
97 CORBA::Short GHS3DPlugin_Hypothesis_i::GetMaximumMemory()
100 return this->GetImpl()->GetMaximumMemory();
103 //=======================================================================
104 //function : SetInitialMemory
105 //=======================================================================
107 void GHS3DPlugin_Hypothesis_i::SetInitialMemory(CORBA::Short MB)
108 throw ( SALOME::SALOME_Exception )
111 THROW_SALOME_CORBA_EXCEPTION( "Invalid memory size",SALOME::BAD_PARAM );
113 this->GetImpl()->SetInitialMemory(MB);
114 SMESH::TPythonDump() << _this() << ".SetInitialMemory( " << MB << " )";
117 //=======================================================================
118 //function : GetInitialMemory
119 //=======================================================================
121 CORBA::Short GHS3DPlugin_Hypothesis_i::GetInitialMemory()
124 return this->GetImpl()->GetInitialMemory();
127 //=======================================================================
128 //function : SetOptimizationLevel
129 //=======================================================================
131 void GHS3DPlugin_Hypothesis_i::SetOptimizationLevel(CORBA::Short level)
132 throw ( SALOME::SALOME_Exception )
134 ::GHS3DPlugin_Hypothesis::OptimizationLevel l =
135 (::GHS3DPlugin_Hypothesis::OptimizationLevel) level;
136 if ( l < ::GHS3DPlugin_Hypothesis::None ||
137 l > ::GHS3DPlugin_Hypothesis::Strong )
138 THROW_SALOME_CORBA_EXCEPTION( "Invalid optimization level",SALOME::BAD_PARAM );
141 this->GetImpl()->SetOptimizationLevel(l);
142 SMESH::TPythonDump() << _this() << ".SetOptimizationLevel( " << level << " )";
145 //=======================================================================
146 //function : GetOptimizationLevel
147 //=======================================================================
149 CORBA::Short GHS3DPlugin_Hypothesis_i::GetOptimizationLevel()
152 return this->GetImpl()->GetOptimizationLevel();
155 //=======================================================================
156 //function : SetWorkingDirectory
157 //=======================================================================
159 void GHS3DPlugin_Hypothesis_i::SetWorkingDirectory(const char* path) throw ( SALOME::SALOME_Exception )
162 THROW_SALOME_CORBA_EXCEPTION( "Null working directory",SALOME::BAD_PARAM );
165 const char lastChar = *file.rbegin();
167 if ( lastChar != '\\' ) file += '\\';
169 if ( lastChar != '/' ) file += '/';
172 SMESH_Mesh_i::PrepareForWriting (file.c_str());
175 this->GetImpl()->SetWorkingDirectory(path);
176 SMESH::TPythonDump() << _this() << ".SetWorkingDirectory( '" << path << "' )";
179 //=======================================================================
180 //function : GetWorkingDirectory
181 //=======================================================================
183 char* GHS3DPlugin_Hypothesis_i::GetWorkingDirectory()
186 return CORBA::string_dup( this->GetImpl()->GetWorkingDirectory().c_str() );
189 //=======================================================================
190 //function : SetKeepFiles
191 //=======================================================================
193 void GHS3DPlugin_Hypothesis_i::SetKeepFiles(CORBA::Boolean toKeep)
196 this->GetImpl()->SetKeepFiles(toKeep);
197 SMESH::TPythonDump() << _this() << ".SetKeepFiles( " << toKeep << " )";
200 //=======================================================================
201 //function : GetKeepFiles
202 //=======================================================================
204 CORBA::Boolean GHS3DPlugin_Hypothesis_i::GetKeepFiles()
207 return this->GetImpl()->GetKeepFiles();
210 //=======================================================================
211 //function : SetVerboseLevel
212 //=======================================================================
214 void GHS3DPlugin_Hypothesis_i::SetVerboseLevel(CORBA::Short level)
215 throw ( SALOME::SALOME_Exception )
217 if (level < 0 || level > 10 )
218 THROW_SALOME_CORBA_EXCEPTION( "Invalid verbose level, valid range is [0-10]",
221 this->GetImpl()->SetVerboseLevel(level);
222 SMESH::TPythonDump() << _this() << ".SetVerboseLevel( " << level << " )";
225 //=======================================================================
226 //function : GetVerboseLevel
227 //=======================================================================
229 CORBA::Short GHS3DPlugin_Hypothesis_i::GetVerboseLevel()
232 return this->GetImpl()->GetVerboseLevel();
235 //=======================================================================
236 //function : SetToCreateNewNodes
237 //=======================================================================
239 void GHS3DPlugin_Hypothesis_i::SetToCreateNewNodes(CORBA::Boolean toCreate)
242 this->GetImpl()->SetToCreateNewNodes(toCreate);
243 SMESH::TPythonDump() << _this() << ".SetToCreateNewNodes( " << toCreate << " )";
246 //=======================================================================
247 //function : GetToCreateNewNodes
248 //=======================================================================
250 CORBA::Boolean GHS3DPlugin_Hypothesis_i::GetToCreateNewNodes()
253 return this->GetImpl()->GetToCreateNewNodes();
256 //=======================================================================
257 //function : SetToUseBoundaryRecoveryVersion
258 //=======================================================================
260 void GHS3DPlugin_Hypothesis_i::SetToUseBoundaryRecoveryVersion(CORBA::Boolean toUse)
263 this->GetImpl()->SetToUseBoundaryRecoveryVersion(toUse);
264 SMESH::TPythonDump() << _this() << ".SetToUseBoundaryRecoveryVersion( " << toUse << " )";
267 //=======================================================================
268 //function : GetToUseBoundaryRecoveryVersion
269 //=======================================================================
271 CORBA::Boolean GHS3DPlugin_Hypothesis_i::GetToUseBoundaryRecoveryVersion()
274 return this->GetImpl()->GetToUseBoundaryRecoveryVersion();
277 //=======================================================================
278 //function : SetFEMCorrection
279 //=======================================================================
281 void GHS3DPlugin_Hypothesis_i::SetFEMCorrection(CORBA::Boolean toUseFem)
284 this->GetImpl()->SetFEMCorrection(toUseFem);
285 SMESH::TPythonDump() << _this() << ".SetFEMCorrection( " << toUseFem << " )";
288 //=======================================================================
289 //function : GetFEMCorrection
290 //=======================================================================
292 CORBA::Boolean GHS3DPlugin_Hypothesis_i::GetFEMCorrection()
295 return this->GetImpl()->GetFEMCorrection();
298 //=======================================================================
299 //function : SetToRemoveCentralPoint
300 //=======================================================================
302 void GHS3DPlugin_Hypothesis_i::SetToRemoveCentralPoint(CORBA::Boolean toRemove)
305 this->GetImpl()->SetToRemoveCentralPoint(toRemove);
306 SMESH::TPythonDump() << _this() << ".SetToRemoveCentralPoint( " << toRemove << " )";
309 //=======================================================================
310 //function : GetToRemoveCentralPoint
311 //=======================================================================
313 CORBA::Boolean GHS3DPlugin_Hypothesis_i::GetToRemoveCentralPoint()
316 return this->GetImpl()->GetToRemoveCentralPoint();
319 //=======================================================================
320 //function : SetTextOption
321 //=======================================================================
323 void GHS3DPlugin_Hypothesis_i::SetTextOption(const char* option)
326 this->GetImpl()->SetTextOption(option);
327 SMESH::TPythonDump() << _this() << ".SetTextOption( '" << option << "' )";
330 //=======================================================================
331 //function : GetTextOption
332 //=======================================================================
334 char* GHS3DPlugin_Hypothesis_i::GetTextOption()
337 return CORBA::string_dup( this->GetImpl()->GetTextOption().c_str() );
340 //=======================================================================
341 //function : SetEnforcedVertex
342 //=======================================================================
344 void GHS3DPlugin_Hypothesis_i::SetEnforcedVertex(CORBA::Double x, CORBA::Double y, CORBA::Double z, CORBA::Double size)
347 this->GetImpl()->SetEnforcedVertex(x,y,z,size);
348 SMESH::TPythonDump() << _this() << ".SetEnforcedVertex( " << x << ", " << y << ", " << z << ", " << size << " )";
351 //=======================================================================
352 //function : GetEnforcedVertex
353 //=======================================================================
355 CORBA::Double GHS3DPlugin_Hypothesis_i::GetEnforcedVertex(CORBA::Double x, CORBA::Double y, CORBA::Double z)
356 throw (SALOME::SALOME_Exception)
360 return this->GetImpl()->GetEnforcedVertex(x,y,z);
362 catch (const std::invalid_argument& ex) {
363 SALOME::ExceptionStruct ExDescription;
364 ExDescription.text = ex.what();
365 ExDescription.type = SALOME::BAD_PARAM;
366 ExDescription.sourceFile = "GHS3DPlugin_Hypothesis::GetEnforcedVertex(x,y,z)";
367 ExDescription.lineNumber = 0;
368 throw SALOME::SALOME_Exception(ExDescription);
370 catch (SALOME_Exception& ex) {
371 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
376 //=======================================================================
377 //function : GetEnforcedVertices
378 //=======================================================================
380 GHS3DPlugin::GHS3DEnforcedVertexList* GHS3DPlugin_Hypothesis_i::GetEnforcedVertices()
383 GHS3DPlugin::GHS3DEnforcedVertexList_var result = new GHS3DPlugin::GHS3DEnforcedVertexList();
385 const ::GHS3DPlugin_Hypothesis::TEnforcedVertexValues sizeMaps = this->GetImpl()->_GetEnforcedVertices();
386 int size = sizeMaps.size();
387 result->length( size );
389 ::GHS3DPlugin_Hypothesis::TEnforcedVertexValues::const_iterator it;
391 for (it = sizeMaps.begin() ; it != sizeMaps.end(); it++ ) {
392 GHS3DPlugin::GHS3DEnforcedVertex_var myVertex = new GHS3DPlugin::GHS3DEnforcedVertex();
393 myVertex->x = it->first[0];
394 myVertex->y = it->first[1];
395 myVertex->z = it->first[2];
396 myVertex->size = it->second;
401 return result._retn();
404 //=======================================================================
405 //function : RemoveEnforcedVertex
406 //=======================================================================
408 void GHS3DPlugin_Hypothesis_i::RemoveEnforcedVertex(CORBA::Double x, CORBA::Double y, CORBA::Double z)
409 throw (SALOME::SALOME_Exception)
413 this->GetImpl()->RemoveEnforcedVertex(x,y,z);
414 SMESH::TPythonDump() << _this() << ".RemoveEnforcedVertex( " << x << ", " << y << ", " << z << " )";
416 catch (const std::invalid_argument& ex) {
417 SALOME::ExceptionStruct ExDescription;
418 ExDescription.text = ex.what();
419 ExDescription.type = SALOME::BAD_PARAM;
420 ExDescription.sourceFile = "GHS3DPlugin_Hypothesis::RemoveEnforcedVertex(x,y,z)";
421 ExDescription.lineNumber = 0;
422 throw SALOME::SALOME_Exception(ExDescription);
424 catch (SALOME_Exception& ex) {
425 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
429 //=======================================================================
430 //function : ClearEnforcedVertices
431 //=======================================================================
433 void GHS3DPlugin_Hypothesis_i::ClearEnforcedVertices()
436 this->GetImpl()->ClearEnforcedVertices();
439 //=============================================================================
443 //=============================================================================
445 ::GHS3DPlugin_Hypothesis* GHS3DPlugin_Hypothesis_i::GetImpl()
447 return (::GHS3DPlugin_Hypothesis*)myBaseImpl;
450 //================================================================================
452 * \brief Verify whether hypothesis supports given entity type
454 //================================================================================
456 CORBA::Boolean GHS3DPlugin_Hypothesis_i::IsDimSupported( SMESH::Dimension type )
458 return type == SMESH::DIM_3D;