1 // Copyright (C) 2007-2016 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::SetTextOptions
80 * HexoticPlugin_Hypothesis_i::SetNbLayers
81 * HexoticPlugin_Hypothesis_i::SetFirstLayerSize
82 * HexoticPlugin_Hypothesis_i::SetDirection
83 * HexoticPlugin_Hypothesis_i::SetGrowth
84 * HexoticPlugin_Hypothesis_i::SetFacesWithLayers
85 * HexoticPlugin_Hypothesis_i::SetImprintedFaces
87 //=============================================================================
89 void HexoticPlugin_Hypothesis_i::SetHexesMinLevel (CORBA::Long theValue)
91 // MESSAGE("HexoticPlugin_Hypothesis_i::SetHexesMinLevel");
93 CORBA::Long oldValue = GetHexesMinLevel();
94 this->GetImpl()->SetHexesMinLevel(theValue);
95 if (theValue != oldValue)
96 SMESH::TPythonDump() << _this() << ".SetHexesMinLevel( " << theValue << " )";
99 void HexoticPlugin_Hypothesis_i::SetHexesMaxLevel (CORBA::Long theValue)
101 // MESSAGE("HexoticPlugin_Hypothesis_i::SetHexesMaxLevel");
103 CORBA::Long oldValue = GetHexesMaxLevel();
104 this->GetImpl()->SetHexesMaxLevel(theValue);
105 if (theValue != oldValue)
106 SMESH::TPythonDump() << _this() << ".SetHexesMaxLevel( " << theValue << " )";
109 void HexoticPlugin_Hypothesis_i::SetMinSize (CORBA::Double theValue)
111 // MESSAGE("HexoticPlugin_Hypothesis_i::SetHexesMaxLevel");
113 CORBA::Double oldValue = GetMinSize();
114 this->GetImpl()->SetMinSize(theValue);
115 if (theValue != oldValue)
116 SMESH::TPythonDump() << _this() << ".SetMinSize( " << theValue << " )";
119 void HexoticPlugin_Hypothesis_i::SetMaxSize (CORBA::Double theValue)
121 // MESSAGE("HexoticPlugin_Hypothesis_i::SetHexesMaxLevel");
123 CORBA::Double oldValue = GetMaxSize();
124 this->GetImpl()->SetMaxSize(theValue);
125 if (theValue != oldValue)
126 SMESH::TPythonDump() << _this() << ".SetMaxSize( " << theValue << " )";
129 void HexoticPlugin_Hypothesis_i::SetHexoticIgnoreRidges (CORBA::Boolean theValue)
131 // MESSAGE("HexoticPlugin_Hypothesis_i::SetHexoticIgnoreRidges");
133 CORBA::Boolean oldValue = GetHexoticIgnoreRidges();
134 this->GetImpl()->SetHexoticIgnoreRidges(theValue);
135 if (theValue != oldValue)
136 SMESH::TPythonDump() << _this() << ".SetHexoticIgnoreRidges( " << theValue << " )";
139 void HexoticPlugin_Hypothesis_i::SetHexoticInvalidElements (CORBA::Boolean theValue)
141 // MESSAGE("HexoticPlugin_Hypothesis_i::SetHexoticInvalidElements");
143 CORBA::Boolean oldValue = GetHexoticInvalidElements();
144 this->GetImpl()->SetHexoticInvalidElements(theValue);
145 if (theValue != oldValue)
146 SMESH::TPythonDump() << _this() << ".SetHexoticInvalidElements( " << theValue << " )";
149 void HexoticPlugin_Hypothesis_i::SetHexoticSharpAngleThreshold (CORBA::Double theValue)
151 // MESSAGE("HexoticPlugin_Hypothesis_i::SetHexoticSharpAngleThreshold");
153 CORBA::Double oldValue = GetHexoticSharpAngleThreshold();
154 this->GetImpl()->SetHexoticSharpAngleThreshold(theValue);
155 if (theValue != oldValue)
156 SMESH::TPythonDump() << _this() << ".SetHexoticSharpAngleThreshold( " << theValue << " )";
159 void HexoticPlugin_Hypothesis_i::SetHexoticNbProc (CORBA::Long theValue)
161 // MESSAGE("HexoticPlugin_Hypothesis_i::SetHexoticNbProc");
163 CORBA::Long oldValue = GetHexoticNbProc();
164 this->GetImpl()->SetHexoticNbProc(theValue);
165 if (theValue != oldValue)
166 SMESH::TPythonDump() << _this() << ".SetHexoticNbProc( " << theValue << " )";
169 void HexoticPlugin_Hypothesis_i::SetHexoticWorkingDirectory(const char* path) throw ( SALOME::SALOME_Exception )
172 THROW_SALOME_CORBA_EXCEPTION( "Null working directory",SALOME::BAD_PARAM );
175 std::string file(path);
176 std::string oldValue(GetHexoticWorkingDirectory());
178 if (oldValue != file)
181 const char lastChar = *file.rbegin();
183 if ( lastChar != '\\' ) file += '\\';
185 if ( lastChar != '/' ) file += '/';
187 file += "Hexotic_In.mesh";
188 SMESH_Mesh_i::PrepareForWriting (file.c_str());
190 this->GetImpl()->SetHexoticWorkingDirectory(path);
192 SMESH::TPythonDump() << _this() << ".SetHexoticWorkingDirectory( '" << path << "' )";
195 void HexoticPlugin_Hypothesis_i::SetHexoticSdMode (CORBA::Long theValue)
197 // MESSAGE("HexoticPlugin_Hypothesis_i::SetHexoticSdMode");
199 CORBA::Long oldValue = GetHexoticSdMode();
200 this->GetImpl()->SetHexoticSdMode(theValue);
201 if (theValue != oldValue)
202 SMESH::TPythonDump() << _this() << ".SetHexoticSdMode( " << theValue << " )";
205 void HexoticPlugin_Hypothesis_i::SetHexoticVerbosity (CORBA::Long theValue)
207 // MESSAGE("HexoticPlugin_Hypothesis_i::SetVerbosity");
209 CORBA::Long oldValue = GetHexoticVerbosity();
210 this->GetImpl()->SetHexoticVerbosity(theValue);
211 if (theValue != oldValue)
212 SMESH::TPythonDump() << _this() << ".SetHexoticVerbosity( " << theValue << " )";
215 void HexoticPlugin_Hypothesis_i::SetHexoticMaxMemory (CORBA::Long theValue)
217 // MESSAGE("HexoticPlugin_Hypothesis_i::SetHexoticMaxMemory");
219 CORBA::Long oldValue = GetHexoticMaxMemory();
220 this->GetImpl()->SetHexoticMaxMemory(theValue);
221 if (theValue != oldValue)
222 SMESH::TPythonDump() << _this() << ".SetHexoticMaxMemory( " << theValue << " )";
225 void HexoticPlugin_Hypothesis_i::SetTextOptions(const char* theOptions)
227 // MESSAGE("HexoticPlugin_Hypothesis_i::SetTextOptions");
229 std::string oldValue(GetTextOptions());
230 this->GetImpl()->SetTextOptions(theOptions);
231 if (theOptions != oldValue)
232 SMESH::TPythonDump() << _this() << ".SetTextOptions( '" << theOptions << "' )";
235 HexoticPlugin::HexoticPluginSizeMapsList* HexoticPlugin_Hypothesis_i::GetSizeMaps ()
237 // Get the std::map < std::string entry, double size >
238 HexoticPlugin::HexoticPluginSizeMapsList_var result = new HexoticPlugin::HexoticPluginSizeMapsList();
239 const ::HexoticPlugin_Hypothesis::THexoticSizeMaps sizeMaps = this->GetImpl()->GetSizeMaps();
240 result->length( sizeMaps.size() );
242 // Write the content into a CORBA sequence of struct{ entry=anEntry; size=aSize; }
243 ::HexoticPlugin_Hypothesis::THexoticSizeMaps::const_iterator it = sizeMaps.begin();
244 for ( int i = 0; it != sizeMaps.end(); i++, it++ )
246 HexoticPlugin::HexoticPluginSizeMap_var aSizeMap = new HexoticPlugin::HexoticPluginSizeMap();
247 aSizeMap->entry = CORBA::string_dup( it->first.c_str() );
248 aSizeMap->size = it->second;
249 result[i] = aSizeMap;
251 return result._retn();
254 void HexoticPlugin_Hypothesis_i::SetSizeMapEntry ( const char* theEntry, CORBA::Double theSize )
256 // MESSAGE("HexoticPlugin_Hypothesis_i::SetSizeMapEntry");
257 bool valueChanged = this->GetImpl()->AddSizeMap(theEntry, theSize);
259 SMESH::TPythonDump() << _this() << ".SetSizeMap( "<< theEntry << ", " << theSize << " )";
262 void HexoticPlugin_Hypothesis_i::UnsetSizeMapEntry ( const char* theEntry )
264 // MESSAGE("HexoticPlugin_Hypothesis_i::UnsetSizeMapEntry");
265 bool entryRemoved = this->GetImpl()->UnsetSizeMap(theEntry);
267 SMESH::TPythonDump() << _this() << ".UnsetSizeMap( "<< theEntry << " )";
270 void HexoticPlugin_Hypothesis_i::SetSizeMap (const GEOM::GEOM_Object_ptr theGeomObj, const double theSize)
272 // MESSAGE("HexoticPlugin_Hypothesis_i::SetSizeMap");
274 std::string entry = theGeomObj->GetStudyEntry();
275 SetSizeMapEntry( entry.c_str(), theSize);
278 void HexoticPlugin_Hypothesis_i::UnsetSizeMap (const GEOM::GEOM_Object_ptr theGeomObj)
280 // MESSAGE("HexoticPlugin_Hypothesis_i::UnsetSizeMap");
282 std::string entry = theGeomObj->GetStudyEntry();
283 UnsetSizeMapEntry( entry.c_str());
286 void HexoticPlugin_Hypothesis_i::SetNbLayers(CORBA::Long theVal)
288 // MESSAGE("HexoticPlugin_Hypothesis_i::SetNbLayers");
290 CORBA::Long oldValue = GetNbLayers();
291 this->GetImpl()->SetNbLayers(theVal);
292 if (theVal != oldValue)
293 SMESH::TPythonDump() << _this() << ".SetNbLayers( " << theVal << " )";
296 void HexoticPlugin_Hypothesis_i::SetFirstLayerSize(CORBA::Double theVal)
298 // MESSAGE("HexoticPlugin_Hypothesis_i::SetFirstLayerSize");
300 CORBA::Double oldValue = GetFirstLayerSize();
301 this->GetImpl()->SetFirstLayerSize(theVal);
302 if (theVal != oldValue)
303 SMESH::TPythonDump() << _this() << ".SetFirstLayerSize( " << theVal << " )";
306 void HexoticPlugin_Hypothesis_i::SetDirection(CORBA::Boolean theVal)
308 // MESSAGE("HexoticPlugin_Hypothesis_i::SetDirection");
310 CORBA::Boolean oldValue = GetDirection();
311 this->GetImpl()->SetDirection(theVal);
312 if (theVal != oldValue)
313 SMESH::TPythonDump() << _this() << ".SetDirection( " << theVal << " )";
316 void HexoticPlugin_Hypothesis_i::SetGrowth(CORBA::Double theVal)
318 // MESSAGE("HexoticPlugin_Hypothesis_i::SetGrowth");
320 CORBA::Double oldValue = GetGrowth();
321 this->GetImpl()->SetGrowth(theVal);
322 if (theVal != oldValue)
323 SMESH::TPythonDump() << _this() << ".SetGrowth( " << theVal << " )";
326 void HexoticPlugin_Hypothesis_i::SetFacesWithLayers(const ::SMESH::long_array& theVal)
328 // MESSAGE("HexoticPlugin_Hypothesis_i::SetFacesWithLayers");
329 std::vector<int> ids( theVal.length() );
330 for ( unsigned i = 0; i < ids.size(); ++i )
333 bool valueChanged = this->GetImpl()->SetFacesWithLayers(ids);
335 SMESH::TPythonDump() << _this() << ".SetFacesWithLayers( "<< theVal << " )";
338 void HexoticPlugin_Hypothesis_i::SetImprintedFaces(const ::SMESH::long_array& theVal)
340 // MESSAGE("HexoticPlugin_Hypothesis_i::SetImprintedFaces");
341 std::vector<int> ids( theVal.length() );
342 for ( unsigned i = 0; i < ids.size(); ++i )
345 bool valueChanged = this->GetImpl()->SetImprintedFaces(ids);
347 SMESH::TPythonDump() << _this() << ".SetImprintedFaces( "<< theVal << " )";
350 //=============================================================================
352 * HexoticPlugin_Hypothesis_i::GetHexesMinLevel
353 * HexoticPlugin_Hypothesis_i::GetHexesMaxLevel
354 * HexoticPlugin_Hypothesis_i::GetMinSize
355 * HexoticPlugin_Hypothesis_i::GetMaxSize
356 * HexoticPlugin_Hypothesis_i::GetHexoticIgnoreRidges
357 * HexoticPlugin_Hypothesis_i::GetHexoticInvalidElements
358 * HexoticPlugin_Hypothesis_i::GetHexoticSharpAngleThreshold
359 * HexoticPlugin_Hypothesis_i::GetHexoticNbProc
360 * HexoticPlugin_Hypothesis_i::GetHexoticWorkingDirectory
361 * HexoticPlugin_Hypothesis_i::GetHexoticSdMode
362 * HexoticPlugin_Hypothesis_i::GetVerbosity
363 * HexoticPlugin_Hypothesis_i::GetHexoticMaxMemory
364 * HexoticPlugin_Hypothesis_i::GetTextOptions
365 * HexoticPlugin_Hypothesis_i::GetNbLayers
366 * HexoticPlugin_Hypothesis_i::GetFirstLayerSize
367 * HexoticPlugin_Hypothesis_i::GetDirection
368 * HexoticPlugin_Hypothesis_i::GetGrowth
369 * HexoticPlugin_Hypothesis_i::GetFacesWithLayers
370 * HexoticPlugin_Hypothesis_i::GetImprintedFaces
372 //=============================================================================
374 CORBA::Long HexoticPlugin_Hypothesis_i::GetHexesMinLevel()
376 // MESSAGE("HexoticPlugin_Hypothesis_i::GetHexesMinLevel");
378 return this->GetImpl()->GetHexesMinLevel();
381 CORBA::Long HexoticPlugin_Hypothesis_i::GetHexesMaxLevel()
383 // MESSAGE("HexoticPlugin_Hypothesis_i::GetHexesMaxLevel");
385 return this->GetImpl()->GetHexesMaxLevel();
388 CORBA::Double HexoticPlugin_Hypothesis_i::GetMinSize()
390 // MESSAGE("HexoticPlugin_Hypothesis_i::GetMinSize");
392 return this->GetImpl()->GetMinSize();
395 CORBA::Double HexoticPlugin_Hypothesis_i::GetMaxSize()
397 // MESSAGE("HexoticPlugin_Hypothesis_i::GetMaxSize");
399 return this->GetImpl()->GetMaxSize();
402 CORBA::Boolean HexoticPlugin_Hypothesis_i::GetHexoticIgnoreRidges()
404 // MESSAGE("HexoticPlugin_Hypothesis_i::GetHexoticIgnoreRidges");
406 return this->GetImpl()->GetHexoticIgnoreRidges();
409 CORBA::Boolean HexoticPlugin_Hypothesis_i::GetHexoticInvalidElements()
411 // MESSAGE("HexoticPlugin_Hypothesis_i::GetHexoticInvalidElements");
413 return this->GetImpl()->GetHexoticInvalidElements();
416 CORBA::Double HexoticPlugin_Hypothesis_i::GetHexoticSharpAngleThreshold()
418 // MESSAGE("HexoticPlugin_Hypothesis_i::GetHexoticSharpAngleThreshold");
420 return this->GetImpl()->GetHexoticSharpAngleThreshold();
423 CORBA::Long HexoticPlugin_Hypothesis_i::GetHexoticNbProc()
425 // MESSAGE("HexoticPlugin_Hypothesis_i::GetHexoticNbProc");
427 return this->GetImpl()->GetHexoticNbProc();
430 char* HexoticPlugin_Hypothesis_i::GetHexoticWorkingDirectory()
433 return CORBA::string_dup( this->GetImpl()->GetHexoticWorkingDirectory().c_str() );
436 CORBA::Long HexoticPlugin_Hypothesis_i::GetHexoticSdMode ()
438 // MESSAGE("HexoticPlugin_Hypothesis_i::GetHexoticSdMode");
440 return this->GetImpl()->GetHexoticSdMode();
443 CORBA::Long HexoticPlugin_Hypothesis_i::GetHexoticVerbosity()
445 // MESSAGE("HexoticPlugin_Hypothesis_i::GetVerbosity");
447 return this->GetImpl()->GetHexoticVerbosity();
450 CORBA::Long HexoticPlugin_Hypothesis_i::GetHexoticMaxMemory()
452 // MESSAGE("HexoticPlugin_Hypothesis_i::GetHexoticMaxMemory");
454 return this->GetImpl()->GetHexoticMaxMemory();
457 char* HexoticPlugin_Hypothesis_i::GetTextOptions()
459 // MESSAGE("HexoticPlugin_Hypothesis_i::GetTextOptions");
461 return CORBA::string_dup( this->GetImpl()->GetTextOptions().c_str() );
464 CORBA::Long HexoticPlugin_Hypothesis_i::GetNbLayers()
466 // MESSAGE("HexoticPlugin_Hypothesis_i::GetNbLayers");
468 return this->GetImpl()->GetNbLayers();
471 CORBA::Double HexoticPlugin_Hypothesis_i::GetFirstLayerSize()
473 // MESSAGE("HexoticPlugin_Hypothesis_i::GetFirstLayerSize");
475 return this->GetImpl()->GetFirstLayerSize();
478 CORBA::Boolean HexoticPlugin_Hypothesis_i::GetDirection()
480 // MESSAGE("HexoticPlugin_Hypothesis_i::GetDirection");
482 return this->GetImpl()->GetDirection();
485 CORBA::Double HexoticPlugin_Hypothesis_i::GetGrowth()
487 // MESSAGE("HexoticPlugin_Hypothesis_i::GetGrowth");
489 return this->GetImpl()->GetGrowth();
492 SMESH::long_array* HexoticPlugin_Hypothesis_i::GetFacesWithLayers()
494 // MESSAGE("HexoticPlugin_Hypothesis_i::GetFacesWithLayers");
496 std::vector<int> idsVec = this->GetImpl()->GetFacesWithLayers();
497 SMESH::long_array_var ids = new SMESH::long_array;
498 ids->length( idsVec.size() );
499 for ( unsigned i = 0; i < idsVec.size(); ++i )
504 SMESH::long_array* HexoticPlugin_Hypothesis_i::GetImprintedFaces()
506 // MESSAGE("HexoticPlugin_Hypothesis_i::GetImprintedFaces");
508 std::vector<int> idsVec = this->GetImpl()->GetImprintedFaces();
509 SMESH::long_array_var ids = new SMESH::long_array;
510 ids->length( idsVec.size() );
511 for ( unsigned i = 0; i < idsVec.size(); ++i )
515 //=============================================================================
517 * HexoticPlugin_Hypothesis_i::GetImpl
521 //=============================================================================
522 ::HexoticPlugin_Hypothesis* HexoticPlugin_Hypothesis_i::GetImpl()
524 // MESSAGE("HexoticPlugin_Hypothesis_i::GetImpl");
525 return (::HexoticPlugin_Hypothesis*)myBaseImpl;
528 //================================================================================
530 * \brief Verify whether hypothesis supports given entity type
531 * \param type - dimension (see SMESH::Dimension enumeration)
532 * \retval CORBA::Boolean - TRUE if dimension is supported, FALSE otherwise
534 * Verify whether hypothesis supports given entity type (see SMESH::Dimension enumeration)
536 //================================================================================
537 CORBA::Boolean HexoticPlugin_Hypothesis_i::IsDimSupported( SMESH::Dimension type )
539 return type == SMESH::DIM_3D;