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