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