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