]> SALOME platform Git repositories - plugins/ghs3dplugin.git/blob - src/GHS3DPlugin/GHS3DPlugin_Hypothesis_i.cxx
Salome HOME
23352: [CEA] Order and naming of meshing algorithms
[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()->SetAdvancedOption(option);
364   SMESH::TPythonDump() << _this() << ".SetAdvancedOption( '" << 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()->GetAdvancedOption().c_str() );
375 }
376
377 //=======================================================================
378 //function : SetAdvancedOption
379 //=======================================================================
380
381 void GHS3DPlugin_Hypothesis_i::SetAdvancedOption(const char* option)
382 {
383   ASSERT(myBaseImpl);
384   this->GetImpl()->SetAdvancedOption(option);
385   SMESH::TPythonDump() << _this() << ".SetAdvancedOption( '" << option << "' )";
386 }
387
388 //=======================================================================
389 //function : GetAdvancedOption
390 //=======================================================================
391
392 char* GHS3DPlugin_Hypothesis_i::GetAdvancedOption()
393 {
394   ASSERT(myBaseImpl);
395   return CORBA::string_dup( this->GetImpl()->GetAdvancedOption().c_str() );
396 }
397
398 //=======================================================================
399 //function : SetToRemoveCentralPoint
400 //=======================================================================
401
402 void GHS3DPlugin_Hypothesis_i::SetGradation(CORBA::Double gradation)
403 {
404   ASSERT(myBaseImpl);
405   if (gradation != GetGradation()) {
406     this->GetImpl()->SetGradation(gradation);
407     SMESH::TPythonDump() << _this() << ".SetGradation( " << gradation << " )";
408   }
409 }
410
411 //=======================================================================
412 //function : GetToRemoveCentralPoint
413 //=======================================================================
414
415 CORBA::Double GHS3DPlugin_Hypothesis_i::GetGradation()
416 {
417   ASSERT(myBaseImpl);
418   return this->GetImpl()->GetGradation();
419 }
420
421 //=======================================================================
422 //function : SetStandardOutputLog
423 //=======================================================================
424
425 void GHS3DPlugin_Hypothesis_i::SetStandardOutputLog(CORBA::Boolean logInStandardOutput)
426 {
427   ASSERT(myBaseImpl);
428   this->GetImpl()->SetStandardOutputLog(logInStandardOutput);
429   SMESH::TPythonDump() << _this() << ".SetPrintLogInFile( " << !logInStandardOutput << " )";
430 }
431
432 //=======================================================================
433 //function : GetStandardOutputLog
434 //=======================================================================
435
436 CORBA::Boolean GHS3DPlugin_Hypothesis_i::GetStandardOutputLog()
437 {
438   ASSERT(myBaseImpl);
439   return this->GetImpl()->GetStandardOutputLog();
440 }
441
442 //=======================================================================
443 //function : SetRemoveLogOnSuccess
444 //=======================================================================
445
446 void GHS3DPlugin_Hypothesis_i::SetRemoveLogOnSuccess(CORBA::Boolean removeLogOnSuccess)
447 {
448   ASSERT(myBaseImpl);
449   this->GetImpl()->SetRemoveLogOnSuccess(removeLogOnSuccess);
450   SMESH::TPythonDump() << _this() << ".SetRemoveLogOnSuccess( " << removeLogOnSuccess << " )";
451 }
452
453 //=======================================================================
454 //function : GetRemoveLogOnSuccess
455 //=======================================================================
456
457 CORBA::Boolean GHS3DPlugin_Hypothesis_i::GetRemoveLogOnSuccess()
458 {
459   ASSERT(myBaseImpl);
460   return this->GetImpl()->GetRemoveLogOnSuccess();
461 }
462
463 //=======================================================================
464 //function : SetEnforcedVertex
465 //=======================================================================
466
467 bool GHS3DPlugin_Hypothesis_i::SetEnforcedVertex(CORBA::Double x, CORBA::Double y, CORBA::Double z, CORBA::Double size)
468     throw (SALOME::SALOME_Exception) {
469   ASSERT(myBaseImpl);
470   MESSAGE("IDL : SetEnforcedVertex( "<< x << ", " << y << ", " << z << ", " << size << ")");
471   return p_SetEnforcedVertex(size, x, y, z);
472 }
473
474 bool GHS3DPlugin_Hypothesis_i::SetEnforcedVertexNamed(CORBA::Double x, CORBA::Double y, CORBA::Double z, CORBA::Double size, const char* theVertexName)
475     throw (SALOME::SALOME_Exception) {
476   ASSERT(myBaseImpl);
477   MESSAGE("IDL : SetEnforcedVertexNamed( "<< x << ", " << y << ", " << z << ", " << size << ", " << theVertexName << ")");
478   return p_SetEnforcedVertex(size, x, y, z, theVertexName, "", "");
479 }
480
481 bool GHS3DPlugin_Hypothesis_i::SetEnforcedVertexWithGroup(CORBA::Double x, CORBA::Double y, CORBA::Double z, CORBA::Double size, const char* theGroupName)
482     throw (SALOME::SALOME_Exception) {
483   ASSERT(myBaseImpl);
484   MESSAGE("IDL : SetEnforcedVertexWithGroup( "<< x << ", " << y << ", " << z << ", " << size << ", " << theGroupName << ")");
485   return p_SetEnforcedVertex(size, x, y, z, "", "", theGroupName);
486 }
487
488 bool GHS3DPlugin_Hypothesis_i::SetEnforcedVertexNamedWithGroup(CORBA::Double x, CORBA::Double y, CORBA::Double z, CORBA::Double size, const char* theVertexName, const char* theGroupName)
489     throw (SALOME::SALOME_Exception) {
490   ASSERT(myBaseImpl);
491   MESSAGE("IDL : SetEnforcedVertexNamedWithGroup( "<< x << ", " << y << ", " << z << ", " << size << ", " << theVertexName << ", " << theGroupName << ")");
492   return p_SetEnforcedVertex(size, x, y, z, theVertexName, "", theGroupName);
493 }
494
495 bool GHS3DPlugin_Hypothesis_i::SetEnforcedVertexGeom(GEOM::GEOM_Object_ptr theVertex, CORBA::Double size)
496     throw (SALOME::SALOME_Exception) {
497   ASSERT(myBaseImpl);
498   
499   if ((theVertex->GetShapeType() != GEOM::VERTEX) && (theVertex->GetShapeType() != GEOM::COMPOUND)) {
500     MESSAGE("theVertex shape type is not VERTEX or COMPOUND");
501     THROW_SALOME_CORBA_EXCEPTION("theVertex shape type is not VERTEX or COMPOUND", SALOME::BAD_PARAM);
502   }
503   
504   string theVertexEntry = theVertex->GetStudyEntry();
505   CORBA::Double x = 0, y = 0, z = 0;
506   CORBA::Boolean isCompound = false;
507   GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine();
508   SMESH_Gen_i *smeshGen = SMESH_Gen_i::GetSMESHGen();
509   if (theVertexEntry.empty()) {
510     string aName;
511     if (theVertex->GetShapeType() == GEOM::VERTEX) {
512       aName = "Vertex_";
513     }
514     if (theVertex->GetShapeType() == GEOM::COMPOUND) {
515       aName = "Compound_";
516       isCompound = true;
517     }
518     aName += theVertex->GetEntry();
519     SALOMEDS::SObject_ptr theSVertex = geomGen->PublishInStudy(smeshGen->GetCurrentStudy(), NULL, theVertex, aName.c_str());
520     if (!theSVertex->_is_nil())
521       theVertexEntry = theSVertex->GetID();
522   }
523   if (theVertexEntry.empty())
524     THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM );
525
526   if (theVertex->GetShapeType() == GEOM::VERTEX) {
527     GEOM::GEOM_IMeasureOperations_var measureOp = geomGen->GetIMeasureOperations( smeshGen->GetCurrentStudy()->StudyId() );
528     if (CORBA::is_nil(measureOp))
529       return false;
530     
531     measureOp->PointCoordinates (theVertex, x, y, z);
532     MESSAGE("Point coordinates from measureOp: " << x << ", " << y << ", " << z);
533   }
534
535   string theVertexName = theVertex->GetName();
536   MESSAGE("IDL : SetEnforcedVertexGeom( "<< theVertexEntry << ", " << size<< ")");
537   
538   return p_SetEnforcedVertex(size, x, y, z, theVertexName.c_str(), theVertexEntry.c_str(), "", isCompound);
539 }
540
541 bool GHS3DPlugin_Hypothesis_i::SetEnforcedVertexGeomWithGroup(GEOM::GEOM_Object_ptr theVertex, CORBA::Double size, const char* theGroupName)
542     throw (SALOME::SALOME_Exception) {
543   ASSERT(myBaseImpl);
544   
545   if ((theVertex->GetShapeType() != GEOM::VERTEX) && (theVertex->GetShapeType() != GEOM::COMPOUND)) {
546     MESSAGE("theVertex shape type is not VERTEX or COMPOUND");
547     THROW_SALOME_CORBA_EXCEPTION("theVertex shape type is not VERTEX or COMPOUND", SALOME::BAD_PARAM);
548   }
549   
550   string theVertexEntry = theVertex->GetStudyEntry();
551   CORBA::Double x = 0, y = 0, z = 0;
552   CORBA::Boolean isCompound = false;
553   GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine();
554   SMESH_Gen_i *smeshGen = SMESH_Gen_i::GetSMESHGen();
555   if (theVertexEntry.empty()) {
556     string aName;
557     if (theVertex->GetShapeType() == GEOM::VERTEX) {
558       aName = "Vertex_";
559     }
560     if (theVertex->GetShapeType() == GEOM::COMPOUND) {
561       aName = "Compound_";
562       isCompound = true;
563     }
564     aName += theVertex->GetEntry();
565     SALOMEDS::SObject_ptr theSVertex = geomGen->PublishInStudy(smeshGen->GetCurrentStudy(), NULL, theVertex, aName.c_str());
566     if (!theSVertex->_is_nil())
567       theVertexEntry = theSVertex->GetID();
568   }
569   if (theVertexEntry.empty())
570     THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM );
571
572   if (theVertex->GetShapeType() == GEOM::VERTEX) {
573     GEOM::GEOM_IMeasureOperations_var measureOp = geomGen->GetIMeasureOperations( smeshGen->GetCurrentStudy()->StudyId() );
574     if (CORBA::is_nil(measureOp))
575       return false;
576     
577     measureOp->PointCoordinates (theVertex, x, y, z);
578     MESSAGE("Point coordinates from measureOp: " << x << ", " << y << ", " << z);
579   }
580     
581   string theVertexName = theVertex->GetName();
582   MESSAGE("IDL : SetEnforcedVertexGeomWithGroup( "<< theVertexEntry << ", " << size<< ", " << theGroupName << ")");
583   
584   return p_SetEnforcedVertex(size, x, y, z, theVertexName.c_str(), theVertexEntry.c_str(), theGroupName, isCompound);
585 }
586
587 bool GHS3DPlugin_Hypothesis_i:: p_SetEnforcedVertex(CORBA::Double size, CORBA::Double x, CORBA::Double y, CORBA::Double z,
588                                                    const char* theVertexName, const char* theVertexEntry, const char* theGroupName,
589                                                    CORBA::Boolean isCompound)
590     throw (SALOME::SALOME_Exception) {
591   ASSERT(myBaseImpl);
592   MESSAGE("IDL : p_SetEnforcedVertex(" << size << ", " << x << ", " << y << ", " << z << ", \"" << theVertexName << "\", \"" << theVertexEntry << "\", \"" << theGroupName << "\", " << isCompound<< ")");
593   bool newValue = false;
594
595   ::GHS3DPlugin_Hypothesis::TCoordsGHS3DEnforcedVertexMap coordsList;
596   ::GHS3DPlugin_Hypothesis::TGeomEntryGHS3DEnforcedVertexMap enfVertexEntryList;
597   if (string(theVertexEntry).empty()) {
598     coordsList = this->GetImpl()->_GetEnforcedVerticesByCoords();
599     std::vector<double> coords;
600     coords.push_back(x);
601     coords.push_back(y);
602     coords.push_back(z);
603     if (coordsList.find(coords) == coordsList.end()) {
604       MESSAGE("Coords not found: add it in coordsList");
605       newValue = true;
606     }
607     else {
608       MESSAGE("Coords already found, compare names");
609       ::GHS3DPlugin_Hypothesis::TGHS3DEnforcedVertex *enfVertex = this->GetImpl()->GetEnforcedVertex(x, y, z);
610       if ((enfVertex->name != theVertexName) || (enfVertex->groupName != theGroupName) || (enfVertex->size != size)) {
611         MESSAGE("The names or size are different: update");
612 //          this->GetImpl()->ClearEnforcedVertex(theFaceEntry, x, y, z);
613         newValue = true;
614       }
615       else {
616         MESSAGE("The names and size are identical");
617       }
618     }
619
620     if (newValue) {
621       if (string(theVertexName).empty()) {
622         if (string(theGroupName).empty())
623           SMESH::TPythonDump() << "isDone = " << _this() << ".SetEnforcedVertex(" << x << ", " << y << ", " << z << ", " << size << ")";
624         else
625           SMESH::TPythonDump() << "isDone = " << _this() << ".SetEnforcedVertexWithGroup(" << x << ", " << y << ", " << z << ", " << size << ", \"" << theGroupName << "\")";
626       }
627       else {
628         if (string(theGroupName).empty())
629           SMESH::TPythonDump() << "isDone = " << _this() << ".SetEnforcedVertexNamed(" << x << ", " << y << ", " << z << ", " << size  << ", \"" << theVertexName << "\")";
630         else
631           SMESH::TPythonDump() << "isDone = " << _this() << ".SetEnforcedVertexNamedWithGroup(" << x << ", " << y << ", " << z << ", " << size  << ", \"" << theVertexName << "\", \"" << theGroupName << "\")";
632       }
633     }
634   } 
635   else {
636 //   if (isCompound || (!isCompound && !string(theVertexEntry).empty())) {
637     enfVertexEntryList = this->GetImpl()->_GetEnforcedVerticesByEntry();
638 //     ::BLSURFPlugin_Hypothesis::TGeomEntryGHS3DEnforcedVertexMap::const_iterator it = enfVertexEntryList.find(theVertexEntry);
639     if ( enfVertexEntryList.find(theVertexEntry) == enfVertexEntryList.end()) {
640       MESSAGE("Geom entry not found: add it in enfVertexEntryList");
641       newValue = true;
642     }
643     else {
644       MESSAGE("Geom entry already found, compare names");
645       ::GHS3DPlugin_Hypothesis::TGHS3DEnforcedVertex *enfVertex = this->GetImpl()->GetEnforcedVertex(theVertexEntry);
646       if ((enfVertex->name != theVertexName) || (enfVertex->groupName != theGroupName) || (enfVertex->size != size)) {
647         MESSAGE("The names or size are different: update");
648 //          this->GetImpl()->ClearEnforcedVertex(theFaceEntry, x, y, z);
649         newValue = true;
650       }
651       else {
652         MESSAGE("The names and size are identical");
653       }
654     }
655
656     if (newValue) {
657       if (string(theGroupName).empty())
658         SMESH::TPythonDump() << "isDone = " << _this() << ".SetEnforcedVertexGeom(" << theVertexEntry << ", " << size << ")";
659       else
660         SMESH::TPythonDump() << "isDone = " << _this() << ".SetEnforcedVertexGeomWithGroup(" << theVertexEntry << ", " << size << ", \"" << theGroupName << "\")";
661     }
662   }
663
664   if (newValue)
665     this->GetImpl()->SetEnforcedVertex(theVertexName, theVertexEntry, theGroupName, size, x, y, z, isCompound);
666
667   MESSAGE("IDL : SetEnforcedVertexEntry END");
668   return newValue;
669 }
670
671 //=======================================================================
672 //function : GetEnforcedVertex
673 //=======================================================================
674
675 CORBA::Double GHS3DPlugin_Hypothesis_i::GetEnforcedVertex(CORBA::Double x, CORBA::Double y, CORBA::Double z)
676   throw (SALOME::SALOME_Exception)
677 {
678   ASSERT(myBaseImpl);
679   try {
680     bool isDone = this->GetImpl()->GetEnforcedVertex(x,y,z)->size;
681     SMESH::TPythonDump() << "aSize = " << _this() << ".GetEnforcedVertex(" << x << ", " << y << ", " << z << ")";
682     return isDone;
683   }
684   catch (const std::invalid_argument& ex) {
685     SALOME::ExceptionStruct ExDescription;
686     ExDescription.text = ex.what();
687     ExDescription.type = SALOME::BAD_PARAM;
688     ExDescription.sourceFile = "GHS3DPlugin_Hypothesis_i.cxx";
689     ExDescription.lineNumber = 513;
690     throw SALOME::SALOME_Exception(ExDescription);
691   }
692   catch (SALOME_Exception& ex) {
693     THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
694   }
695 }
696
697 //=======================================================================
698 //function : GetEnforcedVertex
699 //=======================================================================
700
701 CORBA::Double GHS3DPlugin_Hypothesis_i::GetEnforcedVertexGeom(GEOM::GEOM_Object_ptr theVertex)
702   throw (SALOME::SALOME_Exception)
703 {
704   ASSERT(myBaseImpl);
705   
706   if ((theVertex->GetShapeType() != GEOM::VERTEX) && (theVertex->GetShapeType() != GEOM::COMPOUND)) {
707     MESSAGE("theVertex shape type is not VERTEX or COMPOUND");
708     THROW_SALOME_CORBA_EXCEPTION("theVertex shape type is not VERTEX or COMPOUND", SALOME::BAD_PARAM);
709   }
710   
711   string theVertexEntry = theVertex->GetStudyEntry();
712   if (theVertexEntry.empty()) {
713     GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine();
714     SMESH_Gen_i *smeshGen = SMESH_Gen_i::GetSMESHGen();
715     string aName;
716     if (theVertex->GetShapeType() == GEOM::VERTEX)
717       aName = "Vertex_";
718     if (theVertex->GetShapeType() == GEOM::COMPOUND)
719       aName = "Compound_";
720     aName += theVertex->GetEntry();
721     SALOMEDS::SObject_ptr theSVertex = geomGen->PublishInStudy(smeshGen->GetCurrentStudy(), NULL, theVertex, aName.c_str());
722     if (!theSVertex->_is_nil())
723       theVertexEntry = theSVertex->GetID();
724   }
725   if (theVertexEntry.empty())
726     THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM );
727
728   string theVertexName = theVertex->GetName();
729   
730   try {
731     bool isDone = this->GetImpl()->GetEnforcedVertex(theVertexName)->size;
732     SMESH::TPythonDump() << "aSize = " << _this() << ".GetEnforcedVertexGeom(" << theVertex << ")";
733     return isDone;
734   }
735   catch (const std::invalid_argument& ex) {
736     SALOME::ExceptionStruct ExDescription;
737     ExDescription.text = ex.what();
738     ExDescription.type = SALOME::BAD_PARAM;
739     ExDescription.sourceFile = "GHS3DPlugin_Hypothesis_i.cxx";
740     ExDescription.lineNumber = 538;
741     throw SALOME::SALOME_Exception(ExDescription);
742   }
743   catch (SALOME_Exception& ex) {
744     THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
745   }
746 }
747
748 //=======================================================================
749 //function : GetEnforcedVertices
750 //=======================================================================
751
752 GHS3DPlugin::GHS3DEnforcedVertexList* GHS3DPlugin_Hypothesis_i::GetEnforcedVertices()
753 {
754   ASSERT(myBaseImpl);
755   GHS3DPlugin::GHS3DEnforcedVertexList_var result = new GHS3DPlugin::GHS3DEnforcedVertexList();
756
757   const ::GHS3DPlugin_Hypothesis::TGHS3DEnforcedVertexList enfVertexList = this->GetImpl()->_GetEnforcedVertices();
758   result->length( enfVertexList.size() );
759
760   ::GHS3DPlugin_Hypothesis::TGHS3DEnforcedVertexList::const_iterator it = enfVertexList.begin();
761
762   for (int i = 0 ; it != enfVertexList.end(); ++it, ++i ) {
763     ::GHS3DPlugin_Hypothesis::TGHS3DEnforcedVertex* currentVertex = (*it);
764     GHS3DPlugin::GHS3DEnforcedVertex_var enfVertex = new GHS3DPlugin::GHS3DEnforcedVertex();
765     // Name
766     enfVertex->name = CORBA::string_dup(currentVertex->name.c_str());
767     // Geom Vertex Entry
768     enfVertex->geomEntry = CORBA::string_dup(currentVertex->geomEntry.c_str());
769     // Coords
770     GHS3DPlugin::TCoords_var coords = new GHS3DPlugin::TCoords();
771     coords->length(currentVertex->coords.size());
772     for ( size_t ind = 0; ind < currentVertex->coords.size(); ind++)
773       coords[ind] = currentVertex->coords[ind];
774     enfVertex->coords = coords;
775     // Group Name
776     enfVertex->groupName = CORBA::string_dup(currentVertex->groupName.c_str());
777     // Size
778     enfVertex->size = currentVertex->size;
779     // isCompound
780     enfVertex->isCompound = currentVertex->isCompound;
781     
782     result[i]=enfVertex;
783     }
784   
785 //   SMESH::TPythonDump() << "allEnforcedVertices = " << _this() << ".GetEnforcedVertices()";
786
787   return result._retn();
788 }
789
790 //=======================================================================
791 //function : RemoveEnforcedVertex
792 //=======================================================================
793
794 bool GHS3DPlugin_Hypothesis_i::RemoveEnforcedVertex(CORBA::Double x, CORBA::Double y, CORBA::Double z)
795   throw (SALOME::SALOME_Exception)
796 {
797   ASSERT(myBaseImpl);
798   try {
799     bool res = this->GetImpl()->RemoveEnforcedVertex(x,y,z);
800     SMESH::TPythonDump() << " isDone = " << _this() << ".RemoveEnforcedVertex( " << x << ", " << y << ", " << z << " )";
801     return res;
802   }
803   catch (const std::invalid_argument& ex) {
804     SALOME::ExceptionStruct ExDescription;
805     ExDescription.text = ex.what();
806     ExDescription.type = SALOME::BAD_PARAM;
807     ExDescription.sourceFile = "GHS3DPlugin_Hypothesis_i.cxx";
808     ExDescription.lineNumber = 625;
809     throw SALOME::SALOME_Exception(ExDescription);
810   }
811   catch (SALOME_Exception& ex) {
812     THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
813   }
814 }
815
816 bool GHS3DPlugin_Hypothesis_i::RemoveEnforcedVertexGeom(GEOM::GEOM_Object_ptr theVertex)
817   throw (SALOME::SALOME_Exception)
818 {
819   ASSERT(myBaseImpl);
820   
821   if ((theVertex->GetShapeType() != GEOM::VERTEX) && (theVertex->GetShapeType() != GEOM::COMPOUND)) {
822     MESSAGE("theVertex shape type is not VERTEX or COMPOUND");
823     THROW_SALOME_CORBA_EXCEPTION("theVertex shape type is not VERTEX or COMPOUND", SALOME::BAD_PARAM);
824   }
825   
826   string theVertexEntry = theVertex->GetStudyEntry();
827   if (theVertexEntry.empty()) {
828     GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine();
829     SMESH_Gen_i *smeshGen = SMESH_Gen_i::GetSMESHGen();
830     string aName;
831     if (theVertex->GetShapeType() == GEOM::VERTEX)
832       aName = "Vertex_";
833     if (theVertex->GetShapeType() == GEOM::COMPOUND)
834       aName = "Compound_";
835     aName += theVertex->GetEntry();
836     SALOMEDS::SObject_ptr theSVertex = geomGen->PublishInStudy(smeshGen->GetCurrentStudy(), NULL, theVertex, aName.c_str());
837     if (!theSVertex->_is_nil())
838       theVertexEntry = theSVertex->GetID();
839   }
840   if (theVertexEntry.empty())
841     THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM );
842   
843   try {
844     bool res = this->GetImpl()->RemoveEnforcedVertex(0,0,0, theVertexEntry.c_str());
845     SMESH::TPythonDump() << "isDone = " << _this() << ".RemoveEnforcedVertexGeom( " << theVertexEntry.c_str() << " )";
846     return res;
847   }
848   catch (const std::invalid_argument& ex) {
849     SALOME::ExceptionStruct ExDescription;
850     ExDescription.text = ex.what();
851     ExDescription.type = SALOME::BAD_PARAM;
852     ExDescription.sourceFile = "GHS3DPlugin_Hypothesis_i.cxx";
853     ExDescription.lineNumber = 648;
854     throw SALOME::SALOME_Exception(ExDescription);
855   }
856   catch (SALOME_Exception& ex) {
857     THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
858   }
859 }
860
861 //=======================================================================
862 //function : ClearEnforcedVertices
863 //=======================================================================
864
865 void GHS3DPlugin_Hypothesis_i::ClearEnforcedVertices()
866 {
867   ASSERT(myBaseImpl);
868   this->GetImpl()->ClearEnforcedVertices();
869   SMESH::TPythonDump () << _this() << ".ClearEnforcedVertices() ";
870 }
871
872 //=======================================================================
873 //function : ClearEnforcedMeshes
874 //=======================================================================
875
876 void GHS3DPlugin_Hypothesis_i::ClearEnforcedMeshes()
877 {
878   ASSERT(myBaseImpl);
879   this->GetImpl()->ClearEnforcedMeshes();
880   SMESH::TPythonDump () << _this() << ".ClearEnforcedMeshes() ";
881 }
882
883 //=======================================================================
884 //function : GetEnforcedMeshes
885 //=======================================================================
886
887 GHS3DPlugin::GHS3DEnforcedMeshList* GHS3DPlugin_Hypothesis_i::GetEnforcedMeshes()
888 {
889   ASSERT(myBaseImpl);
890   GHS3DPlugin::GHS3DEnforcedMeshList_var result = new GHS3DPlugin::GHS3DEnforcedMeshList();
891
892   const ::GHS3DPlugin_Hypothesis::TGHS3DEnforcedMeshList enfMeshList = this->GetImpl()->_GetEnforcedMeshes();
893   result->length( enfMeshList.size() );
894
895   ::GHS3DPlugin_Hypothesis::TGHS3DEnforcedMeshList::const_iterator it = enfMeshList.begin();
896
897   for (int i = 0 ; it != enfMeshList.end(); ++it, ++i ) {
898     ::GHS3DPlugin_Hypothesis::TGHS3DEnforcedMesh* currentMesh = (*it);
899     GHS3DPlugin::GHS3DEnforcedMesh_var enfMesh = new GHS3DPlugin::GHS3DEnforcedMesh();
900     // Name
901     enfMesh->name = CORBA::string_dup(currentMesh->name.c_str());
902     // Mesh Entry
903     enfMesh->entry = CORBA::string_dup(currentMesh->entry.c_str());
904     // isCompound
905     enfMesh->elementType = currentMesh->elementType;
906     // Group Name
907     enfMesh->groupName = CORBA::string_dup(currentMesh->groupName.c_str());
908     
909     result[i]=enfMesh;
910     }
911   
912 //   SMESH::TPythonDump() << "allEnforcedVertices = " << _this() << ".GetEnforcedVertices()";
913
914   return result._retn();
915 }
916
917 /*!
918  * \brief Adds enforced elements of type elementType using another mesh/sub-mesh/mesh group theSource. The elements will be grouped in theGroupName.
919  */
920 bool GHS3DPlugin_Hypothesis_i::SetEnforcedMeshWithGroup(SMESH::SMESH_IDSource_ptr theSource, SMESH::ElementType theType, const char* theGroupName)
921   throw (SALOME::SALOME_Exception)
922 {
923 // #if GHS3D_VERSION >= 42
924   return p_SetEnforcedMesh(theSource, theType, "", theGroupName);
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 = 719;
931 //   throw SALOME::SALOME_Exception(ExDescription);
932 // #endif
933 }
934
935 /*!
936  * \brief Adds enforced elements of type elementType using another mesh/sub-mesh/mesh group theSource.
937  */
938 bool GHS3DPlugin_Hypothesis_i::SetEnforcedMesh(SMESH::SMESH_IDSource_ptr theSource, SMESH::ElementType theType)
939   throw (SALOME::SALOME_Exception)
940 {
941 //   MESSAGE("GHS3DPlugin_Hypothesis_i::SetEnforcedMesh");
942 // #if GHS3D_VERSION >= 42
943   return p_SetEnforcedMesh(theSource, theType);
944 // #else
945 //   SALOME::ExceptionStruct ExDescription;
946 //   ExDescription.text = "Bad version of GHS3D. It must >= 4.2.";
947 //   ExDescription.type = SALOME::BAD_PARAM;
948 //   ExDescription.sourceFile = "GHS3DPlugin_Hypothesis_i.cxx";
949 //   ExDescription.lineNumber = 750;
950 //   throw SALOME::SALOME_Exception(ExDescription);
951 // #endif
952 }
953
954 /*!
955  * \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.
956  */
957 bool GHS3DPlugin_Hypothesis_i::SetEnforcedMeshSizeWithGroup(SMESH::SMESH_IDSource_ptr theSource, SMESH::ElementType theType, double theSize, const char* theGroupName)
958   throw (SALOME::SALOME_Exception)
959 {
960 // #if GHS3D_VERSION >= 42
961   return p_SetEnforcedMesh(theSource, theType, "", theGroupName);
962 // #else
963 //   SALOME::ExceptionStruct ExDescription;
964 //   ExDescription.text = "Bad version of GHS3D. It must >= 4.2.";
965 //   ExDescription.type = SALOME::BAD_PARAM;
966 //   ExDescription.sourceFile = "GHS3DPlugin_Hypothesis_i.cxx";
967 //   ExDescription.lineNumber = 750;
968 //   throw SALOME::SALOME_Exception(ExDescription);
969 // #endif
970 }
971
972 /*!
973  * \brief OBSOLETE FUNCTION - Adds enforced elements of type elementType using another mesh/sub-mesh/mesh group theSource and a size.
974  */
975 bool GHS3DPlugin_Hypothesis_i::SetEnforcedMeshSize(SMESH::SMESH_IDSource_ptr theSource, SMESH::ElementType theType, double theSize)
976   throw (SALOME::SALOME_Exception)
977 {
978 // #if GHS3D_VERSION >= 42
979   return p_SetEnforcedMesh(theSource, theType);
980 // #else
981 //   SALOME::ExceptionStruct ExDescription;
982 //   ExDescription.text = "Bad version of GHS3D. It must >= 4.2.";
983 //   ExDescription.type = SALOME::BAD_PARAM;
984 //   ExDescription.sourceFile = "GHS3DPlugin_Hypothesis_i.cxx";
985 //   ExDescription.lineNumber = 750;
986 //   throw SALOME::SALOME_Exception(ExDescription);
987 // #endif
988 }
989
990 bool GHS3DPlugin_Hypothesis_i::p_SetEnforcedMesh(SMESH::SMESH_IDSource_ptr theSource, SMESH::ElementType theType, const char* theName, const char* theGroupName)
991   throw (SALOME::SALOME_Exception)
992 {
993   MESSAGE("GHS3DPlugin_Hypothesis_i::p_SetEnforcedMesh");
994   ASSERT(myBaseImpl);
995   
996   if (CORBA::is_nil( theSource ))
997   {
998     SALOME::ExceptionStruct ExDescription;
999     ExDescription.text = "The source mesh CORBA object is NULL";
1000     ExDescription.type = SALOME::BAD_PARAM;
1001     ExDescription.sourceFile = "GHS3DPlugin_Hypothesis_i.cxx";
1002     ExDescription.lineNumber = 840;
1003     throw SALOME::SALOME_Exception(ExDescription);
1004   }
1005   
1006   switch (theType) {
1007     case SMESH::NODE:
1008       MESSAGE("Required type is NODE");
1009       break;
1010     case SMESH::EDGE:
1011       MESSAGE("Required type is EDGE");
1012       break;
1013     case SMESH::FACE:
1014       MESSAGE("Required type is FACE");
1015       break;
1016     default:
1017         MESSAGE("Incompatible required type: " << theType);
1018         return false;
1019   }
1020 //   MESSAGE("Required type is "<<theType);
1021   SMESH::array_of_ElementType_var types = theSource->GetTypes();
1022   MESSAGE("Available types:");
1023   for ( CORBA::ULong i=0;i<types->length();i++){MESSAGE(types[i]);}
1024   if ( types->length() >= 1 && types[types->length()-1] <  theType)
1025   {
1026     MESSAGE("Required type not available");
1027     return false;
1028 //     SALOME::ExceptionStruct ExDescription;
1029 //     ExDescription.text = "The source mesh has bad type";
1030 //     ExDescription.type = SALOME::BAD_PARAM;
1031 //     ExDescription.sourceFile = "GHS3DPlugin_Hypothesis_i.cxx";
1032 //     ExDescription.lineNumber = 840;
1033 //     throw SALOME::SALOME_Exception(ExDescription);
1034   }
1035   
1036
1037   SMESH_Gen_i *smeshGen = SMESH_Gen_i::GetSMESHGen();
1038   SALOMEDS::SObject_ptr SObj = smeshGen->ObjectToSObject(smeshGen->GetCurrentStudy(),theSource);
1039
1040   SMESH_Mesh_i* theMesh_i = SMESH::DownCast<SMESH_Mesh_i*>( theSource);
1041   SMESH_Group_i* theGroup_i = SMESH::DownCast<SMESH_Group_i*>( theSource);
1042   SMESH_GroupOnGeom_i* theGroupOnGeom_i = SMESH::DownCast<SMESH_GroupOnGeom_i*>( theSource);
1043
1044   string enfMeshName = theName;
1045   if (enfMeshName.empty())
1046     enfMeshName = SObj->GetName();
1047
1048   if (theMesh_i)
1049   {
1050     try {
1051       bool res = this->GetImpl()->SetEnforcedMesh(theMesh_i->GetImpl(), theType, enfMeshName , SObj->GetID(), theGroupName);
1052       if (theGroupName && theGroupName[0] ) {
1053         SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMeshWithGroup( "
1054                               << theSource << ".GetMesh(), " << theType << ", \"" << theGroupName << "\" )";
1055       }
1056       else {
1057         SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMesh( "
1058                               << theSource << ".GetMesh(), " << theType << " )";
1059       }
1060
1061       return res;
1062     }
1063     catch (const std::invalid_argument& ex) {
1064       SALOME::ExceptionStruct ExDescription;
1065       ExDescription.text = ex.what();
1066       ExDescription.type = SALOME::BAD_PARAM;
1067       ExDescription.sourceFile = "GHS3DPlugin_Hypothesis_i.cxx";
1068       ExDescription.lineNumber = 840;
1069       throw SALOME::SALOME_Exception(ExDescription);
1070     }
1071     catch (SALOME_Exception& ex) {
1072       THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
1073     }
1074   }
1075   else if (theGroup_i)// && types->length() == 1 && types[0] == theType)
1076   {
1077     MESSAGE("The source is a group")
1078       try {
1079         bool res = this->GetImpl()->SetEnforcedGroup(theGroup_i->GetGroupDS()->GetMesh(), theGroup_i->GetListOfID(), theType, enfMeshName , SObj->GetID(), theGroupName);
1080         if ( theGroupName && theGroupName[0] ) {
1081           SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMeshWithGroup( "
1082                                 << theSource << ", " << theType << ", \"" << theGroupName << "\" )";
1083         }
1084         else {
1085           SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMesh( "
1086                                 << theSource << ", " << theType << " )";
1087         }
1088         return res;
1089       }
1090       catch (const std::invalid_argument& ex) {
1091         SALOME::ExceptionStruct ExDescription;
1092       ExDescription.text = ex.what();
1093       ExDescription.type = SALOME::BAD_PARAM;
1094       ExDescription.sourceFile = "GHS3DPlugin_Hypothesis_i.cxx";
1095       ExDescription.lineNumber = 840;
1096       throw SALOME::SALOME_Exception(ExDescription);
1097     }
1098     catch (SALOME_Exception& ex) {
1099       THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
1100     }
1101   }
1102   else if (theGroupOnGeom_i)// && types->length() == 1 && types[0] == theType)
1103   {
1104     MESSAGE("The source is a group on geom")
1105     try {
1106         bool res = this->GetImpl()->SetEnforcedGroup(theGroupOnGeom_i->GetGroupDS()->GetMesh(),theGroupOnGeom_i->GetListOfID(), theType, enfMeshName , SObj->GetID(), theGroupName);
1107         if ( theGroupName && theGroupName[0] ) {
1108           SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMeshWithGroup( " 
1109                                 << theSource << ", " << theType << ", \"" << theGroupName << "\" )";
1110         }
1111         else {
1112           SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMesh( " 
1113                                 << theSource << ", " << theType << " )";
1114         }
1115       return res;
1116     }
1117     catch (const std::invalid_argument& ex) {
1118       SALOME::ExceptionStruct ExDescription;
1119       ExDescription.text = ex.what();
1120       ExDescription.type = SALOME::BAD_PARAM;
1121       ExDescription.sourceFile = "GHS3DPlugin_Hypothesis_i.cxx";
1122       ExDescription.lineNumber = 840;
1123       throw SALOME::SALOME_Exception(ExDescription);
1124     }
1125     catch (SALOME_Exception& ex) {
1126       THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
1127     }
1128   }
1129   return false;
1130 }
1131 //=============================================================================
1132 /*!
1133  *  Get implementation
1134  */
1135 //=============================================================================
1136
1137 ::GHS3DPlugin_Hypothesis* GHS3DPlugin_Hypothesis_i::GetImpl()
1138 {
1139   return (::GHS3DPlugin_Hypothesis*)myBaseImpl;
1140 }
1141
1142 //================================================================================
1143 /*!
1144  * \brief Verify whether hypothesis supports given entity type 
1145  */
1146 //================================================================================  
1147
1148 CORBA::Boolean GHS3DPlugin_Hypothesis_i::IsDimSupported( SMESH::Dimension type )
1149 {
1150   return type == SMESH::DIM_3D;
1151 }
1152