Salome HOME
Fix of issue EDF 1287 BLSURFPLUGIN: Problem of size map on edge
[plugins/blsurfplugin.git] / src / BLSURFPlugin / BLSURFPlugin_Hypothesis_i.cxx
1 //  Copyright (C) 2007-2008  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 // File    : BLSURFPlugin_Hypothesis.cxx
21 // Authors : Francis KLOSS (OCC) & Patrick LAUG (INRIA) & Lioka RAZAFINDRAZAKA (CEA)
22 //           Size maps developement: Nicolas GEIMER (OCC) & Gilles DAVID (EURIWARE)
23 // ---
24 //
25 #include "BLSURFPlugin_Hypothesis_i.hxx"
26 #include "SMESH_Gen.hxx"
27 #include "SMESH_PythonDump.hxx"
28 #include "GEOM_Object.hxx"
29
30 #include "Utils_CorbaException.hxx"
31 #include "utilities.h"
32
33 #include <stdexcept>
34 #include "boost/regex.hpp"
35
36 //=============================================================================
37 /*!
38  *  BLSURFPlugin_Hypothesis_i::BLSURFPlugin_Hypothesis_i
39  *
40  *  Constructor
41  */
42 //=============================================================================
43 BLSURFPlugin_Hypothesis_i::
44 BLSURFPlugin_Hypothesis_i (PortableServer::POA_ptr thePOA,
45                            int                     theStudyId,
46                            ::SMESH_Gen*            theGenImpl)
47   : SALOME::GenericObj_i( thePOA ), 
48     SMESH_Hypothesis_i( thePOA )
49 {
50   MESSAGE( "BLSURFPlugin_Hypothesis_i::BLSURFPlugin_Hypothesis_i" );
51   myBaseImpl = new ::BLSURFPlugin_Hypothesis (theGenImpl->GetANewId(),
52                                               theStudyId,
53                                               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 {
65   MESSAGE( "BLSURFPlugin_Hypothesis_i::~BLSURFPlugin_Hypothesis_i" );
66 }
67
68 /*!
69  *  BLSURFPlugin_Hypothesis_i::SetTopology
70  *
71  *  Set topology
72  */
73
74 //=============================================================================
75 void BLSURFPlugin_Hypothesis_i::SetTopology (CORBA::Long theValue)
76 {
77   // MESSAGE("BLSURFPlugin_Hypothesis_i::SetTopology");
78   ASSERT(myBaseImpl);
79   this->GetImpl()->SetTopology((::BLSURFPlugin_Hypothesis::Topology)theValue);
80   SMESH::TPythonDump() << _this() << ".SetTopology( " << theValue << " )";
81 }
82
83 //=============================================================================
84 /*!
85  *  BLSURFPlugin_Hypothesis_i::GetTopology
86  *
87  *  Get Topology
88  */
89 //=============================================================================
90 CORBA::Long BLSURFPlugin_Hypothesis_i::GetTopology()
91 {
92   // MESSAGE("BLSURFPlugin_Hypothesis_i::GetTopology");
93   ASSERT(myBaseImpl);
94   return this->GetImpl()->GetTopology();
95 }
96
97 //=============================================================================
98
99 //=============================================================================
100 /*!
101  *  BLSURFPlugin_Hypothesis_i::SetPhysicalMesh
102  *
103  *  Set PhysicalMesh
104  */
105
106 //=============================================================================
107 void BLSURFPlugin_Hypothesis_i::SetPhysicalMesh (CORBA::Long theValue)
108 {
109   // MESSAGE("BLSURFPlugin_Hypothesis_i::SetPhysicalMesh");
110   ASSERT(myBaseImpl);
111   this->GetImpl()->SetPhysicalMesh((::BLSURFPlugin_Hypothesis::PhysicalMesh)theValue);
112   SMESH::TPythonDump() << _this() << ".SetPhysicalMesh( " << theValue << " )";
113 }
114
115 //=============================================================================
116 /*!
117  *  BLSURFPlugin_Hypothesis_i::GetPhysicalMesh
118  *
119  *  Get PhysicalMesh
120  */
121 //=============================================================================
122 CORBA::Long BLSURFPlugin_Hypothesis_i::GetPhysicalMesh()
123 {
124   // MESSAGE("BLSURFPlugin_Hypothesis_i::GetPhysicalMesh");
125   ASSERT(myBaseImpl);
126   return this->GetImpl()->GetPhysicalMesh();
127 }
128
129 //=============================================================================
130 /*!
131  *  BLSURFPlugin_Hypothesis_i::SetPhySize
132  *
133  *  Set PhySize
134  */
135 //=============================================================================
136 void BLSURFPlugin_Hypothesis_i::SetPhySize (CORBA::Double theValue)
137 {
138   // MESSAGE("BLSURFPlugin_Hypothesis_i::SetPhySize");
139   ASSERT(myBaseImpl);
140   this->GetImpl()->SetPhySize(theValue);
141   SMESH::TPythonDump() << _this() << ".SetPhySize( " << theValue << " )";
142 }
143
144 //=============================================================================
145 /*!
146  *  BLSURFPlugin_Hypothesis_i::GetPhySize
147  *
148  *  Get PhySize
149  */
150 //=============================================================================
151 CORBA::Double BLSURFPlugin_Hypothesis_i::GetPhySize()
152 {
153   // MESSAGE("BLSURFPlugin_Hypothesis_i::GetPhySize");
154   ASSERT(myBaseImpl);
155   return this->GetImpl()->GetPhySize();
156 }
157
158 //=============================================================================
159 void BLSURFPlugin_Hypothesis_i::SetPhyMin(CORBA::Double theMinSize)
160 {
161   ASSERT(myBaseImpl);
162   if ( GetPhyMin() != theMinSize ) {
163     this->GetImpl()->SetPhyMin(theMinSize);
164     SMESH::TPythonDump() << _this() << ".SetPhyMin( " << theMinSize << " )";
165   }
166 }
167
168 //=============================================================================
169 CORBA::Double BLSURFPlugin_Hypothesis_i::GetPhyMin()
170 {
171   ASSERT(myBaseImpl);
172   return this->GetImpl()->GetPhyMin();
173 }
174
175
176 //=============================================================================
177 void BLSURFPlugin_Hypothesis_i::SetPhyMax(CORBA::Double theMaxSize)
178 {
179   ASSERT(myBaseImpl);
180   if ( GetPhyMax() != theMaxSize ) {
181     this->GetImpl()->SetPhyMax(theMaxSize);
182     SMESH::TPythonDump() << _this() << ".SetPhyMax( " << theMaxSize << " )";
183   }
184 }
185
186 //=============================================================================
187 CORBA::Double BLSURFPlugin_Hypothesis_i::GetPhyMax()
188 {
189   ASSERT(myBaseImpl);
190   return this->GetImpl()->GetPhyMax();
191 }
192
193
194 //=============================================================================
195 /*!
196  *  BLSURFPlugin_Hypothesis_i::SetGeometricMesh
197  *
198  *  Set GeometricMesh
199  */
200
201 //=============================================================================
202 void BLSURFPlugin_Hypothesis_i::SetGeometricMesh (CORBA::Long theValue)
203 {
204   // MESSAGE("BLSURFPlugin_Hypothesis_i::SetGeometricMesh");
205   ASSERT(myBaseImpl);
206   this->GetImpl()->SetGeometricMesh((::BLSURFPlugin_Hypothesis::GeometricMesh)theValue);
207   SMESH::TPythonDump() << _this() << ".SetGeometricMesh( " << theValue << " )";
208 }
209
210 //=============================================================================
211 /*!
212  *  BLSURFPlugin_Hypothesis_i::GetGeometricMesh
213  *
214  *  Get GeometricMesh
215  */
216 //=============================================================================
217 CORBA::Long BLSURFPlugin_Hypothesis_i::GetGeometricMesh()
218 {
219   // MESSAGE("BLSURFPlugin_Hypothesis_i::GetGeometricMesh");
220   ASSERT(myBaseImpl);
221   return this->GetImpl()->GetGeometricMesh();
222 }
223
224 //=============================================================================
225 /*!
226  *  BLSURFPlugin_Hypothesis_i::SetAngleMeshS
227  *
228  *  Set AngleMeshS
229  */
230 //=============================================================================
231 void BLSURFPlugin_Hypothesis_i::SetAngleMeshS (CORBA::Double theValue)
232 {
233   // MESSAGE("BLSURFPlugin_Hypothesis_i::SetAngleMeshS");
234   ASSERT(myBaseImpl);
235   this->GetImpl()->SetAngleMeshS(theValue);
236   SMESH::TPythonDump() << _this() << ".SetAngleMeshS( " << theValue << " )";
237 }
238
239 //=============================================================================
240 /*!
241  *  BLSURFPlugin_Hypothesis_i::GetAngleMeshS
242  *
243  *  Get AngleMeshS
244  */
245 //=============================================================================
246 CORBA::Double BLSURFPlugin_Hypothesis_i::GetAngleMeshS()
247 {
248   // MESSAGE("BLSURFPlugin_Hypothesis_i::GetAngleMeshS");
249   ASSERT(myBaseImpl);
250   return this->GetImpl()->GetAngleMeshS();
251 }
252
253 //=============================================================================
254 void BLSURFPlugin_Hypothesis_i::SetAngleMeshC(CORBA::Double angle)
255 {
256   ASSERT(myBaseImpl);
257   this->GetImpl()->SetAngleMeshC(angle);
258   SMESH::TPythonDump() << _this() << ".SetAngleMeshC( " << angle << " )";
259 }
260
261 //=============================================================================
262 CORBA::Double BLSURFPlugin_Hypothesis_i::GetAngleMeshC()
263 {
264   ASSERT(myBaseImpl);
265   return this->GetImpl()->GetAngleMeshC();
266 }
267
268 //=============================================================================
269 void BLSURFPlugin_Hypothesis_i::SetGeoMin(CORBA::Double theMinSize)
270 {
271   ASSERT(myBaseImpl);
272   if ( GetGeoMin() != theMinSize ) {
273     this->GetImpl()->SetGeoMin(theMinSize);
274     SMESH::TPythonDump() << _this() << ".SetGeoMin( " << theMinSize << " )";
275   }
276 }
277
278 //=============================================================================
279 CORBA::Double BLSURFPlugin_Hypothesis_i::GetGeoMin()
280 {
281   ASSERT(myBaseImpl);
282   return this->GetImpl()->GetGeoMin();
283 }
284
285 //=============================================================================
286 void BLSURFPlugin_Hypothesis_i::SetGeoMax(CORBA::Double theMaxSize)
287 {
288   ASSERT(myBaseImpl);
289   if ( GetGeoMax() != theMaxSize ) {
290     this->GetImpl()->SetGeoMax(theMaxSize);
291     SMESH::TPythonDump() << _this() << ".SetGeoMax( " << theMaxSize << " )";
292   }
293 }
294
295 //=============================================================================
296 CORBA::Double BLSURFPlugin_Hypothesis_i::GetGeoMax()
297 {
298   ASSERT(myBaseImpl);
299   return this->GetImpl()->GetGeoMax();
300 }
301
302 //=============================================================================
303 /*!
304  *  BLSURFPlugin_Hypothesis_i::SetGradation
305  *
306  *  Set Gradation
307  */
308 //=============================================================================
309 void BLSURFPlugin_Hypothesis_i::SetGradation (CORBA::Double theValue)
310 {
311   // MESSAGE("BLSURFPlugin_Hypothesis_i::SetGradation");
312   ASSERT(myBaseImpl);
313   this->GetImpl()->SetGradation(theValue);
314   SMESH::TPythonDump() << _this() << ".SetGradation( " << theValue << " )";
315 }
316
317 //=============================================================================
318 /*!
319  *  BLSURFPlugin_Hypothesis_i::GetGradation
320  *
321  *  Get Gradation
322  */
323 //=============================================================================
324 CORBA::Double BLSURFPlugin_Hypothesis_i::GetGradation()
325 {
326   // MESSAGE("BLSURFPlugin_Hypothesis_i::GetGradation");
327   ASSERT(myBaseImpl);
328   return this->GetImpl()->GetGradation();
329 }
330
331 //=============================================================================
332 /*!
333  *  BLSURFPlugin_Hypothesis_i::SetQuadAllowed
334  *
335  *  Set true or false
336  */
337 //=============================================================================
338 void BLSURFPlugin_Hypothesis_i::SetQuadAllowed (CORBA::Boolean theValue)
339 {
340   // MESSAGE("BLSURFPlugin_Hypothesis_i::SetQuadAllowed");
341   ASSERT(myBaseImpl);
342   this->GetImpl()->SetQuadAllowed(theValue);
343   SMESH::TPythonDump() << _this() << ".SetQuadAllowed( " << theValue << " )";
344 }
345
346 //=============================================================================
347 /*!
348  *  BLSURFPlugin_Hypothesis_i::GetQuadAllowed
349  *
350  *  Get true or false
351  */
352 //=============================================================================
353 CORBA::Boolean BLSURFPlugin_Hypothesis_i::GetQuadAllowed()
354 {
355   // MESSAGE("BLSURFPlugin_Hypothesis_i::GetQuadAllowed");
356   ASSERT(myBaseImpl);
357   return this->GetImpl()->GetQuadAllowed();
358 }
359
360 //=============================================================================
361 /*!
362  *  BLSURFPlugin_Hypothesis_i::SetDecimesh
363  *
364  *  Set true or false
365  */
366 //=============================================================================
367 void BLSURFPlugin_Hypothesis_i::SetDecimesh (CORBA::Boolean theValue)
368 {
369   // MESSAGE("BLSURFPlugin_Hypothesis_i::SetDecimesh");
370   ASSERT(myBaseImpl);
371   this->GetImpl()->SetDecimesh(theValue);
372   SMESH::TPythonDump() << _this() << ".SetDecimesh( " << theValue << " )";
373 }
374
375 //=============================================================================
376 /*!
377  *  BLSURFPlugin_Hypothesis_i::GetDecimesh
378  *
379  *  Get true or false
380  */
381 //=============================================================================
382 CORBA::Boolean BLSURFPlugin_Hypothesis_i::GetDecimesh()
383 {
384   // MESSAGE("BLSURFPlugin_Hypothesis_i::GetDecimesh");
385   ASSERT(myBaseImpl);
386   return this->GetImpl()->GetDecimesh();
387 }
388
389 //=============================================================================
390 void BLSURFPlugin_Hypothesis_i::SetVerbosity(CORBA::Short theVal)
391   throw (SALOME::SALOME_Exception)
392 {
393   ASSERT(myBaseImpl);
394   if ( theVal < 0 || theVal > 100 )
395     THROW_SALOME_CORBA_EXCEPTION( "Invalid verbosity level",SALOME::BAD_PARAM );
396   this->GetImpl()->SetVerbosity(theVal);
397   SMESH::TPythonDump() << _this() << ".SetVerbosity( " << theVal << " )";
398 }
399
400 //=============================================================================
401
402 CORBA::Short BLSURFPlugin_Hypothesis_i::GetVerbosity()
403 {
404   ASSERT(myBaseImpl);
405   return (CORBA::Short) this->GetImpl()->GetVerbosity();
406 }
407
408 //=============================================================================
409
410 void BLSURFPlugin_Hypothesis_i::SetOptionValue(const char* optionName,
411                                                const char* optionValue)
412   throw (SALOME::SALOME_Exception)
413 {
414   ASSERT(myBaseImpl);
415   bool valueChanged = false;
416   try {
417     valueChanged = ( this->GetImpl()->GetOptionValue(optionName) != optionValue );
418     if ( valueChanged )
419       this->GetImpl()->SetOptionValue(optionName, optionValue);
420   }
421   catch (const std::invalid_argument& ex) {
422     SALOME::ExceptionStruct ExDescription;
423     ExDescription.text = ex.what();
424     ExDescription.type = SALOME::BAD_PARAM;
425     ExDescription.sourceFile = "BLSURFPlugin_Hypothesis::SetOptionValue(name,value)";
426     ExDescription.lineNumber = 0;
427     throw SALOME::SALOME_Exception(ExDescription);
428   }
429   catch (SALOME_Exception& ex) {
430     THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
431   }
432   if ( valueChanged )
433     SMESH::TPythonDump() << _this() << ".SetOptionValue( '"
434                          << optionName << "', '" << optionValue << "' )";
435 }
436
437 //=============================================================================
438
439 char* BLSURFPlugin_Hypothesis_i::GetOptionValue(const char* optionName)
440   throw (SALOME::SALOME_Exception)
441 {
442   ASSERT(myBaseImpl);
443   try {
444     return CORBA::string_dup( this->GetImpl()->GetOptionValue(optionName).c_str() );
445   }
446   catch (const std::invalid_argument& ex) {
447     SALOME::ExceptionStruct ExDescription;
448     ExDescription.text = ex.what();
449     ExDescription.type = SALOME::BAD_PARAM;
450     ExDescription.sourceFile = "BLSURFPlugin_Hypothesis::GetOptionValue(name)";
451     ExDescription.lineNumber = 0;
452     throw SALOME::SALOME_Exception(ExDescription);
453   }
454   catch (SALOME_Exception& ex) {
455     THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
456   }
457   return 0;
458 }
459
460 //=============================================================================
461
462 void BLSURFPlugin_Hypothesis_i::UnsetOption(const char* optionName)
463 {
464   ASSERT(myBaseImpl);
465   this->GetImpl()->ClearOption(optionName);
466   SMESH::TPythonDump() << _this() << ".UnsetOption( '" << optionName << "' )";
467 }
468
469 //=============================================================================
470
471 BLSURFPlugin::string_array* BLSURFPlugin_Hypothesis_i::GetOptionValues()
472 {
473   ASSERT(myBaseImpl);
474   BLSURFPlugin::string_array_var result = new BLSURFPlugin::string_array();
475
476   const ::BLSURFPlugin_Hypothesis::TOptionValues & opts = this->GetImpl()->GetOptionValues();
477   result->length( opts.size() );
478
479   ::BLSURFPlugin_Hypothesis::TOptionValues::const_iterator opIt = opts.begin();
480   for ( int i = 0 ; opIt != opts.end(); ++opIt, ++i ) {
481     string name_value = opIt->first;
482     if ( !opIt->second.empty() ) {
483       name_value += ":";
484       name_value += opIt->second;
485     }
486     result[i] = CORBA::string_dup(name_value.c_str());
487   }
488   return result._retn();
489 }
490
491 //=============================================================================
492
493 void BLSURFPlugin_Hypothesis_i::SetOptionValues(const BLSURFPlugin::string_array& options)
494   throw (SALOME::SALOME_Exception)
495 {
496   ASSERT(myBaseImpl);
497   for (int i = 0; i < options.length(); ++i)
498   {
499     string name_value = options[i].in();
500     int colonPos = name_value.find( ':' );
501     string name, value;
502     if ( colonPos == string::npos ) // ':' not found
503       name = name_value;
504     else {
505       name = name_value.substr( 0, colonPos);
506       if ( colonPos < name_value.size()-1 && name_value[colonPos] != ' ')
507         value = name_value.substr( colonPos+1 );
508     }
509     SetOptionValue( name.c_str(), value.c_str() );
510   }
511 }
512
513 //=============================================================================
514
515 void BLSURFPlugin_Hypothesis_i::SetSizeMapEntry(const char* entry,const char* sizeMap)
516   throw (SALOME::SALOME_Exception)
517 {
518   ASSERT(myBaseImpl);
519   MESSAGE("ENGINE : SETSIZEMAP START ENTRY : " << entry); 
520   bool valueChanged = false;
521   try {
522     valueChanged = ( this->GetImpl()->GetSizeMapEntry(entry) != sizeMap );
523     if ( valueChanged )
524       this->GetImpl()->SetSizeMapEntry(entry, sizeMap);
525   }
526   catch (const std::invalid_argument& ex) {
527     SALOME::ExceptionStruct ExDescription;
528     ExDescription.text = ex.what();
529     ExDescription.type = SALOME::BAD_PARAM;
530     ExDescription.sourceFile = "BLSURFPlugin_Hypothesis::SetSizeMapEntry(entry,sizemap)";
531     ExDescription.lineNumber = 0;
532     throw SALOME::SALOME_Exception(ExDescription);
533   }
534   catch (SALOME_Exception& ex) {
535     THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
536   }
537   MESSAGE("ENGINE : SETSIZEMAP END ENTRY : " << entry);
538   if ( valueChanged )
539     SMESH::TPythonDump() << _this() << ".SetSizeMap("
540                          << entry << ", '" << sizeMap << "' )";
541 }
542
543 //=============================================================================
544
545 void BLSURFPlugin_Hypothesis_i::SetAttractorEntry(const char* entry,const char* attractor )
546   throw (SALOME::SALOME_Exception)
547 {
548   ASSERT(myBaseImpl);
549   MESSAGE("ENGINE : SETATTRACTOR START ENTRY : " << entry);
550   bool valueChanged = false;
551   try {
552     valueChanged = ( this->GetImpl()->GetAttractorEntry(entry) != attractor );
553     if ( valueChanged ) {
554       boost::regex re("^ATTRACTOR\\((?:(-?0(\\.\\d*)*|-?[1-9]+\\d*(\\.\\d*)*|-?\\.(\\d)+);){5}(True|False)\\)$");
555       if (!boost::regex_match(string(attractor), re))
556         throw std::invalid_argument("Error: an attractor is defined with the following pattern: ATTRACTOR(xa;ya;za;a;b;True|False)");
557       this->GetImpl()->SetAttractorEntry(entry, attractor);
558     }
559   }
560   catch (const std::invalid_argument& ex) {
561     SALOME::ExceptionStruct ExDescription;
562     ExDescription.text = ex.what();
563     ExDescription.type = SALOME::BAD_PARAM;
564     ExDescription.sourceFile = "BLSURFPlugin_Hypothesis::SetAttractorEntry(entry,attractor)";
565     ExDescription.lineNumber = 0;
566     throw SALOME::SALOME_Exception(ExDescription);
567   }
568   catch (SALOME_Exception& ex) {
569     THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
570   }
571   MESSAGE("ENGINE : SETATTRACTOR END ENTRY : " << entry);
572   if ( valueChanged )
573     SMESH::TPythonDump() << _this() << ".SetAttractor("
574                          << entry << ", '" << attractor << "' )";
575 }
576
577
578 //=============================================================================
579
580 char* BLSURFPlugin_Hypothesis_i::GetSizeMapEntry(const char* entry) 
581   throw (SALOME::SALOME_Exception)
582 {
583   ASSERT(myBaseImpl);
584   try {
585     return CORBA::string_dup( this->GetImpl()->GetSizeMapEntry(entry).c_str());
586   }
587   catch (const std::invalid_argument& ex) {
588     SALOME::ExceptionStruct ExDescription;
589     ExDescription.text = ex.what();
590     ExDescription.type = SALOME::BAD_PARAM;
591     ExDescription.sourceFile = "BLSURFPlugin_Hypothesis::GetSizeMapEntry(name)";
592     ExDescription.lineNumber = 0;
593     throw SALOME::SALOME_Exception(ExDescription);
594   }
595   catch (SALOME_Exception& ex) {
596     THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
597   }
598   return 0;
599 }
600
601 //=============================================================================
602
603 char* BLSURFPlugin_Hypothesis_i::GetAttractorEntry(const char* entry)
604   throw (SALOME::SALOME_Exception)
605 {
606   ASSERT(myBaseImpl);
607   try {
608     return CORBA::string_dup( this->GetImpl()->GetAttractorEntry(entry).c_str());
609   }
610   catch (const std::invalid_argument& ex) {
611     SALOME::ExceptionStruct ExDescription;
612     ExDescription.text = ex.what();
613     ExDescription.type = SALOME::BAD_PARAM;
614     ExDescription.sourceFile = "BLSURFPlugin_Hypothesis::GetAttractorEntry(name)";
615     ExDescription.lineNumber = 0;
616     throw SALOME::SALOME_Exception(ExDescription);
617   }
618   catch (SALOME_Exception& ex) {
619     THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
620   }
621   return 0;
622 }
623
624 //=============================================================================
625
626 void BLSURFPlugin_Hypothesis_i::UnsetEntry(const char* entry)
627 {
628   ASSERT(myBaseImpl); 
629   this->GetImpl()->ClearEntry(entry);
630 //  SMESH::TPythonDump() << _this() << ".UnsetSizeMap( " << entry << " )";
631 }
632
633 //=============================================================================
634
635 BLSURFPlugin::string_array* BLSURFPlugin_Hypothesis_i::GetSizeMapEntries()
636 {
637   ASSERT(myBaseImpl);
638   BLSURFPlugin::string_array_var result = new BLSURFPlugin::string_array();
639
640   const ::BLSURFPlugin_Hypothesis::TSizeMap sizeMaps= this->GetImpl()->_GetSizeMapEntries();
641   result->length( sizeMaps.size() );
642
643   ::BLSURFPlugin_Hypothesis::TSizeMap::const_iterator smIt = sizeMaps.begin();
644   for ( int i = 0 ; smIt != sizeMaps.end(); ++smIt, ++i ) {
645     string entry_sizemap = smIt->first;
646     if ( !smIt->second.empty() ) {
647       entry_sizemap += "|";
648       entry_sizemap += smIt->second;
649     }
650     result[i] = CORBA::string_dup(entry_sizemap.c_str());
651   }
652   return result._retn();
653 }
654
655 //=============================================================================
656
657 BLSURFPlugin::string_array* BLSURFPlugin_Hypothesis_i::GetAttractorEntries()
658 {
659   ASSERT(myBaseImpl);
660   BLSURFPlugin::string_array_var result = new BLSURFPlugin::string_array();
661
662   const ::BLSURFPlugin_Hypothesis::TSizeMap attractors= this->GetImpl()->_GetAttractorEntries();
663   result->length( attractors.size() );
664
665   ::BLSURFPlugin_Hypothesis::TSizeMap::const_iterator atIt = attractors.begin();
666   for ( int i = 0 ; atIt != attractors.end(); ++atIt, ++i ) {
667     string entry_attractor = atIt->first;
668     if ( !atIt->second.empty() ) {
669       entry_attractor += "|";
670       entry_attractor += atIt->second;
671     }
672     result[i] = CORBA::string_dup(entry_attractor.c_str());
673   }
674   return result._retn();
675 }
676
677 //=============================================================================
678
679 void BLSURFPlugin_Hypothesis_i::SetSizeMapEntries(const BLSURFPlugin::string_array& sizeMaps)
680   throw (SALOME::SALOME_Exception)
681 {
682   ASSERT(myBaseImpl);
683   for (int i = 0; i < sizeMaps.length(); ++i)
684   {
685     string entry_sizemap = sizeMaps[i].in();
686     int colonPos = entry_sizemap.find( '|' );
687     string entry, sizemap;
688     if ( colonPos == string::npos ) // '|' separator not found
689       entry = entry_sizemap;
690     else {
691       entry = entry_sizemap.substr( 0, colonPos);
692       if ( colonPos < entry_sizemap.size()-1 && entry_sizemap[colonPos] != ' ')
693         sizemap = entry_sizemap.substr( colonPos+1 );
694     }
695     this->GetImpl()->SetSizeMapEntry( entry.c_str(), sizemap.c_str() );
696   }
697 }
698
699 //=============================================================================
700
701 void BLSURFPlugin_Hypothesis_i::ClearSizeMaps()
702 {
703   ASSERT(myBaseImpl);
704   this->GetImpl()->ClearSizeMaps();
705 }
706
707
708 //=============================================================================
709
710 void BLSURFPlugin_Hypothesis_i::SetSizeMap(const GEOM::GEOM_Object_ptr GeomObj,const char* sizeMap)
711 {
712   ASSERT(myBaseImpl);
713   string entry;
714   entry=GeomObj->GetStudyEntry();
715   MESSAGE("IDL : GetName : " << GeomObj->GetName());
716   MESSAGE("IDL : SETSIZEMAP ( "<< entry << " , " << sizeMap << ")"); 
717   SetSizeMapEntry( entry.c_str(),sizeMap);
718 }
719   
720 //=============================================================================
721 void BLSURFPlugin_Hypothesis_i::UnsetSizeMap(const GEOM::GEOM_Object_ptr GeomObj)
722 {
723   ASSERT(myBaseImpl);
724   string entry;
725   entry=GeomObj->GetStudyEntry();
726   MESSAGE("IDL : GetName : " << GeomObj->GetName());
727   MESSAGE("IDL : UNSETSIZEMAP ( "<< entry << ")");
728   UnsetEntry( entry.c_str());
729   SMESH::TPythonDump() << _this() << ".UnsetSizeMap( " << entry.c_str() << " )";
730 }
731
732
733 void BLSURFPlugin_Hypothesis_i::SetAttractor(GEOM::GEOM_Object_ptr GeomObj, const char* attractor)
734 {
735   ASSERT(myBaseImpl);
736   string entry;
737   entry=GeomObj->GetStudyEntry();
738   MESSAGE("IDL : GetName : " << GeomObj->GetName());
739   MESSAGE("IDL : SETATTRACTOR ( "<< entry << " , " << attractor << ")");
740   SetAttractorEntry( entry.c_str(),attractor);
741 }
742
743 void BLSURFPlugin_Hypothesis_i::UnsetAttractor(GEOM::GEOM_Object_ptr GeomObj)
744 {
745   ASSERT(myBaseImpl);
746   string entry;
747   entry=GeomObj->GetStudyEntry();
748   MESSAGE("IDL : GetName : " << GeomObj->GetName());
749   MESSAGE("IDL : UNSETATTRACTOR ( "<< entry << ")");
750   UnsetEntry( entry.c_str());
751   SMESH::TPythonDump() << _this() << ".UnsetAttractor( " << entry.c_str() << " )";
752 }
753
754
755
756
757 /*
758 void BLSURFPlugin_Hypothesis_i::SetCustomSizeMap(GEOM::GEOM_Object_ptr GeomObj, const char* sizeMap)
759 {}
760
761 void BLSURFPlugin_Hypothesis_i::UnsetCustomSizeMap(GEOM::GEOM_Object_ptr GeomObj)
762 {}
763
764 void BLSURFPlugin_Hypothesis_i::SetCustomSizeMapEntry(const char* entry,const char* sizeMap )  throw (SALOME::SALOME_Exception)
765 {}
766
767 char* BLSURFPlugin_Hypothesis_i::GetCustomSizeMapEntry(const char* entry)  throw (SALOME::SALOME_Exception)
768 {}
769
770 void BLSURFPlugin_Hypothesis_i::UnsetCustomSizeMapEntry(const char* entry)
771 {
772   ASSERT(myBaseImpl);
773   this->GetImpl()->UnsetCustomSizeMap(entry);
774   SMESH::TPythonDump() << _this() << ".UnsetCustomSizeMap( " << entry << " )";
775 }
776
777
778 BLSURFPlugin::string_array* BLSURFPlugin_Hypothesis_i::GetCustomSizeMapEntries()
779 {}
780
781 */
782
783
784 ///////////////////////
785 // ENFORCED VERTEXES //
786 ///////////////////////
787
788 BLSURFPlugin::TEnforcedVertexMap* BLSURFPlugin_Hypothesis_i::GetAllEnforcedVertices()
789 {
790   MESSAGE("IDL: GetAllEnforcedVertices()");
791   ASSERT(myBaseImpl);
792   BLSURFPlugin::TEnforcedVertexMap_var resultMap = new BLSURFPlugin::TEnforcedVertexMap();
793   const ::BLSURFPlugin_Hypothesis::TEnforcedVertexMap enforcedVertexMap = this->GetImpl()->_GetAllEnforcedVertices();
794   resultMap->length(enforcedVertexMap.size());
795   MESSAGE("Enforced Vertex map size is " << enforcedVertexMap.size());
796
797   ::BLSURFPlugin_Hypothesis::TEnforcedVertexList enforcedVertexList;
798   ::BLSURFPlugin_Hypothesis::TEnforcedVertexMap::const_iterator evmIt = enforcedVertexMap.begin();
799   for ( int i = 0 ; evmIt != enforcedVertexMap.end(); ++evmIt, ++i ) {
800     string entry = evmIt->first;
801     MESSAGE("Entry: " << entry);
802     enforcedVertexList = evmIt->second;
803
804     BLSURFPlugin::TEnforcedVertexMapElement_var mapElement = new BLSURFPlugin::TEnforcedVertexMapElement();
805
806     BLSURFPlugin::TEnforcedVertexList_var vertexList = new BLSURFPlugin::TEnforcedVertexList();
807     vertexList->length(enforcedVertexList.size());
808     MESSAGE("Number of enforced vertices: " << enforcedVertexList.size());
809
810     ::BLSURFPlugin_Hypothesis::TEnforcedVertexList::const_iterator evlIt = enforcedVertexList.begin();
811     for ( int j = 0 ; evlIt != enforcedVertexList.end(); ++evlIt, ++j ) {
812       MESSAGE("Enforced Vertex #" << j);
813       BLSURFPlugin::TEnforcedVertex_var enforcedVertex = new BLSURFPlugin::TEnforcedVertex();
814       enforcedVertex->length(3);
815       enforcedVertex[0] = (*evlIt)[0];
816       enforcedVertex[1] = (*evlIt)[1];
817       enforcedVertex[2] = (*evlIt)[2];
818       vertexList[j] = enforcedVertex;
819       MESSAGE("Enforced vertex: " << enforcedVertex[0] << ", " << enforcedVertex[1] << ", " << enforcedVertex[2]);
820     }
821
822     mapElement->entry = CORBA::string_dup(entry.c_str());
823     mapElement->vertexList = vertexList;
824
825     resultMap[i] = mapElement;
826
827   }
828   return resultMap._retn();
829 }
830
831 void BLSURFPlugin_Hypothesis_i::ClearAllEnforcedVertices()
832 {
833   ASSERT(myBaseImpl);
834   this->GetImpl()->ClearAllEnforcedVertices();
835   SMESH::TPythonDump() << _this() << ".ClearAllEnforcedVertices()";
836 }
837
838 /*!
839   * Set/get/unset an enforced vertex on geom object
840   */
841 void BLSURFPlugin_Hypothesis_i::SetEnforcedVertex(GEOM::GEOM_Object_ptr GeomObj, CORBA::Double x, CORBA::Double y, CORBA::Double z)
842   throw (SALOME::SALOME_Exception)
843 {
844   ASSERT(myBaseImpl);
845   // TODO check that GeomObj is a face => in engine ?
846   string entry = GeomObj->GetStudyEntry();
847   MESSAGE("IDL : GetName : " << GeomObj->GetName());
848   MESSAGE("IDL : SetEnforcedVertex ( "<< entry << ", " << x << ", " << y << ", " << z << ")");
849   try {
850     SetEnforcedVertexEntry(entry.c_str(), x, y, z);
851   }
852   catch (SALOME_Exception& ex) {
853     THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
854   }
855 }
856
857
858 BLSURFPlugin::TEnforcedVertexList* BLSURFPlugin_Hypothesis_i::GetEnforcedVertices(GEOM::GEOM_Object_ptr GeomObj)
859   throw (SALOME::SALOME_Exception)
860 {
861   ASSERT(myBaseImpl);
862   string entry = GeomObj->GetStudyEntry();
863   MESSAGE("IDL : GetName : " << GeomObj->GetName());
864   MESSAGE("IDL : GetEnforcedVertexList ( "<< entry << ")");
865   try {
866     return GetEnforcedVerticesEntry(entry.c_str());
867   }
868   catch (SALOME_Exception& ex) {
869     THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
870   }
871 }
872
873
874 void BLSURFPlugin_Hypothesis_i::UnsetEnforcedVertex(GEOM::GEOM_Object_ptr GeomObj, CORBA::Double x, CORBA::Double y, CORBA::Double z)
875   throw (SALOME::SALOME_Exception)
876 {
877   ASSERT(myBaseImpl);
878   string entry = GeomObj->GetStudyEntry();
879   MESSAGE("IDL : GetName : " << GeomObj->GetName());
880   MESSAGE("IDL : UnsetEnforcedVertex ( "<< entry << ", " << x << ", " << y << ", " << z << ")");
881
882   try {
883     UnsetEnforcedVertexEntry(entry.c_str(), x, y, z);
884   }
885   catch (SALOME_Exception& ex) {
886     THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
887   }
888 }
889
890
891 void BLSURFPlugin_Hypothesis_i::UnsetEnforcedVertices(GEOM::GEOM_Object_ptr GeomObj)
892   throw (SALOME::SALOME_Exception)
893 {
894   ASSERT(myBaseImpl);;
895   string entry = GeomObj->GetStudyEntry();
896   MESSAGE("IDL : GetName : " << GeomObj->GetName());
897   MESSAGE("IDL : UnsetEnforcedVertices ( "<< entry << ")");
898
899   try {
900     UnsetEnforcedVerticesEntry(entry.c_str());
901   }
902   catch (SALOME_Exception& ex) {
903     THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
904   }
905 }
906
907
908 /*!
909   * Set/get/unset an enforced vertex on geom object given by entry
910   */
911 void BLSURFPlugin_Hypothesis_i::SetEnforcedVertexEntry(const char* entry, double x, double y, double z)
912   throw (SALOME::SALOME_Exception)
913 {
914   ASSERT(myBaseImpl);
915   MESSAGE("IDL : SETENFORCEDVERTEX START - ENTRY: " << entry << " VERTEX: " << x << " " << y << " " << z);
916   bool newValue = false;
917   
918   try {
919     ::BLSURFPlugin_Hypothesis::TEnforcedVertexList vertexList = this->GetImpl()->GetEnforcedVertices(entry);
920     ::BLSURFPlugin_Hypothesis::TEnforcedVertex vertex;
921     vertex.push_back(x);
922     vertex.push_back(y);
923     vertex.push_back(z);
924     if (vertexList.find(vertex) == vertexList.end()) {
925       MESSAGE("Vertex not found: add it in vertexList")
926       newValue = true;
927     }
928     else
929       MESSAGE("Vertex already found")
930   }
931   catch (const std::invalid_argument& ex) {
932     // no enforced vertex for entry
933     MESSAGE("Entry not found : add it to the list")
934     newValue = true;
935   }
936   catch (SALOME_Exception& ex) {
937     THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
938   }
939   
940   if ( newValue ) {
941     this->GetImpl()->SetEnforcedVertex(entry, x, y, z);
942     SMESH::TPythonDump() << _this() << ".SetEnforcedVertex("
943                          << entry << ", "
944                          << x << ", "
945                          << y << ", "
946                          << z << ")";
947   }
948   MESSAGE("IDL : SETENFORCEDVERTEX END - ENTRY: " << entry);
949 }
950 /*
951 void BLSURFPlugin_Hypothesis_i::SetEnforcedVertexListEntry(const char* entry, BLSURFPlugin::TEnforcedVertexList& vertexList)
952   throw (SALOME::SALOME_Exception)
953 {
954   ASSERT(myBaseImpl);
955 }
956 */
957
958 BLSURFPlugin::TEnforcedVertexList* BLSURFPlugin_Hypothesis_i::GetEnforcedVerticesEntry(const char* entry)
959   throw (SALOME::SALOME_Exception)
960 {
961   ASSERT(myBaseImpl);
962   MESSAGE("ENGINE : GETENFORCEDVERTICES START ENTRY : " << entry);
963   
964   try {
965     BLSURFPlugin::TEnforcedVertexList_var vertexList = new BLSURFPlugin::TEnforcedVertexList();
966     ::BLSURFPlugin_Hypothesis::TEnforcedVertexList _vList = this->GetImpl()->GetEnforcedVertices(entry);
967     vertexList->length(_vList.size());
968     MESSAGE("Number of enforced vertices: " << _vList.size());
969     ::BLSURFPlugin_Hypothesis::TEnforcedVertexList::const_iterator evlIt = _vList.begin();
970     for ( int i = 0; evlIt != _vList.end() ; ++evlIt, ++i ) {
971       BLSURFPlugin::TEnforcedVertex_var enforcedVertex = new BLSURFPlugin::TEnforcedVertex();
972       enforcedVertex->length(3);
973       MESSAGE("Enforced vertex #" << i << ": "<< (*evlIt)[0] << ", " << (*evlIt)[1] << ", " << (*evlIt)[2]);
974       enforcedVertex[0] = (*evlIt)[0];
975       enforcedVertex[1] = (*evlIt)[1];
976       enforcedVertex[2] = (*evlIt)[2];
977       vertexList[i] = enforcedVertex;
978     }
979     return vertexList._retn();
980   }
981   catch (const std::invalid_argument& ex) {
982     SALOME::ExceptionStruct ExDescription;
983     ExDescription.text = ex.what();
984     ExDescription.type = SALOME::BAD_PARAM;
985     ExDescription.sourceFile = "BLSURFPlugin_Hypothesis_i::GetEnforcedVerticesEntry(entry)";
986     ExDescription.lineNumber = 945;
987     throw SALOME::SALOME_Exception(ExDescription);
988   }
989   catch(const std::exception& ex) {
990     THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
991   }
992
993   MESSAGE("ENGINE : GETENFORCEDVERTICES END ENTRY : " << entry);
994 }
995
996
997 void BLSURFPlugin_Hypothesis_i::UnsetEnforcedVertexEntry(const char* entry, CORBA::Double x, CORBA::Double y, CORBA::Double z)
998   throw (SALOME::SALOME_Exception)
999 {
1000   ASSERT(myBaseImpl);
1001   MESSAGE("ENGINE : UNSETENFORCEDVERTEX START ENTRY : " << entry);
1002   
1003   try {
1004     this->GetImpl()->ClearEnforcedVertex(entry, x, y, z);
1005     SMESH::TPythonDump() << _this() << ".UnsetEnforcedVertex("
1006                          << entry << ", "
1007                          << x << ", "
1008                          << y << ", "
1009                          << z << ")";
1010   }
1011   catch (const std::invalid_argument& ex) {
1012     SALOME::ExceptionStruct ExDescription;
1013     ExDescription.text = ex.what();
1014     ExDescription.type = SALOME::BAD_PARAM;
1015     ExDescription.sourceFile = "BLSURFPlugin_Hypothesis_i::UnsetEnforcedVertexEntry(entry,x,y,z)";
1016     ExDescription.lineNumber = 1003;
1017     throw SALOME::SALOME_Exception(ExDescription);
1018   }
1019   catch(const std::exception& ex) {
1020     THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
1021   }
1022
1023   MESSAGE("ENGINE : UNSETENFORCEDVERTEX END ENTRY : " << entry);
1024 }
1025 /*
1026 void BLSURFPlugin_Hypothesis_i::UnsetEnforcedVertexListEntry(const char* entry, BLSURFPlugin::TEnforcedVertexList& vertexList)
1027   throw (SALOME::SALOME_Exception)
1028 {
1029   ASSERT(myBaseImpl);
1030 }
1031 */
1032 void BLSURFPlugin_Hypothesis_i::UnsetEnforcedVerticesEntry(const char* entry)
1033   throw (SALOME::SALOME_Exception)
1034 {
1035   ASSERT(myBaseImpl);
1036   MESSAGE("ENGINE : UNSETENFORCEDVERTICES START ENTRY : " << entry);
1037   
1038   try {
1039     this->GetImpl()->ClearEnforcedVertices(entry);
1040     SMESH::TPythonDump() << _this() << ".UnsetEnforcedVertices(" << entry << ")";
1041   }
1042   catch (const std::invalid_argument& ex) {
1043     SALOME::ExceptionStruct ExDescription;
1044     ExDescription.text = ex.what();
1045     ExDescription.type = SALOME::BAD_PARAM;
1046     ExDescription.sourceFile = "BLSURFPlugin_Hypothesis_i::UnsetEnforcedVerticesEntry(entry)";
1047     ExDescription.lineNumber = 1051;
1048     throw SALOME::SALOME_Exception(ExDescription);
1049   }
1050   catch(const std::exception& ex) {
1051     THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
1052   }
1053
1054   MESSAGE("ENGINE : UNSETENFORCEDVERTICES END ENTRY : " << entry);
1055 }
1056
1057
1058 ///////////////////////
1059
1060
1061
1062
1063
1064 //=============================================================================
1065 /*!
1066  *  BLSURFPlugin_Hypothesis_i::GetImpl
1067  *
1068  *  Get implementation
1069  */
1070 //=============================================================================
1071 ::BLSURFPlugin_Hypothesis* BLSURFPlugin_Hypothesis_i::GetImpl()
1072 {
1073   // MESSAGE("BLSURFPlugin_Hypothesis_i::GetImpl");
1074   return (::BLSURFPlugin_Hypothesis*)myBaseImpl;
1075 }
1076
1077 //================================================================================
1078 /*!
1079  * \brief Verify whether hypothesis supports given entity type 
1080   * \param type - dimension (see SMESH::Dimension enumeration)
1081   * \retval CORBA::Boolean - TRUE if dimension is supported, FALSE otherwise
1082  * 
1083  * Verify whether hypothesis supports given entity type (see SMESH::Dimension enumeration)
1084  */
1085 //================================================================================  
1086 CORBA::Boolean BLSURFPlugin_Hypothesis_i::IsDimSupported( SMESH::Dimension type )
1087 {
1088   return type == SMESH::DIM_2D;
1089 }