Salome HOME
updated copyright message
[plugins/blsurfplugin.git] / src / BLSURFPlugin / BLSURFPlugin_Hypothesis_i.cxx
1 // Copyright (C) 2007-2023  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    : BLSURFPlugin_Hypothesis.cxx
22 // Authors : Francis KLOSS (OCC) & Patrick LAUG (INRIA) & Lioka RAZAFINDRAZAKA (CEA)
23 //           Size maps developement: Nicolas GEIMER (OCC) & Gilles DAVID (EURIWARE)
24 // ---
25 //
26 #include "BLSURFPlugin_Hypothesis_i.hxx"
27 #include "BLSURFPlugin_BLSURF.hxx"
28
29 #include <SMESH_Gen.hxx>
30 #include <SMESH_Gen_i.hxx>
31 #include <SMESH_Group_i.hxx>
32 #include <SMESH_PythonDump.hxx>
33
34 #include <SALOMEDS_wrap.hxx>
35 #include <Utils_CorbaException.hxx>
36 #include <utilities.h>
37
38 #include <stdexcept>
39 #include <cstring>
40 #include <boost/regex.hpp>
41
42 using namespace std;
43
44 namespace
45 {
46   //================================================================================
47   /*!
48    * \brief Return persistent ID of a mesh
49    *  \param [in] mesh - the mesh
50    *  \return int - -1 in case of failure
51    */
52   //================================================================================
53
54   int GetMeshPersistentId( SMESH::SMESH_Mesh_ptr mesh )
55   {
56     int id = -1;
57     if ( SMESH_Mesh_i* mesh_i = SMESH::DownCast<SMESH_Mesh_i*>( mesh ))
58       id = mesh_i->GetImpl().GetMeshDS()->GetPersistentId();
59     return id;
60   }
61
62   //================================================================================
63   /*!
64    * \brief Return persistent ID of a group or sub-mesh
65    *  \param [in] meshPart - the mesh part
66    *  \param [out] isGroup - return true if meshPart is a group
67    *  \return int - -1 in case if meshPart is neither a group nor a sub-mesh
68    */
69   //================================================================================
70
71   int GetMeshPartPersistentId( SMESH::SMESH_IDSource_ptr meshPart, bool & isGroup )
72   {
73     int id = -1;
74     isGroup = false;
75     SMESH_GroupBase_i* group_i = SMESH::DownCast<SMESH_GroupBase_i*>( meshPart );
76     if ( group_i )
77     {
78       id = group_i->GetLocalID();
79       isGroup = true;
80     }
81     else
82     {
83       SMESH::SMESH_subMesh_var subMesh = SMESH::SMESH_subMesh::_narrow( meshPart );
84       if ( !subMesh->_is_nil() )
85         id = subMesh->GetId();
86     }
87     return id;
88   }
89
90   //================================================================================
91   /*!
92    * \brief Find a mesh in the study by mesh persistent ID
93    */
94   //================================================================================
95
96   SMESH::SMESH_Mesh_ptr FindMeshByID( int theMeshID )
97   {
98     SMESH::SMESH_Mesh_var mesh;
99
100     SMESH_Gen_i*                gen = SMESH_Gen_i::GetSMESHGen();
101     CORBA::String_var  compDataType = gen->ComponentDataType();
102     SALOMEDS::Study_var      aStudy = gen->getStudyServant();
103     SALOMEDS::SComponent_wrap genSO = aStudy->FindComponent( compDataType.in() );
104     if ( !genSO->_is_nil() )
105     {
106       SALOMEDS::ChildIterator_wrap anIter = aStudy->NewChildIterator( genSO );
107       for ( ; anIter->More(); anIter->Next() )
108       {
109         SALOMEDS::SObject_wrap so = anIter->Value();
110         CORBA::Object_var      obj = gen->SObjectToObject( so );
111         mesh = SMESH::SMESH_Mesh::_narrow( obj );
112         if ( !mesh->_is_nil() && GetMeshPersistentId( mesh ) == theMeshID )
113           break;
114         mesh = SMESH::SMESH_Mesh::_nil();
115       }
116     }
117     return mesh._retn();
118   }
119
120   //================================================================================
121   /*!
122    * \brief Return a group by its ID
123    */
124   //================================================================================
125
126   SMESH::SMESH_GroupBase_ptr GetGroupByID( SMESH::SMESH_Mesh_ptr mesh, int ID )
127   {
128     SMESH::SMESH_GroupBase_var group;
129     if ( !CORBA::is_nil( mesh ))
130     {
131       SMESH::ListOfGroups_var groups = mesh->GetGroups();
132       for ( CORBA::ULong i = 0; i < groups->length(); ++i )
133         if ( SMESH_GroupBase_i* group_i = SMESH::DownCast<SMESH_GroupBase_i*>( groups[i] ))
134           if ( group_i->GetLocalID() == ID )
135           {
136             group = SMESH::SMESH_GroupBase::_narrow( groups[i] );
137             break;
138           }
139     }
140     return group._retn();
141   }
142
143   //================================================================================
144   /*!
145    * \brief Return a sub-mesh by sub-shape ID
146    */
147   //================================================================================
148
149   SMESH::SMESH_subMesh_ptr GetSubMeshByID( SMESH::SMESH_Mesh_ptr mesh,
150                                            const int             shapeID,
151                                            CORBA::Long           subMeshTag )
152   {
153     SMESH::SMESH_subMesh_var subMesh;
154     if ( !CORBA::is_nil( mesh ))
155     {
156       SMESH_Gen_i*              gen = SMESH_Gen_i::GetSMESHGen();
157       SALOMEDS::SObject_wrap meshSO = gen->ObjectToSObject( mesh );
158       SALOMEDS::Study_var    aStudy = gen->getStudyServant();
159       SALOMEDS::SObject_wrap subMeshRootSO;
160       if ( !meshSO->_is_nil() && meshSO->FindSubObject( subMeshTag, subMeshRootSO.inout() ))
161       {
162         SALOMEDS::ChildIterator_wrap anIter = aStudy->NewChildIterator( subMeshRootSO );
163         for ( ; anIter->More(); anIter->Next() )
164         {
165           SALOMEDS::SObject_wrap so = anIter->Value();
166           CORBA::Object_var      obj = gen->SObjectToObject( so );
167           subMesh = SMESH::SMESH_subMesh::_narrow( obj );
168           if ( !subMesh->_is_nil() && subMesh->GetId() == shapeID )
169             break;
170           subMesh = SMESH::SMESH_subMesh::_nil();
171         }
172       }
173       return subMesh._retn();
174     }
175     return subMesh._retn();
176   }
177
178 } // namespace
179
180 //=============================================================================
181 /*!
182  *  BLSURFPlugin_Hypothesis_i::BLSURFPlugin_Hypothesis_i
183  *
184  *  Constructor
185  */
186 //=============================================================================
187 BLSURFPlugin_Hypothesis_i::BLSURFPlugin_Hypothesis_i(PortableServer::POA_ptr thePOA,
188                                                      ::SMESH_Gen*            theGenImpl,
189                                                      bool                    theHasGEOM) :
190   SALOME::GenericObj_i(thePOA), SMESH_Hypothesis_i(thePOA)
191 {
192   myBaseImpl = new ::BLSURFPlugin_Hypothesis(theGenImpl->GetANewId(),
193                                              
194                                              theGenImpl,
195                                              theHasGEOM);
196 }
197
198 //=============================================================================
199 /*!
200  *  BLSURFPlugin_Hypothesis_i::~BLSURFPlugin_Hypothesis_i
201  *
202  *  Destructor
203  */
204 //=============================================================================
205 BLSURFPlugin_Hypothesis_i::~BLSURFPlugin_Hypothesis_i()
206 {
207 }
208
209 //=============================================================================
210 /*!
211  *  BLSURFPlugin_Hypothesis_i::GetMeshGemsVersion
212  *
213  *  Get version of MeshGems suite.
214  */
215 //=============================================================================
216 char* BLSURFPlugin_Hypothesis_i::GetMeshGemsVersion()
217 {
218   return CORBA::string_dup( this->GetImpl()->GetMeshGemsVersion().c_str() );
219 }
220
221 //=============================================================================
222 /*!
223  *  BLSURFPlugin_Hypothesis_i::SetPhysicalMesh
224  *
225  *  Set PhysicalMesh
226  */
227 //=============================================================================
228 void BLSURFPlugin_Hypothesis_i::SetPhysicalMesh(CORBA::Long theValue)
229 {
230   ASSERT(myBaseImpl);
231   this->GetImpl()->SetPhysicalMesh((::BLSURFPlugin_Hypothesis::PhysicalMesh) theValue);
232   SMESH::TPythonDump() << _this() << ".SetPhysicalMesh( " << theValue << " )";
233 }
234
235 //=============================================================================
236 /*!
237  *  BLSURFPlugin_Hypothesis_i::GetPhysicalMesh
238  *
239  *  Get PhysicalMesh
240  */
241 //=============================================================================
242 CORBA::Long BLSURFPlugin_Hypothesis_i::GetPhysicalMesh()
243 {
244   ASSERT(myBaseImpl);
245   return this->GetImpl()->GetPhysicalMesh();
246 }
247
248 //=============================================================================
249 /*!
250  *  BLSURFPlugin_Hypothesis_i::SetGeometricMesh
251  *
252  *  Set GeometricMesh
253  */
254
255 //=============================================================================
256 void BLSURFPlugin_Hypothesis_i::SetGeometricMesh(CORBA::Long theValue)
257 {
258   ASSERT(myBaseImpl);
259   this->GetImpl()->SetGeometricMesh((::BLSURFPlugin_Hypothesis::GeometricMesh) theValue);
260   SMESH::TPythonDump() << _this() << ".SetGeometricMesh( " << theValue << " )";
261 }
262
263 //=============================================================================
264 /*!
265  *  BLSURFPlugin_Hypothesis_i::GetGeometricMesh
266  *
267  *  Get GeometricMesh
268  */
269 //=============================================================================
270 CORBA::Long BLSURFPlugin_Hypothesis_i::GetGeometricMesh()
271 {
272   ASSERT(myBaseImpl);
273   return this->GetImpl()->GetGeometricMesh();
274 }
275
276 //=============================================================================
277 /*!
278  *  BLSURFPlugin_Hypothesis_i::SetPhySize
279  *
280  *  Set PhySize
281  */
282 //=============================================================================
283 void BLSURFPlugin_Hypothesis_i::SetPhySize(CORBA::Double theValue)
284 {
285   ASSERT(myBaseImpl);
286   this->GetImpl()->SetPhySize(theValue, false);
287   SMESH::TPythonDump() << _this() << ".SetPhySize( " << theValue << " )";
288 }
289
290 //=============================================================================
291 /*!
292  *  BLSURFPlugin_Hypothesis_i::SetPhySizeRel
293  *
294  *  Set Relative PhySize
295  */
296 //=============================================================================
297 void BLSURFPlugin_Hypothesis_i::SetPhySizeRel(CORBA::Double theValue)
298 {
299   ASSERT(myBaseImpl);
300   this->GetImpl()->SetPhySize(theValue, true);
301   SMESH::TPythonDump() << _this() << ".SetPhySizeRel( " << theValue << " )";
302 }
303
304 //=============================================================================
305 /*!
306  *  BLSURFPlugin_Hypothesis_i::GetPhySize
307  *
308  *  Get PhySize
309  */
310 //=============================================================================
311 CORBA::Double BLSURFPlugin_Hypothesis_i::GetPhySize()
312 {
313   ASSERT(myBaseImpl);
314   return this->GetImpl()->GetPhySize();
315 }
316
317 //=============================================================================
318 /*!
319  *  BLSURFPlugin_Hypothesis_i::IsPhySizeRel
320  *
321  *  Returns True if PhySize is relative
322  */
323 //=============================================================================
324 CORBA::Boolean BLSURFPlugin_Hypothesis_i::IsPhySizeRel()
325 {
326   ASSERT(myBaseImpl);
327   return this->GetImpl()->IsPhySizeRel();
328 }
329
330 //=============================================================================
331 void BLSURFPlugin_Hypothesis_i::SetMinSize(CORBA::Double theMinSize)
332 {
333   if (IsMinSizeRel() || GetMinSize() != theMinSize ) {
334     this->GetImpl()->SetMinSize(theMinSize, false);
335     SMESH::TPythonDump() << _this() << ".SetMinSize( " << theMinSize << " )";
336   }
337 }
338
339 //=============================================================================
340 void BLSURFPlugin_Hypothesis_i::SetMinSizeRel(CORBA::Double theMinSize)
341 {
342   if ( !IsMinSizeRel() || (GetMinSize() != theMinSize) ) {
343     this->GetImpl()->SetMinSize(theMinSize, true);
344     SMESH::TPythonDump() << _this() << ".SetMinSizeRel( " << theMinSize << " )";
345   }
346 }
347
348 //=============================================================================
349 CORBA::Double BLSURFPlugin_Hypothesis_i::GetMinSize()
350 {
351   return this->GetImpl()->GetMinSize();
352 }
353
354 //=============================================================================
355 CORBA::Boolean BLSURFPlugin_Hypothesis_i::IsMinSizeRel()
356 {
357   return this->GetImpl()->IsMinSizeRel();
358 }
359
360 //=============================================================================
361 void BLSURFPlugin_Hypothesis_i::SetMaxSize(CORBA::Double theMaxSize)
362 {
363   if (IsMaxSizeRel() || GetMaxSize() != theMaxSize) {
364     this->GetImpl()->SetMaxSize(theMaxSize, false);
365     SMESH::TPythonDump() << _this() << ".SetMaxSize( " << theMaxSize << " )";
366   }
367 }
368
369 //=============================================================================
370 void BLSURFPlugin_Hypothesis_i::SetMaxSizeRel(CORBA::Double theMaxSize)
371 {
372   if ( !IsMaxSizeRel() || (GetMaxSize() != theMaxSize) ) {
373     this->GetImpl()->SetMaxSize(theMaxSize, true);
374     SMESH::TPythonDump() << _this() << ".SetMaxSizeRel( " << theMaxSize << " )";
375   }
376 }
377
378 //=============================================================================
379 CORBA::Double BLSURFPlugin_Hypothesis_i::GetMaxSize()
380 {
381   return this->GetImpl()->GetMaxSize();
382 }
383
384 //=============================================================================
385 CORBA::Boolean BLSURFPlugin_Hypothesis_i::IsMaxSizeRel()
386 {
387   return this->GetImpl()->IsMaxSizeRel();
388 }
389
390
391 //=============================================================================
392 /*!
393  *  BLSURFPlugin_Hypothesis_i::SetUseGradation
394  *
395  *  Set true or false
396  */
397 //=============================================================================
398 void BLSURFPlugin_Hypothesis_i::SetUseGradation(CORBA::Boolean theValue)
399 {
400   if ( GetImpl()->GetUseGradation() != bool( theValue ))
401   {
402     this->GetImpl()->SetUseGradation(theValue);
403     std::string theValueStr = theValue ? "True" : "False";
404     SMESH::TPythonDump() << _this() << ".SetUseGradation( " << theValueStr.c_str() << " )";
405   }
406 }
407
408 //=============================================================================
409 /*!
410  *  BLSURFPlugin_Hypothesis_i::GetUseGradation
411  *
412  *  Get true or false
413  */
414 //=============================================================================
415 CORBA::Boolean BLSURFPlugin_Hypothesis_i::GetUseGradation()
416 {
417   return this->GetImpl()->GetUseGradation();
418 }
419
420 //=============================================================================
421 /*!
422  *  BLSURFPlugin_Hypothesis_i::SetGradation
423  *
424  *  Set Gradation
425  */
426 //=============================================================================
427 void BLSURFPlugin_Hypothesis_i::SetGradation(CORBA::Double theValue)
428 {
429   this->GetImpl()->SetGradation(theValue);
430
431   if ( theValue < 0 )
432     SetUseGradation( false );
433   else
434     SMESH::TPythonDump() << _this() << ".SetGradation( " << theValue << " )";
435 }
436
437 //=============================================================================
438 /*!
439  *  BLSURFPlugin_Hypothesis_i::GetGradation
440  *
441  *  Get Gradation
442  */
443 //=============================================================================
444 CORBA::Double BLSURFPlugin_Hypothesis_i::GetGradation()
445 {
446   return this->GetImpl()->GetGradation();
447 }
448
449 //=============================================================================
450 /*!
451  *  BLSURFPlugin_Hypothesis_i::SetUseVolumeGradation
452  *
453  *  Set true or false
454  */
455 //=============================================================================
456 void BLSURFPlugin_Hypothesis_i::SetUseVolumeGradation(CORBA::Boolean theValue)
457 {
458   if ( GetImpl()->GetUseVolumeGradation() != bool( theValue ))
459   {
460     this->GetImpl()->SetUseVolumeGradation(theValue);
461     std::string theValueStr = theValue ? "True" : "False";
462     SMESH::TPythonDump() << _this() << ".SetUseVolumeGradation( " << theValueStr.c_str() << " )";
463   }
464 }
465
466 //=============================================================================
467 /*!
468  *  BLSURFPlugin_Hypothesis_i::GetUseVolumeGradation
469  *
470  *  Get true or false
471  */
472 //=============================================================================
473 CORBA::Boolean BLSURFPlugin_Hypothesis_i::GetUseVolumeGradation()
474 {
475   return this->GetImpl()->GetUseVolumeGradation();
476 }
477
478 //=============================================================================
479 /*!
480  *  BLSURFPlugin_Hypothesis_i::SetVolumeGradation
481  *
482  *  Set VolumeGradation
483  */
484 //=============================================================================
485 void BLSURFPlugin_Hypothesis_i::SetVolumeGradation(CORBA::Double theValue)
486 {
487   this->GetImpl()->SetVolumeGradation(theValue);
488   if ( theValue < 0 )
489     SetUseVolumeGradation( false );
490   else
491     SMESH::TPythonDump() << _this() << ".SetVolumeGradation( " << theValue << " )";
492 }
493
494 //=============================================================================
495 /*!
496  *  BLSURFPlugin_Hypothesis_i::GetVolumeGradation
497  *
498  *  Get VolumeGradation
499  */
500 //=============================================================================
501 CORBA::Double BLSURFPlugin_Hypothesis_i::GetVolumeGradation()
502 {
503   return this->GetImpl()->GetVolumeGradation();
504 }
505
506 //=============================================================================
507 /*!
508  *  BLSURFPlugin_Hypothesis_i::SetQuadAllowed
509  *
510  *  Set true or false
511  *
512  *  DEPRACATED, kept for python script compatibility
513  *
514  *  TO be removed in Salome 9
515  */
516 //=============================================================================
517 void BLSURFPlugin_Hypothesis_i::SetQuadAllowed(CORBA::Boolean theValue)
518 {
519   ::BLSURFPlugin_Hypothesis::ElementType theElementType = theValue ?
520                   ::BLSURFPlugin_Hypothesis::QuadrangleDominant : ::BLSURFPlugin_Hypothesis::Triangles;
521   this->GetImpl()->SetElementType(theElementType);
522   SMESH::TPythonDump() << _this() << ".SetElementType( " << theElementType << " )";
523 }
524
525 //=============================================================================
526 /*!
527  *  BLSURFPlugin_Hypothesis_i::SetElementType
528  *
529  *  Set ElementType
530  */
531 //=============================================================================
532 void BLSURFPlugin_Hypothesis_i::SetElementType(CORBA::Long theValue)
533 {
534   this->GetImpl()->SetElementType((::BLSURFPlugin_Hypothesis::ElementType) theValue);
535   SMESH::TPythonDump() << _this() << ".SetElementType( " << theValue << " )";
536 }
537 //=============================================================================
538 /*!
539  *  BLSURFPlugin_Hypothesis_i::GetElementType
540  *
541  *  Get ElementType
542  */
543 //=============================================================================
544 CORBA::Long BLSURFPlugin_Hypothesis_i::GetElementType()
545 {
546   return this->GetImpl()->GetElementType();
547 }
548
549 //=============================================================================
550 /*!
551  *  BLSURFPlugin_Hypothesis_i::SetAngleMesh
552  *
553  *  Set AngleMesh
554  */
555 //=============================================================================
556 void BLSURFPlugin_Hypothesis_i::SetAngleMesh(CORBA::Double theValue)
557 {
558   this->GetImpl()->SetAngleMesh(theValue);
559   SMESH::TPythonDump() << _this() << ".SetAngleMesh( " << theValue << " )";
560 }
561
562 //=============================================================================
563 /*!
564  *  BLSURFPlugin_Hypothesis_i::GetAngleMesh
565  *
566  *  Get AngleMesh
567  */
568 //=============================================================================
569 CORBA::Double BLSURFPlugin_Hypothesis_i::GetAngleMesh()
570 {
571   return this->GetImpl()->GetAngleMesh();
572 }
573
574 //=============================================================================
575 /*!
576  *  BLSURFPlugin_Hypothesis_i::SetChordalError
577  *
578  *  Set Chordal Error
579  */
580 //=============================================================================
581 void BLSURFPlugin_Hypothesis_i::SetChordalError(CORBA::Double theValue)
582 {
583   this->GetImpl()->SetChordalError(theValue);
584   SMESH::TPythonDump() << _this() << ".SetChordalError( " << theValue << " )";
585 }
586
587 //=============================================================================
588 /*!
589  *  BLSURFPlugin_Hypothesis_i::GetChordalError
590  *
591  *  Get Chordal Error
592  */
593 //=============================================================================
594 CORBA::Double BLSURFPlugin_Hypothesis_i::GetChordalError()
595 {
596   return this->GetImpl()->GetChordalError();
597 }
598
599 //=============================================================================
600 /*!
601  *  BLSURFPlugin_Hypothesis_i::SetAnisotropic
602  *
603  *  Set true or false
604  */
605 //=============================================================================
606 void BLSURFPlugin_Hypothesis_i::SetAnisotropic(CORBA::Boolean theValue)
607 {
608   this->GetImpl()->SetAnisotropic(theValue);
609   std::string theValueStr = theValue ? "True" : "False";
610   SMESH::TPythonDump() << _this() << ".SetAnisotropic( " << theValueStr.c_str() << " )";
611 }
612
613 //=============================================================================
614 /*!
615  *  BLSURFPlugin_Hypothesis_i::GetAnisotropic
616  *
617  *  Get true or false
618  */
619 //=============================================================================
620 CORBA::Boolean BLSURFPlugin_Hypothesis_i::GetAnisotropic()
621 {
622   return this->GetImpl()->GetAnisotropic();
623 }
624
625 //=============================================================================
626 /*!
627  *  BLSURFPlugin_Hypothesis_i::SetAnisotropicRatio
628  *
629  *  Set Anisotropic Ratio
630  */
631 //=============================================================================
632 void BLSURFPlugin_Hypothesis_i::SetAnisotropicRatio(CORBA::Double theValue)
633 {
634   this->GetImpl()->SetAnisotropicRatio(theValue);
635   SMESH::TPythonDump() << _this() << ".SetAnisotropicRatio( " << theValue << " )";
636 }
637
638 //=============================================================================
639 /*!
640  *  BLSURFPlugin_Hypothesis_i::GetAnisotropicRatio
641  *
642  *  Get Anisotropic Ratio
643  */
644 //=============================================================================
645 CORBA::Double BLSURFPlugin_Hypothesis_i::GetAnisotropicRatio()
646 {
647   return this->GetImpl()->GetAnisotropicRatio();
648 }
649
650
651 //=============================================================================
652 /*!
653  *  BLSURFPlugin_Hypothesis_i::SetRemoveTinyEdges
654  *
655  *  Set true or false
656  */
657 //=============================================================================
658 void BLSURFPlugin_Hypothesis_i::SetRemoveTinyEdges(CORBA::Boolean theValue) {
659   ASSERT(myBaseImpl);
660   this->GetImpl()->SetRemoveTinyEdges(theValue);
661   std::string theValueStr = theValue ? "True" : "False";
662   SMESH::TPythonDump() << _this() << ".SetRemoveTinyEdges( " << theValueStr.c_str() << " )";
663 }
664
665 //=============================================================================
666 /*!
667  *  BLSURFPlugin_Hypothesis_i::GetRemoveTinyEdges
668  *
669  *  Get true or false
670  */
671 //=============================================================================
672 CORBA::Boolean BLSURFPlugin_Hypothesis_i::GetRemoveTinyEdges() {
673   ASSERT(myBaseImpl);
674   return this->GetImpl()->GetRemoveTinyEdges();
675 }
676
677 //=============================================================================
678 /*!
679  *  BLSURFPlugin_Hypothesis_i::SetTinyEdgeLength
680  *
681  *  Set Tiny Edge Length
682  */
683 //=============================================================================
684 void BLSURFPlugin_Hypothesis_i::SetTinyEdgeLength(CORBA::Double theValue) {
685   ASSERT(myBaseImpl);
686   this->GetImpl()->SetTinyEdgeLength(theValue);
687   SMESH::TPythonDump() << _this() << ".SetTinyEdgeLength( " << theValue << " )";
688 }
689
690 //=============================================================================
691 /*!
692  *  BLSURFPlugin_Hypothesis_i::GetTinyEdgeLength
693  *
694  *  Get Tiny Edge Length
695  */
696 //=============================================================================
697 CORBA::Double BLSURFPlugin_Hypothesis_i::GetTinyEdgeLength() {
698   ASSERT(myBaseImpl);
699   return this->GetImpl()->GetTinyEdgeLength();
700 }
701
702 //=============================================================================
703 /*!
704  *  BLSURFPlugin_Hypothesis_i::SetOptimiseTinyEdges
705  *
706  *  Set true or false
707  */
708 //=============================================================================
709 void BLSURFPlugin_Hypothesis_i::SetOptimiseTinyEdges(CORBA::Boolean theValue) {
710   ASSERT(myBaseImpl);
711   this->GetImpl()->SetOptimiseTinyEdges(theValue);
712   std::string theValueStr = theValue ? "True" : "False";
713   SMESH::TPythonDump() << _this() << ".SetOptimiseTinyEdges( " << theValueStr.c_str() << " )";
714 }
715
716 //=============================================================================
717 /*!
718  *  BLSURFPlugin_Hypothesis_i::GetOptimiseTinyEdges
719  *
720  *  Get true or false
721  */
722 //=============================================================================
723 CORBA::Boolean BLSURFPlugin_Hypothesis_i::GetOptimiseTinyEdges() {
724   ASSERT(myBaseImpl);
725   return this->GetImpl()->GetOptimiseTinyEdges();
726 }
727
728 //=============================================================================
729 /*!
730  *  BLSURFPlugin_Hypothesis_i::SetTinyEdgeOptimisationLength
731  *
732  *  Set Tiny Edge OptimisationLength
733  */
734 //=============================================================================
735 void BLSURFPlugin_Hypothesis_i::SetTinyEdgeOptimisationLength(CORBA::Double theValue) {
736   ASSERT(myBaseImpl);
737   this->GetImpl()->SetTinyEdgeOptimisationLength(theValue);
738   SMESH::TPythonDump() << _this() << ".SetTinyEdgeOptimisationLength( " << theValue << " )";
739 }
740
741 //=============================================================================
742 /*!
743  *  BLSURFPlugin_Hypothesis_i::GetTinyEdgeOptimisationLength
744  *
745  *  Get Tiny Edge OptimisationLength
746  */
747 //=============================================================================
748 CORBA::Double BLSURFPlugin_Hypothesis_i::GetTinyEdgeOptimisationLength() {
749   ASSERT(myBaseImpl);
750   return this->GetImpl()->GetTinyEdgeOptimisationLength();
751 }
752
753 //=============================================================================
754 /*!
755  *  BLSURFPlugin_Hypothesis_i::SetCorrectSurfaceIntersection
756  *
757  *  Set true or false
758  */
759 //=============================================================================
760 void BLSURFPlugin_Hypothesis_i::SetCorrectSurfaceIntersection(CORBA::Boolean theValue) {
761   ASSERT(myBaseImpl);
762   this->GetImpl()->SetCorrectSurfaceIntersection(theValue);
763   std::string theValueStr = theValue ? "True" : "False";
764   SMESH::TPythonDump() << _this() << ".SetCorrectSurfaceIntersection( " << theValueStr.c_str() << " )";
765 }
766
767 //=============================================================================
768 /*!
769  *  BLSURFPlugin_Hypothesis_i::GetCorrectSurfaceIntersection
770  *
771  *  Get true or false
772  */
773 //=============================================================================
774 CORBA::Boolean BLSURFPlugin_Hypothesis_i::GetCorrectSurfaceIntersection() {
775   ASSERT(myBaseImpl);
776   return this->GetImpl()->GetCorrectSurfaceIntersection();
777 }
778
779 //=============================================================================
780 /*!
781  *  BLSURFPlugin_Hypothesis_i::SetCorrectSurfaceIntersectionMaxCost
782  *
783  *  Set Tiny Edge OptimisationLength
784  */
785 //=============================================================================
786 void BLSURFPlugin_Hypothesis_i::SetCorrectSurfaceIntersectionMaxCost(CORBA::Double theValue) {
787   ASSERT(myBaseImpl);
788   this->GetImpl()->SetCorrectSurfaceIntersectionMaxCost(theValue);
789   SMESH::TPythonDump() << _this() << ".SetCorrectSurfaceIntersectionMaxCost( " << theValue << " )";
790 }
791
792 //=============================================================================
793 /*!
794  *  BLSURFPlugin_Hypothesis_i::GetCorrectSurfaceIntersectionMaxCost
795  *
796  *  Get Tiny Edge OptimisationLength
797  */
798 //=============================================================================
799 CORBA::Double BLSURFPlugin_Hypothesis_i::GetCorrectSurfaceIntersectionMaxCost() {
800   ASSERT(myBaseImpl);
801   return this->GetImpl()->GetCorrectSurfaceIntersectionMaxCost();
802 }
803
804 //=============================================================================
805 /*!
806  *  BLSURFPlugin_Hypothesis_i::SetBadElementRemoval
807  *
808  *  Set true or false
809  */
810 //=============================================================================
811 void BLSURFPlugin_Hypothesis_i::SetBadElementRemoval(CORBA::Boolean theValue) {
812   ASSERT(myBaseImpl);
813   this->GetImpl()->SetBadElementRemoval(theValue);
814   std::string theValueStr = theValue ? "True" : "False";
815   SMESH::TPythonDump() << _this() << ".SetBadElementRemoval( " << theValueStr.c_str() << " )";
816 }
817
818 //=============================================================================
819 /*!
820  *  BLSURFPlugin_Hypothesis_i::GetBadElementRemoval
821  *
822  *  Get true or false
823  */
824 //=============================================================================
825 CORBA::Boolean BLSURFPlugin_Hypothesis_i::GetBadElementRemoval() {
826   ASSERT(myBaseImpl);
827   return this->GetImpl()->GetBadElementRemoval();
828 }
829
830 //=============================================================================
831 /*!
832  *  BLSURFPlugin_Hypothesis_i::SetBadElementAspectRatio
833  *
834  *  Set Bad Surface Element Aspect Ratio
835  */
836 //=============================================================================
837 void BLSURFPlugin_Hypothesis_i::SetBadElementAspectRatio(CORBA::Double theValue) {
838   ASSERT(myBaseImpl);
839   this->GetImpl()->SetBadElementAspectRatio(theValue);
840   SMESH::TPythonDump() << _this() << ".SetBadElementAspectRatio( " << theValue << " )";
841 }
842
843 //=============================================================================
844 /*!
845  *  BLSURFPlugin_Hypothesis_i::GetBadElementAspectRatio
846  *
847  *  Get Bad Surface Element Aspect Ratio
848  */
849 //=============================================================================
850 CORBA::Double BLSURFPlugin_Hypothesis_i::GetBadElementAspectRatio() {
851   ASSERT(myBaseImpl);
852   return this->GetImpl()->GetBadElementAspectRatio();
853 }
854
855 //=============================================================================
856 /*!
857  *  BLSURFPlugin_Hypothesis_i::SetOptimizeMesh
858  *
859  *  Set true or false
860  */
861 //=============================================================================
862 void BLSURFPlugin_Hypothesis_i::SetOptimizeMesh(CORBA::Boolean theValue) {
863   ASSERT(myBaseImpl);
864   this->GetImpl()->SetOptimizeMesh(theValue);
865   std::string theValueStr = theValue ? "True" : "False";
866   SMESH::TPythonDump() << _this() << ".SetOptimizeMesh( " << theValueStr.c_str() << " )";
867 }
868
869 //=============================================================================
870 /*!
871  *  BLSURFPlugin_Hypothesis_i::GetOptimizeMesh
872  *
873  *  Get true or false
874  */
875 //=============================================================================
876 CORBA::Boolean BLSURFPlugin_Hypothesis_i::GetOptimizeMesh() {
877   ASSERT(myBaseImpl);
878   return this->GetImpl()->GetOptimizeMesh();
879 }
880
881 //=============================================================================
882 /*!
883  *  BLSURFPlugin_Hypothesis_i::SetQuadraticMesh
884  *
885  *  Set true or false
886  */
887 //=============================================================================
888 void BLSURFPlugin_Hypothesis_i::SetQuadraticMesh(CORBA::Boolean theValue) {
889   ASSERT(myBaseImpl);
890   this->GetImpl()->SetQuadraticMesh(theValue);
891   std::string theValueStr = theValue ? "True" : "False";
892   SMESH::TPythonDump() << _this() << ".SetQuadraticMesh( " << theValueStr.c_str() << " )";
893 }
894
895 //=============================================================================
896 /*!
897  *  BLSURFPlugin_Hypothesis_i::GetQuadraticMesh
898  *
899  *  Get true or false
900  */
901 //=============================================================================
902 CORBA::Boolean BLSURFPlugin_Hypothesis_i::GetQuadraticMesh() {
903   ASSERT(myBaseImpl);
904   return this->GetImpl()->GetQuadraticMesh();
905 }
906
907
908
909
910
911 /*!
912  *  BLSURFPlugin_Hypothesis_i::SetTopology
913  *
914  *  Set topology
915  */
916
917 //=============================================================================
918 void BLSURFPlugin_Hypothesis_i::SetTopology(CORBA::Long theValue) {
919   ASSERT(myBaseImpl);
920   this->GetImpl()->SetTopology((::BLSURFPlugin_Hypothesis::Topology) theValue);
921   SMESH::TPythonDump() << _this() << ".SetTopology( " << theValue << " )";
922 }
923
924 //=============================================================================
925 /*!
926  *  BLSURFPlugin_Hypothesis_i::GetTopology
927  *
928  *  Get Topology
929  */
930 //=============================================================================
931 CORBA::Long BLSURFPlugin_Hypothesis_i::GetTopology() {
932   ASSERT(myBaseImpl);
933   return this->GetImpl()->GetTopology();
934 }
935
936 //=============================================================================
937 /*!
938  *  Activate/deactivate surface proximity computation
939  */
940 void BLSURFPlugin_Hypothesis_i::SetSurfaceProximity( CORBA::Boolean toUse )
941 {
942   if ( GetSurfaceProximity() != toUse )
943   {
944     this->GetImpl()->SetUseSurfaceProximity( toUse );
945     SMESH::TPythonDump() << _this() << ".SetSurfaceProximity( " << toUse << " )";
946   }
947 }
948
949 CORBA::Boolean BLSURFPlugin_Hypothesis_i::GetSurfaceProximity()
950 {
951   return this->GetImpl()->GetUseSurfaceProximity();
952 }
953
954 //=============================================================================
955 /*!
956  * Set number of surface element layers to be generated due to surface proximity
957  */
958 void BLSURFPlugin_Hypothesis_i::SetNbSurfaceProximityLayers( CORBA::Short nbLayers )
959 {
960   if ( GetNbSurfaceProximityLayers() != nbLayers )
961   {
962     this->GetImpl()->SetNbSurfaceProximityLayers( nbLayers );
963     SMESH::TPythonDump() << _this() << ".SetNbSurfaceProximityLayers( " << nbLayers << " )";
964   }
965 }
966
967 CORBA::Short BLSURFPlugin_Hypothesis_i::GetNbSurfaceProximityLayers()
968 {
969   return (CORBA::Short) this->GetImpl()->GetNbSurfaceProximityLayers();
970 }
971
972 //=============================================================================
973 /*!
974  * Set coefficient by which size of element refined due to surface proximity is increased
975  */
976 void BLSURFPlugin_Hypothesis_i::SetSurfaceProximityRatio( CORBA::Double ratio )
977 {
978   if ( GetSurfaceProximityRatio() != ratio )
979   {
980     this->GetImpl()->SetSurfaceProximityRatio( ratio );
981     SMESH::TPythonDump() << _this() << ".SetSurfaceProximityRatio( " << ratio << " )";
982   }
983 }
984
985 CORBA::Double BLSURFPlugin_Hypothesis_i::GetSurfaceProximityRatio()
986 {
987   return this->GetImpl()->GetSurfaceProximityRatio();
988 }
989
990 //=============================================================================
991 /*!
992  *  Activate/deactivate volume proximity computation
993  */
994 void BLSURFPlugin_Hypothesis_i::SetVolumeProximity( CORBA::Boolean toUse )
995 {
996   if ( GetVolumeProximity() != toUse )
997   {
998     this->GetImpl()->SetUseVolumeProximity( toUse );
999     SMESH::TPythonDump() << _this() << ".SetVolumeProximity( " << toUse << " )";
1000   }
1001 }
1002
1003 CORBA::Boolean BLSURFPlugin_Hypothesis_i::GetVolumeProximity()
1004 {
1005   return this->GetImpl()->GetUseVolumeProximity();
1006 }
1007
1008
1009 //=============================================================================
1010 /*!
1011  * Set number of surface element layers to be generated due to volume proximity
1012  */
1013 void BLSURFPlugin_Hypothesis_i::SetNbVolumeProximityLayers( CORBA::Short nbLayers )
1014 {
1015   if ( GetNbVolumeProximityLayers() != nbLayers )
1016   {
1017     this->GetImpl()->SetNbVolumeProximityLayers( nbLayers );
1018     SMESH::TPythonDump() << _this() << ".SetNbVolumeProximityLayers( " << nbLayers << " )";
1019   }
1020 }
1021
1022 CORBA::Short BLSURFPlugin_Hypothesis_i::GetNbVolumeProximityLayers()
1023 {
1024   return (CORBA::Short) this->GetImpl()->GetNbVolumeProximityLayers();
1025 }
1026
1027 //=============================================================================
1028   /*!
1029    * Set coefficient by which size of element refined due to volume proximity is increased
1030    */
1031 void BLSURFPlugin_Hypothesis_i::SetVolumeProximityRatio( CORBA::Double ratio )
1032 {
1033   if ( GetVolumeProximityRatio() != ratio )
1034   {
1035     this->GetImpl()->SetVolumeProximityRatio( ratio );
1036     SMESH::TPythonDump() << _this() << ".SetVolumeProximityRatio( " << ratio << " )";
1037   }
1038 }
1039
1040 CORBA::Double BLSURFPlugin_Hypothesis_i::GetVolumeProximityRatio()
1041 {
1042   return this->GetImpl()->GetVolumeProximityRatio();
1043 }
1044
1045 //=============================================================================
1046 void BLSURFPlugin_Hypothesis_i::SetVerbosity(CORBA::Short theVal) {
1047   ASSERT(myBaseImpl);
1048   if (theVal < 0 || theVal > 10)
1049     THROW_SALOME_CORBA_EXCEPTION( "Invalid verbosity level",SALOME::BAD_PARAM );
1050   this->GetImpl()->SetVerbosity(theVal);
1051   SMESH::TPythonDump() << _this() << ".SetVerbosity( " << theVal << " )";
1052 }
1053
1054 //=============================================================================
1055
1056 CORBA::Short BLSURFPlugin_Hypothesis_i::GetVerbosity() {
1057   ASSERT(myBaseImpl);
1058   return (CORBA::Short) this->GetImpl()->GetVerbosity();
1059 }
1060
1061
1062 //=============================================================================
1063 void BLSURFPlugin_Hypothesis_i::SetEnforcedMeshes(const BLSURFPlugin::EnforcedMeshesList& theMeshes )
1064 {
1065   std::vector< ::BLSURFPlugin_Hypothesis::EnforcedMesh > enforcedMeshes;
1066   for ( CORBA::ULong i = 0; i < theMeshes.length(); ++i )
1067   {
1068     const BLSURFPlugin::MG_EnforcedMesh1D & inEM = theMeshes[ i ];
1069     if ( CORBA::is_nil( inEM.mesh ))
1070       THROW_SALOME_CORBA_EXCEPTION( "NULL enforced mesh",SALOME::BAD_PARAM );
1071
1072     SMESH::SMESH_Mesh_var mesh = inEM.mesh->GetMesh();
1073     if ( CORBA::is_nil( mesh ))
1074       THROW_SALOME_CORBA_EXCEPTION( "BAD enforced mesh",SALOME::BAD_PARAM );
1075
1076     int meshID = GetMeshPersistentId( mesh );
1077     if ( meshID < 0 )
1078       THROW_SALOME_CORBA_EXCEPTION( "BAD enforced mesh",SALOME::BAD_PARAM );
1079
1080     bool isGroup = false;
1081     int   partID = GetMeshPartPersistentId( inEM.mesh, isGroup );
1082     ::EnforcedMeshType partType = ENFORCED_MESH;
1083     if ( partID > -1 )
1084       partType = isGroup ? ENFORCED_GROUP : ENFORCED_SUBMESH;
1085
1086     enforcedMeshes.push_back({ meshID, partID, partType, inEM.groupName.in() });
1087   }
1088
1089   if ( GetImpl()->GetEnforcedMeshes() == enforcedMeshes )
1090     return;
1091
1092   this->GetImpl()->SetEnforcedMeshes( enforcedMeshes );
1093
1094   // dump
1095
1096   SMESH::TPythonDump pyDump;
1097   pyDump << BLSURFPlugin::BLSURFPlugin_Hypothesis_var( _this() )
1098          << ".SetEnforcedMeshes([ ";
1099
1100   for ( CORBA::ULong i = 0; i < theMeshes.length(); ++i )
1101   {
1102     const BLSURFPlugin::MG_EnforcedMesh1D & inEM = theMeshes[ i ];
1103     pyDump << "BLSURFPlugin.MG_EnforcedMesh1D( " << inEM.mesh.in() << ", ";
1104     if ( inEM.groupName.in() && inEM.groupName.in()[0] )
1105       pyDump << "'" << inEM.groupName.in() << "'";
1106     else
1107       pyDump << "''";
1108     pyDump << ")" << ( i + 1 < theMeshes.length() ? ", " : "");
1109   }
1110   pyDump << "])";
1111 }
1112
1113 //=============================================================================
1114
1115 BLSURFPlugin::EnforcedMeshesList* BLSURFPlugin_Hypothesis_i::GetEnforcedMeshes()
1116 {
1117   const std::vector< ::BLSURFPlugin_Hypothesis::EnforcedMesh > & hypEnfMeshes =
1118     this->GetImpl()->GetEnforcedMeshes();
1119
1120   BLSURFPlugin::EnforcedMeshesList_var outEnfMeshes = new BLSURFPlugin::EnforcedMeshesList();
1121   outEnfMeshes->length( hypEnfMeshes.size() );
1122
1123   int nbMeshes = 0;
1124   for ( size_t i = 0; i < hypEnfMeshes.size(); ++i )
1125   {
1126     const ::BLSURFPlugin_Hypothesis::EnforcedMesh& enfMeshData = hypEnfMeshes[ i ];
1127     BLSURFPlugin::MG_EnforcedMesh1D &               outEnfMesh = outEnfMeshes[ nbMeshes ];
1128
1129     SMESH::SMESH_Mesh_var mesh = FindMeshByID( enfMeshData._meshID );
1130     switch ( enfMeshData._type ) {
1131     case ENFORCED_MESH   :
1132     {
1133       outEnfMesh.mesh = SMESH::SMESH_IDSource::_narrow( mesh );
1134       break;
1135     }
1136     case ENFORCED_GROUP  :
1137     {
1138       SMESH::SMESH_GroupBase_var group = GetGroupByID( mesh, enfMeshData._subID );
1139       outEnfMesh.mesh = SMESH::SMESH_IDSource::_narrow( group );
1140       break;
1141     }
1142     case ENFORCED_SUBMESH:
1143     {
1144       SMESH::SMESH_subMesh_var subMesh;
1145       subMesh   = GetSubMeshByID( mesh, enfMeshData._subID, SMESH::Tag_SubMeshOnEdge );
1146       if ( CORBA::is_nil( subMesh ))
1147         subMesh = GetSubMeshByID( mesh, enfMeshData._subID, SMESH::Tag_SubMeshOnCompound );
1148
1149       outEnfMesh.mesh = SMESH::SMESH_IDSource::_narrow( subMesh );
1150       break;
1151     }
1152     default: continue;
1153     }
1154     outEnfMesh.groupName = enfMeshData._groupName.c_str();
1155
1156     nbMeshes += ( !CORBA::is_nil( outEnfMesh.mesh ));
1157   }
1158   outEnfMeshes->length( nbMeshes );
1159
1160   return outEnfMeshes._retn();
1161 }
1162
1163 //=============================================================================
1164 void BLSURFPlugin_Hypothesis_i::SetEnforceCadEdgesSize( CORBA::Boolean toEnforce )
1165 {
1166   if ( GetEnforceCadEdgesSize() != toEnforce )
1167   {
1168     this->GetImpl()->SetEnforceCadEdgesSize(toEnforce);
1169     SMESH::TPythonDump() << _this() << ".SetEnforceCadEdgesSize( " << toEnforce << " )";
1170   }
1171 }
1172 //=============================================================================
1173 CORBA::Boolean BLSURFPlugin_Hypothesis_i::GetEnforceCadEdgesSize()
1174 {
1175   return this->GetImpl()->GetEnforceCadEdgesSize();
1176 }
1177 //=============================================================================
1178
1179 void BLSURFPlugin_Hypothesis_i::SetJacobianRectificationRespectGeometry( CORBA::Boolean allowRectification )
1180 {
1181   if ( GetJacobianRectificationRespectGeometry() != allowRectification )
1182   {
1183     this->GetImpl()->SetJacobianRectificationRespectGeometry(allowRectification);
1184     SMESH::TPythonDump() << _this() << ".SetJacobianRectificationRespectGeometry( " << allowRectification << " )";
1185   }
1186 }
1187 //=============================================================================
1188 CORBA::Boolean BLSURFPlugin_Hypothesis_i::GetJacobianRectificationRespectGeometry()
1189 {
1190   return this->GetImpl()->GetJacobianRectificationRespectGeometry();
1191 }
1192 //=============================================================================
1193
1194 void BLSURFPlugin_Hypothesis_i::SetJacobianRectification( CORBA::Boolean allowRectification )
1195 {
1196   if ( GetJacobianRectification() != allowRectification )
1197   {
1198     this->GetImpl()->SetJacobianRectification(allowRectification);
1199     SMESH::TPythonDump() << _this() << ".SetJacobianRectification( " << allowRectification << " )";
1200   }
1201 }
1202 //=============================================================================
1203 CORBA::Boolean BLSURFPlugin_Hypothesis_i::GetJacobianRectification()
1204 {
1205   return this->GetImpl()->GetJacobianRectification();
1206 }
1207 //=============================================================================
1208
1209 void BLSURFPlugin_Hypothesis_i::SetUseDeprecatedPatchMesher( CORBA::Boolean useDeprecatedPatchMesher )
1210 {
1211   if ( GetUseDeprecatedPatchMesher() != useDeprecatedPatchMesher )
1212   {
1213     this->GetImpl()->SetUseDeprecatedPatchMesher(useDeprecatedPatchMesher);
1214     SMESH::TPythonDump() << _this() << ".SetUseDeprecatedPatchMesher( " << useDeprecatedPatchMesher << " )";
1215   }
1216 }
1217 //=============================================================================
1218 CORBA::Boolean BLSURFPlugin_Hypothesis_i::GetUseDeprecatedPatchMesher()
1219 {
1220   return this->GetImpl()->GetUseDeprecatedPatchMesher();
1221 }
1222 //=============================================================================
1223
1224 void BLSURFPlugin_Hypothesis_i::SetMaxNumberOfPointsPerPatch( CORBA::Long nb )
1225 {
1226   if ( GetMaxNumberOfPointsPerPatch() != nb )
1227   {
1228     try {
1229       this->GetImpl()->SetMaxNumberOfPointsPerPatch(nb);
1230
1231     } catch (const std::invalid_argument& ex) {
1232       THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
1233     } catch (SALOME_Exception& ex) {
1234       THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
1235     }
1236     SMESH::TPythonDump() << _this() << ".SetMaxNumberOfPointsPerPatch( " << nb << " )";
1237   }
1238 }
1239 //=============================================================================
1240 CORBA::Long BLSURFPlugin_Hypothesis_i::GetMaxNumberOfPointsPerPatch()
1241 {
1242   return this->GetImpl()->GetMaxNumberOfPointsPerPatch();
1243 }
1244 //=============================================================================
1245
1246 void BLSURFPlugin_Hypothesis_i::SetMaxNumberOfThreads( CORBA::Long nb )
1247 {
1248   if ( GetMaxNumberOfThreads() != nb )
1249   {
1250     try {
1251       this->GetImpl()->SetMaxNumberOfThreads(nb);
1252
1253     } catch (const std::invalid_argument& ex) {
1254       THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
1255     } catch (SALOME_Exception& ex) {
1256       THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
1257     }
1258     SMESH::TPythonDump() << _this() << ".SetMaxNumberOfThreads( " << nb << " )";
1259   }
1260 }
1261 //=============================================================================
1262 CORBA::Long BLSURFPlugin_Hypothesis_i::GetMaxNumberOfThreads()
1263 {
1264   return this->GetImpl()->GetMaxNumberOfThreads();
1265 }
1266 //=============================================================================
1267
1268 void BLSURFPlugin_Hypothesis_i::SetRespectGeometry( CORBA::Boolean toRespect )
1269 {
1270   if ( GetRespectGeometry() != toRespect )
1271   {
1272     this->GetImpl()->SetRespectGeometry(toRespect);
1273     SMESH::TPythonDump() << _this() << ".SetRespectGeometry( " << toRespect << " )";
1274   }
1275 }
1276 //=============================================================================
1277 CORBA::Boolean BLSURFPlugin_Hypothesis_i::GetRespectGeometry()
1278 {
1279   return this->GetImpl()->GetRespectGeometry();
1280 }
1281 //=============================================================================
1282
1283 void BLSURFPlugin_Hypothesis_i::SetTinyEdgesAvoidSurfaceIntersections( CORBA::Boolean toAvoidIntersection )
1284 {
1285   if ( GetTinyEdgesAvoidSurfaceIntersections() != toAvoidIntersection )
1286   {
1287     this->GetImpl()->SetTinyEdgesAvoidSurfaceIntersections(toAvoidIntersection);
1288     SMESH::TPythonDump() << _this() << ".SetTinyEdgesAvoidSurfaceIntersections( " << toAvoidIntersection << " )";
1289   }
1290 }
1291 //=============================================================================
1292 CORBA::Boolean BLSURFPlugin_Hypothesis_i::GetTinyEdgesAvoidSurfaceIntersections()
1293 {
1294   return this->GetImpl()->GetTinyEdgesAvoidSurfaceIntersections();
1295 }
1296 //=============================================================================
1297
1298 void BLSURFPlugin_Hypothesis_i::SetClosedGeometry( CORBA::Boolean isClosed )
1299 {
1300   if ( GetClosedGeometry() != isClosed )
1301   {
1302     this->GetImpl()->SetClosedGeometry(isClosed);
1303     SMESH::TPythonDump() << _this() << ".SetClosedGeometry( " << isClosed << " )";
1304   }
1305 }
1306 //=============================================================================
1307 CORBA::Boolean BLSURFPlugin_Hypothesis_i::GetClosedGeometry()
1308 {
1309   return this->GetImpl()->GetClosedGeometry();
1310 }
1311 //=============================================================================
1312
1313 void BLSURFPlugin_Hypothesis_i::SetDebug( CORBA::Boolean isDebug )
1314 {
1315   if ( GetDebug() != isDebug )
1316   {
1317     this->GetImpl()->SetDebug(isDebug);
1318     SMESH::TPythonDump() << _this() << ".SetDebug( " << isDebug << " )";
1319   }
1320 }
1321 //=============================================================================
1322 bool BLSURFPlugin_Hypothesis_i::GetDebug()
1323 {
1324   return this->GetImpl()->GetDebug();
1325 }
1326 //=============================================================================
1327
1328 void BLSURFPlugin_Hypothesis_i::SetPeriodicTolerance( CORBA::Double tol )
1329 {
1330   bool isDefault;
1331   if ( GetImpl()->GetPreCADOptionValue("periodic_tolerance",&isDefault) != SMESH_Comment( tol ))
1332   {
1333     try
1334     {
1335       this->GetImpl()->SetPeriodicTolerance(tol);
1336
1337     } catch (const std::invalid_argument& ex) {
1338       THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
1339     } catch (SALOME_Exception& ex) {
1340       THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
1341     }
1342     SMESH::TPythonDump() << _this() << ".SetPeriodicTolerance( " << tol << " )";
1343   }
1344 }
1345 //=============================================================================
1346 double BLSURFPlugin_Hypothesis_i::GetPeriodicTolerance()
1347 {
1348   try{
1349     return this->GetImpl()->GetPeriodicTolerance();
1350
1351   } catch (const std::invalid_argument& ex) {
1352     THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
1353   } catch (SALOME_Exception& ex) {
1354     THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
1355   }
1356   return -1;
1357 }
1358 //=============================================================================
1359
1360 void BLSURFPlugin_Hypothesis_i::SetRequiredEntities( const char* howToTreat )
1361 {
1362   if ( GetImpl()->GetRequiredEntities() != howToTreat )
1363   {
1364     try {
1365       this->GetImpl()->SetRequiredEntities(howToTreat);
1366
1367     } catch (const std::invalid_argument& ex) {
1368       THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
1369     } catch (SALOME_Exception& ex) {
1370       THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
1371     }
1372     SMESH::TPythonDump() << _this() << ".SetRequiredEntities( '" << howToTreat << "' )";
1373   }
1374 }
1375 //=============================================================================
1376 char* BLSURFPlugin_Hypothesis_i::GetRequiredEntities()
1377 {
1378   return CORBA::string_dup( this->GetImpl()->GetRequiredEntities().c_str() );
1379 }
1380 //=============================================================================
1381
1382 void BLSURFPlugin_Hypothesis_i::SetSewingTolerance( CORBA::Double tol )
1383 {
1384   bool isDefault;
1385   if ( GetImpl()->GetPreCADOptionValue("sewing_tolerance",&isDefault) != SMESH_Comment( tol ))
1386   {
1387     try
1388     {
1389       this->GetImpl()->SetSewingTolerance(tol);
1390       SMESH::TPythonDump() << _this() << ".SetSewingTolerance( " << tol << " )";
1391
1392     } catch (const std::invalid_argument& ex) {
1393       THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
1394     } catch (SALOME_Exception& ex) {
1395       THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
1396     }
1397   }
1398 }
1399 //=============================================================================
1400 CORBA::Double BLSURFPlugin_Hypothesis_i::GetSewingTolerance()
1401 {
1402   try
1403   {
1404     return this->GetImpl()->GetSewingTolerance();
1405
1406   } catch (const std::invalid_argument& ex) {
1407     THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
1408   } catch (SALOME_Exception& ex) {
1409     THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
1410   }
1411   return -1;
1412 }
1413 //=============================================================================
1414
1415 void BLSURFPlugin_Hypothesis_i::SetTags( const char* howToTreat )
1416 {
1417   if ( GetImpl()->GetTags() != howToTreat )
1418   {
1419     try {
1420       this->GetImpl()->SetTags(howToTreat);
1421     }
1422     catch (const std::invalid_argument& ex) {
1423       THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
1424     } catch (SALOME_Exception& ex) {
1425       THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
1426     }
1427   }
1428   SMESH::TPythonDump() << _this() << ".SetTags( '" << howToTreat << "' )";
1429 }
1430 //=============================================================================
1431 char* BLSURFPlugin_Hypothesis_i::GetTags()
1432 {
1433   return CORBA::string_dup( this->GetImpl()->GetTags().c_str() );
1434 }
1435
1436 //=============================================================================
1437 void BLSURFPlugin_Hypothesis_i::SetHyperPatches(const BLSURFPlugin::THyperPatchList& hpl)
1438 {
1439   ::BLSURFPlugin_Hypothesis::THyperPatchList patchList( hpl.length() );
1440   SMESH_Comment hplDump;
1441   hplDump << "[";
1442   for ( CORBA::ULong i = 0; i < patchList.size(); ++i )
1443   {
1444     hplDump << "[ ";
1445     BLSURFPlugin::THyperPatch tags = hpl[ i ];
1446     for ( CORBA::ULong j = 0; j < tags.length(); ++j )
1447     {
1448       patchList[ i ].insert( tags[ j ]);
1449       hplDump << tags[ j ] << ( j+1 < tags.length() ? ", " : " ]" );
1450     }
1451     hplDump << ( i+1 < patchList.size() ? "," : "]");
1452   }
1453   if ( GetImpl()->GetHyperPatches() != patchList )
1454   {
1455     GetImpl()->SetHyperPatches( ::BLSURFPlugin_Hypothesis::THyperPatchEntriesList() ); // erase entries
1456     GetImpl()->SetHyperPatches( patchList );
1457     SMESH::TPythonDump() << _this() << ".SetHyperPatches( " << hplDump << " )";
1458   }
1459 }
1460
1461 //=============================================================================
1462 void BLSURFPlugin_Hypothesis_i::SetHyperPatchEntries(const BLSURFPlugin::THyperPatchEntriesList& hpe)
1463 {
1464   ::BLSURFPlugin_Hypothesis::THyperPatchEntriesList patchList( hpe.length() );
1465   SMESH_Comment hpeDump;
1466   hpeDump << "[";
1467   for ( CORBA::ULong i = 0; i < patchList.size(); ++i )
1468   {
1469     hpeDump << "[ ";
1470     const BLSURFPlugin::THyperPatchEntries& entryList = hpe[ i ];
1471     for ( CORBA::ULong j = 0; j < entryList.length(); ++j )
1472     {
1473       patchList[ i ].insert( entryList[ j ].in() );
1474       hpeDump << entryList[ j ].in() << ( j+1 < entryList.length() ? ", " : " ]" );
1475     }
1476     hpeDump << ( i+1 < patchList.size() ? "," : "]");
1477   }
1478   if ( GetImpl()->GetHyperPatchEntries() != patchList )
1479   {
1480     GetImpl()->SetHyperPatches( ::BLSURFPlugin_Hypothesis::THyperPatchList(), /*notify=*/false );
1481     GetImpl()->SetHyperPatches( patchList );
1482     // TPythonDump converts entries to objects
1483     SMESH::TPythonDump() << _this() << ".SetHyperPatchShapes( " << hpeDump << " )";
1484   }
1485 }
1486
1487 //=============================================================================
1488 void BLSURFPlugin_Hypothesis_i::SetHyperPatchShapes(const BLSURFPlugin::THyperPatchShapesList& hpsl)
1489 {
1490   BLSURFPlugin::THyperPatchEntriesList patchList;
1491   patchList.length( hpsl.length() );
1492   for ( CORBA::ULong i = 0; i < hpsl.length(); ++i )
1493   {
1494     const GEOM::ListOfGO&             shapeList = hpsl[ i ];
1495     BLSURFPlugin::THyperPatchEntries& entryList = patchList[ i ];
1496     entryList.length( shapeList.length() );
1497     for ( CORBA::ULong j = 0; j < shapeList.length(); ++j )
1498     {
1499       CORBA::String_var entry = shapeList[ j ]->GetStudyEntry();
1500       if ( !entry.in() || !entry.in()[0] )
1501         THROW_SALOME_CORBA_EXCEPTION( "BLSURFPlugin_Hypothesis::SetHyperPatchShapes(), "
1502                                       "Not published hyper-patch shape", SALOME::BAD_PARAM );
1503       entryList[ j ] = CORBA::string_dup( entry );
1504     }
1505   }
1506   this->SetHyperPatchEntries( patchList );
1507 }
1508
1509 //=============================================================================
1510 BLSURFPlugin::THyperPatchList*
1511 BLSURFPlugin_Hypothesis_i::GetHyperPatches( GEOM::GEOM_Object_ptr mainShape )
1512 {
1513   const ::BLSURFPlugin_Hypothesis::THyperPatchList& hpl = GetImpl()->GetHyperPatches();
1514   BLSURFPlugin::THyperPatchList*                 resHpl = new BLSURFPlugin::THyperPatchList();
1515   if ( hpl.empty() &&
1516        !CORBA::is_nil( mainShape ) &&
1517        !GetImpl()->GetHyperPatchEntries().empty() )
1518   {
1519     // set IDs by entries
1520     SMESH_Gen_i* smeshGen = SMESH_Gen_i::GetSMESHGen();
1521     TopoDS_Shape S = smeshGen->GeomObjectToShape( mainShape );
1522     if ( !S.IsNull() )
1523     {
1524       std::map< std::string, TopoDS_Shape > entryToShape;
1525       BLSURFPlugin_BLSURF::FillEntryToShape( GetImpl(), entryToShape );
1526       GetImpl()->SetHyperPatchIDsByEntry( S, entryToShape );
1527     }
1528   }
1529   resHpl->length((CORBA::ULong) hpl.size() );
1530
1531   ::BLSURFPlugin_Hypothesis::THyperPatchList::const_iterator hpIt = hpl.begin();
1532   for ( int i = 0; hpIt != hpl.end(); ++hpIt, ++i )
1533   {
1534     const ::BLSURFPlugin_Hypothesis::THyperPatchTags& hp = *hpIt;
1535     BLSURFPlugin::THyperPatch& resHp = (*resHpl)[ i ];
1536     resHp.length((CORBA::ULong) hp.size() );
1537
1538     ::BLSURFPlugin_Hypothesis::THyperPatchTags::const_iterator tag = hp.begin();
1539     for ( int j = 0; tag != hp.end(); ++tag, ++j )
1540       resHp[ j ] = *tag;
1541   }
1542   return resHpl;
1543 }
1544
1545 //=============================================================================
1546 BLSURFPlugin::THyperPatchEntriesList* BLSURFPlugin_Hypothesis_i::GetHyperPatchShapes()
1547 {
1548   const ::BLSURFPlugin_Hypothesis::THyperPatchEntriesList& hpel = GetImpl()->GetHyperPatchEntries();
1549   BLSURFPlugin::THyperPatchEntriesList* resHpl = new BLSURFPlugin::THyperPatchEntriesList();
1550   resHpl->length((CORBA::ULong) hpel.size() );
1551
1552   ::BLSURFPlugin_Hypothesis::THyperPatchEntriesList::const_iterator hpIt = hpel.begin();
1553   for ( int i = 0; hpIt != hpel.end(); ++hpIt, ++i )
1554   {
1555     const ::BLSURFPlugin_Hypothesis::THyperPatchEntries& hp = *hpIt;
1556     BLSURFPlugin::THyperPatchEntries& resHp = (*resHpl)[ i ];
1557     resHp.length((CORBA::ULong) hp.size() );
1558
1559     ::BLSURFPlugin_Hypothesis::THyperPatchEntries::const_iterator entry = hp.begin();
1560     for ( int j = 0; entry != hp.end(); ++entry, ++j )
1561       resHp[ j ] = CORBA::string_dup( entry->c_str() );
1562   }
1563   return resHpl;
1564 }
1565
1566 //=============================================================================
1567 /*!
1568  *  BLSURFPlugin_Hypothesis_i::SetPreCADMergeEdges
1569  *
1570  *  Set true or false
1571  */
1572 //=============================================================================
1573 void BLSURFPlugin_Hypothesis_i::SetPreCADMergeEdges(CORBA::Boolean theValue) {
1574   ASSERT(myBaseImpl);
1575   this->GetImpl()->SetPreCADMergeEdges(theValue);
1576   std::string theValueStr = theValue ? "True" : "False";
1577   SMESH::TPythonDump() << _this() << ".SetPreCADMergeEdges( " << theValueStr.c_str() << " )";
1578 }
1579
1580 //=============================================================================
1581 /*!
1582  *  BLSURFPlugin_Hypothesis_i::GetPreCADMergeEdges
1583  *
1584  *  Get true or false
1585  */
1586 //=============================================================================
1587 CORBA::Boolean BLSURFPlugin_Hypothesis_i::GetPreCADMergeEdges() {
1588   ASSERT(myBaseImpl);
1589   return this->GetImpl()->GetPreCADMergeEdges();
1590 }
1591
1592 //=============================================================================
1593 /*!
1594  *  BLSURFPlugin_Hypothesis_i::SetPreCADRemoveDuplicateCADFaces
1595  *
1596  *  Set true or false
1597  */
1598 //=============================================================================
1599 void BLSURFPlugin_Hypothesis_i::SetPreCADRemoveDuplicateCADFaces(CORBA::Boolean theValue) {
1600   ASSERT(myBaseImpl);
1601   this->GetImpl()->SetPreCADRemoveDuplicateCADFaces(theValue);
1602   std::string theValueStr = theValue ? "True" : "False";
1603   SMESH::TPythonDump() << _this() << ".SetPreCADRemoveDuplicateCADFaces( " << theValueStr.c_str() << " )";
1604 }
1605
1606 //=============================================================================
1607 /*!
1608  *  BLSURFPlugin_Hypothesis_i::GetPreCADRemoveDuplicateCADFaces
1609  *
1610  *  Get true or false
1611  */
1612 //=============================================================================
1613 CORBA::Boolean BLSURFPlugin_Hypothesis_i::GetPreCADRemoveDuplicateCADFaces() {
1614   ASSERT(myBaseImpl);
1615   return this->GetImpl()->GetPreCADRemoveDuplicateCADFaces();
1616 }
1617
1618 //=============================================================================
1619 /*!
1620  *  BLSURFPlugin_Hypothesis_i::SetPreCADProcess3DTopology
1621  *
1622  *  Set true or false
1623  */
1624 //=============================================================================
1625 void BLSURFPlugin_Hypothesis_i::SetPreCADProcess3DTopology(CORBA::Boolean theValue) {
1626   ASSERT(myBaseImpl);
1627   this->GetImpl()->SetPreCADProcess3DTopology(theValue);
1628   std::string theValueStr = theValue ? "True" : "False";
1629   SMESH::TPythonDump() << _this() << ".SetPreCADProcess3DTopology( " << theValueStr.c_str() << " )";
1630 }
1631
1632 //=============================================================================
1633 /*!
1634  *  BLSURFPlugin_Hypothesis_i::GetPreCADProcess3DTopology
1635  *
1636  *  Get true or false
1637  */
1638 //=============================================================================
1639 CORBA::Boolean BLSURFPlugin_Hypothesis_i::GetPreCADProcess3DTopology() {
1640   ASSERT(myBaseImpl);
1641   return this->GetImpl()->GetPreCADProcess3DTopology();
1642 }
1643
1644 //=============================================================================
1645 /*!
1646  *  BLSURFPlugin_Hypothesis_i::SetPreCADDiscardInput
1647  *
1648  *  Set true or false
1649  */
1650 //=============================================================================
1651 void BLSURFPlugin_Hypothesis_i::SetPreCADDiscardInput(CORBA::Boolean theValue) {
1652   ASSERT(myBaseImpl);
1653   this->GetImpl()->SetPreCADDiscardInput(theValue);
1654   std::string theValueStr = theValue ? "True" : "False";
1655   SMESH::TPythonDump() << _this() << ".SetPreCADDiscardInput( " << theValueStr.c_str() << " )";
1656 }
1657
1658 //=============================================================================
1659 /*!
1660  *  BLSURFPlugin_Hypothesis_i::GetPreCADDiscardInput
1661  *
1662  *  Get true or false
1663  */
1664 //=============================================================================
1665 CORBA::Boolean BLSURFPlugin_Hypothesis_i::GetPreCADDiscardInput() {
1666   ASSERT(myBaseImpl);
1667   return this->GetImpl()->GetPreCADDiscardInput();
1668 }
1669
1670
1671 //=============================================================================
1672
1673 void BLSURFPlugin_Hypothesis_i::SetOptionValue(const char* optionName, const char* optionValue)
1674 {
1675   ASSERT(myBaseImpl);
1676   try {
1677     std::string name( optionName );
1678     if ( !optionValue || !optionValue[0] )
1679       UnsetOption( optionName );
1680
1681     // basic options (visible in Advanced table)
1682
1683     else if ( name == "enforce_cad_edge_sizes" )
1684       SetEnforceCadEdgesSize( GetImpl()->ToBool( optionValue ));
1685
1686     else if ( name == "jacobian_rectification_respect_geometry" )
1687       SetJacobianRectificationRespectGeometry( GetImpl()->ToBool( optionValue ));
1688
1689     else if ( name == "max_number_of_points_per_patch" )
1690       SetMaxNumberOfPointsPerPatch( GetImpl()->ToInt( optionValue ));
1691
1692     else if ( name == "max_number_of_threads" )
1693       SetMaxNumberOfThreads( GetImpl()->ToInt( optionValue ));
1694
1695     else if ( name == "rectify_jacobian" )
1696       SetJacobianRectification( GetImpl()->ToBool( optionValue ));
1697
1698     else if ( name == "use_deprecated_patch_mesher" )
1699       SetUseDeprecatedPatchMesher( GetImpl()->ToBool( optionValue ));
1700
1701     else if ( name == "respect_geometry" )
1702       SetRespectGeometry( GetImpl()->ToBool( optionValue ));
1703
1704     else if ( name == "tiny_edge_avoid_surface_intersections" )
1705       SetTinyEdgesAvoidSurfaceIntersections( GetImpl()->ToBool( optionValue ));
1706
1707     else if ( name == "closed_geometry" )
1708       SetClosedGeometry( GetImpl()->ToBool( optionValue ));
1709
1710     else if ( name == "debug" )
1711       SetDebug( GetImpl()->ToBool( optionValue ));
1712
1713     else if ( name == "discard_input_topology" )
1714       SetPreCADDiscardInput( GetImpl()->ToBool( optionValue ));
1715
1716     else if ( name == "merge_edges" )
1717       SetPreCADMergeEdges( GetImpl()->ToBool( optionValue ));
1718
1719     else if ( name == "periodic_tolerance" )
1720       SetPeriodicTolerance( GetImpl()->ToDbl( optionValue ));
1721
1722     else if ( name == "remove_duplicate_cad_faces" )
1723       SetPreCADRemoveDuplicateCADFaces( GetImpl()->ToBool( optionValue ));
1724
1725     else if ( name == "required_entities" )
1726       SetRequiredEntities( optionValue );
1727
1728     else if ( name == "sewing_tolerance" )
1729       SetSewingTolerance( GetImpl()->ToDbl( optionValue ));
1730
1731     else if ( name == "tags" )
1732       SetTags( optionValue );
1733
1734     // other basic options with specific methods
1735
1736     else if ( name == "correct_surface_intersections" )
1737       SetCorrectSurfaceIntersection( GetImpl()->ToBool( optionValue ));
1738
1739     else if ( name == "optimise_tiny_edges" )
1740       SetOptimiseTinyEdges( GetImpl()->ToBool( optionValue ));
1741
1742     else if ( name == "surface_intersections_processing_max_cost" )
1743       SetCorrectSurfaceIntersectionMaxCost( GetImpl()->ToDbl( optionValue ));
1744
1745     else if ( name == "volume_gradation" )
1746       SetVolumeGradation( GetImpl()->ToDbl( optionValue ));
1747
1748     else if ( name == "tiny_edge_optimisation_length" )
1749       SetTinyEdgeOptimisationLength( GetImpl()->ToDbl( optionValue ));
1750
1751     else if ( name == "proximity" )
1752       SetVolumeProximity( GetImpl()->ToBool( optionValue ));
1753
1754     else if ( name == "prox_ratio" )
1755       SetVolumeProximityRatio( GetImpl()->ToDbl( optionValue ));
1756
1757     else if ( name == "prox_nb_layer" )
1758       SetNbVolumeProximityLayers((CORBA::Short) GetImpl()->ToInt( optionValue ));
1759
1760     // advanced options (for backward compatibility)
1761
1762     else if ( name == "create_tag_on_collision" ||
1763               name == "tiny_edge_respect_geometry" )
1764       AddOption( optionName, optionValue );
1765
1766     else {
1767       bool valueChanged;
1768       valueChanged = ( this->GetImpl()->GetOptionValue( name ) != optionValue &&
1769                        this->GetImpl()->GetOptionValue( name, &valueChanged ) != optionValue );
1770       if ( valueChanged )
1771       {
1772         this->GetImpl()->SetOptionValue(optionName, optionValue);
1773         SMESH::TPythonDump() << _this() << ".SetOptionValue( '" << optionName << "', '" << optionValue << "' )";
1774       }
1775     }
1776   } catch (const std::invalid_argument& ex) {
1777     THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
1778   } catch (SALOME_Exception& ex) {
1779     THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
1780   }
1781 }
1782
1783 //=============================================================================
1784
1785 void BLSURFPlugin_Hypothesis_i::SetPreCADOptionValue(const char* optionName, const char* optionValue)
1786 {
1787   ASSERT(myBaseImpl);
1788   bool valueChanged = false;
1789   try {
1790     std::string name( optionName );
1791     if ( !optionValue || !optionValue[0] )
1792       UnsetOption( optionName );
1793
1794     else if ( name == "closed_geometry" )
1795       SetClosedGeometry( GetImpl()->ToBool( optionValue ));
1796
1797     else if ( name == "debug" )
1798       SetDebug( GetImpl()->ToBool( optionValue ));
1799
1800     else if ( name == "discard_input_topology" )
1801       SetPreCADDiscardInput( GetImpl()->ToBool( optionValue ));
1802
1803     else if ( name == "merge_edges" )
1804       SetPreCADMergeEdges( GetImpl()->ToBool( optionValue ));
1805
1806     else if ( name == "periodic_tolerance" )
1807       SetPeriodicTolerance( GetImpl()->ToDbl( optionValue ));
1808
1809     else if ( name == "remove_duplicate_cad_faces" )
1810       SetPreCADRemoveDuplicateCADFaces( GetImpl()->ToBool( optionValue ));
1811
1812     else if ( name == "required_entities" )
1813       SetRequiredEntities( optionValue );
1814
1815     else if ( name == "sewing_tolerance" )
1816       SetSewingTolerance( GetImpl()->ToDbl( optionValue ));
1817
1818     else if ( name == "tags" )
1819       SetTags( optionValue );
1820
1821     // other basic options with specific methods
1822
1823     else if ( name == "correct_surface_intersections" )
1824       SetCorrectSurfaceIntersection( GetImpl()->ToBool( optionValue ));
1825
1826     else if ( name == "optimise_tiny_edges" )
1827       SetOptimiseTinyEdges( GetImpl()->ToBool( optionValue ));
1828
1829     else if ( name == "surface_intersections_processing_max_cost" )
1830       SetCorrectSurfaceIntersectionMaxCost( GetImpl()->ToDbl( optionValue ));
1831
1832     else if ( name == "volume_gradation" )
1833       SetVolumeGradation( GetImpl()->ToDbl( optionValue ));
1834
1835     else if ( name == "tiny_edge_optimisation_length" )
1836       SetTinyEdgeOptimisationLength( GetImpl()->ToDbl( optionValue ));
1837
1838     else if ( name == "process_3d_topology" )
1839       SetPreCADProcess3DTopology( GetImpl()->ToBool( optionValue ));
1840
1841     // advanced options (for backward compatibility)
1842
1843     else if ( name == "create_tag_on_collision" ||
1844               name == "tiny_edge_respect_geometry" ||
1845               name == "remove_tiny_edges" ||
1846               name == "tiny_edge_length")
1847       AddPreCADOption( optionName, optionValue );
1848
1849     else {
1850       valueChanged = (this->GetImpl()->GetPreCADOptionValue(optionName) != optionValue);
1851       if (valueChanged)
1852         this->GetImpl()->SetPreCADOptionValue(optionName, optionValue);
1853     }
1854   } catch (const std::invalid_argument& ex) {
1855     THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
1856   } catch (SALOME_Exception& ex) {
1857     THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
1858   }
1859   if (valueChanged)
1860     SMESH::TPythonDump() << _this() << ".SetPreCADOptionValue( '" << optionName << "', '" << optionValue << "' )";
1861 }
1862
1863 //=============================================================================
1864
1865 char* BLSURFPlugin_Hypothesis_i::GetOptionValue(const char* optionName) {
1866   ASSERT(myBaseImpl);
1867   try {
1868     bool isDefault;
1869     return CORBA::string_dup(this->GetImpl()->GetOptionValue(optionName,&isDefault).c_str());
1870   } catch (const std::invalid_argument& ex) {
1871     THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
1872   } catch (SALOME_Exception& ex) {
1873     THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
1874   }
1875   return 0;
1876 }
1877
1878 //=============================================================================
1879
1880 char* BLSURFPlugin_Hypothesis_i::GetPreCADOptionValue(const char* optionName) {
1881   ASSERT(myBaseImpl);
1882   try {
1883     bool isDefault;
1884     return CORBA::string_dup(this->GetImpl()->GetPreCADOptionValue(optionName,&isDefault).c_str());
1885   } catch (const std::invalid_argument& ex) {
1886     THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
1887   } catch (SALOME_Exception& ex) {
1888     THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
1889   }
1890   return 0;
1891 }
1892
1893 //=============================================================================
1894
1895 void BLSURFPlugin_Hypothesis_i::UnsetOption(const char* optionName) {
1896   ASSERT(myBaseImpl);
1897   if ( !GetImpl()->GetOptionValue( optionName ).empty() )
1898   {
1899     this->GetImpl()->ClearOption(optionName);
1900     SMESH::TPythonDump() << _this() << ".UnsetOption( '" << optionName << "' )";
1901   }
1902 }
1903
1904 //=============================================================================
1905
1906 void BLSURFPlugin_Hypothesis_i::UnsetPreCADOption(const char* optionName) {
1907   ASSERT(myBaseImpl);
1908   if ( !GetImpl()->GetPreCADOptionValue( optionName ).empty() )
1909   {
1910     this->GetImpl()->ClearPreCADOption(optionName);
1911     SMESH::TPythonDump() << _this() << ".UnsetPreCADOption( '" << optionName << "' )";
1912   }
1913 }
1914
1915 //=============================================================================
1916
1917 BLSURFPlugin::string_array* BLSURFPlugin_Hypothesis_i::GetOptionValues() {
1918   ASSERT(myBaseImpl);
1919   BLSURFPlugin::string_array_var result = new BLSURFPlugin::string_array();
1920
1921   const ::BLSURFPlugin_Hypothesis::TOptionValues & opts = this->GetImpl()->GetOptionValues();
1922   result->length((CORBA::ULong) opts.size());
1923   int i=0;
1924
1925   bool isDefault;
1926   ::BLSURFPlugin_Hypothesis::TOptionValues::const_iterator opIt = opts.begin();
1927   for (; opIt != opts.end(); ++opIt, ++i) {
1928     string name_value_type = opIt->first;
1929     if (!opIt->second.empty()) {
1930       name_value_type += ":";
1931       name_value_type += GetImpl()->GetOptionValue( opIt->first, &isDefault );
1932       name_value_type += isDefault ? ":0" : ":1";
1933     }
1934     result[i] = CORBA::string_dup(name_value_type.c_str());
1935   }
1936
1937   return result._retn();
1938 }
1939
1940 //=============================================================================
1941
1942 BLSURFPlugin::string_array* BLSURFPlugin_Hypothesis_i::GetPreCADOptionValues() {
1943   ASSERT(myBaseImpl);
1944   BLSURFPlugin::string_array_var result = new BLSURFPlugin::string_array();
1945
1946   const ::BLSURFPlugin_Hypothesis::TOptionValues & opts = this->GetImpl()->GetPreCADOptionValues();
1947   result->length((CORBA::ULong) opts.size());
1948   int i=0;
1949
1950   bool isDefault;
1951   ::BLSURFPlugin_Hypothesis::TOptionValues::const_iterator opIt = opts.begin();
1952   for (; opIt != opts.end(); ++opIt, ++i) {
1953     string name_value_type = opIt->first;
1954     if (!opIt->second.empty()) {
1955       name_value_type += ":";
1956       name_value_type += GetImpl()->GetPreCADOptionValue( opIt->first, &isDefault );
1957       name_value_type += isDefault ? ":0" : ":1";
1958     }
1959     result[i] = CORBA::string_dup(name_value_type.c_str());
1960   }
1961   return result._retn();
1962 }
1963
1964 //=============================================================================
1965
1966 BLSURFPlugin::string_array* BLSURFPlugin_Hypothesis_i::GetAdvancedOptionValues()
1967 {
1968   BLSURFPlugin::string_array_var result = new BLSURFPlugin::string_array();
1969
1970   const ::BLSURFPlugin_Hypothesis::TOptionValues & custom_opts = this->GetImpl()->GetCustomOptionValues();
1971   result->length((CORBA::ULong) custom_opts.size());
1972   int i=0;
1973
1974   ::BLSURFPlugin_Hypothesis::TOptionValues::const_iterator opIt = custom_opts.begin();
1975   for (; opIt != custom_opts.end(); ++opIt, ++i) {
1976     string name_value_type = opIt->first;
1977     if (!opIt->second.empty()) {
1978       name_value_type += ":";
1979       name_value_type += opIt->second;
1980       name_value_type += ":1"; // user defined
1981     }
1982     result[i] = CORBA::string_dup(name_value_type.c_str());
1983   }
1984   return result._retn();
1985 }
1986
1987 //=============================================================================
1988
1989 void BLSURFPlugin_Hypothesis_i::SetOptionValues(const BLSURFPlugin::string_array& options)
1990 {
1991   ASSERT(myBaseImpl);
1992   for (CORBA::ULong i = 0; i < options.length(); ++i) {
1993     string name_value_type = options[i].in();
1994     if(name_value_type.empty())
1995       continue;
1996     size_t colonPos = name_value_type.find(':');
1997     string name, value;
1998     if (colonPos == string::npos) // ':' not found
1999       name = name_value_type;
2000     else {
2001       name = name_value_type.substr(0, colonPos);
2002       if (colonPos < name_value_type.size() - 1 && name_value_type[colonPos] != ' ') {
2003         string value_type = name_value_type.substr(colonPos + 1);
2004         colonPos = value_type.find(':');
2005         value = value_type.substr(0, colonPos);
2006         if (colonPos < value_type.size() - 1 && value_type[colonPos] != ' ')
2007           if ( value_type.substr(colonPos + 1) == "0" ) // is default
2008             value.clear();
2009       }
2010     }
2011     SetOptionValue(name.c_str(), value.c_str());
2012   }
2013 }
2014
2015 //=============================================================================
2016
2017 void BLSURFPlugin_Hypothesis_i::SetPreCADOptionValues(const BLSURFPlugin::string_array& options)
2018 {
2019   ASSERT(myBaseImpl);
2020   for ( CORBA::ULong i = 0; i < options.length(); ++i) {
2021     string name_value_type = options[i].in();
2022     if(name_value_type.empty())
2023       continue;
2024     size_t colonPos = name_value_type.find(':');
2025     string name, value;
2026     if (colonPos == string::npos) // ':' not found
2027       name = name_value_type;
2028     else {
2029       name = name_value_type.substr(0, colonPos);
2030       if (colonPos < name_value_type.size() - 1 && name_value_type[colonPos] != ' ') {
2031         string value_type = name_value_type.substr(colonPos + 1);
2032         colonPos = value_type.find(':');
2033         value = value_type.substr(0, colonPos);
2034         if (colonPos < value_type.size() - 1 && value_type[colonPos] != ' ')
2035           if ( value_type.substr(colonPos + 1) == "0" ) // is default
2036             value.clear();
2037       }
2038     }
2039     SetPreCADOptionValue(name.c_str(), value.c_str());
2040   }
2041 }
2042
2043 //=============================================================================
2044
2045 void BLSURFPlugin_Hypothesis_i::SetAdvancedOptionValues(const BLSURFPlugin::string_array& options)
2046 {
2047   SMESH::TPythonDump dump;
2048
2049   string optionsAndValues;
2050   for ( CORBA::ULong i = 0; i < options.length(); ++i) {
2051     string name_value_type = options[i].in();
2052     if(name_value_type.empty())
2053       continue;
2054     size_t colonPos = name_value_type.find(':');
2055     string name, value;
2056     if (colonPos == string::npos) // ':' not found
2057       name = name_value_type;
2058     else {
2059       name = name_value_type.substr(0, colonPos);
2060       if (colonPos < name_value_type.size() - 1 && name_value_type[colonPos] != ' ') {
2061         string value_type = name_value_type.substr(colonPos + 1);
2062         colonPos = value_type.find(':');
2063         value = value_type.substr(0, colonPos);
2064       }
2065     }
2066     AddOption(name.c_str(), value.c_str());
2067
2068     optionsAndValues += name + " " + value + " ";
2069   }
2070
2071   if ( !optionsAndValues.empty() )
2072     dump << _this() << ".SetAdvancedOptions( '" << optionsAndValues.c_str() << "' )";
2073 }
2074
2075 //=============================================================================
2076
2077 void BLSURFPlugin_Hypothesis_i::SetAdvancedOption(const char* optionsAndValues)
2078 {
2079   if ( !optionsAndValues ) return;
2080
2081   SMESH::TPythonDump dump;
2082
2083   std::istringstream strm( optionsAndValues );
2084   std::istream_iterator<std::string> sIt( strm ), sEnd;
2085   while ( sIt != sEnd )
2086   {
2087     std::string option = *sIt;
2088     if ( ++sIt != sEnd )
2089     {
2090       std::string value = *sIt;
2091       ++sIt;
2092       AddOption( option.c_str(), value.c_str() );
2093     }
2094     else
2095     {
2096       THROW_SALOME_CORBA_EXCEPTION( "Uneven number of options and values" ,SALOME::BAD_PARAM );
2097     }
2098   }
2099   dump << _this() << ".SetAdvancedOption( '" << optionsAndValues << "' )";
2100 }
2101
2102 //=============================================================================
2103
2104 void BLSURFPlugin_Hypothesis_i::AddOption(const char* optionName, const char* optionValue)
2105 {
2106   // backward compatibility
2107   {
2108     std::string name( optionName );
2109     if ( name == "proximity" )
2110       SetVolumeProximity( GetImpl()->ToBool( optionValue ));
2111
2112     else if ( name == "prox_ratio" )
2113       SetVolumeProximityRatio( GetImpl()->ToDbl( optionValue ));
2114
2115     else if ( name == "prox_nb_layer" )
2116       SetNbVolumeProximityLayers( (CORBA::Short) GetImpl()->ToInt( optionValue ));
2117   }
2118   bool valueChanged = (this->GetImpl()->GetOption(optionName) != optionValue);
2119   if (valueChanged) {
2120     this->GetImpl()->AddOption(optionName, optionValue);
2121     SMESH::TPythonDump() << _this() << ".AddOption( '" << optionName << "', '" << optionValue << "' )";
2122   }
2123 }
2124
2125 //=============================================================================
2126
2127 void BLSURFPlugin_Hypothesis_i::AddPreCADOption(const char* optionName, const char* optionValue)
2128 {
2129   ASSERT(myBaseImpl);
2130   bool valueChanged = (this->GetImpl()->GetPreCADOption(optionName) != optionValue);
2131   if (valueChanged) {
2132     this->GetImpl()->AddPreCADOption(optionName, optionValue);
2133     SMESH::TPythonDump() << _this() << ".AddPreCADOption( '" << optionName << "', '" << optionValue << "' )";
2134   }
2135 }
2136
2137 //=============================================================================
2138
2139 char* BLSURFPlugin_Hypothesis_i::GetOption(const char* optionName)
2140 {
2141   ASSERT(myBaseImpl);
2142   return CORBA::string_dup(this->GetImpl()->GetOption(optionName).c_str());
2143 }
2144
2145 //=============================================================================
2146
2147 char* BLSURFPlugin_Hypothesis_i::GetPreCADOption(const char* optionName)
2148 {
2149   ASSERT(myBaseImpl);
2150   return CORBA::string_dup(this->GetImpl()->GetPreCADOption(optionName).c_str());
2151 }
2152
2153 //=============================================================================
2154
2155 void BLSURFPlugin_Hypothesis_i::SetSizeMapEntry(const char* entry, const char* sizeMap)
2156 {
2157   ASSERT(myBaseImpl);
2158   if ( !entry || !entry[0] )
2159     THROW_SALOME_CORBA_EXCEPTION( "SetSizeMapEntry(): empty geom entry", SALOME::BAD_PARAM );
2160   bool valueChanged = false;
2161   try {
2162     valueChanged = (this->GetImpl()->GetSizeMapEntry(entry) != sizeMap);
2163     if (valueChanged)
2164       this->GetImpl()->SetSizeMapEntry(entry, sizeMap);
2165   } catch (const std::invalid_argument& ex) {
2166     SALOME::ExceptionStruct ExDescription;
2167     ExDescription.text = ex.what();
2168     ExDescription.type = SALOME::BAD_PARAM;
2169     ExDescription.sourceFile = "BLSURFPlugin_Hypothesis::SetSizeMapEntry(entry,sizemap)";
2170     ExDescription.lineNumber = 0;
2171     throw SALOME::SALOME_Exception(ExDescription);
2172   } catch (SALOME_Exception& ex) {
2173     THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
2174   }
2175   if (valueChanged)
2176     SMESH::TPythonDump() << _this() << ".SetSizeMap(" << entry << ", '" << sizeMap << "' )";
2177 }
2178
2179 //=============================================================================
2180
2181 void BLSURFPlugin_Hypothesis_i::SetConstantSizeMapEntry(const char* entry, GEOM::shape_type shapeType, CORBA::Double sizeMap)
2182 {
2183   ASSERT(myBaseImpl);
2184   bool valueChanged = false;
2185   std::ostringstream sizeMapFunction;
2186   switch (shapeType) {
2187   case GEOM::FACE:   sizeMapFunction << "def f(u,v): return " << sizeMap ; break;
2188   case GEOM::EDGE:   sizeMapFunction << "def f(t): return " << sizeMap ; break;
2189   case GEOM::VERTEX: sizeMapFunction << "def f(): return " << sizeMap ; break;
2190   default:;
2191   }
2192   try {
2193     valueChanged = (this->GetImpl()->GetSizeMapEntry(entry) != sizeMapFunction.str());
2194     if (valueChanged)
2195       this->GetImpl()->SetSizeMapEntry(entry, sizeMapFunction.str());
2196   } catch (const std::invalid_argument& ex) {
2197     SALOME::ExceptionStruct ExDescription;
2198     ExDescription.text = ex.what();
2199     ExDescription.type = SALOME::BAD_PARAM;
2200     ExDescription.sourceFile = "BLSURFPlugin_Hypothesis::SetSizeMapEntry(entry,sizemap)";
2201     ExDescription.lineNumber = 0;
2202     throw SALOME::SALOME_Exception(ExDescription);
2203   } catch (SALOME_Exception& ex) {
2204     THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
2205   }
2206   if (valueChanged)
2207     SMESH::TPythonDump() << _this() << ".SetConstantSizeMap(" << entry << ", " << sizeMap << " )";
2208 }
2209
2210 //=============================================================================
2211
2212 void BLSURFPlugin_Hypothesis_i::SetAttractorEntry(const char* entry, const char* attractor)
2213 {
2214   ASSERT(myBaseImpl);
2215   bool valueChanged = false;
2216   try {
2217     valueChanged = ( this->GetImpl()->GetAttractorEntry(entry) != attractor );
2218     if ( valueChanged ) {
2219       boost::regex re("^ATTRACTOR\\((?:(-?0(\\.\\d*)*|-?[1-9]+\\d*(\\.\\d*)*|-?\\.(\\d)+);){5}(True|False)(?:;(-?0(\\.\\d*)*|-?[1-9]+\\d*(\\.\\d*)*|-?\\.(\\d)+))?\\)$");
2220       if (!boost::regex_match(string(attractor), re))
2221         throw std::invalid_argument("Error: an attractor is defined with the following pattern: ATTRACTOR(xa;ya;za;a;b;True|False;d(opt.))");
2222       this->GetImpl()->SetAttractorEntry(entry, attractor);
2223     }
2224   } catch (const std::invalid_argument& ex) {
2225     SALOME::ExceptionStruct ExDescription;
2226     ExDescription.text = ex.what();
2227     ExDescription.type = SALOME::BAD_PARAM;
2228     ExDescription.sourceFile = "BLSURFPlugin_Hypothesis::SetAttractorEntry(entry,attractor)";
2229     ExDescription.lineNumber = 0;
2230     throw SALOME::SALOME_Exception(ExDescription);
2231   } catch (SALOME_Exception& ex) {
2232     THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
2233   }
2234   if (valueChanged)
2235     SMESH::TPythonDump() << _this() << ".SetAttractor(" << entry << ", '" << attractor << "' )";
2236 }
2237
2238 //=============================================================================
2239
2240 void BLSURFPlugin_Hypothesis_i::SetClassAttractorEntry(const char* entry, const char* att_entry, CORBA::Double StartSize, CORBA::Double EndSize, CORBA::Double ActionRadius, CORBA::Double ConstantRadius) //TODO ?? finir
2241 {
2242   ASSERT(myBaseImpl);
2243   //bool valueChanged = false;
2244   try {
2245     this->GetImpl()->SetClassAttractorEntry(entry, att_entry, StartSize, EndSize, ActionRadius, ConstantRadius);
2246   }
2247   catch (const std::invalid_argument& ex) {
2248     SALOME::ExceptionStruct ExDescription;
2249     ExDescription.text = ex.what();
2250     ExDescription.type = SALOME::BAD_PARAM;
2251     ExDescription.sourceFile = "BLSURFPlugin_Hypothesis::SetClassAttractorEntry(entry, att_entry, StartSize, EndSize, ActionRadius, ConstantRadius)";
2252     ExDescription.lineNumber = 0;
2253     throw SALOME::SALOME_Exception(ExDescription);
2254   } catch (SALOME_Exception& ex) {
2255     THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
2256   }
2257   //if ( valueChanged )
2258   SMESH::TPythonDump() << _this() << ".SetAttractorGeom( "
2259                        << entry << ", " << att_entry << ", "<<StartSize<<", "<<EndSize<<", "<<ActionRadius<<", "<<ConstantRadius<<" )";
2260 }
2261
2262 //=============================================================================
2263
2264 char* BLSURFPlugin_Hypothesis_i::GetSizeMapEntry(const char* entry) {
2265   ASSERT(myBaseImpl);
2266   try {
2267     return CORBA::string_dup(this->GetImpl()->GetSizeMapEntry(entry).c_str());
2268   } catch (const std::invalid_argument& ex) {
2269     SALOME::ExceptionStruct ExDescription;
2270     ExDescription.text = ex.what();
2271     ExDescription.type = SALOME::BAD_PARAM;
2272     ExDescription.sourceFile = "BLSURFPlugin_Hypothesis::GetSizeMapEntry(name)";
2273     ExDescription.lineNumber = 0;
2274     throw SALOME::SALOME_Exception(ExDescription);
2275   } catch (SALOME_Exception& ex) {
2276     THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
2277   }
2278   return 0;
2279 }
2280
2281 //=============================================================================
2282
2283 char* BLSURFPlugin_Hypothesis_i::GetAttractorEntry(const char* entry) {
2284   ASSERT(myBaseImpl);
2285   try {
2286     return CORBA::string_dup(this->GetImpl()->GetAttractorEntry(entry).c_str());
2287   } catch (const std::invalid_argument& ex) {
2288     SALOME::ExceptionStruct ExDescription;
2289     ExDescription.text = ex.what();
2290     ExDescription.type = SALOME::BAD_PARAM;
2291     ExDescription.sourceFile = "BLSURFPlugin_Hypothesis::GetAttractorEntry(name)";
2292     ExDescription.lineNumber = 0;
2293     throw SALOME::SALOME_Exception(ExDescription);
2294   } catch (SALOME_Exception& ex) {
2295     THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
2296   }
2297   return 0;
2298 }
2299
2300 // //=============================================================================
2301 // 
2302 // // TODO coder cette fonction (utilis??e pour savoir si la valeur a chang??
2303 // // A finir pour le dump
2304 // char* BLSURFPlugin_Hypothesis_i::GetClassAttractorEntry(const char* entry)
2305 // {
2306 //   ASSERT(myBaseImpl);
2307 //   try {
2308 //     return CORBA::string_dup( this->GetImpl()->GetClassAttractorEntry(entry).c_str());
2309 //   }
2310 //   catch (const std::invalid_argument& ex) {
2311 //     SALOME::ExceptionStruct ExDescription;
2312 //     ExDescription.text = ex.what();
2313 //     ExDescription.type = SALOME::BAD_PARAM;
2314 //     ExDescription.sourceFile = "BLSURFPlugin_Hypothesis::GetClassAttractorEntry(name)";
2315 //     ExDescription.lineNumber = 0;
2316 //     throw SALOME::SALOME_Exception(ExDescription);
2317 //   }
2318 //   catch (SALOME_Exception& ex) {
2319 //     THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
2320 //   }
2321 //   return 0;
2322 // }
2323
2324 //=============================================================================
2325
2326 void BLSURFPlugin_Hypothesis_i::UnsetEntry(const char* entry) {
2327   ASSERT(myBaseImpl);
2328   this->GetImpl()->ClearEntry(entry);
2329   //  SMESH::TPythonDump() << _this() << ".UnsetSizeMap( " << entry << " )";
2330 }
2331
2332 //=============================================================================
2333
2334 BLSURFPlugin::string_array* BLSURFPlugin_Hypothesis_i::GetSizeMapEntries() {
2335   ASSERT(myBaseImpl);
2336   BLSURFPlugin::string_array_var result = new BLSURFPlugin::string_array();
2337
2338   const ::BLSURFPlugin_Hypothesis::TSizeMap sizeMaps = this->GetImpl()->_GetSizeMapEntries();
2339   result->length((CORBA::ULong) sizeMaps.size());
2340
2341   ::BLSURFPlugin_Hypothesis::TSizeMap::const_iterator smIt = sizeMaps.begin();
2342   for (int i = 0; smIt != sizeMaps.end(); ++smIt, ++i) {
2343     string entry_sizemap = smIt->first;
2344     if (!smIt->second.empty()) {
2345       entry_sizemap += "|";
2346       entry_sizemap += smIt->second;
2347     }
2348     result[i] = CORBA::string_dup(entry_sizemap.c_str());
2349   }
2350   return result._retn();
2351 }
2352
2353 //=============================================================================
2354
2355 BLSURFPlugin::string_array* BLSURFPlugin_Hypothesis_i::GetAttractorEntries() {
2356   ASSERT(myBaseImpl);
2357   BLSURFPlugin::string_array_var result = new BLSURFPlugin::string_array();
2358
2359   const ::BLSURFPlugin_Hypothesis::TSizeMap attractors = this->GetImpl()->_GetAttractorEntries();
2360   result->length((CORBA::ULong) attractors.size());
2361
2362   ::BLSURFPlugin_Hypothesis::TSizeMap::const_iterator atIt = attractors.begin();
2363   for (int i = 0; atIt != attractors.end(); ++atIt, ++i) {
2364     string entry_attractor = atIt->first;
2365     if (!atIt->second.empty()) {
2366       entry_attractor += "|";
2367       entry_attractor += atIt->second;
2368     }
2369     result[i] = CORBA::string_dup(entry_attractor.c_str());
2370   }
2371   return result._retn();
2372 }
2373
2374 //=============================================================================
2375
2376 BLSURFPlugin::TAttParamsMap* BLSURFPlugin_Hypothesis_i::GetAttractorParams()
2377 {
2378   ASSERT(myBaseImpl);
2379   BLSURFPlugin::TAttParamsMap_var result = new BLSURFPlugin::TAttParamsMap();
2380
2381   const ::BLSURFPlugin_Hypothesis::TAttractorMap attractors= this->GetImpl()->_GetClassAttractorEntries();
2382   result->length((CORBA::ULong) attractors.size() );
2383
2384   ::BLSURFPlugin_Hypothesis::TAttractorMap::const_iterator atIt = attractors.begin();
2385   for ( int i = 0 ; atIt != attractors.end(); ++atIt, ++i ) {
2386     string faceEntry = atIt->first;
2387     string attEntry;
2388     double startSize=0., endSize=0., infDist=0., constDist=0.;
2389     if ( !atIt->second->Empty() ) {
2390       attEntry = atIt->second->GetAttractorEntry();
2391       std::vector<double> params = atIt->second->GetParameters();
2392       startSize = params[0];
2393       endSize = params[1];
2394       infDist = params[2];
2395       constDist = params[3];
2396     }
2397     result[i].faceEntry = CORBA::string_dup(faceEntry.c_str());
2398     result[i].attEntry = CORBA::string_dup(attEntry.c_str());
2399     result[i].startSize = startSize;
2400     result[i].endSize = endSize;
2401     result[i].infDist = infDist;
2402     result[i].constDist = constDist;
2403   }
2404   return result._retn();
2405 }
2406
2407 //=============================================================================
2408
2409 void BLSURFPlugin_Hypothesis_i::SetSizeMapEntries(const BLSURFPlugin::string_array& sizeMaps)
2410 {
2411   ASSERT(myBaseImpl);
2412   for ( CORBA::ULong i = 0; i < sizeMaps.length(); ++i) {
2413     string entry_sizemap = sizeMaps[i].in();
2414     size_t colonPos = entry_sizemap.find('|');
2415     string entry, sizemap;
2416     if (colonPos == string::npos) // '|' separator not found
2417       entry = entry_sizemap;
2418     else {
2419       entry = entry_sizemap.substr(0, colonPos);
2420       if (colonPos < entry_sizemap.size() - 1 && entry_sizemap[colonPos] != ' ')
2421         sizemap = entry_sizemap.substr(colonPos + 1);
2422     }
2423     this->GetImpl()->SetSizeMapEntry(entry.c_str(), sizemap.c_str());
2424   }
2425 }
2426
2427 //=============================================================================
2428
2429 void BLSURFPlugin_Hypothesis_i::ClearSizeMaps() {
2430   ASSERT(myBaseImpl);
2431   this->GetImpl()->ClearSizeMaps();
2432 }
2433
2434 //=============================================================================
2435
2436 void BLSURFPlugin_Hypothesis_i::SetSizeMap(const GEOM::GEOM_Object_ptr GeomObj, const char* sizeMap)
2437 {
2438   ASSERT(myBaseImpl);
2439   string entry;
2440   entry = GeomObj->GetStudyEntry();
2441   SetSizeMapEntry(entry.c_str(), sizeMap);
2442 }
2443
2444 //=============================================================================
2445
2446 void BLSURFPlugin_Hypothesis_i::SetConstantSizeMap(const GEOM::GEOM_Object_ptr GeomObj, CORBA::Double sizeMap) {
2447   ASSERT(myBaseImpl);
2448   string entry = GeomObj->GetStudyEntry();
2449   GEOM::shape_type shapeType = GeomObj->GetShapeType();
2450   if (shapeType == GEOM::COMPOUND)
2451     shapeType = GeomObj->GetMaxShapeType();
2452   SetConstantSizeMapEntry(entry.c_str(), shapeType, sizeMap);
2453 }
2454
2455 //=============================================================================
2456 void BLSURFPlugin_Hypothesis_i::UnsetSizeMap(const GEOM::GEOM_Object_ptr GeomObj) {
2457   ASSERT(myBaseImpl);
2458   string entry;
2459   entry = GeomObj->GetStudyEntry();
2460   UnsetEntry(entry.c_str());
2461   SMESH::TPythonDump() << _this() << ".UnsetSizeMap( " << entry.c_str() << " )";
2462 }
2463
2464 void BLSURFPlugin_Hypothesis_i::SetAttractor(GEOM::GEOM_Object_ptr GeomObj, const char* attractor) {
2465   ASSERT(myBaseImpl);
2466   string entry;
2467   entry = GeomObj->GetStudyEntry();
2468   SetAttractorEntry(entry.c_str(), attractor);
2469 }
2470
2471 void BLSURFPlugin_Hypothesis_i::UnsetAttractor(GEOM::GEOM_Object_ptr GeomObj) {
2472   ASSERT(myBaseImpl);
2473   string entry;
2474   entry = GeomObj->GetStudyEntry();
2475   UnsetEntry(entry.c_str());
2476   SMESH::TPythonDump() << _this() << ".UnsetAttractor( " << entry.c_str() << " )";
2477 }
2478
2479 void BLSURFPlugin_Hypothesis_i::SetAttractorGeom(GEOM::GEOM_Object_ptr theFace, GEOM::GEOM_Object_ptr theAttractor, CORBA::Double StartSize, CORBA::Double EndSize, CORBA::Double ActionRadius, CORBA::Double ConstantRadius)
2480 {
2481   ASSERT(myBaseImpl);
2482   string theFaceEntry;
2483   string theAttEntry;
2484   theFaceEntry = theFace->GetStudyEntry();
2485   theAttEntry  = theAttractor->GetStudyEntry();
2486   
2487   GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine( theFace );
2488   string aName;
2489   
2490   if (theFaceEntry.empty()) {
2491     aName = "Face_";
2492     aName += theFace->GetEntry();
2493     SALOMEDS::SObject_wrap theSFace = geomGen->PublishInStudy(NULL, theFace, aName.c_str());
2494     if (!theSFace->_is_nil())
2495       theFaceEntry = theSFace->GetID();
2496   }
2497   if (theFaceEntry.empty())
2498     THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM );
2499   
2500   if (theAttEntry.empty()) {
2501     if (theAttractor->GetShapeType() == GEOM::VERTEX)
2502       aName = "Vertex_";
2503     if (theAttractor->GetShapeType() == GEOM::EDGE)
2504       aName = "Edge_";
2505     if (theAttractor->GetShapeType() == GEOM::WIRE)
2506       aName = "Wire_";
2507     if (theAttractor->GetShapeType() == GEOM::COMPOUND)
2508       aName = "Compound_";
2509     aName += theAttractor->GetEntry();
2510     SALOMEDS::SObject_wrap theSAtt = geomGen->PublishInStudy(NULL, theAttractor, aName.c_str());
2511     if (!theSAtt->_is_nil())
2512       theAttEntry = theSAtt->GetID();
2513   }
2514   if (theAttEntry.empty())
2515     THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM );
2516   
2517   TopoDS_Face FaceShape = TopoDS::Face(SMESH_Gen_i::GetSMESHGen()->GeomObjectToShape( theFace ));
2518   TopoDS_Shape AttractorShape = SMESH_Gen_i::GetSMESHGen()->GeomObjectToShape( theAttractor );
2519   SetClassAttractorEntry( theFaceEntry.c_str(), theAttEntry.c_str(), StartSize, EndSize, ActionRadius, ConstantRadius);
2520 }
2521
2522 void BLSURFPlugin_Hypothesis_i::UnsetAttractorGeom(GEOM::GEOM_Object_ptr theFace,
2523                                                    GEOM::GEOM_Object_ptr theAttractor)
2524 {
2525   ASSERT(myBaseImpl);
2526   CORBA::String_var theFaceEntry = theFace->GetStudyEntry();
2527   CORBA::String_var theAttrEntry = theAttractor->GetStudyEntry();
2528   
2529   // GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine( theFace );
2530   // string aName;
2531   
2532   // if (theFaceEntry.empty()) {
2533   //   aName = "Face_";
2534   //   aName += theFace->GetEntry();
2535   //   SALOMEDS::SObject_wrap theSFace = geomGen->PublishInStudy(NULL, theFace, aName.c_str());
2536   //   if (!theSFace->_is_nil())
2537   //     theFaceEntry = theSFace->GetID();
2538   // }
2539   if ( !theFaceEntry.in() || !theFaceEntry.in()[0] ||
2540        !theAttrEntry.in() || !theAttrEntry.in()[0] )
2541     THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM );
2542   
2543   GetImpl()->ClearEntry( theFaceEntry.in(), theAttrEntry.in() );
2544   SMESH::TPythonDump() << _this() << ".UnsetAttractorGeom( "
2545                        << theFace << ", " << theAttractor << " )";
2546 }
2547
2548 void BLSURFPlugin_Hypothesis_i::UnsetAttractorEntry(const char* faceEntry,
2549                                                     const char* attractorEntry)
2550 {
2551   GetImpl()->ClearEntry( faceEntry, attractorEntry );
2552   SMESH::TPythonDump() << _this() << ".UnsetAttractorEntry( '"
2553                        << faceEntry << "', '" << attractorEntry << "' )";
2554 }
2555
2556
2557 /*
2558   void BLSURFPlugin_Hypothesis_i::SetCustomSizeMap(GEOM::GEOM_Object_ptr GeomObj, const char* sizeMap)
2559   {}
2560
2561   void BLSURFPlugin_Hypothesis_i::UnsetCustomSizeMap(GEOM::GEOM_Object_ptr GeomObj)
2562   {}
2563
2564   void BLSURFPlugin_Hypothesis_i::SetCustomSizeMapEntry(const char* entry,const char* sizeMap )
2565   {}
2566
2567   char* BLSURFPlugin_Hypothesis_i::GetCustomSizeMapEntry(const char* entry)
2568   {}
2569
2570   void BLSURFPlugin_Hypothesis_i::UnsetCustomSizeMapEntry(const char* entry)
2571   {
2572   ASSERT(myBaseImpl);
2573   this->GetImpl()->UnsetCustomSizeMap(entry);
2574   SMESH::TPythonDump() << _this() << ".UnsetCustomSizeMap( " << entry << " )";
2575   }
2576
2577
2578   BLSURFPlugin::string_array* BLSURFPlugin_Hypothesis_i::GetCustomSizeMapEntries()
2579   {}
2580
2581 */
2582
2583 // ///////////////////////
2584 // // ENFORCED VERTICES //
2585 // ///////////////////////
2586
2587
2588 /**
2589  * Returns the list of enforced vertices for a given Face entry
2590  * @return A map of Face entry / List of enforced vertices
2591  *
2592  */
2593 BLSURFPlugin::TFaceEntryEnfVertexListMap* BLSURFPlugin_Hypothesis_i::GetAllEnforcedVerticesByFace() {
2594   ASSERT(myBaseImpl);
2595
2596   BLSURFPlugin::TFaceEntryEnfVertexListMap_var resultMap = new BLSURFPlugin::TFaceEntryEnfVertexListMap();
2597
2598   const ::BLSURFPlugin_Hypothesis::TFaceEntryEnfVertexListMap faceEntryEnfVertexListMap =
2599     this->GetImpl()->_GetAllEnforcedVerticesByFace();
2600   resultMap->length((CORBA::ULong) faceEntryEnfVertexListMap.size());
2601
2602   ::BLSURFPlugin_Hypothesis::TEnfVertexList _enfVertexList;
2603   ::BLSURFPlugin_Hypothesis::TFaceEntryEnfVertexListMap::const_iterator it_entry = faceEntryEnfVertexListMap.begin();
2604   for (int i = 0; it_entry != faceEntryEnfVertexListMap.end(); ++it_entry, ++i) {
2605     BLSURFPlugin::TFaceEntryEnfVertexListMapElement_var mapElement =
2606       new BLSURFPlugin::TFaceEntryEnfVertexListMapElement();
2607     mapElement->faceEntry = CORBA::string_dup(it_entry->first.c_str());
2608
2609     _enfVertexList = it_entry->second;
2610     BLSURFPlugin::TEnfVertexList_var enfVertexList = new BLSURFPlugin::TEnfVertexList();
2611     enfVertexList->length((CORBA::ULong) _enfVertexList.size());
2612
2613     ::BLSURFPlugin_Hypothesis::TEnfVertexList::const_iterator it_enfVertex = _enfVertexList.begin();
2614     ::BLSURFPlugin_Hypothesis::TEnfVertex *currentEnfVertex;
2615     for (int j = 0; it_enfVertex != _enfVertexList.end(); ++it_enfVertex, ++j) {
2616       currentEnfVertex = (*it_enfVertex);
2617
2618       BLSURFPlugin::TEnfVertex_var enfVertex = new BLSURFPlugin::TEnfVertex();
2619
2620       // Name
2621       enfVertex->name = CORBA::string_dup(currentEnfVertex->name.c_str());
2622
2623       // Geom entry
2624       enfVertex->geomEntry = CORBA::string_dup(currentEnfVertex->geomEntry.c_str());
2625
2626       // Coords
2627       BLSURFPlugin::TEnfVertexCoords_var coords = new BLSURFPlugin::TEnfVertexCoords();
2628       coords->length((CORBA::ULong) currentEnfVertex->coords.size());
2629       for (CORBA::ULong i=0;i<coords->length();i++)
2630         coords[i] = currentEnfVertex->coords[i];
2631       enfVertex->coords = coords;
2632
2633       // Group name
2634       enfVertex->grpName = CORBA::string_dup(currentEnfVertex->grpName.c_str());
2635       
2636       // Face entry list
2637       BLSURFPlugin::TEntryList_var faceEntryList = new BLSURFPlugin::TEntryList();
2638       faceEntryList->length((CORBA::ULong) currentEnfVertex->faceEntries.size());
2639       ::BLSURFPlugin_Hypothesis::TEntryList::const_iterator it_entry = currentEnfVertex->faceEntries.begin();
2640       for (int ind = 0; it_entry != currentEnfVertex->faceEntries.end();++it_entry, ++ind)
2641         faceEntryList[ind] = CORBA::string_dup((*it_entry).c_str());
2642       enfVertex->faceEntries = faceEntryList;
2643
2644       ostringstream msg;
2645       msg << "Enforced vertex: \n"
2646           << "Name: " << enfVertex->name << "\n";
2647       if (coords->length())
2648         msg << "Coords: " << enfVertex->coords[0] << ", " << enfVertex->coords[1] << ", " << enfVertex->coords[2] << "\n";
2649       msg << "Geom entry: " << enfVertex->geomEntry << "\n"
2650           << "Group Name: " << enfVertex->grpName;
2651
2652       enfVertexList[j] = enfVertex;
2653     }
2654     mapElement->enfVertexList = enfVertexList;
2655
2656     resultMap[i] = mapElement;
2657
2658   }
2659   return resultMap._retn();
2660 }
2661
2662 /**
2663  * Returns the list of all enforced vertices
2664  * @return a list of enforced vertices
2665  *
2666  */
2667 BLSURFPlugin::TEnfVertexList* BLSURFPlugin_Hypothesis_i::GetAllEnforcedVertices() {
2668   ASSERT(myBaseImpl);
2669   BLSURFPlugin::TEnfVertexList_var resultMap = new BLSURFPlugin::TEnfVertexList();
2670   const ::BLSURFPlugin_Hypothesis::TEnfVertexList enfVertexList = this->GetImpl()->_GetAllEnforcedVertices();
2671   resultMap->length((CORBA::ULong) enfVertexList.size());
2672
2673   ::BLSURFPlugin_Hypothesis::TEnfVertexList::const_iterator evlIt = enfVertexList.begin();
2674   ::BLSURFPlugin_Hypothesis::TEnfVertex *currentEnfVertex;
2675   for (int i = 0; evlIt != enfVertexList.end(); ++evlIt, ++i) {
2676     currentEnfVertex = (*evlIt);
2677     BLSURFPlugin::TEnfVertex_var enfVertex = new BLSURFPlugin::TEnfVertex();
2678     // Name
2679     enfVertex->name = CORBA::string_dup(currentEnfVertex->name.c_str());
2680     // Geom entry
2681     enfVertex->geomEntry = CORBA::string_dup(currentEnfVertex->geomEntry.c_str());
2682     // Coords
2683     BLSURFPlugin::TEnfVertexCoords_var coords = new BLSURFPlugin::TEnfVertexCoords();
2684     coords->length((CORBA::ULong) currentEnfVertex->coords.size());
2685     for (CORBA::ULong ind = 0; ind < coords->length(); ind++)
2686       coords[ind] = currentEnfVertex->coords[ind];
2687     enfVertex->coords = coords;
2688     // Group name
2689     enfVertex->grpName = CORBA::string_dup(currentEnfVertex->grpName.c_str());  
2690     // Face entry list
2691     BLSURFPlugin::TEntryList_var faceEntryList = new BLSURFPlugin::TEntryList();
2692     faceEntryList->length((CORBA::ULong) currentEnfVertex->faceEntries.size());
2693     ::BLSURFPlugin_Hypothesis::TEntryList::const_iterator it_entry = currentEnfVertex->faceEntries.begin();
2694     for (int ind = 0; it_entry != currentEnfVertex->faceEntries.end();++it_entry, ++ind)
2695       faceEntryList[ind] = CORBA::string_dup((*it_entry).c_str());
2696     enfVertex->faceEntries = faceEntryList;
2697
2698     ostringstream msg;
2699     msg << "Enforced vertex: \n"
2700         << "Name: " << enfVertex->name << "\n";
2701     if (coords->length())
2702       msg << "Coords: " << enfVertex->coords[0] << ", " << enfVertex->coords[1] << ", " << enfVertex->coords[2] << "\n";
2703     msg << "Geom entry: " << enfVertex->geomEntry << "\n"
2704         << "Group Name: " << enfVertex->grpName;
2705
2706     resultMap[i] = enfVertex;
2707   }
2708   return resultMap._retn();
2709
2710 }
2711
2712 /**
2713  * Returns the list of enforced vertices coords for a given Face entry.
2714  * They are the coords of the "manual" enforced vertices.
2715  * @return A map of Face entry / List of enforced vertices coords
2716  *
2717  */
2718 BLSURFPlugin::TFaceEntryCoordsListMap* BLSURFPlugin_Hypothesis_i::GetAllCoordsByFace() {
2719   ASSERT(myBaseImpl);
2720
2721   BLSURFPlugin::TFaceEntryCoordsListMap_var resultMap = new BLSURFPlugin::TFaceEntryCoordsListMap();
2722
2723   const ::BLSURFPlugin_Hypothesis::TFaceEntryCoordsListMap entryCoordsListMap = this->GetImpl()->_GetAllCoordsByFace();
2724   resultMap->length((CORBA::ULong) entryCoordsListMap.size());
2725
2726   ::BLSURFPlugin_Hypothesis::TEnfVertexCoordsList _coordsList;
2727   ::BLSURFPlugin_Hypothesis::TFaceEntryCoordsListMap::const_iterator it_entry = entryCoordsListMap.begin();
2728   for (int i = 0; it_entry != entryCoordsListMap.end(); ++it_entry, ++i) {
2729     BLSURFPlugin::TFaceEntryCoordsListMapElement_var mapElement = new BLSURFPlugin::TFaceEntryCoordsListMapElement();
2730     mapElement->faceEntry = CORBA::string_dup(it_entry->first.c_str());
2731
2732     _coordsList = it_entry->second;
2733     BLSURFPlugin::TEnfVertexCoordsList_var coordsList = new BLSURFPlugin::TEnfVertexCoordsList();
2734     coordsList->length((CORBA::ULong) _coordsList.size());
2735
2736     ::BLSURFPlugin_Hypothesis::TEnfVertexCoordsList::const_iterator it_coords = _coordsList.begin();
2737     for (int j = 0; it_coords != _coordsList.end(); ++it_coords, ++j) {
2738       BLSURFPlugin::TEnfVertexCoords_var coords = new BLSURFPlugin::TEnfVertexCoords();
2739       coords->length((CORBA::ULong) (*it_coords).size());
2740       for (CORBA::ULong i=0;i<coords->length();i++)
2741         coords[i] = (*it_coords)[i];
2742       coordsList[j] = coords;
2743     }
2744     mapElement->coordsList = coordsList;
2745
2746     resultMap[i] = mapElement;
2747
2748   }
2749   return resultMap._retn();
2750 }
2751
2752 /**
2753  * Returns a map of enforced vertices coords / enforced vertex.
2754  * They are the coords of the "manual" enforced vertices.
2755  */
2756 BLSURFPlugin::TCoordsEnfVertexMap* BLSURFPlugin_Hypothesis_i::GetAllEnforcedVerticesByCoords() {
2757   ASSERT(myBaseImpl);
2758
2759   BLSURFPlugin::TCoordsEnfVertexMap_var resultMap = new BLSURFPlugin::TCoordsEnfVertexMap();
2760   const ::BLSURFPlugin_Hypothesis::TCoordsEnfVertexMap coordsEnfVertexMap =
2761     this->GetImpl()->_GetAllEnforcedVerticesByCoords();
2762   resultMap->length((CORBA::ULong) coordsEnfVertexMap.size());
2763
2764   ::BLSURFPlugin_Hypothesis::TCoordsEnfVertexMap::const_iterator it_coords = coordsEnfVertexMap.begin();
2765   ::BLSURFPlugin_Hypothesis::TEnfVertex *currentEnfVertex;
2766   for (int i = 0; it_coords != coordsEnfVertexMap.end(); ++it_coords, ++i) {
2767     currentEnfVertex = (it_coords->second);
2768     BLSURFPlugin::TCoordsEnfVertexElement_var mapElement = new BLSURFPlugin::TCoordsEnfVertexElement();
2769     BLSURFPlugin::TEnfVertexCoords_var coords = new BLSURFPlugin::TEnfVertexCoords();
2770     coords->length((CORBA::ULong) it_coords->first.size());
2771     for (CORBA::ULong ind=0;ind<coords->length();ind++)
2772       coords[ind] = it_coords->first[ind];
2773     mapElement->coords = coords;
2774
2775     BLSURFPlugin::TEnfVertex_var enfVertex = new BLSURFPlugin::TEnfVertex();
2776     // Name
2777     enfVertex->name = CORBA::string_dup(currentEnfVertex->name.c_str());
2778     // Geom entry
2779     enfVertex->geomEntry = CORBA::string_dup(currentEnfVertex->geomEntry.c_str());
2780     // Coords
2781     BLSURFPlugin::TEnfVertexCoords_var coords2 = new BLSURFPlugin::TEnfVertexCoords();
2782     coords2->length((CORBA::ULong) currentEnfVertex->coords.size());
2783     for (CORBA::ULong ind=0;ind<coords2->length();ind++)
2784       coords2[ind] = currentEnfVertex->coords[ind];
2785     enfVertex->coords = coords2;
2786     // Group name
2787     enfVertex->grpName = CORBA::string_dup(currentEnfVertex->grpName.c_str());  
2788     // Face entry list
2789     BLSURFPlugin::TEntryList_var faceEntryList = new BLSURFPlugin::TEntryList();
2790     faceEntryList->length((CORBA::ULong) currentEnfVertex->faceEntries.size());
2791     ::BLSURFPlugin_Hypothesis::TEntryList::const_iterator it_entry = currentEnfVertex->faceEntries.begin();
2792     for (int ind = 0; it_entry != currentEnfVertex->faceEntries.end();++it_entry, ++ind)
2793       faceEntryList[ind] = CORBA::string_dup((*it_entry).c_str());
2794     enfVertex->faceEntries = faceEntryList;
2795       
2796     mapElement->enfVertex = enfVertex;
2797     ostringstream msg;
2798     msg << "Enforced vertex: \n"
2799         << "Name: " << enfVertex->name << "\n";
2800     if (coords->length())
2801       msg << "Coords: " << enfVertex->coords[0] << ", " << enfVertex->coords[1] << ", " << enfVertex->coords[2] << "\n";
2802     msg << "Geom entry: " << enfVertex->geomEntry << "\n"
2803         << "Group Name: " << enfVertex->grpName;
2804
2805     resultMap[i] = mapElement;
2806   }
2807   return resultMap._retn();
2808 }
2809
2810 /**
2811  * Returns the list of enforced vertices entries for a given Face entry.
2812  * They are the geom entries of the enforced vertices based on geom shape (vertex, compound, group).
2813  * @return A map of Face entry / List of enforced vertices geom entries
2814  *
2815  */
2816 BLSURFPlugin::TFaceEntryEnfVertexEntryListMap* BLSURFPlugin_Hypothesis_i::GetAllEnfVertexEntriesByFace() {
2817   ASSERT(myBaseImpl);
2818
2819   BLSURFPlugin::TFaceEntryEnfVertexEntryListMap_var resultMap = new BLSURFPlugin::TFaceEntryEnfVertexEntryListMap();
2820
2821   const ::BLSURFPlugin_Hypothesis::TFaceEntryEnfVertexEntryListMap entryEnfVertexEntryListMap =
2822     this->GetImpl()->_GetAllEnfVertexEntriesByFace();
2823   resultMap->length((CORBA::ULong) entryEnfVertexEntryListMap.size());
2824
2825   ::BLSURFPlugin_Hypothesis::TEntryList _enfVertexEntryList;
2826   ::BLSURFPlugin_Hypothesis::TFaceEntryEnfVertexEntryListMap::const_iterator it_entry =
2827       entryEnfVertexEntryListMap.begin();
2828   for (int i = 0; it_entry != entryEnfVertexEntryListMap.end(); ++it_entry, ++i) {
2829     BLSURFPlugin::TFaceEntryEnfVertexEntryListMapElement_var mapElement =
2830       new BLSURFPlugin::TFaceEntryEnfVertexEntryListMapElement();
2831     mapElement->faceEntry = CORBA::string_dup(it_entry->first.c_str());
2832
2833     _enfVertexEntryList = it_entry->second;
2834     BLSURFPlugin::TEntryList_var enfVertexEntryList = new BLSURFPlugin::TEntryList();
2835     enfVertexEntryList->length((CORBA::ULong) _enfVertexEntryList.size());
2836
2837     ::BLSURFPlugin_Hypothesis::TEntryList::const_iterator it_enfVertexEntry = _enfVertexEntryList.begin();
2838     for (int j = 0; it_enfVertexEntry != _enfVertexEntryList.end(); ++it_enfVertexEntry, ++j) {
2839       enfVertexEntryList[j] = CORBA::string_dup((*it_enfVertexEntry).c_str());
2840     }
2841     mapElement->enfVertexEntryList = enfVertexEntryList;
2842
2843     resultMap[i] = mapElement;
2844
2845   }
2846   return resultMap._retn();
2847 }
2848
2849 /**
2850  * Returns a map of enforced vertices geom entry / enforced vertex.
2851  * They are the geom entries of the enforced vertices defined with geom shape (vertex, compound, group).
2852  */
2853 BLSURFPlugin::TEnfVertexEntryEnfVertexMap* BLSURFPlugin_Hypothesis_i::GetAllEnforcedVerticesByEnfVertexEntry() {
2854   ASSERT(myBaseImpl);
2855
2856   BLSURFPlugin::TEnfVertexEntryEnfVertexMap_var resultMap = new BLSURFPlugin::TEnfVertexEntryEnfVertexMap();
2857   const ::BLSURFPlugin_Hypothesis::TEnfVertexEntryEnfVertexMap enfVertexEntryEnfVertexMap =
2858     this->GetImpl()->_GetAllEnforcedVerticesByEnfVertexEntry();
2859   resultMap->length((CORBA::ULong) enfVertexEntryEnfVertexMap.size());
2860
2861   ::BLSURFPlugin_Hypothesis::TEnfVertexEntryEnfVertexMap::const_iterator it_enfVertexEntry = enfVertexEntryEnfVertexMap.begin();
2862   ::BLSURFPlugin_Hypothesis::TEnfVertex *currentEnfVertex;
2863   for (int i = 0; it_enfVertexEntry != enfVertexEntryEnfVertexMap.end(); ++it_enfVertexEntry, ++i) {
2864     currentEnfVertex = it_enfVertexEntry->second;
2865     BLSURFPlugin::TEnfVertexEntryEnfVertexElement_var mapElement = new BLSURFPlugin::TEnfVertexEntryEnfVertexElement();
2866     mapElement->enfVertexEntry = CORBA::string_dup(it_enfVertexEntry->first.c_str());;
2867
2868     BLSURFPlugin::TEnfVertex_var enfVertex = new BLSURFPlugin::TEnfVertex();
2869     // Name
2870     enfVertex->name = CORBA::string_dup(currentEnfVertex->name.c_str());
2871     // Geom entry
2872     enfVertex->geomEntry = CORBA::string_dup(currentEnfVertex->geomEntry.c_str());
2873     // Coords
2874     BLSURFPlugin::TEnfVertexCoords_var coords = new BLSURFPlugin::TEnfVertexCoords();
2875     coords->length((CORBA::ULong) currentEnfVertex->coords.size());
2876     for (CORBA::ULong ind=0;ind<coords->length();ind++)
2877       coords[ind] = currentEnfVertex->coords[ind];
2878     enfVertex->coords = coords;
2879     // Group name
2880     enfVertex->grpName = CORBA::string_dup(currentEnfVertex->grpName.c_str());  
2881     // Face entry list
2882     BLSURFPlugin::TEntryList_var faceEntryList = new BLSURFPlugin::TEntryList();
2883     faceEntryList->length((CORBA::ULong) currentEnfVertex->faceEntries.size());
2884     ::BLSURFPlugin_Hypothesis::TEntryList::const_iterator it_entry = currentEnfVertex->faceEntries.begin();
2885     for (int ind = 0; it_entry != currentEnfVertex->faceEntries.end();++it_entry, ++ind)
2886       faceEntryList[ind] = CORBA::string_dup((*it_entry).c_str());
2887     enfVertex->faceEntries = faceEntryList;
2888
2889     ostringstream msg;
2890     msg << "Enforced vertex: \n"
2891         << "Name: " << enfVertex->name << "\n";
2892     if (coords->length())
2893       msg << "Coords: " << enfVertex->coords[0] << ", " << enfVertex->coords[1] << ", " << enfVertex->coords[2] << "\n";
2894     msg << "Geom entry: " << enfVertex->geomEntry << "\n"
2895         << "Group Name: " << enfVertex->grpName;
2896
2897     mapElement->enfVertex = enfVertex;
2898     resultMap[i] = mapElement;
2899   }
2900   return resultMap._retn();
2901 }
2902
2903 /**
2904  * Erase all enforced vertices
2905  */
2906 void BLSURFPlugin_Hypothesis_i::ClearAllEnforcedVertices() {
2907   ASSERT(myBaseImpl);
2908   this->GetImpl()->ClearAllEnforcedVertices();
2909   SMESH::TPythonDump() << _this() << ".ClearAllEnforcedVertices()";
2910 }
2911
2912 /*!
2913  * Set/get/unset an enforced vertex on face - OBSOLETE
2914  */
2915 bool BLSURFPlugin_Hypothesis_i::SetEnforcedVertex(GEOM::GEOM_Object_ptr theFace, CORBA::Double x, CORBA::Double y,
2916                                                   CORBA::Double z) {
2917   ASSERT(myBaseImpl);
2918
2919   if ((theFace->GetShapeType() != GEOM::FACE) && (theFace->GetShapeType() != GEOM::COMPOUND)) {
2920     THROW_SALOME_CORBA_EXCEPTION("theFace shape type is not FACE or COMPOUND", SALOME::BAD_PARAM);
2921   }
2922
2923   string theFaceEntry = theFace->GetStudyEntry();
2924   
2925   if (theFaceEntry.empty()) {
2926     GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine( theFace );
2927     string aName;
2928     if (theFace->GetShapeType() == GEOM::FACE)
2929       aName = "Face_";
2930     if (theFace->GetShapeType() == GEOM::COMPOUND)
2931       aName = "Compound_";
2932     aName += theFace->GetEntry();
2933     SALOMEDS::SObject_wrap theSFace = geomGen->PublishInStudy(NULL, theFace, aName.c_str());
2934     if (!theSFace->_is_nil())
2935       theFaceEntry = theSFace->GetID();
2936   }
2937   if (theFaceEntry.empty())
2938     THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM );
2939   try {
2940     return SetEnforcedVertexEntry(theFaceEntry.c_str(), x, y, z);
2941   } catch (SALOME_Exception& ex) {
2942     THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
2943   }
2944 }
2945
2946 /*!
2947  * Set/get/unset an enforced vertex with name on face
2948  */
2949 bool BLSURFPlugin_Hypothesis_i::SetEnforcedVertexNamed(GEOM::GEOM_Object_ptr theFace, CORBA::Double x, CORBA::Double y,
2950                                                        CORBA::Double z, const char* theVertexName) {
2951   ASSERT(myBaseImpl);
2952
2953   if ((theFace->GetShapeType() != GEOM::FACE) && (theFace->GetShapeType() != GEOM::COMPOUND)) {
2954     THROW_SALOME_CORBA_EXCEPTION("theFace shape type is not FACE or COMPOUND", SALOME::BAD_PARAM);
2955   }
2956
2957   string theFaceEntry = theFace->GetStudyEntry();
2958   
2959   if (theFaceEntry.empty()) {
2960     GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine( theFace );
2961     string aName;
2962     if (theFace->GetShapeType() == GEOM::FACE)
2963       aName = "Face_";
2964     if (theFace->GetShapeType() == GEOM::COMPOUND)
2965       aName = "Compound_";
2966     aName += theFace->GetEntry();
2967     SALOMEDS::SObject_wrap theSFace = geomGen->PublishInStudy(NULL, theFace, aName.c_str());
2968     if (!theSFace->_is_nil())
2969       theFaceEntry = theSFace->GetID();
2970   }
2971   if (theFaceEntry.empty())
2972     THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM );
2973   
2974   try {
2975     return SetEnforcedVertexEntry(theFaceEntry.c_str(), x, y, z, theVertexName);
2976   } catch (SALOME_Exception& ex) {
2977     THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
2978   }
2979 }
2980
2981 /*!
2982  * Set/get/unset an enforced vertex with geom object on face
2983  */
2984 bool BLSURFPlugin_Hypothesis_i::SetEnforcedVertexGeom(GEOM::GEOM_Object_ptr theFace, GEOM::GEOM_Object_ptr theVertex)
2985 {
2986   ASSERT(myBaseImpl);
2987
2988   if ((theFace->GetShapeType() != GEOM::FACE) && (theFace->GetShapeType() != GEOM::COMPOUND)) {
2989     THROW_SALOME_CORBA_EXCEPTION("theFace shape type is not FACE or COMPOUND", SALOME::BAD_PARAM);
2990   }
2991
2992   if ((theVertex->GetShapeType() != GEOM::VERTEX) && (theVertex->GetShapeType() != GEOM::COMPOUND)) {
2993     THROW_SALOME_CORBA_EXCEPTION("theVertex shape type is not VERTEX or COMPOUND", SALOME::BAD_PARAM);
2994   }
2995
2996   //  GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine( theFace );
2997   //  GEOM::GEOM_IMeasureOperations_var measureOp = geomGen->GetIMeasureOperations();
2998   //  if (CORBA::is_nil(measureOp))
2999   //    return false;
3000   //
3001   //  CORBA::Double x, y, z;
3002   //  x = y = z = 0.;
3003   //  measureOp->PointCoordinates(theVertex, x, y, z);
3004
3005   string theFaceEntry = theFace->GetStudyEntry();
3006   string theVertexEntry = theVertex->GetStudyEntry();
3007   
3008   GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine( theFace );
3009   string aName;
3010   
3011   if (theFaceEntry.empty()) {
3012     if (theFace->GetShapeType() == GEOM::FACE)
3013       aName = "Face_";
3014     if (theFace->GetShapeType() == GEOM::COMPOUND)
3015       aName = "Compound_";
3016     aName += theFace->GetEntry();
3017     SALOMEDS::SObject_wrap theSFace = geomGen->PublishInStudy(NULL, theFace, aName.c_str());
3018     if (!theSFace->_is_nil())
3019       theFaceEntry = theSFace->GetID();
3020   }
3021   if (theFaceEntry.empty())
3022     THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM );
3023   
3024   if (theVertexEntry.empty()) {
3025     if (theVertex->GetShapeType() == GEOM::VERTEX)
3026       aName = "Vertex_";
3027     if (theVertex->GetShapeType() == GEOM::COMPOUND)
3028       aName = "Compound_";
3029     aName += theVertex->GetEntry();
3030     SALOMEDS::SObject_wrap theSVertex = geomGen->PublishInStudy(NULL, theVertex, aName.c_str());
3031     if (!theSVertex->_is_nil())
3032       theVertexEntry = theSVertex->GetID();
3033   }
3034   if (theVertexEntry.empty())
3035     THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM );
3036
3037   string theVertexName = theVertex->GetName();
3038   try {
3039     return SetEnforcedVertexEntry(theFaceEntry.c_str(), 0, 0, 0, theVertexName.c_str(), theVertexEntry.c_str());
3040   } catch (SALOME_Exception& ex) {
3041     THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
3042   }
3043 }
3044
3045 /*!
3046  * Set an enforced vertex with group name on face
3047  */
3048 bool BLSURFPlugin_Hypothesis_i::SetEnforcedVertexWithGroup(GEOM::GEOM_Object_ptr theFace, CORBA::Double x, CORBA::Double y, CORBA::Double z, const char* theGroupName)
3049 {
3050   ASSERT(myBaseImpl);
3051
3052   if ((theFace->GetShapeType() != GEOM::FACE) && (theFace->GetShapeType() != GEOM::COMPOUND)) {
3053     THROW_SALOME_CORBA_EXCEPTION("theFace shape type is not FACE or COMPOUND", SALOME::BAD_PARAM);
3054   }
3055
3056   string theFaceEntry = theFace->GetStudyEntry();
3057   
3058   if (theFaceEntry.empty()) {
3059     GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine( theFace );
3060     string aName;
3061     if (theFace->GetShapeType() == GEOM::FACE)
3062       aName = "Face_";
3063     if (theFace->GetShapeType() == GEOM::COMPOUND)
3064       aName = "Compound_";
3065     aName += theFace->GetEntry();
3066     SALOMEDS::SObject_wrap theSFace = geomGen->PublishInStudy(NULL, theFace, aName.c_str());
3067     if (!theSFace->_is_nil())
3068       theFaceEntry = theSFace->GetID();
3069   }
3070   if (theFaceEntry.empty())
3071     THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM );
3072   try {
3073     return SetEnforcedVertexEntry(theFaceEntry.c_str(), x, y, z, "", "", theGroupName);
3074   } catch (SALOME_Exception& ex) {
3075     THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
3076   }
3077 }
3078
3079 /*!
3080  * Set an enforced vertex with name and group name on face
3081  */
3082 bool BLSURFPlugin_Hypothesis_i::SetEnforcedVertexNamedWithGroup(GEOM::GEOM_Object_ptr theFace, CORBA::Double x, CORBA::Double y, CORBA::Double z, 
3083                                                                 const char* theVertexName, const char* theGroupName)
3084 {
3085   ASSERT(myBaseImpl);
3086
3087   if ((theFace->GetShapeType() != GEOM::FACE) && (theFace->GetShapeType() != GEOM::COMPOUND)) {
3088     THROW_SALOME_CORBA_EXCEPTION("theFace shape type is not FACE or COMPOUND", SALOME::BAD_PARAM);
3089   }
3090
3091   string theFaceEntry = theFace->GetStudyEntry();
3092   
3093   if (theFaceEntry.empty()) {
3094     GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine( theFace );
3095     string aName;
3096     if (theFace->GetShapeType() == GEOM::FACE)
3097       aName = "Face_";
3098     if (theFace->GetShapeType() == GEOM::COMPOUND)
3099       aName = "Compound_";
3100     aName += theFace->GetEntry();
3101     SALOMEDS::SObject_wrap theSFace = geomGen->PublishInStudy(NULL, theFace, aName.c_str());
3102     if (!theSFace->_is_nil())
3103       theFaceEntry = theSFace->GetID();
3104   }
3105   if (theFaceEntry.empty())
3106     THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM );
3107   try {
3108     return SetEnforcedVertexEntry(theFaceEntry.c_str(), x, y, z, theVertexName, "", theGroupName);
3109   } catch (SALOME_Exception& ex) {
3110     THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
3111   }
3112 }
3113
3114 /*!
3115  * Set an enforced vertex with geom entry and group name on face
3116  */
3117 bool BLSURFPlugin_Hypothesis_i::SetEnforcedVertexGeomWithGroup(GEOM::GEOM_Object_ptr theFace, GEOM::GEOM_Object_ptr theVertex, const char* theGroupName)
3118 {
3119   ASSERT(myBaseImpl);
3120
3121   if ((theFace->GetShapeType() != GEOM::FACE) && (theFace->GetShapeType() != GEOM::COMPOUND)) {
3122     THROW_SALOME_CORBA_EXCEPTION("theFace shape type is not FACE or COMPOUND", SALOME::BAD_PARAM);
3123   }
3124
3125   if ((theVertex->GetShapeType() != GEOM::VERTEX) && (theVertex->GetShapeType() != GEOM::COMPOUND)) {
3126     THROW_SALOME_CORBA_EXCEPTION("theVertex shape type is not VERTEX or COMPOUND", SALOME::BAD_PARAM);
3127   }
3128
3129   string theFaceEntry = theFace->GetStudyEntry();
3130   string theVertexEntry = theVertex->GetStudyEntry();
3131   
3132   GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine( theFace );
3133   string aName;
3134   
3135   if (theFaceEntry.empty()) {
3136     if (theFace->GetShapeType() == GEOM::FACE)
3137       aName = "Face_";
3138     if (theFace->GetShapeType() == GEOM::COMPOUND)
3139       aName = "Compound_";
3140     aName += theFace->GetEntry();
3141     SALOMEDS::SObject_wrap theSFace = geomGen->PublishInStudy(NULL, theFace, aName.c_str());
3142     if (!theSFace->_is_nil())
3143       theFaceEntry = theSFace->GetID();
3144   }
3145   if (theFaceEntry.empty())
3146     THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM );
3147   
3148   if (theVertexEntry.empty()) {
3149     if (theVertex->GetShapeType() == GEOM::VERTEX)
3150       aName = "Vertex_";
3151     if (theVertex->GetShapeType() == GEOM::COMPOUND)
3152       aName = "Compound_";
3153     aName += theVertex->GetEntry();
3154     SALOMEDS::SObject_wrap theSVertex = geomGen->PublishInStudy(NULL, theVertex, aName.c_str());
3155     if (!theSVertex->_is_nil())
3156       theVertexEntry = theSVertex->GetID();
3157   }
3158   if (theVertexEntry.empty())
3159     THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM );
3160
3161   string theVertexName = theVertex->GetName();
3162   try {
3163     return SetEnforcedVertexEntry(theFaceEntry.c_str(), 0, 0, 0, theVertexName.c_str(), theVertexEntry.c_str(), theGroupName);
3164   } catch (SALOME_Exception& ex) {
3165     THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
3166   }
3167 }
3168
3169 //Enable internal enforced vertices on specific face if requested by user
3170 ///*!
3171 // * Are internal enforced vertices used for a face ?
3172 // */
3173 //CORBA::Boolean BLSURFPlugin_Hypothesis_i::GetInternalEnforcedVertex(GEOM::GEOM_Object_ptr theFace)
3174 //{
3175 //  ASSERT(myBaseImpl);
3176
3177 //  if ((theFace->GetShapeType() != GEOM::FACE) && (theFace->GetShapeType() != GEOM::COMPOUND)) {
3178 //    THROW_SALOME_CORBA_EXCEPTION("theFace shape type is not FACE or COMPOUND", SALOME::BAD_PARAM);
3179 //  }
3180
3181 //  string theFaceEntry = theFace->GetStudyEntry();
3182   
3183 //  if (theFaceEntry.empty()) {
3184 //    GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine( theFace );
3185 //    string aName;
3186 //    if (theFace->GetShapeType() == GEOM::FACE)
3187 //      aName = "Face_";
3188 //    if (theFace->GetShapeType() == GEOM::COMPOUND)
3189 //      aName = "Compound_";
3190 //    aName += theFace->GetEntry();
3191 //    SALOMEDS::SObject_wrap theSFace = geomGen->PublishInStudy(NULL, theFace, aName.c_str());
3192 //    if (!theSFace->_is_nil())
3193 //      theFaceEntry = theSFace->GetID();
3194 //  }
3195 //  if (theFaceEntry.empty())
3196 //    THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM );
3197
3198 //  try {
3199 //    return GetInternalEnforcedVertexEntry(theFaceEntry.c_str());
3200 //  } catch (SALOME_Exception& ex) {
3201 //    THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
3202 //  }
3203 //}
3204
3205 /*!
3206  * Get the list of all enforced vertices
3207  */
3208 BLSURFPlugin::TEnfVertexList* BLSURFPlugin_Hypothesis_i::GetEnforcedVertices(GEOM::GEOM_Object_ptr theFace)
3209 {
3210   ASSERT(myBaseImpl);
3211
3212   if ((theFace->GetShapeType() != GEOM::FACE) && (theFace->GetShapeType() != GEOM::COMPOUND)) {
3213     THROW_SALOME_CORBA_EXCEPTION("theFace shape type is not FACE or COMPOUND", SALOME::BAD_PARAM);
3214   }
3215
3216   string theFaceEntry = theFace->GetStudyEntry();
3217   
3218   if (theFaceEntry.empty()) {
3219     GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine( theFace );
3220     string aName;
3221     if (theFace->GetShapeType() == GEOM::FACE)
3222       aName = "Face_";
3223     if (theFace->GetShapeType() == GEOM::COMPOUND)
3224       aName = "Compound_";
3225     aName += theFace->GetEntry();
3226     SALOMEDS::SObject_wrap theSFace = geomGen->PublishInStudy(NULL, theFace, aName.c_str());
3227     if (!theSFace->_is_nil())
3228       theFaceEntry = theSFace->GetID();
3229   }
3230   if (theFaceEntry.empty())
3231     THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM );
3232
3233   try {
3234     return GetEnforcedVerticesEntry(theFaceEntry.c_str());
3235   } catch (SALOME_Exception& ex) {
3236     THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
3237   }
3238 }
3239
3240 bool BLSURFPlugin_Hypothesis_i::UnsetEnforcedVertex(GEOM::GEOM_Object_ptr theFace, CORBA::Double x, CORBA::Double y,
3241                                                     CORBA::Double z) {
3242   ASSERT(myBaseImpl);
3243
3244   if ((theFace->GetShapeType() != GEOM::FACE) && (theFace->GetShapeType() != GEOM::COMPOUND)) {
3245     THROW_SALOME_CORBA_EXCEPTION("theFace shape type is not FACE or COMPOUND", SALOME::BAD_PARAM);
3246   }
3247
3248   string theFaceEntry = theFace->GetStudyEntry();
3249   
3250   if (theFaceEntry.empty()) {
3251     GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine( theFace );
3252     string aName;
3253     if (theFace->GetShapeType() == GEOM::FACE)
3254       aName = "Face_";
3255     if (theFace->GetShapeType() == GEOM::COMPOUND)
3256       aName = "Compound_";
3257     aName += theFace->GetEntry();
3258     SALOMEDS::SObject_wrap theSFace = geomGen->PublishInStudy(NULL, theFace, aName.c_str());
3259     if (!theSFace->_is_nil())
3260       theFaceEntry = theSFace->GetID();
3261   }
3262   if (theFaceEntry.empty())
3263     THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM );
3264
3265   try {
3266     return UnsetEnforcedVertexEntry(theFaceEntry.c_str(), x, y, z);
3267   } catch (SALOME_Exception& ex) {
3268     THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
3269   }
3270 }
3271
3272 bool BLSURFPlugin_Hypothesis_i::UnsetEnforcedVertexGeom(GEOM::GEOM_Object_ptr theFace, GEOM::GEOM_Object_ptr theVertex)
3273 {
3274   ASSERT(myBaseImpl);
3275
3276   if ((theFace->GetShapeType() != GEOM::FACE) && (theFace->GetShapeType() != GEOM::COMPOUND)) {
3277     THROW_SALOME_CORBA_EXCEPTION("theFace shape type is not FACE or COMPOUND", SALOME::BAD_PARAM);
3278   }
3279   if ((theVertex->GetShapeType() != GEOM::VERTEX) && (theVertex->GetShapeType() != GEOM::COMPOUND)) {
3280     THROW_SALOME_CORBA_EXCEPTION("theVertex shape type is not VERTEX or COMPOUND", SALOME::BAD_PARAM);
3281   }
3282
3283   //  GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine( theFace );
3284   //  GEOM::GEOM_IMeasureOperations_var measureOp = geomGen->GetIMeasureOperations();
3285   //  if (CORBA::is_nil(measureOp))
3286   //    return false;
3287   //
3288   //  CORBA::Double x, y, z;
3289   //  x = y = z = 0.;
3290   //  measureOp->PointCoordinates(theVertex, x, y, z);
3291
3292   std::string theFaceEntry = theFace->GetStudyEntry();
3293   std::string theVertexEntry = theVertex->GetStudyEntry();
3294   
3295   GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine( theFace );
3296   string aName;
3297   
3298   if (theFaceEntry.empty()) {
3299     if (theFace->GetShapeType() == GEOM::FACE)
3300       aName = "Face_";
3301     if (theFace->GetShapeType() == GEOM::COMPOUND)
3302       aName = "Compound_";
3303     aName += theFace->GetEntry();
3304     SALOMEDS::SObject_wrap theSFace = geomGen->PublishInStudy(NULL, theFace, aName.c_str());
3305     if (!theSFace->_is_nil())
3306       theFaceEntry = theSFace->GetID();
3307   }
3308   if (theFaceEntry.empty())
3309     THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM );
3310   
3311   if (theVertexEntry.empty()) {
3312     if (theVertex->GetShapeType() == GEOM::VERTEX)
3313       aName = "Vertex_";
3314     if (theVertex->GetShapeType() == GEOM::COMPOUND)
3315       aName = "Compound_";
3316     aName += theVertex->GetEntry();
3317     SALOMEDS::SObject_wrap theSVertex = geomGen->PublishInStudy(NULL, theVertex, aName.c_str());
3318     if (!theSVertex->_is_nil())
3319       theVertexEntry = theSVertex->GetID();
3320   }
3321   if (theVertexEntry.empty())
3322     THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM );
3323   
3324
3325   try {
3326     return UnsetEnforcedVertexEntry(theFaceEntry.c_str(), 0, 0, 0, theVertexEntry.c_str());
3327   } catch (SALOME_Exception& ex) {
3328     THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
3329   }
3330 }
3331
3332 bool BLSURFPlugin_Hypothesis_i::UnsetEnforcedVertices(GEOM::GEOM_Object_ptr theFace) {
3333   ASSERT(myBaseImpl);
3334
3335   if ((theFace->GetShapeType() != GEOM::FACE) && (theFace->GetShapeType() != GEOM::COMPOUND)) {
3336     THROW_SALOME_CORBA_EXCEPTION("theFace shape type is not FACE or COMPOUND", SALOME::BAD_PARAM);
3337   }
3338
3339   string theFaceEntry = theFace->GetStudyEntry();
3340   
3341   if (theFaceEntry.empty()) {
3342     GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine( theFace );
3343     string aName;
3344     if (theFace->GetShapeType() == GEOM::FACE)
3345       aName = "Face_";
3346     if (theFace->GetShapeType() == GEOM::COMPOUND)
3347       aName = "Compound_";
3348     aName += theFace->GetEntry();
3349     SALOMEDS::SObject_wrap theSFace = geomGen->PublishInStudy(NULL, theFace, aName.c_str());
3350     if (!theSFace->_is_nil())
3351       theFaceEntry = theSFace->GetID();
3352   }
3353   if (theFaceEntry.empty())
3354     THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM );
3355   
3356
3357   try {
3358     return UnsetEnforcedVerticesEntry(theFaceEntry.c_str());
3359   } catch (SALOME_Exception& ex) {
3360     THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
3361   }
3362 }
3363
3364 /*!
3365  * Set/get/unset an enforced vertex on face - NEW (no face)
3366  */
3367 bool BLSURFPlugin_Hypothesis_i::AddEnforcedVertex(CORBA::Double x, CORBA::Double y, CORBA::Double z)
3368 {
3369   ASSERT(myBaseImpl);
3370
3371   try {
3372     return SetEnforcedVertexEntry("", x, y, z);
3373   } catch (SALOME_Exception& ex) {
3374     THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
3375   }
3376 }
3377
3378 /*!
3379  * Set/get/unset an enforced vertex with name on face
3380  */
3381 bool BLSURFPlugin_Hypothesis_i::AddEnforcedVertexNamed(CORBA::Double x, CORBA::Double y, CORBA::Double z, const char* theVertexName)
3382 {
3383   try {
3384     return SetEnforcedVertexEntry("", x, y, z, theVertexName);
3385   } catch (SALOME_Exception& ex) {
3386     THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
3387   }
3388 }
3389
3390 /*!
3391  * Set/get/unset an enforced vertex with geom object on face
3392  */
3393 bool BLSURFPlugin_Hypothesis_i::AddEnforcedVertexGeom(GEOM::GEOM_Object_ptr theVertex)
3394 {
3395   if ((theVertex->GetShapeType() != GEOM::VERTEX) && (theVertex->GetShapeType() != GEOM::COMPOUND)) {
3396     THROW_SALOME_CORBA_EXCEPTION("theVertex shape type is not VERTEX or COMPOUND", SALOME::BAD_PARAM);
3397   }
3398   string theVertexEntry = theVertex->GetStudyEntry();
3399   
3400   GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine( theVertex );
3401   string aName;
3402   
3403   if (theVertexEntry.empty()) {
3404     if (theVertex->GetShapeType() == GEOM::VERTEX)
3405       aName = "Vertex_";
3406     if (theVertex->GetShapeType() == GEOM::COMPOUND)
3407       aName = "Compound_";
3408     aName += theVertex->GetEntry();
3409     SALOMEDS::SObject_wrap theSVertex = geomGen->PublishInStudy( NULL, theVertex, aName.c_str());
3410     if (!theSVertex->_is_nil())
3411       theVertexEntry = theSVertex->GetID();
3412   }
3413   if (theVertexEntry.empty())
3414     THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM );
3415
3416   string theVertexName = theVertex->GetName();
3417   try {
3418     return SetEnforcedVertexEntry("", 0, 0, 0, theVertexName.c_str(), theVertexEntry.c_str());
3419   } catch (SALOME_Exception& ex) {
3420     THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
3421   }
3422 }
3423
3424 /*!
3425  * Set an enforced vertex with group name on face
3426  */
3427 bool BLSURFPlugin_Hypothesis_i::AddEnforcedVertexWithGroup(CORBA::Double x, CORBA::Double y, CORBA::Double z, const char* theGroupName)
3428 {
3429   ASSERT(myBaseImpl);
3430
3431   try {
3432     return SetEnforcedVertexEntry("", x, y, z, "", "", theGroupName);
3433   } catch (SALOME_Exception& ex) {
3434     THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
3435   }
3436 }
3437
3438 /*!
3439  * Set an enforced vertex with name and group name on face
3440  */
3441 bool BLSURFPlugin_Hypothesis_i::AddEnforcedVertexNamedWithGroup(CORBA::Double x, CORBA::Double y, CORBA::Double z, 
3442                                                                 const char* theVertexName, const char* theGroupName)
3443 {
3444   ASSERT(myBaseImpl);
3445
3446   try {
3447     return SetEnforcedVertexEntry("", x, y, z, theVertexName, "", theGroupName);
3448   } catch (SALOME_Exception& ex) {
3449     THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
3450   }
3451 }
3452
3453 /*!
3454  * Set an enforced vertex with geom entry and group name on face
3455  */
3456 bool BLSURFPlugin_Hypothesis_i::AddEnforcedVertexGeomWithGroup(GEOM::GEOM_Object_ptr theVertex, const char* theGroupName)
3457 {
3458   if ((theVertex->GetShapeType() != GEOM::VERTEX) && (theVertex->GetShapeType() != GEOM::COMPOUND)) {
3459     THROW_SALOME_CORBA_EXCEPTION("theVertex shape type is not VERTEX or COMPOUND", SALOME::BAD_PARAM);
3460   }
3461
3462   string theVertexEntry = theVertex->GetStudyEntry();
3463   
3464   GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine( theVertex );
3465   string aName;
3466   
3467   if (theVertexEntry.empty()) {
3468     if (theVertex->GetShapeType() == GEOM::VERTEX)
3469       aName = "Vertex_";
3470     if (theVertex->GetShapeType() == GEOM::COMPOUND)
3471       aName = "Compound_";
3472     aName += theVertex->GetEntry();
3473     SALOMEDS::SObject_wrap theSVertex = geomGen->PublishInStudy( NULL, theVertex, aName.c_str());
3474     if (!theSVertex->_is_nil())
3475       theVertexEntry = theSVertex->GetID();
3476   }
3477   if (theVertexEntry.empty())
3478     THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM );
3479
3480   string theVertexName = theVertex->GetName();
3481   try {
3482     return SetEnforcedVertexEntry("", 0, 0, 0, theVertexName.c_str(), theVertexEntry.c_str(), theGroupName);
3483   } catch (SALOME_Exception& ex) {
3484     THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
3485   }
3486 }
3487
3488 bool BLSURFPlugin_Hypothesis_i::RemoveEnforcedVertex(CORBA::Double x, CORBA::Double y, CORBA::Double z)
3489 {
3490   try {
3491     return UnsetEnforcedVertexEntry("", x, y, z);
3492   } catch (SALOME_Exception& ex) {
3493     THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
3494   }
3495 }
3496
3497 bool BLSURFPlugin_Hypothesis_i::RemoveEnforcedVertexGeom(GEOM::GEOM_Object_ptr theVertex)
3498 {
3499   if ((theVertex->GetShapeType() != GEOM::VERTEX) && (theVertex->GetShapeType() != GEOM::COMPOUND)) {
3500     THROW_SALOME_CORBA_EXCEPTION("theVertex shape type is not VERTEX or COMPOUND", SALOME::BAD_PARAM);
3501   }
3502   std::string theVertexEntry = theVertex->GetStudyEntry();
3503   
3504   GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine( theVertex );
3505   string aName;
3506   
3507   if (theVertexEntry.empty()) {
3508     if (theVertex->GetShapeType() == GEOM::VERTEX)
3509       aName = "Vertex_";
3510     if (theVertex->GetShapeType() == GEOM::COMPOUND)
3511       aName = "Compound_";
3512     aName += theVertex->GetEntry();
3513     SALOMEDS::SObject_wrap theSVertex = geomGen->PublishInStudy( NULL, theVertex, aName.c_str());
3514     if (!theSVertex->_is_nil())
3515       theVertexEntry = theSVertex->GetID();
3516   }
3517   if (theVertexEntry.empty())
3518     THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM );
3519   
3520   try {
3521     return UnsetEnforcedVertexEntry("", 0, 0, 0, theVertexEntry.c_str());
3522   } catch (SALOME_Exception& ex) {
3523     THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
3524   }
3525 }
3526
3527 bool BLSURFPlugin_Hypothesis_i::RemoveEnforcedVertices()
3528 {
3529   try {
3530     return UnsetEnforcedVerticesEntry("");
3531   } catch (SALOME_Exception& ex) {
3532     THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
3533   }
3534 }
3535
3536 /*!
3537  * Set/get/unset an enforced vertex on geom object given by entry
3538  */
3539 bool BLSURFPlugin_Hypothesis_i::SetEnforcedVertexEntry(const char* theFaceEntry,
3540                                                        CORBA::Double x,
3541                                                        CORBA::Double y,
3542                                                        CORBA::Double z,
3543                                                        const char* theVertexName,
3544                                                        const char* theVertexEntry,
3545                                                        const char* theGroupName)
3546 {
3547   bool newValue = false;
3548   if (string(theVertexEntry).empty()) {
3549     try {
3550       ::BLSURFPlugin_Hypothesis::TEnfVertexCoordsList coordsList =
3551         this->GetImpl()->GetEnfVertexCoordsList(theFaceEntry);
3552       ::BLSURFPlugin_Hypothesis::TEnfVertexCoords coords;
3553       coords.push_back(x);
3554       coords.push_back(y);
3555       coords.push_back(z);
3556       if (coordsList.find(coords) == coordsList.end()) {
3557         newValue = true;
3558       } else {
3559         ::BLSURFPlugin_Hypothesis::TEnfVertex *enfVertex = this->GetImpl()->GetEnfVertex(coords);
3560         if ((enfVertex->name != theVertexName) || (enfVertex->grpName != theGroupName)) {
3561           newValue = true;
3562         }
3563       }
3564     } catch (const std::invalid_argument& ex) {
3565       // no enforced vertex for entry
3566       newValue = true;
3567     }
3568     if (newValue) {
3569       if (string(theVertexName).empty()) {
3570         if (string(theGroupName).empty())
3571           SMESH::TPythonDump() << _this() << ".AddEnforcedVertex(" << x << ", " << y << ", " << z << ")";
3572         else
3573           SMESH::TPythonDump() << _this() << ".AddEnforcedVertexWithGroup(" << x << ", " << y << ", " << z << ", \"" << theGroupName << "\")";
3574       }
3575       else {
3576         if (string(theGroupName).empty())
3577           SMESH::TPythonDump() << _this() << ".AddEnforcedVertexNamed(" << x << ", " << y << ", " << z << ", \"" << theVertexName << "\")";
3578         else
3579           SMESH::TPythonDump() << _this() << ".AddEnforcedVertexNamedWithGroup(" << x << ", " << y << ", " << z << ", \""
3580                                << theVertexName << "\", \"" << theGroupName << "\")";
3581       }
3582     }
3583   } else {
3584     try {
3585       ::BLSURFPlugin_Hypothesis::TEntryList enfVertexEntryList = this->GetImpl()->GetEnfVertexEntryList(theFaceEntry);
3586       ::BLSURFPlugin_Hypothesis::TEntryList::const_iterator it = enfVertexEntryList.find(theVertexEntry);
3587       if ( it == enfVertexEntryList.end()) {
3588         newValue = true;
3589       }
3590       else {
3591         ::BLSURFPlugin_Hypothesis::TEnfVertex *enfVertex = this->GetImpl()->GetEnfVertex((*it));
3592         if ((enfVertex->name != theVertexName) || (enfVertex->grpName != theGroupName)) {
3593           newValue = true;
3594         }
3595       }
3596     } catch (const std::invalid_argument& ex) {
3597       // no enforced vertex for entry
3598       newValue = true;
3599     }
3600     if (newValue) {
3601       if (string(theGroupName).empty())
3602         SMESH::TPythonDump() << _this() << ".AddEnforcedVertexGeom(" << theVertexEntry << ")";
3603       else
3604         SMESH::TPythonDump() << _this() << ".AddEnforcedVertexGeomWithGroup(" << theVertexEntry << ", \"" << theGroupName << "\")";
3605     }
3606   }
3607
3608   if (newValue)
3609     this->GetImpl()->SetEnforcedVertex(theFaceEntry, theVertexName, theVertexEntry, theGroupName, x, y, z);
3610
3611   return newValue;
3612 }
3613
3614 BLSURFPlugin::TEnfVertexList* BLSURFPlugin_Hypothesis_i::GetEnforcedVerticesEntry(const char* entry)
3615 {
3616   try {
3617     BLSURFPlugin::TEnfVertexList_var vertexList = new BLSURFPlugin::TEnfVertexList();
3618     ::BLSURFPlugin_Hypothesis::TEnfVertexList _vList = this->GetImpl()->GetEnfVertexList(entry);
3619     vertexList->length((CORBA::ULong) _vList.size());
3620     ::BLSURFPlugin_Hypothesis::TEnfVertexList::const_iterator evlIt = _vList.begin();
3621     for (int i = 0; evlIt != _vList.end(); ++evlIt, ++i) {
3622       ::BLSURFPlugin_Hypothesis::TEnfVertex *_enfVertex = (*evlIt);
3623
3624       BLSURFPlugin::TEnfVertex_var enfVertex = new BLSURFPlugin::TEnfVertex();
3625
3626       // Name
3627       enfVertex->name = CORBA::string_dup(_enfVertex->name.c_str());
3628       // Geom Vertex Entry
3629       enfVertex->geomEntry = CORBA::string_dup(_enfVertex->geomEntry.c_str());
3630       // Coords
3631       BLSURFPlugin::TEnfVertexCoords_var coords = new BLSURFPlugin::TEnfVertexCoords();
3632       coords->length((CORBA::ULong) _enfVertex->coords.size());
3633       for ( CORBA::ULong ind = 0; ind < coords->length(); ind++ )
3634         coords[ind] = _enfVertex->coords[ind];
3635       enfVertex->coords = coords;
3636       // Group Name
3637       enfVertex->grpName = CORBA::string_dup(_enfVertex->grpName.c_str());
3638       // Face entry list
3639       BLSURFPlugin::TEntryList_var faceEntryList = new BLSURFPlugin::TEntryList();
3640       faceEntryList->length((CORBA::ULong) _enfVertex->faceEntries.size());
3641       ::BLSURFPlugin_Hypothesis::TEntryList::const_iterator it_entry = _enfVertex->faceEntries.begin();
3642       for (int ind = 0; it_entry != _enfVertex->faceEntries.end();++it_entry, ++ind)
3643         faceEntryList[ind] = CORBA::string_dup((*it_entry).c_str());
3644       enfVertex->faceEntries = faceEntryList;
3645
3646       vertexList[i] = enfVertex;
3647     }
3648     return vertexList._retn();
3649   } catch (const std::invalid_argument& ex) {
3650     SALOME::ExceptionStruct ExDescription;
3651     ExDescription.text = ex.what();
3652     ExDescription.type = SALOME::BAD_PARAM;
3653     ExDescription.sourceFile = "BLSURFPlugin_Hypothesis_i::GetEnforcedVerticesEntry(entry)";
3654     ExDescription.lineNumber = 1385;
3655     throw SALOME::SALOME_Exception(ExDescription);
3656   } catch (const std::exception& ex) {
3657     std::cout << "Exception: " << ex.what() << std::endl;
3658     THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
3659   }
3660 }
3661
3662 bool BLSURFPlugin_Hypothesis_i::UnsetEnforcedVertexEntry(const char* theFaceEntry, CORBA::Double x, CORBA::Double y, CORBA::Double z, const char* theVertexEntry)
3663 {
3664   ASSERT(myBaseImpl);
3665
3666   bool res = false;
3667   try {
3668     res = this->GetImpl()->ClearEnforcedVertex(theFaceEntry, x, y, z, theVertexEntry);
3669
3670     if (string(theVertexEntry).empty())
3671       SMESH::TPythonDump() << "isDone = " << _this() << ".RemoveEnforcedVertex(" << x << ", " << y << ", " << z
3672                            << ")";
3673     else
3674       SMESH::TPythonDump() << "isDone = " << _this() << ".RemoveEnforcedVertexGeom(" << theVertexEntry << ")";
3675
3676   } catch (const std::invalid_argument& ex) {
3677     return false;
3678   } catch (const std::exception& ex) {
3679     std::cout << "Exception: " << ex.what() << std::endl;
3680     THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
3681   }
3682
3683   return res;
3684 }
3685 bool BLSURFPlugin_Hypothesis_i::UnsetEnforcedVerticesEntry(const char* theFaceEntry)
3686 {
3687   ASSERT(myBaseImpl);
3688
3689   try {
3690     this->GetImpl()->ClearEnforcedVertices(theFaceEntry);
3691     SMESH::TPythonDump() << _this() << ".RemoveEnforcedVertices()";
3692   } catch (const std::invalid_argument& ex) {
3693     return false;
3694   } catch (const std::exception& ex) {
3695     THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
3696   }
3697
3698   return true;
3699 }
3700
3701 //=============================================================================
3702 /*!
3703  *  BLSURFPlugin_Hypothesis_i::SetInternalEnforcedVertexAllFaces
3704  *
3705  *  Set true or false
3706  */
3707 //=============================================================================
3708 void BLSURFPlugin_Hypothesis_i::SetInternalEnforcedVertexAllFaces(CORBA::Boolean theValue)
3709 {
3710   ASSERT(myBaseImpl);
3711   this->GetImpl()->SetInternalEnforcedVertexAllFaces(theValue);
3712   std::string theValueStr = theValue ? "True" : "False";
3713   SMESH::TPythonDump() << _this() << ".SetInternalEnforcedVertexAllFaces( " << theValueStr.c_str() << " )";
3714 }
3715
3716 //=============================================================================
3717 /*!
3718  *  BLSURFPlugin_Hypothesis_i::GetInternalEnforcedVertexAllFaces
3719  *
3720  *  Get true or false
3721  */
3722 //=============================================================================
3723 CORBA::Boolean BLSURFPlugin_Hypothesis_i::GetInternalEnforcedVertexAllFaces()
3724 {
3725   ASSERT(myBaseImpl);
3726   return this->GetImpl()->_GetInternalEnforcedVertexAllFaces();
3727 }
3728
3729 //=============================================================================
3730 /*!
3731  *  BLSURFPlugin_Hypothesis_i::SetInternalEnforcedVertexAllFacesGroup
3732  *
3733  *  Set group name
3734  */
3735 //=============================================================================
3736 void BLSURFPlugin_Hypothesis_i::SetInternalEnforcedVertexAllFacesGroup(const char*  groupName)
3737 {
3738   ASSERT(myBaseImpl);
3739   this->GetImpl()->SetInternalEnforcedVertexAllFacesGroup(groupName);
3740   SMESH::TPythonDump() << _this() << ".SetInternalEnforcedVertexAllFacesGroup( \"" << groupName << "\" )";
3741 }
3742
3743 //=============================================================================
3744 /*!
3745  *  BLSURFPlugin_Hypothesis_i::GetInternalEnforcedVertexAllFacesGroup
3746  *
3747  *  Get group name
3748  */
3749 //=============================================================================
3750 char* BLSURFPlugin_Hypothesis_i::GetInternalEnforcedVertexAllFacesGroup()
3751 {
3752   ASSERT(myBaseImpl);
3753   return CORBA::string_dup(this->GetImpl()->_GetInternalEnforcedVertexAllFacesGroup().c_str());
3754 }
3755
3756 /*
3757  * Enable internal enforced vertices on specific face if requested by user
3758  *
3759  void BLSURFPlugin_Hypothesis_i::SetInternalEnforcedVertex(GEOM::GEOM_Object_ptr theFace, CORBA::Boolean toEnforceInternalVertices)
3760  {
3761  try {
3762  SetInternalEnforcedVertexWithGroup(theFace, toEnforceInternalVertices);
3763  } catch (SALOME_Exception& ex) {
3764  THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
3765  }
3766  }
3767
3768  void BLSURFPlugin_Hypothesis_i::SetInternalEnforcedVertexWithGroup(GEOM::GEOM_Object_ptr theFace, CORBA::Boolean toEnforceInternalVertices, const char* theGroupName)
3769  {
3770  if ((theFace->GetShapeType() != GEOM::FACE) && (theFace->GetShapeType() != GEOM::COMPOUND)) {
3771  THROW_SALOME_CORBA_EXCEPTION("theFace shape type is not FACE or COMPOUND", SALOME::BAD_PARAM);
3772  }
3773
3774  string theFaceEntry = theFace->GetStudyEntry();
3775
3776  if (theFaceEntry.empty()) {
3777  GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine( theFace );
3778  SMESH_Gen_i *smeshGen = SMESH_Gen_i::GetSMESHGen();
3779  string aName;
3780  if (theFace->GetShapeType() == GEOM::FACE)
3781  aName = "Face_";
3782  if (theFace->GetShapeType() == GEOM::COMPOUND)
3783  aName = "Compound_";
3784  aName += theFace->GetEntry();
3785  SALOMEDS::SObject_wrap theSFace = geomGen->PublishInStudy(NULL, theFace, aName.c_str());
3786  if (!theSFace->_is_nil())
3787  theFaceEntry = theSFace->GetID();
3788  }
3789  if (theFaceEntry.empty())
3790  THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM );
3791
3792  try {
3793  SetInternalEnforcedVertexEntry(theFaceEntry.c_str(), toEnforceInternalVertices, theGroupName);
3794  } catch (SALOME_Exception& ex) {
3795  THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
3796  }
3797  }
3798
3799  void BLSURFPlugin_Hypothesis_i::SetInternalEnforcedVertexEntry(const char* theFaceEntry, CORBA::Boolean toEnforceInternalVertices, const char* theGroupName)
3800  {
3801  ASSERT(myBaseImpl);
3802  try {
3803  this->GetImpl()->SetInternalEnforcedVertex(theFaceEntry, toEnforceInternalVertices, theGroupName);
3804  std::string theValueStr = toEnforceInternalVertices ? "True" : "False";
3805  if (string(theGroupName).empty())
3806  SMESH::TPythonDump() << _this() << ".SetInternalEnforcedVertex( " << theFaceEntry << ", " << theValueStr.c_str() << " )";
3807  else
3808  SMESH::TPythonDump() << _this() << ".SetInternalEnforcedVertexWithGroup( " << theFaceEntry << ", " << theValueStr.c_str() << ", \"" << theGroupName << "\" )";
3809  } catch (const std::exception& ex) {
3810  std::cout << "Exception: " << ex.what() << std::endl;
3811  THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
3812  }
3813  }
3814
3815 */
3816
3817 /* TODO GROUPS
3818    char* BLSURFPlugin_Hypothesis_i::GetEnforcedVertexGroupName(CORBA::Double x, CORBA::Double y, CORBA::Double z)
3819    
3820    {
3821    ASSERT(myBaseImpl);
3822    try {
3823    return CORBA::string_dup( this->GetImpl()->GetEnforcedVertexGroupName(x, y, z).c_str());
3824    }
3825    catch (const std::invalid_argument& ex) {
3826    SALOME::ExceptionStruct ExDescription;
3827    ExDescription.text = ex.what();
3828    ExDescription.type = SALOME::BAD_PARAM;
3829    ExDescription.sourceFile = "BLSURFPlugin_Hypothesis_i::GetEnforcedVertexGroupName(entry)";
3830    ExDescription.lineNumber = 1146;
3831    throw SALOME::SALOME_Exception(ExDescription);
3832    }
3833    catch (SALOME_Exception& ex) {
3834    THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
3835    }
3836    return 0;
3837    }
3838
3839
3840    void BLSURFPlugin_Hypothesis_i::SetEnforcedVertexGroupName(CORBA::Double x, CORBA::Double y, CORBA::Double z, const char* groupName)
3841    {
3842    ASSERT(myBaseImpl);
3843    try {
3844    this->GetImpl()->SetEnforcedVertexGroupName(x, y, z, groupName);
3845    }
3846    catch (const std::invalid_argument& ex) {
3847    SALOME::ExceptionStruct ExDescription;
3848    ExDescription.text = ex.what();
3849    ExDescription.type = SALOME::BAD_PARAM;
3850    ExDescription.sourceFile = "BLSURFPlugin_Hypothesis::SetEnforcedVertexGroupName(x,y,z)";
3851    ExDescription.lineNumber = 1170;
3852    throw SALOME::SALOME_Exception(ExDescription);
3853    }
3854    catch (SALOME_Exception& ex) {
3855    THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
3856    }
3857
3858    SMESH::TPythonDump() << _this() << ".SetEnforcedVertexGroupName("
3859    << x << ", " << y << ", " << z << ", '" << groupName << "' )";
3860
3861    }
3862 */
3863 ///////////////////////
3864
3865 ///////////////////////
3866 // PERIODICITY       //
3867 ///////////////////////
3868
3869
3870 std::string BLSURFPlugin_Hypothesis_i::ShapeTypeToString(GEOM::shape_type theShapeType)
3871 {
3872   std::map<GEOM::shape_type, std::string> MapShapeTypeToString;
3873   MapShapeTypeToString[GEOM::COMPOUND] = std::string("COMPOUND");
3874   MapShapeTypeToString[GEOM::COMPSOLID] = std::string("COMPSOLID");
3875   MapShapeTypeToString[GEOM::SOLID] = std::string("SOLID");
3876   MapShapeTypeToString[GEOM::SHELL] = std::string("SHELL");
3877   MapShapeTypeToString[GEOM::FACE] = std::string("FACE");
3878   MapShapeTypeToString[GEOM::WIRE] = std::string("WIRE");
3879   MapShapeTypeToString[GEOM::EDGE] = std::string("EDGE");
3880   MapShapeTypeToString[GEOM::VERTEX] = std::string("VERTEX");
3881   MapShapeTypeToString[GEOM::SHAPE] = std::string("SHAPE");
3882   std::string txtShapeType = MapShapeTypeToString[theShapeType];
3883   return txtShapeType;
3884 }
3885
3886 void BLSURFPlugin_Hypothesis_i::CheckShapeTypes(GEOM::GEOM_Object_ptr shape, std::vector<GEOM::shape_type> theShapeTypes)
3887 {
3888   // Check shape types
3889   bool ok = false;
3890   std::stringstream typesTxt;
3891   for (std::size_t i=0; i<theShapeTypes.size(); i++)
3892   {
3893     GEOM::shape_type theShapeType = theShapeTypes[i];
3894     if (shape->GetShapeType() == theShapeType)
3895       ok = true;
3896     typesTxt << ShapeTypeToString(theShapeType);
3897     if (i < theShapeTypes.size()-1 )
3898       typesTxt << ", ";
3899   }
3900   if (!ok)
3901   {
3902     std::stringstream msg;
3903     msg << "shape type is not in" << typesTxt.str();
3904     THROW_SALOME_CORBA_EXCEPTION(msg.str().c_str(), SALOME::BAD_PARAM);
3905   }
3906 }
3907
3908 void BLSURFPlugin_Hypothesis_i::CheckShapeType(GEOM::GEOM_Object_ptr shape, GEOM::shape_type theShapeType)
3909 {
3910   // Check shape type
3911   if (shape->GetShapeType() != theShapeType) {
3912     std::stringstream msg;
3913     msg << "shape shape type is not " << ShapeTypeToString(theShapeType);
3914     THROW_SALOME_CORBA_EXCEPTION(msg.str().c_str(), SALOME::BAD_PARAM);
3915   }
3916 }
3917
3918 std::string BLSURFPlugin_Hypothesis_i::PublishIfNeeded(GEOM::GEOM_Object_ptr shape, GEOM::shape_type theShapeType, std::string prefix)
3919 {
3920   // Check shape is published in the object browser
3921   string shapeEntry = shape->GetStudyEntry();
3922
3923   GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine( shape );
3924   string aName;
3925
3926   // Publish shape if needed
3927   if (shapeEntry.empty()) {
3928     if (shape->GetShapeType() == theShapeType)
3929       aName = prefix;
3930     aName += shape->GetEntry();
3931     SALOMEDS::SObject_wrap theSFace1 = geomGen->PublishInStudy(NULL, shape, aName.c_str());
3932     if (!theSFace1->_is_nil())
3933       shapeEntry = theSFace1->GetID();
3934   }
3935   if (shapeEntry.empty())
3936     THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM );
3937   return shapeEntry;
3938 }
3939
3940 // Format the output of two vectors to use it in MESSAGE and PythonDump
3941 std::string BLSURFPlugin_Hypothesis_i::FormatVerticesEntries(vector<string> &theSourceVerticesEntries, vector<string> &theTargetVerticesEntries)
3942 {
3943   std::stringstream listEntriesTxt;
3944
3945   if (!theSourceVerticesEntries.empty())
3946   {
3947     listEntriesTxt << ", [" ;
3948     size_t i =0;
3949     for (std::vector<std::string>::const_iterator it = theSourceVerticesEntries.begin(); it != theSourceVerticesEntries.end(); it++, i++)
3950     {
3951       if (i>0)
3952         listEntriesTxt << ", ";
3953       listEntriesTxt << *it;
3954     }
3955
3956     listEntriesTxt << "], [" ;
3957     i =0;
3958     for (std::vector<std::string>::const_iterator it = theTargetVerticesEntries.begin(); it != theTargetVerticesEntries.end(); it++, i++)
3959     {
3960       if (i>0)
3961         listEntriesTxt << ", ";
3962       listEntriesTxt << *it;
3963     }
3964     listEntriesTxt << "]" ;
3965   }
3966   return listEntriesTxt.str();
3967 }
3968
3969 /**
3970  * Erase all PreCad periodicity associations
3971  */
3972 void BLSURFPlugin_Hypothesis_i::ClearPreCadPeriodicityVectors() {
3973   ASSERT(myBaseImpl);
3974   this->GetImpl()->ClearPreCadPeriodicityVectors();
3975   SMESH::TPythonDump() << _this() << ".ClearPreCadPeriodicityVectors()";
3976 }
3977
3978 BLSURFPlugin::TPeriodicityList* BLSURFPlugin_Hypothesis_i::GetPreCadFacesPeriodicityVector()
3979 {
3980   const ::BLSURFPlugin_Hypothesis::TPreCadPeriodicityVector preCadPeriodicityVector =
3981     this->GetImpl()->_GetPreCadFacesPeriodicityVector();
3982
3983   BLSURFPlugin::TPeriodicityList_var periodicityList = PreCadVectorToSequence(preCadPeriodicityVector);
3984
3985   return periodicityList._retn();
3986 }
3987
3988 BLSURFPlugin::TPeriodicityList* BLSURFPlugin_Hypothesis_i::GetPreCadEdgesPeriodicityVector()
3989 {
3990   const ::BLSURFPlugin_Hypothesis::TPreCadPeriodicityVector preCadPeriodicityVector =
3991     this->GetImpl()->_GetPreCadEdgesPeriodicityVector();
3992
3993   BLSURFPlugin::TPeriodicityList_var periodicityList = PreCadVectorToSequence(preCadPeriodicityVector);
3994
3995   return periodicityList._retn();
3996 }
3997
3998 // convert a vector preCadPeriodicityVector into TPeriodicityList Corba sequence
3999 BLSURFPlugin::TPeriodicityList* BLSURFPlugin_Hypothesis_i::PreCadVectorToSequence(const ::BLSURFPlugin_Hypothesis::TPreCadPeriodicityVector& preCadPeriodicityVector)
4000 {
4001   BLSURFPlugin::TPeriodicityList_var periodicityList = new BLSURFPlugin::TPeriodicityList();
4002
4003   periodicityList->length((CORBA::ULong) preCadPeriodicityVector.size());
4004
4005   for ( CORBA::ULong i = 0; i<preCadPeriodicityVector.size(); i++)
4006   {
4007     ::BLSURFPlugin_Hypothesis::TPreCadPeriodicity preCadPeriodicityVector_i = preCadPeriodicityVector[i];
4008
4009     BLSURFPlugin::TPreCadPeriodicity_var myPreCadPeriodicity = new BLSURFPlugin::TPreCadPeriodicity();
4010     myPreCadPeriodicity->shape1Entry = CORBA::string_dup(preCadPeriodicityVector_i.shape1Entry.c_str());
4011     myPreCadPeriodicity->shape2Entry = CORBA::string_dup(preCadPeriodicityVector_i.shape2Entry.c_str());
4012
4013     BLSURFPlugin::TEntryList_var sourceVertices = new BLSURFPlugin::TEntryList();
4014     if (! preCadPeriodicityVector_i.theSourceVerticesEntries.empty())
4015     {
4016       sourceVertices->length((CORBA::ULong) preCadPeriodicityVector_i.theSourceVerticesEntries.size());
4017       for (CORBA::ULong j=0; j<preCadPeriodicityVector_i.theSourceVerticesEntries.size(); j++)
4018         sourceVertices[j]=CORBA::string_dup(preCadPeriodicityVector_i.theSourceVerticesEntries[j].c_str());
4019     }
4020
4021     myPreCadPeriodicity->theSourceVerticesEntries = sourceVertices;
4022
4023     BLSURFPlugin::TEntryList_var targetVertices = new BLSURFPlugin::TEntryList();
4024     if (! preCadPeriodicityVector_i.theTargetVerticesEntries.empty())
4025     {
4026       targetVertices->length((CORBA::ULong) preCadPeriodicityVector_i.theTargetVerticesEntries.size());
4027       for (CORBA::ULong j=0; j<preCadPeriodicityVector_i.theTargetVerticesEntries.size(); j++)
4028         targetVertices[j]=CORBA::string_dup(preCadPeriodicityVector_i.theTargetVerticesEntries[j].c_str());
4029     }
4030
4031     myPreCadPeriodicity->theTargetVerticesEntries = targetVertices;
4032
4033     periodicityList[i] = myPreCadPeriodicity;
4034   }
4035
4036
4037   return periodicityList._retn();
4038 }
4039
4040
4041 void BLSURFPlugin_Hypothesis_i::AddPreCadFacesPeriodicity(GEOM::GEOM_Object_ptr theFace1, GEOM::GEOM_Object_ptr theFace2)
4042 {
4043   ASSERT(myBaseImpl);
4044   const GEOM::ListOfGO theSourceVertices;
4045   const GEOM::ListOfGO theTargetVertices;
4046   AddPreCadFacesPeriodicityWithVertices(theFace1, theFace2, theSourceVertices, theTargetVertices);
4047 }
4048
4049
4050 void BLSURFPlugin_Hypothesis_i::AddPreCadFacesPeriodicityWithVertices(GEOM::GEOM_Object_ptr theFace1, GEOM::GEOM_Object_ptr theFace2,
4051                                                                       const GEOM::ListOfGO& theSourceVertices, const GEOM::ListOfGO& theTargetVertices)
4052 {
4053   ASSERT(myBaseImpl);
4054
4055   size_t theLength = theSourceVertices.length();
4056   if (theLength != theTargetVertices.length())
4057     THROW_SALOME_CORBA_EXCEPTION( "The sizes of theSourceVertices and theTargetVertices must be the same" ,SALOME::BAD_PARAM );
4058
4059   std::vector<GEOM::shape_type> allowedShapeTypes;
4060   allowedShapeTypes.push_back(GEOM::FACE);
4061   allowedShapeTypes.push_back(GEOM::COMPOUND);
4062
4063   string prefix1 = "Source_face_";
4064   CheckShapeTypes(theFace1, allowedShapeTypes);
4065   string theFace1Entry = PublishIfNeeded(theFace1, GEOM::FACE, prefix1);
4066
4067   string prefix2 = "Target_face_";
4068   CheckShapeTypes(theFace2, allowedShapeTypes);
4069   string theFace2Entry = PublishIfNeeded(theFace2, GEOM::FACE, prefix2);
4070
4071   string prefix3 = "Source_vertex_";
4072   BLSURFPlugin::TEntryList_var theSourceVerticesEntries = new BLSURFPlugin::TEntryList();
4073   theSourceVerticesEntries->length((CORBA::ULong) theLength);
4074   GEOM::GEOM_Object_ptr theVtx_i;
4075   string theEntry_i;
4076   for (CORBA::ULong ind = 0; ind < theLength; ind++) {
4077     theVtx_i = theSourceVertices[ind];
4078     theEntry_i = PublishIfNeeded(theVtx_i, GEOM::VERTEX, prefix3);
4079     theSourceVerticesEntries[ind] = CORBA::string_dup(theEntry_i.c_str());
4080   }
4081
4082   string prefix4 = "Target_vertex_";
4083   BLSURFPlugin::TEntryList_var theTargetVerticesEntries = new BLSURFPlugin::TEntryList();
4084   theTargetVerticesEntries->length((CORBA::ULong) theLength);
4085   for ( CORBA::ULong  ind = 0; ind < theLength; ind++) {
4086     theVtx_i = theTargetVertices[ind];
4087     theEntry_i = PublishIfNeeded(theVtx_i, GEOM::VERTEX, prefix4);
4088     theTargetVerticesEntries[ind] = CORBA::string_dup(theEntry_i.c_str());
4089   }
4090
4091   string theFace2Name = theFace2->GetName();
4092   try {
4093     AddPreCadFacesPeriodicityEntry(theFace1Entry.c_str(), theFace2Entry.c_str(),
4094                                    theSourceVerticesEntries, theTargetVerticesEntries);
4095   } catch (SALOME_Exception& ex) {
4096     THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
4097   }
4098 }
4099
4100
4101 void BLSURFPlugin_Hypothesis_i::AddPreCadFacesPeriodicityEntry(const char* theFace1Entry, const char* theFace2Entry,
4102                                                                const BLSURFPlugin::TEntryList& theSourceVerticesEntriesCorba, const BLSURFPlugin::TEntryList& theTargetVerticesEntriesCorba)
4103 {
4104   ASSERT(myBaseImpl);
4105
4106   // Convert BLSURFPlugin::TEntryList to vector<string>
4107   vector<string> theSourceVerticesEntries, theTargetVerticesEntries;
4108   for ( CORBA::ULong  ind = 0; ind < theSourceVerticesEntriesCorba.length(); ind++) {
4109     theSourceVerticesEntries.push_back(theSourceVerticesEntriesCorba[ind].in());
4110     theTargetVerticesEntries.push_back(theTargetVerticesEntriesCorba[ind].in());
4111   }
4112
4113   string listEntriesTxt = FormatVerticesEntries(theSourceVerticesEntries, theTargetVerticesEntries);
4114
4115
4116   this->GetImpl()->AddPreCadFacesPeriodicity(theFace1Entry, theFace2Entry,
4117                                              theSourceVerticesEntries, theTargetVerticesEntries);
4118
4119   SMESH::TPythonDump pd;
4120   if (!theSourceVerticesEntries.empty())
4121   {
4122     pd << _this() << ".AddPreCadFacesPeriodicityWithVertices(" << theFace1Entry << ", " << theFace2Entry;
4123     pd << listEntriesTxt.c_str();
4124     pd << ")";
4125   }
4126   else
4127     pd << _this() << ".AddPreCadFacesPeriodicity(" << theFace1Entry << ", " << theFace2Entry << ")";
4128 }
4129
4130 void BLSURFPlugin_Hypothesis_i::AddPreCadEdgesPeriodicity(GEOM::GEOM_Object_ptr theEdge1, GEOM::GEOM_Object_ptr theEdge2)
4131 {
4132   ASSERT(myBaseImpl);
4133   const GEOM::ListOfGO theSourceVertices;
4134   const GEOM::ListOfGO theTargetVertices;
4135   AddPreCadEdgesPeriodicityWithVertices(theEdge1, theEdge2, theSourceVertices, theTargetVertices);
4136 }
4137
4138 void BLSURFPlugin_Hypothesis_i::AddPreCadEdgesPeriodicityWithVertices(GEOM::GEOM_Object_ptr theEdge1, GEOM::GEOM_Object_ptr theEdge2,
4139                                                                       const GEOM::ListOfGO& theSourceVertices, const GEOM::ListOfGO& theTargetVertices)
4140 {
4141   ASSERT(myBaseImpl);
4142
4143   size_t theLength = theSourceVertices.length();
4144   if (theLength != theTargetVertices.length())
4145     THROW_SALOME_CORBA_EXCEPTION( "The sizes of theSourceVertices and theTargetVertices must be the same" ,SALOME::BAD_PARAM );
4146
4147   std::vector<GEOM::shape_type> allowedShapeTypes;
4148   allowedShapeTypes.push_back(GEOM::EDGE);
4149   allowedShapeTypes.push_back(GEOM::COMPOUND);
4150
4151   string prefix1 = "Source_edge_";
4152   CheckShapeTypes(theEdge1, allowedShapeTypes);
4153   string theEdge1Entry = PublishIfNeeded(theEdge1, GEOM::EDGE, prefix1);
4154
4155   string prefix2 = "Target_edge_";
4156   CheckShapeTypes(theEdge2, allowedShapeTypes);
4157   string theEdge2Entry = PublishIfNeeded(theEdge2, GEOM::EDGE, prefix2);
4158
4159   string prefix3 = "Source_vertex_";
4160   BLSURFPlugin::TEntryList_var theSourceVerticesEntries = new BLSURFPlugin::TEntryList();
4161   theSourceVerticesEntries->length((CORBA::ULong) theLength);
4162   GEOM::GEOM_Object_ptr theVtx_i;
4163   string theEntry_i;
4164   for (CORBA::ULong ind = 0; ind < theLength; ind++) {
4165     theVtx_i = theSourceVertices[ind];
4166     theEntry_i = PublishIfNeeded(theVtx_i, GEOM::VERTEX, prefix3);
4167     theSourceVerticesEntries[ind] = CORBA::string_dup(theEntry_i.c_str());
4168   }
4169
4170   string prefix4 = "Target_vertex_";
4171   BLSURFPlugin::TEntryList_var theTargetVerticesEntries = new BLSURFPlugin::TEntryList();
4172   theTargetVerticesEntries->length((CORBA::ULong) theLength);
4173   for (CORBA::ULong ind = 0; ind < theLength; ind++) {
4174     theVtx_i = theTargetVertices[ind];
4175     theEntry_i = PublishIfNeeded(theVtx_i, GEOM::VERTEX, prefix4);
4176     theTargetVerticesEntries[ind] = CORBA::string_dup(theEntry_i.c_str());
4177   }
4178
4179   string theEdge2Name = theEdge2->GetName();
4180   try {
4181     AddPreCadEdgesPeriodicityEntry(theEdge1Entry.c_str(), theEdge2Entry.c_str(),
4182                                    theSourceVerticesEntries, theTargetVerticesEntries);
4183   } catch (SALOME_Exception& ex) {
4184     THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
4185   }
4186 }
4187
4188
4189 void BLSURFPlugin_Hypothesis_i::AddPreCadEdgesPeriodicityEntry(const char* theEdge1Entry, const char* theEdge2Entry,
4190                                                                const BLSURFPlugin::TEntryList& theSourceVerticesEntriesCorba, const BLSURFPlugin::TEntryList& theTargetVerticesEntriesCorba)
4191 {
4192
4193   ASSERT(myBaseImpl);
4194
4195   // Convert BLSURFPlugin::TEntryList to vector<string>
4196   vector<string> theSourceVerticesEntries, theTargetVerticesEntries;
4197   for (CORBA::ULong  ind = 0; ind < theSourceVerticesEntriesCorba.length(); ind++) {
4198     theSourceVerticesEntries.push_back(theSourceVerticesEntriesCorba[ind].in());
4199     theTargetVerticesEntries.push_back(theTargetVerticesEntriesCorba[ind].in());
4200   }
4201
4202   string listEntriesTxt = FormatVerticesEntries(theSourceVerticesEntries, theTargetVerticesEntries);
4203
4204   this->GetImpl()->AddPreCadEdgesPeriodicity(theEdge1Entry, theEdge2Entry,
4205                                              theSourceVerticesEntries, theTargetVerticesEntries);
4206
4207   SMESH::TPythonDump pd;
4208   if (!theSourceVerticesEntries.empty())
4209   {
4210     pd << _this() << ".AddPreCadEdgesPeriodicityWithVertices(" << theEdge1Entry << ", " << theEdge2Entry;
4211     pd << listEntriesTxt.c_str();
4212     pd << ")";
4213   }
4214   else
4215     pd << _this() << ".AddPreCadEdgesPeriodicity(" << theEdge1Entry << ", " << theEdge2Entry << ")";
4216
4217 }
4218
4219
4220 //================================================================================
4221 /*!
4222  * \brief Sets the file for export resulting mesh in GMF format
4223  * \param theFileName - full name of the file (.mesh, .meshb)
4224  * 
4225  * After compute, export the resulting mesh in the given file with the GMF format (.mesh)
4226  */
4227 //================================================================================  
4228 // void BLSURFPlugin_Hypothesis_i::SetGMFFile(const char* theFileName, CORBA::Boolean isBinary) {
4229 void BLSURFPlugin_Hypothesis_i::SetGMFFile(const char* theFileName) {
4230   ASSERT(myBaseImpl);
4231   bool valueChanged/*, modeChanged*/ = false;
4232   try {
4233     valueChanged = (this->GetImpl()->GetGMFFile() != theFileName);
4234     //     modeChanged = (this->GetImpl()->GetGMFFileMode() != isBinary);
4235     if (valueChanged)// or (!valueChanged && modeChanged))
4236       this->GetImpl()->SetGMFFile(theFileName);// ,isBinary);
4237   } catch (const std::exception& ex) {
4238     THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
4239   }
4240   if (valueChanged)// or (!valueChanged && modeChanged))
4241     SMESH::TPythonDump() << _this() << ".SetGMFFile(\"" << theFileName << "\")"; //", " << isBinary << ")";
4242 }
4243
4244 //================================================================================
4245 /*!
4246  * \brief Gets the file name for export resulting mesh in GMF format
4247  * \retval char* - The file name
4248  * 
4249  * Returns the GMF file name
4250  */
4251 //================================================================================  
4252 char* BLSURFPlugin_Hypothesis_i::GetGMFFile() {
4253   ASSERT(myBaseImpl);
4254   return CORBA::string_dup(this->GetImpl()->GetGMFFile().c_str());
4255 }
4256
4257 // //================================================================================
4258 // /*!
4259 //  * \brief Gets the file mode for export resulting mesh in GMF format
4260 //  * \retval CORBA::Boolean - TRUE if binary mode, FALSE if ascii mode
4261 //  * 
4262 //  * Returns the GMF file mode
4263 //  */
4264 // //================================================================================  
4265 // CORBA::Boolean BLSURFPlugin_Hypothesis_i::GetGMFFileMode() {
4266 //   ASSERT(myBaseImpl);
4267 //   return this->GetImpl()->GetGMFFileMode();
4268 // }
4269
4270 //=============================================================================
4271 /*!
4272  *  BLSURFPlugin_Hypothesis_i::GetImpl
4273  *
4274  *  Get implementation
4275  */
4276 //=============================================================================
4277 ::BLSURFPlugin_Hypothesis* BLSURFPlugin_Hypothesis_i::GetImpl() {
4278   return (::BLSURFPlugin_Hypothesis*) myBaseImpl;
4279 }
4280
4281 //================================================================================
4282 /*!
4283  * \brief Verify whether hypothesis supports given entity type
4284  * \param type - dimension (see SMESH::Dimension enumeration)
4285  * \retval CORBA::Boolean - TRUE if dimension is supported, FALSE otherwise
4286  *
4287  * Verify whether hypothesis supports given entity type (see SMESH::Dimension enumeration)
4288  */
4289 //================================================================================
4290 CORBA::Boolean BLSURFPlugin_Hypothesis_i::IsDimSupported(SMESH::Dimension type) {
4291   return type == SMESH::DIM_2D;
4292 }
4293
4294
4295 //================================================================================
4296 /*!
4297  * \brief Return geometry this hypothesis depends on. Return false if there is no geometry parameter
4298  */
4299 //================================================================================
4300
4301 bool
4302 BLSURFPlugin_Hypothesis_i::getObjectsDependOn( std::vector< std::string > & entryArray,
4303                                                std::vector< int >         & subIDArray ) const
4304 {
4305   typedef ::BLSURFPlugin_Hypothesis BH;
4306   const BH* impl = static_cast<const BH*>( myBaseImpl );
4307
4308   {
4309     const BH::TSizeMap& sizeMap = impl->_GetSizeMapEntries();
4310     BH::TSizeMap::const_iterator entry2size = sizeMap.cbegin();
4311     for ( ; entry2size != sizeMap.cend(); ++entry2size )
4312       entryArray.push_back( entry2size->first );
4313   }
4314   {
4315     const BH::TSizeMap& sizeMap = impl->_GetAttractorEntries();
4316     BH::TSizeMap::const_iterator entry2size = sizeMap.cbegin();
4317     for ( ; entry2size != sizeMap.cend(); ++entry2size )
4318       entryArray.push_back( entry2size->first );
4319   }
4320   {
4321     const BH::TAttractorMap& classAttractors = impl-> _GetClassAttractorEntries();
4322     BH::TAttractorMap::const_iterator entry2size = classAttractors.cbegin();
4323     for ( ; entry2size != classAttractors.cend(); ++entry2size )
4324       entryArray.push_back( entry2size->first );
4325   }
4326   {
4327     const BH::TFaceEntryEnfVertexListMap& faceEntryEnfVertexListMap = impl->_GetAllEnforcedVerticesByFace();
4328     BH::TFaceEntryEnfVertexListMap::const_iterator entry2evList = faceEntryEnfVertexListMap.cbegin();
4329     for ( ; entry2evList != faceEntryEnfVertexListMap.cend(); ++entry2evList )
4330     {
4331       entryArray.push_back( entry2evList->first );
4332
4333       const BH::TEnfVertexList& evList = entry2evList->second;
4334       BH::TEnfVertexList::const_iterator evIt = evList.cbegin();
4335       for ( ; evIt != evList.cend(); ++evIt )
4336       {
4337         const BH::TEnfVertex* ev = *evIt;
4338         entryArray.push_back( ev->geomEntry );
4339         entryArray.insert( entryArray.end(), ev->faceEntries.cbegin(), ev->faceEntries.cend() );
4340       }
4341     }
4342   }
4343   // { // duplicated data of faceEntryEnfVertexListMap
4344   //   const BH::TEnfVertexList& enfVertexList = impl->_GetAllEnforcedVertices();
4345   //   const BH::TFaceEntryCoordsListMap& faceEntryCoordsListMap = impl->_GetAllCoordsByFace();
4346   //   const BH::TFaceEntryEnfVertexEntryListMap& faceEntryEnfVertexEntryListMap = impl->_GetAllEnfV  //   const BH::TEnfVertexEntryEnfVertexMap& enfVertexEntryEnfVertexMap = impl->_GetAllEnforcedVert  // }
4347   {
4348     const BH::TPreCadPeriodicityVector& preCadFacesPeriodicityVector = impl->_GetPreCadFacesPeriodicityVector();
4349     BH::TPreCadPeriodicityVector::const_iterator pcp = preCadFacesPeriodicityVector.cbegin();
4350     for ( ; pcp != preCadFacesPeriodicityVector.cend(); ++pcp )
4351     {
4352       entryArray.push_back( pcp->shape1Entry );
4353       entryArray.push_back( pcp->shape2Entry );
4354       entryArray.insert( entryArray.end(),
4355                          pcp->theSourceVerticesEntries.cbegin(),
4356                          pcp->theSourceVerticesEntries.cend() );
4357       entryArray.insert( entryArray.end(),
4358                          pcp->theTargetVerticesEntries.cbegin(),
4359                          pcp->theTargetVerticesEntries.cend() );
4360     }
4361   }
4362   {
4363     const BH::TPreCadPeriodicityVector& preCadEdgesPeriodicityVector = impl->_GetPreCadEdgesPeriodicityVector();
4364     BH::TPreCadPeriodicityVector::const_iterator pcp = preCadEdgesPeriodicityVector.cbegin();
4365     for ( ; pcp != preCadEdgesPeriodicityVector.cend(); ++pcp )
4366     {
4367       entryArray.push_back( pcp->shape1Entry );
4368       entryArray.push_back( pcp->shape2Entry );
4369       entryArray.insert( entryArray.end(),
4370                          pcp->theSourceVerticesEntries.cbegin(),
4371                          pcp->theSourceVerticesEntries.cend() );
4372       entryArray.insert( entryArray.end(),
4373                          pcp->theTargetVerticesEntries.cbegin(),
4374                          pcp->theTargetVerticesEntries.cend() );
4375     }
4376   }
4377   {
4378     const BH::THyperPatchList& hyperPatchList = impl->GetHyperPatches();
4379     BH::THyperPatchList::const_iterator idSet = hyperPatchList.cbegin();
4380     for ( ; idSet != hyperPatchList.cend(); ++idSet )
4381     {
4382       subIDArray.insert( subIDArray.end(), idSet->cbegin(), idSet->cend() );
4383     }
4384   }
4385   return true;
4386 }
4387
4388 //================================================================================
4389 /*!
4390  * \brief Set new geometry instead of that returned by getObjectsDependOn()
4391  */
4392 //================================================================================
4393
4394 bool
4395 BLSURFPlugin_Hypothesis_i::setObjectsDependOn( std::vector< std::string > & entryArray,
4396                                                std::vector< int >         & subIDArray )
4397 {
4398   typedef ::BLSURFPlugin_Hypothesis BH;
4399   BH* impl = static_cast<BH*>( myBaseImpl );
4400
4401   size_t iEnt = 0;
4402   {
4403     BH::TSizeMap& sizeMapNew = const_cast< BH::TSizeMap& >( impl->_GetSizeMapEntries() );
4404     BH::TSizeMap sizeMap;
4405     sizeMap.swap( sizeMapNew );
4406     BH::TSizeMap::const_iterator entry2size = sizeMap.cbegin();
4407     for ( ; entry2size != sizeMap.cend(); ++entry2size, ++iEnt )
4408       if ( entryArray[ iEnt ].empty() == entry2size->first.empty() )
4409         sizeMapNew[ entryArray[ iEnt ]] =  entry2size->second;
4410   }
4411   {
4412     BH::TSizeMap& sizeMapNew = const_cast< BH::TSizeMap& >( impl->_GetAttractorEntries() );
4413     BH::TSizeMap sizeMap;
4414     sizeMap.swap( sizeMapNew );
4415     BH::TSizeMap::const_iterator entry2size = sizeMap.cbegin();
4416     for ( ; entry2size != sizeMap.cend(); ++entry2size, ++iEnt )
4417       if ( entryArray[ iEnt ].empty() == entry2size->first.empty() )
4418         sizeMapNew[ entryArray[ iEnt ]] =  entry2size->second;
4419   }
4420   {
4421     BH::TAttractorMap& attrMapNew =
4422       const_cast< BH::TAttractorMap& > ( impl->_GetClassAttractorEntries() );
4423     BH::TAttractorMap attrMap;
4424     attrMap.swap( attrMapNew );
4425     BH::TAttractorMap::const_iterator entry2size = attrMap.cbegin();
4426     for ( ; entry2size != attrMap.cend(); ++entry2size, ++iEnt )
4427       if ( entryArray[ iEnt ].empty() == entry2size->first.empty() )
4428         attrMapNew.insert( std::make_pair( entryArray[ iEnt ], entry2size->second ));
4429       else
4430         delete entry2size->second;
4431   }
4432   {
4433     BH::TFaceEntryEnfVertexListMap& faceEntryEnfVertexListMapNew =
4434       const_cast< BH::TFaceEntryEnfVertexListMap& >( impl->_GetAllEnforcedVerticesByFace() );
4435     BH::TFaceEntryEnfVertexListMap faceEntryEnfVertexListMap;
4436     faceEntryEnfVertexListMap.swap( faceEntryEnfVertexListMapNew );
4437
4438     BH::TEnfVertexList& enfVertexList =
4439       const_cast< BH::TEnfVertexList& > ( impl->_GetAllEnforcedVertices() );
4440     enfVertexList.clear(); // avoid removal
4441
4442     impl->ClearAllEnforcedVertices();
4443
4444     BH::TFaceEntryEnfVertexListMap::iterator entry2evList = faceEntryEnfVertexListMap.begin();
4445     for ( ; entry2evList != faceEntryEnfVertexListMap.end(); ++entry2evList )
4446     {
4447       const BH::TEntry& entry = entryArray[ iEnt++ ];
4448       bool faceOk = ( entry.empty() == entry2evList->first.empty() );
4449
4450       BH::TEnfVertexList& evList = entry2evList->second;
4451       BH::TEnfVertexList::iterator evIt = evList.begin();
4452       for ( ; evIt != evList.end(); ++evIt )
4453       {
4454         BH::TEnfVertex* ev = *evIt;
4455         bool ok = faceOk && ( ev->geomEntry.empty() != entryArray[ iEnt ].empty() );
4456         ev->geomEntry = entryArray[ iEnt++ ];
4457         BH::TEntryList faceEntriesNew;
4458         BH::TEntryList::iterator fEnt = ev->faceEntries.begin();
4459         for ( ; fEnt != ev->faceEntries.end(); ++fEnt, ++iEnt )
4460         {
4461           if ( !entryArray[ iEnt ].empty() )
4462             faceEntriesNew.insert( entryArray[ iEnt ]);
4463         }
4464         if ( ok )
4465         {
4466           ev->faceEntries.swap( faceEntriesNew );
4467           impl->AddEnforcedVertex( entry, ev );
4468         }
4469         else
4470         {
4471           delete ev;
4472         }
4473       }
4474     }
4475   }
4476   {
4477     BH::TPreCadPeriodicityVector& preCadPeriodicityVector =
4478       const_cast< BH::TPreCadPeriodicityVector&> ( impl->_GetPreCadFacesPeriodicityVector() );
4479     BH::TPreCadPeriodicityVector::iterator pcp = preCadPeriodicityVector.begin();
4480     for ( ; pcp != preCadPeriodicityVector.end(); ++pcp )
4481     {
4482       pcp->shape1Entry = entryArray[ iEnt++ ];
4483       pcp->shape2Entry = entryArray[ iEnt++ ];
4484       for ( size_t i = 0; i < pcp->theSourceVerticesEntries.size(); ++i, iEnt++ )
4485         pcp->theSourceVerticesEntries[i] = entryArray[ iEnt ];
4486
4487       for ( size_t i = 0; i < pcp->theTargetVerticesEntries.size(); ++i, iEnt++ )
4488         pcp->theTargetVerticesEntries[i] = entryArray[ iEnt ];
4489     }
4490   }
4491   {
4492     BH::TPreCadPeriodicityVector& preCadPeriodicityVector =
4493       const_cast< BH::TPreCadPeriodicityVector&> ( impl->_GetPreCadEdgesPeriodicityVector() );
4494     BH::TPreCadPeriodicityVector::iterator pcp = preCadPeriodicityVector.begin();
4495     for ( ; pcp != preCadPeriodicityVector.end(); ++pcp )
4496     {
4497       pcp->shape1Entry = entryArray[ iEnt++ ];
4498       pcp->shape2Entry = entryArray[ iEnt++ ];
4499       for ( size_t i = 0; i < pcp->theSourceVerticesEntries.size(); ++i, iEnt++ )
4500         pcp->theSourceVerticesEntries[i] = entryArray[ iEnt ];
4501
4502       for ( size_t i = 0; i < pcp->theTargetVerticesEntries.size(); ++i, iEnt++ )
4503         pcp->theTargetVerticesEntries[i] = entryArray[ iEnt ];
4504     }
4505   }
4506
4507   size_t iID = 0;
4508   {
4509     BH::THyperPatchList& hyperPatchListNew =
4510       const_cast< BH::THyperPatchList& >( impl->GetHyperPatches() );
4511     BH::THyperPatchList hyperPatchList;
4512     hyperPatchList.swap( hyperPatchListNew );
4513     BH::THyperPatchList::iterator idSet = hyperPatchList.begin();
4514     for ( ; idSet != hyperPatchList.end(); ++idSet )
4515     {
4516       BH::THyperPatchTags& ids = *idSet;
4517       BH::THyperPatchTags idsNew;
4518       BH::THyperPatchTags::iterator i = ids.begin();
4519       for ( ; i != ids.end(); ++i, ++iID )
4520         if ( subIDArray[ iID ] > 0 )
4521           idsNew.insert( subIDArray[ iID ]);
4522       if ( !idsNew.empty() )
4523         hyperPatchListNew.push_back( idsNew );
4524     }
4525   }
4526
4527   return ( iEnt == entryArray.size() && iID == subIDArray.size() );
4528 }