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