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