]> SALOME platform Git repositories - plugins/blsurfplugin.git/blob - src/BLSURFPlugin/BLSURFPlugin_Hypothesis_i.cxx
Salome HOME
Fix compilation problems on 32bit platforms (wrong CORBA mappings)
[plugins/blsurfplugin.git] / src / BLSURFPlugin / BLSURFPlugin_Hypothesis_i.cxx
1 // Copyright (C) 2007-2013  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.
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 <GEOM_Object.hxx>
33
34 #include <SALOMEDS_wrap.hxx>
35 #include <Utils_CorbaException.hxx>
36 #include <utilities.h>
37
38 #include <stdexcept>
39 #include <cstring>
40 #include <boost/regex.hpp>
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, int theStudyId,
50     ::SMESH_Gen* theGenImpl) :
51   SALOME::GenericObj_i(thePOA), SMESH_Hypothesis_i(thePOA) {
52   MESSAGE( "BLSURFPlugin_Hypothesis_i::BLSURFPlugin_Hypothesis_i" );
53   myBaseImpl = new ::BLSURFPlugin_Hypothesis(theGenImpl->GetANewId(), theStudyId, theGenImpl);
54 }
55
56 //=============================================================================
57 /*!
58  *  BLSURFPlugin_Hypothesis_i::~BLSURFPlugin_Hypothesis_i
59  *
60  *  Destructor
61  */
62 //=============================================================================
63 BLSURFPlugin_Hypothesis_i::~BLSURFPlugin_Hypothesis_i() {
64   MESSAGE( "BLSURFPlugin_Hypothesis_i::~BLSURFPlugin_Hypothesis_i" );
65 }
66
67 //=============================================================================
68
69 //=============================================================================
70 /*!
71  *  BLSURFPlugin_Hypothesis_i::SetPhysicalMesh
72  *
73  *  Set PhysicalMesh
74  */
75
76 //=============================================================================
77 void BLSURFPlugin_Hypothesis_i::SetPhysicalMesh(CORBA::Long theValue) {
78   // MESSAGE("BLSURFPlugin_Hypothesis_i::SetPhysicalMesh");
79   ASSERT(myBaseImpl);
80   this->GetImpl()->SetPhysicalMesh((::BLSURFPlugin_Hypothesis::PhysicalMesh) theValue);
81   SMESH::TPythonDump() << _this() << ".SetPhysicalMesh( " << theValue << " )";
82 }
83
84 //=============================================================================
85 /*!
86  *  BLSURFPlugin_Hypothesis_i::GetPhysicalMesh
87  *
88  *  Get PhysicalMesh
89  */
90 //=============================================================================
91 CORBA::Long BLSURFPlugin_Hypothesis_i::GetPhysicalMesh() {
92   // MESSAGE("BLSURFPlugin_Hypothesis_i::GetPhysicalMesh");
93   ASSERT(myBaseImpl);
94   return this->GetImpl()->GetPhysicalMesh();
95 }
96
97 //=============================================================================
98 /*!
99  *  BLSURFPlugin_Hypothesis_i::SetGeometricMesh
100  *
101  *  Set GeometricMesh
102  */
103
104 //=============================================================================
105 void BLSURFPlugin_Hypothesis_i::SetGeometricMesh(CORBA::Long theValue) {
106   // MESSAGE("BLSURFPlugin_Hypothesis_i::SetGeometricMesh");
107   ASSERT(myBaseImpl);
108   this->GetImpl()->SetGeometricMesh((::BLSURFPlugin_Hypothesis::GeometricMesh) theValue);
109   SMESH::TPythonDump() << _this() << ".SetGeometricMesh( " << theValue << " )";
110 }
111
112 //=============================================================================
113 /*!
114  *  BLSURFPlugin_Hypothesis_i::GetGeometricMesh
115  *
116  *  Get GeometricMesh
117  */
118 //=============================================================================
119 CORBA::Long BLSURFPlugin_Hypothesis_i::GetGeometricMesh() {
120   // MESSAGE("BLSURFPlugin_Hypothesis_i::GetGeometricMesh");
121   ASSERT(myBaseImpl);
122   return this->GetImpl()->GetGeometricMesh();
123 }
124
125 //=============================================================================
126 /*!
127  *  BLSURFPlugin_Hypothesis_i::SetPhySize
128  *
129  *  Set PhySize
130  */
131 //=============================================================================
132 void BLSURFPlugin_Hypothesis_i::SetPhySize(CORBA::Double theValue) {
133 //   MESSAGE("BLSURFPlugin_Hypothesis_i::SetPhySize");
134   ASSERT(myBaseImpl);
135   this->GetImpl()->SetPhySize(theValue, false);
136   SMESH::TPythonDump() << _this() << ".SetPhySize( " << theValue << " )";
137 }
138
139 //=============================================================================
140 /*!
141  *  BLSURFPlugin_Hypothesis_i::SetPhySizeRel
142  *
143  *  Set Relative PhySize
144  */
145 //=============================================================================
146 void BLSURFPlugin_Hypothesis_i::SetPhySizeRel(CORBA::Double theValue) {
147 //   MESSAGE("BLSURFPlugin_Hypothesis_i::SetPhySizeRel");
148   ASSERT(myBaseImpl);
149   this->GetImpl()->SetPhySize(theValue, true);
150   SMESH::TPythonDump() << _this() << ".SetPhySize( " << theValue << ", isRelative = True )";
151 }
152
153 //=============================================================================
154 /*!
155  *  BLSURFPlugin_Hypothesis_i::GetPhySize
156  *
157  *  Get PhySize
158  */
159 //=============================================================================
160 CORBA::Double BLSURFPlugin_Hypothesis_i::GetPhySize() {
161 //   MESSAGE("BLSURFPlugin_Hypothesis_i::GetPhySize");
162   ASSERT(myBaseImpl);
163   return this->GetImpl()->GetPhySize();
164 }
165
166 //=============================================================================
167 /*!
168  *  BLSURFPlugin_Hypothesis_i::IsPhySizeRel
169  *
170  *  Returns True if PhySize is relative
171  */
172 //=============================================================================
173 CORBA::Boolean BLSURFPlugin_Hypothesis_i::IsPhySizeRel() {
174 //   MESSAGE("BLSURFPlugin_Hypothesis_i::IsPhySizeRel");
175   ASSERT(myBaseImpl);
176   return this->GetImpl()->IsPhySizeRel();
177 }
178
179 //=============================================================================
180 void BLSURFPlugin_Hypothesis_i::SetMinSize(CORBA::Double theMinSize) {
181   ASSERT(myBaseImpl);
182   if (IsMinSizeRel() || GetMinSize() != theMinSize ) {
183     this->GetImpl()->SetMinSize(theMinSize, false);
184     SMESH::TPythonDump() << _this() << ".SetMinSize( " << theMinSize << " )";
185   }
186 }
187
188 //=============================================================================
189 void BLSURFPlugin_Hypothesis_i::SetMinSizeRel(CORBA::Double theMinSize) {
190   ASSERT(myBaseImpl);
191   if ( !IsMinSizeRel() || (GetMinSize() != theMinSize) ) {
192     this->GetImpl()->SetMinSize(theMinSize, true);
193     SMESH::TPythonDump() << _this() << ".SetMinSize( " << theMinSize << ", isRelative = True )";
194   }
195 }
196
197 //=============================================================================
198 CORBA::Double BLSURFPlugin_Hypothesis_i::GetMinSize() {
199   ASSERT(myBaseImpl);
200   return this->GetImpl()->GetMinSize();
201 }
202
203 //=============================================================================
204 CORBA::Boolean BLSURFPlugin_Hypothesis_i::IsMinSizeRel() {
205 //   MESSAGE("BLSURFPlugin_Hypothesis_i::IsMinSizeRel");
206   ASSERT(myBaseImpl);
207   return this->GetImpl()->IsMinSizeRel();
208 }
209
210 //=============================================================================
211 void BLSURFPlugin_Hypothesis_i::SetMaxSize(CORBA::Double theMaxSize) {
212   ASSERT(myBaseImpl);
213   if (IsMaxSizeRel() || GetMaxSize() != theMaxSize) {
214     this->GetImpl()->SetMaxSize(theMaxSize, false);
215     SMESH::TPythonDump() << _this() << ".SetMaxSize( " << theMaxSize << " )";
216   }
217 }
218
219 //=============================================================================
220 void BLSURFPlugin_Hypothesis_i::SetMaxSizeRel(CORBA::Double theMaxSize) {
221   ASSERT(myBaseImpl);
222   if ( !IsMaxSizeRel() || (GetMaxSize() != theMaxSize) ) {
223     this->GetImpl()->SetMaxSize(theMaxSize, true);
224     SMESH::TPythonDump() << _this() << ".SetMaxSize( " << theMaxSize << ", isRelative = True )";
225   }
226 }
227
228 //=============================================================================
229 CORBA::Double BLSURFPlugin_Hypothesis_i::GetMaxSize() {
230   ASSERT(myBaseImpl);
231   return this->GetImpl()->GetMaxSize();
232 }
233
234 //=============================================================================
235 CORBA::Boolean BLSURFPlugin_Hypothesis_i::IsMaxSizeRel() {
236 //   MESSAGE("BLSURFPlugin_Hypothesis_i::IsMaxSizeRel");
237   ASSERT(myBaseImpl);
238   return this->GetImpl()->IsMaxSizeRel();
239 }
240
241 //=============================================================================
242 /*!
243  *  BLSURFPlugin_Hypothesis_i::SetGradation
244  *
245  *  Set Gradation
246  */
247 //=============================================================================
248 void BLSURFPlugin_Hypothesis_i::SetGradation(CORBA::Double theValue) {
249   // MESSAGE("BLSURFPlugin_Hypothesis_i::SetGradation");
250   ASSERT(myBaseImpl);
251   this->GetImpl()->SetGradation(theValue);
252   SMESH::TPythonDump() << _this() << ".SetGradation( " << theValue << " )";
253 }
254
255 //=============================================================================
256 /*!
257  *  BLSURFPlugin_Hypothesis_i::GetGradation
258  *
259  *  Get Gradation
260  */
261 //=============================================================================
262 CORBA::Double BLSURFPlugin_Hypothesis_i::GetGradation() {
263   // MESSAGE("BLSURFPlugin_Hypothesis_i::GetGradation");
264   ASSERT(myBaseImpl);
265   return this->GetImpl()->GetGradation();
266 }
267
268 //=============================================================================
269 /*!
270  *  BLSURFPlugin_Hypothesis_i::SetQuadAllowed
271  *
272  *  Set true or false
273  */
274 //=============================================================================
275 void BLSURFPlugin_Hypothesis_i::SetQuadAllowed(CORBA::Boolean theValue) {
276   // MESSAGE("BLSURFPlugin_Hypothesis_i::SetQuadAllowed");
277   ASSERT(myBaseImpl);
278   this->GetImpl()->SetQuadAllowed(theValue);
279   std::string theValueStr = theValue ? "True" : "False";
280   SMESH::TPythonDump() << _this() << ".SetQuadAllowed( " << theValueStr.c_str() << " )";
281 }
282
283 //=============================================================================
284 /*!
285  *  BLSURFPlugin_Hypothesis_i::GetQuadAllowed
286  *
287  *  Get true or false
288  */
289 //=============================================================================
290 CORBA::Boolean BLSURFPlugin_Hypothesis_i::GetQuadAllowed() {
291   // MESSAGE("BLSURFPlugin_Hypothesis_i::GetQuadAllowed");
292   ASSERT(myBaseImpl);
293   return this->GetImpl()->GetQuadAllowed();
294 }
295
296 //=============================================================================
297 /*!
298  *  BLSURFPlugin_Hypothesis_i::SetAngleMesh
299  *
300  *  Set AngleMesh
301  */
302 //=============================================================================
303 void BLSURFPlugin_Hypothesis_i::SetAngleMesh(CORBA::Double theValue) {
304   // MESSAGE("BLSURFPlugin_Hypothesis_i::SetAngleMesh");
305   ASSERT(myBaseImpl);
306   this->GetImpl()->SetAngleMesh(theValue);
307   SMESH::TPythonDump() << _this() << ".SetAngleMesh( " << theValue << " )";
308 }
309
310 //=============================================================================
311 /*!
312  *  BLSURFPlugin_Hypothesis_i::GetAngleMesh
313  *
314  *  Get AngleMesh
315  */
316 //=============================================================================
317 CORBA::Double BLSURFPlugin_Hypothesis_i::GetAngleMesh() {
318   // MESSAGE("BLSURFPlugin_Hypothesis_i::GetAngleMesh");
319   ASSERT(myBaseImpl);
320   return this->GetImpl()->GetAngleMesh();
321 }
322
323 //=============================================================================
324 /*!
325  *  BLSURFPlugin_Hypothesis_i::SetChordalError
326  *
327  *  Set Chordal Error
328  */
329 //=============================================================================
330 void BLSURFPlugin_Hypothesis_i::SetChordalError(CORBA::Double theValue) {
331   // MESSAGE("BLSURFPlugin_Hypothesis_i::SetChordalError");
332   ASSERT(myBaseImpl);
333   this->GetImpl()->SetChordalError(theValue);
334   SMESH::TPythonDump() << _this() << ".SetChordalError( " << theValue << " )";
335 }
336
337 //=============================================================================
338 /*!
339  *  BLSURFPlugin_Hypothesis_i::GetChordalError
340  *
341  *  Get Chordal Error
342  */
343 //=============================================================================
344 CORBA::Double BLSURFPlugin_Hypothesis_i::GetChordalError() {
345   // MESSAGE("BLSURFPlugin_Hypothesis_i::GetChordalError");
346   ASSERT(myBaseImpl);
347   return this->GetImpl()->GetChordalError();
348 }
349
350 //=============================================================================
351 /*!
352  *  BLSURFPlugin_Hypothesis_i::SetAnisotropic
353  *
354  *  Set true or false
355  */
356 //=============================================================================
357 void BLSURFPlugin_Hypothesis_i::SetAnisotropic(CORBA::Boolean theValue) {
358   // MESSAGE("BLSURFPlugin_Hypothesis_i::SetAnisotropic");
359   ASSERT(myBaseImpl);
360   this->GetImpl()->SetAnisotropic(theValue);
361   std::string theValueStr = theValue ? "True" : "False";
362   SMESH::TPythonDump() << _this() << ".SetAnisotropic( " << theValueStr.c_str() << " )";
363 }
364
365 //=============================================================================
366 /*!
367  *  BLSURFPlugin_Hypothesis_i::GetAnisotropic
368  *
369  *  Get true or false
370  */
371 //=============================================================================
372 CORBA::Boolean BLSURFPlugin_Hypothesis_i::GetAnisotropic() {
373   // MESSAGE("BLSURFPlugin_Hypothesis_i::GetAnisotropic");
374   ASSERT(myBaseImpl);
375   return this->GetImpl()->GetAnisotropic();
376 }
377
378 //=============================================================================
379 /*!
380  *  BLSURFPlugin_Hypothesis_i::SetAnisotropicRatio
381  *
382  *  Set Anisotropic Ratio
383  */
384 //=============================================================================
385 void BLSURFPlugin_Hypothesis_i::SetAnisotropicRatio(CORBA::Double theValue) {
386   // MESSAGE("BLSURFPlugin_Hypothesis_i::SetAnisotropicRatio");
387   ASSERT(myBaseImpl);
388   this->GetImpl()->SetAnisotropicRatio(theValue);
389   SMESH::TPythonDump() << _this() << ".SetAnisotropicRatio( " << theValue << " )";
390 }
391
392 //=============================================================================
393 /*!
394  *  BLSURFPlugin_Hypothesis_i::GetAnisotropicRatio
395  *
396  *  Get Anisotropic Ratio
397  */
398 //=============================================================================
399 CORBA::Double BLSURFPlugin_Hypothesis_i::GetAnisotropicRatio() {
400   // MESSAGE("BLSURFPlugin_Hypothesis_i::GetAnisotropicRatio");
401   ASSERT(myBaseImpl);
402   return this->GetImpl()->GetAnisotropicRatio();
403 }
404
405
406 //=============================================================================
407 /*!
408  *  BLSURFPlugin_Hypothesis_i::SetRemoveTinyEdges
409  *
410  *  Set true or false
411  */
412 //=============================================================================
413 void BLSURFPlugin_Hypothesis_i::SetRemoveTinyEdges(CORBA::Boolean theValue) {
414   // MESSAGE("BLSURFPlugin_Hypothesis_i::SetRemoveTinyEdges");
415   ASSERT(myBaseImpl);
416   this->GetImpl()->SetRemoveTinyEdges(theValue);
417   std::string theValueStr = theValue ? "True" : "False";
418   SMESH::TPythonDump() << _this() << ".SetRemoveTinyEdges( " << theValueStr.c_str() << " )";
419 }
420
421 //=============================================================================
422 /*!
423  *  BLSURFPlugin_Hypothesis_i::GetRemoveTinyEdges
424  *
425  *  Get true or false
426  */
427 //=============================================================================
428 CORBA::Boolean BLSURFPlugin_Hypothesis_i::GetRemoveTinyEdges() {
429   // MESSAGE("BLSURFPlugin_Hypothesis_i::GetRemoveTinyEdges");
430   ASSERT(myBaseImpl);
431   return this->GetImpl()->GetRemoveTinyEdges();
432 }
433
434 //=============================================================================
435 /*!
436  *  BLSURFPlugin_Hypothesis_i::SetTinyEdgeLength
437  *
438  *  Set Tiny Edge Length
439  */
440 //=============================================================================
441 void BLSURFPlugin_Hypothesis_i::SetTinyEdgeLength(CORBA::Double theValue) {
442   // MESSAGE("BLSURFPlugin_Hypothesis_i::SetTinyEdgeLength");
443   ASSERT(myBaseImpl);
444   this->GetImpl()->SetTinyEdgeLength(theValue);
445   SMESH::TPythonDump() << _this() << ".SetTinyEdgeLength( " << theValue << " )";
446 }
447
448 //=============================================================================
449 /*!
450  *  BLSURFPlugin_Hypothesis_i::GetTinyEdgeLength
451  *
452  *  Get Tiny Edge Length
453  */
454 //=============================================================================
455 CORBA::Double BLSURFPlugin_Hypothesis_i::GetTinyEdgeLength() {
456   // MESSAGE("BLSURFPlugin_Hypothesis_i::GetTinyEdgeLength");
457   ASSERT(myBaseImpl);
458   return this->GetImpl()->GetTinyEdgeLength();
459 }
460
461 //=============================================================================
462 /*!
463  *  BLSURFPlugin_Hypothesis_i::SetBadElementRemoval
464  *
465  *  Set true or false
466  */
467 //=============================================================================
468 void BLSURFPlugin_Hypothesis_i::SetBadElementRemoval(CORBA::Boolean theValue) {
469   // MESSAGE("BLSURFPlugin_Hypothesis_i::SetBadElementRemoval");
470   ASSERT(myBaseImpl);
471   this->GetImpl()->SetBadElementRemoval(theValue);
472   std::string theValueStr = theValue ? "True" : "False";
473   SMESH::TPythonDump() << _this() << ".SetBadElementRemoval( " << theValueStr.c_str() << " )";
474 }
475
476 //=============================================================================
477 /*!
478  *  BLSURFPlugin_Hypothesis_i::GetBadElementRemoval
479  *
480  *  Get true or false
481  */
482 //=============================================================================
483 CORBA::Boolean BLSURFPlugin_Hypothesis_i::GetBadElementRemoval() {
484   // MESSAGE("BLSURFPlugin_Hypothesis_i::GetBadElementRemoval");
485   ASSERT(myBaseImpl);
486   return this->GetImpl()->GetBadElementRemoval();
487 }
488
489 //=============================================================================
490 /*!
491  *  BLSURFPlugin_Hypothesis_i::SetBadElementAspectRatio
492  *
493  *  Set Bad Surface Element Aspect Ratio
494  */
495 //=============================================================================
496 void BLSURFPlugin_Hypothesis_i::SetBadElementAspectRatio(CORBA::Double theValue) {
497   // MESSAGE("BLSURFPlugin_Hypothesis_i::SetBadElementAspectRatio");
498   ASSERT(myBaseImpl);
499   this->GetImpl()->SetBadElementAspectRatio(theValue);
500   SMESH::TPythonDump() << _this() << ".SetBadElementAspectRatio( " << theValue << " )";
501 }
502
503 //=============================================================================
504 /*!
505  *  BLSURFPlugin_Hypothesis_i::GetBadElementAspectRatio
506  *
507  *  Get Bad Surface Element Aspect Ratio
508  */
509 //=============================================================================
510 CORBA::Double BLSURFPlugin_Hypothesis_i::GetBadElementAspectRatio() {
511   // MESSAGE("BLSURFPlugin_Hypothesis_i::GetBadElementAspectRatio");
512   ASSERT(myBaseImpl);
513   return this->GetImpl()->GetBadElementAspectRatio();
514 }
515
516 //=============================================================================
517 /*!
518  *  BLSURFPlugin_Hypothesis_i::SetOptimizeMesh
519  *
520  *  Set true or false
521  */
522 //=============================================================================
523 void BLSURFPlugin_Hypothesis_i::SetOptimizeMesh(CORBA::Boolean theValue) {
524   // MESSAGE("BLSURFPlugin_Hypothesis_i::SetOptimizeMesh");
525   ASSERT(myBaseImpl);
526   this->GetImpl()->SetOptimizeMesh(theValue);
527   std::string theValueStr = theValue ? "True" : "False";
528   SMESH::TPythonDump() << _this() << ".SetOptimizeMesh( " << theValueStr.c_str() << " )";
529 }
530
531 //=============================================================================
532 /*!
533  *  BLSURFPlugin_Hypothesis_i::GetOptimizeMesh
534  *
535  *  Get true or false
536  */
537 //=============================================================================
538 CORBA::Boolean BLSURFPlugin_Hypothesis_i::GetOptimizeMesh() {
539   // MESSAGE("BLSURFPlugin_Hypothesis_i::GetOptimizeMesh");
540   ASSERT(myBaseImpl);
541   return this->GetImpl()->GetOptimizeMesh();
542 }
543
544 //=============================================================================
545 /*!
546  *  BLSURFPlugin_Hypothesis_i::SetQuadraticMesh
547  *
548  *  Set true or false
549  */
550 //=============================================================================
551 void BLSURFPlugin_Hypothesis_i::SetQuadraticMesh(CORBA::Boolean theValue) {
552   // MESSAGE("BLSURFPlugin_Hypothesis_i::SetQuadraticMesh");
553   ASSERT(myBaseImpl);
554   this->GetImpl()->SetQuadraticMesh(theValue);
555   std::string theValueStr = theValue ? "True" : "False";
556   SMESH::TPythonDump() << _this() << ".SetQuadraticMesh( " << theValueStr.c_str() << " )";
557 }
558
559 //=============================================================================
560 /*!
561  *  BLSURFPlugin_Hypothesis_i::GetQuadraticMesh
562  *
563  *  Get true or false
564  */
565 //=============================================================================
566 CORBA::Boolean BLSURFPlugin_Hypothesis_i::GetQuadraticMesh() {
567   // MESSAGE("BLSURFPlugin_Hypothesis_i::GetQuadraticMesh");
568   ASSERT(myBaseImpl);
569   return this->GetImpl()->GetQuadraticMesh();
570 }
571
572
573
574
575
576 /*!
577  *  BLSURFPlugin_Hypothesis_i::SetTopology
578  *
579  *  Set topology
580  */
581
582 //=============================================================================
583 void BLSURFPlugin_Hypothesis_i::SetTopology(CORBA::Long theValue) {
584   // MESSAGE("BLSURFPlugin_Hypothesis_i::SetTopology");
585   ASSERT(myBaseImpl);
586   this->GetImpl()->SetTopology((::BLSURFPlugin_Hypothesis::Topology) theValue);
587   SMESH::TPythonDump() << _this() << ".SetTopology( " << theValue << " )";
588 }
589
590 //=============================================================================
591 /*!
592  *  BLSURFPlugin_Hypothesis_i::GetTopology
593  *
594  *  Get Topology
595  */
596 //=============================================================================
597 CORBA::Long BLSURFPlugin_Hypothesis_i::GetTopology() {
598   // MESSAGE("BLSURFPlugin_Hypothesis_i::GetTopology");
599   ASSERT(myBaseImpl);
600   return this->GetImpl()->GetTopology();
601 }
602
603 //=============================================================================
604 void BLSURFPlugin_Hypothesis_i::SetVerbosity(CORBA::Short theVal) throw (SALOME::SALOME_Exception) {
605   ASSERT(myBaseImpl);
606   if (theVal < 0 || theVal > 100)
607     THROW_SALOME_CORBA_EXCEPTION( "Invalid verbosity level",SALOME::BAD_PARAM );
608   this->GetImpl()->SetVerbosity(theVal);
609   SMESH::TPythonDump() << _this() << ".SetVerbosity( " << theVal << " )";
610 }
611
612 //=============================================================================
613
614 CORBA::Short BLSURFPlugin_Hypothesis_i::GetVerbosity() {
615   ASSERT(myBaseImpl);
616   return (CORBA::Short) this->GetImpl()->GetVerbosity();
617 }
618
619 //=============================================================================
620 /*!
621  *  BLSURFPlugin_Hypothesis_i::SetPreCADMergeEdges
622  *
623  *  Set true or false
624  */
625 //=============================================================================
626 void BLSURFPlugin_Hypothesis_i::SetPreCADMergeEdges(CORBA::Boolean theValue) {
627   // MESSAGE("BLSURFPlugin_Hypothesis_i::SetPreCADMergeEdges");
628   ASSERT(myBaseImpl);
629   this->GetImpl()->SetPreCADMergeEdges(theValue);
630   std::string theValueStr = theValue ? "True" : "False";
631   SMESH::TPythonDump() << _this() << ".SetPreCADMergeEdges( " << theValueStr.c_str() << " )";
632 }
633
634 //=============================================================================
635 /*!
636  *  BLSURFPlugin_Hypothesis_i::GetPreCADMergeEdges
637  *
638  *  Get true or false
639  */
640 //=============================================================================
641 CORBA::Boolean BLSURFPlugin_Hypothesis_i::GetPreCADMergeEdges() {
642   // MESSAGE("BLSURFPlugin_Hypothesis_i::GetPreCADMergeEdges");
643   ASSERT(myBaseImpl);
644   return this->GetImpl()->GetPreCADMergeEdges();
645 }
646
647 //=============================================================================
648 /*!
649  *  BLSURFPlugin_Hypothesis_i::SetPreCADProcess3DTopology
650  *
651  *  Set true or false
652  */
653 //=============================================================================
654 void BLSURFPlugin_Hypothesis_i::SetPreCADProcess3DTopology(CORBA::Boolean theValue) {
655   // MESSAGE("BLSURFPlugin_Hypothesis_i::SetPreCADProcess3DTopology");
656   ASSERT(myBaseImpl);
657   this->GetImpl()->SetPreCADProcess3DTopology(theValue);
658   std::string theValueStr = theValue ? "True" : "False";
659   SMESH::TPythonDump() << _this() << ".SetPreCADProcess3DTopology( " << theValueStr.c_str() << " )";
660 }
661
662 //=============================================================================
663 /*!
664  *  BLSURFPlugin_Hypothesis_i::GetPreCADProcess3DTopology
665  *
666  *  Get true or false
667  */
668 //=============================================================================
669 CORBA::Boolean BLSURFPlugin_Hypothesis_i::GetPreCADProcess3DTopology() {
670   // MESSAGE("BLSURFPlugin_Hypothesis_i::GetPreCADProcess3DTopology");
671   ASSERT(myBaseImpl);
672   return this->GetImpl()->GetPreCADProcess3DTopology();
673 }
674
675 //=============================================================================
676 /*!
677  *  BLSURFPlugin_Hypothesis_i::SetPreCADDiscardInput
678  *
679  *  Set true or false
680  */
681 //=============================================================================
682 void BLSURFPlugin_Hypothesis_i::SetPreCADDiscardInput(CORBA::Boolean theValue) {
683   // MESSAGE("BLSURFPlugin_Hypothesis_i::SetPreCADDiscardInput");
684   ASSERT(myBaseImpl);
685   this->GetImpl()->SetPreCADDiscardInput(theValue);
686   std::string theValueStr = theValue ? "True" : "False";
687   SMESH::TPythonDump() << _this() << ".SetPreCADDiscardInput( " << theValueStr.c_str() << " )";
688 }
689
690 //=============================================================================
691 /*!
692  *  BLSURFPlugin_Hypothesis_i::GetPreCADDiscardInput
693  *
694  *  Get true or false
695  */
696 //=============================================================================
697 CORBA::Boolean BLSURFPlugin_Hypothesis_i::GetPreCADDiscardInput() {
698   // MESSAGE("BLSURFPlugin_Hypothesis_i::GetPreCADDiscardInput");
699   ASSERT(myBaseImpl);
700   return this->GetImpl()->GetPreCADDiscardInput();
701 }
702
703
704 //=============================================================================
705
706 void BLSURFPlugin_Hypothesis_i::SetOptionValue(const char* optionName, const char* optionValue)
707     throw (SALOME::SALOME_Exception) {
708   ASSERT(myBaseImpl);
709   bool valueChanged = false;
710   try {
711     valueChanged = (this->GetImpl()->GetOptionValue(optionName) != optionValue);
712     if (valueChanged)
713       this->GetImpl()->SetOptionValue(optionName, optionValue);
714   } catch (const std::invalid_argument& ex) {
715     SALOME::ExceptionStruct ExDescription;
716     ExDescription.text = ex.what();
717     ExDescription.type = SALOME::BAD_PARAM;
718     ExDescription.sourceFile = "BLSURFPlugin_Hypothesis::SetOptionValue(name,value)";
719     ExDescription.lineNumber = 0;
720     throw SALOME::SALOME_Exception(ExDescription);
721   } catch (SALOME_Exception& ex) {
722     THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
723   }
724   if (valueChanged)
725     SMESH::TPythonDump() << _this() << ".SetOptionValue( '" << optionName << "', '" << optionValue << "' )";
726 }
727
728 //=============================================================================
729
730 void BLSURFPlugin_Hypothesis_i::SetPreCADOptionValue(const char* optionName, const char* optionValue)
731     throw (SALOME::SALOME_Exception) {
732   ASSERT(myBaseImpl);
733   bool valueChanged = false;
734   try {
735     valueChanged = (this->GetImpl()->GetPreCADOptionValue(optionName) != optionValue);
736     if (valueChanged)
737       this->GetImpl()->SetPreCADOptionValue(optionName, optionValue);
738   } catch (const std::invalid_argument& ex) {
739     SALOME::ExceptionStruct ExDescription;
740     ExDescription.text = ex.what();
741     ExDescription.type = SALOME::BAD_PARAM;
742     ExDescription.sourceFile = "BLSURFPlugin_Hypothesis::SetPreCADOptionValue(name,value)";
743     ExDescription.lineNumber = 0;
744     throw SALOME::SALOME_Exception(ExDescription);
745   } catch (SALOME_Exception& ex) {
746     THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
747   }
748   if (valueChanged)
749     SMESH::TPythonDump() << _this() << ".SetPreCADOptionValue( '" << optionName << "', '" << optionValue << "' )";
750 }
751
752 //=============================================================================
753
754 char* BLSURFPlugin_Hypothesis_i::GetOptionValue(const char* optionName) throw (SALOME::SALOME_Exception) {
755   ASSERT(myBaseImpl);
756   try {
757     return CORBA::string_dup(this->GetImpl()->GetOptionValue(optionName).c_str());
758   } catch (const std::invalid_argument& ex) {
759     SALOME::ExceptionStruct ExDescription;
760     ExDescription.text = ex.what();
761     ExDescription.type = SALOME::BAD_PARAM;
762     ExDescription.sourceFile = "BLSURFPlugin_Hypothesis::GetOptionValue(name)";
763     ExDescription.lineNumber = 0;
764     throw SALOME::SALOME_Exception(ExDescription);
765   } catch (SALOME_Exception& ex) {
766     THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
767   }
768   return 0;
769 }
770
771 //=============================================================================
772
773 char* BLSURFPlugin_Hypothesis_i::GetPreCADOptionValue(const char* optionName) throw (SALOME::SALOME_Exception) {
774   ASSERT(myBaseImpl);
775   try {
776     return CORBA::string_dup(this->GetImpl()->GetPreCADOptionValue(optionName).c_str());
777   } catch (const std::invalid_argument& ex) {
778     SALOME::ExceptionStruct ExDescription;
779     ExDescription.text = ex.what();
780     ExDescription.type = SALOME::BAD_PARAM;
781     ExDescription.sourceFile = "BLSURFPlugin_Hypothesis::GetPreCADOptionValue(name)";
782     ExDescription.lineNumber = 0;
783     throw SALOME::SALOME_Exception(ExDescription);
784   } catch (SALOME_Exception& ex) {
785     THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
786   }
787   return 0;
788 }
789
790 //=============================================================================
791
792 void BLSURFPlugin_Hypothesis_i::UnsetOption(const char* optionName) {
793   ASSERT(myBaseImpl);
794   this->GetImpl()->ClearOption(optionName);
795   SMESH::TPythonDump() << _this() << ".UnsetOption( '" << optionName << "' )";
796 }
797
798 //=============================================================================
799
800 void BLSURFPlugin_Hypothesis_i::UnsetPreCADOption(const char* optionName) {
801   ASSERT(myBaseImpl);
802   this->GetImpl()->ClearPreCADOption(optionName);
803   SMESH::TPythonDump() << _this() << ".UnsetPreCADOption( '" << optionName << "' )";
804 }
805
806 //=============================================================================
807
808 BLSURFPlugin::string_array* BLSURFPlugin_Hypothesis_i::GetOptionValues() {
809   ASSERT(myBaseImpl);
810   BLSURFPlugin::string_array_var result = new BLSURFPlugin::string_array();
811
812   const ::BLSURFPlugin_Hypothesis::TOptionValues & opts = this->GetImpl()->GetOptionValues();
813   result->length(opts.size());
814
815   ::BLSURFPlugin_Hypothesis::TOptionValues::const_iterator opIt = opts.begin();
816   for (int i = 0; opIt != opts.end(); ++opIt, ++i) {
817     string name_value = opIt->first;
818     if (!opIt->second.empty()) {
819       name_value += ":";
820       name_value += opIt->second;
821     }
822     result[i] = CORBA::string_dup(name_value.c_str());
823   }
824   return result._retn();
825 }
826
827 //=============================================================================
828
829 BLSURFPlugin::string_array* BLSURFPlugin_Hypothesis_i::GetPreCADOptionValues() {
830   ASSERT(myBaseImpl);
831   BLSURFPlugin::string_array_var result = new BLSURFPlugin::string_array();
832
833   const ::BLSURFPlugin_Hypothesis::TOptionValues & opts = this->GetImpl()->GetPreCADOptionValues();
834   result->length(opts.size());
835
836   ::BLSURFPlugin_Hypothesis::TOptionValues::const_iterator opIt = opts.begin();
837   for (int i = 0; opIt != opts.end(); ++opIt, ++i) {
838     string name_value = opIt->first;
839     if (!opIt->second.empty()) {
840       name_value += ":";
841       name_value += opIt->second;
842     }
843     result[i] = CORBA::string_dup(name_value.c_str());
844   }
845   return result._retn();
846 }
847
848 //=============================================================================
849
850 void BLSURFPlugin_Hypothesis_i::SetOptionValues(const BLSURFPlugin::string_array& options)
851     throw (SALOME::SALOME_Exception) {
852   ASSERT(myBaseImpl);
853   for (int i = 0; i < options.length(); ++i) {
854     string name_value = options[i].in();
855     int colonPos = name_value.find(':');
856     string name, value;
857     if (colonPos == string::npos) // ':' not found
858       name = name_value;
859     else {
860       name = name_value.substr(0, colonPos);
861       if (colonPos < name_value.size() - 1 && name_value[colonPos] != ' ')
862         value = name_value.substr(colonPos + 1);
863     }
864     SetOptionValue(name.c_str(), value.c_str());
865   }
866 }
867
868 //=============================================================================
869
870 void BLSURFPlugin_Hypothesis_i::SetPreCADOptionValues(const BLSURFPlugin::string_array& options)
871     throw (SALOME::SALOME_Exception) {
872   ASSERT(myBaseImpl);
873   for (int i = 0; i < options.length(); ++i) {
874     string name_value = options[i].in();
875     int colonPos = name_value.find(':');
876     string name, value;
877     if (colonPos == string::npos) // ':' not found
878       name = name_value;
879     else {
880       name = name_value.substr(0, colonPos);
881       if (colonPos < name_value.size() - 1 && name_value[colonPos] != ' ')
882         value = name_value.substr(colonPos + 1);
883     }
884     SetPreCADOptionValue(name.c_str(), value.c_str());
885   }
886 }
887
888 //=============================================================================
889
890 void BLSURFPlugin_Hypothesis_i::SetSizeMapEntry(const char* entry, const char* sizeMap)
891     throw (SALOME::SALOME_Exception) {
892   ASSERT(myBaseImpl);
893   MESSAGE("ENGINE : SETSIZEMAP START ENTRY : " << entry);
894   bool valueChanged = false;
895   try {
896     valueChanged = (this->GetImpl()->GetSizeMapEntry(entry) != sizeMap);
897     if (valueChanged)
898       this->GetImpl()->SetSizeMapEntry(entry, sizeMap);
899   } catch (const std::invalid_argument& ex) {
900     SALOME::ExceptionStruct ExDescription;
901     ExDescription.text = ex.what();
902     ExDescription.type = SALOME::BAD_PARAM;
903     ExDescription.sourceFile = "BLSURFPlugin_Hypothesis::SetSizeMapEntry(entry,sizemap)";
904     ExDescription.lineNumber = 0;
905     throw SALOME::SALOME_Exception(ExDescription);
906   } catch (SALOME_Exception& ex) {
907     THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
908   }
909   MESSAGE("ENGINE : SETSIZEMAP END ENTRY : " << entry);
910   if (valueChanged)
911     SMESH::TPythonDump() << _this() << ".SetSizeMap(" << entry << ", '" << sizeMap << "' )";
912 }
913
914 //=============================================================================
915
916 void BLSURFPlugin_Hypothesis_i::SetConstantSizeMapEntry(const char* entry, GEOM::shape_type shapeType, CORBA::Double sizeMap)
917     throw (SALOME::SALOME_Exception) {
918   ASSERT(myBaseImpl);
919   MESSAGE("ENGINE : SETSIZEMAP START ENTRY : " << entry);
920   bool valueChanged = false;
921   std::ostringstream sizeMapFunction;
922   switch (shapeType) {
923     case GEOM::FACE:   sizeMapFunction << "def f(u,v): return " << sizeMap ; break;
924     case GEOM::EDGE:   sizeMapFunction << "def f(t): return " << sizeMap ; break;
925     case GEOM::VERTEX: sizeMapFunction << "def f(): return " << sizeMap ; break;
926   }
927   try {
928     valueChanged = (this->GetImpl()->GetSizeMapEntry(entry) != sizeMapFunction.str());
929     if (valueChanged)
930       this->GetImpl()->SetSizeMapEntry(entry, sizeMapFunction.str());
931   } catch (const std::invalid_argument& ex) {
932     SALOME::ExceptionStruct ExDescription;
933     ExDescription.text = ex.what();
934     ExDescription.type = SALOME::BAD_PARAM;
935     ExDescription.sourceFile = "BLSURFPlugin_Hypothesis::SetSizeMapEntry(entry,sizemap)";
936     ExDescription.lineNumber = 0;
937     throw SALOME::SALOME_Exception(ExDescription);
938   } catch (SALOME_Exception& ex) {
939     THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
940   }
941   MESSAGE("ENGINE : SETSIZEMAP END ENTRY : " << entry);
942   if (valueChanged)
943     SMESH::TPythonDump() << _this() << ".SetConstantSizeMap(" << entry << ", '" << sizeMap << "' )";
944 }
945
946 //=============================================================================
947
948 void BLSURFPlugin_Hypothesis_i::SetAttractorEntry(const char* entry, const char* attractor)
949     throw (SALOME::SALOME_Exception) {
950   ASSERT(myBaseImpl);
951   MESSAGE("ENGINE : SETATTRACTOR START ENTRY : " << entry);
952   bool valueChanged = false;
953   try {
954     valueChanged = ( this->GetImpl()->GetAttractorEntry(entry) != attractor );
955     if ( valueChanged ) {
956       boost::regex re("^ATTRACTOR\\((?:(-?0(\\.\\d*)*|-?[1-9]+\\d*(\\.\\d*)*|-?\\.(\\d)+);){5}(True|False)(?:;(-?0(\\.\\d*)*|-?[1-9]+\\d*(\\.\\d*)*|-?\\.(\\d)+))?\\)$");
957       if (!boost::regex_match(string(attractor), re))
958         throw std::invalid_argument("Error: an attractor is defined with the following pattern: ATTRACTOR(xa;ya;za;a;b;True|False;d(opt.))");
959       this->GetImpl()->SetAttractorEntry(entry, attractor);
960     }
961   } catch (const std::invalid_argument& ex) {
962     SALOME::ExceptionStruct ExDescription;
963     ExDescription.text = ex.what();
964     ExDescription.type = SALOME::BAD_PARAM;
965     ExDescription.sourceFile = "BLSURFPlugin_Hypothesis::SetAttractorEntry(entry,attractor)";
966     ExDescription.lineNumber = 0;
967     throw SALOME::SALOME_Exception(ExDescription);
968   } catch (SALOME_Exception& ex) {
969     THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
970   }
971   MESSAGE("ENGINE : SETATTRACTOR END ENTRY : " << entry);
972   if (valueChanged)
973     SMESH::TPythonDump() << _this() << ".SetAttractor(" << entry << ", '" << attractor << "' )";
974 }
975
976 //=============================================================================
977
978 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
979   throw (SALOME::SALOME_Exception)
980 {
981   ASSERT(myBaseImpl);
982   MESSAGE("ENGINE : SETATTRACTOR START ENTRY : " << entry);
983   bool valueChanged = false;
984   try {
985     this->GetImpl()->SetClassAttractorEntry(entry, att_entry, StartSize, EndSize, ActionRadius, ConstantRadius);
986   }
987   catch (const std::invalid_argument& ex) {
988     SALOME::ExceptionStruct ExDescription;
989     ExDescription.text = ex.what();
990     ExDescription.type = SALOME::BAD_PARAM;
991     ExDescription.sourceFile = "BLSURFPlugin_Hypothesis::SetClassAttractorEntry(entry, att_entry, StartSize, EndSize, ActionRadius, ConstantRadius)";
992     ExDescription.lineNumber = 0;
993     throw SALOME::SALOME_Exception(ExDescription);
994   } catch (SALOME_Exception& ex) {
995     THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
996   }
997   MESSAGE("ENGINE : SETATTRACTOR END ENTRY : " << entry);
998   //if ( valueChanged )
999   SMESH::TPythonDump() << _this() << ".SetAttractorGeom("
1000                        << entry << ", " << att_entry << ", "<<StartSize<<", "<<EndSize<<", "<<ActionRadius<<", "<<ConstantRadius<<" )";
1001 }
1002
1003 //=============================================================================
1004
1005 char* BLSURFPlugin_Hypothesis_i::GetSizeMapEntry(const char* entry) throw (SALOME::SALOME_Exception) {
1006   ASSERT(myBaseImpl);
1007   try {
1008     return CORBA::string_dup(this->GetImpl()->GetSizeMapEntry(entry).c_str());
1009   } catch (const std::invalid_argument& ex) {
1010     SALOME::ExceptionStruct ExDescription;
1011     ExDescription.text = ex.what();
1012     ExDescription.type = SALOME::BAD_PARAM;
1013     ExDescription.sourceFile = "BLSURFPlugin_Hypothesis::GetSizeMapEntry(name)";
1014     ExDescription.lineNumber = 0;
1015     throw SALOME::SALOME_Exception(ExDescription);
1016   } catch (SALOME_Exception& ex) {
1017     THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
1018   }
1019   return 0;
1020 }
1021
1022 //=============================================================================
1023
1024 char* BLSURFPlugin_Hypothesis_i::GetAttractorEntry(const char* entry) throw (SALOME::SALOME_Exception) {
1025   ASSERT(myBaseImpl);
1026   try {
1027     return CORBA::string_dup(this->GetImpl()->GetAttractorEntry(entry).c_str());
1028   } catch (const std::invalid_argument& ex) {
1029     SALOME::ExceptionStruct ExDescription;
1030     ExDescription.text = ex.what();
1031     ExDescription.type = SALOME::BAD_PARAM;
1032     ExDescription.sourceFile = "BLSURFPlugin_Hypothesis::GetAttractorEntry(name)";
1033     ExDescription.lineNumber = 0;
1034     throw SALOME::SALOME_Exception(ExDescription);
1035   } catch (SALOME_Exception& ex) {
1036     THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
1037   }
1038   return 0;
1039 }
1040
1041 // //=============================================================================
1042 // 
1043 // // TODO coder cette fonction (utilisée pour savoir si la valeur a changé
1044 // // A finir pour le dump
1045 // char* BLSURFPlugin_Hypothesis_i::GetClassAttractorEntry(const char* entry)
1046 //   throw (SALOME::SALOME_Exception)
1047 // {
1048 //   ASSERT(myBaseImpl);
1049 //   try {
1050 //     return CORBA::string_dup( this->GetImpl()->GetClassAttractorEntry(entry).c_str());
1051 //   }
1052 //   catch (const std::invalid_argument& ex) {
1053 //     SALOME::ExceptionStruct ExDescription;
1054 //     ExDescription.text = ex.what();
1055 //     ExDescription.type = SALOME::BAD_PARAM;
1056 //     ExDescription.sourceFile = "BLSURFPlugin_Hypothesis::GetClassAttractorEntry(name)";
1057 //     ExDescription.lineNumber = 0;
1058 //     throw SALOME::SALOME_Exception(ExDescription);
1059 //   }
1060 //   catch (SALOME_Exception& ex) {
1061 //     THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
1062 //   }
1063 //   return 0;
1064 // }
1065
1066 //=============================================================================
1067
1068 void BLSURFPlugin_Hypothesis_i::UnsetEntry(const char* entry) {
1069   ASSERT(myBaseImpl);
1070   this->GetImpl()->ClearEntry(entry);
1071   //  SMESH::TPythonDump() << _this() << ".UnsetSizeMap( " << entry << " )";
1072 }
1073
1074 //=============================================================================
1075
1076 BLSURFPlugin::string_array* BLSURFPlugin_Hypothesis_i::GetSizeMapEntries() {
1077   ASSERT(myBaseImpl);
1078   BLSURFPlugin::string_array_var result = new BLSURFPlugin::string_array();
1079
1080   const ::BLSURFPlugin_Hypothesis::TSizeMap sizeMaps = this->GetImpl()->_GetSizeMapEntries();
1081   result->length(sizeMaps.size());
1082
1083   ::BLSURFPlugin_Hypothesis::TSizeMap::const_iterator smIt = sizeMaps.begin();
1084   for (int i = 0; smIt != sizeMaps.end(); ++smIt, ++i) {
1085     string entry_sizemap = smIt->first;
1086     if (!smIt->second.empty()) {
1087       entry_sizemap += "|";
1088       entry_sizemap += smIt->second;
1089     }
1090     result[i] = CORBA::string_dup(entry_sizemap.c_str());
1091   }
1092   return result._retn();
1093 }
1094
1095 //=============================================================================
1096
1097 BLSURFPlugin::string_array* BLSURFPlugin_Hypothesis_i::GetAttractorEntries() {
1098   ASSERT(myBaseImpl);
1099   BLSURFPlugin::string_array_var result = new BLSURFPlugin::string_array();
1100
1101   const ::BLSURFPlugin_Hypothesis::TSizeMap attractors = this->GetImpl()->_GetAttractorEntries();
1102   result->length(attractors.size());
1103
1104   ::BLSURFPlugin_Hypothesis::TSizeMap::const_iterator atIt = attractors.begin();
1105   for (int i = 0; atIt != attractors.end(); ++atIt, ++i) {
1106     string entry_attractor = atIt->first;
1107     if (!atIt->second.empty()) {
1108       entry_attractor += "|";
1109       entry_attractor += atIt->second;
1110     }
1111     result[i] = CORBA::string_dup(entry_attractor.c_str());
1112   }
1113   return result._retn();
1114 }
1115
1116 //=============================================================================
1117
1118 BLSURFPlugin::TAttParamsMap* BLSURFPlugin_Hypothesis_i::GetAttractorParams()
1119 {
1120   ASSERT(myBaseImpl);
1121   BLSURFPlugin::TAttParamsMap_var result = new BLSURFPlugin::TAttParamsMap();
1122
1123   const ::BLSURFPlugin_Hypothesis::TAttractorMap attractors= this->GetImpl()->_GetClassAttractorEntries();
1124   result->length( attractors.size() );
1125
1126   ::BLSURFPlugin_Hypothesis::TAttractorMap::const_iterator atIt = attractors.begin();
1127   for ( int i = 0 ; atIt != attractors.end(); ++atIt, ++i ) {
1128     string faceEntry = atIt->first;
1129     string attEntry;
1130     double startSize, endSize, infDist, constDist;
1131     if ( !atIt->second->Empty() ) {
1132       attEntry = atIt->second->GetAttractorEntry();
1133       MESSAGE("GetAttractorParams : attEntry ="<<attEntry)
1134       std::vector<double> params = atIt->second->GetParameters();
1135       startSize = params[0];
1136       endSize = params[1];
1137       infDist = params[2];
1138       constDist = params[3];
1139     }
1140     result[i].faceEntry = CORBA::string_dup(faceEntry.c_str());
1141     result[i].attEntry = CORBA::string_dup(attEntry.c_str());
1142     result[i].startSize = startSize;
1143     result[i].endSize = endSize;
1144     result[i].infDist = infDist;
1145     result[i].constDist = constDist;
1146     MESSAGE("GetAttractorParams : result[i].attEntry ="<<result[i].attEntry)
1147     MESSAGE("GetAttractorParams : result[i].faceEntry ="<<result[i].faceEntry)
1148   }
1149   return result._retn();
1150 }
1151
1152 //=============================================================================
1153
1154 void BLSURFPlugin_Hypothesis_i::SetSizeMapEntries(const BLSURFPlugin::string_array& sizeMaps)
1155     throw (SALOME::SALOME_Exception) {
1156   ASSERT(myBaseImpl);
1157   for (int i = 0; i < sizeMaps.length(); ++i) {
1158     string entry_sizemap = sizeMaps[i].in();
1159     int colonPos = entry_sizemap.find('|');
1160     string entry, sizemap;
1161     if (colonPos == string::npos) // '|' separator not found
1162       entry = entry_sizemap;
1163     else {
1164       entry = entry_sizemap.substr(0, colonPos);
1165       if (colonPos < entry_sizemap.size() - 1 && entry_sizemap[colonPos] != ' ')
1166         sizemap = entry_sizemap.substr(colonPos + 1);
1167     }
1168     this->GetImpl()->SetSizeMapEntry(entry.c_str(), sizemap.c_str());
1169   }
1170 }
1171
1172 //=============================================================================
1173
1174 void BLSURFPlugin_Hypothesis_i::ClearSizeMaps() {
1175   ASSERT(myBaseImpl);
1176   this->GetImpl()->ClearSizeMaps();
1177 }
1178
1179 //=============================================================================
1180
1181 void BLSURFPlugin_Hypothesis_i::SetSizeMap(const GEOM::GEOM_Object_ptr GeomObj, const char* sizeMap) {
1182   ASSERT(myBaseImpl);
1183   string entry;
1184   entry = GeomObj->GetStudyEntry();
1185   MESSAGE("IDL : GetName : " << GeomObj->GetName());
1186   MESSAGE("IDL : SETSIZEMAP ( "<< entry << " , " << sizeMap << ")");
1187   SetSizeMapEntry(entry.c_str(), sizeMap);
1188 }
1189
1190 //=============================================================================
1191
1192 void BLSURFPlugin_Hypothesis_i::SetConstantSizeMap(const GEOM::GEOM_Object_ptr GeomObj, CORBA::Double sizeMap) {
1193   ASSERT(myBaseImpl);
1194   string entry = GeomObj->GetStudyEntry();
1195   GEOM::shape_type shapeType = GeomObj->GetShapeType();
1196   if (shapeType == GEOM::COMPOUND)
1197     shapeType = GeomObj->GetMaxShapeType();
1198   MESSAGE("IDL : GetName : " << GeomObj->GetName());
1199   MESSAGE("IDL : SETSIZEMAP ( "<< entry << " , " << sizeMap << ")");
1200   SetConstantSizeMapEntry(entry.c_str(), shapeType, sizeMap);
1201 }
1202
1203 //=============================================================================
1204 void BLSURFPlugin_Hypothesis_i::UnsetSizeMap(const GEOM::GEOM_Object_ptr GeomObj) {
1205   ASSERT(myBaseImpl);
1206   string entry;
1207   entry = GeomObj->GetStudyEntry();
1208   MESSAGE("IDL : GetName : " << GeomObj->GetName());
1209   MESSAGE("IDL : UNSETSIZEMAP ( "<< entry << ")");
1210   UnsetEntry(entry.c_str());
1211   SMESH::TPythonDump() << _this() << ".UnsetSizeMap( " << entry.c_str() << " )";
1212 }
1213
1214 void BLSURFPlugin_Hypothesis_i::SetAttractor(GEOM::GEOM_Object_ptr GeomObj, const char* attractor) {
1215   ASSERT(myBaseImpl);
1216   string entry;
1217   entry = GeomObj->GetStudyEntry();
1218   MESSAGE("IDL : GetName : " << GeomObj->GetName());
1219   MESSAGE("IDL : SETATTRACTOR ( "<< entry << " , " << attractor << ")");
1220   SetAttractorEntry(entry.c_str(), attractor);
1221 }
1222
1223 void BLSURFPlugin_Hypothesis_i::UnsetAttractor(GEOM::GEOM_Object_ptr GeomObj) {
1224   ASSERT(myBaseImpl);
1225   string entry;
1226   entry = GeomObj->GetStudyEntry();
1227   MESSAGE("IDL : GetName : " << GeomObj->GetName());
1228   MESSAGE("IDL : UNSETATTRACTOR ( "<< entry << ")");
1229   UnsetEntry(entry.c_str());
1230   SMESH::TPythonDump() << _this() << ".UnsetAttractor( " << entry.c_str() << " )";
1231 }
1232
1233 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)
1234 {
1235   ASSERT(myBaseImpl);
1236   string theFaceEntry;
1237   string theAttEntry;
1238   theFaceEntry = theFace->GetStudyEntry();
1239   theAttEntry  = theAttractor->GetStudyEntry();
1240   
1241   GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine();
1242   SMESH_Gen_i *smeshGen = SMESH_Gen_i::GetSMESHGen();
1243   string aName;
1244   
1245   if (theFaceEntry.empty()) {
1246     aName = "Face_";
1247     aName += theFace->GetEntry();
1248     SALOMEDS::SObject_wrap theSFace = geomGen->PublishInStudy(smeshGen->GetCurrentStudy(), NULL, theFace, aName.c_str());
1249     if (!theSFace->_is_nil())
1250       theFaceEntry = theSFace->GetID();
1251   }
1252   if (theFaceEntry.empty())
1253     THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM );
1254   
1255   if (theAttEntry.empty()) {
1256     if (theAttractor->GetShapeType() == GEOM::VERTEX)
1257       aName = "Vertex_";
1258     if (theAttractor->GetShapeType() == GEOM::EDGE)
1259       aName = "Edge_";
1260     if (theAttractor->GetShapeType() == GEOM::WIRE)
1261       aName = "Wire_";
1262     if (theAttractor->GetShapeType() == GEOM::COMPOUND)
1263       aName = "Compound_";
1264     aName += theAttractor->GetEntry();
1265     SALOMEDS::SObject_wrap theSAtt = geomGen->PublishInStudy(smeshGen->GetCurrentStudy(), NULL, theAttractor, aName.c_str());
1266     if (!theSAtt->_is_nil())
1267       theAttEntry = theSAtt->GetID();
1268   }
1269   if (theAttEntry.empty())
1270     THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM );
1271   
1272   TopoDS_Face FaceShape = TopoDS::Face(SMESH_Gen_i::GetSMESHGen()->GeomObjectToShape( theFace ));
1273   TopoDS_Shape AttractorShape = SMESH_Gen_i::GetSMESHGen()->GeomObjectToShape( theAttractor );
1274   MESSAGE("IDL : GetName : " << theFace->GetName());
1275   MESSAGE("IDL : SETATTRACTOR () ");//<< entry << " , " << att_entry << ")");
1276   SetClassAttractorEntry( theFaceEntry.c_str(), theAttEntry.c_str(), StartSize, EndSize, ActionRadius, ConstantRadius);
1277 }
1278
1279 void BLSURFPlugin_Hypothesis_i::UnsetAttractorGeom(GEOM::GEOM_Object_ptr theFace)
1280 {
1281   ASSERT(myBaseImpl);
1282   string theFaceEntry;
1283   theFaceEntry = theFace->GetStudyEntry();
1284   
1285   GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine();
1286   SMESH_Gen_i *smeshGen = SMESH_Gen_i::GetSMESHGen();
1287   string aName;
1288   
1289   if (theFaceEntry.empty()) {
1290     aName = "Face_";
1291     aName += theFace->GetEntry();
1292     SALOMEDS::SObject_wrap theSFace = geomGen->PublishInStudy(smeshGen->GetCurrentStudy(), NULL, theFace, aName.c_str());
1293     if (!theSFace->_is_nil())
1294       theFaceEntry = theSFace->GetID();
1295   }
1296   if (theFaceEntry.empty())
1297     THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM );
1298   
1299   MESSAGE("IDL : GetName : " << theFace->GetName());
1300   MESSAGE("IDL : UNSETATTRACTOR ( "<< theFaceEntry << ")");
1301   UnsetEntry( theFaceEntry.c_str());
1302   SMESH::TPythonDump() << _this() << ".UnsetAttractorGeom( " << theFaceEntry.c_str() << " )";
1303 }
1304
1305 /*
1306  void BLSURFPlugin_Hypothesis_i::SetCustomSizeMap(GEOM::GEOM_Object_ptr GeomObj, const char* sizeMap)
1307  {}
1308
1309  void BLSURFPlugin_Hypothesis_i::UnsetCustomSizeMap(GEOM::GEOM_Object_ptr GeomObj)
1310  {}
1311
1312  void BLSURFPlugin_Hypothesis_i::SetCustomSizeMapEntry(const char* entry,const char* sizeMap )  throw (SALOME::SALOME_Exception)
1313  {}
1314
1315  char* BLSURFPlugin_Hypothesis_i::GetCustomSizeMapEntry(const char* entry)  throw (SALOME::SALOME_Exception)
1316  {}
1317
1318  void BLSURFPlugin_Hypothesis_i::UnsetCustomSizeMapEntry(const char* entry)
1319  {
1320  ASSERT(myBaseImpl);
1321  this->GetImpl()->UnsetCustomSizeMap(entry);
1322  SMESH::TPythonDump() << _this() << ".UnsetCustomSizeMap( " << entry << " )";
1323  }
1324
1325
1326  BLSURFPlugin::string_array* BLSURFPlugin_Hypothesis_i::GetCustomSizeMapEntries()
1327  {}
1328
1329  */
1330
1331 // ///////////////////////
1332 // // ENFORCED VERTICES //
1333 // ///////////////////////
1334
1335
1336 /**
1337  * Returns the list of enforced vertices for a given Face entry
1338  * @return A map of Face entry / List of enforced vertices
1339  *
1340  */
1341 BLSURFPlugin::TFaceEntryEnfVertexListMap* BLSURFPlugin_Hypothesis_i::GetAllEnforcedVerticesByFace() {
1342   MESSAGE("IDL: GetAllEnforcedVerticesByFace()");
1343   ASSERT(myBaseImpl);
1344
1345   BLSURFPlugin::TFaceEntryEnfVertexListMap_var resultMap = new BLSURFPlugin::TFaceEntryEnfVertexListMap();
1346
1347   const ::BLSURFPlugin_Hypothesis::TFaceEntryEnfVertexListMap faceEntryEnfVertexListMap =
1348       this->GetImpl()->_GetAllEnforcedVerticesByFace();
1349   resultMap->length(faceEntryEnfVertexListMap.size());
1350   MESSAGE("Face entry to Enforced Vertex map size is " << resultMap->length());
1351
1352   ::BLSURFPlugin_Hypothesis::TEnfVertexList _enfVertexList;
1353   ::BLSURFPlugin_Hypothesis::TFaceEntryEnfVertexListMap::const_iterator it_entry = faceEntryEnfVertexListMap.begin();
1354   for (int i = 0; it_entry != faceEntryEnfVertexListMap.end(); ++it_entry, ++i) {
1355     BLSURFPlugin::TFaceEntryEnfVertexListMapElement_var mapElement =
1356         new BLSURFPlugin::TFaceEntryEnfVertexListMapElement();
1357     mapElement->faceEntry = CORBA::string_dup(it_entry->first.c_str());
1358     MESSAGE("Face Entry: " << mapElement->faceEntry);
1359
1360     _enfVertexList = it_entry->second;
1361     BLSURFPlugin::TEnfVertexList_var enfVertexList = new BLSURFPlugin::TEnfVertexList();
1362     enfVertexList->length(_enfVertexList.size());
1363     MESSAGE("Number of enf vertex: " << enfVertexList->length());
1364
1365     ::BLSURFPlugin_Hypothesis::TEnfVertexList::const_iterator it_enfVertex = _enfVertexList.begin();
1366     ::BLSURFPlugin_Hypothesis::TEnfVertex *currentEnfVertex;
1367     for (int j = 0; it_enfVertex != _enfVertexList.end(); ++it_enfVertex, ++j) {
1368       currentEnfVertex = (*it_enfVertex);
1369
1370       BLSURFPlugin::TEnfVertex_var enfVertex = new BLSURFPlugin::TEnfVertex();
1371
1372       // Name
1373       enfVertex->name = CORBA::string_dup(currentEnfVertex->name.c_str());
1374
1375       // Geom entry
1376       enfVertex->geomEntry = CORBA::string_dup(currentEnfVertex->geomEntry.c_str());
1377
1378       // Coords
1379       BLSURFPlugin::TEnfVertexCoords_var coords = new BLSURFPlugin::TEnfVertexCoords();
1380       coords->length(currentEnfVertex->coords.size());
1381       for (int i=0;i<coords->length();i++)
1382         coords[i] = currentEnfVertex->coords[i];
1383       enfVertex->coords = coords;
1384
1385       // Group name
1386       enfVertex->grpName = CORBA::string_dup(currentEnfVertex->grpName.c_str());
1387       
1388       // Face entry list
1389       BLSURFPlugin::TEntryList_var faceEntryList = new BLSURFPlugin::TEntryList();
1390       faceEntryList->length(currentEnfVertex->faceEntries.size());
1391       ::BLSURFPlugin_Hypothesis::TEntryList::const_iterator it_entry = currentEnfVertex->faceEntries.begin();
1392       for (int ind = 0; it_entry != currentEnfVertex->faceEntries.end();++it_entry, ++ind)
1393         faceEntryList[ind] = CORBA::string_dup((*it_entry).c_str());
1394       enfVertex->faceEntries = faceEntryList;
1395
1396       ostringstream msg;
1397       msg << "Enforced vertex: \n"
1398           << "Name: " << enfVertex->name << "\n";
1399       if (coords->length())
1400           msg << "Coords: " << enfVertex->coords[0] << ", " << enfVertex->coords[1] << ", " << enfVertex->coords[2] << "\n";
1401       msg << "Geom entry: " << enfVertex->geomEntry << "\n"
1402           << "Group Name: " << enfVertex->grpName;
1403       MESSAGE(msg.str());
1404
1405       enfVertexList[j] = enfVertex;
1406     }
1407     mapElement->enfVertexList = enfVertexList;
1408
1409     resultMap[i] = mapElement;
1410
1411   }
1412   return resultMap._retn();
1413 }
1414
1415 /**
1416  * Returns the list of all enforced vertices
1417  * @return a list of enforced vertices
1418  *
1419  */
1420 BLSURFPlugin::TEnfVertexList* BLSURFPlugin_Hypothesis_i::GetAllEnforcedVertices() {
1421   MESSAGE("IDL: GetAllEnforcedVertices()");
1422   ASSERT(myBaseImpl);
1423   BLSURFPlugin::TEnfVertexList_var resultMap = new BLSURFPlugin::TEnfVertexList();
1424   const ::BLSURFPlugin_Hypothesis::TEnfVertexList enfVertexList = this->GetImpl()->_GetAllEnforcedVertices();
1425   resultMap->length(enfVertexList.size());
1426   MESSAGE("Enforced Vertex map size is " << resultMap->length());
1427
1428   ::BLSURFPlugin_Hypothesis::TEnfVertexList::const_iterator evlIt = enfVertexList.begin();
1429   ::BLSURFPlugin_Hypothesis::TEnfVertex *currentEnfVertex;
1430   for (int i = 0; evlIt != enfVertexList.end(); ++evlIt, ++i) {
1431     MESSAGE("Enforced Vertex #" << i);
1432     currentEnfVertex = (*evlIt);
1433     BLSURFPlugin::TEnfVertex_var enfVertex = new BLSURFPlugin::TEnfVertex();
1434     // Name
1435     enfVertex->name = CORBA::string_dup(currentEnfVertex->name.c_str());
1436     // Geom entry
1437     enfVertex->geomEntry = CORBA::string_dup(currentEnfVertex->geomEntry.c_str());
1438     // Coords
1439     BLSURFPlugin::TEnfVertexCoords_var coords = new BLSURFPlugin::TEnfVertexCoords();
1440     coords->length(currentEnfVertex->coords.size());
1441     for (int ind = 0; ind < coords->length(); ind++)
1442       coords[ind] = currentEnfVertex->coords[ind];
1443     enfVertex->coords = coords;
1444     // Group name
1445     enfVertex->grpName = CORBA::string_dup(currentEnfVertex->grpName.c_str());  
1446     // Face entry list
1447     BLSURFPlugin::TEntryList_var faceEntryList = new BLSURFPlugin::TEntryList();
1448     faceEntryList->length(currentEnfVertex->faceEntries.size());
1449     ::BLSURFPlugin_Hypothesis::TEntryList::const_iterator it_entry = currentEnfVertex->faceEntries.begin();
1450     for (int ind = 0; it_entry != currentEnfVertex->faceEntries.end();++it_entry, ++ind)
1451       faceEntryList[ind] = CORBA::string_dup((*it_entry).c_str());
1452     enfVertex->faceEntries = faceEntryList;
1453
1454     ostringstream msg;
1455     msg << "Enforced vertex: \n"
1456         << "Name: " << enfVertex->name << "\n";
1457     if (coords->length())
1458         msg << "Coords: " << enfVertex->coords[0] << ", " << enfVertex->coords[1] << ", " << enfVertex->coords[2] << "\n";
1459     msg << "Geom entry: " << enfVertex->geomEntry << "\n"
1460         << "Group Name: " << enfVertex->grpName;
1461     MESSAGE(msg.str());
1462
1463     resultMap[i] = enfVertex;
1464   }
1465   return resultMap._retn();
1466
1467 }
1468
1469 /**
1470  * Returns the list of enforced vertices coords for a given Face entry.
1471  * They are the coords of the "manual" enforced vertices.
1472  * @return A map of Face entry / List of enforced vertices coords
1473  *
1474  */
1475 BLSURFPlugin::TFaceEntryCoordsListMap* BLSURFPlugin_Hypothesis_i::GetAllCoordsByFace() {
1476   MESSAGE("IDL: GetAllCoordsByFace()");
1477   ASSERT(myBaseImpl);
1478
1479   BLSURFPlugin::TFaceEntryCoordsListMap_var resultMap = new BLSURFPlugin::TFaceEntryCoordsListMap();
1480
1481   const ::BLSURFPlugin_Hypothesis::TFaceEntryCoordsListMap entryCoordsListMap = this->GetImpl()->_GetAllCoordsByFace();
1482   resultMap->length(entryCoordsListMap.size());
1483   MESSAGE("Enforced Vertex map size is " << resultMap->length());
1484
1485   ::BLSURFPlugin_Hypothesis::TEnfVertexCoordsList _coordsList;
1486   ::BLSURFPlugin_Hypothesis::TFaceEntryCoordsListMap::const_iterator it_entry = entryCoordsListMap.begin();
1487   for (int i = 0; it_entry != entryCoordsListMap.end(); ++it_entry, ++i) {
1488     BLSURFPlugin::TFaceEntryCoordsListMapElement_var mapElement = new BLSURFPlugin::TFaceEntryCoordsListMapElement();
1489     mapElement->faceEntry = CORBA::string_dup(it_entry->first.c_str());
1490     MESSAGE("Face Entry: " << mapElement->faceEntry);
1491
1492     _coordsList = it_entry->second;
1493     BLSURFPlugin::TEnfVertexCoordsList_var coordsList = new BLSURFPlugin::TEnfVertexCoordsList();
1494     coordsList->length(_coordsList.size());
1495     MESSAGE("Number of coords: " << coordsList->length());
1496
1497     ::BLSURFPlugin_Hypothesis::TEnfVertexCoordsList::const_iterator it_coords = _coordsList.begin();
1498     for (int j = 0; it_coords != _coordsList.end(); ++it_coords, ++j) {
1499       BLSURFPlugin::TEnfVertexCoords_var coords = new BLSURFPlugin::TEnfVertexCoords();
1500       coords->length((*it_coords).size());
1501       for (int i=0;i<coords->length();i++)
1502         coords[i] = (*it_coords)[i];
1503       coordsList[j] = coords;
1504       MESSAGE("Coords #" << j << ": " << coords[0] << ", " << coords[1] << ", " << coords[2]);
1505     }
1506     mapElement->coordsList = coordsList;
1507
1508     resultMap[i] = mapElement;
1509
1510   }
1511   return resultMap._retn();
1512 }
1513
1514 /**
1515  * Returns a map of enforced vertices coords / enforced vertex.
1516  * They are the coords of the "manual" enforced vertices.
1517  */
1518 BLSURFPlugin::TCoordsEnfVertexMap* BLSURFPlugin_Hypothesis_i::GetAllEnforcedVerticesByCoords() {
1519   MESSAGE("IDL: GetAllEnforcedVerticesByCoords()");
1520   ASSERT(myBaseImpl);
1521
1522   BLSURFPlugin::TCoordsEnfVertexMap_var resultMap = new BLSURFPlugin::TCoordsEnfVertexMap();
1523   const ::BLSURFPlugin_Hypothesis::TCoordsEnfVertexMap coordsEnfVertexMap =
1524       this->GetImpl()->_GetAllEnforcedVerticesByCoords();
1525   resultMap->length(coordsEnfVertexMap.size());
1526   MESSAGE("Enforced Vertex map size is " << resultMap->length());
1527
1528   ::BLSURFPlugin_Hypothesis::TCoordsEnfVertexMap::const_iterator it_coords = coordsEnfVertexMap.begin();
1529   ::BLSURFPlugin_Hypothesis::TEnfVertex *currentEnfVertex;
1530   for (int i = 0; it_coords != coordsEnfVertexMap.end(); ++it_coords, ++i) {
1531     MESSAGE("Enforced Vertex #" << i);
1532     currentEnfVertex = (it_coords->second);
1533     BLSURFPlugin::TCoordsEnfVertexElement_var mapElement = new BLSURFPlugin::TCoordsEnfVertexElement();
1534     BLSURFPlugin::TEnfVertexCoords_var coords = new BLSURFPlugin::TEnfVertexCoords();
1535     coords->length(it_coords->first.size());
1536     for (int ind=0;ind<coords->length();ind++)
1537       coords[ind] = it_coords->first[ind];
1538     mapElement->coords = coords;
1539     MESSAGE("Coords: " << mapElement->coords[0] << ", " << mapElement->coords[1] << ", " << mapElement->coords[2]);
1540
1541     BLSURFPlugin::TEnfVertex_var enfVertex = new BLSURFPlugin::TEnfVertex();
1542     // Name
1543     enfVertex->name = CORBA::string_dup(currentEnfVertex->name.c_str());
1544     // Geom entry
1545     enfVertex->geomEntry = CORBA::string_dup(currentEnfVertex->geomEntry.c_str());
1546     // Coords
1547     BLSURFPlugin::TEnfVertexCoords_var coords2 = new BLSURFPlugin::TEnfVertexCoords();
1548     coords2->length(currentEnfVertex->coords.size());
1549     for (int ind=0;ind<coords2->length();ind++)
1550       coords2[ind] = currentEnfVertex->coords[ind];
1551     enfVertex->coords = coords2;
1552     // Group name
1553     enfVertex->grpName = CORBA::string_dup(currentEnfVertex->grpName.c_str());  
1554     // Face entry list
1555     BLSURFPlugin::TEntryList_var faceEntryList = new BLSURFPlugin::TEntryList();
1556     faceEntryList->length(currentEnfVertex->faceEntries.size());
1557     ::BLSURFPlugin_Hypothesis::TEntryList::const_iterator it_entry = currentEnfVertex->faceEntries.begin();
1558     for (int ind = 0; it_entry != currentEnfVertex->faceEntries.end();++it_entry, ++ind)
1559       faceEntryList[ind] = CORBA::string_dup((*it_entry).c_str());
1560     enfVertex->faceEntries = faceEntryList;
1561       
1562     mapElement->enfVertex = enfVertex;
1563     ostringstream msg;
1564     msg << "Enforced vertex: \n"
1565         << "Name: " << enfVertex->name << "\n";
1566     if (coords->length())
1567         msg << "Coords: " << enfVertex->coords[0] << ", " << enfVertex->coords[1] << ", " << enfVertex->coords[2] << "\n";
1568     msg << "Geom entry: " << enfVertex->geomEntry << "\n"
1569         << "Group Name: " << enfVertex->grpName;
1570     MESSAGE(msg.str());
1571
1572     resultMap[i] = mapElement;
1573   }
1574   return resultMap._retn();
1575 }
1576
1577 /**
1578  * Returns the list of enforced vertices entries for a given Face entry.
1579  * They are the geom entries of the enforced vertices based on geom shape (vertex, compound, group).
1580  * @return A map of Face entry / List of enforced vertices geom entries
1581  *
1582  */
1583 BLSURFPlugin::TFaceEntryEnfVertexEntryListMap* BLSURFPlugin_Hypothesis_i::GetAllEnfVertexEntriesByFace() {
1584   MESSAGE("IDL: GetAllEnfVertexEntriesByFace()");
1585   ASSERT(myBaseImpl);
1586
1587   BLSURFPlugin::TFaceEntryEnfVertexEntryListMap_var resultMap = new BLSURFPlugin::TFaceEntryEnfVertexEntryListMap();
1588
1589   const ::BLSURFPlugin_Hypothesis::TFaceEntryEnfVertexEntryListMap entryEnfVertexEntryListMap =
1590       this->GetImpl()->_GetAllEnfVertexEntriesByFace();
1591   resultMap->length(entryEnfVertexEntryListMap.size());
1592   MESSAGE("Enforced Vertex map size is " << resultMap->length());
1593
1594   ::BLSURFPlugin_Hypothesis::TEntryList _enfVertexEntryList;
1595   ::BLSURFPlugin_Hypothesis::TFaceEntryEnfVertexEntryListMap::const_iterator it_entry =
1596       entryEnfVertexEntryListMap.begin();
1597   for (int i = 0; it_entry != entryEnfVertexEntryListMap.end(); ++it_entry, ++i) {
1598     BLSURFPlugin::TFaceEntryEnfVertexEntryListMapElement_var mapElement =
1599         new BLSURFPlugin::TFaceEntryEnfVertexEntryListMapElement();
1600     mapElement->faceEntry = CORBA::string_dup(it_entry->first.c_str());
1601     MESSAGE("Face Entry: " << mapElement->faceEntry);
1602
1603     _enfVertexEntryList = it_entry->second;
1604     BLSURFPlugin::TEntryList_var enfVertexEntryList = new BLSURFPlugin::TEntryList();
1605     enfVertexEntryList->length(_enfVertexEntryList.size());
1606     MESSAGE("Number of enf vertex entries: " << enfVertexEntryList->length());
1607
1608     ::BLSURFPlugin_Hypothesis::TEntryList::const_iterator it_enfVertexEntry = _enfVertexEntryList.begin();
1609     for (int j = 0; it_enfVertexEntry != _enfVertexEntryList.end(); ++it_enfVertexEntry, ++j) {
1610       enfVertexEntryList[j] = CORBA::string_dup((*it_enfVertexEntry).c_str());
1611       MESSAGE("Enf Vertex Entry #" << j << ": " << enfVertexEntryList[j]);
1612     }
1613     mapElement->enfVertexEntryList = enfVertexEntryList;
1614
1615     resultMap[i] = mapElement;
1616
1617   }
1618   return resultMap._retn();
1619 }
1620
1621 /**
1622  * Returns a map of enforced vertices geom entry / enforced vertex.
1623  * They are the geom entries of the enforced vertices defined with geom shape (vertex, compound, group).
1624  */
1625 BLSURFPlugin::TEnfVertexEntryEnfVertexMap* BLSURFPlugin_Hypothesis_i::GetAllEnforcedVerticesByEnfVertexEntry() {
1626   MESSAGE("IDL: GetAllEnforcedVerticesByEnfVertexEntry()");
1627   ASSERT(myBaseImpl);
1628
1629   BLSURFPlugin::TEnfVertexEntryEnfVertexMap_var resultMap = new BLSURFPlugin::TEnfVertexEntryEnfVertexMap();
1630   const ::BLSURFPlugin_Hypothesis::TEnfVertexEntryEnfVertexMap enfVertexEntryEnfVertexMap =
1631       this->GetImpl()->_GetAllEnforcedVerticesByEnfVertexEntry();
1632   resultMap->length(enfVertexEntryEnfVertexMap.size());
1633   MESSAGE("Enforced Vertex map size is " << resultMap->length());
1634
1635   ::BLSURFPlugin_Hypothesis::TEnfVertexEntryEnfVertexMap::const_iterator it_enfVertexEntry = enfVertexEntryEnfVertexMap.begin();
1636   ::BLSURFPlugin_Hypothesis::TEnfVertex *currentEnfVertex;
1637   for (int i = 0; it_enfVertexEntry != enfVertexEntryEnfVertexMap.end(); ++it_enfVertexEntry, ++i) {
1638     MESSAGE("Enforced Vertex #" << i);
1639     currentEnfVertex = it_enfVertexEntry->second;
1640     BLSURFPlugin::TEnfVertexEntryEnfVertexElement_var mapElement = new BLSURFPlugin::TEnfVertexEntryEnfVertexElement();
1641     mapElement->enfVertexEntry = CORBA::string_dup(it_enfVertexEntry->first.c_str());;
1642     MESSAGE("Enf Vertex Entry #" << i << ": " << mapElement->enfVertexEntry);
1643
1644     BLSURFPlugin::TEnfVertex_var enfVertex = new BLSURFPlugin::TEnfVertex();
1645     // Name
1646     enfVertex->name = CORBA::string_dup(currentEnfVertex->name.c_str());
1647     // Geom entry
1648     enfVertex->geomEntry = CORBA::string_dup(currentEnfVertex->geomEntry.c_str());
1649     // Coords
1650     BLSURFPlugin::TEnfVertexCoords_var coords = new BLSURFPlugin::TEnfVertexCoords();
1651     coords->length(currentEnfVertex->coords.size());
1652     for (int ind=0;ind<coords->length();ind++)
1653       coords[ind] = currentEnfVertex->coords[ind];
1654     enfVertex->coords = coords;
1655     // Group name
1656     enfVertex->grpName = CORBA::string_dup(currentEnfVertex->grpName.c_str());  
1657     // Face entry list
1658     BLSURFPlugin::TEntryList_var faceEntryList = new BLSURFPlugin::TEntryList();
1659     faceEntryList->length(currentEnfVertex->faceEntries.size());
1660     ::BLSURFPlugin_Hypothesis::TEntryList::const_iterator it_entry = currentEnfVertex->faceEntries.begin();
1661     for (int ind = 0; it_entry != currentEnfVertex->faceEntries.end();++it_entry, ++ind)
1662       faceEntryList[ind] = CORBA::string_dup((*it_entry).c_str());
1663     enfVertex->faceEntries = faceEntryList;
1664
1665     ostringstream msg;
1666     msg << "Enforced vertex: \n"
1667         << "Name: " << enfVertex->name << "\n";
1668     if (coords->length())
1669         msg << "Coords: " << enfVertex->coords[0] << ", " << enfVertex->coords[1] << ", " << enfVertex->coords[2] << "\n";
1670     msg << "Geom entry: " << enfVertex->geomEntry << "\n"
1671         << "Group Name: " << enfVertex->grpName;
1672     MESSAGE(msg.str());
1673
1674     mapElement->enfVertex = enfVertex;
1675     resultMap[i] = mapElement;
1676   }
1677   return resultMap._retn();
1678 }
1679
1680 /**
1681  * Erase all enforced vertices
1682  */
1683 void BLSURFPlugin_Hypothesis_i::ClearAllEnforcedVertices() {
1684   ASSERT(myBaseImpl);
1685   this->GetImpl()->ClearAllEnforcedVertices();
1686   SMESH::TPythonDump() << _this() << ".ClearAllEnforcedVertices()";
1687 }
1688
1689 /*!
1690  * Set/get/unset an enforced vertex on face
1691  */
1692 bool BLSURFPlugin_Hypothesis_i::SetEnforcedVertex(GEOM::GEOM_Object_ptr theFace, CORBA::Double x, CORBA::Double y,
1693     CORBA::Double z) throw (SALOME::SALOME_Exception) {
1694   ASSERT(myBaseImpl);
1695
1696   if ((theFace->GetShapeType() != GEOM::FACE) && (theFace->GetShapeType() != GEOM::COMPOUND)) {
1697     MESSAGE("theFace shape type is not FACE or COMPOUND");
1698     THROW_SALOME_CORBA_EXCEPTION("theFace shape type is not FACE or COMPOUND", SALOME::BAD_PARAM);
1699   }
1700
1701   string theFaceEntry = theFace->GetStudyEntry();
1702   
1703   if (theFaceEntry.empty()) {
1704     GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine();
1705     SMESH_Gen_i *smeshGen = SMESH_Gen_i::GetSMESHGen();
1706     string aName;
1707     if (theFace->GetShapeType() == GEOM::FACE)
1708       aName = "Face_";
1709     if (theFace->GetShapeType() == GEOM::COMPOUND)
1710       aName = "Compound_";
1711     aName += theFace->GetEntry();
1712     SALOMEDS::SObject_wrap theSFace = geomGen->PublishInStudy(smeshGen->GetCurrentStudy(), NULL, theFace, aName.c_str());
1713     if (!theSFace->_is_nil())
1714       theFaceEntry = theSFace->GetID();
1715   }
1716   if (theFaceEntry.empty())
1717     THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM );
1718   MESSAGE("IDL : GetName : " << theFace->GetName());
1719   MESSAGE("IDL : SetEnforcedVertex( "<< theFaceEntry << ", " << x << ", " << y << ", " << z << ")");
1720   try {
1721     return SetEnforcedVertexEntry(theFaceEntry.c_str(), x, y, z);
1722   } catch (SALOME_Exception& ex) {
1723     THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
1724   }
1725 }
1726
1727 /*!
1728  * Set/get/unset an enforced vertex with name on face
1729  */
1730 bool BLSURFPlugin_Hypothesis_i::SetEnforcedVertexNamed(GEOM::GEOM_Object_ptr theFace, CORBA::Double x, CORBA::Double y,
1731     CORBA::Double z, const char* theVertexName) throw (SALOME::SALOME_Exception) {
1732   ASSERT(myBaseImpl);
1733
1734   if ((theFace->GetShapeType() != GEOM::FACE) && (theFace->GetShapeType() != GEOM::COMPOUND)) {
1735     MESSAGE("theFace shape type is not FACE or COMPOUND");
1736     THROW_SALOME_CORBA_EXCEPTION("theFace shape type is not FACE or COMPOUND", SALOME::BAD_PARAM);
1737   }
1738
1739   string theFaceEntry = theFace->GetStudyEntry();
1740   
1741   if (theFaceEntry.empty()) {
1742     GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine();
1743     SMESH_Gen_i *smeshGen = SMESH_Gen_i::GetSMESHGen();
1744     string aName;
1745     if (theFace->GetShapeType() == GEOM::FACE)
1746       aName = "Face_";
1747     if (theFace->GetShapeType() == GEOM::COMPOUND)
1748       aName = "Compound_";
1749     aName += theFace->GetEntry();
1750     SALOMEDS::SObject_wrap theSFace = geomGen->PublishInStudy(smeshGen->GetCurrentStudy(), NULL, theFace, aName.c_str());
1751     if (!theSFace->_is_nil())
1752       theFaceEntry = theSFace->GetID();
1753   }
1754   if (theFaceEntry.empty())
1755     THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM );
1756   
1757   MESSAGE("IDL : GetName : " << theFace->GetName());
1758   MESSAGE("IDL : SetEnforcedVertexNamed( "<< theFaceEntry << ", " << x << ", " << y << ", " << z << ", " << theVertexName << ")");
1759   try {
1760     return SetEnforcedVertexEntry(theFaceEntry.c_str(), x, y, z, theVertexName);
1761   } catch (SALOME_Exception& ex) {
1762     THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
1763   }
1764 }
1765
1766 /*!
1767  * Set/get/unset an enforced vertex with geom object on face
1768  */
1769 bool BLSURFPlugin_Hypothesis_i::SetEnforcedVertexGeom(GEOM::GEOM_Object_ptr theFace, GEOM::GEOM_Object_ptr theVertex)
1770     throw (SALOME::SALOME_Exception) {
1771   ASSERT(myBaseImpl);
1772
1773   if ((theFace->GetShapeType() != GEOM::FACE) && (theFace->GetShapeType() != GEOM::COMPOUND)) {
1774     MESSAGE("theFace shape type is not FACE or COMPOUND");
1775     THROW_SALOME_CORBA_EXCEPTION("theFace shape type is not FACE or COMPOUND", SALOME::BAD_PARAM);
1776   }
1777
1778   if ((theVertex->GetShapeType() != GEOM::VERTEX) && (theVertex->GetShapeType() != GEOM::COMPOUND)) {
1779     MESSAGE("theVertex shape type is not VERTEX or COMPOUND");
1780     THROW_SALOME_CORBA_EXCEPTION("theVertex shape type is not VERTEX or COMPOUND", SALOME::BAD_PARAM);
1781   }
1782
1783   //  GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine();
1784   //  GEOM::GEOM_IMeasureOperations_var measureOp = geomGen->GetIMeasureOperations(this->GetImpl()->GetStudyId());
1785   //  if (CORBA::is_nil(measureOp))
1786   //    return false;
1787   //
1788   //  CORBA::Double x, y, z;
1789   //  x = y = z = 0.;
1790   //  measureOp->PointCoordinates(theVertex, x, y, z);
1791
1792   string theFaceEntry = theFace->GetStudyEntry();
1793   string theVertexEntry = theVertex->GetStudyEntry();
1794   
1795   GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine();
1796   SMESH_Gen_i *smeshGen = SMESH_Gen_i::GetSMESHGen();
1797   string aName;
1798   
1799   if (theFaceEntry.empty()) {
1800     if (theFace->GetShapeType() == GEOM::FACE)
1801       aName = "Face_";
1802     if (theFace->GetShapeType() == GEOM::COMPOUND)
1803       aName = "Compound_";
1804     aName += theFace->GetEntry();
1805     SALOMEDS::SObject_wrap theSFace = geomGen->PublishInStudy(smeshGen->GetCurrentStudy(), NULL, theFace, aName.c_str());
1806     if (!theSFace->_is_nil())
1807       theFaceEntry = theSFace->GetID();
1808   }
1809   if (theFaceEntry.empty())
1810     THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM );
1811   
1812   if (theVertexEntry.empty()) {
1813     if (theVertex->GetShapeType() == GEOM::VERTEX)
1814       aName = "Vertex_";
1815     if (theVertex->GetShapeType() == GEOM::COMPOUND)
1816       aName = "Compound_";
1817     aName += theVertex->GetEntry();
1818     SALOMEDS::SObject_wrap theSVertex = geomGen->PublishInStudy(smeshGen->GetCurrentStudy(), NULL, theVertex, aName.c_str());
1819     if (!theSVertex->_is_nil())
1820       theVertexEntry = theSVertex->GetID();
1821   }
1822   if (theVertexEntry.empty())
1823     THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM );
1824
1825   string theVertexName = theVertex->GetName();
1826   MESSAGE("IDL : theFace->GetName : " << theFace->GetName());
1827   MESSAGE("IDL : theVertex->GetName : " << theVertexName);
1828   MESSAGE("IDL : SetEnforcedVertexGeom( "<< theFaceEntry << ", " << theVertexEntry<< ")");
1829   try {
1830     return SetEnforcedVertexEntry(theFaceEntry.c_str(), 0, 0, 0, theVertexName.c_str(), theVertexEntry.c_str());
1831   } catch (SALOME_Exception& ex) {
1832     THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
1833   }
1834 }
1835
1836 /*!
1837  * Set an enforced vertex with group name on face
1838  */
1839 bool BLSURFPlugin_Hypothesis_i::SetEnforcedVertexWithGroup(GEOM::GEOM_Object_ptr theFace, CORBA::Double x, CORBA::Double y, CORBA::Double z, const char* theGroupName)
1840  throw (SALOME::SALOME_Exception)
1841 {
1842   ASSERT(myBaseImpl);
1843
1844   if ((theFace->GetShapeType() != GEOM::FACE) && (theFace->GetShapeType() != GEOM::COMPOUND)) {
1845     MESSAGE("theFace shape type is not FACE or COMPOUND");
1846     THROW_SALOME_CORBA_EXCEPTION("theFace shape type is not FACE or COMPOUND", SALOME::BAD_PARAM);
1847   }
1848
1849   string theFaceEntry = theFace->GetStudyEntry();
1850   
1851   if (theFaceEntry.empty()) {
1852     GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine();
1853     SMESH_Gen_i *smeshGen = SMESH_Gen_i::GetSMESHGen();
1854     string aName;
1855     if (theFace->GetShapeType() == GEOM::FACE)
1856       aName = "Face_";
1857     if (theFace->GetShapeType() == GEOM::COMPOUND)
1858       aName = "Compound_";
1859     aName += theFace->GetEntry();
1860     SALOMEDS::SObject_wrap theSFace = geomGen->PublishInStudy(smeshGen->GetCurrentStudy(), NULL, theFace, aName.c_str());
1861     if (!theSFace->_is_nil())
1862       theFaceEntry = theSFace->GetID();
1863   }
1864   if (theFaceEntry.empty())
1865     THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM );
1866   MESSAGE("IDL : GetName : " << theFace->GetName());
1867   MESSAGE("IDL : SetEnforcedVertexWithGroup( "<< theFaceEntry << ", " << x << ", " << y << ", " << z << ", " << theGroupName << ")");
1868   try {
1869     return SetEnforcedVertexEntry(theFaceEntry.c_str(), x, y, z, "", "", theGroupName);
1870   } catch (SALOME_Exception& ex) {
1871     THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
1872   }
1873 }
1874
1875 /*!
1876  * Set an enforced vertex with name and group name on face
1877  */
1878 bool BLSURFPlugin_Hypothesis_i::SetEnforcedVertexNamedWithGroup(GEOM::GEOM_Object_ptr theFace, CORBA::Double x, CORBA::Double y, CORBA::Double z, 
1879                                                                 const char* theVertexName, const char* theGroupName)
1880  throw (SALOME::SALOME_Exception)
1881 {
1882   ASSERT(myBaseImpl);
1883
1884   if ((theFace->GetShapeType() != GEOM::FACE) && (theFace->GetShapeType() != GEOM::COMPOUND)) {
1885     MESSAGE("theFace shape type is not FACE or COMPOUND");
1886     THROW_SALOME_CORBA_EXCEPTION("theFace shape type is not FACE or COMPOUND", SALOME::BAD_PARAM);
1887   }
1888
1889   string theFaceEntry = theFace->GetStudyEntry();
1890   
1891   if (theFaceEntry.empty()) {
1892     GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine();
1893     SMESH_Gen_i *smeshGen = SMESH_Gen_i::GetSMESHGen();
1894     string aName;
1895     if (theFace->GetShapeType() == GEOM::FACE)
1896       aName = "Face_";
1897     if (theFace->GetShapeType() == GEOM::COMPOUND)
1898       aName = "Compound_";
1899     aName += theFace->GetEntry();
1900     SALOMEDS::SObject_wrap theSFace = geomGen->PublishInStudy(smeshGen->GetCurrentStudy(), NULL, theFace, aName.c_str());
1901     if (!theSFace->_is_nil())
1902       theFaceEntry = theSFace->GetID();
1903   }
1904   if (theFaceEntry.empty())
1905     THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM );
1906   MESSAGE("IDL : GetName : " << theFace->GetName());
1907   MESSAGE("IDL : SetEnforcedVertexNamedWithGroup( "<< theFaceEntry << ", " << x << ", " << y << ", " << z << ", " << theVertexName << ", " << theGroupName << ")");
1908   try {
1909     return SetEnforcedVertexEntry(theFaceEntry.c_str(), x, y, z, theVertexName, "", theGroupName);
1910   } catch (SALOME_Exception& ex) {
1911     THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
1912   }
1913 }
1914
1915 /*!
1916  * Set an enforced vertex with geom entry and group name on face
1917  */
1918 bool BLSURFPlugin_Hypothesis_i::SetEnforcedVertexGeomWithGroup(GEOM::GEOM_Object_ptr theFace, GEOM::GEOM_Object_ptr theVertex, const char* theGroupName)
1919  throw (SALOME::SALOME_Exception)
1920 {
1921   ASSERT(myBaseImpl);
1922
1923   if ((theFace->GetShapeType() != GEOM::FACE) && (theFace->GetShapeType() != GEOM::COMPOUND)) {
1924     MESSAGE("theFace shape type is not FACE or COMPOUND");
1925     THROW_SALOME_CORBA_EXCEPTION("theFace shape type is not FACE or COMPOUND", SALOME::BAD_PARAM);
1926   }
1927
1928   if ((theVertex->GetShapeType() != GEOM::VERTEX) && (theVertex->GetShapeType() != GEOM::COMPOUND)) {
1929     MESSAGE("theVertex shape type is not VERTEX or COMPOUND");
1930     THROW_SALOME_CORBA_EXCEPTION("theVertex shape type is not VERTEX or COMPOUND", SALOME::BAD_PARAM);
1931   }
1932
1933   string theFaceEntry = theFace->GetStudyEntry();
1934   string theVertexEntry = theVertex->GetStudyEntry();
1935   
1936   GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine();
1937   SMESH_Gen_i *smeshGen = SMESH_Gen_i::GetSMESHGen();
1938   string aName;
1939   
1940   if (theFaceEntry.empty()) {
1941     if (theFace->GetShapeType() == GEOM::FACE)
1942       aName = "Face_";
1943     if (theFace->GetShapeType() == GEOM::COMPOUND)
1944       aName = "Compound_";
1945     aName += theFace->GetEntry();
1946     SALOMEDS::SObject_wrap theSFace = geomGen->PublishInStudy(smeshGen->GetCurrentStudy(), NULL, theFace, aName.c_str());
1947     if (!theSFace->_is_nil())
1948       theFaceEntry = theSFace->GetID();
1949   }
1950   if (theFaceEntry.empty())
1951     THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM );
1952   
1953   if (theVertexEntry.empty()) {
1954     if (theVertex->GetShapeType() == GEOM::VERTEX)
1955       aName = "Vertex_";
1956     if (theVertex->GetShapeType() == GEOM::COMPOUND)
1957       aName = "Compound_";
1958     aName += theVertex->GetEntry();
1959     SALOMEDS::SObject_wrap theSVertex = geomGen->PublishInStudy(smeshGen->GetCurrentStudy(), NULL, theVertex, aName.c_str());
1960     if (!theSVertex->_is_nil())
1961       theVertexEntry = theSVertex->GetID();
1962   }
1963   if (theVertexEntry.empty())
1964     THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM );
1965
1966   string theVertexName = theVertex->GetName();
1967   MESSAGE("IDL : theFace->GetName : " << theFace->GetName());
1968   MESSAGE("IDL : theVertex->GetName : " << theVertexName);
1969   MESSAGE("IDL : SetEnforcedVertexGeomWithGroup( "<< theFaceEntry << ", " << theVertexEntry<< ", " << theGroupName<< ")");
1970   try {
1971     return SetEnforcedVertexEntry(theFaceEntry.c_str(), 0, 0, 0, theVertexName.c_str(), theVertexEntry.c_str(), theGroupName);
1972   } catch (SALOME_Exception& ex) {
1973     THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
1974   }
1975 }
1976
1977 //Enable internal enforced vertices on specific face if requested by user
1978 ///*!
1979 // * Are internal enforced vertices used for a face ?
1980 // */
1981 //CORBA::Boolean BLSURFPlugin_Hypothesis_i::GetInternalEnforcedVertex(GEOM::GEOM_Object_ptr theFace)
1982 //    throw (SALOME::SALOME_Exception) {
1983 //  ASSERT(myBaseImpl);
1984
1985 //  if ((theFace->GetShapeType() != GEOM::FACE) && (theFace->GetShapeType() != GEOM::COMPOUND)) {
1986 //    MESSAGE("theFace shape type is not FACE or COMPOUND");
1987 //    THROW_SALOME_CORBA_EXCEPTION("theFace shape type is not FACE or COMPOUND", SALOME::BAD_PARAM);
1988 //  }
1989
1990 //  string theFaceEntry = theFace->GetStudyEntry();
1991   
1992 //  if (theFaceEntry.empty()) {
1993 //    GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine();
1994 //    SMESH_Gen_i *smeshGen = SMESH_Gen_i::GetSMESHGen();
1995 //    string aName;
1996 //    if (theFace->GetShapeType() == GEOM::FACE)
1997 //      aName = "Face_";
1998 //    if (theFace->GetShapeType() == GEOM::COMPOUND)
1999 //      aName = "Compound_";
2000 //    aName += theFace->GetEntry();
2001 //    SALOMEDS::SObject_wrap theSFace = geomGen->PublishInStudy(smeshGen->GetCurrentStudy(), NULL, theFace, aName.c_str());
2002 //    if (!theSFace->_is_nil())
2003 //      theFaceEntry = theSFace->GetID();
2004 //  }
2005 //  if (theFaceEntry.empty())
2006 //    THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM );
2007
2008 //  MESSAGE("IDL : GetName : " << theFace->GetName());
2009 //  MESSAGE("IDL : GetInternalEnforcedVertexEntry ( "<< theFaceEntry << ")");
2010 //  try {
2011 //    return GetInternalEnforcedVertexEntry(theFaceEntry.c_str());
2012 //  } catch (SALOME_Exception& ex) {
2013 //    THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
2014 //  }
2015 //}
2016
2017 /*!
2018  * Get the list of all enforced vertices
2019  */
2020 BLSURFPlugin::TEnfVertexList* BLSURFPlugin_Hypothesis_i::GetEnforcedVertices(GEOM::GEOM_Object_ptr theFace)
2021     throw (SALOME::SALOME_Exception) {
2022   ASSERT(myBaseImpl);
2023
2024   if ((theFace->GetShapeType() != GEOM::FACE) && (theFace->GetShapeType() != GEOM::COMPOUND)) {
2025     MESSAGE("theFace shape type is not FACE or COMPOUND");
2026     THROW_SALOME_CORBA_EXCEPTION("theFace shape type is not FACE or COMPOUND", SALOME::BAD_PARAM);
2027   }
2028
2029   string theFaceEntry = theFace->GetStudyEntry();
2030   
2031   if (theFaceEntry.empty()) {
2032     GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine();
2033     SMESH_Gen_i *smeshGen = SMESH_Gen_i::GetSMESHGen();
2034     string aName;
2035     if (theFace->GetShapeType() == GEOM::FACE)
2036       aName = "Face_";
2037     if (theFace->GetShapeType() == GEOM::COMPOUND)
2038       aName = "Compound_";
2039     aName += theFace->GetEntry();
2040     SALOMEDS::SObject_wrap theSFace = geomGen->PublishInStudy(smeshGen->GetCurrentStudy(), NULL, theFace, aName.c_str());
2041     if (!theSFace->_is_nil())
2042       theFaceEntry = theSFace->GetID();
2043   }
2044   if (theFaceEntry.empty())
2045     THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM );
2046
2047   MESSAGE("IDL : GetName : " << theFace->GetName());
2048   MESSAGE("IDL : GetEnforcedVerticesEntry ( "<< theFaceEntry << ")");
2049   try {
2050     return GetEnforcedVerticesEntry(theFaceEntry.c_str());
2051   } catch (SALOME_Exception& ex) {
2052     THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
2053   }
2054 }
2055
2056 bool BLSURFPlugin_Hypothesis_i::UnsetEnforcedVertex(GEOM::GEOM_Object_ptr theFace, CORBA::Double x, CORBA::Double y,
2057     CORBA::Double z) throw (SALOME::SALOME_Exception) {
2058   ASSERT(myBaseImpl);
2059
2060   if ((theFace->GetShapeType() != GEOM::FACE) && (theFace->GetShapeType() != GEOM::COMPOUND)) {
2061     MESSAGE("theFace shape type is not FACE or COMPOUND");
2062     THROW_SALOME_CORBA_EXCEPTION("theFace shape type is not FACE or COMPOUND", SALOME::BAD_PARAM);
2063   }
2064
2065   string theFaceEntry = theFace->GetStudyEntry();
2066   
2067   if (theFaceEntry.empty()) {
2068     GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine();
2069     SMESH_Gen_i *smeshGen = SMESH_Gen_i::GetSMESHGen();
2070     string aName;
2071     if (theFace->GetShapeType() == GEOM::FACE)
2072       aName = "Face_";
2073     if (theFace->GetShapeType() == GEOM::COMPOUND)
2074       aName = "Compound_";
2075     aName += theFace->GetEntry();
2076     SALOMEDS::SObject_wrap theSFace = geomGen->PublishInStudy(smeshGen->GetCurrentStudy(), NULL, theFace, aName.c_str());
2077     if (!theSFace->_is_nil())
2078       theFaceEntry = theSFace->GetID();
2079   }
2080   if (theFaceEntry.empty())
2081     THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM );
2082   MESSAGE("IDL : GetName : " << theFace->GetName());
2083   MESSAGE("IDL : UnsetEnforcedVertex ( "<< theFaceEntry << ", " << x << ", " << y << ", " << z << ")");
2084
2085   try {
2086     return UnsetEnforcedVertexEntry(theFaceEntry.c_str(), x, y, z);
2087   } catch (SALOME_Exception& ex) {
2088     THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
2089   }
2090 }
2091
2092 bool BLSURFPlugin_Hypothesis_i::UnsetEnforcedVertexGeom(GEOM::GEOM_Object_ptr theFace, GEOM::GEOM_Object_ptr theVertex)
2093     throw (SALOME::SALOME_Exception) {
2094   ASSERT(myBaseImpl);
2095
2096   if ((theFace->GetShapeType() != GEOM::FACE) && (theFace->GetShapeType() != GEOM::COMPOUND)) {
2097     MESSAGE("theFace shape type is not FACE or COMPOUND");
2098     THROW_SALOME_CORBA_EXCEPTION("theFace shape type is not FACE or COMPOUND", SALOME::BAD_PARAM);
2099   }
2100   if ((theVertex->GetShapeType() != GEOM::VERTEX) && (theVertex->GetShapeType() != GEOM::COMPOUND)) {
2101     MESSAGE("theVertex shape type is not VERTEX or COMPOUND");
2102     THROW_SALOME_CORBA_EXCEPTION("theVertex shape type is not VERTEX or COMPOUND", SALOME::BAD_PARAM);
2103   }
2104
2105   //  GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine();
2106   //  GEOM::GEOM_IMeasureOperations_var measureOp = geomGen->GetIMeasureOperations(this->GetImpl()->GetStudyId());
2107   //  if (CORBA::is_nil(measureOp))
2108   //    return false;
2109   //
2110   //  CORBA::Double x, y, z;
2111   //  x = y = z = 0.;
2112   //  measureOp->PointCoordinates(theVertex, x, y, z);
2113
2114   std::string theFaceEntry = theFace->GetStudyEntry();
2115   std::string theVertexEntry = theVertex->GetStudyEntry();
2116   
2117   GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine();
2118   SMESH_Gen_i *smeshGen = SMESH_Gen_i::GetSMESHGen();
2119   string aName;
2120   
2121   if (theFaceEntry.empty()) {
2122     if (theFace->GetShapeType() == GEOM::FACE)
2123       aName = "Face_";
2124     if (theFace->GetShapeType() == GEOM::COMPOUND)
2125       aName = "Compound_";
2126     aName += theFace->GetEntry();
2127     SALOMEDS::SObject_wrap theSFace = geomGen->PublishInStudy(smeshGen->GetCurrentStudy(), NULL, theFace, aName.c_str());
2128     if (!theSFace->_is_nil())
2129       theFaceEntry = theSFace->GetID();
2130   }
2131   if (theFaceEntry.empty())
2132     THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM );
2133   
2134   if (theVertexEntry.empty()) {
2135     if (theVertex->GetShapeType() == GEOM::VERTEX)
2136       aName = "Vertex_";
2137     if (theVertex->GetShapeType() == GEOM::COMPOUND)
2138       aName = "Compound_";
2139     aName += theVertex->GetEntry();
2140     SALOMEDS::SObject_wrap theSVertex = geomGen->PublishInStudy(smeshGen->GetCurrentStudy(), NULL, theVertex, aName.c_str());
2141     if (!theSVertex->_is_nil())
2142       theVertexEntry = theSVertex->GetID();
2143   }
2144   if (theVertexEntry.empty())
2145     THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM );
2146   
2147   MESSAGE("IDL : UnsetEnforcedVertexGeom ( "<< theFaceEntry << ", " << theVertexEntry << ")");
2148
2149   try {
2150     return UnsetEnforcedVertexEntry(theFaceEntry.c_str(), 0, 0, 0, theVertexEntry.c_str());
2151   } catch (SALOME_Exception& ex) {
2152     THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
2153   }
2154 }
2155
2156 bool BLSURFPlugin_Hypothesis_i::UnsetEnforcedVertices(GEOM::GEOM_Object_ptr theFace) throw (SALOME::SALOME_Exception) {
2157   ASSERT(myBaseImpl);
2158
2159   if ((theFace->GetShapeType() != GEOM::FACE) && (theFace->GetShapeType() != GEOM::COMPOUND)) {
2160     MESSAGE("theFace shape type is not FACE or COMPOUND");
2161     THROW_SALOME_CORBA_EXCEPTION("theFace shape type is not FACE or COMPOUND", SALOME::BAD_PARAM);
2162   }
2163
2164   string theFaceEntry = theFace->GetStudyEntry();
2165   
2166   if (theFaceEntry.empty()) {
2167     GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine();
2168     SMESH_Gen_i *smeshGen = SMESH_Gen_i::GetSMESHGen();
2169     string aName;
2170     if (theFace->GetShapeType() == GEOM::FACE)
2171       aName = "Face_";
2172     if (theFace->GetShapeType() == GEOM::COMPOUND)
2173       aName = "Compound_";
2174     aName += theFace->GetEntry();
2175     SALOMEDS::SObject_wrap theSFace = geomGen->PublishInStudy(smeshGen->GetCurrentStudy(), NULL, theFace, aName.c_str());
2176     if (!theSFace->_is_nil())
2177       theFaceEntry = theSFace->GetID();
2178   }
2179   if (theFaceEntry.empty())
2180     THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM );
2181   
2182   MESSAGE("IDL : GetName : " << theFace->GetName());
2183   MESSAGE("IDL : UnsetEnforcedVertices ( "<< theFaceEntry << ")");
2184
2185   try {
2186     return UnsetEnforcedVerticesEntry(theFaceEntry.c_str());
2187   } catch (SALOME_Exception& ex) {
2188     THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
2189   }
2190 }
2191
2192 /*!
2193  * Set/get/unset an enforced vertex on geom object given by entry
2194  */
2195 bool BLSURFPlugin_Hypothesis_i::SetEnforcedVertexEntry(const char* theFaceEntry, CORBA::Double x, CORBA::Double y,
2196     CORBA::Double z, const char* theVertexName, const char* theVertexEntry, const char* theGroupName)
2197     throw (SALOME::SALOME_Exception) {
2198   ASSERT(myBaseImpl);
2199   MESSAGE("IDL : SetEnforcedVertexEntry(" << theFaceEntry << ", " << x << ", " << y << ", " << z << ", \"" << theVertexName << "\", \"" << theVertexEntry << "\", \"" << theGroupName << "\")");
2200   bool newValue = false;
2201   if (string(theVertexEntry).empty()) {
2202     try {
2203       ::BLSURFPlugin_Hypothesis::TEnfVertexCoordsList coordsList =
2204           this->GetImpl()->GetEnfVertexCoordsList(theFaceEntry);
2205       ::BLSURFPlugin_Hypothesis::TEnfVertexCoords coords;
2206       coords.push_back(x);
2207       coords.push_back(y);
2208       coords.push_back(z);
2209       if (coordsList.find(coords) == coordsList.end()) {
2210         MESSAGE("Coords not found: add it in coordsList");
2211         newValue = true;
2212       } else {
2213         MESSAGE("Coords already found, compare names");
2214         ::BLSURFPlugin_Hypothesis::TEnfVertex *enfVertex = this->GetImpl()->GetEnfVertex(coords);
2215         if ((enfVertex->name != theVertexName) || (enfVertex->grpName != theGroupName)) {
2216           MESSAGE("The names are different: update");
2217 //          this->GetImpl()->ClearEnforcedVertex(theFaceEntry, x, y, z);
2218           newValue = true;
2219         }
2220         else {
2221           MESSAGE("The names are identical");
2222         }
2223       }
2224     } catch (const std::invalid_argument& ex) {
2225       // no enforced vertex for entry
2226       MESSAGE("Face entry not found : add it to the list");
2227       newValue = true;
2228     }
2229     if (newValue)
2230       if (string(theVertexName).empty())
2231         if (string(theGroupName).empty())
2232           SMESH::TPythonDump() << _this() << ".SetEnforcedVertex(" << theFaceEntry << ", " << x << ", " << y << ", " << z << ")";
2233         else
2234           SMESH::TPythonDump() << _this() << ".SetEnforcedVertexWithGroup(" << theFaceEntry << ", " << x << ", " << y << ", " << z << ", \"" << theGroupName << "\")";
2235       else
2236         if (string(theGroupName).empty())
2237           SMESH::TPythonDump() << _this() << ".SetEnforcedVertexNamed(" << theFaceEntry << ", " << x << ", " << y << ", " << z << ", \"" << theVertexName << "\")";
2238         else
2239           SMESH::TPythonDump() << _this() << ".SetEnforcedVertexNamedWithGroup(" << theFaceEntry << ", " << x << ", " << y << ", " << z << ", \"" 
2240                                           << theVertexName << "\", \"" << theGroupName << "\")";
2241   } else {
2242     try {
2243       ::BLSURFPlugin_Hypothesis::TEntryList enfVertexEntryList = this->GetImpl()->GetEnfVertexEntryList(theFaceEntry);
2244       ::BLSURFPlugin_Hypothesis::TEntryList::const_iterator it = enfVertexEntryList.find(theVertexEntry);
2245       if ( it == enfVertexEntryList.end()) {
2246         MESSAGE("Geom entry not found: add it in enfVertexEntryList");
2247         newValue = true;
2248       }
2249       else {
2250         MESSAGE("Geom entry already found, compare names");
2251         ::BLSURFPlugin_Hypothesis::TEnfVertex *enfVertex = this->GetImpl()->GetEnfVertex((*it));
2252         if ((enfVertex->name != theVertexName) || (enfVertex->grpName != theGroupName)) {
2253           MESSAGE("The names are different: update");
2254 //          this->GetImpl()->ClearEnforcedVertex(theFaceEntry, x, y, z);
2255           newValue = true;
2256         }
2257         else {
2258           MESSAGE("The names are identical");
2259         }
2260       }
2261     } catch (const std::invalid_argument& ex) {
2262       // no enforced vertex for entry
2263       MESSAGE("Face entry not found : add it to the list");
2264       newValue = true;
2265     }
2266     if (newValue)
2267         if (string(theGroupName).empty())
2268           SMESH::TPythonDump() << _this() << ".SetEnforcedVertexGeom(" << theFaceEntry << ", " << theVertexEntry << ")";
2269         else
2270           SMESH::TPythonDump() << _this() << ".SetEnforcedVertexGeomWithGroup(" << theFaceEntry << ", " << theVertexEntry << ", \"" << theGroupName << "\")";
2271   }
2272
2273   if (newValue)
2274     this->GetImpl()->SetEnforcedVertex(theFaceEntry, theVertexName, theVertexEntry, theGroupName, x, y, z);
2275
2276   MESSAGE("IDL : SetEnforcedVertexEntry END");
2277   return newValue;
2278 }
2279
2280 //Enable internal enforced vertices on specific face if requested by user
2281 //CORBA::Boolean BLSURFPlugin_Hypothesis_i::GetInternalEnforcedVertexEntry(const char* theFaceEntry)
2282 //    throw (SALOME::SALOME_Exception) {
2283 //  ASSERT(myBaseImpl);
2284 //  try {
2285 //    return this->GetImpl()->GetInternalEnforcedVertex(theFaceEntry);
2286 //  } catch (const std::exception& ex) {
2287 //    std::cout << "Exception: " << ex.what() << std::endl;
2288 //    THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
2289 //  }
2290 //}
2291   
2292 BLSURFPlugin::TEnfVertexList* BLSURFPlugin_Hypothesis_i::GetEnforcedVerticesEntry(const char* entry)
2293     throw (SALOME::SALOME_Exception) {
2294   ASSERT(myBaseImpl);
2295   MESSAGE("ENGINE : GetEnforcedVerticesEntry START ENTRY : " << entry);
2296
2297   try {
2298     BLSURFPlugin::TEnfVertexList_var vertexList = new BLSURFPlugin::TEnfVertexList();
2299     ::BLSURFPlugin_Hypothesis::TEnfVertexList _vList = this->GetImpl()->GetEnfVertexList(entry);
2300     vertexList->length(_vList.size());
2301     MESSAGE("Number of enforced vertices: " << vertexList->length());
2302     ::BLSURFPlugin_Hypothesis::TEnfVertexList::const_iterator evlIt = _vList.begin();
2303     for (int i = 0; evlIt != _vList.end(); ++evlIt, ++i) {
2304       ::BLSURFPlugin_Hypothesis::TEnfVertex *_enfVertex = (*evlIt);
2305
2306       BLSURFPlugin::TEnfVertex_var enfVertex = new BLSURFPlugin::TEnfVertex();
2307
2308       // Name
2309       enfVertex->name = CORBA::string_dup(_enfVertex->name.c_str());
2310       // Geom Vertex Entry
2311       enfVertex->geomEntry = CORBA::string_dup(_enfVertex->geomEntry.c_str());
2312       // Coords
2313       BLSURFPlugin::TEnfVertexCoords_var coords = new BLSURFPlugin::TEnfVertexCoords();
2314       coords->length(_enfVertex->coords.size());
2315       for (int ind=0;ind<coords->length();ind++)
2316         coords[ind] = _enfVertex->coords[ind];
2317       enfVertex->coords = coords;
2318       // Group Name
2319       enfVertex->grpName = CORBA::string_dup(_enfVertex->grpName.c_str());
2320       // Face entry list
2321       BLSURFPlugin::TEntryList_var faceEntryList = new BLSURFPlugin::TEntryList();
2322       faceEntryList->length(_enfVertex->faceEntries.size());
2323       ::BLSURFPlugin_Hypothesis::TEntryList::const_iterator it_entry = _enfVertex->faceEntries.begin();
2324       for (int ind = 0; it_entry != _enfVertex->faceEntries.end();++it_entry, ++ind)
2325         faceEntryList[ind] = CORBA::string_dup((*it_entry).c_str());
2326       enfVertex->faceEntries = faceEntryList;
2327
2328       vertexList[i] = enfVertex;
2329     }
2330     MESSAGE("ENGINE : GetEnforcedVerticesEntry END ENTRY : " << entry);
2331     return vertexList._retn();
2332   } catch (const std::invalid_argument& ex) {
2333     SALOME::ExceptionStruct ExDescription;
2334     ExDescription.text = ex.what();
2335     ExDescription.type = SALOME::BAD_PARAM;
2336     ExDescription.sourceFile = "BLSURFPlugin_Hypothesis_i::GetEnforcedVerticesEntry(entry)";
2337     ExDescription.lineNumber = 1385;
2338     throw SALOME::SALOME_Exception(ExDescription);
2339   } catch (const std::exception& ex) {
2340     std::cout << "Exception: " << ex.what() << std::endl;
2341     THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
2342   }
2343 }
2344
2345 bool BLSURFPlugin_Hypothesis_i::UnsetEnforcedVertexEntry(const char* theFaceEntry, CORBA::Double x, CORBA::Double y,
2346     CORBA::Double z, const char* theVertexEntry) throw (SALOME::SALOME_Exception) {
2347   ASSERT(myBaseImpl);
2348   MESSAGE("IDL : UnsetEnforcedVertexEntry(" << theFaceEntry << "," << x << "," << y << "," << z << ", " << theVertexEntry << ")");
2349
2350   bool res = false;
2351   try {
2352     res = this->GetImpl()->ClearEnforcedVertex(theFaceEntry, x, y, z, theVertexEntry);
2353
2354     if (string(theVertexEntry).empty())
2355       SMESH::TPythonDump() << "isDone = " << _this() << ".UnsetEnforcedVertex(" << theFaceEntry << ", " << x << ", " << y << ", " << z
2356           << ")";
2357     else
2358       SMESH::TPythonDump() << "isDone = " << _this() << ".UnsetEnforcedVertexGeom(" << theFaceEntry << ", " << theVertexEntry << ")";
2359
2360   } catch (const std::invalid_argument& ex) {
2361     return false;
2362   } catch (const std::exception& ex) {
2363     std::cout << "Exception: " << ex.what() << std::endl;
2364     THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
2365   }
2366
2367   MESSAGE("ENGINE : UnsetEnforcedVertexEntry END ENTRY : " << theFaceEntry);
2368   return res;
2369 }
2370
2371 //bool BLSURFPlugin_Hypothesis_i::UnsetEnforcedVertexEntryWithPoint(const char* theFaceEntry, const char* theVertexEntry,
2372 //    CORBA::Double x, CORBA::Double y, CORBA::Double z) throw (SALOME::SALOME_Exception) {
2373 //  MESSAGE("IDL : UnsetEnforcedVertexEntryWithPoint START theFaceEntry=" << theFaceEntry << ", theVertexEntry=" << theVertexEntry);
2374 //
2375 //  bool ret = false;
2376 //
2377 //  try {
2378 //    ret = _unsetEnfVertex(theFaceEntry, x, y, z);
2379 //  } catch (SALOME_Exception& ex) {
2380 //    THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
2381 //  }
2382 //
2383 //  if (ret)
2384 //    SMESH::TPythonDump() << _this() << ".UnsetEnforcedVertexWithPoint(" << theFaceEntry << ", " << theVertexEntry
2385 //        << ")";
2386 //
2387 //  MESSAGE("IDL : UnsetEnforcedVertexEntryWithPoint END ENTRY : " << theFaceEntry);
2388 //  return ret;
2389 //}
2390
2391 bool BLSURFPlugin_Hypothesis_i::UnsetEnforcedVerticesEntry(const char* theFaceEntry) throw (SALOME::SALOME_Exception) {
2392   ASSERT(myBaseImpl);
2393   MESSAGE("IDL : UnsetEnforcedVerticesEntry(" << theFaceEntry << ")");
2394
2395   try {
2396     this->GetImpl()->ClearEnforcedVertices(theFaceEntry);
2397     SMESH::TPythonDump() << _this() << ".UnsetEnforcedVertices(" << theFaceEntry << ")";
2398   } catch (const std::invalid_argument& ex) {
2399     return false;
2400   } catch (const std::exception& ex) {
2401     THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
2402   }
2403
2404   MESSAGE("IDL : UnsetEnforcedVerticesEntry END ENTRY : " << theFaceEntry);
2405   return true;
2406 }
2407
2408 //=============================================================================
2409 /*!
2410  *  BLSURFPlugin_Hypothesis_i::SetInternalEnforcedVertexAllFaces
2411  *
2412  *  Set true or false
2413  */
2414 //=============================================================================
2415 void BLSURFPlugin_Hypothesis_i::SetInternalEnforcedVertexAllFaces(CORBA::Boolean theValue) {
2416   MESSAGE("BLSURFPlugin_Hypothesis_i::SetInternalEnforcedVertexAllFaces");
2417   ASSERT(myBaseImpl);
2418   this->GetImpl()->SetInternalEnforcedVertexAllFaces(theValue);
2419   std::string theValueStr = theValue ? "True" : "False";
2420   SMESH::TPythonDump() << _this() << ".SetInternalEnforcedVertexAllFaces( " << theValueStr.c_str() << " )";
2421 }
2422
2423 //=============================================================================
2424 /*!
2425  *  BLSURFPlugin_Hypothesis_i::GetInternalEnforcedVertexAllFaces
2426  *
2427  *  Get true or false
2428  */
2429 //=============================================================================
2430 CORBA::Boolean BLSURFPlugin_Hypothesis_i::GetInternalEnforcedVertexAllFaces() {
2431   MESSAGE("BLSURFPlugin_Hypothesis_i::GetInternalEnforcedVertexAllFaces");
2432   ASSERT(myBaseImpl);
2433   return this->GetImpl()->_GetInternalEnforcedVertexAllFaces();
2434 }
2435
2436 //=============================================================================
2437 /*!
2438  *  BLSURFPlugin_Hypothesis_i::SetInternalEnforcedVertexAllFacesGroup
2439  *
2440  *  Set group name
2441  */
2442 //=============================================================================
2443 void BLSURFPlugin_Hypothesis_i::SetInternalEnforcedVertexAllFacesGroup(const char*  groupName) {
2444   MESSAGE("BLSURFPlugin_Hypothesis_i::SetInternalEnforcedVertexAllFacesGroup");
2445   ASSERT(myBaseImpl);
2446   this->GetImpl()->SetInternalEnforcedVertexAllFacesGroup(groupName);
2447   SMESH::TPythonDump() << _this() << ".SetInternalEnforcedVertexAllFacesGroup( \"" << groupName << "\" )";
2448 }
2449
2450 //=============================================================================
2451 /*!
2452  *  BLSURFPlugin_Hypothesis_i::GetInternalEnforcedVertexAllFacesGroup
2453  *
2454  *  Get group name
2455  */
2456 //=============================================================================
2457 char* BLSURFPlugin_Hypothesis_i::GetInternalEnforcedVertexAllFacesGroup() {
2458   MESSAGE("BLSURFPlugin_Hypothesis_i::GetInternalEnforcedVertexAllFacesGroup");
2459   ASSERT(myBaseImpl);
2460   return CORBA::string_dup(this->GetImpl()->_GetInternalEnforcedVertexAllFacesGroup().c_str());
2461 }
2462
2463 /*
2464  * Enable internal enforced vertices on specific face if requested by user
2465  *
2466 void BLSURFPlugin_Hypothesis_i::SetInternalEnforcedVertex(GEOM::GEOM_Object_ptr theFace, CORBA::Boolean toEnforceInternalVertices)
2467  throw (SALOME::SALOME_Exception)
2468 {
2469   MESSAGE("BLSURFPlugin_Hypothesis_i::SetInternalEnforcedVertexForFace");
2470   try {
2471     SetInternalEnforcedVertexWithGroup(theFace, toEnforceInternalVertices);
2472   } catch (SALOME_Exception& ex) {
2473     THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
2474   }
2475 }
2476
2477 void BLSURFPlugin_Hypothesis_i::SetInternalEnforcedVertexWithGroup(GEOM::GEOM_Object_ptr theFace, CORBA::Boolean toEnforceInternalVertices, const char* theGroupName)
2478  throw (SALOME::SALOME_Exception)
2479 {
2480   MESSAGE("BLSURFPlugin_Hypothesis_i::SetInternalEnforcedVertexForFaceWithGroup");
2481
2482   if ((theFace->GetShapeType() != GEOM::FACE) && (theFace->GetShapeType() != GEOM::COMPOUND)) {
2483     MESSAGE("theFace shape type is not FACE or COMPOUND");
2484     THROW_SALOME_CORBA_EXCEPTION("theFace shape type is not FACE or COMPOUND", SALOME::BAD_PARAM);
2485   }
2486
2487   string theFaceEntry = theFace->GetStudyEntry();
2488
2489   if (theFaceEntry.empty()) {
2490     GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine();
2491     SMESH_Gen_i *smeshGen = SMESH_Gen_i::GetSMESHGen();
2492     string aName;
2493     if (theFace->GetShapeType() == GEOM::FACE)
2494       aName = "Face_";
2495     if (theFace->GetShapeType() == GEOM::COMPOUND)
2496       aName = "Compound_";
2497     aName += theFace->GetEntry();
2498     SALOMEDS::SObject_wrap theSFace = geomGen->PublishInStudy(smeshGen->GetCurrentStudy(), NULL, theFace, aName.c_str());
2499     if (!theSFace->_is_nil())
2500       theFaceEntry = theSFace->GetID();
2501   }
2502   if (theFaceEntry.empty())
2503     THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM );
2504
2505   MESSAGE("IDL : GetName : " << theFace->GetName());
2506   MESSAGE("IDL : GetInternalEnforcedVertexEntry ( "<< theFaceEntry << ")");
2507   try {
2508     SetInternalEnforcedVertexEntry(theFaceEntry.c_str(), toEnforceInternalVertices, theGroupName);
2509   } catch (SALOME_Exception& ex) {
2510     THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
2511   }
2512 }
2513
2514 void BLSURFPlugin_Hypothesis_i::SetInternalEnforcedVertexEntry(const char* theFaceEntry, CORBA::Boolean toEnforceInternalVertices, const char* theGroupName)
2515     throw (SALOME::SALOME_Exception)
2516 {
2517   MESSAGE("BLSURFPlugin_Hypothesis_i::SetInternalEnforcedVertexForFaceEntry");
2518   ASSERT(myBaseImpl);
2519   try {
2520     this->GetImpl()->SetInternalEnforcedVertex(theFaceEntry, toEnforceInternalVertices, theGroupName);
2521     std::string theValueStr = toEnforceInternalVertices ? "True" : "False";
2522     if (string(theGroupName).empty())
2523       SMESH::TPythonDump() << _this() << ".SetInternalEnforcedVertex( " << theFaceEntry << ", " << theValueStr.c_str() << " )";
2524     else
2525       SMESH::TPythonDump() << _this() << ".SetInternalEnforcedVertexWithGroup( " << theFaceEntry << ", " << theValueStr.c_str() << ", \"" << theGroupName << "\" )";
2526   } catch (const std::exception& ex) {
2527     std::cout << "Exception: " << ex.what() << std::endl;
2528     THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
2529   }
2530 }
2531
2532 */
2533
2534 /* TODO GROUPS
2535  char* BLSURFPlugin_Hypothesis_i::GetEnforcedVertexGroupName(CORBA::Double x, CORBA::Double y, CORBA::Double z)
2536  throw (SALOME::SALOME_Exception)
2537  {
2538  ASSERT(myBaseImpl);
2539  MESSAGE("ENGINE : GetEnforcedVertexGroupName START ");
2540  try {
2541  return CORBA::string_dup( this->GetImpl()->GetEnforcedVertexGroupName(x, y, z).c_str());
2542  }
2543  catch (const std::invalid_argument& ex) {
2544  SALOME::ExceptionStruct ExDescription;
2545  ExDescription.text = ex.what();
2546  ExDescription.type = SALOME::BAD_PARAM;
2547  ExDescription.sourceFile = "BLSURFPlugin_Hypothesis_i::GetEnforcedVertexGroupName(entry)";
2548  ExDescription.lineNumber = 1146;
2549  throw SALOME::SALOME_Exception(ExDescription);
2550  }
2551  catch (SALOME_Exception& ex) {
2552  THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
2553  }
2554  MESSAGE("ENGINE : GetEnforcedVertexGroupName END ");
2555  return 0;
2556  }
2557
2558
2559  void BLSURFPlugin_Hypothesis_i::SetEnforcedVertexGroupName(CORBA::Double x, CORBA::Double y, CORBA::Double z, const char* groupName)
2560  throw (SALOME::SALOME_Exception)
2561  {
2562  ASSERT(myBaseImpl);
2563  MESSAGE("ENGINE : SetEnforcedVertexGroupName START ");
2564  try {
2565  this->GetImpl()->SetEnforcedVertexGroupName(x, y, z, groupName);
2566  }
2567  catch (const std::invalid_argument& ex) {
2568  SALOME::ExceptionStruct ExDescription;
2569  ExDescription.text = ex.what();
2570  ExDescription.type = SALOME::BAD_PARAM;
2571  ExDescription.sourceFile = "BLSURFPlugin_Hypothesis::SetEnforcedVertexGroupName(x,y,z)";
2572  ExDescription.lineNumber = 1170;
2573  throw SALOME::SALOME_Exception(ExDescription);
2574  }
2575  catch (SALOME_Exception& ex) {
2576  THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
2577  }
2578
2579  SMESH::TPythonDump() << _this() << ".SetEnforcedVertexGroupName("
2580  << x << ", " << y << ", " << z << ", '" << groupName << "' )";
2581
2582  MESSAGE("ENGINE : SetEnforcedVertexGroupName END ");
2583  }
2584  */
2585 ///////////////////////
2586
2587 ///////////////////////
2588 // PERIODICITY       //
2589 ///////////////////////
2590
2591
2592 std::string BLSURFPlugin_Hypothesis_i::ShapeTypeToString(GEOM::shape_type theShapeType)
2593 {
2594 //enum shape_type { COMPOUND, COMPSOLID, SOLID, SHELL, FACE, WIRE, EDGE, VERTEX, SHAPE /*, __max_shape_type=0xffffffff */ };
2595   std::map<GEOM::shape_type, std::string> MapShapeTypeToString;
2596   MapShapeTypeToString[GEOM::COMPOUND] = std::string("COMPOUND");
2597   MapShapeTypeToString[GEOM::COMPSOLID] = std::string("COMPSOLID");
2598   MapShapeTypeToString[GEOM::SOLID] = std::string("SOLID");
2599   MapShapeTypeToString[GEOM::SHELL] = std::string("SHELL");
2600   MapShapeTypeToString[GEOM::FACE] = std::string("FACE");
2601   MapShapeTypeToString[GEOM::WIRE] = std::string("WIRE");
2602   MapShapeTypeToString[GEOM::EDGE] = std::string("EDGE");
2603   MapShapeTypeToString[GEOM::VERTEX] = std::string("VERTEX");
2604   MapShapeTypeToString[GEOM::SHAPE] = std::string("SHAPE");
2605   std::string txtShapeType = MapShapeTypeToString[theShapeType];
2606   return txtShapeType;
2607 }
2608
2609 void BLSURFPlugin_Hypothesis_i::CheckShapeTypes(GEOM::GEOM_Object_ptr shape, std::vector<GEOM::shape_type> theShapeTypes)
2610 {
2611   // Check shape types
2612   bool ok = false;
2613   std::stringstream typesTxt;
2614   for (std::size_t i=0; i<theShapeTypes.size(); i++)
2615     {
2616       GEOM::shape_type theShapeType = theShapeTypes[i];
2617       if (shape->GetShapeType() == theShapeType)
2618         ok = true;
2619       typesTxt << ShapeTypeToString(theShapeType);
2620       if (i < theShapeTypes.size()-1 )
2621         typesTxt << ", ";
2622     }
2623   if (!ok){
2624     std::stringstream msg;
2625     msg << "shape shape type is not in" << typesTxt;
2626     MESSAGE(msg);
2627     THROW_SALOME_CORBA_EXCEPTION(msg.str().c_str(), SALOME::BAD_PARAM);
2628   }
2629 }
2630
2631 void BLSURFPlugin_Hypothesis_i::CheckShapeType(GEOM::GEOM_Object_ptr shape, GEOM::shape_type theShapeType)
2632 {
2633   // Check shape type
2634   if (shape->GetShapeType() != theShapeType) {
2635     std::stringstream msg;
2636     msg << "shape shape type is not " << ShapeTypeToString(theShapeType);
2637     MESSAGE(msg);
2638     THROW_SALOME_CORBA_EXCEPTION(msg.str().c_str(), SALOME::BAD_PARAM);
2639   }
2640 }
2641
2642 std::string BLSURFPlugin_Hypothesis_i::PublishIfNeeded(GEOM::GEOM_Object_ptr shape, GEOM::shape_type theShapeType, std::string prefix)
2643 {
2644   // Check shape is published in the object browser
2645   string shapeEntry = shape->GetStudyEntry();
2646
2647   GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine();
2648   SMESH_Gen_i *smeshGen = SMESH_Gen_i::GetSMESHGen();
2649   string aName;
2650
2651   // Publish shape if needed
2652   if (shapeEntry.empty()) {
2653     if (shape->GetShapeType() == theShapeType)
2654       aName = prefix;
2655     aName += shape->GetEntry();
2656     SALOMEDS::SObject_wrap theSFace1 = geomGen->PublishInStudy(smeshGen->GetCurrentStudy(), NULL, shape, aName.c_str());
2657     if (!theSFace1->_is_nil())
2658       shapeEntry = theSFace1->GetID();
2659   }
2660   if (shapeEntry.empty())
2661     THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM );
2662   return shapeEntry;
2663 }
2664
2665 // Format the output of two vectors to use it in MESSAGE and PythonDump
2666 std::string BLSURFPlugin_Hypothesis_i::FormatVerticesEntries(vector<string> &theSourceVerticesEntries, vector<string> &theTargetVerticesEntries)
2667 {
2668   std::stringstream listEntriesTxt;
2669
2670   if (!theSourceVerticesEntries.empty())
2671     {
2672       listEntriesTxt << ", [" ;
2673       for (size_t i = 0; i<theSourceVerticesEntries.size(); i++)
2674         {
2675           if (i>0)
2676             listEntriesTxt << ", ";
2677           listEntriesTxt << theSourceVerticesEntries[i];
2678         }
2679
2680       listEntriesTxt << "], [" ;
2681       for (size_t i = 0; i<theTargetVerticesEntries.size(); i++)
2682         {
2683           if (i>0)
2684             listEntriesTxt << ", ";
2685           listEntriesTxt << theTargetVerticesEntries[i];
2686         }
2687       listEntriesTxt << "]" ;
2688     }
2689   return listEntriesTxt.str();
2690 }
2691
2692
2693 void BLSURFPlugin_Hypothesis_i::AddPreCadFacesPeriodicity(GEOM::GEOM_Object_ptr theFace1, GEOM::GEOM_Object_ptr theFace2)
2694 throw (SALOME::SALOME_Exception)
2695 {
2696   ASSERT(myBaseImpl);
2697   const GEOM::ListOfGO theSourceVertices;
2698   const GEOM::ListOfGO theTargetVertices;
2699   AddPreCadFacesPeriodicityWithVertices(theFace1, theFace2, theSourceVertices, theTargetVertices);
2700 }
2701
2702
2703 void BLSURFPlugin_Hypothesis_i::AddPreCadFacesPeriodicityWithVertices(GEOM::GEOM_Object_ptr theFace1, GEOM::GEOM_Object_ptr theFace2,
2704     const GEOM::ListOfGO& theSourceVertices, const GEOM::ListOfGO& theTargetVertices)
2705 throw (SALOME::SALOME_Exception)
2706 {
2707   ASSERT(myBaseImpl);
2708
2709   size_t theLength = theSourceVertices.length();
2710   if (theLength != theTargetVertices.length())
2711     THROW_SALOME_CORBA_EXCEPTION( "The sizes of theSourceVertices and theTargetVertices must be the same" ,SALOME::BAD_PARAM );
2712
2713   std::vector<GEOM::shape_type> allowedShapeTypes;
2714   allowedShapeTypes.push_back(GEOM::FACE);
2715   allowedShapeTypes.push_back(GEOM::COMPOUND);
2716
2717   string prefix1 = "Source_face_";
2718   CheckShapeTypes(theFace1, allowedShapeTypes);
2719   string theFace1Entry = PublishIfNeeded(theFace1, GEOM::FACE, prefix1);
2720
2721   string prefix2 = "Target_face_";
2722   CheckShapeTypes(theFace2, allowedShapeTypes);
2723   string theFace2Entry = PublishIfNeeded(theFace2, GEOM::FACE, prefix2);
2724
2725   string prefix3 = "Source_vertex_";
2726   vector<string> theSourceVerticesEntries (theLength) ;
2727   GEOM::GEOM_Object_ptr theVtx_i;
2728   string theEntry_i;
2729   for (size_t ind = 0; ind < theLength; ind++) {
2730       theVtx_i = theSourceVertices[ind];
2731       theEntry_i = PublishIfNeeded(theVtx_i, GEOM::VERTEX, prefix3);
2732       theSourceVerticesEntries[ind] = theEntry_i;
2733   }
2734
2735   string prefix4 = "Target_vertex_";
2736   vector<string> theTargetVerticesEntries (theLength) ;
2737   for (size_t ind = 0; ind < theLength; ind++) {
2738       theVtx_i = theTargetVertices[ind];
2739       theEntry_i = PublishIfNeeded(theVtx_i, GEOM::VERTEX, prefix4);
2740       theTargetVerticesEntries[ind] = theEntry_i;
2741   }
2742
2743   string theFace2Name = theFace2->GetName();
2744   MESSAGE("IDL : theFace1->GetName : " << theFace1->GetName());
2745   MESSAGE("IDL : theFace2->GetName : " << theFace2->GetName());
2746   MESSAGE("IDL : AddPreCadFacesPeriodicity( "<< theFace1Entry << ", " << theFace2Entry <<  ")");
2747   try {
2748       AddPreCadFacesPeriodicityEntry(theFace1Entry.c_str(), theFace2Entry.c_str(),
2749           theSourceVerticesEntries, theTargetVerticesEntries);
2750   } catch (SALOME_Exception& ex) {
2751     THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
2752   }
2753 }
2754
2755
2756 void BLSURFPlugin_Hypothesis_i::AddPreCadFacesPeriodicityEntry(const char* theFace1Entry, const char* theFace2Entry,
2757     vector<string> &theSourceVerticesEntries, vector<string> &theTargetVerticesEntries)
2758     throw (SALOME::SALOME_Exception)
2759 {
2760
2761   ASSERT(myBaseImpl);
2762
2763   string listEntriesTxt = FormatVerticesEntries(theSourceVerticesEntries, theTargetVerticesEntries);
2764
2765   MESSAGE("IDL : AddPreCadFacesPeriodicityEntry(" << theFace1Entry << ", " << theFace2Entry << listEntriesTxt.c_str() << ")");
2766
2767   this->GetImpl()->AddPreCadFacesPeriodicity(theFace1Entry, theFace2Entry,
2768       theSourceVerticesEntries, theTargetVerticesEntries);
2769
2770   SMESH::TPythonDump pd;
2771   if (!theSourceVerticesEntries.empty())
2772     {
2773       pd << _this() << ".AddPreCadFacesPeriodicityWithVertices(" << theFace1Entry << ", " << theFace2Entry;
2774       pd << listEntriesTxt.c_str();
2775       pd << ")";
2776     }
2777   else
2778     pd << _this() << ".AddPreCadFacesPeriodicity(" << theFace1Entry << ", " << theFace2Entry << ")";
2779   MESSAGE("IDL : AddPreCadFacesPeriodicityEntry END");
2780 }
2781
2782 void BLSURFPlugin_Hypothesis_i::AddPreCadEdgesPeriodicity(GEOM::GEOM_Object_ptr theEdge1, GEOM::GEOM_Object_ptr theEdge2)
2783       throw (SALOME::SALOME_Exception)
2784 {
2785   ASSERT(myBaseImpl);
2786   const GEOM::ListOfGO theSourceVertices;
2787   const GEOM::ListOfGO theTargetVertices;
2788   AddPreCadEdgesPeriodicityWithVertices(theEdge1, theEdge2, theSourceVertices, theTargetVertices);
2789 }
2790
2791 void BLSURFPlugin_Hypothesis_i::AddPreCadEdgesPeriodicityWithVertices(GEOM::GEOM_Object_ptr theEdge1, GEOM::GEOM_Object_ptr theEdge2,
2792     const GEOM::ListOfGO& theSourceVertices, const GEOM::ListOfGO& theTargetVertices)
2793       throw (SALOME::SALOME_Exception)
2794 {
2795   ASSERT(myBaseImpl);
2796
2797   size_t theLength = theSourceVertices.length();
2798   if (theLength != theTargetVertices.length())
2799     THROW_SALOME_CORBA_EXCEPTION( "The sizes of theSourceVertices and theTargetVertices must be the same" ,SALOME::BAD_PARAM );
2800
2801   std::vector<GEOM::shape_type> allowedShapeTypes;
2802   allowedShapeTypes.push_back(GEOM::EDGE);
2803   allowedShapeTypes.push_back(GEOM::COMPOUND);
2804
2805   string prefix1 = "Source_edge_";
2806   CheckShapeTypes(theEdge1, allowedShapeTypes);
2807   string theEdge1Entry = PublishIfNeeded(theEdge1, GEOM::EDGE, prefix1);
2808
2809   string prefix2 = "Target_edge_";
2810   CheckShapeTypes(theEdge2, allowedShapeTypes);
2811   string theEdge2Entry = PublishIfNeeded(theEdge2, GEOM::EDGE, prefix2);
2812
2813   string prefix3 = "Source_vertex_";
2814   vector<string> theSourceVerticesEntries (theLength) ;
2815   GEOM::GEOM_Object_ptr theVtx_i;
2816   string theEntry_i;
2817   for (size_t ind = 0; ind < theLength; ind++) {
2818       theVtx_i = theSourceVertices[ind];
2819       theEntry_i = PublishIfNeeded(theVtx_i, GEOM::VERTEX, prefix3);
2820       theSourceVerticesEntries[ind] = theEntry_i;
2821   }
2822
2823   string prefix4 = "Target_vertex_";
2824   vector<string> theTargetVerticesEntries (theLength) ;
2825   for (size_t ind = 0; ind < theLength; ind++) {
2826       theVtx_i = theTargetVertices[ind];
2827       theEntry_i = PublishIfNeeded(theVtx_i, GEOM::VERTEX, prefix4);
2828       theTargetVerticesEntries[ind] = theEntry_i;
2829   }
2830
2831   string theEdge2Name = theEdge2->GetName();
2832   MESSAGE("IDL : theEdge1->GetName : " << theEdge1->GetName());
2833   MESSAGE("IDL : theEdge2->GetName : " << theEdge2->GetName());
2834   MESSAGE("IDL : AddPreCadEdgesPeriodicity( "<< theEdge1Entry << ", " << theEdge2Entry << ")");
2835   try {
2836       AddPreCadEdgesPeriodicityEntry(theEdge1Entry.c_str(), theEdge2Entry.c_str(),
2837           theSourceVerticesEntries, theTargetVerticesEntries);
2838   } catch (SALOME_Exception& ex) {
2839     THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
2840   }
2841 }
2842
2843
2844 void BLSURFPlugin_Hypothesis_i::AddPreCadEdgesPeriodicityEntry(const char* theEdge1Entry, const char* theEdge2Entry,
2845     vector<string> &theSourceVerticesEntries, vector<string> &theTargetVerticesEntries)
2846     throw (SALOME::SALOME_Exception)
2847 {
2848
2849   ASSERT(myBaseImpl);
2850
2851   string listEntriesTxt = FormatVerticesEntries(theSourceVerticesEntries, theTargetVerticesEntries);
2852
2853   MESSAGE("IDL : AddPreCadEdgesPeriodicityEntry(" << theEdge1Entry << ", " << theEdge2Entry << listEntriesTxt.c_str() << ")");
2854   this->GetImpl()->AddPreCadEdgesPeriodicity(theEdge1Entry, theEdge2Entry,
2855       theSourceVerticesEntries, theTargetVerticesEntries);
2856
2857   SMESH::TPythonDump pd;
2858   if (!theSourceVerticesEntries.empty())
2859     {
2860       pd << _this() << ".AddPreCadEdgesPeriodicityWithVertices(" << theEdge1Entry << ", " << theEdge2Entry;
2861       pd << listEntriesTxt.c_str();
2862       pd << ")";
2863     }
2864   else
2865     pd << _this() << ".AddPreCadEdgesPeriodicity(" << theEdge1Entry << ", " << theEdge2Entry << ")";
2866
2867   MESSAGE("IDL : AddPreCadEdgesPeriodicityEntry END");
2868 }
2869
2870 void BLSURFPlugin_Hypothesis_i::AddFacePeriodicity(GEOM::GEOM_Object_ptr theFace1, GEOM::GEOM_Object_ptr theFace2)
2871     throw (SALOME::SALOME_Exception)
2872 {
2873   ASSERT(myBaseImpl);
2874
2875   string prefix1 = "Source_face_";
2876   CheckShapeType(theFace1, GEOM::FACE);
2877   string theFace1Entry = PublishIfNeeded(theFace1, GEOM::FACE, prefix1);
2878   string prefix2 = "Target_face_";
2879   CheckShapeType(theFace2, GEOM::FACE);
2880   string theFace2Entry = PublishIfNeeded(theFace2, GEOM::FACE, prefix2);
2881
2882   MESSAGE("IDL : theFace1->GetName : " << theFace1->GetName());
2883   MESSAGE("IDL : theFace2->GetName : " << theFace2->GetName());
2884   MESSAGE("IDL : AddFacePeriodicity( "<< theFace1Entry << ", " << theFace2Entry << ")");
2885   try {
2886       AddFacePeriodicityEntry(theFace1Entry.c_str(), theFace2Entry.c_str());
2887   } catch (SALOME_Exception& ex) {
2888     THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
2889   }
2890
2891
2892 }
2893
2894 void BLSURFPlugin_Hypothesis_i::AddFacePeriodicityEntry(const char* theFace1Entry, const char* theFace2Entry)
2895     throw (SALOME::SALOME_Exception){
2896
2897   ASSERT(myBaseImpl);
2898
2899   MESSAGE("IDL : AddFacePeriodicityEntry(" << theFace1Entry << ", " << theFace2Entry << ")");
2900   this->GetImpl()->AddFacePeriodicity(theFace1Entry, theFace2Entry);
2901   SMESH::TPythonDump pd;
2902   pd << _this() << ".AddFacePeriodicity(" << theFace1Entry << ", " << theFace2Entry << ")";
2903   MESSAGE("IDL : AddFacePeriodicityEntry END");
2904 }
2905
2906
2907 void BLSURFPlugin_Hypothesis_i::AddEdgePeriodicity(GEOM::GEOM_Object_ptr theFace1, GEOM::GEOM_Object_ptr theEdge1,
2908                                                    GEOM::GEOM_Object_ptr theFace2, GEOM::GEOM_Object_ptr theEdge2,
2909                                                    CORBA::Long edge_orientation)
2910     throw (SALOME::SALOME_Exception){
2911   ASSERT(myBaseImpl);
2912
2913   string prefix_theFace1 = "Source_face_";
2914   CheckShapeType(theFace1, GEOM::FACE);
2915   string theFace1Entry = PublishIfNeeded(theFace1, GEOM::FACE, prefix_theFace1);
2916   string prefix_theFace2 = "Target_face_";
2917   CheckShapeType(theFace2, GEOM::FACE);
2918   string theFace2Entry = PublishIfNeeded(theFace2, GEOM::FACE, prefix_theFace2);
2919
2920   string prefix_theEdge1 = "Source_edge_";
2921   CheckShapeType(theEdge1, GEOM::EDGE);
2922   string theEdge1Entry = PublishIfNeeded(theEdge1, GEOM::EDGE, prefix_theEdge1);
2923   string prefix_theEdge2 = "Target_edge_";
2924   CheckShapeType(theEdge2, GEOM::EDGE);
2925   string theEdge2Entry = PublishIfNeeded(theEdge2, GEOM::EDGE, prefix_theEdge2);
2926
2927   MESSAGE("IDL : theFace1->GetName : " << theFace1->GetName());
2928   MESSAGE("IDL : theEdge1->GetName : " << theEdge1->GetName());
2929   MESSAGE("IDL : theFace2->GetName : " << theFace2->GetName());
2930   MESSAGE("IDL : theEdge2->GetName : " << theEdge2->GetName());
2931   MESSAGE("IDL : AddEdgePeriodicity( "<< theFace1Entry << ", " << theEdge1Entry << ", " << theFace2Entry << ", "  << theEdge2Entry << ", " << edge_orientation << ")");
2932   try {
2933       AddEdgePeriodicityEntry(theFace1Entry.c_str(), theEdge1Entry.c_str(), theFace2Entry.c_str(), theEdge2Entry.c_str(), edge_orientation);
2934   } catch (SALOME_Exception& ex) {
2935     THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
2936   }
2937
2938
2939 }
2940
2941 void BLSURFPlugin_Hypothesis_i::AddEdgePeriodicityWithoutFaces(GEOM::GEOM_Object_ptr theEdge1,
2942                                                                GEOM::GEOM_Object_ptr theEdge2,
2943                                                                CORBA::Long edge_orientation)
2944     throw (SALOME::SALOME_Exception){
2945   ASSERT(myBaseImpl);
2946
2947   string theFace1Entry = "";
2948   string theFace2Entry = "";
2949
2950   string prefix_theEdge1 = "Source_edge_";
2951   CheckShapeType(theEdge1, GEOM::EDGE);
2952   string theEdge1Entry = PublishIfNeeded(theEdge1, GEOM::EDGE, prefix_theEdge1);
2953   string prefix_theEdge2 = "Target_edge_";
2954   CheckShapeType(theEdge2, GEOM::EDGE);
2955   string theEdge2Entry = PublishIfNeeded(theEdge2, GEOM::EDGE, prefix_theEdge2);
2956
2957   MESSAGE("IDL : theEdge1->GetName : " << theEdge1->GetName());
2958   MESSAGE("IDL : theEdge2->GetName : " << theEdge2->GetName());
2959   MESSAGE("IDL : AddEdgePeriodicity( "<< theFace1Entry << ", " << theEdge1Entry << ", " << theFace2Entry << ", "  << theEdge2Entry << ", " << edge_orientation << ")");
2960   try {
2961       AddEdgePeriodicityEntry(theFace1Entry.c_str(), theEdge1Entry.c_str(), theFace2Entry.c_str(), theEdge2Entry.c_str(), edge_orientation);
2962   } catch (SALOME_Exception& ex) {
2963     THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
2964   }
2965
2966
2967 }
2968
2969 void BLSURFPlugin_Hypothesis_i::AddEdgePeriodicityEntry(const char* theFace1Entry, const char* theEdge1Entry, const char* theFace2Entry, const char* theEdge2Entry, const long edge_orientation)
2970     throw (SALOME::SALOME_Exception){
2971
2972   ASSERT(myBaseImpl);
2973
2974   MESSAGE("IDL : AddEdgePeriodicityEntry(" << theFace1Entry << ", " << theEdge1Entry << ", " << theFace2Entry << ", "  << theEdge2Entry << ", " << edge_orientation << ")");
2975   this->GetImpl()->AddEdgePeriodicity(theFace1Entry, theEdge1Entry, theFace2Entry, theEdge2Entry, edge_orientation);
2976   SMESH::TPythonDump pd;
2977   if (theFace1Entry)
2978     pd << _this() << ".AddEdgePeriodicity(" << theFace1Entry << ", " << theEdge1Entry << ", " << theFace2Entry << ", "  << theEdge2Entry << ", " << edge_orientation <<")";
2979   else
2980     pd << _this() << ".AddEdgePeriodicityWithoutFaces(" << theEdge1Entry << ", " << theEdge2Entry << ", " << edge_orientation <<")";
2981   MESSAGE("IDL : AddEdgePeriodicityEntry END");
2982 }
2983
2984 void BLSURFPlugin_Hypothesis_i::AddVertexPeriodicity(GEOM::GEOM_Object_ptr theEdge1, GEOM::GEOM_Object_ptr theVertex1,
2985     GEOM::GEOM_Object_ptr theEdge2, GEOM::GEOM_Object_ptr theVertex2)
2986     throw (SALOME::SALOME_Exception){
2987   ASSERT(myBaseImpl);
2988
2989   string prefix_theEdge1 = "Source_edge_";
2990   CheckShapeType(theEdge1, GEOM::EDGE);
2991   string theEdge1Entry = PublishIfNeeded(theEdge1, GEOM::EDGE, prefix_theEdge1);
2992   string prefix_theEdge2 = "Target_edge_";
2993   CheckShapeType(theEdge2, GEOM::EDGE);
2994   string theEdge2Entry = PublishIfNeeded(theEdge2, GEOM::EDGE, prefix_theEdge2);
2995
2996   string prefix_theVertex1 = "Source_vertex_";
2997   CheckShapeType(theVertex1, GEOM::VERTEX);
2998   string theVertex1Entry = PublishIfNeeded(theVertex1, GEOM::VERTEX, prefix_theVertex1);
2999   string prefix_theVertex2 = "Target_vertex_";
3000   CheckShapeType(theVertex2, GEOM::VERTEX);
3001   string theVertex2Entry = PublishIfNeeded(theVertex2, GEOM::VERTEX, prefix_theVertex2);
3002
3003   MESSAGE("IDL : theEdge1->GetName : " << theEdge1->GetName());
3004   MESSAGE("IDL : theVertex1->GetName : " << theVertex1->GetName());
3005   MESSAGE("IDL : theEdge2->GetName : " << theEdge2->GetName());
3006   MESSAGE("IDL : theVertex2->GetName : " << theVertex2->GetName());
3007   MESSAGE("IDL : AddVertexPeriodicity( "<< theEdge1Entry << ", " << theVertex1Entry << ", " << theEdge2Entry << ", "  << theVertex2Entry << ")");
3008   try {
3009       AddVertexPeriodicityEntry(theEdge1Entry.c_str(), theVertex1Entry.c_str(), theEdge2Entry.c_str(), theVertex2Entry.c_str());
3010   } catch (SALOME_Exception& ex) {
3011     THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
3012   }
3013
3014
3015 }
3016
3017 void BLSURFPlugin_Hypothesis_i::AddVertexPeriodicityEntry(const char* theEdge1Entry, const char* theVertex1Entry, const char* theEdge2Entry, const char* theVertex2Entry)
3018     throw (SALOME::SALOME_Exception){
3019
3020   ASSERT(myBaseImpl);
3021
3022   MESSAGE("IDL : AddVertexPeriodicityEntry(" << theEdge1Entry << ", " << theVertex1Entry << ", " << theEdge2Entry << ", "  << theVertex2Entry << ")");
3023   this->GetImpl()->AddVertexPeriodicity(theEdge1Entry, theVertex1Entry, theEdge2Entry, theVertex2Entry);
3024   SMESH::TPythonDump pd;
3025   pd << _this() << ".AddVertexPeriodicity(" << theEdge1Entry << ", " << theVertex1Entry << ", " << theEdge2Entry << ", "  << theVertex2Entry << ")";
3026   MESSAGE("IDL : AddVertexPeriodicityEntry END");
3027 }
3028
3029
3030 //================================================================================
3031 /*!
3032  * \brief Sets the file for export resulting mesh in GMF format
3033  * \param theFileName - full name of the file (.mesh, .meshb)
3034  * 
3035  * After compute, export the resulting mesh in the given file with the GMF format (.mesh)
3036  */
3037 //================================================================================  
3038 // void BLSURFPlugin_Hypothesis_i::SetGMFFile(const char* theFileName, CORBA::Boolean isBinary) {
3039 void BLSURFPlugin_Hypothesis_i::SetGMFFile(const char* theFileName) {
3040   ASSERT(myBaseImpl);
3041   MESSAGE("IDL : SetGMFFile(" << theFileName << ")");
3042   bool valueChanged/*, modeChanged*/ = false;
3043   try {
3044     valueChanged = (this->GetImpl()->GetGMFFile() != theFileName);
3045 //     modeChanged = (this->GetImpl()->GetGMFFileMode() != isBinary);
3046     if (valueChanged)// or (!valueChanged && modeChanged))
3047       this->GetImpl()->SetGMFFile(theFileName);// ,isBinary);
3048   } catch (const std::exception& ex) {
3049     THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
3050   }
3051   if (valueChanged)// or (!valueChanged && modeChanged))
3052     SMESH::TPythonDump() << _this() << ".SetGMFFile(\"" << theFileName << "\")"; //", " << isBinary << ")";
3053   MESSAGE("IDL : SetGMFFile END ");
3054 }
3055
3056 //================================================================================
3057 /*!
3058  * \brief Gets the file name for export resulting mesh in GMF format
3059  * \retval char* - The file name
3060  * 
3061  * Returns the GMF file name
3062  */
3063 //================================================================================  
3064 char* BLSURFPlugin_Hypothesis_i::GetGMFFile() {
3065   ASSERT(myBaseImpl);
3066 //   MESSAGE("IDL : GetGMFFile()");
3067   return CORBA::string_dup(this->GetImpl()->GetGMFFile().c_str());
3068 }
3069
3070 // //================================================================================
3071 // /*!
3072 //  * \brief Gets the file mode for export resulting mesh in GMF format
3073 //  * \retval CORBA::Boolean - TRUE if binary mode, FALSE if ascii mode
3074 //  * 
3075 //  * Returns the GMF file mode
3076 //  */
3077 // //================================================================================  
3078 // CORBA::Boolean BLSURFPlugin_Hypothesis_i::GetGMFFileMode() {
3079 //   ASSERT(myBaseImpl);
3080 //   MESSAGE("IDL : GetGMFFileMode()");
3081 //   return this->GetImpl()->GetGMFFileMode();
3082 // }
3083
3084 //=============================================================================
3085 /*!
3086  *  BLSURFPlugin_Hypothesis_i::GetImpl
3087  *
3088  *  Get implementation
3089  */
3090 //=============================================================================
3091 ::BLSURFPlugin_Hypothesis* BLSURFPlugin_Hypothesis_i::GetImpl() {
3092   // MESSAGE("BLSURFPlugin_Hypothesis_i::GetImpl");
3093   return (::BLSURFPlugin_Hypothesis*) myBaseImpl;
3094 }
3095
3096 //================================================================================
3097 /*!
3098  * \brief Verify whether hypothesis supports given entity type 
3099  * \param type - dimension (see SMESH::Dimension enumeration)
3100  * \retval CORBA::Boolean - TRUE if dimension is supported, FALSE otherwise
3101  * 
3102  * Verify whether hypothesis supports given entity type (see SMESH::Dimension enumeration)
3103  */
3104 //================================================================================  
3105 CORBA::Boolean BLSURFPlugin_Hypothesis_i::IsDimSupported(SMESH::Dimension type) {
3106   return type == SMESH::DIM_2D;
3107 }
3108
3109 //
3110 // Obsolete methods - To be removed in V7
3111 //
3112
3113 void BLSURFPlugin_Hypothesis_i::SetPhyMin(CORBA::Double theMinSize) {
3114   this->SetMinSize(theMinSize);
3115 }
3116 CORBA::Double BLSURFPlugin_Hypothesis_i::GetPhyMin() {
3117   return this->GetMinSize();
3118 }
3119 void BLSURFPlugin_Hypothesis_i::SetPhyMax(CORBA::Double theMaxSize) {
3120   this->SetMaxSize(theMaxSize);
3121 }
3122 CORBA::Double BLSURFPlugin_Hypothesis_i::GetPhyMax() {
3123   return this->GetMaxSize();
3124 }
3125 void BLSURFPlugin_Hypothesis_i::SetGeoMin(CORBA::Double theMinSize) {
3126   this->SetMinSize(theMinSize);
3127 }
3128 CORBA::Double BLSURFPlugin_Hypothesis_i::GetGeoMin() {
3129   return this->GetMinSize();
3130 }
3131 void BLSURFPlugin_Hypothesis_i::SetGeoMax(CORBA::Double theMaxSize) {
3132   this->SetMaxSize(theMaxSize);
3133 }
3134 CORBA::Double BLSURFPlugin_Hypothesis_i::GetGeoMax() {
3135   return this->GetMaxSize();
3136 }
3137 void BLSURFPlugin_Hypothesis_i::SetAngleMeshS(CORBA::Double theValue) {
3138   this->SetAngleMesh(theValue);
3139 }
3140 CORBA::Double BLSURFPlugin_Hypothesis_i::GetAngleMeshS() {
3141   return this->GetAngleMesh();
3142 }
3143 void BLSURFPlugin_Hypothesis_i::SetAngleMeshC(CORBA::Double theValue) {
3144   this->SetAngleMesh(theValue);
3145 }
3146 CORBA::Double BLSURFPlugin_Hypothesis_i::GetAngleMeshC() {
3147   return this->GetAngleMesh();
3148 }
3149 void BLSURFPlugin_Hypothesis_i::SetDecimesh(CORBA::Boolean theValue) {
3150   std::string theValueStr = theValue ? "1" : "0";
3151   this->SetOptionValue("respect_geometry",theValueStr.c_str());
3152 }
3153 CORBA::Boolean BLSURFPlugin_Hypothesis_i::GetDecimesh() {
3154   std::string theValueStr = this->GetOptionValue("respect_geometry");
3155   if (theValueStr.empty() || theValueStr == "respect")
3156       return true;
3157   return false;
3158 }
3159 void BLSURFPlugin_Hypothesis_i::SetPreCADRemoveNanoEdges(CORBA::Boolean theValue) {
3160   std::string theValueStr = theValue ? "1" : "0";
3161   this->SetPreCADOptionValue("remove_tiny_edges",theValueStr.c_str());
3162 }
3163 CORBA::Boolean BLSURFPlugin_Hypothesis_i::GetPreCADRemoveNanoEdges() {
3164   std::string theValueStr = this->GetPreCADOptionValue("remove_tiny_edges");
3165   if (theValueStr == "1")
3166       return true;
3167   return false;
3168 }
3169 void BLSURFPlugin_Hypothesis_i::SetPreCADEpsNano(CORBA::Double theValue) {
3170   std::ostringstream theValueStr;
3171   theValueStr << theValue;
3172   this->SetPreCADOptionValue("tiny_edge_length",theValueStr.str().c_str());
3173 }
3174 CORBA::Double BLSURFPlugin_Hypothesis_i::GetPreCADEpsNano() {
3175   std::istringstream theValueStr(this->GetPreCADOptionValue("tiny_edge_length"));
3176   double result;
3177   theValueStr >> result;
3178   return result;
3179 }