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 std::string anEntry = theEntry;
241 bool valueChanged = this->GetImpl()->AddSizeMap(theEntry, theSize);
242 MESSAGE("valueChanged = "<<valueChanged);
244 SMESH::TPythonDump() << _this() << ".SetSizeMap( "<< theEntry << ", " << theSize << " )";
247 void HexoticPlugin_Hypothesis_i::SetSizeMap (const GEOM::GEOM_Object_ptr theGeomObj, const double theSize)
249 MESSAGE("HexoticPlugin_Hypothesis_i::SetSizeMap");
251 std::string entry = theGeomObj->GetStudyEntry();
252 SetSizeMapEntry( entry.c_str(), theSize);
255 void HexoticPlugin_Hypothesis_i::ClearSizeMaps ()
257 this->GetImpl()->ClearSizeMaps();
258 SMESH::TPythonDump() << _this() << ".ClearSizeMaps()";
261 //=============================================================================
263 * HexoticPlugin_Hypothesis_i::GetHexesMinLevel
264 * HexoticPlugin_Hypothesis_i::GetHexesMaxLevel
265 * HexoticPlugin_Hypothesis_i::GetMinSize
266 * HexoticPlugin_Hypothesis_i::GetMaxSize
267 * HexoticPlugin_Hypothesis_i::GetHexoticIgnoreRidges
268 * HexoticPlugin_Hypothesis_i::GetHexoticInvalidElements
269 * HexoticPlugin_Hypothesis_i::GetHexoticSharpAngleThreshold
270 * HexoticPlugin_Hypothesis_i::GetHexoticNbProc
271 * HexoticPlugin_Hypothesis_i::GetHexoticWorkingDirectory
272 * HexoticPlugin_Hypothesis_i::GetHexoticSdMode
273 * HexoticPlugin_Hypothesis_i::GetVerbosity
274 * HexoticPlugin_Hypothesis_i::GetHexoticMaxMemory
276 //=============================================================================
278 CORBA::Long HexoticPlugin_Hypothesis_i::GetHexesMinLevel()
280 // MESSAGE("HexoticPlugin_Hypothesis_i::GetHexesMinLevel");
282 return this->GetImpl()->GetHexesMinLevel();
285 CORBA::Long HexoticPlugin_Hypothesis_i::GetHexesMaxLevel()
287 // MESSAGE("HexoticPlugin_Hypothesis_i::GetHexesMaxLevel");
289 return this->GetImpl()->GetHexesMaxLevel();
292 CORBA::Double HexoticPlugin_Hypothesis_i::GetMinSize()
294 // MESSAGE("HexoticPlugin_Hypothesis_i::GetMinSize");
296 return this->GetImpl()->GetMinSize();
299 CORBA::Double HexoticPlugin_Hypothesis_i::GetMaxSize()
301 // MESSAGE("HexoticPlugin_Hypothesis_i::GetMaxSize");
303 return this->GetImpl()->GetMaxSize();
306 CORBA::Boolean HexoticPlugin_Hypothesis_i::GetHexoticIgnoreRidges()
308 // MESSAGE("HexoticPlugin_Hypothesis_i::GetHexoticIgnoreRidges");
310 return this->GetImpl()->GetHexoticIgnoreRidges();
313 CORBA::Boolean HexoticPlugin_Hypothesis_i::GetHexoticInvalidElements()
315 // MESSAGE("HexoticPlugin_Hypothesis_i::GetHexoticInvalidElements");
317 return this->GetImpl()->GetHexoticInvalidElements();
320 CORBA::Double HexoticPlugin_Hypothesis_i::GetHexoticSharpAngleThreshold()
322 // MESSAGE("HexoticPlugin_Hypothesis_i::GetHexoticSharpAngleThreshold");
324 return this->GetImpl()->GetHexoticSharpAngleThreshold();
327 CORBA::Long HexoticPlugin_Hypothesis_i::GetHexoticNbProc()
329 // MESSAGE("HexoticPlugin_Hypothesis_i::GetHexoticNbProc");
331 return this->GetImpl()->GetHexoticNbProc();
334 char* HexoticPlugin_Hypothesis_i::GetHexoticWorkingDirectory()
337 return CORBA::string_dup( this->GetImpl()->GetHexoticWorkingDirectory().c_str() );
340 CORBA::Long HexoticPlugin_Hypothesis_i::GetHexoticSdMode ()
342 // MESSAGE("HexoticPlugin_Hypothesis_i::GetHexoticSdMode");
344 return this->GetImpl()->GetHexoticSdMode();
347 CORBA::Long HexoticPlugin_Hypothesis_i::GetHexoticVerbosity()
349 // MESSAGE("HexoticPlugin_Hypothesis_i::GetVerbosity");
351 return this->GetImpl()->GetHexoticVerbosity();
354 CORBA::Long HexoticPlugin_Hypothesis_i::GetHexoticMaxMemory()
356 // MESSAGE("HexoticPlugin_Hypothesis_i::GetHexoticMaxMemory");
358 return this->GetImpl()->GetHexoticMaxMemory();
361 //=============================================================================
363 * HexoticPlugin_Hypothesis_i::GetImpl
367 //=============================================================================
368 ::HexoticPlugin_Hypothesis* HexoticPlugin_Hypothesis_i::GetImpl()
370 // MESSAGE("HexoticPlugin_Hypothesis_i::GetImpl");
371 return (::HexoticPlugin_Hypothesis*)myBaseImpl;
374 //================================================================================
376 * \brief Verify whether hypothesis supports given entity type
377 * \param type - dimension (see SMESH::Dimension enumeration)
378 * \retval CORBA::Boolean - TRUE if dimension is supported, FALSE otherwise
380 * Verify whether hypothesis supports given entity type (see SMESH::Dimension enumeration)
382 //================================================================================
383 CORBA::Boolean HexoticPlugin_Hypothesis_i::IsDimSupported( SMESH::Dimension type )
385 return type == SMESH::DIM_3D;