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