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,
42 ::SMESH_Gen* theGenImpl)
43 : SALOME::GenericObj_i( thePOA ),
44 SMESH_Hypothesis_i( thePOA )
46 MESSAGE( "HexoticPlugin_Hypothesis_i::HexoticPlugin_Hypothesis_i" );
47 myBaseImpl = new ::HexoticPlugin_Hypothesis (theGenImpl->GetANewId(),
51 //=============================================================================
53 * HexoticPlugin_Hypothesis_i::~HexoticPlugin_Hypothesis_i
57 //=============================================================================
58 HexoticPlugin_Hypothesis_i::~HexoticPlugin_Hypothesis_i()
60 MESSAGE( "HexoticPlugin_Hypothesis_i::~HexoticPlugin_Hypothesis_i" );
63 //=============================================================================
65 * HexoticPlugin_Hypothesis_i::SetHexesMinLevel
66 * HexoticPlugin_Hypothesis_i::SetHexesMaxLevel
67 * HexoticPlugin_Hypothesis_i::SetMinSize
68 * HexoticPlugin_Hypothesis_i::SetMaxSize
69 * HexoticPlugin_Hypothesis_i::SetHexoticIgnoreRidges
70 * HexoticPlugin_Hypothesis_i::SetHexoticInvalidElements
71 * HexoticPlugin_Hypothesis_i::SetHexoticSharpAngleThreshold
72 * HexoticPlugin_Hypothesis_i::SetHexoticNbProc
73 * HexoticPlugin_Hypothesis_i::SetHexoticWorkingDirectory
74 * HexoticPlugin_Hypothesis_i::SetHexoticSdMode
75 * HexoticPlugin_Hypothesis_i::SetVerbosity
76 * HexoticPlugin_Hypothesis_i::SetHexoticMaxMemory
77 * HexoticPlugin_Hypothesis_i::SetTextOptions
78 * HexoticPlugin_Hypothesis_i::SetNbLayers
79 * HexoticPlugin_Hypothesis_i::SetFirstLayerSize
80 * HexoticPlugin_Hypothesis_i::SetDirection
81 * HexoticPlugin_Hypothesis_i::SetGrowth
82 * HexoticPlugin_Hypothesis_i::SetFacesWithLayers
83 * HexoticPlugin_Hypothesis_i::SetImprintedFaces
85 //=============================================================================
87 void HexoticPlugin_Hypothesis_i::SetHexesMinLevel (CORBA::Long theValue)
89 // MESSAGE("HexoticPlugin_Hypothesis_i::SetHexesMinLevel");
91 CORBA::Long oldValue = GetHexesMinLevel();
92 this->GetImpl()->SetHexesMinLevel(theValue);
93 if (theValue != oldValue)
94 SMESH::TPythonDump() << _this() << ".SetHexesMinLevel( " << theValue << " )";
97 void HexoticPlugin_Hypothesis_i::SetHexesMaxLevel (CORBA::Long theValue)
99 // MESSAGE("HexoticPlugin_Hypothesis_i::SetHexesMaxLevel");
101 CORBA::Long oldValue = GetHexesMaxLevel();
102 this->GetImpl()->SetHexesMaxLevel(theValue);
103 if (theValue != oldValue)
104 SMESH::TPythonDump() << _this() << ".SetHexesMaxLevel( " << theValue << " )";
107 void HexoticPlugin_Hypothesis_i::SetMinSize (CORBA::Double theValue)
109 // MESSAGE("HexoticPlugin_Hypothesis_i::SetHexesMaxLevel");
111 CORBA::Double oldValue = GetMinSize();
112 this->GetImpl()->SetMinSize(theValue);
113 if (theValue != oldValue)
114 SMESH::TPythonDump() << _this() << ".SetMinSize( " << theValue << " )";
117 void HexoticPlugin_Hypothesis_i::SetMaxSize (CORBA::Double theValue)
119 // MESSAGE("HexoticPlugin_Hypothesis_i::SetHexesMaxLevel");
121 CORBA::Double oldValue = GetMaxSize();
122 this->GetImpl()->SetMaxSize(theValue);
123 if (theValue != oldValue)
124 SMESH::TPythonDump() << _this() << ".SetMaxSize( " << theValue << " )";
127 void HexoticPlugin_Hypothesis_i::SetHexoticIgnoreRidges (CORBA::Boolean theValue)
129 // MESSAGE("HexoticPlugin_Hypothesis_i::SetHexoticIgnoreRidges");
131 CORBA::Boolean oldValue = GetHexoticIgnoreRidges();
132 this->GetImpl()->SetHexoticIgnoreRidges(theValue);
133 if (theValue != oldValue)
134 SMESH::TPythonDump() << _this() << ".SetHexoticIgnoreRidges( " << theValue << " )";
137 void HexoticPlugin_Hypothesis_i::SetHexoticInvalidElements (CORBA::Boolean theValue)
139 // MESSAGE("HexoticPlugin_Hypothesis_i::SetHexoticInvalidElements");
141 CORBA::Boolean oldValue = GetHexoticInvalidElements();
142 this->GetImpl()->SetHexoticInvalidElements(theValue);
143 if (theValue != oldValue)
144 SMESH::TPythonDump() << _this() << ".SetHexoticInvalidElements( " << theValue << " )";
147 void HexoticPlugin_Hypothesis_i::SetHexoticSharpAngleThreshold (CORBA::Double theValue)
149 // MESSAGE("HexoticPlugin_Hypothesis_i::SetHexoticSharpAngleThreshold");
151 CORBA::Double oldValue = GetHexoticSharpAngleThreshold();
152 this->GetImpl()->SetHexoticSharpAngleThreshold(theValue);
153 if (theValue != oldValue)
154 SMESH::TPythonDump() << _this() << ".SetHexoticSharpAngleThreshold( " << theValue << " )";
157 void HexoticPlugin_Hypothesis_i::SetHexoticNbProc (CORBA::Long theValue)
159 // MESSAGE("HexoticPlugin_Hypothesis_i::SetHexoticNbProc");
161 CORBA::Long oldValue = GetHexoticNbProc();
162 this->GetImpl()->SetHexoticNbProc(theValue);
163 if (theValue != oldValue)
164 SMESH::TPythonDump() << _this() << ".SetHexoticNbProc( " << theValue << " )";
167 void HexoticPlugin_Hypothesis_i::SetHexoticWorkingDirectory(const char* path) throw ( SALOME::SALOME_Exception )
170 THROW_SALOME_CORBA_EXCEPTION( "Null working directory",SALOME::BAD_PARAM );
173 std::string file(path);
174 std::string oldValue(GetHexoticWorkingDirectory());
176 if (oldValue != file)
179 const char lastChar = *file.rbegin();
181 if ( lastChar != '\\' ) file += '\\';
183 if ( lastChar != '/' ) file += '/';
185 file += "Hexotic_In.mesh";
186 SMESH_Mesh_i::PrepareForWriting (file.c_str());
188 this->GetImpl()->SetHexoticWorkingDirectory(path);
190 SMESH::TPythonDump() << _this() << ".SetHexoticWorkingDirectory( '" << path << "' )";
193 void HexoticPlugin_Hypothesis_i::SetHexoticSdMode (CORBA::Long theValue)
195 // MESSAGE("HexoticPlugin_Hypothesis_i::SetHexoticSdMode");
197 CORBA::Long oldValue = GetHexoticSdMode();
198 this->GetImpl()->SetHexoticSdMode(theValue);
199 if (theValue != oldValue)
200 SMESH::TPythonDump() << _this() << ".SetHexoticSdMode( " << theValue << " )";
203 void HexoticPlugin_Hypothesis_i::SetHexoticVerbosity (CORBA::Long theValue)
205 // MESSAGE("HexoticPlugin_Hypothesis_i::SetVerbosity");
207 CORBA::Long oldValue = GetHexoticVerbosity();
208 this->GetImpl()->SetHexoticVerbosity(theValue);
209 if (theValue != oldValue)
210 SMESH::TPythonDump() << _this() << ".SetHexoticVerbosity( " << theValue << " )";
213 void HexoticPlugin_Hypothesis_i::SetHexoticMaxMemory (CORBA::Long theValue)
215 // MESSAGE("HexoticPlugin_Hypothesis_i::SetHexoticMaxMemory");
217 CORBA::Long oldValue = GetHexoticMaxMemory();
218 this->GetImpl()->SetHexoticMaxMemory(theValue);
219 if (theValue != oldValue)
220 SMESH::TPythonDump() << _this() << ".SetHexoticMaxMemory( " << theValue << " )";
223 void HexoticPlugin_Hypothesis_i::SetTextOptions(const char* theOptions)
225 // MESSAGE("HexoticPlugin_Hypothesis_i::SetTextOptions");
227 std::string oldValue(GetAdvancedOption());
228 this->GetImpl()->SetAdvancedOption(theOptions);
229 if (theOptions != oldValue)
230 SMESH::TPythonDump() << _this() << ".SetAdvancedOption( '" << theOptions << "' )";
233 void HexoticPlugin_Hypothesis_i::SetAdvancedOption(const char* theOptions)
235 // MESSAGE("HexoticPlugin_Hypothesis_i::SetAdvancedOption");
237 std::string oldValue(GetAdvancedOption());
238 this->GetImpl()->SetAdvancedOption(theOptions);
239 if (theOptions != oldValue)
240 SMESH::TPythonDump() << _this() << ".SetAdvancedOption( '" << theOptions << "' )";
243 HexoticPlugin::HexoticPluginSizeMapsList* HexoticPlugin_Hypothesis_i::GetSizeMaps ()
245 // Get the std::map < std::string entry, double size >
246 HexoticPlugin::HexoticPluginSizeMapsList_var result = new HexoticPlugin::HexoticPluginSizeMapsList();
247 const ::HexoticPlugin_Hypothesis::THexoticSizeMaps sizeMaps = this->GetImpl()->GetSizeMaps();
248 result->length( sizeMaps.size() );
250 // Write the content into a CORBA sequence of struct{ entry=anEntry; size=aSize; }
251 ::HexoticPlugin_Hypothesis::THexoticSizeMaps::const_iterator it = sizeMaps.begin();
252 for ( int i = 0; it != sizeMaps.end(); i++, it++ )
254 HexoticPlugin::HexoticPluginSizeMap_var aSizeMap = new HexoticPlugin::HexoticPluginSizeMap();
255 aSizeMap->entry = CORBA::string_dup( it->first.c_str() );
256 aSizeMap->size = it->second;
257 result[i] = aSizeMap;
259 return result._retn();
262 void HexoticPlugin_Hypothesis_i::SetSizeMapEntry ( const char* theEntry, CORBA::Double theSize )
264 // MESSAGE("HexoticPlugin_Hypothesis_i::SetSizeMapEntry");
265 bool valueChanged = this->GetImpl()->AddSizeMap(theEntry, theSize);
267 SMESH::TPythonDump() << _this() << ".SetSizeMap( "<< theEntry << ", " << theSize << " )";
270 void HexoticPlugin_Hypothesis_i::UnsetSizeMapEntry ( const char* theEntry )
272 // MESSAGE("HexoticPlugin_Hypothesis_i::UnsetSizeMapEntry");
273 bool entryRemoved = this->GetImpl()->UnsetSizeMap(theEntry);
275 SMESH::TPythonDump() << _this() << ".UnsetSizeMap( "<< theEntry << " )";
278 void HexoticPlugin_Hypothesis_i::SetSizeMap (const GEOM::GEOM_Object_ptr theGeomObj, const double theSize)
280 // MESSAGE("HexoticPlugin_Hypothesis_i::SetSizeMap");
282 std::string entry = theGeomObj->GetStudyEntry();
283 SetSizeMapEntry( entry.c_str(), theSize);
286 void HexoticPlugin_Hypothesis_i::UnsetSizeMap (const GEOM::GEOM_Object_ptr theGeomObj)
288 // MESSAGE("HexoticPlugin_Hypothesis_i::UnsetSizeMap");
290 std::string entry = theGeomObj->GetStudyEntry();
291 UnsetSizeMapEntry( entry.c_str());
294 void HexoticPlugin_Hypothesis_i::SetNbLayers(CORBA::Long theVal)
296 // MESSAGE("HexoticPlugin_Hypothesis_i::SetNbLayers");
298 CORBA::Long oldValue = GetNbLayers();
299 this->GetImpl()->SetNbLayers(theVal);
300 if (theVal != oldValue)
301 SMESH::TPythonDump() << _this() << ".SetNbLayers( " << theVal << " )";
304 void HexoticPlugin_Hypothesis_i::SetFirstLayerSize(CORBA::Double theVal)
306 // MESSAGE("HexoticPlugin_Hypothesis_i::SetFirstLayerSize");
308 CORBA::Double oldValue = GetFirstLayerSize();
309 this->GetImpl()->SetFirstLayerSize(theVal);
310 if (theVal != oldValue)
311 SMESH::TPythonDump() << _this() << ".SetFirstLayerSize( " << theVal << " )";
314 void HexoticPlugin_Hypothesis_i::SetDirection(CORBA::Boolean theVal)
316 // MESSAGE("HexoticPlugin_Hypothesis_i::SetDirection");
318 CORBA::Boolean oldValue = GetDirection();
319 this->GetImpl()->SetDirection(theVal);
320 if (theVal != oldValue)
321 SMESH::TPythonDump() << _this() << ".SetDirection( " << theVal << " )";
324 void HexoticPlugin_Hypothesis_i::SetGrowth(CORBA::Double theVal)
326 // MESSAGE("HexoticPlugin_Hypothesis_i::SetGrowth");
328 CORBA::Double oldValue = GetGrowth();
329 this->GetImpl()->SetGrowth(theVal);
330 if (theVal != oldValue)
331 SMESH::TPythonDump() << _this() << ".SetGrowth( " << theVal << " )";
334 void HexoticPlugin_Hypothesis_i::SetFacesWithLayers(const ::SMESH::long_array& theVal)
336 // MESSAGE("HexoticPlugin_Hypothesis_i::SetFacesWithLayers");
337 std::vector<int> ids( theVal.length() );
338 for ( unsigned i = 0; i < ids.size(); ++i )
341 bool valueChanged = this->GetImpl()->SetFacesWithLayers(ids);
343 SMESH::TPythonDump() << _this() << ".SetFacesWithLayers( "<< theVal << " )";
346 void HexoticPlugin_Hypothesis_i::SetImprintedFaces(const ::SMESH::long_array& theVal)
348 // MESSAGE("HexoticPlugin_Hypothesis_i::SetImprintedFaces");
349 std::vector<int> ids( theVal.length() );
350 for ( unsigned i = 0; i < ids.size(); ++i )
353 bool valueChanged = this->GetImpl()->SetImprintedFaces(ids);
355 SMESH::TPythonDump() << _this() << ".SetImprintedFaces( "<< theVal << " )";
358 //=============================================================================
360 * HexoticPlugin_Hypothesis_i::GetHexesMinLevel
361 * HexoticPlugin_Hypothesis_i::GetHexesMaxLevel
362 * HexoticPlugin_Hypothesis_i::GetMinSize
363 * HexoticPlugin_Hypothesis_i::GetMaxSize
364 * HexoticPlugin_Hypothesis_i::GetHexoticIgnoreRidges
365 * HexoticPlugin_Hypothesis_i::GetHexoticInvalidElements
366 * HexoticPlugin_Hypothesis_i::GetHexoticSharpAngleThreshold
367 * HexoticPlugin_Hypothesis_i::GetHexoticNbProc
368 * HexoticPlugin_Hypothesis_i::GetHexoticWorkingDirectory
369 * HexoticPlugin_Hypothesis_i::GetHexoticSdMode
370 * HexoticPlugin_Hypothesis_i::GetVerbosity
371 * HexoticPlugin_Hypothesis_i::GetHexoticMaxMemory
372 * HexoticPlugin_Hypothesis_i::GetTextOptions
373 * HexoticPlugin_Hypothesis_i::GetNbLayers
374 * HexoticPlugin_Hypothesis_i::GetFirstLayerSize
375 * HexoticPlugin_Hypothesis_i::GetDirection
376 * HexoticPlugin_Hypothesis_i::GetGrowth
377 * HexoticPlugin_Hypothesis_i::GetFacesWithLayers
378 * HexoticPlugin_Hypothesis_i::GetImprintedFaces
380 //=============================================================================
382 CORBA::Long HexoticPlugin_Hypothesis_i::GetHexesMinLevel()
384 // MESSAGE("HexoticPlugin_Hypothesis_i::GetHexesMinLevel");
386 return this->GetImpl()->GetHexesMinLevel();
389 CORBA::Long HexoticPlugin_Hypothesis_i::GetHexesMaxLevel()
391 // MESSAGE("HexoticPlugin_Hypothesis_i::GetHexesMaxLevel");
393 return this->GetImpl()->GetHexesMaxLevel();
396 CORBA::Double HexoticPlugin_Hypothesis_i::GetMinSize()
398 // MESSAGE("HexoticPlugin_Hypothesis_i::GetMinSize");
400 return this->GetImpl()->GetMinSize();
403 CORBA::Double HexoticPlugin_Hypothesis_i::GetMaxSize()
405 // MESSAGE("HexoticPlugin_Hypothesis_i::GetMaxSize");
407 return this->GetImpl()->GetMaxSize();
410 CORBA::Boolean HexoticPlugin_Hypothesis_i::GetHexoticIgnoreRidges()
412 // MESSAGE("HexoticPlugin_Hypothesis_i::GetHexoticIgnoreRidges");
414 return this->GetImpl()->GetHexoticIgnoreRidges();
417 CORBA::Boolean HexoticPlugin_Hypothesis_i::GetHexoticInvalidElements()
419 // MESSAGE("HexoticPlugin_Hypothesis_i::GetHexoticInvalidElements");
421 return this->GetImpl()->GetHexoticInvalidElements();
424 CORBA::Double HexoticPlugin_Hypothesis_i::GetHexoticSharpAngleThreshold()
426 // MESSAGE("HexoticPlugin_Hypothesis_i::GetHexoticSharpAngleThreshold");
428 return this->GetImpl()->GetHexoticSharpAngleThreshold();
431 CORBA::Long HexoticPlugin_Hypothesis_i::GetHexoticNbProc()
433 // MESSAGE("HexoticPlugin_Hypothesis_i::GetHexoticNbProc");
435 return this->GetImpl()->GetHexoticNbProc();
438 char* HexoticPlugin_Hypothesis_i::GetHexoticWorkingDirectory()
441 return CORBA::string_dup( this->GetImpl()->GetHexoticWorkingDirectory().c_str() );
444 CORBA::Long HexoticPlugin_Hypothesis_i::GetHexoticSdMode ()
446 // MESSAGE("HexoticPlugin_Hypothesis_i::GetHexoticSdMode");
448 return this->GetImpl()->GetHexoticSdMode();
451 CORBA::Long HexoticPlugin_Hypothesis_i::GetHexoticVerbosity()
453 // MESSAGE("HexoticPlugin_Hypothesis_i::GetVerbosity");
455 return this->GetImpl()->GetHexoticVerbosity();
458 CORBA::Long HexoticPlugin_Hypothesis_i::GetHexoticMaxMemory()
460 // MESSAGE("HexoticPlugin_Hypothesis_i::GetHexoticMaxMemory");
462 return this->GetImpl()->GetHexoticMaxMemory();
465 char* HexoticPlugin_Hypothesis_i::GetAdvancedOption()
467 // MESSAGE("HexoticPlugin_Hypothesis_i::GetAdvancedOption");
469 return CORBA::string_dup( this->GetImpl()->GetAdvancedOption().c_str() );
471 char* HexoticPlugin_Hypothesis_i::GetTextOptions()
473 // MESSAGE("HexoticPlugin_Hypothesis_i::GetTextOptions");
475 return CORBA::string_dup( this->GetImpl()->GetAdvancedOption().c_str() );
478 CORBA::Long HexoticPlugin_Hypothesis_i::GetNbLayers()
480 // MESSAGE("HexoticPlugin_Hypothesis_i::GetNbLayers");
482 return this->GetImpl()->GetNbLayers();
485 CORBA::Double HexoticPlugin_Hypothesis_i::GetFirstLayerSize()
487 // MESSAGE("HexoticPlugin_Hypothesis_i::GetFirstLayerSize");
489 return this->GetImpl()->GetFirstLayerSize();
492 CORBA::Boolean HexoticPlugin_Hypothesis_i::GetDirection()
494 // MESSAGE("HexoticPlugin_Hypothesis_i::GetDirection");
496 return this->GetImpl()->GetDirection();
499 CORBA::Double HexoticPlugin_Hypothesis_i::GetGrowth()
501 // MESSAGE("HexoticPlugin_Hypothesis_i::GetGrowth");
503 return this->GetImpl()->GetGrowth();
506 SMESH::long_array* HexoticPlugin_Hypothesis_i::GetFacesWithLayers()
508 // MESSAGE("HexoticPlugin_Hypothesis_i::GetFacesWithLayers");
510 std::vector<int> idsVec = this->GetImpl()->GetFacesWithLayers();
511 SMESH::long_array_var ids = new SMESH::long_array;
512 ids->length( idsVec.size() );
513 for ( unsigned i = 0; i < idsVec.size(); ++i )
518 SMESH::long_array* HexoticPlugin_Hypothesis_i::GetImprintedFaces()
520 // MESSAGE("HexoticPlugin_Hypothesis_i::GetImprintedFaces");
522 std::vector<int> idsVec = this->GetImpl()->GetImprintedFaces();
523 SMESH::long_array_var ids = new SMESH::long_array;
524 ids->length( idsVec.size() );
525 for ( unsigned i = 0; i < idsVec.size(); ++i )
529 //=============================================================================
531 * HexoticPlugin_Hypothesis_i::GetImpl
535 //=============================================================================
536 ::HexoticPlugin_Hypothesis* HexoticPlugin_Hypothesis_i::GetImpl()
538 // MESSAGE("HexoticPlugin_Hypothesis_i::GetImpl");
539 return (::HexoticPlugin_Hypothesis*)myBaseImpl;
542 //================================================================================
544 * \brief Verify whether hypothesis supports given entity type
545 * \param type - dimension (see SMESH::Dimension enumeration)
546 * \retval CORBA::Boolean - TRUE if dimension is supported, FALSE otherwise
548 * Verify whether hypothesis supports given entity type (see SMESH::Dimension enumeration)
550 //================================================================================
551 CORBA::Boolean HexoticPlugin_Hypothesis_i::IsDimSupported( SMESH::Dimension type )
553 return type == SMESH::DIM_3D;