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