]> SALOME platform Git repositories - plugins/blsurfplugin.git/blob - src/BLSURFPlugin/BLSURFPlugin_Hypothesis_i.cxx
Salome HOME
9541fad2ce685527af6d3243a340ffa28d466120
[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::GetAllEnforcedVerteces()
789 {
790   ASSERT(myBaseImpl);
791   BLSURFPlugin::TEnforcedVertexMap_var resultMap = new BLSURFPlugin::TEnforcedVertexMap();
792   const ::BLSURFPlugin_Hypothesis::TEnforcedVertexMap enforcedVertexMap = this->GetImpl()->_GetAllEnforcedVerteces();
793   resultMap->length(enforcedVertexMap.size());
794
795   ::BLSURFPlugin_Hypothesis::TEnforcedVertexList enforcedVertexList;
796   ::BLSURFPlugin_Hypothesis::TEnforcedVertexMap::const_iterator evmIt = enforcedVertexMap.begin();
797   for ( int i = 0 ; evmIt != enforcedVertexMap.end(); ++evmIt, ++i ) {
798     string entry = evmIt->first;
799     enforcedVertexList = evmIt->second;
800
801     BLSURFPlugin::TEnforcedVertexMapElement_var mapElement = new BLSURFPlugin::TEnforcedVertexMapElement();
802
803     BLSURFPlugin::TEnforcedVertexList_var vertexList = new BLSURFPlugin::TEnforcedVertexList();
804     vertexList->length(enforcedVertexList.size());
805
806     ::BLSURFPlugin_Hypothesis::TEnforcedVertexList::const_iterator evlIt = enforcedVertexList.begin();
807     for ( int j = 0 ; evlIt != enforcedVertexList.end(); ++evlIt, ++j ) {
808       BLSURFPlugin::TEnforcedVertex_var enforcedVertex = new BLSURFPlugin::TEnforcedVertex();
809       enforcedVertex[0] = (*evlIt)[0];
810       enforcedVertex[1] = (*evlIt)[1];
811       enforcedVertex[2] = (*evlIt)[2];
812       vertexList[j] = enforcedVertex;
813     }
814
815     mapElement->entry = CORBA::string_dup(entry.c_str());
816     mapElement->vertexList = vertexList;
817
818     resultMap[i] = mapElement;
819
820   }
821   return resultMap._retn();
822 }
823
824 void BLSURFPlugin_Hypothesis_i::ClearAllEnforcedVerteces()
825 {
826   ASSERT(myBaseImpl);
827   this->GetImpl()->ClearAllEnforcedVerteces();
828   SMESH::TPythonDump() << _this() << ".ClearAllEnforcedVerteces()";
829 }
830
831 /*!
832   * Set/get/unset an enforced vertex on geom object
833   */
834 void BLSURFPlugin_Hypothesis_i::SetEnforcedVertex(GEOM::GEOM_Object_ptr GeomObj, CORBA::Double x, CORBA::Double y, CORBA::Double z)
835   throw (SALOME::SALOME_Exception)
836 {
837   ASSERT(myBaseImpl);
838   // TODO check that GeomObj is a face => in engine ?
839   string entry = GeomObj->GetStudyEntry();
840   MESSAGE("IDL : GetName : " << GeomObj->GetName());
841   MESSAGE("IDL : SetEnforcedVertex ( "<< entry << ", " << x << ", " << y << ", " << z << ")");
842   try {
843     SetEnforcedVertexEntry(entry.c_str(), x, y, z);
844   }
845   catch (SALOME_Exception& ex) {
846     THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
847   }
848 }
849
850
851 BLSURFPlugin::TEnforcedVertexList* BLSURFPlugin_Hypothesis_i::GetEnforcedVerteces(GEOM::GEOM_Object_ptr GeomObj)
852   throw (SALOME::SALOME_Exception)
853 {
854   ASSERT(myBaseImpl);
855   string entry = GeomObj->GetStudyEntry();
856   MESSAGE("IDL : GetName : " << GeomObj->GetName());
857   MESSAGE("IDL : GetEnforcedVertexList ( "<< entry << ")");
858   try {
859     return GetEnforcedVertecesEntry(entry.c_str());
860   }
861   catch (SALOME_Exception& ex) {
862     THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
863   }
864 }
865
866
867 void BLSURFPlugin_Hypothesis_i::UnsetEnforcedVertex(GEOM::GEOM_Object_ptr GeomObj, CORBA::Double x, CORBA::Double y, CORBA::Double z)
868   throw (SALOME::SALOME_Exception)
869 {
870   ASSERT(myBaseImpl);
871   string entry = GeomObj->GetStudyEntry();
872   MESSAGE("IDL : GetName : " << GeomObj->GetName());
873   MESSAGE("IDL : UnsetEnforcedVertex ( "<< entry << ", " << x << ", " << y << ", " << z << ")");
874
875   try {
876     UnsetEnforcedVertexEntry(entry.c_str(), x, y, z);
877   }
878   catch (SALOME_Exception& ex) {
879     THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
880   }
881 }
882
883
884 void BLSURFPlugin_Hypothesis_i::UnsetEnforcedVerteces(GEOM::GEOM_Object_ptr GeomObj)
885   throw (SALOME::SALOME_Exception)
886 {
887   ASSERT(myBaseImpl);;
888   string entry = GeomObj->GetStudyEntry();
889   MESSAGE("IDL : GetName : " << GeomObj->GetName());
890   MESSAGE("IDL : UnsetEnforcedVerteces ( "<< entry << ")");
891
892   try {
893     UnsetEnforcedVertecesEntry(entry.c_str());
894   }
895   catch (SALOME_Exception& ex) {
896     THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
897   }
898 }
899
900
901 /*!
902   * Set/get/unset an enforced vertex on geom object given by entry
903   */
904 void BLSURFPlugin_Hypothesis_i::SetEnforcedVertexEntry(const char* entry, double x, double y, double z)
905   throw (SALOME::SALOME_Exception)
906 {
907   ASSERT(myBaseImpl);
908   MESSAGE("IDL : SETENFORCEDVERTEX START - ENTRY: " << entry << " VERTEX: " << x << " " << y << " " << z);
909   bool newValue = false;
910   
911   try {
912     ::BLSURFPlugin_Hypothesis::TEnforcedVertexList vertexList = this->GetImpl()->GetEnforcedVerteces(entry);
913     ::BLSURFPlugin_Hypothesis::TEnforcedVertex vertex;
914     vertex.push_back(x);
915     vertex.push_back(y);
916     vertex.push_back(z);
917     if (vertexList.find(vertex) == vertexList.end()) {
918       MESSAGE("Vertex not found: add it in vertexList")
919       newValue = true;
920     }
921     else
922       MESSAGE("Vertex already found")
923   }
924   catch (const std::invalid_argument& ex) {
925     // no enforced vertex for entry
926     MESSAGE("Entry not found : add it to the list")
927     newValue = true;
928   }
929   catch (SALOME_Exception& ex) {
930     THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
931   }
932   
933   if ( newValue ) {
934     this->GetImpl()->SetEnforcedVertex(entry, x, y, z);
935     SMESH::TPythonDump() << _this() << ".SetEnforcedVertex("
936                          << entry << ", "
937                          << x << ", "
938                          << y << ", "
939                          << z << ")";
940   }
941   MESSAGE("IDL : SETENFORCEDVERTEX END - ENTRY: " << entry);
942 }
943 /*
944 void BLSURFPlugin_Hypothesis_i::SetEnforcedVertexListEntry(const char* entry, BLSURFPlugin::TEnforcedVertexList& vertexList)
945   throw (SALOME::SALOME_Exception)
946 {
947   ASSERT(myBaseImpl);
948 }
949 */
950
951 BLSURFPlugin::TEnforcedVertexList* BLSURFPlugin_Hypothesis_i::GetEnforcedVertecesEntry(const char* entry)
952   throw (SALOME::SALOME_Exception)
953 {
954   ASSERT(myBaseImpl);
955   MESSAGE("ENGINE : GETENFORCEDVERTECES START ENTRY : " << entry);
956   
957   try {
958     BLSURFPlugin::TEnforcedVertexList_var vertexList = new BLSURFPlugin::TEnforcedVertexList();
959     ::BLSURFPlugin_Hypothesis::TEnforcedVertexList _vList = this->GetImpl()->GetEnforcedVerteces(entry);
960     vertexList->length(_vList.size());
961     MESSAGE("Number of enforced verteces: " << _vList.size());
962     ::BLSURFPlugin_Hypothesis::TEnforcedVertexList::const_iterator evlIt = _vList.begin();
963     for ( int i = 0; evlIt != _vList.end() ; ++evlIt, ++i ) {
964       BLSURFPlugin::TEnforcedVertex_var enforcedVertex = new BLSURFPlugin::TEnforcedVertex();
965       enforcedVertex->length(3);
966       MESSAGE("Enforced vertex #" << i << ": "<< (*evlIt)[0] << ", " << (*evlIt)[1] << ", " << (*evlIt)[2]);
967       enforcedVertex[0] = (*evlIt)[0];
968       enforcedVertex[1] = (*evlIt)[1];
969       enforcedVertex[2] = (*evlIt)[2];
970       vertexList[i] = enforcedVertex;
971     }
972     return vertexList._retn();
973   }
974   catch (const std::invalid_argument& ex) {
975     SALOME::ExceptionStruct ExDescription;
976     ExDescription.text = ex.what();
977     ExDescription.type = SALOME::BAD_PARAM;
978     ExDescription.sourceFile = "BLSURFPlugin_Hypothesis_i::GetEnforcedVertecesEntry(entry)";
979     ExDescription.lineNumber = 945;
980     throw SALOME::SALOME_Exception(ExDescription);
981   }
982   catch(const std::exception& ex) {
983     THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
984   }
985
986   MESSAGE("ENGINE : GETENFORCEDVERTECES END ENTRY : " << entry);
987 }
988
989
990 void BLSURFPlugin_Hypothesis_i::UnsetEnforcedVertexEntry(const char* entry, CORBA::Double x, CORBA::Double y, CORBA::Double z)
991   throw (SALOME::SALOME_Exception)
992 {
993   ASSERT(myBaseImpl);
994   MESSAGE("ENGINE : UNSETENFORCEDVERTEX START ENTRY : " << entry);
995   
996   try {
997     this->GetImpl()->ClearEnforcedVertex(entry, x, y, z);
998     SMESH::TPythonDump() << _this() << ".UnsetEnforcedVertex("
999                          << entry << ", "
1000                          << x << ", "
1001                          << y << ", "
1002                          << z << ")";
1003   }
1004   catch (const std::invalid_argument& ex) {
1005     SALOME::ExceptionStruct ExDescription;
1006     ExDescription.text = ex.what();
1007     ExDescription.type = SALOME::BAD_PARAM;
1008     ExDescription.sourceFile = "BLSURFPlugin_Hypothesis_i::UnsetEnforcedVertexEntry(entry,x,y,z)";
1009     ExDescription.lineNumber = 1003;
1010     throw SALOME::SALOME_Exception(ExDescription);
1011   }
1012   catch(const std::exception& ex) {
1013     THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
1014   }
1015
1016   MESSAGE("ENGINE : UNSETENFORCEDVERTEX END ENTRY : " << entry);
1017 }
1018 /*
1019 void BLSURFPlugin_Hypothesis_i::UnsetEnforcedVertexListEntry(const char* entry, BLSURFPlugin::TEnforcedVertexList& vertexList)
1020   throw (SALOME::SALOME_Exception)
1021 {
1022   ASSERT(myBaseImpl);
1023 }
1024 */
1025 void BLSURFPlugin_Hypothesis_i::UnsetEnforcedVertecesEntry(const char* entry)
1026   throw (SALOME::SALOME_Exception)
1027 {
1028   ASSERT(myBaseImpl);
1029   MESSAGE("ENGINE : UNSETENFORCEDVERTECES START ENTRY : " << entry);
1030   
1031   try {
1032     this->GetImpl()->ClearEnforcedVerteces(entry);
1033     SMESH::TPythonDump() << _this() << ".UnsetEnforcedVerteces(" << entry << ")";
1034   }
1035   catch (const std::invalid_argument& ex) {
1036     SALOME::ExceptionStruct ExDescription;
1037     ExDescription.text = ex.what();
1038     ExDescription.type = SALOME::BAD_PARAM;
1039     ExDescription.sourceFile = "BLSURFPlugin_Hypothesis_i::UnsetEnforcedVertecesEntry(entry)";
1040     ExDescription.lineNumber = 1051;
1041     throw SALOME::SALOME_Exception(ExDescription);
1042   }
1043   catch(const std::exception& ex) {
1044     THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
1045   }
1046
1047   MESSAGE("ENGINE : UNSETENFORCEDVERTECES END ENTRY : " << entry);
1048 }
1049
1050
1051 ///////////////////////
1052
1053
1054
1055
1056
1057 //=============================================================================
1058 /*!
1059  *  BLSURFPlugin_Hypothesis_i::GetImpl
1060  *
1061  *  Get implementation
1062  */
1063 //=============================================================================
1064 ::BLSURFPlugin_Hypothesis* BLSURFPlugin_Hypothesis_i::GetImpl()
1065 {
1066   // MESSAGE("BLSURFPlugin_Hypothesis_i::GetImpl");
1067   return (::BLSURFPlugin_Hypothesis*)myBaseImpl;
1068 }
1069
1070 //================================================================================
1071 /*!
1072  * \brief Verify whether hypothesis supports given entity type 
1073   * \param type - dimension (see SMESH::Dimension enumeration)
1074   * \retval CORBA::Boolean - TRUE if dimension is supported, FALSE otherwise
1075  * 
1076  * Verify whether hypothesis supports given entity type (see SMESH::Dimension enumeration)
1077  */
1078 //================================================================================  
1079 CORBA::Boolean BLSURFPlugin_Hypothesis_i::IsDimSupported( SMESH::Dimension type )
1080 {
1081   return type == SMESH::DIM_2D;
1082 }