1 // Copyright (C) 2004-2008 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
19 // File : GHS3DPlugin_Hypothesis_i.cxx
20 // Created : Wed Apr 2 13:53:01 2008
21 // Author : Edward AGAPOV (eap)
23 #include "GHS3DPlugin_Hypothesis_i.hxx"
25 #include <SMESH_Gen.hxx>
26 #include <SMESH_PythonDump.hxx>
28 #include <Utils_CorbaException.hxx>
29 #include <utilities.h>
30 #include <SMESH_Mesh_i.hxx>
32 //=======================================================================
33 //function : GHS3DPlugin_Hypothesis_i
34 //=======================================================================
36 GHS3DPlugin_Hypothesis_i::GHS3DPlugin_Hypothesis_i (PortableServer::POA_ptr thePOA,
38 ::SMESH_Gen* theGenImpl)
39 : SALOME::GenericObj_i( thePOA ),
40 SMESH_Hypothesis_i( thePOA )
42 MESSAGE( "GHS3DPlugin_Hypothesis_i::GHS3DPlugin_Hypothesis_i" );
43 myBaseImpl = new ::GHS3DPlugin_Hypothesis (theGenImpl->GetANewId(),
48 //=======================================================================
49 //function : ~GHS3DPlugin_Hypothesis_i
50 //=======================================================================
52 GHS3DPlugin_Hypothesis_i::~GHS3DPlugin_Hypothesis_i()
54 MESSAGE( "GHS3DPlugin_Hypothesis_i::~GHS3DPlugin_Hypothesis_i" );
57 //=======================================================================
58 //function : SetToMeshHoles
59 //=======================================================================
61 void GHS3DPlugin_Hypothesis_i::SetToMeshHoles(CORBA::Boolean toMesh)
64 this->GetImpl()->SetToMeshHoles(toMesh);
65 SMESH::TPythonDump() << _this() << ".SetToMeshHoles( " << toMesh << " )";
68 //=======================================================================
69 //function : GetToMeshHoles
70 //=======================================================================
72 CORBA::Boolean GHS3DPlugin_Hypothesis_i::GetToMeshHoles()
75 return this->GetImpl()->GetToMeshHoles();
78 //=======================================================================
79 //function : SetMaximumMemory
80 //=======================================================================
82 void GHS3DPlugin_Hypothesis_i::SetMaximumMemory(CORBA::Short MB)
83 throw ( SALOME::SALOME_Exception )
86 THROW_SALOME_CORBA_EXCEPTION( "Invalid memory size",SALOME::BAD_PARAM );
88 this->GetImpl()->SetMaximumMemory(MB);
89 SMESH::TPythonDump() << _this() << ".SetMaximumMemory( " << MB << " )";
92 //=======================================================================
93 //function : GetMaximumMemory
94 //=======================================================================
96 CORBA::Short GHS3DPlugin_Hypothesis_i::GetMaximumMemory()
99 return this->GetImpl()->GetMaximumMemory();
102 //=======================================================================
103 //function : SetInitialMemory
104 //=======================================================================
106 void GHS3DPlugin_Hypothesis_i::SetInitialMemory(CORBA::Short MB)
107 throw ( SALOME::SALOME_Exception )
110 THROW_SALOME_CORBA_EXCEPTION( "Invalid memory size",SALOME::BAD_PARAM );
112 this->GetImpl()->SetInitialMemory(MB);
113 SMESH::TPythonDump() << _this() << ".SetInitialMemory( " << MB << " )";
116 //=======================================================================
117 //function : GetInitialMemory
118 //=======================================================================
120 CORBA::Short GHS3DPlugin_Hypothesis_i::GetInitialMemory()
123 return this->GetImpl()->GetInitialMemory();
126 //=======================================================================
127 //function : SetOptimizationLevel
128 //=======================================================================
130 void GHS3DPlugin_Hypothesis_i::SetOptimizationLevel(CORBA::Short level)
131 throw ( SALOME::SALOME_Exception )
133 ::GHS3DPlugin_Hypothesis::OptimizationLevel l =
134 (::GHS3DPlugin_Hypothesis::OptimizationLevel) level;
135 if ( l < ::GHS3DPlugin_Hypothesis::None ||
136 l > ::GHS3DPlugin_Hypothesis::Strong )
137 THROW_SALOME_CORBA_EXCEPTION( "Invalid optimization level",SALOME::BAD_PARAM );
140 this->GetImpl()->SetOptimizationLevel(l);
141 SMESH::TPythonDump() << _this() << ".SetOptimizationLevel( " << level << " )";
144 //=======================================================================
145 //function : GetOptimizationLevel
146 //=======================================================================
148 CORBA::Short GHS3DPlugin_Hypothesis_i::GetOptimizationLevel()
151 return this->GetImpl()->GetOptimizationLevel();
154 //=======================================================================
155 //function : SetWorkingDirectory
156 //=======================================================================
158 void GHS3DPlugin_Hypothesis_i::SetWorkingDirectory(const char* path) throw ( SALOME::SALOME_Exception )
161 THROW_SALOME_CORBA_EXCEPTION( "Null working directory",SALOME::BAD_PARAM );
164 const char lastChar = *file.rbegin();
166 if ( lastChar != '\\' ) file += '\\';
168 if ( lastChar != '/' ) file += '/';
171 SMESH_Mesh_i::PrepareForWriting (file.c_str());
174 this->GetImpl()->SetWorkingDirectory(path);
175 SMESH::TPythonDump() << _this() << ".SetWorkingDirectory( '" << path << "' )";
178 //=======================================================================
179 //function : GetWorkingDirectory
180 //=======================================================================
182 char* GHS3DPlugin_Hypothesis_i::GetWorkingDirectory()
185 return CORBA::string_dup( this->GetImpl()->GetWorkingDirectory().c_str() );
188 //=======================================================================
189 //function : SetKeepFiles
190 //=======================================================================
192 void GHS3DPlugin_Hypothesis_i::SetKeepFiles(CORBA::Boolean toKeep)
195 this->GetImpl()->SetKeepFiles(toKeep);
196 SMESH::TPythonDump() << _this() << ".SetKeepFiles( " << toKeep << " )";
199 //=======================================================================
200 //function : GetKeepFiles
201 //=======================================================================
203 CORBA::Boolean GHS3DPlugin_Hypothesis_i::GetKeepFiles()
206 return this->GetImpl()->GetKeepFiles();
209 //=======================================================================
210 //function : SetVerboseLevel
211 //=======================================================================
213 void GHS3DPlugin_Hypothesis_i::SetVerboseLevel(CORBA::Short level)
214 throw ( SALOME::SALOME_Exception )
216 if (level < 0 || level > 10 )
217 THROW_SALOME_CORBA_EXCEPTION( "Invalid verbose level, valid range is [0-10]",
220 this->GetImpl()->SetVerboseLevel(level);
221 SMESH::TPythonDump() << _this() << ".SetVerboseLevel( " << level << " )";
224 //=======================================================================
225 //function : GetVerboseLevel
226 //=======================================================================
228 CORBA::Short GHS3DPlugin_Hypothesis_i::GetVerboseLevel()
231 return this->GetImpl()->GetVerboseLevel();
234 //=======================================================================
235 //function : SetToCreateNewNodes
236 //=======================================================================
238 void GHS3DPlugin_Hypothesis_i::SetToCreateNewNodes(CORBA::Boolean toCreate)
241 this->GetImpl()->SetToCreateNewNodes(toCreate);
242 SMESH::TPythonDump() << _this() << ".SetToCreateNewNodes( " << toCreate << " )";
245 //=======================================================================
246 //function : GetToCreateNewNodes
247 //=======================================================================
249 CORBA::Boolean GHS3DPlugin_Hypothesis_i::GetToCreateNewNodes()
252 return this->GetImpl()->GetToCreateNewNodes();
255 //=======================================================================
256 //function : SetToUseBoundaryRecoveryVersion
257 //=======================================================================
259 void GHS3DPlugin_Hypothesis_i::SetToUseBoundaryRecoveryVersion(CORBA::Boolean toUse)
262 this->GetImpl()->SetToUseBoundaryRecoveryVersion(toUse);
263 SMESH::TPythonDump() << _this() << ".SetToUseBoundaryRecoveryVersion( " << toUse << " )";
266 //=======================================================================
267 //function : GetToUseBoundaryRecoveryVersion
268 //=======================================================================
270 CORBA::Boolean GHS3DPlugin_Hypothesis_i::GetToUseBoundaryRecoveryVersion()
273 return this->GetImpl()->GetToUseBoundaryRecoveryVersion();
276 //=======================================================================
277 //function : SetFEMCorrection
278 //=======================================================================
280 void GHS3DPlugin_Hypothesis_i::SetFEMCorrection(CORBA::Boolean toUseFem)
283 this->GetImpl()->SetFEMCorrection(toUseFem);
284 SMESH::TPythonDump() << _this() << ".SetFEMCorrection( " << toUseFem << " )";
287 //=======================================================================
288 //function : GetFEMCorrection
289 //=======================================================================
291 CORBA::Boolean GHS3DPlugin_Hypothesis_i::GetFEMCorrection()
294 return this->GetImpl()->GetFEMCorrection();
297 //=======================================================================
298 //function : SetToRemoveCentralPoint
299 //=======================================================================
301 void GHS3DPlugin_Hypothesis_i::SetToRemoveCentralPoint(CORBA::Boolean toRemove)
304 this->GetImpl()->SetToRemoveCentralPoint(toRemove);
305 SMESH::TPythonDump() << _this() << ".SetToRemoveCentralPoint( " << toRemove << " )";
308 //=======================================================================
309 //function : GetToRemoveCentralPoint
310 //=======================================================================
312 CORBA::Boolean GHS3DPlugin_Hypothesis_i::GetToRemoveCentralPoint()
315 return this->GetImpl()->GetToRemoveCentralPoint();
318 //=======================================================================
319 //function : SetTextOption
320 //=======================================================================
322 void GHS3DPlugin_Hypothesis_i::SetTextOption(const char* option)
325 this->GetImpl()->SetTextOption(option);
326 SMESH::TPythonDump() << _this() << ".SetTextOption( '" << option << "' )";
329 //=======================================================================
330 //function : GetTextOption
331 //=======================================================================
333 char* GHS3DPlugin_Hypothesis_i::GetTextOption()
336 return CORBA::string_dup( this->GetImpl()->GetTextOption().c_str() );
339 //=======================================================================
340 //function : SetEnforcedVertex
341 //=======================================================================
343 void GHS3DPlugin_Hypothesis_i::SetEnforcedVertex(CORBA::Double x, CORBA::Double y, CORBA::Double z, CORBA::Double size)
346 this->GetImpl()->SetEnforcedVertex(x,y,z,size);
347 SMESH::TPythonDump() << _this() << ".SetEnforcedVertex( " << x << ", " << y << ", " << z << ", " << size << " )";
350 //=======================================================================
351 //function : GetEnforcedVertex
352 //=======================================================================
354 CORBA::Double GHS3DPlugin_Hypothesis_i::GetEnforcedVertex(CORBA::Double x, CORBA::Double y, CORBA::Double z)
355 throw (SALOME::SALOME_Exception)
359 return this->GetImpl()->GetEnforcedVertex(x,y,z);
361 catch (const std::invalid_argument& ex) {
362 SALOME::ExceptionStruct ExDescription;
363 ExDescription.text = ex.what();
364 ExDescription.type = SALOME::BAD_PARAM;
365 ExDescription.sourceFile = "GHS3DPlugin_Hypothesis::GetEnforcedVertex(x,y,z)";
366 ExDescription.lineNumber = 0;
367 throw SALOME::SALOME_Exception(ExDescription);
369 catch (SALOME_Exception& ex) {
370 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
375 //=======================================================================
376 //function : GetEnforcedVertices
377 //=======================================================================
379 GHS3DPlugin::GHS3DEnforcedVertexList* GHS3DPlugin_Hypothesis_i::GetEnforcedVertices()
382 GHS3DPlugin::GHS3DEnforcedVertexList_var result = new GHS3DPlugin::GHS3DEnforcedVertexList();
384 const ::GHS3DPlugin_Hypothesis::TEnforcedVertexValues sizeMaps = this->GetImpl()->_GetEnforcedVertices();
385 int size = sizeMaps.size();
386 result->length( size );
388 ::GHS3DPlugin_Hypothesis::TEnforcedVertexValues::const_iterator it;
390 for (it = sizeMaps.begin() ; it != sizeMaps.end(); it++ ) {
391 GHS3DPlugin::GHS3DEnforcedVertex_var myVertex = new GHS3DPlugin::GHS3DEnforcedVertex();
392 myVertex->x = it->first[0];
393 myVertex->y = it->first[1];
394 myVertex->z = it->first[2];
395 myVertex->size = it->second;
400 return result._retn();
403 //=======================================================================
404 //function : RemoveEnforcedVertex
405 //=======================================================================
407 void GHS3DPlugin_Hypothesis_i::RemoveEnforcedVertex(CORBA::Double x, CORBA::Double y, CORBA::Double z)
408 throw (SALOME::SALOME_Exception)
412 this->GetImpl()->RemoveEnforcedVertex(x,y,z);
413 SMESH::TPythonDump() << _this() << ".RemoveEnforcedVertex( " << x << ", " << y << ", " << z << " )";
415 catch (const std::invalid_argument& ex) {
416 SALOME::ExceptionStruct ExDescription;
417 ExDescription.text = ex.what();
418 ExDescription.type = SALOME::BAD_PARAM;
419 ExDescription.sourceFile = "GHS3DPlugin_Hypothesis::RemoveEnforcedVertex(x,y,z)";
420 ExDescription.lineNumber = 0;
421 throw SALOME::SALOME_Exception(ExDescription);
423 catch (SALOME_Exception& ex) {
424 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
428 //=======================================================================
429 //function : ClearEnforcedVertices
430 //=======================================================================
432 void GHS3DPlugin_Hypothesis_i::ClearEnforcedVertices()
435 this->GetImpl()->ClearEnforcedVertices();
438 //=============================================================================
442 //=============================================================================
444 ::GHS3DPlugin_Hypothesis* GHS3DPlugin_Hypothesis_i::GetImpl()
446 return (::GHS3DPlugin_Hypothesis*)myBaseImpl;
449 //================================================================================
451 * \brief Verify whether hypothesis supports given entity type
453 //================================================================================
455 CORBA::Boolean GHS3DPlugin_Hypothesis_i::IsDimSupported( SMESH::Dimension type )
457 return type == SMESH::DIM_3D;