Salome HOME
Copyright update: 2016
[plugins/ghs3dplugin.git] / src / GHS3DPlugin / GHS3DPlugin_Hypothesis_i.cxx
1 // Copyright (C) 2004-2016  CEA/DEN, EDF R&D
2 //
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.
7 //
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.
12 //
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
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19
20 // File      : GHS3DPlugin_Hypothesis_i.cxx
21 // Created   : Wed Apr  2 13:53:01 2008
22 // Author    : Edward AGAPOV (eap)
23 //
24 #include "GHS3DPlugin_Hypothesis_i.hxx"
25
26 #include "SMESH_Gen.hxx"
27 #include "SMESH_PythonDump.hxx"
28 //#include "SMESH_Mesh.hxx"
29 //#include "SMESH_ProxyMesh.hxx"
30 //#include <StdMeshers_QuadToTriaAdaptor.hxx>
31
32 #include "Utils_CorbaException.hxx"
33 #include "utilities.h"
34 #include "SMESH_Mesh_i.hxx"
35 #include "SMESH_Group_i.hxx"
36 #include "SMESH_Gen_i.hxx"
37 #include "SMESH_TypeDefs.hxx"
38 #include "SMESHDS_GroupBase.hxx"
39
40 // SALOME KERNEL includes
41 #include "SALOMEDSClient.hxx"
42 #include <SALOMEDSClient_definitions.hxx>
43 // // IDL headers
44 // #include <SALOMEconfig.h>
45 // #include CORBA_SERVER_HEADER(SALOMEDS)
46
47 using namespace std;
48
49 //=======================================================================
50 //function : GHS3DPlugin_Hypothesis_i
51 //=======================================================================
52
53 GHS3DPlugin_Hypothesis_i::GHS3DPlugin_Hypothesis_i (PortableServer::POA_ptr thePOA,
54                                                     int                     theStudyId,
55                                                     ::SMESH_Gen*            theGenImpl)
56   : SALOME::GenericObj_i( thePOA ), 
57     SMESH_Hypothesis_i( thePOA )
58 {
59   MESSAGE( "GHS3DPlugin_Hypothesis_i::GHS3DPlugin_Hypothesis_i" );
60   myBaseImpl = new ::GHS3DPlugin_Hypothesis (theGenImpl->GetANewId(),
61                                               theStudyId,
62                                               theGenImpl);
63 }
64
65 //=======================================================================
66 //function : ~GHS3DPlugin_Hypothesis_i
67 //=======================================================================
68
69 GHS3DPlugin_Hypothesis_i::~GHS3DPlugin_Hypothesis_i()
70 {
71   MESSAGE( "GHS3DPlugin_Hypothesis_i::~GHS3DPlugin_Hypothesis_i" );
72 }
73
74 //=======================================================================
75 //function : SetToMeshHoles
76 //=======================================================================
77
78 void GHS3DPlugin_Hypothesis_i::SetToMeshHoles(CORBA::Boolean toMesh)
79 {
80   ASSERT(myBaseImpl);
81   this->GetImpl()->SetToMeshHoles(toMesh);
82   SMESH::TPythonDump() << _this() << ".SetToMeshHoles( " << toMesh << " )";
83 }
84
85 //=======================================================================
86 //function : GetToMeshHoles
87 //=======================================================================
88
89 CORBA::Boolean GHS3DPlugin_Hypothesis_i::GetToMeshHoles()
90 {
91   ASSERT(myBaseImpl);
92   return this->GetImpl()->GetToMeshHoles();
93 }
94
95 //=======================================================================
96 //function : SetToMakeGroupsOfDomains
97 //=======================================================================
98
99 void GHS3DPlugin_Hypothesis_i::SetToMakeGroupsOfDomains(CORBA::Boolean toMakeGroups)
100 {
101   ASSERT(myBaseImpl);
102   this->GetImpl()->SetToMakeGroupsOfDomains(toMakeGroups);
103   SMESH::TPythonDump() << _this() << ".SetToMakeGroupsOfDomains( " << toMakeGroups << " )";
104 }
105
106 //=======================================================================
107 //function : GetToMakeGroupsOfDomains
108 //=======================================================================
109
110 CORBA::Boolean GHS3DPlugin_Hypothesis_i::GetToMakeGroupsOfDomains()
111 {
112   ASSERT(myBaseImpl);
113   return this->GetImpl()->GetToMakeGroupsOfDomains();
114 }
115
116 //=======================================================================
117 //function : SetMaximumMemory
118 //=======================================================================
119
120 void GHS3DPlugin_Hypothesis_i::SetMaximumMemory(CORBA::Long MB)
121    throw ( SALOME::SALOME_Exception )
122 {
123   if ( MB == 0 )
124     THROW_SALOME_CORBA_EXCEPTION( "Invalid memory size",SALOME::BAD_PARAM );
125   ASSERT(myBaseImpl);
126   this->GetImpl()->SetMaximumMemory(MB);
127   SMESH::TPythonDump() << _this() << ".SetMaximumMemory( " << MB << " )";
128 }
129
130 //=======================================================================
131 //function : GetMaximumMemory
132 //=======================================================================
133
134 CORBA::Long GHS3DPlugin_Hypothesis_i::GetMaximumMemory()
135 {
136   ASSERT(myBaseImpl);
137   return this->GetImpl()->GetMaximumMemory();
138 }
139
140 //=======================================================================
141 //function : SetInitialMemory
142 //=======================================================================
143
144 void GHS3DPlugin_Hypothesis_i::SetInitialMemory(CORBA::Long MB)
145   throw ( SALOME::SALOME_Exception )
146 {
147   if ( MB == 0 )
148     THROW_SALOME_CORBA_EXCEPTION( "Invalid memory size",SALOME::BAD_PARAM );
149   ASSERT(myBaseImpl);
150   this->GetImpl()->SetInitialMemory(MB);
151   SMESH::TPythonDump() << _this() << ".SetInitialMemory( " << MB << " )";
152 }
153
154 //=======================================================================
155 //function : GetInitialMemory
156 //=======================================================================
157
158 CORBA::Long GHS3DPlugin_Hypothesis_i::GetInitialMemory()
159 {
160   ASSERT(myBaseImpl);
161   return this->GetImpl()->GetInitialMemory();
162 }
163
164 //=======================================================================
165 //function : SetOptimizationLevel
166 //=======================================================================
167
168 void GHS3DPlugin_Hypothesis_i::SetOptimizationLevel(CORBA::Short level)
169   throw ( SALOME::SALOME_Exception )
170 {
171   ::GHS3DPlugin_Hypothesis::OptimizationLevel l =
172       (::GHS3DPlugin_Hypothesis::OptimizationLevel) level;
173   if ( l < ::GHS3DPlugin_Hypothesis::None ||
174        l > ::GHS3DPlugin_Hypothesis::Strong )
175     THROW_SALOME_CORBA_EXCEPTION( "Invalid optimization level",SALOME::BAD_PARAM );
176     
177   ASSERT(myBaseImpl);
178   this->GetImpl()->SetOptimizationLevel(l);
179   SMESH::TPythonDump() << _this() << ".SetOptimizationLevel( " << level << " )";
180 }
181
182 //=======================================================================
183 //function : GetOptimizationLevel
184 //=======================================================================
185
186 CORBA::Short GHS3DPlugin_Hypothesis_i::GetOptimizationLevel()
187 {
188   ASSERT(myBaseImpl);
189   return this->GetImpl()->GetOptimizationLevel();
190 }
191
192 //=======================================================================
193 //function : SetWorkingDirectory
194 //=======================================================================
195
196 void GHS3DPlugin_Hypothesis_i::SetWorkingDirectory(const char* path) throw ( SALOME::SALOME_Exception )
197 {
198   if (!path )
199     THROW_SALOME_CORBA_EXCEPTION( "Null working directory",SALOME::BAD_PARAM );
200
201   string file(path);
202   const char lastChar = *file.rbegin();
203 #ifdef WIN32
204   if ( lastChar != '\\' ) file += '\\';
205 #else
206   if ( lastChar != '/' ) file += '/';
207 #endif
208   file += "GHS3D.log";
209   SMESH_Mesh_i::PrepareForWriting (file.c_str());
210
211   ASSERT(myBaseImpl);
212   this->GetImpl()->SetWorkingDirectory(path);
213   SMESH::TPythonDump() << _this() << ".SetWorkingDirectory( '" << path << "' )";
214 }
215
216 //=======================================================================
217 //function : GetWorkingDirectory
218 //=======================================================================
219
220 char* GHS3DPlugin_Hypothesis_i::GetWorkingDirectory()
221 {
222   ASSERT(myBaseImpl);
223   return CORBA::string_dup( this->GetImpl()->GetWorkingDirectory().c_str() );
224 }
225
226 //=======================================================================
227 //function : SetKeepFiles
228 //=======================================================================
229
230 void GHS3DPlugin_Hypothesis_i::SetKeepFiles(CORBA::Boolean toKeep)
231 {
232   ASSERT(myBaseImpl);
233   this->GetImpl()->SetKeepFiles(toKeep);
234   SMESH::TPythonDump() << _this() << ".SetKeepFiles( " << toKeep << " )";
235 }
236
237 //=======================================================================
238 //function : GetKeepFiles
239 //=======================================================================
240
241 CORBA::Boolean GHS3DPlugin_Hypothesis_i::GetKeepFiles()
242 {
243   ASSERT(myBaseImpl);
244   return this->GetImpl()->GetKeepFiles();
245 }
246
247 //=======================================================================
248 //function : SetVerboseLevel
249 //=======================================================================
250
251 void GHS3DPlugin_Hypothesis_i::SetVerboseLevel(CORBA::Short level)
252   throw ( SALOME::SALOME_Exception )
253 {
254   if (level < 0 || level > 10 )
255     THROW_SALOME_CORBA_EXCEPTION( "Invalid verbose level, valid range is [0-10]",
256                                   SALOME::BAD_PARAM );
257   ASSERT(myBaseImpl);
258   this->GetImpl()->SetVerboseLevel(level);
259   SMESH::TPythonDump() << _this() << ".SetVerboseLevel( " << level << " )";
260 }
261
262 //=======================================================================
263 //function : GetVerboseLevel
264 //=======================================================================
265
266 CORBA::Short GHS3DPlugin_Hypothesis_i::GetVerboseLevel()
267 {
268   ASSERT(myBaseImpl);
269   return this->GetImpl()->GetVerboseLevel();
270 }
271
272 //=======================================================================
273 //function : SetToCreateNewNodes
274 //=======================================================================
275
276 void GHS3DPlugin_Hypothesis_i::SetToCreateNewNodes(CORBA::Boolean toCreate)
277 {
278   ASSERT(myBaseImpl);
279   this->GetImpl()->SetToCreateNewNodes(toCreate);
280   SMESH::TPythonDump() << _this() << ".SetToCreateNewNodes( " << toCreate << " )";
281 }
282
283 //=======================================================================
284 //function : GetToCreateNewNodes
285 //=======================================================================
286
287 CORBA::Boolean GHS3DPlugin_Hypothesis_i::GetToCreateNewNodes()
288 {
289   ASSERT(myBaseImpl);
290   return this->GetImpl()->GetToCreateNewNodes();
291 }
292
293 //=======================================================================
294 //function : SetToUseBoundaryRecoveryVersion
295 //=======================================================================
296
297 void GHS3DPlugin_Hypothesis_i::SetToUseBoundaryRecoveryVersion(CORBA::Boolean toUse)
298 {
299   ASSERT(myBaseImpl);
300   this->GetImpl()->SetToUseBoundaryRecoveryVersion(toUse);
301   SMESH::TPythonDump() << _this() << ".SetToUseBoundaryRecoveryVersion( " << toUse << " )";
302 }
303
304 //=======================================================================
305 //function : GetToUseBoundaryRecoveryVersion
306 //=======================================================================
307
308 CORBA::Boolean GHS3DPlugin_Hypothesis_i::GetToUseBoundaryRecoveryVersion()
309 {
310   ASSERT(myBaseImpl);
311   return this->GetImpl()->GetToUseBoundaryRecoveryVersion();
312 }
313
314 //=======================================================================
315 //function : SetFEMCorrection
316 //=======================================================================
317
318 void GHS3DPlugin_Hypothesis_i::SetFEMCorrection(CORBA::Boolean toUseFem)
319 {
320   ASSERT(myBaseImpl);
321   this->GetImpl()->SetFEMCorrection(toUseFem);
322   SMESH::TPythonDump() << _this() << ".SetFEMCorrection( " << toUseFem << " )";
323 }
324
325 //=======================================================================
326 //function : GetFEMCorrection
327 //=======================================================================
328
329 CORBA::Boolean GHS3DPlugin_Hypothesis_i::GetFEMCorrection()
330 {
331   ASSERT(myBaseImpl);
332   return this->GetImpl()->GetFEMCorrection();
333 }
334
335 //=======================================================================
336 //function : SetToRemoveCentralPoint
337 //=======================================================================
338
339 void GHS3DPlugin_Hypothesis_i::SetToRemoveCentralPoint(CORBA::Boolean toRemove)
340 {
341   ASSERT(myBaseImpl);
342   this->GetImpl()->SetToRemoveCentralPoint(toRemove);
343   SMESH::TPythonDump() << _this() << ".SetToRemoveCentralPoint( " << toRemove << " )";
344 }
345
346 //=======================================================================
347 //function : GetToRemoveCentralPoint
348 //=======================================================================
349
350 CORBA::Boolean GHS3DPlugin_Hypothesis_i::GetToRemoveCentralPoint()
351 {
352   ASSERT(myBaseImpl);
353   return this->GetImpl()->GetToRemoveCentralPoint();
354 }
355
356 //=======================================================================
357 //function : SetTextOption
358 //=======================================================================
359
360 void GHS3DPlugin_Hypothesis_i::SetTextOption(const char* option)
361 {
362   ASSERT(myBaseImpl);
363   this->GetImpl()->SetTextOption(option);
364   SMESH::TPythonDump() << _this() << ".SetTextOption( '" << option << "' )";
365 }
366
367 //=======================================================================
368 //function : GetTextOption
369 //=======================================================================
370
371 char* GHS3DPlugin_Hypothesis_i::GetTextOption()
372 {
373   ASSERT(myBaseImpl);
374   return CORBA::string_dup( this->GetImpl()->GetTextOption().c_str() );
375 }
376
377 //=======================================================================
378 //function : SetToRemoveCentralPoint
379 //=======================================================================
380
381 void GHS3DPlugin_Hypothesis_i::SetGradation(CORBA::Double gradation)
382 {
383   if (gradation <= 1)
384     THROW_SALOME_CORBA_EXCEPTION( "The volumic gradation must be > 1",SALOME::BAD_PARAM );
385   ASSERT(myBaseImpl);
386   if (gradation != GetGradation()) {
387     this->GetImpl()->SetGradation(gradation);
388     SMESH::TPythonDump() << _this() << ".SetGradation( " << gradation << " )";
389   }
390 }
391
392 //=======================================================================
393 //function : GetToRemoveCentralPoint
394 //=======================================================================
395
396 CORBA::Double GHS3DPlugin_Hypothesis_i::GetGradation()
397 {
398   ASSERT(myBaseImpl);
399   return this->GetImpl()->GetGradation();
400 }
401
402 //=======================================================================
403 //function : SetStandardOutputLog
404 //=======================================================================
405
406 void GHS3DPlugin_Hypothesis_i::SetStandardOutputLog(CORBA::Boolean logInStandardOutput)
407 {
408   ASSERT(myBaseImpl);
409   this->GetImpl()->SetStandardOutputLog(logInStandardOutput);
410   SMESH::TPythonDump() << _this() << ".SetPrintLogInFile( " << !logInStandardOutput << " )";
411 }
412
413 //=======================================================================
414 //function : GetStandardOutputLog
415 //=======================================================================
416
417 CORBA::Boolean GHS3DPlugin_Hypothesis_i::GetStandardOutputLog()
418 {
419   ASSERT(myBaseImpl);
420   return this->GetImpl()->GetStandardOutputLog();
421 }
422
423 //=======================================================================
424 //function : SetRemoveLogOnSuccess
425 //=======================================================================
426
427 void GHS3DPlugin_Hypothesis_i::SetRemoveLogOnSuccess(CORBA::Boolean removeLogOnSuccess)
428 {
429   ASSERT(myBaseImpl);
430   this->GetImpl()->SetRemoveLogOnSuccess(removeLogOnSuccess);
431   SMESH::TPythonDump() << _this() << ".SetRemoveLogOnSuccess( " << removeLogOnSuccess << " )";
432 }
433
434 //=======================================================================
435 //function : GetRemoveLogOnSuccess
436 //=======================================================================
437
438 CORBA::Boolean GHS3DPlugin_Hypothesis_i::GetRemoveLogOnSuccess()
439 {
440   ASSERT(myBaseImpl);
441   return this->GetImpl()->GetRemoveLogOnSuccess();
442 }
443
444 //=======================================================================
445 //function : SetEnforcedVertex
446 //=======================================================================
447
448 bool GHS3DPlugin_Hypothesis_i::SetEnforcedVertex(CORBA::Double x, CORBA::Double y, CORBA::Double z, CORBA::Double size)
449     throw (SALOME::SALOME_Exception) {
450   ASSERT(myBaseImpl);
451   MESSAGE("IDL : SetEnforcedVertex( "<< x << ", " << y << ", " << z << ", " << size << ")");
452   return p_SetEnforcedVertex(size, x, y, z);
453 }
454
455 bool GHS3DPlugin_Hypothesis_i::SetEnforcedVertexNamed(CORBA::Double x, CORBA::Double y, CORBA::Double z, CORBA::Double size, const char* theVertexName)
456     throw (SALOME::SALOME_Exception) {
457   ASSERT(myBaseImpl);
458   MESSAGE("IDL : SetEnforcedVertexNamed( "<< x << ", " << y << ", " << z << ", " << size << ", " << theVertexName << ")");
459   return p_SetEnforcedVertex(size, x, y, z, theVertexName, "", "");
460 }
461
462 bool GHS3DPlugin_Hypothesis_i::SetEnforcedVertexWithGroup(CORBA::Double x, CORBA::Double y, CORBA::Double z, CORBA::Double size, const char* theGroupName)
463     throw (SALOME::SALOME_Exception) {
464   ASSERT(myBaseImpl);
465   MESSAGE("IDL : SetEnforcedVertexWithGroup( "<< x << ", " << y << ", " << z << ", " << size << ", " << theGroupName << ")");
466   return p_SetEnforcedVertex(size, x, y, z, "", "", theGroupName);
467 }
468
469 bool GHS3DPlugin_Hypothesis_i::SetEnforcedVertexNamedWithGroup(CORBA::Double x, CORBA::Double y, CORBA::Double z, CORBA::Double size, const char* theVertexName, const char* theGroupName)
470     throw (SALOME::SALOME_Exception) {
471   ASSERT(myBaseImpl);
472   MESSAGE("IDL : SetEnforcedVertexNamedWithGroup( "<< x << ", " << y << ", " << z << ", " << size << ", " << theVertexName << ", " << theGroupName << ")");
473   return p_SetEnforcedVertex(size, x, y, z, theVertexName, "", theGroupName);
474 }
475
476 bool GHS3DPlugin_Hypothesis_i::SetEnforcedVertexGeom(GEOM::GEOM_Object_ptr theVertex, CORBA::Double size)
477     throw (SALOME::SALOME_Exception) {
478   ASSERT(myBaseImpl);
479   
480   if ((theVertex->GetShapeType() != GEOM::VERTEX) && (theVertex->GetShapeType() != GEOM::COMPOUND)) {
481     MESSAGE("theVertex shape type is not VERTEX or COMPOUND");
482     THROW_SALOME_CORBA_EXCEPTION("theVertex shape type is not VERTEX or COMPOUND", SALOME::BAD_PARAM);
483   }
484   
485   string theVertexEntry = theVertex->GetStudyEntry();
486   CORBA::Double x = 0, y = 0, z = 0;
487   CORBA::Boolean isCompound = false;
488   GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine();
489   SMESH_Gen_i *smeshGen = SMESH_Gen_i::GetSMESHGen();
490   if (theVertexEntry.empty()) {
491     string aName;
492     if (theVertex->GetShapeType() == GEOM::VERTEX) {
493       aName = "Vertex_";
494     }
495     if (theVertex->GetShapeType() == GEOM::COMPOUND) {
496       aName = "Compound_";
497       isCompound = true;
498     }
499     aName += theVertex->GetEntry();
500     SALOMEDS::SObject_ptr theSVertex = geomGen->PublishInStudy(smeshGen->GetCurrentStudy(), NULL, theVertex, aName.c_str());
501     if (!theSVertex->_is_nil())
502       theVertexEntry = theSVertex->GetID();
503   }
504   if (theVertexEntry.empty())
505     THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM );
506
507   if (theVertex->GetShapeType() == GEOM::VERTEX) {
508     GEOM::GEOM_IMeasureOperations_var measureOp = geomGen->GetIMeasureOperations( smeshGen->GetCurrentStudy()->StudyId() );
509     if (CORBA::is_nil(measureOp))
510       return false;
511     
512     measureOp->PointCoordinates (theVertex, x, y, z);
513     MESSAGE("Point coordinates from measureOp: " << x << ", " << y << ", " << z);
514   }
515
516   string theVertexName = theVertex->GetName();
517   MESSAGE("IDL : SetEnforcedVertexGeom( "<< theVertexEntry << ", " << size<< ")");
518   
519   return p_SetEnforcedVertex(size, x, y, z, theVertexName.c_str(), theVertexEntry.c_str(), "", isCompound);
520 }
521
522 bool GHS3DPlugin_Hypothesis_i::SetEnforcedVertexGeomWithGroup(GEOM::GEOM_Object_ptr theVertex, CORBA::Double size, const char* theGroupName)
523     throw (SALOME::SALOME_Exception) {
524   ASSERT(myBaseImpl);
525   
526   if ((theVertex->GetShapeType() != GEOM::VERTEX) && (theVertex->GetShapeType() != GEOM::COMPOUND)) {
527     MESSAGE("theVertex shape type is not VERTEX or COMPOUND");
528     THROW_SALOME_CORBA_EXCEPTION("theVertex shape type is not VERTEX or COMPOUND", SALOME::BAD_PARAM);
529   }
530   
531   string theVertexEntry = theVertex->GetStudyEntry();
532   CORBA::Double x = 0, y = 0, z = 0;
533   CORBA::Boolean isCompound = false;
534   GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine();
535   SMESH_Gen_i *smeshGen = SMESH_Gen_i::GetSMESHGen();
536   if (theVertexEntry.empty()) {
537     string aName;
538     if (theVertex->GetShapeType() == GEOM::VERTEX) {
539       aName = "Vertex_";
540     }
541     if (theVertex->GetShapeType() == GEOM::COMPOUND) {
542       aName = "Compound_";
543       isCompound = true;
544     }
545     aName += theVertex->GetEntry();
546     SALOMEDS::SObject_ptr theSVertex = geomGen->PublishInStudy(smeshGen->GetCurrentStudy(), NULL, theVertex, aName.c_str());
547     if (!theSVertex->_is_nil())
548       theVertexEntry = theSVertex->GetID();
549   }
550   if (theVertexEntry.empty())
551     THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM );
552
553   if (theVertex->GetShapeType() == GEOM::VERTEX) {
554     GEOM::GEOM_IMeasureOperations_var measureOp = geomGen->GetIMeasureOperations( smeshGen->GetCurrentStudy()->StudyId() );
555     if (CORBA::is_nil(measureOp))
556       return false;
557     
558     measureOp->PointCoordinates (theVertex, x, y, z);
559     MESSAGE("Point coordinates from measureOp: " << x << ", " << y << ", " << z);
560   }
561     
562   string theVertexName = theVertex->GetName();
563   MESSAGE("IDL : SetEnforcedVertexGeomWithGroup( "<< theVertexEntry << ", " << size<< ", " << theGroupName << ")");
564   
565   return p_SetEnforcedVertex(size, x, y, z, theVertexName.c_str(), theVertexEntry.c_str(), theGroupName, isCompound);
566 }
567
568 bool GHS3DPlugin_Hypothesis_i:: p_SetEnforcedVertex(CORBA::Double size, CORBA::Double x, CORBA::Double y, CORBA::Double z,
569                                                    const char* theVertexName, const char* theVertexEntry, const char* theGroupName,
570                                                    CORBA::Boolean isCompound)
571     throw (SALOME::SALOME_Exception) {
572   ASSERT(myBaseImpl);
573   MESSAGE("IDL : p_SetEnforcedVertex(" << size << ", " << x << ", " << y << ", " << z << ", \"" << theVertexName << "\", \"" << theVertexEntry << "\", \"" << theGroupName << "\", " << isCompound<< ")");
574   bool newValue = false;
575
576   ::GHS3DPlugin_Hypothesis::TCoordsGHS3DEnforcedVertexMap coordsList;
577   ::GHS3DPlugin_Hypothesis::TGeomEntryGHS3DEnforcedVertexMap enfVertexEntryList;
578   if (string(theVertexEntry).empty()) {
579     coordsList = this->GetImpl()->_GetEnforcedVerticesByCoords();
580     std::vector<double> coords;
581     coords.push_back(x);
582     coords.push_back(y);
583     coords.push_back(z);
584     if (coordsList.find(coords) == coordsList.end()) {
585       MESSAGE("Coords not found: add it in coordsList");
586       newValue = true;
587     }
588     else {
589       MESSAGE("Coords already found, compare names");
590       ::GHS3DPlugin_Hypothesis::TGHS3DEnforcedVertex *enfVertex = this->GetImpl()->GetEnforcedVertex(x, y, z);
591       if ((enfVertex->name != theVertexName) || (enfVertex->groupName != theGroupName) || (enfVertex->size != size)) {
592         MESSAGE("The names or size are different: update");
593 //          this->GetImpl()->ClearEnforcedVertex(theFaceEntry, x, y, z);
594         newValue = true;
595       }
596       else {
597         MESSAGE("The names and size are identical");
598       }
599     }
600
601     if (newValue) {
602       if (string(theVertexName).empty()) {
603         if (string(theGroupName).empty())
604           SMESH::TPythonDump() << "isDone = " << _this() << ".SetEnforcedVertex(" << x << ", " << y << ", " << z << ", " << size << ")";
605         else
606           SMESH::TPythonDump() << "isDone = " << _this() << ".SetEnforcedVertexWithGroup(" << x << ", " << y << ", " << z << ", " << size << ", \"" << theGroupName << "\")";
607       }
608       else {
609         if (string(theGroupName).empty())
610           SMESH::TPythonDump() << "isDone = " << _this() << ".SetEnforcedVertexNamed(" << x << ", " << y << ", " << z << ", " << size  << ", \"" << theVertexName << "\")";
611         else
612           SMESH::TPythonDump() << "isDone = " << _this() << ".SetEnforcedVertexNamedWithGroup(" << x << ", " << y << ", " << z << ", " << size  << ", \"" << theVertexName << "\", \"" << theGroupName << "\")";
613       }
614     }
615   } 
616   else {
617 //   if (isCompound || (!isCompound && !string(theVertexEntry).empty())) {
618     enfVertexEntryList = this->GetImpl()->_GetEnforcedVerticesByEntry();
619 //     ::BLSURFPlugin_Hypothesis::TGeomEntryGHS3DEnforcedVertexMap::const_iterator it = enfVertexEntryList.find(theVertexEntry);
620     if ( enfVertexEntryList.find(theVertexEntry) == enfVertexEntryList.end()) {
621       MESSAGE("Geom entry not found: add it in enfVertexEntryList");
622       newValue = true;
623     }
624     else {
625       MESSAGE("Geom entry already found, compare names");
626       ::GHS3DPlugin_Hypothesis::TGHS3DEnforcedVertex *enfVertex = this->GetImpl()->GetEnforcedVertex(theVertexEntry);
627       if ((enfVertex->name != theVertexName) || (enfVertex->groupName != theGroupName) || (enfVertex->size != size)) {
628         MESSAGE("The names or size are different: update");
629 //          this->GetImpl()->ClearEnforcedVertex(theFaceEntry, x, y, z);
630         newValue = true;
631       }
632       else {
633         MESSAGE("The names and size are identical");
634       }
635     }
636
637     if (newValue) {
638       if (string(theGroupName).empty())
639         SMESH::TPythonDump() << "isDone = " << _this() << ".SetEnforcedVertexGeom(" << theVertexEntry << ", " << size << ")";
640       else
641         SMESH::TPythonDump() << "isDone = " << _this() << ".SetEnforcedVertexGeomWithGroup(" << theVertexEntry << ", " << size << ", \"" << theGroupName << "\")";
642     }
643   }
644
645   if (newValue)
646     this->GetImpl()->SetEnforcedVertex(theVertexName, theVertexEntry, theGroupName, size, x, y, z, isCompound);
647
648   MESSAGE("IDL : SetEnforcedVertexEntry END");
649   return newValue;
650 }
651
652 //=======================================================================
653 //function : GetEnforcedVertex
654 //=======================================================================
655
656 CORBA::Double GHS3DPlugin_Hypothesis_i::GetEnforcedVertex(CORBA::Double x, CORBA::Double y, CORBA::Double z)
657   throw (SALOME::SALOME_Exception)
658 {
659   ASSERT(myBaseImpl);
660   try {
661     bool isDone = this->GetImpl()->GetEnforcedVertex(x,y,z)->size;
662     SMESH::TPythonDump() << "aSize = " << _this() << ".GetEnforcedVertex(" << x << ", " << y << ", " << z << ")";
663     return isDone;
664   }
665   catch (const std::invalid_argument& ex) {
666     SALOME::ExceptionStruct ExDescription;
667     ExDescription.text = ex.what();
668     ExDescription.type = SALOME::BAD_PARAM;
669     ExDescription.sourceFile = "GHS3DPlugin_Hypothesis_i.cxx";
670     ExDescription.lineNumber = 513;
671     throw SALOME::SALOME_Exception(ExDescription);
672   }
673   catch (SALOME_Exception& ex) {
674     THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
675   }
676 }
677
678 //=======================================================================
679 //function : GetEnforcedVertex
680 //=======================================================================
681
682 CORBA::Double GHS3DPlugin_Hypothesis_i::GetEnforcedVertexGeom(GEOM::GEOM_Object_ptr theVertex)
683   throw (SALOME::SALOME_Exception)
684 {
685   ASSERT(myBaseImpl);
686   
687   if ((theVertex->GetShapeType() != GEOM::VERTEX) && (theVertex->GetShapeType() != GEOM::COMPOUND)) {
688     MESSAGE("theVertex shape type is not VERTEX or COMPOUND");
689     THROW_SALOME_CORBA_EXCEPTION("theVertex shape type is not VERTEX or COMPOUND", SALOME::BAD_PARAM);
690   }
691   
692   string theVertexEntry = theVertex->GetStudyEntry();
693   if (theVertexEntry.empty()) {
694     GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine();
695     SMESH_Gen_i *smeshGen = SMESH_Gen_i::GetSMESHGen();
696     string aName;
697     if (theVertex->GetShapeType() == GEOM::VERTEX)
698       aName = "Vertex_";
699     if (theVertex->GetShapeType() == GEOM::COMPOUND)
700       aName = "Compound_";
701     aName += theVertex->GetEntry();
702     SALOMEDS::SObject_ptr theSVertex = geomGen->PublishInStudy(smeshGen->GetCurrentStudy(), NULL, theVertex, aName.c_str());
703     if (!theSVertex->_is_nil())
704       theVertexEntry = theSVertex->GetID();
705   }
706   if (theVertexEntry.empty())
707     THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM );
708
709   string theVertexName = theVertex->GetName();
710   
711   try {
712     bool isDone = this->GetImpl()->GetEnforcedVertex(theVertexName)->size;
713     SMESH::TPythonDump() << "aSize = " << _this() << ".GetEnforcedVertexGeom(" << theVertex << ")";
714     return isDone;
715   }
716   catch (const std::invalid_argument& ex) {
717     SALOME::ExceptionStruct ExDescription;
718     ExDescription.text = ex.what();
719     ExDescription.type = SALOME::BAD_PARAM;
720     ExDescription.sourceFile = "GHS3DPlugin_Hypothesis_i.cxx";
721     ExDescription.lineNumber = 538;
722     throw SALOME::SALOME_Exception(ExDescription);
723   }
724   catch (SALOME_Exception& ex) {
725     THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
726   }
727 }
728
729 //=======================================================================
730 //function : GetEnforcedVertices
731 //=======================================================================
732
733 GHS3DPlugin::GHS3DEnforcedVertexList* GHS3DPlugin_Hypothesis_i::GetEnforcedVertices()
734 {
735   ASSERT(myBaseImpl);
736   GHS3DPlugin::GHS3DEnforcedVertexList_var result = new GHS3DPlugin::GHS3DEnforcedVertexList();
737
738   const ::GHS3DPlugin_Hypothesis::TGHS3DEnforcedVertexList enfVertexList = this->GetImpl()->_GetEnforcedVertices();
739   result->length( enfVertexList.size() );
740
741   ::GHS3DPlugin_Hypothesis::TGHS3DEnforcedVertexList::const_iterator it = enfVertexList.begin();
742
743   for (int i = 0 ; it != enfVertexList.end(); ++it, ++i ) {
744     ::GHS3DPlugin_Hypothesis::TGHS3DEnforcedVertex* currentVertex = (*it);
745     GHS3DPlugin::GHS3DEnforcedVertex_var enfVertex = new GHS3DPlugin::GHS3DEnforcedVertex();
746     // Name
747     enfVertex->name = CORBA::string_dup(currentVertex->name.c_str());
748     // Geom Vertex Entry
749     enfVertex->geomEntry = CORBA::string_dup(currentVertex->geomEntry.c_str());
750     // Coords
751     GHS3DPlugin::TCoords_var coords = new GHS3DPlugin::TCoords();
752     coords->length(currentVertex->coords.size());
753     for ( size_t ind = 0; ind < currentVertex->coords.size(); ind++)
754       coords[ind] = currentVertex->coords[ind];
755     enfVertex->coords = coords;
756     // Group Name
757     enfVertex->groupName = CORBA::string_dup(currentVertex->groupName.c_str());
758     // Size
759     enfVertex->size = currentVertex->size;
760     // isCompound
761     enfVertex->isCompound = currentVertex->isCompound;
762     
763     result[i]=enfVertex;
764     }
765   
766 //   SMESH::TPythonDump() << "allEnforcedVertices = " << _this() << ".GetEnforcedVertices()";
767
768   return result._retn();
769 }
770
771 //=======================================================================
772 //function : RemoveEnforcedVertex
773 //=======================================================================
774
775 bool GHS3DPlugin_Hypothesis_i::RemoveEnforcedVertex(CORBA::Double x, CORBA::Double y, CORBA::Double z)
776   throw (SALOME::SALOME_Exception)
777 {
778   ASSERT(myBaseImpl);
779   try {
780     bool res = this->GetImpl()->RemoveEnforcedVertex(x,y,z);
781     SMESH::TPythonDump() << " isDone = " << _this() << ".RemoveEnforcedVertex( " << x << ", " << y << ", " << z << " )";
782     return res;
783   }
784   catch (const std::invalid_argument& ex) {
785     SALOME::ExceptionStruct ExDescription;
786     ExDescription.text = ex.what();
787     ExDescription.type = SALOME::BAD_PARAM;
788     ExDescription.sourceFile = "GHS3DPlugin_Hypothesis_i.cxx";
789     ExDescription.lineNumber = 625;
790     throw SALOME::SALOME_Exception(ExDescription);
791   }
792   catch (SALOME_Exception& ex) {
793     THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
794   }
795 }
796
797 bool GHS3DPlugin_Hypothesis_i::RemoveEnforcedVertexGeom(GEOM::GEOM_Object_ptr theVertex)
798   throw (SALOME::SALOME_Exception)
799 {
800   ASSERT(myBaseImpl);
801   
802   if ((theVertex->GetShapeType() != GEOM::VERTEX) && (theVertex->GetShapeType() != GEOM::COMPOUND)) {
803     MESSAGE("theVertex shape type is not VERTEX or COMPOUND");
804     THROW_SALOME_CORBA_EXCEPTION("theVertex shape type is not VERTEX or COMPOUND", SALOME::BAD_PARAM);
805   }
806   
807   string theVertexEntry = theVertex->GetStudyEntry();
808   if (theVertexEntry.empty()) {
809     GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine();
810     SMESH_Gen_i *smeshGen = SMESH_Gen_i::GetSMESHGen();
811     string aName;
812     if (theVertex->GetShapeType() == GEOM::VERTEX)
813       aName = "Vertex_";
814     if (theVertex->GetShapeType() == GEOM::COMPOUND)
815       aName = "Compound_";
816     aName += theVertex->GetEntry();
817     SALOMEDS::SObject_ptr theSVertex = geomGen->PublishInStudy(smeshGen->GetCurrentStudy(), NULL, theVertex, aName.c_str());
818     if (!theSVertex->_is_nil())
819       theVertexEntry = theSVertex->GetID();
820   }
821   if (theVertexEntry.empty())
822     THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM );
823   
824   try {
825     bool res = this->GetImpl()->RemoveEnforcedVertex(0,0,0, theVertexEntry.c_str());
826     SMESH::TPythonDump() << "isDone = " << _this() << ".RemoveEnforcedVertexGeom( " << theVertexEntry.c_str() << " )";
827     return res;
828   }
829   catch (const std::invalid_argument& ex) {
830     SALOME::ExceptionStruct ExDescription;
831     ExDescription.text = ex.what();
832     ExDescription.type = SALOME::BAD_PARAM;
833     ExDescription.sourceFile = "GHS3DPlugin_Hypothesis_i.cxx";
834     ExDescription.lineNumber = 648;
835     throw SALOME::SALOME_Exception(ExDescription);
836   }
837   catch (SALOME_Exception& ex) {
838     THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
839   }
840 }
841
842 //=======================================================================
843 //function : ClearEnforcedVertices
844 //=======================================================================
845
846 void GHS3DPlugin_Hypothesis_i::ClearEnforcedVertices()
847 {
848   ASSERT(myBaseImpl);
849   this->GetImpl()->ClearEnforcedVertices();
850   SMESH::TPythonDump () << _this() << ".ClearEnforcedVertices() ";
851 }
852
853 //=======================================================================
854 //function : ClearEnforcedMeshes
855 //=======================================================================
856
857 void GHS3DPlugin_Hypothesis_i::ClearEnforcedMeshes()
858 {
859   ASSERT(myBaseImpl);
860   this->GetImpl()->ClearEnforcedMeshes();
861   SMESH::TPythonDump () << _this() << ".ClearEnforcedMeshes() ";
862 }
863
864 //=======================================================================
865 //function : GetEnforcedMeshes
866 //=======================================================================
867
868 GHS3DPlugin::GHS3DEnforcedMeshList* GHS3DPlugin_Hypothesis_i::GetEnforcedMeshes()
869 {
870   ASSERT(myBaseImpl);
871   GHS3DPlugin::GHS3DEnforcedMeshList_var result = new GHS3DPlugin::GHS3DEnforcedMeshList();
872
873   const ::GHS3DPlugin_Hypothesis::TGHS3DEnforcedMeshList enfMeshList = this->GetImpl()->_GetEnforcedMeshes();
874   result->length( enfMeshList.size() );
875
876   ::GHS3DPlugin_Hypothesis::TGHS3DEnforcedMeshList::const_iterator it = enfMeshList.begin();
877
878   for (int i = 0 ; it != enfMeshList.end(); ++it, ++i ) {
879     ::GHS3DPlugin_Hypothesis::TGHS3DEnforcedMesh* currentMesh = (*it);
880     GHS3DPlugin::GHS3DEnforcedMesh_var enfMesh = new GHS3DPlugin::GHS3DEnforcedMesh();
881     // Name
882     enfMesh->name = CORBA::string_dup(currentMesh->name.c_str());
883     // Mesh Entry
884     enfMesh->entry = CORBA::string_dup(currentMesh->entry.c_str());
885     // isCompound
886     enfMesh->elementType = currentMesh->elementType;
887     // Group Name
888     enfMesh->groupName = CORBA::string_dup(currentMesh->groupName.c_str());
889     
890     result[i]=enfMesh;
891     }
892   
893 //   SMESH::TPythonDump() << "allEnforcedVertices = " << _this() << ".GetEnforcedVertices()";
894
895   return result._retn();
896 }
897
898 /*!
899  * \brief Adds enforced elements of type elementType using another mesh/sub-mesh/mesh group theSource. The elements will be grouped in theGroupName.
900  */
901 bool GHS3DPlugin_Hypothesis_i::SetEnforcedMeshWithGroup(SMESH::SMESH_IDSource_ptr theSource, SMESH::ElementType theType, const char* theGroupName)
902   throw (SALOME::SALOME_Exception)
903 {
904 // #if GHS3D_VERSION >= 42
905   return p_SetEnforcedMesh(theSource, theType, "", theGroupName);
906 // #else
907 //   SALOME::ExceptionStruct ExDescription;
908 //   ExDescription.text = "Bad version of GHS3D. It must >= 4.2.";
909 //   ExDescription.type = SALOME::BAD_PARAM;
910 //   ExDescription.sourceFile = "GHS3DPlugin_Hypothesis_i.cxx";
911 //   ExDescription.lineNumber = 719;
912 //   throw SALOME::SALOME_Exception(ExDescription);
913 // #endif
914 }
915
916 /*!
917  * \brief Adds enforced elements of type elementType using another mesh/sub-mesh/mesh group theSource.
918  */
919 bool GHS3DPlugin_Hypothesis_i::SetEnforcedMesh(SMESH::SMESH_IDSource_ptr theSource, SMESH::ElementType theType)
920   throw (SALOME::SALOME_Exception)
921 {
922 //   MESSAGE("GHS3DPlugin_Hypothesis_i::SetEnforcedMesh");
923 // #if GHS3D_VERSION >= 42
924   return p_SetEnforcedMesh(theSource, theType);
925 // #else
926 //   SALOME::ExceptionStruct ExDescription;
927 //   ExDescription.text = "Bad version of GHS3D. It must >= 4.2.";
928 //   ExDescription.type = SALOME::BAD_PARAM;
929 //   ExDescription.sourceFile = "GHS3DPlugin_Hypothesis_i.cxx";
930 //   ExDescription.lineNumber = 750;
931 //   throw SALOME::SALOME_Exception(ExDescription);
932 // #endif
933 }
934
935 /*!
936  * \brief OBSOLETE FUNCTION - Adds enforced elements of type elementType using another mesh/sub-mesh/mesh group theSource and a size. The elements will be grouped in theGroupName.
937  */
938 bool GHS3DPlugin_Hypothesis_i::SetEnforcedMeshSizeWithGroup(SMESH::SMESH_IDSource_ptr theSource, SMESH::ElementType theType, double theSize, const char* theGroupName)
939   throw (SALOME::SALOME_Exception)
940 {
941 // #if GHS3D_VERSION >= 42
942   return p_SetEnforcedMesh(theSource, theType, "", theGroupName);
943 // #else
944 //   SALOME::ExceptionStruct ExDescription;
945 //   ExDescription.text = "Bad version of GHS3D. It must >= 4.2.";
946 //   ExDescription.type = SALOME::BAD_PARAM;
947 //   ExDescription.sourceFile = "GHS3DPlugin_Hypothesis_i.cxx";
948 //   ExDescription.lineNumber = 750;
949 //   throw SALOME::SALOME_Exception(ExDescription);
950 // #endif
951 }
952
953 /*!
954  * \brief OBSOLETE FUNCTION - Adds enforced elements of type elementType using another mesh/sub-mesh/mesh group theSource and a size.
955  */
956 bool GHS3DPlugin_Hypothesis_i::SetEnforcedMeshSize(SMESH::SMESH_IDSource_ptr theSource, SMESH::ElementType theType, double theSize)
957   throw (SALOME::SALOME_Exception)
958 {
959 // #if GHS3D_VERSION >= 42
960   return p_SetEnforcedMesh(theSource, theType);
961 // #else
962 //   SALOME::ExceptionStruct ExDescription;
963 //   ExDescription.text = "Bad version of GHS3D. It must >= 4.2.";
964 //   ExDescription.type = SALOME::BAD_PARAM;
965 //   ExDescription.sourceFile = "GHS3DPlugin_Hypothesis_i.cxx";
966 //   ExDescription.lineNumber = 750;
967 //   throw SALOME::SALOME_Exception(ExDescription);
968 // #endif
969 }
970
971 bool GHS3DPlugin_Hypothesis_i::p_SetEnforcedMesh(SMESH::SMESH_IDSource_ptr theSource, SMESH::ElementType theType, const char* theName, const char* theGroupName)
972   throw (SALOME::SALOME_Exception)
973 {
974   MESSAGE("GHS3DPlugin_Hypothesis_i::p_SetEnforcedMesh");
975   ASSERT(myBaseImpl);
976   
977   if (CORBA::is_nil( theSource ))
978   {
979     SALOME::ExceptionStruct ExDescription;
980     ExDescription.text = "The source mesh CORBA object is NULL";
981     ExDescription.type = SALOME::BAD_PARAM;
982     ExDescription.sourceFile = "GHS3DPlugin_Hypothesis_i.cxx";
983     ExDescription.lineNumber = 840;
984     throw SALOME::SALOME_Exception(ExDescription);
985   }
986   
987   switch (theType) {
988     case SMESH::NODE:
989       MESSAGE("Required type is NODE");
990       break;
991     case SMESH::EDGE:
992       MESSAGE("Required type is EDGE");
993       break;
994     case SMESH::FACE:
995       MESSAGE("Required type is FACE");
996       break;
997     default:
998         MESSAGE("Incompatible required type: " << theType);
999         return false;
1000   }
1001 //   MESSAGE("Required type is "<<theType);
1002   SMESH::array_of_ElementType_var types = theSource->GetTypes();
1003   MESSAGE("Available types:");
1004   for ( CORBA::ULong i=0;i<types->length();i++){MESSAGE(types[i]);}
1005   if ( types->length() >= 1 && types[types->length()-1] <  theType)
1006   {
1007     MESSAGE("Required type not available");
1008     return false;
1009 //     SALOME::ExceptionStruct ExDescription;
1010 //     ExDescription.text = "The source mesh has bad type";
1011 //     ExDescription.type = SALOME::BAD_PARAM;
1012 //     ExDescription.sourceFile = "GHS3DPlugin_Hypothesis_i.cxx";
1013 //     ExDescription.lineNumber = 840;
1014 //     throw SALOME::SALOME_Exception(ExDescription);
1015   }
1016   
1017
1018   SMESH_Gen_i *smeshGen = SMESH_Gen_i::GetSMESHGen();
1019   SALOMEDS::SObject_ptr SObj = smeshGen->ObjectToSObject(smeshGen->GetCurrentStudy(),theSource);
1020
1021   SMESH_Mesh_i* theMesh_i = SMESH::DownCast<SMESH_Mesh_i*>( theSource);
1022   SMESH_Group_i* theGroup_i = SMESH::DownCast<SMESH_Group_i*>( theSource);
1023   SMESH_GroupOnGeom_i* theGroupOnGeom_i = SMESH::DownCast<SMESH_GroupOnGeom_i*>( theSource);
1024
1025   string enfMeshName = theName;
1026   if (enfMeshName.empty())
1027     enfMeshName = SObj->GetName();
1028
1029   if (theMesh_i)
1030   {
1031     try {
1032       bool res = this->GetImpl()->SetEnforcedMesh(theMesh_i->GetImpl(), theType, enfMeshName , SObj->GetID(), theGroupName);
1033       if (theGroupName && theGroupName[0] ) {
1034         SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMeshWithGroup( "
1035                               << theSource << ".GetMesh(), " << theType << ", \"" << theGroupName << "\" )";
1036       }
1037       else {
1038         SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMesh( "
1039                               << theSource << ".GetMesh(), " << theType << " )";
1040       }
1041
1042       return res;
1043     }
1044     catch (const std::invalid_argument& ex) {
1045       SALOME::ExceptionStruct ExDescription;
1046       ExDescription.text = ex.what();
1047       ExDescription.type = SALOME::BAD_PARAM;
1048       ExDescription.sourceFile = "GHS3DPlugin_Hypothesis_i.cxx";
1049       ExDescription.lineNumber = 840;
1050       throw SALOME::SALOME_Exception(ExDescription);
1051     }
1052     catch (SALOME_Exception& ex) {
1053       THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
1054     }
1055   }
1056   else if (theGroup_i)// && types->length() == 1 && types[0] == theType)
1057   {
1058     MESSAGE("The source is a group")
1059       try {
1060         bool res = this->GetImpl()->SetEnforcedGroup(theGroup_i->GetGroupDS()->GetMesh(), theGroup_i->GetListOfID(), theType, enfMeshName , SObj->GetID(), theGroupName);
1061         if ( theGroupName && theGroupName[0] ) {
1062           SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMeshWithGroup( "
1063                                 << theSource << ", " << theType << ", \"" << theGroupName << "\" )";
1064         }
1065         else {
1066           SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMesh( "
1067                                 << theSource << ", " << theType << " )";
1068         }
1069         return res;
1070       }
1071       catch (const std::invalid_argument& ex) {
1072         SALOME::ExceptionStruct ExDescription;
1073       ExDescription.text = ex.what();
1074       ExDescription.type = SALOME::BAD_PARAM;
1075       ExDescription.sourceFile = "GHS3DPlugin_Hypothesis_i.cxx";
1076       ExDescription.lineNumber = 840;
1077       throw SALOME::SALOME_Exception(ExDescription);
1078     }
1079     catch (SALOME_Exception& ex) {
1080       THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
1081     }
1082   }
1083   else if (theGroupOnGeom_i)// && types->length() == 1 && types[0] == theType)
1084   {
1085     MESSAGE("The source is a group on geom")
1086     try {
1087         bool res = this->GetImpl()->SetEnforcedGroup(theGroupOnGeom_i->GetGroupDS()->GetMesh(),theGroupOnGeom_i->GetListOfID(), theType, enfMeshName , SObj->GetID(), theGroupName);
1088         if ( theGroupName && theGroupName[0] ) {
1089           SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMeshWithGroup( " 
1090                                 << theSource << ", " << theType << ", \"" << theGroupName << "\" )";
1091         }
1092         else {
1093           SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMesh( " 
1094                                 << theSource << ", " << theType << " )";
1095         }
1096       return res;
1097     }
1098     catch (const std::invalid_argument& ex) {
1099       SALOME::ExceptionStruct ExDescription;
1100       ExDescription.text = ex.what();
1101       ExDescription.type = SALOME::BAD_PARAM;
1102       ExDescription.sourceFile = "GHS3DPlugin_Hypothesis_i.cxx";
1103       ExDescription.lineNumber = 840;
1104       throw SALOME::SALOME_Exception(ExDescription);
1105     }
1106     catch (SALOME_Exception& ex) {
1107       THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
1108     }
1109   }
1110   return false;
1111 }
1112 //=============================================================================
1113 /*!
1114  *  Get implementation
1115  */
1116 //=============================================================================
1117
1118 ::GHS3DPlugin_Hypothesis* GHS3DPlugin_Hypothesis_i::GetImpl()
1119 {
1120   return (::GHS3DPlugin_Hypothesis*)myBaseImpl;
1121 }
1122
1123 //================================================================================
1124 /*!
1125  * \brief Verify whether hypothesis supports given entity type 
1126  */
1127 //================================================================================  
1128
1129 CORBA::Boolean GHS3DPlugin_Hypothesis_i::IsDimSupported( SMESH::Dimension type )
1130 {
1131   return type == SMESH::DIM_3D;
1132 }
1133