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