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