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