1 // Copyright (C) 2007-2015 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, or (at your option) any later version.
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
21 // File : HexoticPlugin_Hypothesis_i.cxx
22 // Author : Lioka RAZAFINDRAZAKA (CEA)
25 #include "HexoticPlugin_Hypothesis_i.hxx"
26 #include "SMESH_Mesh_i.hxx"
27 #include "SMESH_Gen.hxx"
28 #include "SMESH_PythonDump.hxx"
30 #include "Utils_CorbaException.hxx"
31 #include "utilities.h"
33 //=============================================================================
35 * HexoticPlugin_Hypothesis_i::HexoticPlugin_Hypothesis_i
39 //=============================================================================
40 HexoticPlugin_Hypothesis_i::
41 HexoticPlugin_Hypothesis_i (PortableServer::POA_ptr thePOA,
43 ::SMESH_Gen* theGenImpl)
44 : SALOME::GenericObj_i( thePOA ),
45 SMESH_Hypothesis_i( thePOA )
47 MESSAGE( "HexoticPlugin_Hypothesis_i::HexoticPlugin_Hypothesis_i" );
48 myBaseImpl = new ::HexoticPlugin_Hypothesis (theGenImpl->GetANewId(),
53 //=============================================================================
55 * HexoticPlugin_Hypothesis_i::~HexoticPlugin_Hypothesis_i
59 //=============================================================================
60 HexoticPlugin_Hypothesis_i::~HexoticPlugin_Hypothesis_i()
62 MESSAGE( "HexoticPlugin_Hypothesis_i::~HexoticPlugin_Hypothesis_i" );
65 //=============================================================================
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 * HexoticPlugin_Hypothesis_i::SetHexoticMaxMemory
79 * HexoticPlugin_Hypothesis_i::SetNbLayers
80 * HexoticPlugin_Hypothesis_i::SetFirstLayerSize
81 * HexoticPlugin_Hypothesis_i::SetDirection
82 * HexoticPlugin_Hypothesis_i::SetGrowth
83 * HexoticPlugin_Hypothesis_i::SetFacesWithLayers
84 * HexoticPlugin_Hypothesis_i::SetImprintedFaces
86 //=============================================================================
88 void HexoticPlugin_Hypothesis_i::SetHexesMinLevel (CORBA::Long theValue)
90 // MESSAGE("HexoticPlugin_Hypothesis_i::SetHexesMinLevel");
92 CORBA::Long oldValue = GetHexesMinLevel();
93 this->GetImpl()->SetHexesMinLevel(theValue);
94 if (theValue != oldValue)
95 SMESH::TPythonDump() << _this() << ".SetHexesMinLevel( " << theValue << " )";
98 void HexoticPlugin_Hypothesis_i::SetHexesMaxLevel (CORBA::Long theValue)
100 // MESSAGE("HexoticPlugin_Hypothesis_i::SetHexesMaxLevel");
102 CORBA::Long oldValue = GetHexesMaxLevel();
103 this->GetImpl()->SetHexesMaxLevel(theValue);
104 if (theValue != oldValue)
105 SMESH::TPythonDump() << _this() << ".SetHexesMaxLevel( " << theValue << " )";
108 void HexoticPlugin_Hypothesis_i::SetMinSize (CORBA::Double theValue)
110 // MESSAGE("HexoticPlugin_Hypothesis_i::SetHexesMaxLevel");
112 CORBA::Double oldValue = GetMinSize();
113 this->GetImpl()->SetMinSize(theValue);
114 if (theValue != oldValue)
115 SMESH::TPythonDump() << _this() << ".SetMinSize( " << theValue << " )";
118 void HexoticPlugin_Hypothesis_i::SetMaxSize (CORBA::Double theValue)
120 // MESSAGE("HexoticPlugin_Hypothesis_i::SetHexesMaxLevel");
122 CORBA::Double oldValue = GetMaxSize();
123 this->GetImpl()->SetMaxSize(theValue);
124 if (theValue != oldValue)
125 SMESH::TPythonDump() << _this() << ".SetMaxSize( " << theValue << " )";
128 void HexoticPlugin_Hypothesis_i::SetHexoticIgnoreRidges (CORBA::Boolean theValue)
130 // MESSAGE("HexoticPlugin_Hypothesis_i::SetHexoticIgnoreRidges");
132 CORBA::Boolean oldValue = GetHexoticIgnoreRidges();
133 this->GetImpl()->SetHexoticIgnoreRidges(theValue);
134 if (theValue != oldValue)
135 SMESH::TPythonDump() << _this() << ".SetHexoticIgnoreRidges( " << theValue << " )";
138 void HexoticPlugin_Hypothesis_i::SetHexoticInvalidElements (CORBA::Boolean theValue)
140 // MESSAGE("HexoticPlugin_Hypothesis_i::SetHexoticInvalidElements");
142 CORBA::Boolean oldValue = GetHexoticInvalidElements();
143 this->GetImpl()->SetHexoticInvalidElements(theValue);
144 if (theValue != oldValue)
145 SMESH::TPythonDump() << _this() << ".SetHexoticInvalidElements( " << theValue << " )";
148 void HexoticPlugin_Hypothesis_i::SetHexoticSharpAngleThreshold (CORBA::Double theValue)
150 // MESSAGE("HexoticPlugin_Hypothesis_i::SetHexoticSharpAngleThreshold");
152 CORBA::Double oldValue = GetHexoticSharpAngleThreshold();
153 this->GetImpl()->SetHexoticSharpAngleThreshold(theValue);
154 if (theValue != oldValue)
155 SMESH::TPythonDump() << _this() << ".SetHexoticSharpAngleThreshold( " << theValue << " )";
158 void HexoticPlugin_Hypothesis_i::SetHexoticNbProc (CORBA::Long theValue)
160 // MESSAGE("HexoticPlugin_Hypothesis_i::SetHexoticNbProc");
162 CORBA::Long oldValue = GetHexoticNbProc();
163 this->GetImpl()->SetHexoticNbProc(theValue);
164 if (theValue != oldValue)
165 SMESH::TPythonDump() << _this() << ".SetHexoticNbProc( " << theValue << " )";
168 void HexoticPlugin_Hypothesis_i::SetHexoticWorkingDirectory(const char* path) throw ( SALOME::SALOME_Exception )
171 THROW_SALOME_CORBA_EXCEPTION( "Null working directory",SALOME::BAD_PARAM );
175 string oldValue(GetHexoticWorkingDirectory());
177 if (oldValue != file)
180 const char lastChar = *file.rbegin();
182 if ( lastChar != '\\' ) file += '\\';
184 if ( lastChar != '/' ) file += '/';
186 file += "Hexotic_In.mesh";
187 SMESH_Mesh_i::PrepareForWriting (file.c_str());
189 this->GetImpl()->SetHexoticWorkingDirectory(path);
191 SMESH::TPythonDump() << _this() << ".SetHexoticWorkingDirectory( '" << path << "' )";
194 void HexoticPlugin_Hypothesis_i::SetHexoticSdMode (CORBA::Long theValue)
196 // MESSAGE("HexoticPlugin_Hypothesis_i::SetHexoticSdMode");
198 CORBA::Long oldValue = GetHexoticSdMode();
199 this->GetImpl()->SetHexoticSdMode(theValue);
200 if (theValue != oldValue)
201 SMESH::TPythonDump() << _this() << ".SetHexoticSdMode( " << theValue << " )";
204 void HexoticPlugin_Hypothesis_i::SetHexoticVerbosity (CORBA::Long theValue)
206 // MESSAGE("HexoticPlugin_Hypothesis_i::SetVerbosity");
208 CORBA::Long oldValue = GetHexoticVerbosity();
209 this->GetImpl()->SetHexoticVerbosity(theValue);
210 if (theValue != oldValue)
211 SMESH::TPythonDump() << _this() << ".SetHexoticVerbosity( " << theValue << " )";
214 void HexoticPlugin_Hypothesis_i::SetHexoticMaxMemory (CORBA::Long theValue)
216 // MESSAGE("HexoticPlugin_Hypothesis_i::SetHexoticMaxMemory");
218 CORBA::Long oldValue = GetHexoticMaxMemory();
219 this->GetImpl()->SetHexoticMaxMemory(theValue);
220 if (theValue != oldValue)
221 SMESH::TPythonDump() << _this() << ".SetHexoticMaxMemory( " << theValue << " )";
224 HexoticPlugin::HexoticPluginSizeMapsList* HexoticPlugin_Hypothesis_i::GetSizeMaps ()
226 // Get the std::map < string entry, double size >
227 HexoticPlugin::HexoticPluginSizeMapsList_var result = new HexoticPlugin::HexoticPluginSizeMapsList();
228 const ::HexoticPlugin_Hypothesis::THexoticSizeMaps sizeMaps = this->GetImpl()->GetSizeMaps();
229 result->length( sizeMaps.size() );
231 // Write the content into a CORBA sequence of struct{ entry=anEntry; size=aSize; }
232 ::HexoticPlugin_Hypothesis::THexoticSizeMaps::const_iterator it = sizeMaps.begin();
233 for ( int i = 0; it != sizeMaps.end(); i++, it++ )
235 HexoticPlugin::HexoticPluginSizeMap_var aSizeMap = new HexoticPlugin::HexoticPluginSizeMap();
236 aSizeMap->entry = CORBA::string_dup( it->first.c_str() );
237 aSizeMap->size = it->second;
238 result[i] = aSizeMap;
240 return result._retn();
243 void HexoticPlugin_Hypothesis_i::SetSizeMapEntry ( const char* theEntry, CORBA::Double theSize )
245 // MESSAGE("HexoticPlugin_Hypothesis_i::SetSizeMapEntry");
246 bool valueChanged = this->GetImpl()->AddSizeMap(theEntry, theSize);
248 SMESH::TPythonDump() << _this() << ".SetSizeMap( "<< theEntry << ", " << theSize << " )";
251 void HexoticPlugin_Hypothesis_i::UnsetSizeMapEntry ( const char* theEntry )
253 // MESSAGE("HexoticPlugin_Hypothesis_i::UnsetSizeMapEntry");
254 bool entryRemoved = this->GetImpl()->UnsetSizeMap(theEntry);
256 SMESH::TPythonDump() << _this() << ".UnsetSizeMap( "<< theEntry << " )";
259 void HexoticPlugin_Hypothesis_i::SetSizeMap (const GEOM::GEOM_Object_ptr theGeomObj, const double theSize)
261 // MESSAGE("HexoticPlugin_Hypothesis_i::SetSizeMap");
263 std::string entry = theGeomObj->GetStudyEntry();
264 SetSizeMapEntry( entry.c_str(), theSize);
267 void HexoticPlugin_Hypothesis_i::UnsetSizeMap (const GEOM::GEOM_Object_ptr theGeomObj)
269 // MESSAGE("HexoticPlugin_Hypothesis_i::UnsetSizeMap");
271 std::string entry = theGeomObj->GetStudyEntry();
272 UnsetSizeMapEntry( entry.c_str());
275 void HexoticPlugin_Hypothesis_i::SetNbLayers(CORBA::Long theVal)
277 // MESSAGE("HexoticPlugin_Hypothesis_i::SetNbLayers");
279 CORBA::Long oldValue = GetNbLayers();
280 this->GetImpl()->SetNbLayers(theVal);
281 if (theVal != oldValue)
282 SMESH::TPythonDump() << _this() << ".SetNbLayers( " << theVal << " )";
285 void HexoticPlugin_Hypothesis_i::SetFirstLayerSize(CORBA::Double theVal)
287 // MESSAGE("HexoticPlugin_Hypothesis_i::SetFirstLayerSize");
289 CORBA::Double oldValue = GetFirstLayerSize();
290 this->GetImpl()->SetFirstLayerSize(theVal);
291 if (theVal != oldValue)
292 SMESH::TPythonDump() << _this() << ".SetFirstLayerSize( " << theVal << " )";
295 void HexoticPlugin_Hypothesis_i::SetDirection(CORBA::Boolean theVal)
297 // MESSAGE("HexoticPlugin_Hypothesis_i::SetDirection");
299 CORBA::Boolean oldValue = GetDirection();
300 this->GetImpl()->SetDirection(theVal);
301 if (theVal != oldValue)
302 SMESH::TPythonDump() << _this() << ".SetDirection( " << theVal << " )";
305 void HexoticPlugin_Hypothesis_i::SetGrowth(CORBA::Double theVal)
307 // MESSAGE("HexoticPlugin_Hypothesis_i::SetGrowth");
309 CORBA::Double oldValue = GetGrowth();
310 this->GetImpl()->SetGrowth(theVal);
311 if (theVal != oldValue)
312 SMESH::TPythonDump() << _this() << ".SetGrowth( " << theVal << " )";
315 void HexoticPlugin_Hypothesis_i::SetFacesWithLayers(const ::SMESH::long_array& theVal)
317 // MESSAGE("HexoticPlugin_Hypothesis_i::SetFacesWithLayers");
318 vector<int> ids( theVal.length() );
319 for ( unsigned i = 0; i < ids.size(); ++i )
322 bool valueChanged = this->GetImpl()->SetFacesWithLayers(ids);
324 SMESH::TPythonDump() << _this() << ".SetFacesWithLayers( "<< theVal << " )";
327 void HexoticPlugin_Hypothesis_i::SetImprintedFaces(const ::SMESH::long_array& theVal)
329 // MESSAGE("HexoticPlugin_Hypothesis_i::SetImprintedFaces");
330 vector<int> ids( theVal.length() );
331 for ( unsigned i = 0; i < ids.size(); ++i )
334 bool valueChanged = this->GetImpl()->SetImprintedFaces(ids);
336 SMESH::TPythonDump() << _this() << ".SetImprintedFaces( "<< theVal << " )";
339 //=============================================================================
341 * HexoticPlugin_Hypothesis_i::GetHexesMinLevel
342 * HexoticPlugin_Hypothesis_i::GetHexesMaxLevel
343 * HexoticPlugin_Hypothesis_i::GetMinSize
344 * HexoticPlugin_Hypothesis_i::GetMaxSize
345 * HexoticPlugin_Hypothesis_i::GetHexoticIgnoreRidges
346 * HexoticPlugin_Hypothesis_i::GetHexoticInvalidElements
347 * HexoticPlugin_Hypothesis_i::GetHexoticSharpAngleThreshold
348 * HexoticPlugin_Hypothesis_i::GetHexoticNbProc
349 * HexoticPlugin_Hypothesis_i::GetHexoticWorkingDirectory
350 * HexoticPlugin_Hypothesis_i::GetHexoticSdMode
351 * HexoticPlugin_Hypothesis_i::GetVerbosity
352 * HexoticPlugin_Hypothesis_i::GetHexoticMaxMemory
353 * HexoticPlugin_Hypothesis_i::GetNbLayers
354 * HexoticPlugin_Hypothesis_i::GetFirstLayerSize
355 * HexoticPlugin_Hypothesis_i::GetDirection
356 * HexoticPlugin_Hypothesis_i::GetGrowth
357 * HexoticPlugin_Hypothesis_i::GetFacesWithLayers
358 * HexoticPlugin_Hypothesis_i::GetImprintedFaces
360 //=============================================================================
362 CORBA::Long HexoticPlugin_Hypothesis_i::GetHexesMinLevel()
364 // MESSAGE("HexoticPlugin_Hypothesis_i::GetHexesMinLevel");
366 return this->GetImpl()->GetHexesMinLevel();
369 CORBA::Long HexoticPlugin_Hypothesis_i::GetHexesMaxLevel()
371 // MESSAGE("HexoticPlugin_Hypothesis_i::GetHexesMaxLevel");
373 return this->GetImpl()->GetHexesMaxLevel();
376 CORBA::Double HexoticPlugin_Hypothesis_i::GetMinSize()
378 // MESSAGE("HexoticPlugin_Hypothesis_i::GetMinSize");
380 return this->GetImpl()->GetMinSize();
383 CORBA::Double HexoticPlugin_Hypothesis_i::GetMaxSize()
385 // MESSAGE("HexoticPlugin_Hypothesis_i::GetMaxSize");
387 return this->GetImpl()->GetMaxSize();
390 CORBA::Boolean HexoticPlugin_Hypothesis_i::GetHexoticIgnoreRidges()
392 // MESSAGE("HexoticPlugin_Hypothesis_i::GetHexoticIgnoreRidges");
394 return this->GetImpl()->GetHexoticIgnoreRidges();
397 CORBA::Boolean HexoticPlugin_Hypothesis_i::GetHexoticInvalidElements()
399 // MESSAGE("HexoticPlugin_Hypothesis_i::GetHexoticInvalidElements");
401 return this->GetImpl()->GetHexoticInvalidElements();
404 CORBA::Double HexoticPlugin_Hypothesis_i::GetHexoticSharpAngleThreshold()
406 // MESSAGE("HexoticPlugin_Hypothesis_i::GetHexoticSharpAngleThreshold");
408 return this->GetImpl()->GetHexoticSharpAngleThreshold();
411 CORBA::Long HexoticPlugin_Hypothesis_i::GetHexoticNbProc()
413 // MESSAGE("HexoticPlugin_Hypothesis_i::GetHexoticNbProc");
415 return this->GetImpl()->GetHexoticNbProc();
418 char* HexoticPlugin_Hypothesis_i::GetHexoticWorkingDirectory()
421 return CORBA::string_dup( this->GetImpl()->GetHexoticWorkingDirectory().c_str() );
424 CORBA::Long HexoticPlugin_Hypothesis_i::GetHexoticSdMode ()
426 // MESSAGE("HexoticPlugin_Hypothesis_i::GetHexoticSdMode");
428 return this->GetImpl()->GetHexoticSdMode();
431 CORBA::Long HexoticPlugin_Hypothesis_i::GetHexoticVerbosity()
433 // MESSAGE("HexoticPlugin_Hypothesis_i::GetVerbosity");
435 return this->GetImpl()->GetHexoticVerbosity();
438 CORBA::Long HexoticPlugin_Hypothesis_i::GetHexoticMaxMemory()
440 // MESSAGE("HexoticPlugin_Hypothesis_i::GetHexoticMaxMemory");
442 return this->GetImpl()->GetHexoticMaxMemory();
445 CORBA::Long HexoticPlugin_Hypothesis_i::GetNbLayers()
447 // MESSAGE("HexoticPlugin_Hypothesis_i::GetNbLayers");
449 return this->GetImpl()->GetNbLayers();
452 CORBA::Double HexoticPlugin_Hypothesis_i::GetFirstLayerSize()
454 // MESSAGE("HexoticPlugin_Hypothesis_i::GetFirstLayerSize");
456 return this->GetImpl()->GetFirstLayerSize();
459 CORBA::Boolean HexoticPlugin_Hypothesis_i::GetDirection()
461 // MESSAGE("HexoticPlugin_Hypothesis_i::GetDirection");
463 return this->GetImpl()->GetDirection();
466 CORBA::Double HexoticPlugin_Hypothesis_i::GetGrowth()
468 // MESSAGE("HexoticPlugin_Hypothesis_i::GetGrowth");
470 return this->GetImpl()->GetGrowth();
473 SMESH::long_array* HexoticPlugin_Hypothesis_i::GetFacesWithLayers()
475 // MESSAGE("HexoticPlugin_Hypothesis_i::GetFacesWithLayers");
477 std::vector<int> idsVec = this->GetImpl()->GetFacesWithLayers();
478 SMESH::long_array_var ids = new SMESH::long_array;
479 ids->length( idsVec.size() );
480 for ( unsigned i = 0; i < idsVec.size(); ++i )
485 SMESH::long_array* HexoticPlugin_Hypothesis_i::GetImprintedFaces()
487 // MESSAGE("HexoticPlugin_Hypothesis_i::GetImprintedFaces");
489 std::vector<int> idsVec = this->GetImpl()->GetImprintedFaces();
490 SMESH::long_array_var ids = new SMESH::long_array;
491 ids->length( idsVec.size() );
492 for ( unsigned i = 0; i < idsVec.size(); ++i )
496 //=============================================================================
498 * HexoticPlugin_Hypothesis_i::GetImpl
502 //=============================================================================
503 ::HexoticPlugin_Hypothesis* HexoticPlugin_Hypothesis_i::GetImpl()
505 // MESSAGE("HexoticPlugin_Hypothesis_i::GetImpl");
506 return (::HexoticPlugin_Hypothesis*)myBaseImpl;
509 //================================================================================
511 * \brief Verify whether hypothesis supports given entity type
512 * \param type - dimension (see SMESH::Dimension enumeration)
513 * \retval CORBA::Boolean - TRUE if dimension is supported, FALSE otherwise
515 * Verify whether hypothesis supports given entity type (see SMESH::Dimension enumeration)
517 //================================================================================
518 CORBA::Boolean HexoticPlugin_Hypothesis_i::IsDimSupported( SMESH::Dimension type )
520 return type == SMESH::DIM_3D;