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