Salome HOME
Copyright update 2022
[plugins/hybridplugin.git] / src / HYBRIDPlugin / HYBRIDPlugin_Hypothesis_i.cxx
1 // Copyright (C) 2007-2022  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   myBaseImpl = new ::HYBRIDPlugin_Hypothesis (theGenImpl->GetANewId(),
57                                               theGenImpl);
58 }
59
60 //=======================================================================
61 //function : ~HYBRIDPlugin_Hypothesis_i
62 //=======================================================================
63 HYBRIDPlugin_Hypothesis_i::~HYBRIDPlugin_Hypothesis_i()
64 {
65 }
66
67 //=======================================================================
68 /*!
69  * Sizes of boundary layers are relative to the surface size. Default no
70  */
71 //=======================================================================
72
73 void HYBRIDPlugin_Hypothesis_i::SetHeightIsRelative( CORBA::Boolean isRelative )
74 {
75   ASSERT(myBaseImpl);
76   if ( GetImpl()->GetHeightIsRelative() != isRelative )
77   {
78     this->GetImpl()->SetHeightIsRelative( isRelative );
79     SMESH::TPythonDump() << _this() << ".SetHeightIsRelative( " << isRelative << " )";
80   }
81 }
82
83 CORBA::Boolean HYBRIDPlugin_Hypothesis_i::GetHeightIsRelative()
84 {
85   return this->GetImpl()->GetHeightIsRelative();
86 }
87
88 //=======================================================================
89 /*!
90  * Maximum internal angles of boundary elements (in degree)
91  */
92 //=======================================================================
93
94 void HYBRIDPlugin_Hypothesis_i::SetBoundaryLayersMaxElemAngle( CORBA::Double angle )
95 {
96   if ( GetImpl()->GetBoundaryLayersMaxElemAngle() != angle )
97   {
98     this->GetImpl()->SetBoundaryLayersMaxElemAngle( angle );
99     SMESH::TPythonDump() << _this() << ".SetBoundaryLayersMaxElemAngle( " << angle << " )";
100   }
101 }
102
103 CORBA::Double HYBRIDPlugin_Hypothesis_i::GetBoundaryLayersMaxElemAngle()
104 {
105   return this->GetImpl()->GetBoundaryLayersMaxElemAngle();
106 }
107
108 //=======================================================================
109 //function : SetLayersOnAllWrap
110 //=======================================================================
111
112 void HYBRIDPlugin_Hypothesis_i::SetLayersOnAllWrap(CORBA::Boolean toMesh)
113 {
114   ASSERT(myBaseImpl);
115   this->GetImpl()->SetLayersOnAllWrap(toMesh);
116   SMESH::TPythonDump() << _this() << ".SetLayersOnAllWrap( " << toMesh << " )";
117 }
118
119 //=======================================================================
120 //function : GetLayersOnAllWrap
121 //=======================================================================
122
123 CORBA::Boolean HYBRIDPlugin_Hypothesis_i::GetLayersOnAllWrap()
124 {
125   ASSERT(myBaseImpl);
126   return this->GetImpl()->GetLayersOnAllWrap();
127 }
128
129 //=======================================================================
130 //function : SetFacesWithLayers
131 //=======================================================================
132
133 void HYBRIDPlugin_Hypothesis_i::SetFacesWithLayers(const ::SMESH::long_array& theVal)
134 {
135   std::vector<int> ids( theVal.length() );
136   for ( size_t i = 0; i < ids.size(); ++i )
137    ids[i] = theVal[i];
138
139   bool valueChanged = this->GetImpl()->SetFacesWithLayers(ids);
140   if (valueChanged)
141     SMESH::TPythonDump() << _this() << ".SetFacesWithLayers( "<< theVal << " )";
142 }
143
144 //=======================================================================
145 //function : GetFacesWithLayers
146 //=======================================================================
147
148 SMESH::long_array* HYBRIDPlugin_Hypothesis_i::GetFacesWithLayers()
149 {
150   const std::vector<int>& idsVec = this->GetImpl()->GetFacesWithLayers();
151   SMESH::long_array_var ids = new SMESH::long_array;
152   ids->length( idsVec.size() );
153   for ( size_t i = 0; i < idsVec.size(); ++i )
154     ids[i] = idsVec[i];
155   return ids._retn();
156 }
157
158 //=======================================================================
159 //function : SetFacesWithImprinting
160 //=======================================================================
161
162 void HYBRIDPlugin_Hypothesis_i::SetFacesWithImprinting(const ::SMESH::long_array& theVal)
163 {
164   std::vector<int> ids( theVal.length() );
165   for ( size_t i = 0; i < ids.size(); ++i )
166    ids[i] = theVal[i];
167
168   bool valueChanged = this->GetImpl()->SetFacesWithImprinting(ids);
169   if (valueChanged)
170     SMESH::TPythonDump() << _this() << ".SetFacesWithImprinting( "<< theVal << " )";
171 }
172
173 //=======================================================================
174 //function : GetFacesWithImprinting
175 //=======================================================================
176
177 SMESH::long_array* HYBRIDPlugin_Hypothesis_i::GetFacesWithImprinting()
178 {
179   const std::vector<int>& idsVec = this->GetImpl()->GetFacesWithImprinting();
180   SMESH::long_array_var ids = new SMESH::long_array;
181   ids->length( idsVec.size() );
182   for ( size_t i = 0; i < idsVec.size(); ++i )
183     ids[i] = idsVec[i];
184   return ids._retn();
185 }
186
187 //=======================================================================
188 //function : SetFacesWithSnapping
189 //=======================================================================
190
191 void HYBRIDPlugin_Hypothesis_i::SetFacesWithSnapping(const ::SMESH::long_array& theVal)
192 {
193   std::vector<int> ids( theVal.length() );
194   for ( size_t i = 0; i < ids.size(); ++i )
195    ids[i] = theVal[i];
196
197   bool valueChanged = this->GetImpl()->SetFacesWithSnapping(ids);
198   if (valueChanged)
199     SMESH::TPythonDump() << _this() << ".SetFacesWithSnapping( "<< theVal << " )";
200 }
201
202 //=======================================================================
203 //function : GetFacesWithSnapping
204 //=======================================================================
205
206 SMESH::long_array* HYBRIDPlugin_Hypothesis_i::GetFacesWithSnapping()
207 {
208   const std::vector<int>& idsVec = this->GetImpl()->GetFacesWithSnapping();
209   SMESH::long_array_var ids = new SMESH::long_array;
210   ids->length( idsVec.size() );
211   for ( size_t i = 0; i < idsVec.size(); ++i )
212     ids[i] = idsVec[i];
213   return ids._retn();
214 }
215
216 //=======================================================================
217 //function : SetToMeshHoles
218 //=======================================================================
219
220 void HYBRIDPlugin_Hypothesis_i::SetToMeshHoles(CORBA::Boolean toMesh)
221 {
222   ASSERT(myBaseImpl);
223   this->GetImpl()->SetToMeshHoles(toMesh);
224   SMESH::TPythonDump() << _this() << ".SetToMeshHoles( " << toMesh << " )";
225 }
226
227 //=======================================================================
228 //function : GetToMeshHoles
229 //=======================================================================
230
231 CORBA::Boolean HYBRIDPlugin_Hypothesis_i::GetToMeshHoles()
232 {
233   ASSERT(myBaseImpl);
234   return this->GetImpl()->GetToMeshHoles();
235 }
236
237 //=======================================================================
238 //function : SetToMakeGroupsOfDomains
239 //=======================================================================
240
241 void HYBRIDPlugin_Hypothesis_i::SetToMakeGroupsOfDomains(CORBA::Boolean toMakeGroups)
242 {
243   ASSERT(myBaseImpl);
244   this->GetImpl()->SetToMakeGroupsOfDomains(toMakeGroups);
245   SMESH::TPythonDump() << _this() << ".SetToMakeGroupsOfDomains( " << toMakeGroups << " )";
246 }
247
248 //=======================================================================
249 //function : GetToMakeGroupsOfDomains
250 //=======================================================================
251
252 CORBA::Boolean HYBRIDPlugin_Hypothesis_i::GetToMakeGroupsOfDomains()
253 {
254   ASSERT(myBaseImpl);
255   return this->GetImpl()->GetToMakeGroupsOfDomains();
256 }
257
258 //=======================================================================
259 //function : SetMaximumMemory
260 //=======================================================================
261
262 void HYBRIDPlugin_Hypothesis_i::SetMaximumMemory(CORBA::Double MB)
263 {
264   if ( MB == 0 )
265     THROW_SALOME_CORBA_EXCEPTION( "Invalid memory size",SALOME::BAD_PARAM );
266   ASSERT(myBaseImpl);
267   this->GetImpl()->SetMaximumMemory(MB);
268   SMESH::TPythonDump() << _this() << ".SetMaximumMemory( " << MB << " )";
269 }
270
271 //=======================================================================
272 //function : GetMaximumMemory
273 //=======================================================================
274
275 CORBA::Double HYBRIDPlugin_Hypothesis_i::GetMaximumMemory()
276 {
277   ASSERT(myBaseImpl);
278   return this->GetImpl()->GetMaximumMemory();
279 }
280
281 //=======================================================================
282 //function : SetInitialMemory
283 //=======================================================================
284
285 void HYBRIDPlugin_Hypothesis_i::SetInitialMemory(CORBA::Double MB)
286 {
287   if ( MB == 0 )
288     THROW_SALOME_CORBA_EXCEPTION( "Invalid memory size",SALOME::BAD_PARAM );
289   ASSERT(myBaseImpl);
290   this->GetImpl()->SetInitialMemory(MB);
291   SMESH::TPythonDump() << _this() << ".SetInitialMemory( " << MB << " )";
292 }
293
294 //=======================================================================
295 //function : GetInitialMemory
296 //=======================================================================
297
298 CORBA::Double HYBRIDPlugin_Hypothesis_i::GetInitialMemory()
299 {
300   ASSERT(myBaseImpl);
301   return this->GetImpl()->GetInitialMemory();
302 }
303
304 //=======================================================================
305 //function : SetOptimizationLevel
306 //=======================================================================
307
308 void HYBRIDPlugin_Hypothesis_i::SetOptimizationLevel(CORBA::Short level)
309 {
310   ::HYBRIDPlugin_Hypothesis::OptimizationLevel l =
311       (::HYBRIDPlugin_Hypothesis::OptimizationLevel) level;
312   if ( l < ::HYBRIDPlugin_Hypothesis::None ||
313        l > ::HYBRIDPlugin_Hypothesis::Strong )
314     THROW_SALOME_CORBA_EXCEPTION( "Invalid optimization level",SALOME::BAD_PARAM );
315     
316   ASSERT(myBaseImpl);
317   this->GetImpl()->SetOptimizationLevel(l);
318   SMESH::TPythonDump() << _this() << ".SetOptimizationLevel( " << level << " )";
319 }
320
321 //=======================================================================
322 //function : GetOptimizationLevel
323 //=======================================================================
324
325 CORBA::Short HYBRIDPlugin_Hypothesis_i::GetOptimizationLevel()
326 {
327   ASSERT(myBaseImpl);
328   return this->GetImpl()->GetOptimizationLevel();
329 }
330
331
332 //=======================================================================
333 //function : SetCollisionMode
334 //=======================================================================
335 void HYBRIDPlugin_Hypothesis_i::SetCollisionMode(CORBA::Short level)
336 {
337   ::HYBRIDPlugin_Hypothesis::CollisionMode l =
338       (::HYBRIDPlugin_Hypothesis::CollisionMode) level;
339   if ( l < ::HYBRIDPlugin_Hypothesis::Decrease ||
340        l > ::HYBRIDPlugin_Hypothesis::Stop )
341     THROW_SALOME_CORBA_EXCEPTION( "Invalid collision mode",SALOME::BAD_PARAM );
342     
343   ASSERT(myBaseImpl);
344   this->GetImpl()->SetCollisionMode(l);
345   SMESH::TPythonDump() << _this() << ".SetCollisionMode( " << level << " )";
346 }
347
348 //=======================================================================
349 //function : GetCollisionMode
350 //=======================================================================
351 CORBA::Short HYBRIDPlugin_Hypothesis_i::GetCollisionMode()
352 {
353   ASSERT(myBaseImpl);
354   return this->GetImpl()->GetCollisionMode();
355 }
356
357 //=======================================================================
358 //function : SetWorkingDirectory
359 //=======================================================================
360 void HYBRIDPlugin_Hypothesis_i::SetWorkingDirectory(const char* path)
361 {
362   if (!path )
363     THROW_SALOME_CORBA_EXCEPTION( "Null working directory",SALOME::BAD_PARAM );
364
365   std::string file(path);
366   const char lastChar = *file.rbegin();
367 #ifdef WIN32
368   if ( lastChar != '\\' ) file += '\\';
369 #else
370   if ( lastChar != '/' ) file += '/';
371 #endif
372   file += "HYBRID.log";
373   SMESH_Mesh_i::PrepareForWriting (file.c_str());
374
375   ASSERT(myBaseImpl);
376   this->GetImpl()->SetWorkingDirectory(path);
377   SMESH::TPythonDump() << _this() << ".SetWorkingDirectory( '" << path << "' )";
378 }
379
380 //=======================================================================
381 //function : GetWorkingDirectory
382 //=======================================================================
383 char* HYBRIDPlugin_Hypothesis_i::GetWorkingDirectory()
384 {
385   ASSERT(myBaseImpl);
386   return CORBA::string_dup( this->GetImpl()->GetWorkingDirectory().c_str() );
387 }
388
389 //=======================================================================
390 //function : SetKeepFiles
391 //=======================================================================
392 void HYBRIDPlugin_Hypothesis_i::SetKeepFiles(CORBA::Boolean toKeep)
393 {
394   ASSERT(myBaseImpl);
395   this->GetImpl()->SetKeepFiles(toKeep);
396   SMESH::TPythonDump() << _this() << ".SetKeepFiles( " << toKeep << " )";
397 }
398
399 //=======================================================================
400 //function : GetKeepFiles
401 //=======================================================================
402 CORBA::Boolean HYBRIDPlugin_Hypothesis_i::GetKeepFiles()
403 {
404   ASSERT(myBaseImpl);
405   return this->GetImpl()->GetKeepFiles();
406 }
407
408 //=======================================================================
409 //function : SetVerboseLevel
410 //=======================================================================
411 void HYBRIDPlugin_Hypothesis_i::SetVerboseLevel(CORBA::Short level)
412 {
413   if (level < 0 || level > 10 )
414     THROW_SALOME_CORBA_EXCEPTION( "Invalid verbose level, valid range is [0-10]",
415                                   SALOME::BAD_PARAM );
416   ASSERT(myBaseImpl);
417   this->GetImpl()->SetVerboseLevel(level);
418   SMESH::TPythonDump() << _this() << ".SetVerboseLevel( " << level << " )";
419 }
420
421 //=======================================================================
422 //function : GetVerboseLevel
423 //=======================================================================
424 CORBA::Short HYBRIDPlugin_Hypothesis_i::GetVerboseLevel()
425 {
426   ASSERT(myBaseImpl);
427   return this->GetImpl()->GetVerboseLevel();
428 }
429
430 //=======================================================================
431 //function : SetToCreateNewNodes
432 //=======================================================================
433
434 void HYBRIDPlugin_Hypothesis_i::SetToCreateNewNodes(CORBA::Boolean toCreate)
435 {
436   ASSERT(myBaseImpl);
437   this->GetImpl()->SetToCreateNewNodes(toCreate);
438   SMESH::TPythonDump() << _this() << ".SetToCreateNewNodes( " << toCreate << " )";
439 }
440
441 //=======================================================================
442 //function : GetToCreateNewNodes
443 //=======================================================================
444
445 CORBA::Boolean HYBRIDPlugin_Hypothesis_i::GetToCreateNewNodes()
446 {
447   ASSERT(myBaseImpl);
448   return this->GetImpl()->GetToCreateNewNodes();
449 }
450
451 //=======================================================================
452 //function : SetToUseBoundaryRecoveryVersion
453 //=======================================================================
454
455 void HYBRIDPlugin_Hypothesis_i::SetToUseBoundaryRecoveryVersion(CORBA::Boolean toUse)
456 {
457   ASSERT(myBaseImpl);
458   this->GetImpl()->SetToUseBoundaryRecoveryVersion(toUse);
459   SMESH::TPythonDump() << _this() << ".SetToUseBoundaryRecoveryVersion( " << toUse << " )";
460 }
461
462 //=======================================================================
463 //function : GetToUseBoundaryRecoveryVersion
464 //=======================================================================
465
466 CORBA::Boolean HYBRIDPlugin_Hypothesis_i::GetToUseBoundaryRecoveryVersion()
467 {
468   ASSERT(myBaseImpl);
469   return this->GetImpl()->GetToUseBoundaryRecoveryVersion();
470 }
471
472 //=======================================================================
473 //function : SetFEMCorrection
474 //=======================================================================
475
476 void HYBRIDPlugin_Hypothesis_i::SetFEMCorrection(CORBA::Boolean toUseFem)
477 {
478   ASSERT(myBaseImpl);
479   this->GetImpl()->SetFEMCorrection(toUseFem);
480   SMESH::TPythonDump() << _this() << ".SetFEMCorrection( " << toUseFem << " )";
481 }
482
483 //=======================================================================
484 //function : GetFEMCorrection
485 //=======================================================================
486
487 CORBA::Boolean HYBRIDPlugin_Hypothesis_i::GetFEMCorrection()
488 {
489   ASSERT(myBaseImpl);
490   return this->GetImpl()->GetFEMCorrection();
491 }
492
493 //=======================================================================
494 //function : SetToRemoveCentralPoint
495 //=======================================================================
496
497 void HYBRIDPlugin_Hypothesis_i::SetToRemoveCentralPoint(CORBA::Boolean toRemove)
498 {
499   ASSERT(myBaseImpl);
500   this->GetImpl()->SetToRemoveCentralPoint(toRemove);
501   SMESH::TPythonDump() << _this() << ".SetToRemoveCentralPoint( " << toRemove << " )";
502 }
503
504 //=======================================================================
505 //function : GetToRemoveCentralPoint
506 //=======================================================================
507
508 CORBA::Boolean HYBRIDPlugin_Hypothesis_i::GetToRemoveCentralPoint()
509 {
510   ASSERT(myBaseImpl);
511   return this->GetImpl()->GetToRemoveCentralPoint();
512 }
513
514 //=============================================================================
515
516 void HYBRIDPlugin_Hypothesis_i::SetOptionValue(const char* optionName, const char* optionValue)
517 {
518   ASSERT(myBaseImpl);
519   try {
520     std::string name( optionName );
521     while ( !name.empty() && name[0] == '-' )
522       name = name.substr(1);
523
524     if ( !optionValue || !optionValue[0] )
525       UnsetOption( optionName );
526
527     // basic options (visible in Advanced table)
528
529     else if ( name == "number_of_boundary_layers" )
530       SetNbOfBoundaryLayers( GetImpl()->ToInt( optionValue ));
531
532     else if ( name == "boundary_layer_global_initial_height" )
533       SetHeightFirstLayer( GetImpl()->ToDbl( optionValue ));
534
535     else if ( name == "boundary_layer_geometric_progression" )
536       SetBoundaryLayersProgression( GetImpl()->ToDbl( optionValue ));
537
538     else if ( name == "boundary_layer_max_element_angle" )
539       SetBoundaryLayersMaxElemAngle( GetImpl()->ToDbl( optionValue ));
540
541     else if ( name == "boundary_layer_height_relative_to_local_surface_size" )
542       SetHeightIsRelative( GetImpl()->ToBool( optionValue ));
543
544     else if ( name == "gradation" )
545       SetGradation( GetImpl()->ToDbl( optionValue ));
546
547     else if ( name == "element_generation" )
548       switch ( optionValue[0] ) {
549       case 't': SetElementGeneration( 0 ); break;
550       case 'h': SetElementGeneration( 1 ); break;
551       case 'c': SetElementGeneration( 2 ); break;
552       case 'e': SetElementGeneration( 3 ); break;
553       default:;
554       }
555     else if ( name == "collision_mode" ) // decrease|stop
556       SetCollisionMode( optionValue[0] != 'd' );
557
558     else if ( name == "add_multinormals" )
559       SetAddMultinormals( GetImpl()->ToBool( optionValue ));
560
561     else if ( name == "multinormal_angle_threshold" )
562       SetMultinormalsAngle( GetImpl()->ToDbl( optionValue ));
563
564     else if ( name == "verbose" )
565       SetVerboseLevel( GetImpl()->ToInt( optionValue ));
566
567     else if ( name == "max_memory" )
568       SetMaximumMemory( GetImpl()->ToInt( optionValue ));
569
570     else if ( name == "automatic_memory" )
571       SetInitialMemory( GetImpl()->ToInt( optionValue ));
572
573     else if ( name == "smooth_normals" )
574         SetSmoothNormals( GetImpl()->ToBool( optionValue ));
575
576     else if ( name == "optimisation" )
577       switch ( optionValue[0] ) {
578       case 'n': SetOptimizationLevel( 0 ); break;
579       case 'y': SetOptimizationLevel( 1 ); break;
580       case 'o': SetOptimizationLevel( 2 ); break;
581       default:;
582       }
583
584     // advanced options (for backward compatibility)
585     // else if ( name == "create_tag_on_collision" ||
586     //           name == "tiny_edge_respect_geometry" )
587     //   AddOption( optionName, optionValue );
588
589     else {
590       bool valueChanged = true;
591       try {
592         valueChanged = ( this->GetImpl()->GetOptionValue( name ) != optionValue );
593       }
594       catch ( std::invalid_argument& ) {
595       }
596       if ( valueChanged )
597       {
598         this->GetImpl()->SetOptionValue(optionName, optionValue);
599         SMESH::TPythonDump() << _this() << ".SetOptionValue( '" << optionName << "', '" << optionValue << "' )";
600       }
601     }
602   } catch (const std::invalid_argument& ex) {
603     THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
604   } catch (SALOME_Exception& ex) {
605     THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
606   }
607 }
608
609 //=============================================================================
610
611 char* HYBRIDPlugin_Hypothesis_i::GetOptionValue(const char* optionName)
612 {
613   ASSERT(myBaseImpl);
614   try {
615     bool isDefault;
616     return CORBA::string_dup(this->GetImpl()->GetOptionValue(optionName,&isDefault).c_str());
617   } catch (const std::invalid_argument& ex) {
618     THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
619   } catch (SALOME_Exception& ex) {
620     THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
621   }
622   return 0;
623 }
624
625 //=============================================================================
626
627 void HYBRIDPlugin_Hypothesis_i::UnsetOption(const char* optionName) {
628   ASSERT(myBaseImpl);
629   if ( !GetImpl()->GetOptionValue( optionName ).empty() )
630   {
631     this->GetImpl()->ClearOption(optionName);
632     SMESH::TPythonDump() << _this() << ".UnsetOption( '" << optionName << "' )";
633   }
634 }
635
636 //=============================================================================
637
638 HYBRIDPlugin::string_array* HYBRIDPlugin_Hypothesis_i::GetOptionValues()
639 {
640   HYBRIDPlugin::string_array_var result = new HYBRIDPlugin::string_array();
641
642   const ::HYBRIDPlugin_Hypothesis::TOptionValues & opts = this->GetImpl()->GetOptionValues();
643   result->length(opts.size());
644   int i=0;
645
646   bool isDefault;
647   ::HYBRIDPlugin_Hypothesis::TOptionValues::const_iterator opIt = opts.begin();
648   for (; opIt != opts.end(); ++opIt, ++i)
649   {
650     std::string name_value_type = opIt->first;
651     //if (!opIt->second.empty())
652     {
653       name_value_type += ":";
654       name_value_type += GetImpl()->GetOptionValue( opIt->first, &isDefault );
655       name_value_type += isDefault ? ":0" : ":1";
656     }
657     result[i] = CORBA::string_dup(name_value_type.c_str());
658   }
659
660   return result._retn();
661 }
662
663 //=============================================================================
664
665 HYBRIDPlugin::string_array* HYBRIDPlugin_Hypothesis_i::GetAdvancedOptionValues()
666 {
667   HYBRIDPlugin::string_array_var result = new HYBRIDPlugin::string_array();
668
669   const ::HYBRIDPlugin_Hypothesis::TOptionValues & custom_opts = this->GetImpl()->GetCustomOptionValues();
670   result->length(custom_opts.size());
671   int i=0;
672
673   ::HYBRIDPlugin_Hypothesis::TOptionValues::const_iterator opIt = custom_opts.begin();
674   for (; opIt != custom_opts.end(); ++opIt, ++i) {
675     std::string name_value_type = opIt->first;
676     if (!opIt->second.empty()) {
677       name_value_type += ":";
678       name_value_type += opIt->second;
679       name_value_type += ":1"; // user defined
680     }
681     result[i] = CORBA::string_dup(name_value_type.c_str());
682   }
683   return result._retn();
684 }
685
686 //=============================================================================
687
688 void HYBRIDPlugin_Hypothesis_i::SetOptionValues(const HYBRIDPlugin::string_array& options)
689 {
690   for (CORBA::ULong i = 0; i < options.length(); ++i)
691   {
692     std::string name_value_type = options[i].in();
693     if(name_value_type.empty())
694       continue;
695     size_t colonPos = name_value_type.find(':');
696     std::string name, value;
697     if (colonPos == std::string::npos) // ':' not found
698       name = name_value_type;
699     else {
700       name = name_value_type.substr(0, colonPos);
701       if (colonPos < name_value_type.size() - 1 && name_value_type[colonPos] != ' ') {
702         std::string value_type = name_value_type.substr(colonPos + 1);
703         colonPos = value_type.find(':');
704         value = value_type.substr(0, colonPos);
705         if (colonPos < value_type.size() - 1 && value_type[colonPos] != ' ')
706           if ( value_type.substr(colonPos + 1) == "0" ) // is default
707             value.clear();
708       }
709     }
710     SetOptionValue(name.c_str(), value.c_str());
711   }
712 }
713
714 //=============================================================================
715
716 void HYBRIDPlugin_Hypothesis_i::SetAdvancedOptionValues(const HYBRIDPlugin::string_array& options)
717 {
718   SMESH::TPythonDump dump;
719
720   std::string optionsAndValues;
721   for ( CORBA::ULong i = 0; i < options.length(); ++i) {
722     std::string name_value_type = options[i].in();
723     if(name_value_type.empty())
724       continue;
725     size_t colonPos = name_value_type.find(':');
726     std::string name, value;
727     if (colonPos == std::string::npos) // ':' not found
728       name = name_value_type;
729     else {
730       name = name_value_type.substr(0, colonPos);
731       if (colonPos < name_value_type.size() - 1 && name_value_type[colonPos] != ' ') {
732         std::string value_type = name_value_type.substr(colonPos + 1);
733         colonPos = value_type.find(':');
734         value = value_type.substr(0, colonPos);
735       }
736     }
737     AddOption(name.c_str(), value.c_str());
738
739     optionsAndValues += name + " " + value + " ";
740   }
741
742   if ( !optionsAndValues.empty() )
743     dump << _this() << ".SetAdvancedOptions( '" << optionsAndValues.c_str() << "' )";
744 }
745
746 //=============================================================================
747
748 void HYBRIDPlugin_Hypothesis_i::SetAdvancedOption(const char* optionsAndValues)
749 {
750   if ( !optionsAndValues ) return;
751
752   //SMESH::TPythonDump dump;
753
754   std::istringstream strm( optionsAndValues );
755   std::istream_iterator<std::string> sIt( strm ), sEnd;
756   for ( int nbPairs = 0; sIt != sEnd; ++nbPairs )
757   {
758     std::string option = *sIt;
759     if ( ++sIt != sEnd )
760     {
761       std::string value = *sIt;
762       ++sIt;
763       AddOption( option.c_str(), value.c_str() );
764     }
765     else
766     {
767       if ( nbPairs > 0 )
768         THROW_SALOME_CORBA_EXCEPTION( "Uneven number of options and values" ,SALOME::BAD_PARAM );
769       AddOption( option.c_str(), "" );
770     }
771   }
772   //dump << _this() << ".SetAdvancedOption( '" << optionsAndValues << "' )";
773 }
774
775 //=============================================================================
776
777 void HYBRIDPlugin_Hypothesis_i::AddOption(const char* optionName, const char* optionValue)
778 {
779   if ( strncmp( "--", optionName, 2 ) == 0 )
780     optionName += 2;
781
782   bool valueChanged = ( !this->GetImpl()->HasOptionDefined(optionName) ||
783                         this->GetImpl()->GetOptionValue(optionName) != optionValue );
784   if ( valueChanged )
785   {
786     SetOptionValue(optionName, optionValue);
787
788     SMESH_Comment optVal("--");
789     optVal << optionName << " " << optionValue;
790     std::string cmd = ::HYBRIDPlugin_Hypothesis::CommandToRun( GetImpl() );
791     if ( cmd.find( optVal ) == std::string::npos )
792     {
793       this->GetImpl()->SetOptionValue(optionName, optionValue);
794       SMESH::TPythonDump() << _this() << ".AddOption( '" << optionName << "', '" << optionValue << "' )";
795     }
796   }
797 }
798
799 //=============================================================================
800
801 char* HYBRIDPlugin_Hypothesis_i::GetOption(const char* optionName)
802 {
803   ASSERT(myBaseImpl);
804   return CORBA::string_dup(this->GetImpl()->GetOptionValue(optionName).c_str());
805 }
806
807 //=======================================================================
808 //function : SetTextOption
809 //=======================================================================
810 void HYBRIDPlugin_Hypothesis_i::SetTextOption(const char* option)
811 {
812   ASSERT(myBaseImpl);
813   this->GetImpl()->SetAdvancedOption(option);
814   SMESH::TPythonDump() << _this() << ".SetAdvancedOption( '" << option << "' )";
815 }
816
817 //=======================================================================
818 //function : GetTextOption
819 //=======================================================================
820 char* HYBRIDPlugin_Hypothesis_i::GetTextOption()
821 {
822   ASSERT(myBaseImpl);
823   return CORBA::string_dup( this->GetImpl()->GetAdvancedOption().c_str() );
824 }
825
826 //=======================================================================
827 //function : GetAdvancedOption
828 //=======================================================================
829 char* HYBRIDPlugin_Hypothesis_i::GetAdvancedOption()
830 {
831   return CORBA::string_dup( GetImpl()->GetAdvancedOption().c_str() );
832 }
833
834 //=======================================================================
835 //function : SetToRemoveCentralPoint
836 //=======================================================================
837
838 void HYBRIDPlugin_Hypothesis_i::SetGradation(CORBA::Double gradation)
839 {
840   if (gradation <= 1)
841     THROW_SALOME_CORBA_EXCEPTION( "The volumic gradation must be > 1",SALOME::BAD_PARAM );
842   ASSERT(myBaseImpl);
843   if (gradation != GetGradation()) {
844     this->GetImpl()->SetGradation(gradation);
845     SMESH::TPythonDump() << _this() << ".SetGradation( " << gradation << " )";
846   }
847 }
848
849 //=======================================================================
850 //function : GetToRemoveCentralPoint
851 //=======================================================================
852
853 CORBA::Double HYBRIDPlugin_Hypothesis_i::GetGradation()
854 {
855   ASSERT(myBaseImpl);
856   return this->GetImpl()->GetGradation();
857 }
858
859 //=======================================================================
860 //function : SetStandardOutputLog
861 //=======================================================================
862 void HYBRIDPlugin_Hypothesis_i::SetStandardOutputLog(CORBA::Boolean logInStandardOutput)
863 {
864   ASSERT(myBaseImpl);
865   this->GetImpl()->SetStandardOutputLog(logInStandardOutput);
866   SMESH::TPythonDump() << _this() << ".SetPrintLogInFile( " << !logInStandardOutput << " )";
867 }
868
869 //=======================================================================
870 //function : GetStandardOutputLog
871 //=======================================================================
872 CORBA::Boolean HYBRIDPlugin_Hypothesis_i::GetStandardOutputLog()
873 {
874   ASSERT(myBaseImpl);
875   return this->GetImpl()->GetStandardOutputLog();
876 }
877
878 //=======================================================================
879 //function : SetRemoveLogOnSuccess
880 //=======================================================================
881 void HYBRIDPlugin_Hypothesis_i::SetRemoveLogOnSuccess(CORBA::Boolean removeLogOnSuccess)
882 {
883   ASSERT(myBaseImpl);
884   this->GetImpl()->SetRemoveLogOnSuccess(removeLogOnSuccess);
885   SMESH::TPythonDump() << _this() << ".SetRemoveLogOnSuccess( " << removeLogOnSuccess << " )";
886 }
887
888 //=======================================================================
889 //function : GetRemoveLogOnSuccess
890 //=======================================================================
891 CORBA::Boolean HYBRIDPlugin_Hypothesis_i::GetRemoveLogOnSuccess()
892 {
893   ASSERT(myBaseImpl);
894   return this->GetImpl()->GetRemoveLogOnSuccess();
895 }
896
897 //=======================================================================
898 //function : SetBoundaryLayersGrowth
899 //=======================================================================
900 void HYBRIDPlugin_Hypothesis_i::SetBoundaryLayersGrowth(CORBA::Short level)
901 {
902   ::HYBRIDPlugin_Hypothesis::BoundaryLayersGrowth l =
903       (::HYBRIDPlugin_Hypothesis::BoundaryLayersGrowth) level;
904   if ( l < ::HYBRIDPlugin_Hypothesis::Layer_Growth_Inward ||
905        l > ::HYBRIDPlugin_Hypothesis::Layer_Growth_Outward )
906     THROW_SALOME_CORBA_EXCEPTION( "Invalid BoundaryLayersGrowth mode",SALOME::BAD_PARAM );
907     
908   ASSERT(myBaseImpl);
909   this->GetImpl()->SetBoundaryLayersGrowth(l);
910   SMESH::TPythonDump() << _this() << ".SetBoundaryLayersGrowth( " << level << " )";
911 }
912
913 //=======================================================================
914 //function : GetBoundaryLayersGrowth
915 //=======================================================================
916 CORBA::Short HYBRIDPlugin_Hypothesis_i::GetBoundaryLayersGrowth()
917 {
918   ASSERT(myBaseImpl);
919   return this->GetImpl()->GetBoundaryLayersGrowth();
920 }
921
922 //=======================================================================
923 //function : SetElementGeneration
924 //=======================================================================
925 void HYBRIDPlugin_Hypothesis_i::SetElementGeneration(CORBA::Short level)
926 {
927   ::HYBRIDPlugin_Hypothesis::ElementGeneration l =
928       (::HYBRIDPlugin_Hypothesis::ElementGeneration) level;
929   if ( l < ::HYBRIDPlugin_Hypothesis::Generation_Tetra_Dominant ||
930        l > ::HYBRIDPlugin_Hypothesis::Generation_Extrusion_Only )
931     THROW_SALOME_CORBA_EXCEPTION( "Invalid ElementGeneration mode",SALOME::BAD_PARAM );
932     
933   ASSERT(myBaseImpl);
934   this->GetImpl()->SetElementGeneration(l);
935   SMESH::TPythonDump() << _this() << ".SetElementGeneration( " << level << " )";
936 }
937
938 //=======================================================================
939 //function : GetElementGeneration
940 //=======================================================================
941 CORBA::Short HYBRIDPlugin_Hypothesis_i::GetElementGeneration()
942 {
943   ASSERT(myBaseImpl);
944   return this->GetImpl()->GetElementGeneration();
945 }
946
947 //=======================================================================
948 //function : SetAddMultinormals
949 //=======================================================================
950 void HYBRIDPlugin_Hypothesis_i::SetAddMultinormals(CORBA::Boolean toAddMultinormals)
951 {
952   ASSERT(myBaseImpl);
953   this->GetImpl()->SetAddMultinormals(toAddMultinormals);
954   SMESH::TPythonDump() << _this() << ".SetAddMultinormals( " << toAddMultinormals << " )";
955 }
956
957 //=======================================================================
958 //function : GetAddMultinormals
959 //=======================================================================
960 CORBA::Boolean HYBRIDPlugin_Hypothesis_i::GetAddMultinormals()
961 {
962   ASSERT(myBaseImpl);
963   return this->GetImpl()->GetAddMultinormals();
964 }
965
966 //=======================================================================
967 //function : SetSmoothNormals
968 //=======================================================================
969 void HYBRIDPlugin_Hypothesis_i::SetSmoothNormals(CORBA::Boolean toSmoothNormals)
970 {
971   ASSERT(myBaseImpl);
972   this->GetImpl()->SetSmoothNormals(toSmoothNormals);
973   SMESH::TPythonDump() << _this() << ".SetSmoothNormals( " << toSmoothNormals << " )";
974 }
975
976 //=======================================================================
977 //function : GetSmoothNormals
978 //=======================================================================
979 CORBA::Boolean HYBRIDPlugin_Hypothesis_i::GetSmoothNormals()
980 {
981   ASSERT(myBaseImpl);
982   return this->GetImpl()->GetSmoothNormals();
983 }
984
985 //=======================================================================
986 //function : SetHeightFirstLayer
987 //=======================================================================
988 void HYBRIDPlugin_Hypothesis_i::SetHeightFirstLayer(CORBA::Double toHeightFirstLayer)
989 {
990   ASSERT(myBaseImpl);
991   this->GetImpl()->SetHeightFirstLayer(toHeightFirstLayer);
992   SMESH::TPythonDump() << _this() << ".SetHeightFirstLayer( " << toHeightFirstLayer << " )";
993 }
994
995 //=======================================================================
996 //function : GetHeightFirstLayer
997 //=======================================================================
998 CORBA::Double HYBRIDPlugin_Hypothesis_i::GetHeightFirstLayer()
999 {
1000   ASSERT(myBaseImpl);
1001   return this->GetImpl()->GetHeightFirstLayer();
1002 }
1003
1004 //=======================================================================
1005 //function : SetBoundaryLayersProgression
1006 //=======================================================================
1007 void HYBRIDPlugin_Hypothesis_i::SetBoundaryLayersProgression(CORBA::Double toBoundaryLayersProgression)
1008 {
1009   ASSERT(myBaseImpl);
1010   this->GetImpl()->SetBoundaryLayersProgression(toBoundaryLayersProgression);
1011   SMESH::TPythonDump() << _this() << ".SetBoundaryLayersProgression( " << toBoundaryLayersProgression << " )";
1012 }
1013
1014 //=======================================================================
1015 //function : GetBoundaryLayersProgression
1016 //=======================================================================
1017 CORBA::Double HYBRIDPlugin_Hypothesis_i::GetBoundaryLayersProgression()
1018 {
1019   ASSERT(myBaseImpl);
1020   return this->GetImpl()->GetBoundaryLayersProgression();
1021 }
1022
1023 //=======================================================================
1024 //function : SetCoreSize
1025 //=======================================================================
1026 void HYBRIDPlugin_Hypothesis_i::SetCoreSize(CORBA::Double toCoreSize)
1027 {
1028   ASSERT(myBaseImpl);
1029   this->GetImpl()->SetCoreSize(toCoreSize);
1030   SMESH::TPythonDump() << _this() << ".SetCoreSize( " << toCoreSize << " )";
1031 }
1032
1033 //=======================================================================
1034 //function : GetCoreSize
1035 //=======================================================================
1036 CORBA::Double HYBRIDPlugin_Hypothesis_i::GetCoreSize()
1037 {
1038   ASSERT(myBaseImpl);
1039   return this->GetImpl()->GetCoreSize();
1040 }
1041
1042 //=======================================================================
1043 //function : SetMultinormalsAngle
1044 //=======================================================================
1045 void HYBRIDPlugin_Hypothesis_i::SetMultinormalsAngle(CORBA::Double toMultinormalsAngle)
1046 {
1047   ASSERT(myBaseImpl);
1048   this->GetImpl()->SetMultinormalsAngle(toMultinormalsAngle);
1049   SMESH::TPythonDump() << _this() << ".SetMultinormalsAngle( " << toMultinormalsAngle << " )";
1050 }
1051
1052 //=======================================================================
1053 //function : GetMultinormalsAngle
1054 //=======================================================================
1055 CORBA::Double HYBRIDPlugin_Hypothesis_i::GetMultinormalsAngle()
1056 {
1057   ASSERT(myBaseImpl);
1058   return this->GetImpl()->GetMultinormalsAngle();
1059 }
1060
1061 //=======================================================================
1062 //function : SetNbOfBoundaryLayers
1063 //=======================================================================
1064 void HYBRIDPlugin_Hypothesis_i::SetNbOfBoundaryLayers(CORBA::Short toNbOfBoundaryLayers)
1065 {
1066   ASSERT(myBaseImpl);
1067   this->GetImpl()->SetNbOfBoundaryLayers(toNbOfBoundaryLayers);
1068   SMESH::TPythonDump() << _this() << ".SetNbOfBoundaryLayers( " << toNbOfBoundaryLayers << " )";
1069 }
1070
1071 //=======================================================================
1072 //function : GetNbOfBoundaryLayers
1073 //=======================================================================
1074 CORBA::Short HYBRIDPlugin_Hypothesis_i::GetNbOfBoundaryLayers()
1075 {
1076   ASSERT(myBaseImpl);
1077   return this->GetImpl()->GetNbOfBoundaryLayers();
1078 }
1079
1080 //=======================================================================
1081 //function : SetEnforcedVertex
1082 //=======================================================================
1083
1084 bool HYBRIDPlugin_Hypothesis_i::SetEnforcedVertex(CORBA::Double x, CORBA::Double y, CORBA::Double z, CORBA::Double size)
1085 {
1086   ASSERT(myBaseImpl);
1087   return p_SetEnforcedVertex(size, x, y, z);
1088 }
1089
1090 bool HYBRIDPlugin_Hypothesis_i::SetEnforcedVertexNamed(CORBA::Double x, CORBA::Double y, CORBA::Double z, CORBA::Double size, const char* theVertexName)
1091 {
1092   ASSERT(myBaseImpl);
1093   return p_SetEnforcedVertex(size, x, y, z, theVertexName, "", "");
1094 }
1095
1096 bool HYBRIDPlugin_Hypothesis_i::SetEnforcedVertexWithGroup(CORBA::Double x, CORBA::Double y, CORBA::Double z, CORBA::Double size, const char* theGroupName)
1097 {
1098   ASSERT(myBaseImpl);
1099   return p_SetEnforcedVertex(size, x, y, z, "", "", theGroupName);
1100 }
1101
1102 bool HYBRIDPlugin_Hypothesis_i::SetEnforcedVertexNamedWithGroup(CORBA::Double x, CORBA::Double y, CORBA::Double z, CORBA::Double size, const char* theVertexName, const char* theGroupName)
1103 {
1104   ASSERT(myBaseImpl);
1105   return p_SetEnforcedVertex(size, x, y, z, theVertexName, "", theGroupName);
1106 }
1107
1108 bool HYBRIDPlugin_Hypothesis_i::SetEnforcedVertexGeom(GEOM::GEOM_Object_ptr theVertex, CORBA::Double size)
1109 {
1110   ASSERT(myBaseImpl);
1111   
1112   if ((theVertex->GetShapeType() != GEOM::VERTEX) && (theVertex->GetShapeType() != GEOM::COMPOUND)) {
1113     THROW_SALOME_CORBA_EXCEPTION("theVertex shape type is not VERTEX or COMPOUND", SALOME::BAD_PARAM);
1114   }
1115   
1116   std::string theVertexEntry = theVertex->GetStudyEntry();
1117   CORBA::Double x = 0, y = 0, z = 0;
1118   CORBA::Boolean isCompound = false;
1119   GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine( theVertex );
1120   if (theVertexEntry.empty()) {
1121     std::string aName;
1122     if (theVertex->GetShapeType() == GEOM::VERTEX) {
1123       aName = "Vertex_";
1124     }
1125     if (theVertex->GetShapeType() == GEOM::COMPOUND) {
1126       aName = "Compound_";
1127       isCompound = true;
1128     }
1129     aName += theVertex->GetEntry();
1130     SALOMEDS::SObject_ptr theSVertex = geomGen->PublishInStudy(NULL, theVertex, aName.c_str());
1131     if (!theSVertex->_is_nil())
1132       theVertexEntry = theSVertex->GetID();
1133   }
1134   if (theVertexEntry.empty())
1135     THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM );
1136
1137   if (theVertex->GetShapeType() == GEOM::VERTEX) {
1138     GEOM::GEOM_IMeasureOperations_var measureOp = geomGen->GetIMeasureOperations();
1139     if (CORBA::is_nil(measureOp))
1140       return false;
1141     
1142     measureOp->PointCoordinates (theVertex, x, y, z);
1143   }
1144
1145   std::string theVertexName = theVertex->GetName();
1146   
1147   return p_SetEnforcedVertex(size, x, y, z, theVertexName.c_str(), theVertexEntry.c_str(), "", isCompound);
1148 }
1149
1150 bool HYBRIDPlugin_Hypothesis_i::SetEnforcedVertexGeomWithGroup(GEOM::GEOM_Object_ptr theVertex, CORBA::Double size, const char* theGroupName)
1151 {
1152   ASSERT(myBaseImpl);
1153   
1154   if ((theVertex->GetShapeType() != GEOM::VERTEX) && (theVertex->GetShapeType() != GEOM::COMPOUND)) {
1155     MESSAGE("theVertex shape type is not VERTEX or COMPOUND");
1156     THROW_SALOME_CORBA_EXCEPTION("theVertex shape type is not VERTEX or COMPOUND", SALOME::BAD_PARAM);
1157   }
1158   
1159   std::string theVertexEntry = theVertex->GetStudyEntry();
1160   CORBA::Double x = 0, y = 0, z = 0;
1161   CORBA::Boolean isCompound = false;
1162   GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine( theVertex );
1163   if (theVertexEntry.empty()) {
1164     std::string aName;
1165     if (theVertex->GetShapeType() == GEOM::VERTEX) {
1166       aName = "Vertex_";
1167     }
1168     if (theVertex->GetShapeType() == GEOM::COMPOUND) {
1169       aName = "Compound_";
1170       isCompound = true;
1171     }
1172     aName += theVertex->GetEntry();
1173     SALOMEDS::SObject_ptr theSVertex = geomGen->PublishInStudy(NULL, theVertex, aName.c_str());
1174     if (!theSVertex->_is_nil())
1175       theVertexEntry = theSVertex->GetID();
1176   }
1177   if (theVertexEntry.empty())
1178     THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM );
1179
1180   if (theVertex->GetShapeType() == GEOM::VERTEX) {
1181     GEOM::GEOM_IMeasureOperations_var measureOp = geomGen->GetIMeasureOperations();
1182     if (CORBA::is_nil(measureOp))
1183       return false;
1184     
1185     measureOp->PointCoordinates (theVertex, x, y, z);
1186   }
1187     
1188   std::string theVertexName = theVertex->GetName();
1189   
1190   return p_SetEnforcedVertex(size, x, y, z, theVertexName.c_str(), theVertexEntry.c_str(), theGroupName, isCompound);
1191 }
1192
1193 bool HYBRIDPlugin_Hypothesis_i:: p_SetEnforcedVertex(CORBA::Double size, CORBA::Double x, CORBA::Double y, CORBA::Double z,
1194                                                    const char* theVertexName, const char* theVertexEntry, const char* theGroupName,
1195                                                    CORBA::Boolean isCompound)
1196 {
1197   ASSERT(myBaseImpl);
1198   bool newValue = false;
1199
1200   ::HYBRIDPlugin_Hypothesis::TCoordsHYBRIDEnforcedVertexMap coordsList;
1201   ::HYBRIDPlugin_Hypothesis::TGeomEntryHYBRIDEnforcedVertexMap enfVertexEntryList;
1202   if (std::string(theVertexEntry).empty()) {
1203     coordsList = this->GetImpl()->_GetEnforcedVerticesByCoords();
1204     std::vector<double> coords;
1205     coords.push_back(x);
1206     coords.push_back(y);
1207     coords.push_back(z);
1208     if (coordsList.find(coords) == coordsList.end()) {
1209       newValue = true;
1210     }
1211     else {
1212       ::HYBRIDPlugin_Hypothesis::THYBRIDEnforcedVertex *enfVertex = this->GetImpl()->GetEnforcedVertex(x, y, z);
1213       if ((enfVertex->name != theVertexName) || (enfVertex->groupName != theGroupName) || (enfVertex->size != size)) {
1214 //          this->GetImpl()->ClearEnforcedVertex(theFaceEntry, x, y, z);
1215         newValue = true;
1216       }
1217       else {
1218       }
1219     }
1220
1221     if (newValue) {
1222       if (std::string(theVertexName).empty()) {
1223         if (std::string(theGroupName).empty())
1224           SMESH::TPythonDump() << "isDone = " << _this() << ".SetEnforcedVertex(" << x << ", " << y << ", " << z << ", " << size << ")";
1225         else
1226           SMESH::TPythonDump() << "isDone = " << _this() << ".SetEnforcedVertexWithGroup(" << x << ", " << y << ", " << z << ", " << size << ", \"" << theGroupName << "\")";
1227       }
1228       else {
1229         if (std::string(theGroupName).empty())
1230           SMESH::TPythonDump() << "isDone = " << _this() << ".SetEnforcedVertexNamed(" << x << ", " << y << ", " << z << ", " << size  << ", \"" << theVertexName << "\")";
1231         else
1232           SMESH::TPythonDump() << "isDone = " << _this() << ".SetEnforcedVertexNamedWithGroup(" << x << ", " << y << ", " << z << ", " << size  << ", \"" << theVertexName << "\", \"" << theGroupName << "\")";
1233       }
1234     }
1235   } 
1236   else {
1237 //   if (isCompound || (!isCompound && !std::string(theVertexEntry).empty())) {
1238     enfVertexEntryList = this->GetImpl()->_GetEnforcedVerticesByEntry();
1239 //     ::BLSURFPlugin_Hypothesis::TGeomEntryHYBRIDEnforcedVertexMap::const_iterator it = enfVertexEntryList.find(theVertexEntry);
1240     if ( enfVertexEntryList.find(theVertexEntry) == enfVertexEntryList.end()) {
1241       newValue = true;
1242     }
1243     else {
1244       ::HYBRIDPlugin_Hypothesis::THYBRIDEnforcedVertex *enfVertex = this->GetImpl()->GetEnforcedVertex(theVertexEntry);
1245       if ((enfVertex->name != theVertexName) || (enfVertex->groupName != theGroupName) || (enfVertex->size != size)) {
1246 //          this->GetImpl()->ClearEnforcedVertex(theFaceEntry, x, y, z);
1247         newValue = true;
1248       }
1249       else {
1250       }
1251     }
1252
1253     if (newValue) {
1254       if (std::string(theGroupName).empty())
1255         SMESH::TPythonDump() << "isDone = " << _this() << ".SetEnforcedVertexGeom(" << theVertexEntry << ", " << size << ")";
1256       else
1257         SMESH::TPythonDump() << "isDone = " << _this() << ".SetEnforcedVertexGeomWithGroup(" << theVertexEntry << ", " << size << ", \"" << theGroupName << "\")";
1258     }
1259   }
1260
1261   if (newValue)
1262     this->GetImpl()->SetEnforcedVertex(theVertexName, theVertexEntry, theGroupName, size, x, y, z, isCompound);
1263
1264   return newValue;
1265 }
1266
1267 //=======================================================================
1268 //function : GetEnforcedVertex
1269 //=======================================================================
1270
1271 CORBA::Double HYBRIDPlugin_Hypothesis_i::GetEnforcedVertex(CORBA::Double x, CORBA::Double y, CORBA::Double z)
1272 {
1273   ASSERT(myBaseImpl);
1274   try {
1275     bool isDone = this->GetImpl()->GetEnforcedVertex(x,y,z)->size;
1276     SMESH::TPythonDump() << "aSize = " << _this() << ".GetEnforcedVertex(" << x << ", " << y << ", " << z << ")";
1277     return isDone;
1278   }
1279   catch (const std::invalid_argument& ex) {
1280     SALOME::ExceptionStruct ExDescription;
1281     ExDescription.text = ex.what();
1282     ExDescription.type = SALOME::BAD_PARAM;
1283     ExDescription.sourceFile = "HYBRIDPlugin_Hypothesis_i.cxx";
1284     ExDescription.lineNumber = 513;
1285     throw SALOME::SALOME_Exception(ExDescription);
1286   }
1287   catch (SALOME_Exception& ex) {
1288     THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
1289   }
1290 }
1291
1292 //=======================================================================
1293 //function : GetEnforcedVertex
1294 //=======================================================================
1295
1296 CORBA::Double HYBRIDPlugin_Hypothesis_i::GetEnforcedVertexGeom(GEOM::GEOM_Object_ptr theVertex)
1297 {
1298   ASSERT(myBaseImpl);
1299   
1300   if ((theVertex->GetShapeType() != GEOM::VERTEX) && (theVertex->GetShapeType() != GEOM::COMPOUND)) {
1301     MESSAGE("theVertex shape type is not VERTEX or COMPOUND");
1302     THROW_SALOME_CORBA_EXCEPTION("theVertex shape type is not VERTEX or COMPOUND", SALOME::BAD_PARAM);
1303   }
1304   
1305   std::string theVertexEntry = theVertex->GetStudyEntry();
1306   if (theVertexEntry.empty()) {
1307     GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine( theVertex );
1308     std::string aName;
1309     if (theVertex->GetShapeType() == GEOM::VERTEX)
1310       aName = "Vertex_";
1311     if (theVertex->GetShapeType() == GEOM::COMPOUND)
1312       aName = "Compound_";
1313     aName += theVertex->GetEntry();
1314     SALOMEDS::SObject_ptr theSVertex = geomGen->PublishInStudy(NULL, theVertex, aName.c_str());
1315     if (!theSVertex->_is_nil())
1316       theVertexEntry = theSVertex->GetID();
1317   }
1318   if (theVertexEntry.empty())
1319     THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM );
1320
1321   std::string theVertexName = theVertex->GetName();
1322   
1323   try {
1324     bool isDone = this->GetImpl()->GetEnforcedVertex(theVertexName)->size;
1325     SMESH::TPythonDump() << "aSize = " << _this() << ".GetEnforcedVertexGeom(" << theVertex << ")";
1326     return isDone;
1327   }
1328   catch (const std::invalid_argument& ex) {
1329     SALOME::ExceptionStruct ExDescription;
1330     ExDescription.text = ex.what();
1331     ExDescription.type = SALOME::BAD_PARAM;
1332     ExDescription.sourceFile = "HYBRIDPlugin_Hypothesis_i.cxx";
1333     ExDescription.lineNumber = 538;
1334     throw SALOME::SALOME_Exception(ExDescription);
1335   }
1336   catch (SALOME_Exception& ex) {
1337     THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
1338   }
1339 }
1340
1341 //=======================================================================
1342 //function : GetEnforcedVertices
1343 //=======================================================================
1344
1345 HYBRIDPlugin::HYBRIDEnforcedVertexList* HYBRIDPlugin_Hypothesis_i::GetEnforcedVertices()
1346 {
1347   ASSERT(myBaseImpl);
1348   HYBRIDPlugin::HYBRIDEnforcedVertexList_var result = new HYBRIDPlugin::HYBRIDEnforcedVertexList();
1349
1350   const ::HYBRIDPlugin_Hypothesis::THYBRIDEnforcedVertexList enfVertexList = this->GetImpl()->_GetEnforcedVertices();
1351   result->length( enfVertexList.size() );
1352
1353   ::HYBRIDPlugin_Hypothesis::THYBRIDEnforcedVertexList::const_iterator it = enfVertexList.begin();
1354
1355   for (int i = 0 ; it != enfVertexList.end(); ++it, ++i ) {
1356     ::HYBRIDPlugin_Hypothesis::THYBRIDEnforcedVertex* currentVertex = (*it);
1357     HYBRIDPlugin::HYBRIDEnforcedVertex_var enfVertex = new HYBRIDPlugin::HYBRIDEnforcedVertex();
1358     // Name
1359     enfVertex->name = CORBA::string_dup(currentVertex->name.c_str());
1360     // Geom Vertex Entry
1361     enfVertex->geomEntry = CORBA::string_dup(currentVertex->geomEntry.c_str());
1362     // Coords
1363     HYBRIDPlugin::TCoords_var coords = new HYBRIDPlugin::TCoords();
1364     coords->length(currentVertex->coords.size());
1365     for (size_t ind = 0; ind < currentVertex->coords.size(); ind++)
1366       coords[ind] = currentVertex->coords[ind];
1367     enfVertex->coords = coords;
1368     // Group Name
1369     enfVertex->groupName = CORBA::string_dup(currentVertex->groupName.c_str());
1370     // Size
1371     enfVertex->size = currentVertex->size;
1372     // isCompound
1373     enfVertex->isCompound = currentVertex->isCompound;
1374     
1375     result[i]=enfVertex;
1376     }
1377   
1378 //   SMESH::TPythonDump() << "allEnforcedVertices = " << _this() << ".GetEnforcedVertices()";
1379
1380   return result._retn();
1381 }
1382
1383 //=======================================================================
1384 //function : RemoveEnforcedVertex
1385 //=======================================================================
1386
1387 bool HYBRIDPlugin_Hypothesis_i::RemoveEnforcedVertex(CORBA::Double x, CORBA::Double y, CORBA::Double z)
1388 {
1389   ASSERT(myBaseImpl);
1390   try {
1391     bool res = this->GetImpl()->RemoveEnforcedVertex(x,y,z);
1392     SMESH::TPythonDump() << " isDone = " << _this() << ".RemoveEnforcedVertex( " << x << ", " << y << ", " << z << " )";
1393     return res;
1394   }
1395   catch (const std::invalid_argument& ex) {
1396     SALOME::ExceptionStruct ExDescription;
1397     ExDescription.text = ex.what();
1398     ExDescription.type = SALOME::BAD_PARAM;
1399     ExDescription.sourceFile = "HYBRIDPlugin_Hypothesis_i.cxx";
1400     ExDescription.lineNumber = 625;
1401     throw SALOME::SALOME_Exception(ExDescription);
1402   }
1403   catch (SALOME_Exception& ex) {
1404     THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
1405   }
1406 }
1407
1408 bool HYBRIDPlugin_Hypothesis_i::RemoveEnforcedVertexGeom(GEOM::GEOM_Object_ptr theVertex)
1409 {
1410   ASSERT(myBaseImpl);
1411   
1412   if ((theVertex->GetShapeType() != GEOM::VERTEX) && (theVertex->GetShapeType() != GEOM::COMPOUND)) {
1413     MESSAGE("theVertex shape type is not VERTEX or COMPOUND");
1414     THROW_SALOME_CORBA_EXCEPTION("theVertex shape type is not VERTEX or COMPOUND", SALOME::BAD_PARAM);
1415   }
1416   
1417   std::string theVertexEntry = theVertex->GetStudyEntry();
1418   if (theVertexEntry.empty()) {
1419     GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine( theVertex );
1420     std::string aName;
1421     if (theVertex->GetShapeType() == GEOM::VERTEX)
1422       aName = "Vertex_";
1423     if (theVertex->GetShapeType() == GEOM::COMPOUND)
1424       aName = "Compound_";
1425     aName += theVertex->GetEntry();
1426     SALOMEDS::SObject_ptr theSVertex = geomGen->PublishInStudy(NULL, theVertex, aName.c_str());
1427     if (!theSVertex->_is_nil())
1428       theVertexEntry = theSVertex->GetID();
1429   }
1430   if (theVertexEntry.empty())
1431     THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM );
1432   
1433   try {
1434     bool res = this->GetImpl()->RemoveEnforcedVertex(0,0,0, theVertexEntry.c_str());
1435     SMESH::TPythonDump() << "isDone = " << _this() << ".RemoveEnforcedVertexGeom( " << theVertexEntry.c_str() << " )";
1436     return res;
1437   }
1438   catch (const std::invalid_argument& ex) {
1439     SALOME::ExceptionStruct ExDescription;
1440     ExDescription.text = ex.what();
1441     ExDescription.type = SALOME::BAD_PARAM;
1442     ExDescription.sourceFile = "HYBRIDPlugin_Hypothesis_i.cxx";
1443     ExDescription.lineNumber = 648;
1444     throw SALOME::SALOME_Exception(ExDescription);
1445   }
1446   catch (SALOME_Exception& ex) {
1447     THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
1448   }
1449 }
1450
1451 //=======================================================================
1452 //function : ClearEnforcedVertices
1453 //=======================================================================
1454
1455 void HYBRIDPlugin_Hypothesis_i::ClearEnforcedVertices()
1456 {
1457   ASSERT(myBaseImpl);
1458   this->GetImpl()->ClearEnforcedVertices();
1459   SMESH::TPythonDump () << _this() << ".ClearEnforcedVertices() ";
1460 }
1461
1462 //=======================================================================
1463 //function : ClearEnforcedMeshes
1464 //=======================================================================
1465
1466 void HYBRIDPlugin_Hypothesis_i::ClearEnforcedMeshes()
1467 {
1468   ASSERT(myBaseImpl);
1469   this->GetImpl()->ClearEnforcedMeshes();
1470   SMESH::TPythonDump () << _this() << ".ClearEnforcedMeshes() ";
1471 }
1472
1473 //=======================================================================
1474 //function : GetEnforcedMeshes
1475 //=======================================================================
1476
1477 HYBRIDPlugin::HYBRIDEnforcedMeshList* HYBRIDPlugin_Hypothesis_i::GetEnforcedMeshes()
1478 {
1479   ASSERT(myBaseImpl);
1480   HYBRIDPlugin::HYBRIDEnforcedMeshList_var result = new HYBRIDPlugin::HYBRIDEnforcedMeshList();
1481
1482   const ::HYBRIDPlugin_Hypothesis::THYBRIDEnforcedMeshList enfMeshList = this->GetImpl()->_GetEnforcedMeshes();
1483   result->length( enfMeshList.size() );
1484
1485   ::HYBRIDPlugin_Hypothesis::THYBRIDEnforcedMeshList::const_iterator it = enfMeshList.begin();
1486
1487   for (int i = 0 ; it != enfMeshList.end(); ++it, ++i ) {
1488     ::HYBRIDPlugin_Hypothesis::THYBRIDEnforcedMesh* currentMesh = (*it);
1489     HYBRIDPlugin::HYBRIDEnforcedMesh_var enfMesh = new HYBRIDPlugin::HYBRIDEnforcedMesh();
1490     // Name
1491     enfMesh->name = CORBA::string_dup(currentMesh->name.c_str());
1492     // Mesh Entry
1493     enfMesh->entry = CORBA::string_dup(currentMesh->entry.c_str());
1494     // isCompound
1495     enfMesh->elementType = currentMesh->elementType;
1496     // Group Name
1497     enfMesh->groupName = CORBA::string_dup(currentMesh->groupName.c_str());
1498     
1499     result[i]=enfMesh;
1500     }
1501   
1502 //   SMESH::TPythonDump() << "allEnforcedVertices = " << _this() << ".GetEnforcedVertices()";
1503
1504   return result._retn();
1505 }
1506
1507 /*!
1508  * \brief Adds enforced elements of type elementType using another mesh/sub-mesh/mesh group theSource. The elements will be grouped in theGroupName.
1509  */
1510 bool HYBRIDPlugin_Hypothesis_i::SetEnforcedMeshWithGroup(SMESH::SMESH_IDSource_ptr theSource, SMESH::ElementType theType, const char* theGroupName)
1511 {
1512 // #if HYBRID_VERSION >= 42
1513   return p_SetEnforcedMesh(theSource, theType, "", theGroupName);
1514 // #else
1515 //   SALOME::ExceptionStruct ExDescription;
1516 //   ExDescription.text = "Bad version of HYBRID. It must >= 4.2.";
1517 //   ExDescription.type = SALOME::BAD_PARAM;
1518 //   ExDescription.sourceFile = "HYBRIDPlugin_Hypothesis_i.cxx";
1519 //   ExDescription.lineNumber = 719;
1520 //   throw SALOME::SALOME_Exception(ExDescription);
1521 // #endif
1522 }
1523
1524 /*!
1525  * \brief Adds enforced elements of type elementType using another mesh/sub-mesh/mesh group theSource.
1526  */
1527 bool HYBRIDPlugin_Hypothesis_i::SetEnforcedMesh(SMESH::SMESH_IDSource_ptr theSource, SMESH::ElementType theType)
1528 {
1529 // #if HYBRID_VERSION >= 42
1530   return p_SetEnforcedMesh(theSource, theType);
1531 // #else
1532 //   SALOME::ExceptionStruct ExDescription;
1533 //   ExDescription.text = "Bad version of HYBRID. It must >= 4.2.";
1534 //   ExDescription.type = SALOME::BAD_PARAM;
1535 //   ExDescription.sourceFile = "HYBRIDPlugin_Hypothesis_i.cxx";
1536 //   ExDescription.lineNumber = 750;
1537 //   throw SALOME::SALOME_Exception(ExDescription);
1538 // #endif
1539 }
1540
1541 /*!
1542  * \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.
1543  */
1544 bool HYBRIDPlugin_Hypothesis_i::SetEnforcedMeshSizeWithGroup(SMESH::SMESH_IDSource_ptr theSource, SMESH::ElementType theType, double /*theSize*/, const char* theGroupName)
1545 {
1546 // #if HYBRID_VERSION >= 42
1547   return p_SetEnforcedMesh(theSource, theType, "", theGroupName);
1548 // #else
1549 //   SALOME::ExceptionStruct ExDescription;
1550 //   ExDescription.text = "Bad version of HYBRID. It must >= 4.2.";
1551 //   ExDescription.type = SALOME::BAD_PARAM;
1552 //   ExDescription.sourceFile = "HYBRIDPlugin_Hypothesis_i.cxx";
1553 //   ExDescription.lineNumber = 750;
1554 //   throw SALOME::SALOME_Exception(ExDescription);
1555 // #endif
1556 }
1557
1558 /*!
1559  * \brief OBSOLETE FUNCTION - Adds enforced elements of type elementType using another mesh/sub-mesh/mesh group theSource and a size.
1560  */
1561 bool HYBRIDPlugin_Hypothesis_i::SetEnforcedMeshSize(SMESH::SMESH_IDSource_ptr theSource, SMESH::ElementType theType, double /*theSize*/)
1562 {
1563 // #if HYBRID_VERSION >= 42
1564   return p_SetEnforcedMesh(theSource, theType);
1565 // #else
1566 //   SALOME::ExceptionStruct ExDescription;
1567 //   ExDescription.text = "Bad version of HYBRID. It must >= 4.2.";
1568 //   ExDescription.type = SALOME::BAD_PARAM;
1569 //   ExDescription.sourceFile = "HYBRIDPlugin_Hypothesis_i.cxx";
1570 //   ExDescription.lineNumber = 750;
1571 //   throw SALOME::SALOME_Exception(ExDescription);
1572 // #endif
1573 }
1574
1575 bool HYBRIDPlugin_Hypothesis_i::p_SetEnforcedMesh(SMESH::SMESH_IDSource_ptr theSource, SMESH::ElementType theType, const char* theName, const char* theGroupName)
1576 {
1577   ASSERT(myBaseImpl);
1578   
1579   if (CORBA::is_nil( theSource ))
1580   {
1581     SALOME::ExceptionStruct ExDescription;
1582     ExDescription.text = "The source mesh CORBA object is NULL";
1583     ExDescription.type = SALOME::BAD_PARAM;
1584     ExDescription.sourceFile = "HYBRIDPlugin_Hypothesis_i.cxx";
1585     ExDescription.lineNumber = 840;
1586     throw SALOME::SALOME_Exception(ExDescription);
1587   }
1588   
1589   switch (theType) {
1590     case SMESH::NODE:
1591       break;
1592     case SMESH::EDGE:
1593       break;
1594     case SMESH::FACE:
1595       break;
1596     default:
1597       return false;
1598   }
1599   SMESH::array_of_ElementType_var types = theSource->GetTypes();
1600   if ( types->length() >= 1 && types[types->length()-1] <  theType)
1601   {
1602     return false;
1603 //     SALOME::ExceptionStruct ExDescription;
1604 //     ExDescription.text = "The source mesh has bad type";
1605 //     ExDescription.type = SALOME::BAD_PARAM;
1606 //     ExDescription.sourceFile = "HYBRIDPlugin_Hypothesis_i.cxx";
1607 //     ExDescription.lineNumber = 840;
1608 //     throw SALOME::SALOME_Exception(ExDescription);
1609   }
1610
1611
1612   SMESH_Gen_i *smeshGen = SMESH_Gen_i::GetSMESHGen();
1613   SALOMEDS::SObject_ptr SObj = smeshGen->ObjectToSObject(theSource);
1614
1615   SMESH_Mesh_i* theMesh_i = SMESH::DownCast<SMESH_Mesh_i*>( theSource);
1616   SMESH_Group_i* theGroup_i = SMESH::DownCast<SMESH_Group_i*>( theSource);
1617   SMESH_GroupOnGeom_i* theGroupOnGeom_i = SMESH::DownCast<SMESH_GroupOnGeom_i*>( theSource);
1618
1619   std::string enfMeshName = theName;
1620   if (enfMeshName.empty())
1621     enfMeshName = SObj->GetName();
1622
1623   if (theMesh_i)
1624   {
1625     try {
1626       bool res = this->GetImpl()->SetEnforcedMesh(theMesh_i->GetImpl(), theType, enfMeshName , SObj->GetID(), theGroupName);
1627       if (theGroupName && theGroupName[0]) {
1628         SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMeshWithGroup( "
1629                               << theSource << ".GetMesh(), " << theType << ", \"" << theGroupName << "\" )";
1630       }
1631       else {
1632         SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMesh( "
1633                               << theSource << ".GetMesh(), " << theType << " )";
1634       }
1635
1636       return res;
1637     }
1638     catch (const std::invalid_argument& ex) {
1639       SALOME::ExceptionStruct ExDescription;
1640       ExDescription.text = ex.what();
1641       ExDescription.type = SALOME::BAD_PARAM;
1642       ExDescription.sourceFile = "HYBRIDPlugin_Hypothesis_i.cxx";
1643       ExDescription.lineNumber = 840;
1644       throw SALOME::SALOME_Exception(ExDescription);
1645     }
1646     catch (SALOME_Exception& ex) {
1647       THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
1648     }
1649   }
1650   else if (theGroup_i)// && types->length() == 1 && types[0] == theType)
1651   {
1652     try {
1653         bool res = this->GetImpl()->SetEnforcedGroup(theGroup_i->GetGroupDS()->GetMesh(), theGroup_i->GetListOfID(), theType, enfMeshName , SObj->GetID(), theGroupName);
1654         if (theGroupName && theGroupName[0]) {
1655           SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMeshWithGroup( " 
1656                                 << theSource << ", " << theType << ", \"" << theGroupName << "\" )";
1657         }
1658         else {
1659           SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMesh( " 
1660                                 << theSource << ", " << theType << " )";
1661         }
1662       return res;
1663     }
1664     catch (const std::invalid_argument& ex) {
1665       SALOME::ExceptionStruct ExDescription;
1666       ExDescription.text = ex.what();
1667       ExDescription.type = SALOME::BAD_PARAM;
1668       ExDescription.sourceFile = "HYBRIDPlugin_Hypothesis_i.cxx";
1669       ExDescription.lineNumber = 840;
1670       throw SALOME::SALOME_Exception(ExDescription);
1671     }
1672     catch (SALOME_Exception& ex) {
1673       THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
1674     }
1675   }
1676   else if (theGroupOnGeom_i)// && types->length() == 1 && types[0] == theType)
1677   {
1678       try {
1679         bool res = this->GetImpl()->SetEnforcedGroup(theGroupOnGeom_i->GetGroupDS()->GetMesh(),theGroupOnGeom_i->GetListOfID(), theType, enfMeshName , SObj->GetID(), theGroupName);
1680         if (theGroupName && theGroupName[0]) {
1681           SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMeshWithGroup( "
1682                                 << theSource << ", " << theType << ", \"" << theGroupName << "\" )";
1683         }
1684         else {
1685           SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMesh( "
1686                                 << theSource << ", " << theType << " )";
1687         }
1688         return res;
1689       }
1690       catch (const std::invalid_argument& ex) {
1691         SALOME::ExceptionStruct ExDescription;
1692       ExDescription.text = ex.what();
1693       ExDescription.type = SALOME::BAD_PARAM;
1694       ExDescription.sourceFile = "HYBRIDPlugin_Hypothesis_i.cxx";
1695       ExDescription.lineNumber = 840;
1696       throw SALOME::SALOME_Exception(ExDescription);
1697     }
1698     catch (SALOME_Exception& ex) {
1699       THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
1700     }
1701   }
1702   return false;
1703 }
1704 //=============================================================================
1705 /*!
1706  *  Get implementation
1707  */
1708 //=============================================================================
1709
1710 ::HYBRIDPlugin_Hypothesis* HYBRIDPlugin_Hypothesis_i::GetImpl()
1711 {
1712   return (::HYBRIDPlugin_Hypothesis*)myBaseImpl;
1713 }
1714
1715 //================================================================================
1716 /*!
1717  * \brief Verify whether hypothesis supports given entity type 
1718  */
1719 //================================================================================  
1720
1721 CORBA::Boolean HYBRIDPlugin_Hypothesis_i::IsDimSupported( SMESH::Dimension type )
1722 {
1723   return type == SMESH::DIM_3D;
1724 }
1725