1 // Copyright (C) 2007-2013 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
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
80 //=============================================================================
82 void HexoticPlugin_Hypothesis_i::SetHexesMinLevel (CORBA::Long theValue)
84 // MESSAGE("HexoticPlugin_Hypothesis_i::SetHexesMinLevel");
86 CORBA::Long oldValue = GetHexesMinLevel();
87 this->GetImpl()->SetHexesMinLevel(theValue);
88 if (theValue != oldValue)
89 SMESH::TPythonDump() << _this() << ".SetHexesMinLevel( " << theValue << " )";
92 void HexoticPlugin_Hypothesis_i::SetHexesMaxLevel (CORBA::Long theValue)
94 // MESSAGE("HexoticPlugin_Hypothesis_i::SetHexesMaxLevel");
96 CORBA::Long oldValue = GetHexesMaxLevel();
97 this->GetImpl()->SetHexesMaxLevel(theValue);
98 if (theValue != oldValue)
99 SMESH::TPythonDump() << _this() << ".SetHexesMaxLevel( " << theValue << " )";
102 void HexoticPlugin_Hypothesis_i::SetMinSize (CORBA::Double theValue)
104 // MESSAGE("HexoticPlugin_Hypothesis_i::SetHexesMaxLevel");
106 CORBA::Double oldValue = GetMinSize();
107 this->GetImpl()->SetMinSize(theValue);
108 if (theValue != oldValue)
109 SMESH::TPythonDump() << _this() << ".SetMinSize( " << theValue << " )";
112 void HexoticPlugin_Hypothesis_i::SetMaxSize (CORBA::Double theValue)
114 // MESSAGE("HexoticPlugin_Hypothesis_i::SetHexesMaxLevel");
116 CORBA::Double oldValue = GetMaxSize();
117 this->GetImpl()->SetMaxSize(theValue);
118 if (theValue != oldValue)
119 SMESH::TPythonDump() << _this() << ".SetMaxSize( " << theValue << " )";
122 void HexoticPlugin_Hypothesis_i::SetHexoticIgnoreRidges (CORBA::Boolean theValue)
124 // MESSAGE("HexoticPlugin_Hypothesis_i::SetHexoticIgnoreRidges");
126 CORBA::Boolean oldValue = GetHexoticIgnoreRidges();
127 this->GetImpl()->SetHexoticIgnoreRidges(theValue);
128 if (theValue != oldValue)
129 SMESH::TPythonDump() << _this() << ".SetHexoticIgnoreRidges( " << theValue << " )";
132 void HexoticPlugin_Hypothesis_i::SetHexoticInvalidElements (CORBA::Boolean theValue)
134 // MESSAGE("HexoticPlugin_Hypothesis_i::SetHexoticInvalidElements");
136 CORBA::Boolean oldValue = GetHexoticInvalidElements();
137 this->GetImpl()->SetHexoticInvalidElements(theValue);
138 if (theValue != oldValue)
139 SMESH::TPythonDump() << _this() << ".SetHexoticInvalidElements( " << theValue << " )";
142 void HexoticPlugin_Hypothesis_i::SetHexoticSharpAngleThreshold (CORBA::Double theValue)
144 // MESSAGE("HexoticPlugin_Hypothesis_i::SetHexoticSharpAngleThreshold");
146 CORBA::Double oldValue = GetHexoticSharpAngleThreshold();
147 this->GetImpl()->SetHexoticSharpAngleThreshold(theValue);
148 if (theValue != oldValue)
149 SMESH::TPythonDump() << _this() << ".SetHexoticSharpAngleThreshold( " << theValue << " )";
152 void HexoticPlugin_Hypothesis_i::SetHexoticNbProc (CORBA::Long theValue)
154 // MESSAGE("HexoticPlugin_Hypothesis_i::SetHexoticNbProc");
156 CORBA::Long oldValue = GetHexoticNbProc();
157 this->GetImpl()->SetHexoticNbProc(theValue);
158 if (theValue != oldValue)
159 SMESH::TPythonDump() << _this() << ".SetHexoticNbProc( " << theValue << " )";
162 void HexoticPlugin_Hypothesis_i::SetHexoticWorkingDirectory(const char* path) throw ( SALOME::SALOME_Exception )
165 THROW_SALOME_CORBA_EXCEPTION( "Null working directory",SALOME::BAD_PARAM );
169 string oldValue(GetHexoticWorkingDirectory());
171 if (oldValue != file)
174 const char lastChar = *file.rbegin();
176 if ( lastChar != '\\' ) file += '\\';
178 if ( lastChar != '/' ) file += '/';
180 file += "Hexotic_In.mesh";
181 SMESH_Mesh_i::PrepareForWriting (file.c_str());
183 this->GetImpl()->SetHexoticWorkingDirectory(path);
185 SMESH::TPythonDump() << _this() << ".SetHexoticWorkingDirectory( '" << path << "' )";
188 void HexoticPlugin_Hypothesis_i::SetHexoticSdMode (CORBA::Long theValue)
190 // MESSAGE("HexoticPlugin_Hypothesis_i::SetHexoticSdMode");
192 CORBA::Long oldValue = GetHexoticSdMode();
193 this->GetImpl()->SetHexoticSdMode(theValue);
194 if (theValue != oldValue)
195 SMESH::TPythonDump() << _this() << ".SetHexoticSdMode( " << theValue << " )";
198 void HexoticPlugin_Hypothesis_i::SetHexoticVerbosity (CORBA::Long theValue)
200 // MESSAGE("HexoticPlugin_Hypothesis_i::SetVerbosity");
202 CORBA::Long oldValue = GetHexoticVerbosity();
203 this->GetImpl()->SetHexoticVerbosity(theValue);
204 if (theValue != oldValue)
205 SMESH::TPythonDump() << _this() << ".SetHexoticVerbosity( " << theValue << " )";
208 void HexoticPlugin_Hypothesis_i::SetHexoticMaxMemory (CORBA::Long theValue)
210 // MESSAGE("HexoticPlugin_Hypothesis_i::SetHexoticMaxMemory");
212 CORBA::Long oldValue = GetHexoticMaxMemory();
213 this->GetImpl()->SetHexoticMaxMemory(theValue);
214 if (theValue != oldValue)
215 SMESH::TPythonDump() << _this() << ".SetHexoticMaxMemory( " << theValue << " )";
218 HexoticPlugin::HexoticPluginSizeMapsList* HexoticPlugin_Hypothesis_i::GetSizeMaps ()
220 // Get the std::map < string entry, double size >
221 HexoticPlugin::HexoticPluginSizeMapsList_var result = new HexoticPlugin::HexoticPluginSizeMapsList();
222 const ::HexoticPlugin_Hypothesis::THexoticSizeMaps sizeMaps = this->GetImpl()->GetSizeMaps();
223 result->length( sizeMaps.size() );
225 // Write the content into a CORBA sequence of struct{ entry=anEntry; size=aSize; }
226 ::HexoticPlugin_Hypothesis::THexoticSizeMaps::const_iterator it = sizeMaps.begin();
227 for ( int i = 0; it != sizeMaps.end(); i++, it++ )
229 HexoticPlugin::HexoticPluginSizeMap_var aSizeMap = new HexoticPlugin::HexoticPluginSizeMap();
230 aSizeMap->entry = CORBA::string_dup( it->first.c_str() );
231 aSizeMap->size = it->second;
232 result[i] = aSizeMap;
234 return result._retn();
237 void HexoticPlugin_Hypothesis_i::SetSizeMapEntry ( const char* theEntry, CORBA::Double theSize )
239 // MESSAGE("HexoticPlugin_Hypothesis_i::SetSizeMapEntry");
240 bool valueChanged = this->GetImpl()->AddSizeMap(theEntry, theSize);
242 SMESH::TPythonDump() << _this() << ".SetSizeMap( "<< theEntry << ", " << theSize << " )";
245 void HexoticPlugin_Hypothesis_i::UnsetSizeMapEntry ( const char* theEntry )
247 // MESSAGE("HexoticPlugin_Hypothesis_i::UnsetSizeMapEntry");
248 bool entryRemoved = this->GetImpl()->UnsetSizeMap(theEntry);
250 SMESH::TPythonDump() << _this() << ".UnsetSizeMap( "<< theEntry << " )";
253 void HexoticPlugin_Hypothesis_i::SetSizeMap (const GEOM::GEOM_Object_ptr theGeomObj, const double theSize)
255 // MESSAGE("HexoticPlugin_Hypothesis_i::SetSizeMap");
257 std::string entry = theGeomObj->GetStudyEntry();
258 SetSizeMapEntry( entry.c_str(), theSize);
261 void HexoticPlugin_Hypothesis_i::UnsetSizeMap (const GEOM::GEOM_Object_ptr theGeomObj)
263 // MESSAGE("HexoticPlugin_Hypothesis_i::UnsetSizeMap");
265 std::string entry = theGeomObj->GetStudyEntry();
266 UnsetSizeMapEntry( entry.c_str());
269 //=============================================================================
271 * HexoticPlugin_Hypothesis_i::GetHexesMinLevel
272 * HexoticPlugin_Hypothesis_i::GetHexesMaxLevel
273 * HexoticPlugin_Hypothesis_i::GetMinSize
274 * HexoticPlugin_Hypothesis_i::GetMaxSize
275 * HexoticPlugin_Hypothesis_i::GetHexoticIgnoreRidges
276 * HexoticPlugin_Hypothesis_i::GetHexoticInvalidElements
277 * HexoticPlugin_Hypothesis_i::GetHexoticSharpAngleThreshold
278 * HexoticPlugin_Hypothesis_i::GetHexoticNbProc
279 * HexoticPlugin_Hypothesis_i::GetHexoticWorkingDirectory
280 * HexoticPlugin_Hypothesis_i::GetHexoticSdMode
281 * HexoticPlugin_Hypothesis_i::GetVerbosity
282 * HexoticPlugin_Hypothesis_i::GetHexoticMaxMemory
284 //=============================================================================
286 CORBA::Long HexoticPlugin_Hypothesis_i::GetHexesMinLevel()
288 // MESSAGE("HexoticPlugin_Hypothesis_i::GetHexesMinLevel");
290 return this->GetImpl()->GetHexesMinLevel();
293 CORBA::Long HexoticPlugin_Hypothesis_i::GetHexesMaxLevel()
295 // MESSAGE("HexoticPlugin_Hypothesis_i::GetHexesMaxLevel");
297 return this->GetImpl()->GetHexesMaxLevel();
300 CORBA::Double HexoticPlugin_Hypothesis_i::GetMinSize()
302 // MESSAGE("HexoticPlugin_Hypothesis_i::GetMinSize");
304 return this->GetImpl()->GetMinSize();
307 CORBA::Double HexoticPlugin_Hypothesis_i::GetMaxSize()
309 // MESSAGE("HexoticPlugin_Hypothesis_i::GetMaxSize");
311 return this->GetImpl()->GetMaxSize();
314 CORBA::Boolean HexoticPlugin_Hypothesis_i::GetHexoticIgnoreRidges()
316 // MESSAGE("HexoticPlugin_Hypothesis_i::GetHexoticIgnoreRidges");
318 return this->GetImpl()->GetHexoticIgnoreRidges();
321 CORBA::Boolean HexoticPlugin_Hypothesis_i::GetHexoticInvalidElements()
323 // MESSAGE("HexoticPlugin_Hypothesis_i::GetHexoticInvalidElements");
325 return this->GetImpl()->GetHexoticInvalidElements();
328 CORBA::Double HexoticPlugin_Hypothesis_i::GetHexoticSharpAngleThreshold()
330 // MESSAGE("HexoticPlugin_Hypothesis_i::GetHexoticSharpAngleThreshold");
332 return this->GetImpl()->GetHexoticSharpAngleThreshold();
335 CORBA::Long HexoticPlugin_Hypothesis_i::GetHexoticNbProc()
337 // MESSAGE("HexoticPlugin_Hypothesis_i::GetHexoticNbProc");
339 return this->GetImpl()->GetHexoticNbProc();
342 char* HexoticPlugin_Hypothesis_i::GetHexoticWorkingDirectory()
345 return CORBA::string_dup( this->GetImpl()->GetHexoticWorkingDirectory().c_str() );
348 CORBA::Long HexoticPlugin_Hypothesis_i::GetHexoticSdMode ()
350 // MESSAGE("HexoticPlugin_Hypothesis_i::GetHexoticSdMode");
352 return this->GetImpl()->GetHexoticSdMode();
355 CORBA::Long HexoticPlugin_Hypothesis_i::GetHexoticVerbosity()
357 // MESSAGE("HexoticPlugin_Hypothesis_i::GetVerbosity");
359 return this->GetImpl()->GetHexoticVerbosity();
362 CORBA::Long HexoticPlugin_Hypothesis_i::GetHexoticMaxMemory()
364 // MESSAGE("HexoticPlugin_Hypothesis_i::GetHexoticMaxMemory");
366 return this->GetImpl()->GetHexoticMaxMemory();
369 //=============================================================================
371 * HexoticPlugin_Hypothesis_i::GetImpl
375 //=============================================================================
376 ::HexoticPlugin_Hypothesis* HexoticPlugin_Hypothesis_i::GetImpl()
378 // MESSAGE("HexoticPlugin_Hypothesis_i::GetImpl");
379 return (::HexoticPlugin_Hypothesis*)myBaseImpl;
382 //================================================================================
384 * \brief Verify whether hypothesis supports given entity type
385 * \param type - dimension (see SMESH::Dimension enumeration)
386 * \retval CORBA::Boolean - TRUE if dimension is supported, FALSE otherwise
388 * Verify whether hypothesis supports given entity type (see SMESH::Dimension enumeration)
390 //================================================================================
391 CORBA::Boolean HexoticPlugin_Hypothesis_i::IsDimSupported( SMESH::Dimension type )
393 return type == SMESH::DIM_3D;