Salome HOME
0d769f5395f72ab7ce4e8b47483f7423ff074ad0
[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_Hexa_Dominant )
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 : SetMultinormalsAngle
654 //=======================================================================
655 void HYBRIDPlugin_Hypothesis_i::SetMultinormalsAngle(CORBA::Double toMultinormalsAngle)
656 {
657   ASSERT(myBaseImpl);
658   this->GetImpl()->SetMultinormalsAngle(toMultinormalsAngle);
659   SMESH::TPythonDump() << _this() << ".SetMultinormalsAngle( " << toMultinormalsAngle << " )";
660 }
661
662 //=======================================================================
663 //function : GetMultinormalsAngle
664 //=======================================================================
665 CORBA::Double HYBRIDPlugin_Hypothesis_i::GetMultinormalsAngle()
666 {
667   ASSERT(myBaseImpl);
668   return this->GetImpl()->GetMultinormalsAngle();
669 }
670
671 //=======================================================================
672 //function : SetNbOfBoundaryLayers
673 //=======================================================================
674 void HYBRIDPlugin_Hypothesis_i::SetNbOfBoundaryLayers(CORBA::Short toNbOfBoundaryLayers)
675 {
676   ASSERT(myBaseImpl);
677   this->GetImpl()->SetNbOfBoundaryLayers(toNbOfBoundaryLayers);
678   SMESH::TPythonDump() << _this() << ".SetNbOfBoundaryLayers( " << toNbOfBoundaryLayers << " )";
679 }
680
681 //=======================================================================
682 //function : GetNbOfBoundaryLayers
683 //=======================================================================
684 CORBA::Short HYBRIDPlugin_Hypothesis_i::GetNbOfBoundaryLayers()
685 {
686   ASSERT(myBaseImpl);
687   return this->GetImpl()->GetNbOfBoundaryLayers();
688 }
689
690 //=======================================================================
691 //function : SetEnforcedVertex
692 //=======================================================================
693
694 bool HYBRIDPlugin_Hypothesis_i::SetEnforcedVertex(CORBA::Double x, CORBA::Double y, CORBA::Double z, CORBA::Double size)
695     throw (SALOME::SALOME_Exception) {
696   ASSERT(myBaseImpl);
697   return p_SetEnforcedVertex(size, x, y, z);
698 }
699
700 bool HYBRIDPlugin_Hypothesis_i::SetEnforcedVertexNamed(CORBA::Double x, CORBA::Double y, CORBA::Double z, CORBA::Double size, const char* theVertexName)
701     throw (SALOME::SALOME_Exception) {
702   ASSERT(myBaseImpl);
703   return p_SetEnforcedVertex(size, x, y, z, theVertexName, "", "");
704 }
705
706 bool HYBRIDPlugin_Hypothesis_i::SetEnforcedVertexWithGroup(CORBA::Double x, CORBA::Double y, CORBA::Double z, CORBA::Double size, const char* theGroupName)
707     throw (SALOME::SALOME_Exception) {
708   ASSERT(myBaseImpl);
709   return p_SetEnforcedVertex(size, x, y, z, "", "", theGroupName);
710 }
711
712 bool HYBRIDPlugin_Hypothesis_i::SetEnforcedVertexNamedWithGroup(CORBA::Double x, CORBA::Double y, CORBA::Double z, CORBA::Double size, const char* theVertexName, const char* theGroupName)
713     throw (SALOME::SALOME_Exception) {
714   ASSERT(myBaseImpl);
715   return p_SetEnforcedVertex(size, x, y, z, theVertexName, "", theGroupName);
716 }
717
718 bool HYBRIDPlugin_Hypothesis_i::SetEnforcedVertexGeom(GEOM::GEOM_Object_ptr theVertex, CORBA::Double size)
719     throw (SALOME::SALOME_Exception) {
720   ASSERT(myBaseImpl);
721   
722   if ((theVertex->GetShapeType() != GEOM::VERTEX) && (theVertex->GetShapeType() != GEOM::COMPOUND)) {
723     THROW_SALOME_CORBA_EXCEPTION("theVertex shape type is not VERTEX or COMPOUND", SALOME::BAD_PARAM);
724   }
725   
726   std::string theVertexEntry = theVertex->GetStudyEntry();
727   CORBA::Double x = 0, y = 0, z = 0;
728   CORBA::Boolean isCompound = false;
729   GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine();
730   SMESH_Gen_i *smeshGen = SMESH_Gen_i::GetSMESHGen();
731   if (theVertexEntry.empty()) {
732     std::string aName;
733     if (theVertex->GetShapeType() == GEOM::VERTEX) {
734       aName = "Vertex_";
735     }
736     if (theVertex->GetShapeType() == GEOM::COMPOUND) {
737       aName = "Compound_";
738       isCompound = true;
739     }
740     aName += theVertex->GetEntry();
741     SALOMEDS::SObject_ptr theSVertex = geomGen->PublishInStudy(smeshGen->GetCurrentStudy(), NULL, theVertex, aName.c_str());
742     if (!theSVertex->_is_nil())
743       theVertexEntry = theSVertex->GetID();
744   }
745   if (theVertexEntry.empty())
746     THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM );
747
748   if (theVertex->GetShapeType() == GEOM::VERTEX) {
749     GEOM::GEOM_IMeasureOperations_var measureOp = geomGen->GetIMeasureOperations( smeshGen->GetCurrentStudy()->StudyId() );
750     if (CORBA::is_nil(measureOp))
751       return false;
752     
753     measureOp->PointCoordinates (theVertex, x, y, z);
754   }
755
756   std::string theVertexName = theVertex->GetName();
757   
758   return p_SetEnforcedVertex(size, x, y, z, theVertexName.c_str(), theVertexEntry.c_str(), "", isCompound);
759 }
760
761 bool HYBRIDPlugin_Hypothesis_i::SetEnforcedVertexGeomWithGroup(GEOM::GEOM_Object_ptr theVertex, CORBA::Double size, const char* theGroupName)
762     throw (SALOME::SALOME_Exception) {
763   ASSERT(myBaseImpl);
764   
765   if ((theVertex->GetShapeType() != GEOM::VERTEX) && (theVertex->GetShapeType() != GEOM::COMPOUND)) {
766     MESSAGE("theVertex shape type is not VERTEX or COMPOUND");
767     THROW_SALOME_CORBA_EXCEPTION("theVertex shape type is not VERTEX or COMPOUND", SALOME::BAD_PARAM);
768   }
769   
770   std::string theVertexEntry = theVertex->GetStudyEntry();
771   CORBA::Double x = 0, y = 0, z = 0;
772   CORBA::Boolean isCompound = false;
773   GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine();
774   SMESH_Gen_i *smeshGen = SMESH_Gen_i::GetSMESHGen();
775   if (theVertexEntry.empty()) {
776     std::string aName;
777     if (theVertex->GetShapeType() == GEOM::VERTEX) {
778       aName = "Vertex_";
779     }
780     if (theVertex->GetShapeType() == GEOM::COMPOUND) {
781       aName = "Compound_";
782       isCompound = true;
783     }
784     aName += theVertex->GetEntry();
785     SALOMEDS::SObject_ptr theSVertex = geomGen->PublishInStudy(smeshGen->GetCurrentStudy(), NULL, theVertex, aName.c_str());
786     if (!theSVertex->_is_nil())
787       theVertexEntry = theSVertex->GetID();
788   }
789   if (theVertexEntry.empty())
790     THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM );
791
792   if (theVertex->GetShapeType() == GEOM::VERTEX) {
793     GEOM::GEOM_IMeasureOperations_var measureOp = geomGen->GetIMeasureOperations( smeshGen->GetCurrentStudy()->StudyId() );
794     if (CORBA::is_nil(measureOp))
795       return false;
796     
797     measureOp->PointCoordinates (theVertex, x, y, z);
798   }
799     
800   std::string theVertexName = theVertex->GetName();
801   
802   return p_SetEnforcedVertex(size, x, y, z, theVertexName.c_str(), theVertexEntry.c_str(), theGroupName, isCompound);
803 }
804
805 bool HYBRIDPlugin_Hypothesis_i:: p_SetEnforcedVertex(CORBA::Double size, CORBA::Double x, CORBA::Double y, CORBA::Double z,
806                                                    const char* theVertexName, const char* theVertexEntry, const char* theGroupName,
807                                                    CORBA::Boolean isCompound)
808     throw (SALOME::SALOME_Exception) {
809   ASSERT(myBaseImpl);
810   bool newValue = false;
811
812   ::HYBRIDPlugin_Hypothesis::TCoordsHYBRIDEnforcedVertexMap coordsList;
813   ::HYBRIDPlugin_Hypothesis::TGeomEntryHYBRIDEnforcedVertexMap enfVertexEntryList;
814   if (std::string(theVertexEntry).empty()) {
815     coordsList = this->GetImpl()->_GetEnforcedVerticesByCoords();
816     std::vector<double> coords;
817     coords.push_back(x);
818     coords.push_back(y);
819     coords.push_back(z);
820     if (coordsList.find(coords) == coordsList.end()) {
821       newValue = true;
822     }
823     else {
824       ::HYBRIDPlugin_Hypothesis::THYBRIDEnforcedVertex *enfVertex = this->GetImpl()->GetEnforcedVertex(x, y, z);
825       if ((enfVertex->name != theVertexName) || (enfVertex->groupName != theGroupName) || (enfVertex->size != size)) {
826 //          this->GetImpl()->ClearEnforcedVertex(theFaceEntry, x, y, z);
827         newValue = true;
828       }
829       else {
830       }
831     }
832
833     if (newValue) {
834       if (std::string(theVertexName).empty()) {
835         if (std::string(theGroupName).empty())
836           SMESH::TPythonDump() << "isDone = " << _this() << ".SetEnforcedVertex(" << x << ", " << y << ", " << z << ", " << size << ")";
837         else
838           SMESH::TPythonDump() << "isDone = " << _this() << ".SetEnforcedVertexWithGroup(" << x << ", " << y << ", " << z << ", " << size << ", \"" << theGroupName << "\")";
839       }
840       else {
841         if (std::string(theGroupName).empty())
842           SMESH::TPythonDump() << "isDone = " << _this() << ".SetEnforcedVertexNamed(" << x << ", " << y << ", " << z << ", " << size  << ", \"" << theVertexName << "\")";
843         else
844           SMESH::TPythonDump() << "isDone = " << _this() << ".SetEnforcedVertexNamedWithGroup(" << x << ", " << y << ", " << z << ", " << size  << ", \"" << theVertexName << "\", \"" << theGroupName << "\")";
845       }
846     }
847   } 
848   else {
849 //   if (isCompound || (!isCompound && !std::string(theVertexEntry).empty())) {
850     enfVertexEntryList = this->GetImpl()->_GetEnforcedVerticesByEntry();
851 //     ::BLSURFPlugin_Hypothesis::TGeomEntryHYBRIDEnforcedVertexMap::const_iterator it = enfVertexEntryList.find(theVertexEntry);
852     if ( enfVertexEntryList.find(theVertexEntry) == enfVertexEntryList.end()) {
853       newValue = true;
854     }
855     else {
856       ::HYBRIDPlugin_Hypothesis::THYBRIDEnforcedVertex *enfVertex = this->GetImpl()->GetEnforcedVertex(theVertexEntry);
857       if ((enfVertex->name != theVertexName) || (enfVertex->groupName != theGroupName) || (enfVertex->size != size)) {
858 //          this->GetImpl()->ClearEnforcedVertex(theFaceEntry, x, y, z);
859         newValue = true;
860       }
861       else {
862       }
863     }
864
865     if (newValue) {
866       if (std::string(theGroupName).empty())
867         SMESH::TPythonDump() << "isDone = " << _this() << ".SetEnforcedVertexGeom(" << theVertexEntry << ", " << size << ")";
868       else
869         SMESH::TPythonDump() << "isDone = " << _this() << ".SetEnforcedVertexGeomWithGroup(" << theVertexEntry << ", " << size << ", \"" << theGroupName << "\")";
870     }
871   }
872
873   if (newValue)
874     this->GetImpl()->SetEnforcedVertex(theVertexName, theVertexEntry, theGroupName, size, x, y, z, isCompound);
875
876   return newValue;
877 }
878
879 //=======================================================================
880 //function : GetEnforcedVertex
881 //=======================================================================
882
883 CORBA::Double HYBRIDPlugin_Hypothesis_i::GetEnforcedVertex(CORBA::Double x, CORBA::Double y, CORBA::Double z)
884   throw (SALOME::SALOME_Exception)
885 {
886   ASSERT(myBaseImpl);
887   try {
888     bool isDone = this->GetImpl()->GetEnforcedVertex(x,y,z)->size;
889     SMESH::TPythonDump() << "aSize = " << _this() << ".GetEnforcedVertex(" << x << ", " << y << ", " << z << ")";
890     return isDone;
891   }
892   catch (const std::invalid_argument& ex) {
893     SALOME::ExceptionStruct ExDescription;
894     ExDescription.text = ex.what();
895     ExDescription.type = SALOME::BAD_PARAM;
896     ExDescription.sourceFile = "HYBRIDPlugin_Hypothesis_i.cxx";
897     ExDescription.lineNumber = 513;
898     throw SALOME::SALOME_Exception(ExDescription);
899   }
900   catch (SALOME_Exception& ex) {
901     THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
902   }
903 }
904
905 //=======================================================================
906 //function : GetEnforcedVertex
907 //=======================================================================
908
909 CORBA::Double HYBRIDPlugin_Hypothesis_i::GetEnforcedVertexGeom(GEOM::GEOM_Object_ptr theVertex)
910   throw (SALOME::SALOME_Exception)
911 {
912   ASSERT(myBaseImpl);
913   
914   if ((theVertex->GetShapeType() != GEOM::VERTEX) && (theVertex->GetShapeType() != GEOM::COMPOUND)) {
915     MESSAGE("theVertex shape type is not VERTEX or COMPOUND");
916     THROW_SALOME_CORBA_EXCEPTION("theVertex shape type is not VERTEX or COMPOUND", SALOME::BAD_PARAM);
917   }
918   
919   std::string theVertexEntry = theVertex->GetStudyEntry();
920   if (theVertexEntry.empty()) {
921     GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine();
922     SMESH_Gen_i *smeshGen = SMESH_Gen_i::GetSMESHGen();
923     std::string aName;
924     if (theVertex->GetShapeType() == GEOM::VERTEX)
925       aName = "Vertex_";
926     if (theVertex->GetShapeType() == GEOM::COMPOUND)
927       aName = "Compound_";
928     aName += theVertex->GetEntry();
929     SALOMEDS::SObject_ptr theSVertex = geomGen->PublishInStudy(smeshGen->GetCurrentStudy(), NULL, theVertex, aName.c_str());
930     if (!theSVertex->_is_nil())
931       theVertexEntry = theSVertex->GetID();
932   }
933   if (theVertexEntry.empty())
934     THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM );
935
936   std::string theVertexName = theVertex->GetName();
937   
938   try {
939     bool isDone = this->GetImpl()->GetEnforcedVertex(theVertexName)->size;
940     SMESH::TPythonDump() << "aSize = " << _this() << ".GetEnforcedVertexGeom(" << theVertex << ")";
941     return isDone;
942   }
943   catch (const std::invalid_argument& ex) {
944     SALOME::ExceptionStruct ExDescription;
945     ExDescription.text = ex.what();
946     ExDescription.type = SALOME::BAD_PARAM;
947     ExDescription.sourceFile = "HYBRIDPlugin_Hypothesis_i.cxx";
948     ExDescription.lineNumber = 538;
949     throw SALOME::SALOME_Exception(ExDescription);
950   }
951   catch (SALOME_Exception& ex) {
952     THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
953   }
954 }
955
956 //=======================================================================
957 //function : GetEnforcedVertices
958 //=======================================================================
959
960 HYBRIDPlugin::HYBRIDEnforcedVertexList* HYBRIDPlugin_Hypothesis_i::GetEnforcedVertices()
961 {
962   ASSERT(myBaseImpl);
963   HYBRIDPlugin::HYBRIDEnforcedVertexList_var result = new HYBRIDPlugin::HYBRIDEnforcedVertexList();
964
965   const ::HYBRIDPlugin_Hypothesis::THYBRIDEnforcedVertexList enfVertexList = this->GetImpl()->_GetEnforcedVertices();
966   result->length( enfVertexList.size() );
967
968   ::HYBRIDPlugin_Hypothesis::THYBRIDEnforcedVertexList::const_iterator it = enfVertexList.begin();
969
970   for (int i = 0 ; it != enfVertexList.end(); ++it, ++i ) {
971     ::HYBRIDPlugin_Hypothesis::THYBRIDEnforcedVertex* currentVertex = (*it);
972     HYBRIDPlugin::HYBRIDEnforcedVertex_var enfVertex = new HYBRIDPlugin::HYBRIDEnforcedVertex();
973     // Name
974     enfVertex->name = CORBA::string_dup(currentVertex->name.c_str());
975     // Geom Vertex Entry
976     enfVertex->geomEntry = CORBA::string_dup(currentVertex->geomEntry.c_str());
977     // Coords
978     HYBRIDPlugin::TCoords_var coords = new HYBRIDPlugin::TCoords();
979     coords->length(currentVertex->coords.size());
980     for (size_t ind = 0; ind < currentVertex->coords.size(); ind++)
981       coords[ind] = currentVertex->coords[ind];
982     enfVertex->coords = coords;
983     // Group Name
984     enfVertex->groupName = CORBA::string_dup(currentVertex->groupName.c_str());
985     // Size
986     enfVertex->size = currentVertex->size;
987     // isCompound
988     enfVertex->isCompound = currentVertex->isCompound;
989     
990     result[i]=enfVertex;
991     }
992   
993 //   SMESH::TPythonDump() << "allEnforcedVertices = " << _this() << ".GetEnforcedVertices()";
994
995   return result._retn();
996 }
997
998 //=======================================================================
999 //function : RemoveEnforcedVertex
1000 //=======================================================================
1001
1002 bool HYBRIDPlugin_Hypothesis_i::RemoveEnforcedVertex(CORBA::Double x, CORBA::Double y, CORBA::Double z)
1003   throw (SALOME::SALOME_Exception)
1004 {
1005   ASSERT(myBaseImpl);
1006   try {
1007     bool res = this->GetImpl()->RemoveEnforcedVertex(x,y,z);
1008     SMESH::TPythonDump() << " isDone = " << _this() << ".RemoveEnforcedVertex( " << x << ", " << y << ", " << z << " )";
1009     return res;
1010   }
1011   catch (const std::invalid_argument& ex) {
1012     SALOME::ExceptionStruct ExDescription;
1013     ExDescription.text = ex.what();
1014     ExDescription.type = SALOME::BAD_PARAM;
1015     ExDescription.sourceFile = "HYBRIDPlugin_Hypothesis_i.cxx";
1016     ExDescription.lineNumber = 625;
1017     throw SALOME::SALOME_Exception(ExDescription);
1018   }
1019   catch (SALOME_Exception& ex) {
1020     THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
1021   }
1022 }
1023
1024 bool HYBRIDPlugin_Hypothesis_i::RemoveEnforcedVertexGeom(GEOM::GEOM_Object_ptr theVertex)
1025   throw (SALOME::SALOME_Exception)
1026 {
1027   ASSERT(myBaseImpl);
1028   
1029   if ((theVertex->GetShapeType() != GEOM::VERTEX) && (theVertex->GetShapeType() != GEOM::COMPOUND)) {
1030     MESSAGE("theVertex shape type is not VERTEX or COMPOUND");
1031     THROW_SALOME_CORBA_EXCEPTION("theVertex shape type is not VERTEX or COMPOUND", SALOME::BAD_PARAM);
1032   }
1033   
1034   std::string theVertexEntry = theVertex->GetStudyEntry();
1035   if (theVertexEntry.empty()) {
1036     GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine();
1037     SMESH_Gen_i *smeshGen = SMESH_Gen_i::GetSMESHGen();
1038     std::string aName;
1039     if (theVertex->GetShapeType() == GEOM::VERTEX)
1040       aName = "Vertex_";
1041     if (theVertex->GetShapeType() == GEOM::COMPOUND)
1042       aName = "Compound_";
1043     aName += theVertex->GetEntry();
1044     SALOMEDS::SObject_ptr theSVertex = geomGen->PublishInStudy(smeshGen->GetCurrentStudy(), NULL, theVertex, aName.c_str());
1045     if (!theSVertex->_is_nil())
1046       theVertexEntry = theSVertex->GetID();
1047   }
1048   if (theVertexEntry.empty())
1049     THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM );
1050   
1051   try {
1052     bool res = this->GetImpl()->RemoveEnforcedVertex(0,0,0, theVertexEntry.c_str());
1053     SMESH::TPythonDump() << "isDone = " << _this() << ".RemoveEnforcedVertexGeom( " << theVertexEntry.c_str() << " )";
1054     return res;
1055   }
1056   catch (const std::invalid_argument& ex) {
1057     SALOME::ExceptionStruct ExDescription;
1058     ExDescription.text = ex.what();
1059     ExDescription.type = SALOME::BAD_PARAM;
1060     ExDescription.sourceFile = "HYBRIDPlugin_Hypothesis_i.cxx";
1061     ExDescription.lineNumber = 648;
1062     throw SALOME::SALOME_Exception(ExDescription);
1063   }
1064   catch (SALOME_Exception& ex) {
1065     THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
1066   }
1067 }
1068
1069 //=======================================================================
1070 //function : ClearEnforcedVertices
1071 //=======================================================================
1072
1073 void HYBRIDPlugin_Hypothesis_i::ClearEnforcedVertices()
1074 {
1075   ASSERT(myBaseImpl);
1076   this->GetImpl()->ClearEnforcedVertices();
1077   SMESH::TPythonDump () << _this() << ".ClearEnforcedVertices() ";
1078 }
1079
1080 //=======================================================================
1081 //function : ClearEnforcedMeshes
1082 //=======================================================================
1083
1084 void HYBRIDPlugin_Hypothesis_i::ClearEnforcedMeshes()
1085 {
1086   ASSERT(myBaseImpl);
1087   this->GetImpl()->ClearEnforcedMeshes();
1088   SMESH::TPythonDump () << _this() << ".ClearEnforcedMeshes() ";
1089 }
1090
1091 //=======================================================================
1092 //function : GetEnforcedMeshes
1093 //=======================================================================
1094
1095 HYBRIDPlugin::HYBRIDEnforcedMeshList* HYBRIDPlugin_Hypothesis_i::GetEnforcedMeshes()
1096 {
1097   ASSERT(myBaseImpl);
1098   HYBRIDPlugin::HYBRIDEnforcedMeshList_var result = new HYBRIDPlugin::HYBRIDEnforcedMeshList();
1099
1100   const ::HYBRIDPlugin_Hypothesis::THYBRIDEnforcedMeshList enfMeshList = this->GetImpl()->_GetEnforcedMeshes();
1101   result->length( enfMeshList.size() );
1102
1103   ::HYBRIDPlugin_Hypothesis::THYBRIDEnforcedMeshList::const_iterator it = enfMeshList.begin();
1104
1105   for (int i = 0 ; it != enfMeshList.end(); ++it, ++i ) {
1106     ::HYBRIDPlugin_Hypothesis::THYBRIDEnforcedMesh* currentMesh = (*it);
1107     HYBRIDPlugin::HYBRIDEnforcedMesh_var enfMesh = new HYBRIDPlugin::HYBRIDEnforcedMesh();
1108     // Name
1109     enfMesh->name = CORBA::string_dup(currentMesh->name.c_str());
1110     // Mesh Entry
1111     enfMesh->entry = CORBA::string_dup(currentMesh->entry.c_str());
1112     // isCompound
1113     enfMesh->elementType = currentMesh->elementType;
1114     // Group Name
1115     enfMesh->groupName = CORBA::string_dup(currentMesh->groupName.c_str());
1116     
1117     result[i]=enfMesh;
1118     }
1119   
1120 //   SMESH::TPythonDump() << "allEnforcedVertices = " << _this() << ".GetEnforcedVertices()";
1121
1122   return result._retn();
1123 }
1124
1125 /*!
1126  * \brief Adds enforced elements of type elementType using another mesh/sub-mesh/mesh group theSource. The elements will be grouped in theGroupName.
1127  */
1128 bool HYBRIDPlugin_Hypothesis_i::SetEnforcedMeshWithGroup(SMESH::SMESH_IDSource_ptr theSource, SMESH::ElementType theType, const char* theGroupName)
1129   throw (SALOME::SALOME_Exception)
1130 {
1131 // #if HYBRID_VERSION >= 42
1132   return p_SetEnforcedMesh(theSource, theType, "", theGroupName);
1133 // #else
1134 //   SALOME::ExceptionStruct ExDescription;
1135 //   ExDescription.text = "Bad version of HYBRID. It must >= 4.2.";
1136 //   ExDescription.type = SALOME::BAD_PARAM;
1137 //   ExDescription.sourceFile = "HYBRIDPlugin_Hypothesis_i.cxx";
1138 //   ExDescription.lineNumber = 719;
1139 //   throw SALOME::SALOME_Exception(ExDescription);
1140 // #endif
1141 }
1142
1143 /*!
1144  * \brief Adds enforced elements of type elementType using another mesh/sub-mesh/mesh group theSource.
1145  */
1146 bool HYBRIDPlugin_Hypothesis_i::SetEnforcedMesh(SMESH::SMESH_IDSource_ptr theSource, SMESH::ElementType theType)
1147   throw (SALOME::SALOME_Exception)
1148 {
1149 // #if HYBRID_VERSION >= 42
1150   return p_SetEnforcedMesh(theSource, theType);
1151 // #else
1152 //   SALOME::ExceptionStruct ExDescription;
1153 //   ExDescription.text = "Bad version of HYBRID. It must >= 4.2.";
1154 //   ExDescription.type = SALOME::BAD_PARAM;
1155 //   ExDescription.sourceFile = "HYBRIDPlugin_Hypothesis_i.cxx";
1156 //   ExDescription.lineNumber = 750;
1157 //   throw SALOME::SALOME_Exception(ExDescription);
1158 // #endif
1159 }
1160
1161 /*!
1162  * \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.
1163  */
1164 bool HYBRIDPlugin_Hypothesis_i::SetEnforcedMeshSizeWithGroup(SMESH::SMESH_IDSource_ptr theSource, SMESH::ElementType theType, double theSize, const char* theGroupName)
1165   throw (SALOME::SALOME_Exception)
1166 {
1167 // #if HYBRID_VERSION >= 42
1168   return p_SetEnforcedMesh(theSource, theType, "", theGroupName);
1169 // #else
1170 //   SALOME::ExceptionStruct ExDescription;
1171 //   ExDescription.text = "Bad version of HYBRID. It must >= 4.2.";
1172 //   ExDescription.type = SALOME::BAD_PARAM;
1173 //   ExDescription.sourceFile = "HYBRIDPlugin_Hypothesis_i.cxx";
1174 //   ExDescription.lineNumber = 750;
1175 //   throw SALOME::SALOME_Exception(ExDescription);
1176 // #endif
1177 }
1178
1179 /*!
1180  * \brief OBSOLETE FUNCTION - Adds enforced elements of type elementType using another mesh/sub-mesh/mesh group theSource and a size.
1181  */
1182 bool HYBRIDPlugin_Hypothesis_i::SetEnforcedMeshSize(SMESH::SMESH_IDSource_ptr theSource, SMESH::ElementType theType, double theSize)
1183   throw (SALOME::SALOME_Exception)
1184 {
1185 // #if HYBRID_VERSION >= 42
1186   return p_SetEnforcedMesh(theSource, theType);
1187 // #else
1188 //   SALOME::ExceptionStruct ExDescription;
1189 //   ExDescription.text = "Bad version of HYBRID. It must >= 4.2.";
1190 //   ExDescription.type = SALOME::BAD_PARAM;
1191 //   ExDescription.sourceFile = "HYBRIDPlugin_Hypothesis_i.cxx";
1192 //   ExDescription.lineNumber = 750;
1193 //   throw SALOME::SALOME_Exception(ExDescription);
1194 // #endif
1195 }
1196
1197 bool HYBRIDPlugin_Hypothesis_i::p_SetEnforcedMesh(SMESH::SMESH_IDSource_ptr theSource, SMESH::ElementType theType, const char* theName, const char* theGroupName)
1198   throw (SALOME::SALOME_Exception)
1199 {
1200   ASSERT(myBaseImpl);
1201   
1202   if (CORBA::is_nil( theSource ))
1203   {
1204     SALOME::ExceptionStruct ExDescription;
1205     ExDescription.text = "The source mesh CORBA object is NULL";
1206     ExDescription.type = SALOME::BAD_PARAM;
1207     ExDescription.sourceFile = "HYBRIDPlugin_Hypothesis_i.cxx";
1208     ExDescription.lineNumber = 840;
1209     throw SALOME::SALOME_Exception(ExDescription);
1210   }
1211   
1212   switch (theType) {
1213     case SMESH::NODE:
1214       break;
1215     case SMESH::EDGE:
1216       break;
1217     case SMESH::FACE:
1218       break;
1219     default:
1220       return false;
1221   }
1222   SMESH::array_of_ElementType_var types = theSource->GetTypes();
1223   if ( types->length() >= 1 && types[types->length()-1] <  theType)
1224   {
1225     return false;
1226 //     SALOME::ExceptionStruct ExDescription;
1227 //     ExDescription.text = "The source mesh has bad type";
1228 //     ExDescription.type = SALOME::BAD_PARAM;
1229 //     ExDescription.sourceFile = "HYBRIDPlugin_Hypothesis_i.cxx";
1230 //     ExDescription.lineNumber = 840;
1231 //     throw SALOME::SALOME_Exception(ExDescription);
1232   }
1233
1234
1235   SMESH_Gen_i *smeshGen = SMESH_Gen_i::GetSMESHGen();
1236   SALOMEDS::SObject_ptr SObj = smeshGen->ObjectToSObject(smeshGen->GetCurrentStudy(),theSource);
1237
1238   SMESH_Mesh_i* theMesh_i = SMESH::DownCast<SMESH_Mesh_i*>( theSource);
1239   SMESH_Group_i* theGroup_i = SMESH::DownCast<SMESH_Group_i*>( theSource);
1240   SMESH_GroupOnGeom_i* theGroupOnGeom_i = SMESH::DownCast<SMESH_GroupOnGeom_i*>( theSource);
1241
1242   std::string enfMeshName = theName;
1243   if (enfMeshName.empty())
1244     enfMeshName = SObj->GetName();
1245
1246   if (theMesh_i)
1247   {
1248     try {
1249       bool res = this->GetImpl()->SetEnforcedMesh(theMesh_i->GetImpl(), theType, enfMeshName , SObj->GetID(), theGroupName);
1250       if (theGroupName && theGroupName[0]) {
1251         SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMeshWithGroup( "
1252                               << theSource << ".GetMesh(), " << theType << ", \"" << theGroupName << "\" )";
1253       }
1254       else {
1255         SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMesh( "
1256                               << theSource << ".GetMesh(), " << theType << " )";
1257       }
1258
1259       return res;
1260     }
1261     catch (const std::invalid_argument& ex) {
1262       SALOME::ExceptionStruct ExDescription;
1263       ExDescription.text = ex.what();
1264       ExDescription.type = SALOME::BAD_PARAM;
1265       ExDescription.sourceFile = "HYBRIDPlugin_Hypothesis_i.cxx";
1266       ExDescription.lineNumber = 840;
1267       throw SALOME::SALOME_Exception(ExDescription);
1268     }
1269     catch (SALOME_Exception& ex) {
1270       THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
1271     }
1272   }
1273   else if (theGroup_i)// && types->length() == 1 && types[0] == theType)
1274   {
1275     try {
1276         bool res = this->GetImpl()->SetEnforcedGroup(theGroup_i->GetGroupDS()->GetMesh(), theGroup_i->GetListOfID(), theType, enfMeshName , SObj->GetID(), theGroupName);
1277         if (theGroupName && theGroupName[0]) {
1278           SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMeshWithGroup( " 
1279                                 << theSource << ", " << theType << ", \"" << theGroupName << "\" )";
1280         }
1281         else {
1282           SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMesh( " 
1283                                 << theSource << ", " << theType << " )";
1284         }
1285       return res;
1286     }
1287     catch (const std::invalid_argument& ex) {
1288       SALOME::ExceptionStruct ExDescription;
1289       ExDescription.text = ex.what();
1290       ExDescription.type = SALOME::BAD_PARAM;
1291       ExDescription.sourceFile = "HYBRIDPlugin_Hypothesis_i.cxx";
1292       ExDescription.lineNumber = 840;
1293       throw SALOME::SALOME_Exception(ExDescription);
1294     }
1295     catch (SALOME_Exception& ex) {
1296       THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
1297     }
1298   }
1299   else if (theGroupOnGeom_i)// && types->length() == 1 && types[0] == theType)
1300   {
1301       try {
1302         bool res = this->GetImpl()->SetEnforcedGroup(theGroupOnGeom_i->GetGroupDS()->GetMesh(),theGroupOnGeom_i->GetListOfID(), theType, enfMeshName , SObj->GetID(), theGroupName);
1303         if (theGroupName && theGroupName[0]) {
1304           SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMeshWithGroup( "
1305                                 << theSource << ", " << theType << ", \"" << theGroupName << "\" )";
1306         }
1307         else {
1308           SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMesh( "
1309                                 << theSource << ", " << theType << " )";
1310         }
1311         return res;
1312       }
1313       catch (const std::invalid_argument& ex) {
1314         SALOME::ExceptionStruct ExDescription;
1315       ExDescription.text = ex.what();
1316       ExDescription.type = SALOME::BAD_PARAM;
1317       ExDescription.sourceFile = "HYBRIDPlugin_Hypothesis_i.cxx";
1318       ExDescription.lineNumber = 840;
1319       throw SALOME::SALOME_Exception(ExDescription);
1320     }
1321     catch (SALOME_Exception& ex) {
1322       THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
1323     }
1324   }
1325   return false;
1326 }
1327 //=============================================================================
1328 /*!
1329  *  Get implementation
1330  */
1331 //=============================================================================
1332
1333 ::HYBRIDPlugin_Hypothesis* HYBRIDPlugin_Hypothesis_i::GetImpl()
1334 {
1335   return (::HYBRIDPlugin_Hypothesis*)myBaseImpl;
1336 }
1337
1338 //================================================================================
1339 /*!
1340  * \brief Verify whether hypothesis supports given entity type 
1341  */
1342 //================================================================================  
1343
1344 CORBA::Boolean HYBRIDPlugin_Hypothesis_i::IsDimSupported( SMESH::Dimension type )
1345 {
1346   return type == SMESH::DIM_3D;
1347 }
1348