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