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