]> SALOME platform Git repositories - plugins/ghs3dplugin.git/blob - src/GHS3DPlugin_Hypothesis_i.cxx
Salome HOME
PAL19680: Meshers: BLSURF, GHS3D and holed shapes
[plugins/ghs3dplugin.git] / src / GHS3DPlugin_Hypothesis_i.cxx
1 // File      : GHS3DPlugin_Hypothesis_i.cxx
2 // Created   : Wed Apr  2 13:53:01 2008
3 // Author    : Edward AGAPOV (eap)
4
5
6 #include "GHS3DPlugin_Hypothesis_i.hxx"
7
8 #include <SMESH_Gen.hxx>
9 #include <SMESH_PythonDump.hxx>
10
11 #include <Utils_CorbaException.hxx>
12 #include <utilities.h>
13 #include <SMESH_Mesh_i.hxx>
14
15 //=======================================================================
16 //function : GHS3DPlugin_Hypothesis_i
17 //=======================================================================
18
19 GHS3DPlugin_Hypothesis_i::GHS3DPlugin_Hypothesis_i (PortableServer::POA_ptr thePOA,
20                                                     int                     theStudyId,
21                                                     ::SMESH_Gen*            theGenImpl)
22   : SALOME::GenericObj_i( thePOA ), 
23     SMESH_Hypothesis_i( thePOA )
24 {
25   MESSAGE( "GHS3DPlugin_Hypothesis_i::GHS3DPlugin_Hypothesis_i" );
26   myBaseImpl = new ::GHS3DPlugin_Hypothesis (theGenImpl->GetANewId(),
27                                               theStudyId,
28                                               theGenImpl);
29 }
30
31 //=======================================================================
32 //function : ~GHS3DPlugin_Hypothesis_i
33 //=======================================================================
34
35 GHS3DPlugin_Hypothesis_i::~GHS3DPlugin_Hypothesis_i()
36 {
37   MESSAGE( "GHS3DPlugin_Hypothesis_i::~GHS3DPlugin_Hypothesis_i" );
38 }
39
40 //=======================================================================
41 //function : SetToMeshHoles
42 //=======================================================================
43
44 void GHS3DPlugin_Hypothesis_i::SetToMeshHoles(CORBA::Boolean toMesh)
45 {
46   ASSERT(myBaseImpl);
47   this->GetImpl()->SetToMeshHoles(toMesh);
48   SMESH::TPythonDump() << _this() << ".SetToMeshHoles( " << toMesh << " )";
49 }
50
51 //=======================================================================
52 //function : GetToMeshHoles
53 //=======================================================================
54
55 CORBA::Boolean GHS3DPlugin_Hypothesis_i::GetToMeshHoles()
56 {
57   ASSERT(myBaseImpl);
58   return this->GetImpl()->GetToMeshHoles();
59 }
60
61 //=======================================================================
62 //function : SetMaximumMemory
63 //=======================================================================
64
65 void GHS3DPlugin_Hypothesis_i::SetMaximumMemory(CORBA::Short MB)
66    throw ( SALOME::SALOME_Exception )
67 {
68   if ( MB == 0 )
69     THROW_SALOME_CORBA_EXCEPTION( "Invalid memory size",SALOME::BAD_PARAM );
70   ASSERT(myBaseImpl);
71   this->GetImpl()->SetMaximumMemory(MB);
72   SMESH::TPythonDump() << _this() << ".SetMaximumMemory( " << MB << " )";
73 }
74
75 //=======================================================================
76 //function : GetMaximumMemory
77 //=======================================================================
78
79 CORBA::Short GHS3DPlugin_Hypothesis_i::GetMaximumMemory()
80 {
81   ASSERT(myBaseImpl);
82   return this->GetImpl()->GetMaximumMemory();
83 }
84
85 //=======================================================================
86 //function : SetInitialMemory
87 //=======================================================================
88
89 void GHS3DPlugin_Hypothesis_i::SetInitialMemory(CORBA::Short MB)
90   throw ( SALOME::SALOME_Exception )
91 {
92   if ( MB == 0 )
93     THROW_SALOME_CORBA_EXCEPTION( "Invalid memory size",SALOME::BAD_PARAM );
94   ASSERT(myBaseImpl);
95   this->GetImpl()->SetInitialMemory(MB);
96   SMESH::TPythonDump() << _this() << ".SetInitialMemory( " << MB << " )";
97 }
98
99 //=======================================================================
100 //function : GetInitialMemory
101 //=======================================================================
102
103 CORBA::Short GHS3DPlugin_Hypothesis_i::GetInitialMemory()
104 {
105   ASSERT(myBaseImpl);
106   return this->GetImpl()->GetInitialMemory();
107 }
108
109 //=======================================================================
110 //function : SetOptimizationLevel
111 //=======================================================================
112
113 void GHS3DPlugin_Hypothesis_i::SetOptimizationLevel(CORBA::Short level)
114   throw ( SALOME::SALOME_Exception )
115 {
116   ::GHS3DPlugin_Hypothesis::OptimizationLevel l =
117       (::GHS3DPlugin_Hypothesis::OptimizationLevel) level;
118   if ( l < ::GHS3DPlugin_Hypothesis::None ||
119        l > ::GHS3DPlugin_Hypothesis::Strong )
120     THROW_SALOME_CORBA_EXCEPTION( "Invalid optimization level",SALOME::BAD_PARAM );
121     
122   ASSERT(myBaseImpl);
123   this->GetImpl()->SetOptimizationLevel(l);
124   SMESH::TPythonDump() << _this() << ".SetOptimizationLevel( " << level << " )";
125 }
126
127 //=======================================================================
128 //function : GetOptimizationLevel
129 //=======================================================================
130
131 CORBA::Short GHS3DPlugin_Hypothesis_i::GetOptimizationLevel()
132 {
133   ASSERT(myBaseImpl);
134   return this->GetImpl()->GetOptimizationLevel();
135 }
136
137 //=======================================================================
138 //function : SetWorkingDirectory
139 //=======================================================================
140
141 void GHS3DPlugin_Hypothesis_i::SetWorkingDirectory(const char* path) throw ( SALOME::SALOME_Exception )
142 {
143   if (!path )
144     THROW_SALOME_CORBA_EXCEPTION( "Null working directory",SALOME::BAD_PARAM );
145
146   string file(path);
147   const char lastChar = *file.rbegin();
148 #ifdef WIN32
149   if ( lastChar != '\\' ) file += '\\';
150 #else
151   if ( lastChar != '/' ) file += '/';
152 #endif
153   file += "GHS3D.log";
154   SMESH_Mesh_i::PrepareForWriting (file.c_str());
155
156   ASSERT(myBaseImpl);
157   this->GetImpl()->SetWorkingDirectory(path);
158   SMESH::TPythonDump() << _this() << ".SetWorkingDirectory( '" << path << "' )";
159 }
160
161 //=======================================================================
162 //function : GetWorkingDirectory
163 //=======================================================================
164
165 char* GHS3DPlugin_Hypothesis_i::GetWorkingDirectory()
166 {
167   ASSERT(myBaseImpl);
168   return CORBA::string_dup( this->GetImpl()->GetWorkingDirectory().c_str() );
169 }
170
171 //=======================================================================
172 //function : SetKeepFiles
173 //=======================================================================
174
175 void GHS3DPlugin_Hypothesis_i::SetKeepFiles(CORBA::Boolean toKeep)
176 {
177   ASSERT(myBaseImpl);
178   this->GetImpl()->SetKeepFiles(toKeep);
179   SMESH::TPythonDump() << _this() << ".SetKeepFiles( " << toKeep << " )";
180 }
181
182 //=======================================================================
183 //function : GetKeepFiles
184 //=======================================================================
185
186 CORBA::Boolean GHS3DPlugin_Hypothesis_i::GetKeepFiles()
187 {
188   ASSERT(myBaseImpl);
189   return this->GetImpl()->GetKeepFiles();
190 }
191
192 //=======================================================================
193 //function : SetVerboseLevel
194 //=======================================================================
195
196 void GHS3DPlugin_Hypothesis_i::SetVerboseLevel(CORBA::Short level)
197   throw ( SALOME::SALOME_Exception )
198 {
199   if (level < 0 || level > 10 )
200     THROW_SALOME_CORBA_EXCEPTION( "Invalid verbose level, valid range is [0-10]",
201                                   SALOME::BAD_PARAM );
202   ASSERT(myBaseImpl);
203   this->GetImpl()->SetVerboseLevel(level);
204   SMESH::TPythonDump() << _this() << ".SetVerboseLevel( " << level << " )";
205 }
206
207 //=======================================================================
208 //function : GetVerboseLevel
209 //=======================================================================
210
211 CORBA::Short GHS3DPlugin_Hypothesis_i::GetVerboseLevel()
212 {
213   ASSERT(myBaseImpl);
214   return this->GetImpl()->GetVerboseLevel();
215 }
216
217 //=======================================================================
218 //function : SetToCreateNewNodes
219 //=======================================================================
220
221 void GHS3DPlugin_Hypothesis_i::SetToCreateNewNodes(CORBA::Boolean toCreate)
222 {
223   ASSERT(myBaseImpl);
224   this->GetImpl()->SetToCreateNewNodes(toCreate);
225   SMESH::TPythonDump() << _this() << ".SetToCreateNewNodes( " << toCreate << " )";
226 }
227
228 //=======================================================================
229 //function : GetToCreateNewNodes
230 //=======================================================================
231
232 CORBA::Boolean GHS3DPlugin_Hypothesis_i::GetToCreateNewNodes()
233 {
234   ASSERT(myBaseImpl);
235   return this->GetImpl()->GetToCreateNewNodes();
236 }
237
238 //=======================================================================
239 //function : SetToUseBoundaryRecoveryVersion
240 //=======================================================================
241
242 void GHS3DPlugin_Hypothesis_i::SetToUseBoundaryRecoveryVersion(CORBA::Boolean toUse)
243 {
244   ASSERT(myBaseImpl);
245   this->GetImpl()->SetToUseBoundaryRecoveryVersion(toUse);
246   SMESH::TPythonDump() << _this() << ".SetToUseBoundaryRecoveryVersion( " << toUse << " )";
247 }
248
249 //=======================================================================
250 //function : GetToUseBoundaryRecoveryVersion
251 //=======================================================================
252
253 CORBA::Boolean GHS3DPlugin_Hypothesis_i::GetToUseBoundaryRecoveryVersion()
254 {
255   ASSERT(myBaseImpl);
256   return this->GetImpl()->GetToUseBoundaryRecoveryVersion();
257 }
258
259 //=======================================================================
260 //function : SetTextOption
261 //=======================================================================
262
263 void GHS3DPlugin_Hypothesis_i::SetTextOption(const char* option)
264 {
265   ASSERT(myBaseImpl);
266   this->GetImpl()->SetTextOption(option);
267   SMESH::TPythonDump() << _this() << ".SetTextOption( '" << option << "' )";
268 }
269
270 //=======================================================================
271 //function : GetTextOption
272 //=======================================================================
273
274 char* GHS3DPlugin_Hypothesis_i::GetTextOption()
275 {
276   ASSERT(myBaseImpl);
277   return CORBA::string_dup( this->GetImpl()->GetTextOption().c_str() );
278 }
279
280 //=============================================================================
281 /*!
282  *  Get implementation
283  */
284 //=============================================================================
285
286 ::GHS3DPlugin_Hypothesis* GHS3DPlugin_Hypothesis_i::GetImpl()
287 {
288   return (::GHS3DPlugin_Hypothesis*)myBaseImpl;
289 }
290
291 //================================================================================
292 /*!
293  * \brief Verify whether hypothesis supports given entity type 
294  */
295 //================================================================================  
296
297 CORBA::Boolean GHS3DPlugin_Hypothesis_i::IsDimSupported( SMESH::Dimension type )
298 {
299   return type == SMESH::DIM_3D;
300 }
301