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