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