]> SALOME platform Git repositories - plugins/blsurfplugin.git/blob - src/BLSURFPlugin/BLSURFPlugin_Hypothesis_i.cxx
Salome HOME
Merge from BR_EDF_PAL_1456
[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_Gen_i.hxx"
29 #include "SMESH_PythonDump.hxx"
30 #include "GEOM_Object.hxx"
31
32 #include "Utils_CorbaException.hxx"
33 #include "utilities.h"
34
35 #include <stdexcept>
36 #include <cstring>
37 #include "boost/regex.hpp"
38
39 //=============================================================================
40 /*!
41  *  BLSURFPlugin_Hypothesis_i::BLSURFPlugin_Hypothesis_i
42  *
43  *  Constructor
44  */
45 //=============================================================================
46 BLSURFPlugin_Hypothesis_i::BLSURFPlugin_Hypothesis_i(PortableServer::POA_ptr thePOA, int theStudyId,
47     ::SMESH_Gen* theGenImpl) :
48   SALOME::GenericObj_i(thePOA), SMESH_Hypothesis_i(thePOA) {
49   MESSAGE( "BLSURFPlugin_Hypothesis_i::BLSURFPlugin_Hypothesis_i" );
50   myBaseImpl = new ::BLSURFPlugin_Hypothesis(theGenImpl->GetANewId(), theStudyId, theGenImpl);
51 }
52
53 //=============================================================================
54 /*!
55  *  BLSURFPlugin_Hypothesis_i::~BLSURFPlugin_Hypothesis_i
56  *
57  *  Destructor
58  */
59 //=============================================================================
60 BLSURFPlugin_Hypothesis_i::~BLSURFPlugin_Hypothesis_i() {
61   MESSAGE( "BLSURFPlugin_Hypothesis_i::~BLSURFPlugin_Hypothesis_i" );
62 }
63
64 /*!
65  *  BLSURFPlugin_Hypothesis_i::SetTopology
66  *
67  *  Set topology
68  */
69
70 //=============================================================================
71 void BLSURFPlugin_Hypothesis_i::SetTopology(CORBA::Long theValue) {
72   // MESSAGE("BLSURFPlugin_Hypothesis_i::SetTopology");
73   ASSERT(myBaseImpl);
74   this->GetImpl()->SetTopology((::BLSURFPlugin_Hypothesis::Topology) theValue);
75   SMESH::TPythonDump() << _this() << ".SetTopology( " << theValue << " )";
76 }
77
78 //=============================================================================
79 /*!
80  *  BLSURFPlugin_Hypothesis_i::GetTopology
81  *
82  *  Get Topology
83  */
84 //=============================================================================
85 CORBA::Long BLSURFPlugin_Hypothesis_i::GetTopology() {
86   // MESSAGE("BLSURFPlugin_Hypothesis_i::GetTopology");
87   ASSERT(myBaseImpl);
88   return this->GetImpl()->GetTopology();
89 }
90
91 //=============================================================================
92
93 //=============================================================================
94 /*!
95  *  BLSURFPlugin_Hypothesis_i::SetPhysicalMesh
96  *
97  *  Set PhysicalMesh
98  */
99
100 //=============================================================================
101 void BLSURFPlugin_Hypothesis_i::SetPhysicalMesh(CORBA::Long theValue) {
102   // MESSAGE("BLSURFPlugin_Hypothesis_i::SetPhysicalMesh");
103   ASSERT(myBaseImpl);
104   this->GetImpl()->SetPhysicalMesh((::BLSURFPlugin_Hypothesis::PhysicalMesh) theValue);
105   SMESH::TPythonDump() << _this() << ".SetPhysicalMesh( " << theValue << " )";
106 }
107
108 //=============================================================================
109 /*!
110  *  BLSURFPlugin_Hypothesis_i::GetPhysicalMesh
111  *
112  *  Get PhysicalMesh
113  */
114 //=============================================================================
115 CORBA::Long BLSURFPlugin_Hypothesis_i::GetPhysicalMesh() {
116   // MESSAGE("BLSURFPlugin_Hypothesis_i::GetPhysicalMesh");
117   ASSERT(myBaseImpl);
118   return this->GetImpl()->GetPhysicalMesh();
119 }
120
121 //=============================================================================
122 /*!
123  *  BLSURFPlugin_Hypothesis_i::SetPhySize
124  *
125  *  Set PhySize
126  */
127 //=============================================================================
128 void BLSURFPlugin_Hypothesis_i::SetPhySize(CORBA::Double theValue) {
129   // MESSAGE("BLSURFPlugin_Hypothesis_i::SetPhySize");
130   ASSERT(myBaseImpl);
131   this->GetImpl()->SetPhySize(theValue);
132   SMESH::TPythonDump() << _this() << ".SetPhySize( " << theValue << " )";
133 }
134
135 //=============================================================================
136 /*!
137  *  BLSURFPlugin_Hypothesis_i::GetPhySize
138  *
139  *  Get PhySize
140  */
141 //=============================================================================
142 CORBA::Double BLSURFPlugin_Hypothesis_i::GetPhySize() {
143   // MESSAGE("BLSURFPlugin_Hypothesis_i::GetPhySize");
144   ASSERT(myBaseImpl);
145   return this->GetImpl()->GetPhySize();
146 }
147
148 //=============================================================================
149 void BLSURFPlugin_Hypothesis_i::SetPhyMin(CORBA::Double theMinSize) {
150   ASSERT(myBaseImpl);
151   if (GetPhyMin() != theMinSize) {
152     this->GetImpl()->SetPhyMin(theMinSize);
153     SMESH::TPythonDump() << _this() << ".SetPhyMin( " << theMinSize << " )";
154   }
155 }
156
157 //=============================================================================
158 CORBA::Double BLSURFPlugin_Hypothesis_i::GetPhyMin() {
159   ASSERT(myBaseImpl);
160   return this->GetImpl()->GetPhyMin();
161 }
162
163 //=============================================================================
164 void BLSURFPlugin_Hypothesis_i::SetPhyMax(CORBA::Double theMaxSize) {
165   ASSERT(myBaseImpl);
166   if (GetPhyMax() != theMaxSize) {
167     this->GetImpl()->SetPhyMax(theMaxSize);
168     SMESH::TPythonDump() << _this() << ".SetPhyMax( " << theMaxSize << " )";
169   }
170 }
171
172 //=============================================================================
173 CORBA::Double BLSURFPlugin_Hypothesis_i::GetPhyMax() {
174   ASSERT(myBaseImpl);
175   return this->GetImpl()->GetPhyMax();
176 }
177
178 //=============================================================================
179 /*!
180  *  BLSURFPlugin_Hypothesis_i::SetGeometricMesh
181  *
182  *  Set GeometricMesh
183  */
184
185 //=============================================================================
186 void BLSURFPlugin_Hypothesis_i::SetGeometricMesh(CORBA::Long theValue) {
187   // MESSAGE("BLSURFPlugin_Hypothesis_i::SetGeometricMesh");
188   ASSERT(myBaseImpl);
189   this->GetImpl()->SetGeometricMesh((::BLSURFPlugin_Hypothesis::GeometricMesh) theValue);
190   SMESH::TPythonDump() << _this() << ".SetGeometricMesh( " << theValue << " )";
191 }
192
193 //=============================================================================
194 /*!
195  *  BLSURFPlugin_Hypothesis_i::GetGeometricMesh
196  *
197  *  Get GeometricMesh
198  */
199 //=============================================================================
200 CORBA::Long BLSURFPlugin_Hypothesis_i::GetGeometricMesh() {
201   // MESSAGE("BLSURFPlugin_Hypothesis_i::GetGeometricMesh");
202   ASSERT(myBaseImpl);
203   return this->GetImpl()->GetGeometricMesh();
204 }
205
206 //=============================================================================
207 /*!
208  *  BLSURFPlugin_Hypothesis_i::SetAngleMeshS
209  *
210  *  Set AngleMeshS
211  */
212 //=============================================================================
213 void BLSURFPlugin_Hypothesis_i::SetAngleMeshS(CORBA::Double theValue) {
214   // MESSAGE("BLSURFPlugin_Hypothesis_i::SetAngleMeshS");
215   ASSERT(myBaseImpl);
216   this->GetImpl()->SetAngleMeshS(theValue);
217   SMESH::TPythonDump() << _this() << ".SetAngleMeshS( " << theValue << " )";
218 }
219
220 //=============================================================================
221 /*!
222  *  BLSURFPlugin_Hypothesis_i::GetAngleMeshS
223  *
224  *  Get AngleMeshS
225  */
226 //=============================================================================
227 CORBA::Double BLSURFPlugin_Hypothesis_i::GetAngleMeshS() {
228   // MESSAGE("BLSURFPlugin_Hypothesis_i::GetAngleMeshS");
229   ASSERT(myBaseImpl);
230   return this->GetImpl()->GetAngleMeshS();
231 }
232
233 //=============================================================================
234 void BLSURFPlugin_Hypothesis_i::SetAngleMeshC(CORBA::Double angle) {
235   ASSERT(myBaseImpl);
236   this->GetImpl()->SetAngleMeshC(angle);
237   SMESH::TPythonDump() << _this() << ".SetAngleMeshC( " << angle << " )";
238 }
239
240 //=============================================================================
241 CORBA::Double BLSURFPlugin_Hypothesis_i::GetAngleMeshC() {
242   ASSERT(myBaseImpl);
243   return this->GetImpl()->GetAngleMeshC();
244 }
245
246 //=============================================================================
247 void BLSURFPlugin_Hypothesis_i::SetGeoMin(CORBA::Double theMinSize) {
248   ASSERT(myBaseImpl);
249   if (GetGeoMin() != theMinSize) {
250     this->GetImpl()->SetGeoMin(theMinSize);
251     SMESH::TPythonDump() << _this() << ".SetGeoMin( " << theMinSize << " )";
252   }
253 }
254
255 //=============================================================================
256 CORBA::Double BLSURFPlugin_Hypothesis_i::GetGeoMin() {
257   ASSERT(myBaseImpl);
258   return this->GetImpl()->GetGeoMin();
259 }
260
261 //=============================================================================
262 void BLSURFPlugin_Hypothesis_i::SetGeoMax(CORBA::Double theMaxSize) {
263   ASSERT(myBaseImpl);
264   if (GetGeoMax() != theMaxSize) {
265     this->GetImpl()->SetGeoMax(theMaxSize);
266     SMESH::TPythonDump() << _this() << ".SetGeoMax( " << theMaxSize << " )";
267   }
268 }
269
270 //=============================================================================
271 CORBA::Double BLSURFPlugin_Hypothesis_i::GetGeoMax() {
272   ASSERT(myBaseImpl);
273   return this->GetImpl()->GetGeoMax();
274 }
275
276 //=============================================================================
277 /*!
278  *  BLSURFPlugin_Hypothesis_i::SetGradation
279  *
280  *  Set Gradation
281  */
282 //=============================================================================
283 void BLSURFPlugin_Hypothesis_i::SetGradation(CORBA::Double theValue) {
284   // MESSAGE("BLSURFPlugin_Hypothesis_i::SetGradation");
285   ASSERT(myBaseImpl);
286   this->GetImpl()->SetGradation(theValue);
287   SMESH::TPythonDump() << _this() << ".SetGradation( " << theValue << " )";
288 }
289
290 //=============================================================================
291 /*!
292  *  BLSURFPlugin_Hypothesis_i::GetGradation
293  *
294  *  Get Gradation
295  */
296 //=============================================================================
297 CORBA::Double BLSURFPlugin_Hypothesis_i::GetGradation() {
298   // MESSAGE("BLSURFPlugin_Hypothesis_i::GetGradation");
299   ASSERT(myBaseImpl);
300   return this->GetImpl()->GetGradation();
301 }
302
303 //=============================================================================
304 /*!
305  *  BLSURFPlugin_Hypothesis_i::SetQuadAllowed
306  *
307  *  Set true or false
308  */
309 //=============================================================================
310 void BLSURFPlugin_Hypothesis_i::SetQuadAllowed(CORBA::Boolean theValue) {
311   // MESSAGE("BLSURFPlugin_Hypothesis_i::SetQuadAllowed");
312   ASSERT(myBaseImpl);
313   this->GetImpl()->SetQuadAllowed(theValue);
314   SMESH::TPythonDump() << _this() << ".SetQuadAllowed( " << theValue << " )";
315 }
316
317 //=============================================================================
318 /*!
319  *  BLSURFPlugin_Hypothesis_i::GetQuadAllowed
320  *
321  *  Get true or false
322  */
323 //=============================================================================
324 CORBA::Boolean BLSURFPlugin_Hypothesis_i::GetQuadAllowed() {
325   // MESSAGE("BLSURFPlugin_Hypothesis_i::GetQuadAllowed");
326   ASSERT(myBaseImpl);
327   return this->GetImpl()->GetQuadAllowed();
328 }
329
330 //=============================================================================
331 /*!
332  *  BLSURFPlugin_Hypothesis_i::SetDecimesh
333  *
334  *  Set true or false
335  */
336 //=============================================================================
337 void BLSURFPlugin_Hypothesis_i::SetDecimesh(CORBA::Boolean theValue) {
338   // MESSAGE("BLSURFPlugin_Hypothesis_i::SetDecimesh");
339   ASSERT(myBaseImpl);
340   this->GetImpl()->SetDecimesh(theValue);
341   SMESH::TPythonDump() << _this() << ".SetDecimesh( " << theValue << " )";
342 }
343
344 //=============================================================================
345 /*!
346  *  BLSURFPlugin_Hypothesis_i::GetDecimesh
347  *
348  *  Get true or false
349  */
350 //=============================================================================
351 CORBA::Boolean BLSURFPlugin_Hypothesis_i::GetDecimesh() {
352   // MESSAGE("BLSURFPlugin_Hypothesis_i::GetDecimesh");
353   ASSERT(myBaseImpl);
354   return this->GetImpl()->GetDecimesh();
355 }
356
357 //=============================================================================
358 void BLSURFPlugin_Hypothesis_i::SetVerbosity(CORBA::Short theVal) throw (SALOME::SALOME_Exception) {
359   ASSERT(myBaseImpl);
360   if (theVal < 0 || theVal > 100)
361     THROW_SALOME_CORBA_EXCEPTION( "Invalid verbosity level",SALOME::BAD_PARAM );
362   this->GetImpl()->SetVerbosity(theVal);
363   SMESH::TPythonDump() << _this() << ".SetVerbosity( " << theVal << " )";
364 }
365
366 //=============================================================================
367
368 CORBA::Short BLSURFPlugin_Hypothesis_i::GetVerbosity() {
369   ASSERT(myBaseImpl);
370   return (CORBA::Short) this->GetImpl()->GetVerbosity();
371 }
372
373 //=============================================================================
374
375 void BLSURFPlugin_Hypothesis_i::SetOptionValue(const char* optionName, const char* optionValue)
376     throw (SALOME::SALOME_Exception) {
377   ASSERT(myBaseImpl);
378   bool valueChanged = false;
379   try {
380     valueChanged = (this->GetImpl()->GetOptionValue(optionName) != optionValue);
381     if (valueChanged)
382       this->GetImpl()->SetOptionValue(optionName, optionValue);
383   } catch (const std::invalid_argument& ex) {
384     SALOME::ExceptionStruct ExDescription;
385     ExDescription.text = ex.what();
386     ExDescription.type = SALOME::BAD_PARAM;
387     ExDescription.sourceFile = "BLSURFPlugin_Hypothesis::SetOptionValue(name,value)";
388     ExDescription.lineNumber = 0;
389     throw SALOME::SALOME_Exception(ExDescription);
390   } catch (SALOME_Exception& ex) {
391     THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
392   }
393   if (valueChanged)
394     SMESH::TPythonDump() << _this() << ".SetOptionValue( '" << optionName << "', '" << optionValue << "' )";
395 }
396
397 //=============================================================================
398
399 char* BLSURFPlugin_Hypothesis_i::GetOptionValue(const char* optionName) throw (SALOME::SALOME_Exception) {
400   ASSERT(myBaseImpl);
401   try {
402     return CORBA::string_dup(this->GetImpl()->GetOptionValue(optionName).c_str());
403   } catch (const std::invalid_argument& ex) {
404     SALOME::ExceptionStruct ExDescription;
405     ExDescription.text = ex.what();
406     ExDescription.type = SALOME::BAD_PARAM;
407     ExDescription.sourceFile = "BLSURFPlugin_Hypothesis::GetOptionValue(name)";
408     ExDescription.lineNumber = 0;
409     throw SALOME::SALOME_Exception(ExDescription);
410   } catch (SALOME_Exception& ex) {
411     THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
412   }
413   return 0;
414 }
415
416 //=============================================================================
417
418 void BLSURFPlugin_Hypothesis_i::UnsetOption(const char* optionName) {
419   ASSERT(myBaseImpl);
420   this->GetImpl()->ClearOption(optionName);
421   SMESH::TPythonDump() << _this() << ".UnsetOption( '" << optionName << "' )";
422 }
423
424 //=============================================================================
425
426 BLSURFPlugin::string_array* BLSURFPlugin_Hypothesis_i::GetOptionValues() {
427   ASSERT(myBaseImpl);
428   BLSURFPlugin::string_array_var result = new BLSURFPlugin::string_array();
429
430   const ::BLSURFPlugin_Hypothesis::TOptionValues & opts = this->GetImpl()->GetOptionValues();
431   result->length(opts.size());
432
433   ::BLSURFPlugin_Hypothesis::TOptionValues::const_iterator opIt = opts.begin();
434   for (int i = 0; opIt != opts.end(); ++opIt, ++i) {
435     string name_value = opIt->first;
436     if (!opIt->second.empty()) {
437       name_value += ":";
438       name_value += opIt->second;
439     }
440     result[i] = CORBA::string_dup(name_value.c_str());
441   }
442   return result._retn();
443 }
444
445 //=============================================================================
446
447 void BLSURFPlugin_Hypothesis_i::SetOptionValues(const BLSURFPlugin::string_array& options)
448     throw (SALOME::SALOME_Exception) {
449   ASSERT(myBaseImpl);
450   for (int i = 0; i < options.length(); ++i) {
451     string name_value = options[i].in();
452     int colonPos = name_value.find(':');
453     string name, value;
454     if (colonPos == string::npos) // ':' not found
455       name = name_value;
456     else {
457       name = name_value.substr(0, colonPos);
458       if (colonPos < name_value.size() - 1 && name_value[colonPos] != ' ')
459         value = name_value.substr(colonPos + 1);
460     }
461     SetOptionValue(name.c_str(), value.c_str());
462   }
463 }
464
465 //=============================================================================
466
467 void BLSURFPlugin_Hypothesis_i::SetSizeMapEntry(const char* entry, const char* sizeMap)
468     throw (SALOME::SALOME_Exception) {
469   ASSERT(myBaseImpl);
470   MESSAGE("ENGINE : SETSIZEMAP START ENTRY : " << entry);
471   bool valueChanged = false;
472   try {
473     valueChanged = (this->GetImpl()->GetSizeMapEntry(entry) != sizeMap);
474     if (valueChanged)
475       this->GetImpl()->SetSizeMapEntry(entry, sizeMap);
476   } catch (const std::invalid_argument& ex) {
477     SALOME::ExceptionStruct ExDescription;
478     ExDescription.text = ex.what();
479     ExDescription.type = SALOME::BAD_PARAM;
480     ExDescription.sourceFile = "BLSURFPlugin_Hypothesis::SetSizeMapEntry(entry,sizemap)";
481     ExDescription.lineNumber = 0;
482     throw SALOME::SALOME_Exception(ExDescription);
483   } catch (SALOME_Exception& ex) {
484     THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
485   }
486   MESSAGE("ENGINE : SETSIZEMAP END ENTRY : " << entry);
487   if (valueChanged)
488     SMESH::TPythonDump() << _this() << ".SetSizeMap(" << entry << ", '" << sizeMap << "' )";
489 }
490
491 //=============================================================================
492
493 void BLSURFPlugin_Hypothesis_i::SetAttractorEntry(const char* entry, const char* attractor)
494     throw (SALOME::SALOME_Exception) {
495   ASSERT(myBaseImpl);
496   MESSAGE("ENGINE : SETATTRACTOR START ENTRY : " << entry);
497   bool valueChanged = false;
498   try {
499     valueChanged = ( this->GetImpl()->GetAttractorEntry(entry) != attractor );
500     if ( valueChanged ) {
501       //boost::regex re("^ATTRACTOR\\((?:(-?0(\\.\\d*)*|-?[1-9]+\\d*(\\.\\d*)*|-?\\.(\\d)+);){5}(True|False)\\)$");
502       boost::regex re("^ATTRACTOR\\((?:(-?0(\\.\\d*)*|-?[1-9]+\\d*(\\.\\d*)*|-?\\.(\\d)+);){5}(True|False)(?:;(-?0(\\.\\d*)*|-?[1-9]+\\d*(\\.\\d*)*|-?\\.(\\d)+))?\\)$");
503       if (!boost::regex_match(string(attractor), re))
504         throw std::invalid_argument("Error: an attractor is defined with the following pattern: ATTRACTOR(xa;ya;za;a;b;True|False;d(opt.))");
505       this->GetImpl()->SetAttractorEntry(entry, attractor);
506     }
507   } catch (const std::invalid_argument& ex) {
508     SALOME::ExceptionStruct ExDescription;
509     ExDescription.text = ex.what();
510     ExDescription.type = SALOME::BAD_PARAM;
511     ExDescription.sourceFile = "BLSURFPlugin_Hypothesis::SetAttractorEntry(entry,attractor)";
512     ExDescription.lineNumber = 0;
513     throw SALOME::SALOME_Exception(ExDescription);
514   } catch (SALOME_Exception& ex) {
515     THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
516   }
517   MESSAGE("ENGINE : SETATTRACTOR END ENTRY : " << entry);
518   if (valueChanged)
519     SMESH::TPythonDump() << _this() << ".SetAttractor(" << entry << ", '" << attractor << "' )";
520 }
521
522 //=============================================================================
523
524 char* BLSURFPlugin_Hypothesis_i::GetSizeMapEntry(const char* entry) throw (SALOME::SALOME_Exception) {
525   ASSERT(myBaseImpl);
526   try {
527     return CORBA::string_dup(this->GetImpl()->GetSizeMapEntry(entry).c_str());
528   } catch (const std::invalid_argument& ex) {
529     SALOME::ExceptionStruct ExDescription;
530     ExDescription.text = ex.what();
531     ExDescription.type = SALOME::BAD_PARAM;
532     ExDescription.sourceFile = "BLSURFPlugin_Hypothesis::GetSizeMapEntry(name)";
533     ExDescription.lineNumber = 0;
534     throw SALOME::SALOME_Exception(ExDescription);
535   } catch (SALOME_Exception& ex) {
536     THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
537   }
538   return 0;
539 }
540
541 //=============================================================================
542
543 char* BLSURFPlugin_Hypothesis_i::GetAttractorEntry(const char* entry) throw (SALOME::SALOME_Exception) {
544   ASSERT(myBaseImpl);
545   try {
546     return CORBA::string_dup(this->GetImpl()->GetAttractorEntry(entry).c_str());
547   } catch (const std::invalid_argument& ex) {
548     SALOME::ExceptionStruct ExDescription;
549     ExDescription.text = ex.what();
550     ExDescription.type = SALOME::BAD_PARAM;
551     ExDescription.sourceFile = "BLSURFPlugin_Hypothesis::GetAttractorEntry(name)";
552     ExDescription.lineNumber = 0;
553     throw SALOME::SALOME_Exception(ExDescription);
554   } catch (SALOME_Exception& ex) {
555     THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
556   }
557   return 0;
558 }
559
560 //=============================================================================
561
562 void BLSURFPlugin_Hypothesis_i::UnsetEntry(const char* entry) {
563   ASSERT(myBaseImpl);
564   this->GetImpl()->ClearEntry(entry);
565   //  SMESH::TPythonDump() << _this() << ".UnsetSizeMap( " << entry << " )";
566 }
567
568 //=============================================================================
569
570 BLSURFPlugin::string_array* BLSURFPlugin_Hypothesis_i::GetSizeMapEntries() {
571   ASSERT(myBaseImpl);
572   BLSURFPlugin::string_array_var result = new BLSURFPlugin::string_array();
573
574   const ::BLSURFPlugin_Hypothesis::TSizeMap sizeMaps = this->GetImpl()->_GetSizeMapEntries();
575   result->length(sizeMaps.size());
576
577   ::BLSURFPlugin_Hypothesis::TSizeMap::const_iterator smIt = sizeMaps.begin();
578   for (int i = 0; smIt != sizeMaps.end(); ++smIt, ++i) {
579     string entry_sizemap = smIt->first;
580     if (!smIt->second.empty()) {
581       entry_sizemap += "|";
582       entry_sizemap += smIt->second;
583     }
584     result[i] = CORBA::string_dup(entry_sizemap.c_str());
585   }
586   return result._retn();
587 }
588
589 //=============================================================================
590
591 BLSURFPlugin::string_array* BLSURFPlugin_Hypothesis_i::GetAttractorEntries() {
592   ASSERT(myBaseImpl);
593   BLSURFPlugin::string_array_var result = new BLSURFPlugin::string_array();
594
595   const ::BLSURFPlugin_Hypothesis::TSizeMap attractors = this->GetImpl()->_GetAttractorEntries();
596   result->length(attractors.size());
597
598   ::BLSURFPlugin_Hypothesis::TSizeMap::const_iterator atIt = attractors.begin();
599   for (int i = 0; atIt != attractors.end(); ++atIt, ++i) {
600     string entry_attractor = atIt->first;
601     if (!atIt->second.empty()) {
602       entry_attractor += "|";
603       entry_attractor += atIt->second;
604     }
605     result[i] = CORBA::string_dup(entry_attractor.c_str());
606   }
607   return result._retn();
608 }
609
610 //=============================================================================
611
612 void BLSURFPlugin_Hypothesis_i::SetSizeMapEntries(const BLSURFPlugin::string_array& sizeMaps)
613     throw (SALOME::SALOME_Exception) {
614   ASSERT(myBaseImpl);
615   for (int i = 0; i < sizeMaps.length(); ++i) {
616     string entry_sizemap = sizeMaps[i].in();
617     int colonPos = entry_sizemap.find('|');
618     string entry, sizemap;
619     if (colonPos == string::npos) // '|' separator not found
620       entry = entry_sizemap;
621     else {
622       entry = entry_sizemap.substr(0, colonPos);
623       if (colonPos < entry_sizemap.size() - 1 && entry_sizemap[colonPos] != ' ')
624         sizemap = entry_sizemap.substr(colonPos + 1);
625     }
626     this->GetImpl()->SetSizeMapEntry(entry.c_str(), sizemap.c_str());
627   }
628 }
629
630 //=============================================================================
631
632 void BLSURFPlugin_Hypothesis_i::ClearSizeMaps() {
633   ASSERT(myBaseImpl);
634   this->GetImpl()->ClearSizeMaps();
635 }
636
637 //=============================================================================
638
639 void BLSURFPlugin_Hypothesis_i::SetSizeMap(const GEOM::GEOM_Object_ptr GeomObj, const char* sizeMap) {
640   ASSERT(myBaseImpl);
641   string entry;
642   entry = GeomObj->GetStudyEntry();
643   MESSAGE("IDL : GetName : " << GeomObj->GetName());
644   MESSAGE("IDL : SETSIZEMAP ( "<< entry << " , " << sizeMap << ")");
645   SetSizeMapEntry(entry.c_str(), sizeMap);
646 }
647
648 //=============================================================================
649 void BLSURFPlugin_Hypothesis_i::UnsetSizeMap(const GEOM::GEOM_Object_ptr GeomObj) {
650   ASSERT(myBaseImpl);
651   string entry;
652   entry = GeomObj->GetStudyEntry();
653   MESSAGE("IDL : GetName : " << GeomObj->GetName());
654   MESSAGE("IDL : UNSETSIZEMAP ( "<< entry << ")");
655   UnsetEntry(entry.c_str());
656   SMESH::TPythonDump() << _this() << ".UnsetSizeMap( " << entry.c_str() << " )";
657 }
658
659 void BLSURFPlugin_Hypothesis_i::SetAttractor(GEOM::GEOM_Object_ptr GeomObj, const char* attractor) {
660   ASSERT(myBaseImpl);
661   string entry;
662   entry = GeomObj->GetStudyEntry();
663   MESSAGE("IDL : GetName : " << GeomObj->GetName());
664   MESSAGE("IDL : SETATTRACTOR ( "<< entry << " , " << attractor << ")");
665   SetAttractorEntry(entry.c_str(), attractor);
666 }
667
668 void BLSURFPlugin_Hypothesis_i::UnsetAttractor(GEOM::GEOM_Object_ptr GeomObj) {
669   ASSERT(myBaseImpl);
670   string entry;
671   entry = GeomObj->GetStudyEntry();
672   MESSAGE("IDL : GetName : " << GeomObj->GetName());
673   MESSAGE("IDL : UNSETATTRACTOR ( "<< entry << ")");
674   UnsetEntry(entry.c_str());
675   SMESH::TPythonDump() << _this() << ".UnsetAttractor( " << entry.c_str() << " )";
676 }
677
678 /*
679  void BLSURFPlugin_Hypothesis_i::SetCustomSizeMap(GEOM::GEOM_Object_ptr GeomObj, const char* sizeMap)
680  {}
681
682  void BLSURFPlugin_Hypothesis_i::UnsetCustomSizeMap(GEOM::GEOM_Object_ptr GeomObj)
683  {}
684
685  void BLSURFPlugin_Hypothesis_i::SetCustomSizeMapEntry(const char* entry,const char* sizeMap )  throw (SALOME::SALOME_Exception)
686  {}
687
688  char* BLSURFPlugin_Hypothesis_i::GetCustomSizeMapEntry(const char* entry)  throw (SALOME::SALOME_Exception)
689  {}
690
691  void BLSURFPlugin_Hypothesis_i::UnsetCustomSizeMapEntry(const char* entry)
692  {
693  ASSERT(myBaseImpl);
694  this->GetImpl()->UnsetCustomSizeMap(entry);
695  SMESH::TPythonDump() << _this() << ".UnsetCustomSizeMap( " << entry << " )";
696  }
697
698
699  BLSURFPlugin::string_array* BLSURFPlugin_Hypothesis_i::GetCustomSizeMapEntries()
700  {}
701
702  */
703
704 // ///////////////////////
705 // // ENFORCED VERTICES //
706 // ///////////////////////
707
708
709 /**
710  * Returns the list of enforced vertices for a given Face entry
711  * @return A map of Face entry / List of enforced vertices
712  *
713  */
714 BLSURFPlugin::TFaceEntryEnfVertexListMap* BLSURFPlugin_Hypothesis_i::GetAllEnforcedVerticesByFace() {
715   MESSAGE("IDL: GetAllEnforcedVerticesByFace()");
716   ASSERT(myBaseImpl);
717
718   BLSURFPlugin::TFaceEntryEnfVertexListMap_var resultMap = new BLSURFPlugin::TFaceEntryEnfVertexListMap();
719
720   const ::BLSURFPlugin_Hypothesis::TFaceEntryEnfVertexListMap faceEntryEnfVertexListMap =
721       this->GetImpl()->_GetAllEnforcedVerticesByFace();
722   resultMap->length(faceEntryEnfVertexListMap.size());
723   MESSAGE("Face entry to Enforced Vertex map size is " << resultMap->length());
724
725   ::BLSURFPlugin_Hypothesis::TEnfVertexList _enfVertexList;
726   ::BLSURFPlugin_Hypothesis::TFaceEntryEnfVertexListMap::const_iterator it_entry = faceEntryEnfVertexListMap.begin();
727   for (int i = 0; it_entry != faceEntryEnfVertexListMap.end(); ++it_entry, ++i) {
728     BLSURFPlugin::TFaceEntryEnfVertexListMapElement_var mapElement =
729         new BLSURFPlugin::TFaceEntryEnfVertexListMapElement();
730     mapElement->faceEntry = CORBA::string_dup(it_entry->first.c_str());
731     MESSAGE("Face Entry: " << mapElement->faceEntry);
732
733     _enfVertexList = it_entry->second;
734     BLSURFPlugin::TEnfVertexList_var enfVertexList = new BLSURFPlugin::TEnfVertexList();
735     enfVertexList->length(_enfVertexList.size());
736     MESSAGE("Number of enf vertex: " << enfVertexList->length());
737
738     ::BLSURFPlugin_Hypothesis::TEnfVertexList::const_iterator it_enfVertex = _enfVertexList.begin();
739     ::BLSURFPlugin_Hypothesis::TEnfVertex *currentEnfVertex;
740     for (int j = 0; it_enfVertex != _enfVertexList.end(); ++it_enfVertex, ++j) {
741       currentEnfVertex = (*it_enfVertex);
742
743       BLSURFPlugin::TEnfVertex_var enfVertex = new BLSURFPlugin::TEnfVertex();
744
745       // Name
746       enfVertex->name = CORBA::string_dup(currentEnfVertex->name.c_str());
747
748       // Geom entry
749       enfVertex->geomEntry = CORBA::string_dup(currentEnfVertex->geomEntry.c_str());
750
751       // Coords
752       BLSURFPlugin::TEnfVertexCoords_var coords = new BLSURFPlugin::TEnfVertexCoords();
753       coords->length(currentEnfVertex->coords.size());
754       for (int i=0;i<coords->length();i++)
755         coords[i] = currentEnfVertex->coords[i];
756       enfVertex->coords = coords;
757
758       // Group name
759       enfVertex->grpName = CORBA::string_dup(currentEnfVertex->grpName.c_str());
760       
761       // Face entry list
762       BLSURFPlugin::TEntryList_var faceEntryList = new BLSURFPlugin::TEntryList();
763       faceEntryList->length(currentEnfVertex->faceEntries.size());
764       ::BLSURFPlugin_Hypothesis::TEntryList::const_iterator it_entry = currentEnfVertex->faceEntries.begin();
765       for (int ind = 0; it_entry != currentEnfVertex->faceEntries.end();++it_entry, ++ind)
766         faceEntryList[ind] = CORBA::string_dup((*it_entry).c_str());
767       enfVertex->faceEntries = faceEntryList;
768
769       ostringstream msg;
770       msg << "Enforced vertex: \n"
771           << "Name: " << enfVertex->name << "\n";
772       if (coords->length())
773           msg << "Coords: " << enfVertex->coords[0] << ", " << enfVertex->coords[1] << ", " << enfVertex->coords[2] << "\n";
774       msg << "Geom entry: " << enfVertex->geomEntry << "\n"
775           << "Group Name: " << enfVertex->grpName;
776       MESSAGE(msg.str());
777
778       enfVertexList[j] = enfVertex;
779     }
780     mapElement->enfVertexList = enfVertexList;
781
782     resultMap[i] = mapElement;
783
784   }
785   return resultMap._retn();
786 }
787
788 /**
789  * Returns the list of all enforced vertices
790  * @return a list of enforced vertices
791  *
792  */
793 BLSURFPlugin::TEnfVertexList* BLSURFPlugin_Hypothesis_i::GetAllEnforcedVertices() {
794   MESSAGE("IDL: GetAllEnforcedVertices()");
795   ASSERT(myBaseImpl);
796   BLSURFPlugin::TEnfVertexList_var resultMap = new BLSURFPlugin::TEnfVertexList();
797   const ::BLSURFPlugin_Hypothesis::TEnfVertexList enfVertexList = this->GetImpl()->_GetAllEnforcedVertices();
798   resultMap->length(enfVertexList.size());
799   MESSAGE("Enforced Vertex map size is " << resultMap->length());
800
801   ::BLSURFPlugin_Hypothesis::TEnfVertexList::const_iterator evlIt = enfVertexList.begin();
802   ::BLSURFPlugin_Hypothesis::TEnfVertex *currentEnfVertex;
803   for (int i = 0; evlIt != enfVertexList.end(); ++evlIt, ++i) {
804     MESSAGE("Enforced Vertex #" << i);
805     currentEnfVertex = (*evlIt);
806     BLSURFPlugin::TEnfVertex_var enfVertex = new BLSURFPlugin::TEnfVertex();
807     // Name
808     enfVertex->name = CORBA::string_dup(currentEnfVertex->name.c_str());
809     // Geom entry
810     enfVertex->geomEntry = CORBA::string_dup(currentEnfVertex->geomEntry.c_str());
811     // Coords
812     BLSURFPlugin::TEnfVertexCoords_var coords = new BLSURFPlugin::TEnfVertexCoords();
813     coords->length(currentEnfVertex->coords.size());
814     for (int ind = 0; ind < coords->length(); ind++)
815       coords[ind] = currentEnfVertex->coords[ind];
816     enfVertex->coords = coords;
817     // Group name
818     enfVertex->grpName = CORBA::string_dup(currentEnfVertex->grpName.c_str());  
819     // Face entry list
820     BLSURFPlugin::TEntryList_var faceEntryList = new BLSURFPlugin::TEntryList();
821     faceEntryList->length(currentEnfVertex->faceEntries.size());
822     ::BLSURFPlugin_Hypothesis::TEntryList::const_iterator it_entry = currentEnfVertex->faceEntries.begin();
823     for (int ind = 0; it_entry != currentEnfVertex->faceEntries.end();++it_entry, ++ind)
824       faceEntryList[ind] = CORBA::string_dup((*it_entry).c_str());
825     enfVertex->faceEntries = faceEntryList;
826
827     ostringstream msg;
828     msg << "Enforced vertex: \n"
829         << "Name: " << enfVertex->name << "\n";
830     if (coords->length())
831         msg << "Coords: " << enfVertex->coords[0] << ", " << enfVertex->coords[1] << ", " << enfVertex->coords[2] << "\n";
832     msg << "Geom entry: " << enfVertex->geomEntry << "\n"
833         << "Group Name: " << enfVertex->grpName;
834     MESSAGE(msg.str());
835
836     resultMap[i] = enfVertex;
837   }
838   return resultMap._retn();
839
840 }
841
842 /**
843  * Returns the list of enforced vertices coords for a given Face entry.
844  * They are the coords of the "manual" enforced vertices.
845  * @return A map of Face entry / List of enforced vertices coords
846  *
847  */
848 BLSURFPlugin::TFaceEntryCoordsListMap* BLSURFPlugin_Hypothesis_i::GetAllCoordsByFace() {
849   MESSAGE("IDL: GetAllCoordsByFace()");
850   ASSERT(myBaseImpl);
851
852   BLSURFPlugin::TFaceEntryCoordsListMap_var resultMap = new BLSURFPlugin::TFaceEntryCoordsListMap();
853
854   const ::BLSURFPlugin_Hypothesis::TFaceEntryCoordsListMap entryCoordsListMap = this->GetImpl()->_GetAllCoordsByFace();
855   resultMap->length(entryCoordsListMap.size());
856   MESSAGE("Enforced Vertex map size is " << resultMap->length());
857
858   ::BLSURFPlugin_Hypothesis::TEnfVertexCoordsList _coordsList;
859   ::BLSURFPlugin_Hypothesis::TFaceEntryCoordsListMap::const_iterator it_entry = entryCoordsListMap.begin();
860   for (int i = 0; it_entry != entryCoordsListMap.end(); ++it_entry, ++i) {
861     BLSURFPlugin::TFaceEntryCoordsListMapElement_var mapElement = new BLSURFPlugin::TFaceEntryCoordsListMapElement();
862     mapElement->faceEntry = CORBA::string_dup(it_entry->first.c_str());
863     MESSAGE("Face Entry: " << mapElement->faceEntry);
864
865     _coordsList = it_entry->second;
866     BLSURFPlugin::TEnfVertexCoordsList_var coordsList = new BLSURFPlugin::TEnfVertexCoordsList();
867     coordsList->length(_coordsList.size());
868     MESSAGE("Number of coords: " << coordsList->length());
869
870     ::BLSURFPlugin_Hypothesis::TEnfVertexCoordsList::const_iterator it_coords = _coordsList.begin();
871     for (int j = 0; it_coords != _coordsList.end(); ++it_coords, ++j) {
872       BLSURFPlugin::TEnfVertexCoords_var coords = new BLSURFPlugin::TEnfVertexCoords();
873       coords->length((*it_coords).size());
874       for (int i=0;i<coords->length();i++)
875         coords[i] = (*it_coords)[i];
876       coordsList[j] = coords;
877       MESSAGE("Coords #" << j << ": " << coords[0] << ", " << coords[1] << ", " << coords[2]);
878     }
879     mapElement->coordsList = coordsList;
880
881     resultMap[i] = mapElement;
882
883   }
884   return resultMap._retn();
885 }
886
887 /**
888  * Returns a map of enforced vertices coords / enforced vertex.
889  * They are the coords of the "manual" enforced vertices.
890  */
891 BLSURFPlugin::TCoordsEnfVertexMap* BLSURFPlugin_Hypothesis_i::GetAllEnforcedVerticesByCoords() {
892   MESSAGE("IDL: GetAllEnforcedVerticesByCoords()");
893   ASSERT(myBaseImpl);
894
895   BLSURFPlugin::TCoordsEnfVertexMap_var resultMap = new BLSURFPlugin::TCoordsEnfVertexMap();
896   const ::BLSURFPlugin_Hypothesis::TCoordsEnfVertexMap coordsEnfVertexMap =
897       this->GetImpl()->_GetAllEnforcedVerticesByCoords();
898   resultMap->length(coordsEnfVertexMap.size());
899   MESSAGE("Enforced Vertex map size is " << resultMap->length());
900
901   ::BLSURFPlugin_Hypothesis::TCoordsEnfVertexMap::const_iterator it_coords = coordsEnfVertexMap.begin();
902   ::BLSURFPlugin_Hypothesis::TEnfVertex *currentEnfVertex;
903   for (int i = 0; it_coords != coordsEnfVertexMap.end(); ++it_coords, ++i) {
904     MESSAGE("Enforced Vertex #" << i);
905     currentEnfVertex = (it_coords->second);
906     BLSURFPlugin::TCoordsEnfVertexElement_var mapElement = new BLSURFPlugin::TCoordsEnfVertexElement();
907     BLSURFPlugin::TEnfVertexCoords_var coords = new BLSURFPlugin::TEnfVertexCoords();
908     coords->length(it_coords->first.size());
909     for (int ind=0;ind<coords->length();ind++)
910       coords[ind] = it_coords->first[ind];
911     mapElement->coords = coords;
912     MESSAGE("Coords: " << mapElement->coords[0] << ", " << mapElement->coords[1] << ", " << mapElement->coords[2]);
913
914     BLSURFPlugin::TEnfVertex_var enfVertex = new BLSURFPlugin::TEnfVertex();
915     // Name
916     enfVertex->name = CORBA::string_dup(currentEnfVertex->name.c_str());
917     // Geom entry
918     enfVertex->geomEntry = CORBA::string_dup(currentEnfVertex->geomEntry.c_str());
919     // Coords
920     BLSURFPlugin::TEnfVertexCoords_var coords2 = new BLSURFPlugin::TEnfVertexCoords();
921     coords2->length(currentEnfVertex->coords.size());
922     for (int ind=0;ind<coords2->length();ind++)
923       coords2[ind] = currentEnfVertex->coords[ind];
924     enfVertex->coords = coords2;
925     // Group name
926     enfVertex->grpName = CORBA::string_dup(currentEnfVertex->grpName.c_str());  
927     // Face entry list
928     BLSURFPlugin::TEntryList_var faceEntryList = new BLSURFPlugin::TEntryList();
929     faceEntryList->length(currentEnfVertex->faceEntries.size());
930     ::BLSURFPlugin_Hypothesis::TEntryList::const_iterator it_entry = currentEnfVertex->faceEntries.begin();
931     for (int ind = 0; it_entry != currentEnfVertex->faceEntries.end();++it_entry, ++ind)
932       faceEntryList[ind] = CORBA::string_dup((*it_entry).c_str());
933     enfVertex->faceEntries = faceEntryList;
934       
935     mapElement->enfVertex = enfVertex;
936     ostringstream msg;
937     msg << "Enforced vertex: \n"
938         << "Name: " << enfVertex->name << "\n";
939     if (coords->length())
940         msg << "Coords: " << enfVertex->coords[0] << ", " << enfVertex->coords[1] << ", " << enfVertex->coords[2] << "\n";
941     msg << "Geom entry: " << enfVertex->geomEntry << "\n"
942         << "Group Name: " << enfVertex->grpName;
943     MESSAGE(msg.str());
944
945     resultMap[i] = mapElement;
946   }
947   return resultMap._retn();
948 }
949
950 /**
951  * Returns the list of enforced vertices entries for a given Face entry.
952  * They are the geom entries of the enforced vertices based on geom shape (vertex, compound, group).
953  * @return A map of Face entry / List of enforced vertices geom entries
954  *
955  */
956 BLSURFPlugin::TFaceEntryEnfVertexEntryListMap* BLSURFPlugin_Hypothesis_i::GetAllEnfVertexEntriesByFace() {
957   MESSAGE("IDL: GetAllEnfVertexEntriesByFace()");
958   ASSERT(myBaseImpl);
959
960   BLSURFPlugin::TFaceEntryEnfVertexEntryListMap_var resultMap = new BLSURFPlugin::TFaceEntryEnfVertexEntryListMap();
961
962   const ::BLSURFPlugin_Hypothesis::TFaceEntryEnfVertexEntryListMap entryEnfVertexEntryListMap =
963       this->GetImpl()->_GetAllEnfVertexEntriesByFace();
964   resultMap->length(entryEnfVertexEntryListMap.size());
965   MESSAGE("Enforced Vertex map size is " << resultMap->length());
966
967   ::BLSURFPlugin_Hypothesis::TEntryList _enfVertexEntryList;
968   ::BLSURFPlugin_Hypothesis::TFaceEntryEnfVertexEntryListMap::const_iterator it_entry =
969       entryEnfVertexEntryListMap.begin();
970   for (int i = 0; it_entry != entryEnfVertexEntryListMap.end(); ++it_entry, ++i) {
971     BLSURFPlugin::TFaceEntryEnfVertexEntryListMapElement_var mapElement =
972         new BLSURFPlugin::TFaceEntryEnfVertexEntryListMapElement();
973     mapElement->faceEntry = CORBA::string_dup(it_entry->first.c_str());
974     MESSAGE("Face Entry: " << mapElement->faceEntry);
975
976     _enfVertexEntryList = it_entry->second;
977     BLSURFPlugin::TEntryList_var enfVertexEntryList = new BLSURFPlugin::TEntryList();
978     enfVertexEntryList->length(_enfVertexEntryList.size());
979     MESSAGE("Number of enf vertex entries: " << enfVertexEntryList->length());
980
981     ::BLSURFPlugin_Hypothesis::TEntryList::const_iterator it_enfVertexEntry = _enfVertexEntryList.begin();
982     for (int j = 0; it_enfVertexEntry != _enfVertexEntryList.end(); ++it_enfVertexEntry, ++j) {
983       enfVertexEntryList[j] = CORBA::string_dup((*it_enfVertexEntry).c_str());
984       MESSAGE("Enf Vertex Entry #" << j << ": " << enfVertexEntryList[j]);
985     }
986     mapElement->enfVertexEntryList = enfVertexEntryList;
987
988     resultMap[i] = mapElement;
989
990   }
991   return resultMap._retn();
992 }
993
994 /**
995  * Returns a map of enforced vertices geom entry / enforced vertex.
996  * They are the geom entries of the enforced vertices defined with geom shape (vertex, compound, group).
997  */
998 BLSURFPlugin::TEnfVertexEntryEnfVertexMap* BLSURFPlugin_Hypothesis_i::GetAllEnforcedVerticesByEnfVertexEntry() {
999   MESSAGE("IDL: GetAllEnforcedVerticesByEnfVertexEntry()");
1000   ASSERT(myBaseImpl);
1001
1002   BLSURFPlugin::TEnfVertexEntryEnfVertexMap_var resultMap = new BLSURFPlugin::TEnfVertexEntryEnfVertexMap();
1003   const ::BLSURFPlugin_Hypothesis::TEnfVertexEntryEnfVertexMap enfVertexEntryEnfVertexMap =
1004       this->GetImpl()->_GetAllEnforcedVerticesByEnfVertexEntry();
1005   resultMap->length(enfVertexEntryEnfVertexMap.size());
1006   MESSAGE("Enforced Vertex map size is " << resultMap->length());
1007
1008   ::BLSURFPlugin_Hypothesis::TEnfVertexEntryEnfVertexMap::const_iterator it_enfVertexEntry = enfVertexEntryEnfVertexMap.begin();
1009   ::BLSURFPlugin_Hypothesis::TEnfVertex *currentEnfVertex;
1010   for (int i = 0; it_enfVertexEntry != enfVertexEntryEnfVertexMap.end(); ++it_enfVertexEntry, ++i) {
1011     MESSAGE("Enforced Vertex #" << i);
1012     currentEnfVertex = it_enfVertexEntry->second;
1013     BLSURFPlugin::TEnfVertexEntryEnfVertexElement_var mapElement = new BLSURFPlugin::TEnfVertexEntryEnfVertexElement();
1014     mapElement->enfVertexEntry = CORBA::string_dup(it_enfVertexEntry->first.c_str());;
1015     MESSAGE("Enf Vertex Entry #" << i << ": " << mapElement->enfVertexEntry);
1016
1017     BLSURFPlugin::TEnfVertex_var enfVertex = new BLSURFPlugin::TEnfVertex();
1018     // Name
1019     enfVertex->name = CORBA::string_dup(currentEnfVertex->name.c_str());
1020     // Geom entry
1021     enfVertex->geomEntry = CORBA::string_dup(currentEnfVertex->geomEntry.c_str());
1022     // Coords
1023     BLSURFPlugin::TEnfVertexCoords_var coords = new BLSURFPlugin::TEnfVertexCoords();
1024     coords->length(currentEnfVertex->coords.size());
1025     for (int ind=0;ind<coords->length();ind++)
1026       coords[ind] = currentEnfVertex->coords[ind];
1027     enfVertex->coords = coords;
1028     // Group name
1029     enfVertex->grpName = CORBA::string_dup(currentEnfVertex->grpName.c_str());  
1030     // Face entry list
1031     BLSURFPlugin::TEntryList_var faceEntryList = new BLSURFPlugin::TEntryList();
1032     faceEntryList->length(currentEnfVertex->faceEntries.size());
1033     ::BLSURFPlugin_Hypothesis::TEntryList::const_iterator it_entry = currentEnfVertex->faceEntries.begin();
1034     for (int ind = 0; it_entry != currentEnfVertex->faceEntries.end();++it_entry, ++ind)
1035       faceEntryList[ind] = CORBA::string_dup((*it_entry).c_str());
1036     enfVertex->faceEntries = faceEntryList;
1037
1038     ostringstream msg;
1039     msg << "Enforced vertex: \n"
1040         << "Name: " << enfVertex->name << "\n";
1041     if (coords->length())
1042         msg << "Coords: " << enfVertex->coords[0] << ", " << enfVertex->coords[1] << ", " << enfVertex->coords[2] << "\n";
1043     msg << "Geom entry: " << enfVertex->geomEntry << "\n"
1044         << "Group Name: " << enfVertex->grpName;
1045     MESSAGE(msg.str());
1046
1047     mapElement->enfVertex = enfVertex;
1048     resultMap[i] = mapElement;
1049   }
1050   return resultMap._retn();
1051 }
1052
1053 /**
1054  * Erase all enforced vertices
1055  */
1056 void BLSURFPlugin_Hypothesis_i::ClearAllEnforcedVertices() {
1057   ASSERT(myBaseImpl);
1058   this->GetImpl()->ClearAllEnforcedVertices();
1059   SMESH::TPythonDump() << _this() << ".ClearAllEnforcedVertices()";
1060 }
1061
1062 /*!
1063  * Set/get/unset an enforced vertex on face
1064  */
1065 bool BLSURFPlugin_Hypothesis_i::SetEnforcedVertex(GEOM::GEOM_Object_ptr theFace, CORBA::Double x, CORBA::Double y,
1066     CORBA::Double z) throw (SALOME::SALOME_Exception) {
1067   ASSERT(myBaseImpl);
1068
1069   if ((theFace->GetShapeType() != GEOM::FACE) && (theFace->GetShapeType() != GEOM::COMPOUND)) {
1070     MESSAGE("theFace shape type is not FACE or COMPOUND");
1071     THROW_SALOME_CORBA_EXCEPTION("theFace shape type is not FACE or COMPOUND", SALOME::BAD_PARAM);
1072   }
1073
1074   string theFaceEntry = theFace->GetStudyEntry();
1075   
1076   if (theFaceEntry.empty()) {
1077     GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine();
1078     SMESH_Gen_i *smeshGen = SMESH_Gen_i::GetSMESHGen();
1079     string aName;
1080     if (theFace->GetShapeType() == GEOM::FACE)
1081       aName = "Face_";
1082     if (theFace->GetShapeType() == GEOM::COMPOUND)
1083       aName = "Compound_";
1084     aName += theFace->GetEntry();
1085     SALOMEDS::SObject_ptr theSFace = geomGen->PublishInStudy(smeshGen->GetCurrentStudy(), NULL, theFace, aName.c_str());
1086     if (!theSFace->_is_nil())
1087       theFaceEntry = theSFace->GetID();
1088   }
1089   if (theFaceEntry.empty())
1090     THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM );
1091   MESSAGE("IDL : GetName : " << theFace->GetName());
1092   MESSAGE("IDL : SetEnforcedVertex( "<< theFaceEntry << ", " << x << ", " << y << ", " << z << ")");
1093   try {
1094     return SetEnforcedVertexEntry(theFaceEntry.c_str(), x, y, z);
1095   } catch (SALOME_Exception& ex) {
1096     THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
1097   }
1098 }
1099
1100 /*!
1101  * Set/get/unset an enforced vertex with name on face
1102  */
1103 bool BLSURFPlugin_Hypothesis_i::SetEnforcedVertexNamed(GEOM::GEOM_Object_ptr theFace, CORBA::Double x, CORBA::Double y,
1104     CORBA::Double z, const char* theVertexName) throw (SALOME::SALOME_Exception) {
1105   ASSERT(myBaseImpl);
1106
1107   if ((theFace->GetShapeType() != GEOM::FACE) && (theFace->GetShapeType() != GEOM::COMPOUND)) {
1108     MESSAGE("theFace shape type is not FACE or COMPOUND");
1109     THROW_SALOME_CORBA_EXCEPTION("theFace shape type is not FACE or COMPOUND", SALOME::BAD_PARAM);
1110   }
1111
1112   string theFaceEntry = theFace->GetStudyEntry();
1113   
1114   if (theFaceEntry.empty()) {
1115     GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine();
1116     SMESH_Gen_i *smeshGen = SMESH_Gen_i::GetSMESHGen();
1117     string aName;
1118     if (theFace->GetShapeType() == GEOM::FACE)
1119       aName = "Face_";
1120     if (theFace->GetShapeType() == GEOM::COMPOUND)
1121       aName = "Compound_";
1122     aName += theFace->GetEntry();
1123     SALOMEDS::SObject_ptr theSFace = geomGen->PublishInStudy(smeshGen->GetCurrentStudy(), NULL, theFace, aName.c_str());
1124     if (!theSFace->_is_nil())
1125       theFaceEntry = theSFace->GetID();
1126   }
1127   if (theFaceEntry.empty())
1128     THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM );
1129   
1130   MESSAGE("IDL : GetName : " << theFace->GetName());
1131   MESSAGE("IDL : SetEnforcedVertexNamed( "<< theFaceEntry << ", " << x << ", " << y << ", " << z << ", " << theVertexName << ")");
1132   try {
1133     return SetEnforcedVertexEntry(theFaceEntry.c_str(), x, y, z, theVertexName);
1134   } catch (SALOME_Exception& ex) {
1135     THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
1136   }
1137 }
1138
1139 /*!
1140  * Set/get/unset an enforced vertex with geom object on face
1141  */
1142 bool BLSURFPlugin_Hypothesis_i::SetEnforcedVertexGeom(GEOM::GEOM_Object_ptr theFace, GEOM::GEOM_Object_ptr theVertex)
1143     throw (SALOME::SALOME_Exception) {
1144   ASSERT(myBaseImpl);
1145
1146   if ((theFace->GetShapeType() != GEOM::FACE) && (theFace->GetShapeType() != GEOM::COMPOUND)) {
1147     MESSAGE("theFace shape type is not FACE or COMPOUND");
1148     THROW_SALOME_CORBA_EXCEPTION("theFace shape type is not FACE or COMPOUND", SALOME::BAD_PARAM);
1149   }
1150
1151   if ((theVertex->GetShapeType() != GEOM::VERTEX) && (theVertex->GetShapeType() != GEOM::COMPOUND)) {
1152     MESSAGE("theVertex shape type is not VERTEX or COMPOUND");
1153     THROW_SALOME_CORBA_EXCEPTION("theVertex shape type is not VERTEX or COMPOUND", SALOME::BAD_PARAM);
1154   }
1155
1156   //  GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine();
1157   //  GEOM::GEOM_IMeasureOperations_var measureOp = geomGen->GetIMeasureOperations(this->GetImpl()->GetStudyId());
1158   //  if (CORBA::is_nil(measureOp))
1159   //    return false;
1160   //
1161   //  CORBA::Double x, y, z;
1162   //  x = y = z = 0.;
1163   //  measureOp->PointCoordinates(theVertex, x, y, z);
1164
1165   string theFaceEntry = theFace->GetStudyEntry();
1166   string theVertexEntry = theVertex->GetStudyEntry();
1167   
1168   GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine();
1169   SMESH_Gen_i *smeshGen = SMESH_Gen_i::GetSMESHGen();
1170   string aName;
1171   
1172   if (theFaceEntry.empty()) {
1173     if (theFace->GetShapeType() == GEOM::FACE)
1174       aName = "Face_";
1175     if (theFace->GetShapeType() == GEOM::COMPOUND)
1176       aName = "Compound_";
1177     aName += theFace->GetEntry();
1178     SALOMEDS::SObject_ptr theSFace = geomGen->PublishInStudy(smeshGen->GetCurrentStudy(), NULL, theFace, aName.c_str());
1179     if (!theSFace->_is_nil())
1180       theFaceEntry = theSFace->GetID();
1181   }
1182   if (theFaceEntry.empty())
1183     THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM );
1184   
1185   if (theVertexEntry.empty()) {
1186     if (theVertex->GetShapeType() == GEOM::VERTEX)
1187       aName = "Vertex_";
1188     if (theVertex->GetShapeType() == GEOM::COMPOUND)
1189       aName = "Compound_";
1190     aName += theVertex->GetEntry();
1191     SALOMEDS::SObject_ptr theSVertex = geomGen->PublishInStudy(smeshGen->GetCurrentStudy(), NULL, theVertex, aName.c_str());
1192     if (!theSVertex->_is_nil())
1193       theVertexEntry = theSVertex->GetID();
1194   }
1195   if (theVertexEntry.empty())
1196     THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM );
1197
1198   string theVertexName = theVertex->GetName();
1199   MESSAGE("IDL : theFace->GetName : " << theFace->GetName());
1200   MESSAGE("IDL : theVertex->GetName : " << theVertexName);
1201   MESSAGE("IDL : SetEnforcedVertexGeom( "<< theFaceEntry << ", " << theVertexEntry<< ")");
1202   try {
1203     return SetEnforcedVertexEntry(theFaceEntry.c_str(), 0, 0, 0, theVertexName.c_str(), theVertexEntry.c_str());
1204   } catch (SALOME_Exception& ex) {
1205     THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
1206   }
1207 }
1208
1209 /*!
1210  * Set an enforced vertex with group name on face
1211  */
1212 bool BLSURFPlugin_Hypothesis_i::SetEnforcedVertexWithGroup(GEOM::GEOM_Object_ptr theFace, CORBA::Double x, CORBA::Double y, CORBA::Double z, const char* theGroupName)
1213  throw (SALOME::SALOME_Exception)
1214 {
1215   ASSERT(myBaseImpl);
1216
1217   if ((theFace->GetShapeType() != GEOM::FACE) && (theFace->GetShapeType() != GEOM::COMPOUND)) {
1218     MESSAGE("theFace shape type is not FACE or COMPOUND");
1219     THROW_SALOME_CORBA_EXCEPTION("theFace shape type is not FACE or COMPOUND", SALOME::BAD_PARAM);
1220   }
1221
1222   string theFaceEntry = theFace->GetStudyEntry();
1223   
1224   if (theFaceEntry.empty()) {
1225     GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine();
1226     SMESH_Gen_i *smeshGen = SMESH_Gen_i::GetSMESHGen();
1227     string aName;
1228     if (theFace->GetShapeType() == GEOM::FACE)
1229       aName = "Face_";
1230     if (theFace->GetShapeType() == GEOM::COMPOUND)
1231       aName = "Compound_";
1232     aName += theFace->GetEntry();
1233     SALOMEDS::SObject_ptr theSFace = geomGen->PublishInStudy(smeshGen->GetCurrentStudy(), NULL, theFace, aName.c_str());
1234     if (!theSFace->_is_nil())
1235       theFaceEntry = theSFace->GetID();
1236   }
1237   if (theFaceEntry.empty())
1238     THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM );
1239   MESSAGE("IDL : GetName : " << theFace->GetName());
1240   MESSAGE("IDL : SetEnforcedVertexWithGroup( "<< theFaceEntry << ", " << x << ", " << y << ", " << z << ", " << theGroupName << ")");
1241   try {
1242     return SetEnforcedVertexEntry(theFaceEntry.c_str(), x, y, z, "", "", theGroupName);
1243   } catch (SALOME_Exception& ex) {
1244     THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
1245   }
1246 }
1247
1248 /*!
1249  * Set an enforced vertex with name and group name on face
1250  */
1251 bool BLSURFPlugin_Hypothesis_i::SetEnforcedVertexNamedWithGroup(GEOM::GEOM_Object_ptr theFace, CORBA::Double x, CORBA::Double y, CORBA::Double z, 
1252                                                                 const char* theVertexName, const char* theGroupName)
1253  throw (SALOME::SALOME_Exception)
1254 {
1255   ASSERT(myBaseImpl);
1256
1257   if ((theFace->GetShapeType() != GEOM::FACE) && (theFace->GetShapeType() != GEOM::COMPOUND)) {
1258     MESSAGE("theFace shape type is not FACE or COMPOUND");
1259     THROW_SALOME_CORBA_EXCEPTION("theFace shape type is not FACE or COMPOUND", SALOME::BAD_PARAM);
1260   }
1261
1262   string theFaceEntry = theFace->GetStudyEntry();
1263   
1264   if (theFaceEntry.empty()) {
1265     GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine();
1266     SMESH_Gen_i *smeshGen = SMESH_Gen_i::GetSMESHGen();
1267     string aName;
1268     if (theFace->GetShapeType() == GEOM::FACE)
1269       aName = "Face_";
1270     if (theFace->GetShapeType() == GEOM::COMPOUND)
1271       aName = "Compound_";
1272     aName += theFace->GetEntry();
1273     SALOMEDS::SObject_ptr theSFace = geomGen->PublishInStudy(smeshGen->GetCurrentStudy(), NULL, theFace, aName.c_str());
1274     if (!theSFace->_is_nil())
1275       theFaceEntry = theSFace->GetID();
1276   }
1277   if (theFaceEntry.empty())
1278     THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM );
1279   MESSAGE("IDL : GetName : " << theFace->GetName());
1280   MESSAGE("IDL : SetEnforcedVertexNamedWithGroup( "<< theFaceEntry << ", " << x << ", " << y << ", " << z << ", " << theVertexName << ", " << theGroupName << ")");
1281   try {
1282     return SetEnforcedVertexEntry(theFaceEntry.c_str(), x, y, z, theVertexName, "", theGroupName);
1283   } catch (SALOME_Exception& ex) {
1284     THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
1285   }
1286 }
1287
1288 /*!
1289  * Set an enforced vertex with geom entry and group name on face
1290  */
1291 bool BLSURFPlugin_Hypothesis_i::SetEnforcedVertexGeomWithGroup(GEOM::GEOM_Object_ptr theFace, GEOM::GEOM_Object_ptr theVertex, const char* theGroupName)
1292  throw (SALOME::SALOME_Exception)
1293 {
1294   ASSERT(myBaseImpl);
1295
1296   if ((theFace->GetShapeType() != GEOM::FACE) && (theFace->GetShapeType() != GEOM::COMPOUND)) {
1297     MESSAGE("theFace shape type is not FACE or COMPOUND");
1298     THROW_SALOME_CORBA_EXCEPTION("theFace shape type is not FACE or COMPOUND", SALOME::BAD_PARAM);
1299   }
1300
1301   if ((theVertex->GetShapeType() != GEOM::VERTEX) && (theVertex->GetShapeType() != GEOM::COMPOUND)) {
1302     MESSAGE("theVertex shape type is not VERTEX or COMPOUND");
1303     THROW_SALOME_CORBA_EXCEPTION("theVertex shape type is not VERTEX or COMPOUND", SALOME::BAD_PARAM);
1304   }
1305
1306   string theFaceEntry = theFace->GetStudyEntry();
1307   string theVertexEntry = theVertex->GetStudyEntry();
1308   
1309   GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine();
1310   SMESH_Gen_i *smeshGen = SMESH_Gen_i::GetSMESHGen();
1311   string aName;
1312   
1313   if (theFaceEntry.empty()) {
1314     if (theFace->GetShapeType() == GEOM::FACE)
1315       aName = "Face_";
1316     if (theFace->GetShapeType() == GEOM::COMPOUND)
1317       aName = "Compound_";
1318     aName += theFace->GetEntry();
1319     SALOMEDS::SObject_ptr theSFace = geomGen->PublishInStudy(smeshGen->GetCurrentStudy(), NULL, theFace, aName.c_str());
1320     if (!theSFace->_is_nil())
1321       theFaceEntry = theSFace->GetID();
1322   }
1323   if (theFaceEntry.empty())
1324     THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM );
1325   
1326   if (theVertexEntry.empty()) {
1327     if (theVertex->GetShapeType() == GEOM::VERTEX)
1328       aName = "Vertex_";
1329     if (theVertex->GetShapeType() == GEOM::COMPOUND)
1330       aName = "Compound_";
1331     aName += theVertex->GetEntry();
1332     SALOMEDS::SObject_ptr theSVertex = geomGen->PublishInStudy(smeshGen->GetCurrentStudy(), NULL, theVertex, aName.c_str());
1333     if (!theSVertex->_is_nil())
1334       theVertexEntry = theSVertex->GetID();
1335   }
1336   if (theVertexEntry.empty())
1337     THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM );
1338
1339   string theVertexName = theVertex->GetName();
1340   MESSAGE("IDL : theFace->GetName : " << theFace->GetName());
1341   MESSAGE("IDL : theVertex->GetName : " << theVertexName);
1342   MESSAGE("IDL : SetEnforcedVertexGeomWithGroup( "<< theFaceEntry << ", " << theVertexEntry<< ", " << theGroupName<< ")");
1343   try {
1344     return SetEnforcedVertexEntry(theFaceEntry.c_str(), 0, 0, 0, theVertexName.c_str(), theVertexEntry.c_str(), theGroupName);
1345   } catch (SALOME_Exception& ex) {
1346     THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
1347   }
1348 }
1349
1350 /*!
1351  * Get the list of all enforced vertices
1352  */
1353 BLSURFPlugin::TEnfVertexList* BLSURFPlugin_Hypothesis_i::GetEnforcedVertices(GEOM::GEOM_Object_ptr theFace)
1354     throw (SALOME::SALOME_Exception) {
1355   ASSERT(myBaseImpl);
1356
1357   if ((theFace->GetShapeType() != GEOM::FACE) && (theFace->GetShapeType() != GEOM::COMPOUND)) {
1358     MESSAGE("theFace shape type is not FACE or COMPOUND");
1359     THROW_SALOME_CORBA_EXCEPTION("theFace shape type is not FACE or COMPOUND", SALOME::BAD_PARAM);
1360   }
1361
1362   string theFaceEntry = theFace->GetStudyEntry();
1363   
1364   if (theFaceEntry.empty()) {
1365     GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine();
1366     SMESH_Gen_i *smeshGen = SMESH_Gen_i::GetSMESHGen();
1367     string aName;
1368     if (theFace->GetShapeType() == GEOM::FACE)
1369       aName = "Face_";
1370     if (theFace->GetShapeType() == GEOM::COMPOUND)
1371       aName = "Compound_";
1372     aName += theFace->GetEntry();
1373     SALOMEDS::SObject_ptr theSFace = geomGen->PublishInStudy(smeshGen->GetCurrentStudy(), NULL, theFace, aName.c_str());
1374     if (!theSFace->_is_nil())
1375       theFaceEntry = theSFace->GetID();
1376   }
1377   if (theFaceEntry.empty())
1378     THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM );
1379
1380   MESSAGE("IDL : GetName : " << theFace->GetName());
1381   MESSAGE("IDL : GetEnforcedVertexList ( "<< theFaceEntry << ")");
1382   try {
1383     return GetEnforcedVerticesEntry(theFaceEntry.c_str());
1384   } catch (SALOME_Exception& ex) {
1385     THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
1386   }
1387 }
1388
1389 bool BLSURFPlugin_Hypothesis_i::UnsetEnforcedVertex(GEOM::GEOM_Object_ptr theFace, CORBA::Double x, CORBA::Double y,
1390     CORBA::Double z) throw (SALOME::SALOME_Exception) {
1391   ASSERT(myBaseImpl);
1392
1393   if ((theFace->GetShapeType() != GEOM::FACE) && (theFace->GetShapeType() != GEOM::COMPOUND)) {
1394     MESSAGE("theFace shape type is not FACE or COMPOUND");
1395     THROW_SALOME_CORBA_EXCEPTION("theFace shape type is not FACE or COMPOUND", SALOME::BAD_PARAM);
1396   }
1397
1398   string theFaceEntry = theFace->GetStudyEntry();
1399   
1400   if (theFaceEntry.empty()) {
1401     GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine();
1402     SMESH_Gen_i *smeshGen = SMESH_Gen_i::GetSMESHGen();
1403     string aName;
1404     if (theFace->GetShapeType() == GEOM::FACE)
1405       aName = "Face_";
1406     if (theFace->GetShapeType() == GEOM::COMPOUND)
1407       aName = "Compound_";
1408     aName += theFace->GetEntry();
1409     SALOMEDS::SObject_ptr theSFace = geomGen->PublishInStudy(smeshGen->GetCurrentStudy(), NULL, theFace, aName.c_str());
1410     if (!theSFace->_is_nil())
1411       theFaceEntry = theSFace->GetID();
1412   }
1413   if (theFaceEntry.empty())
1414     THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM );
1415   MESSAGE("IDL : GetName : " << theFace->GetName());
1416   MESSAGE("IDL : UnsetEnforcedVertex ( "<< theFaceEntry << ", " << x << ", " << y << ", " << z << ")");
1417
1418   try {
1419     return UnsetEnforcedVertexEntry(theFaceEntry.c_str(), x, y, z);
1420   } catch (SALOME_Exception& ex) {
1421     THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
1422   }
1423 }
1424
1425 bool BLSURFPlugin_Hypothesis_i::UnsetEnforcedVertexGeom(GEOM::GEOM_Object_ptr theFace, GEOM::GEOM_Object_ptr theVertex)
1426     throw (SALOME::SALOME_Exception) {
1427   ASSERT(myBaseImpl);
1428
1429   if ((theFace->GetShapeType() != GEOM::FACE) && (theFace->GetShapeType() != GEOM::COMPOUND)) {
1430     MESSAGE("theFace shape type is not FACE or COMPOUND");
1431     THROW_SALOME_CORBA_EXCEPTION("theFace shape type is not FACE or COMPOUND", SALOME::BAD_PARAM);
1432   }
1433   if ((theVertex->GetShapeType() != GEOM::VERTEX) && (theVertex->GetShapeType() != GEOM::COMPOUND)) {
1434     MESSAGE("theVertex shape type is not VERTEX or COMPOUND");
1435     THROW_SALOME_CORBA_EXCEPTION("theVertex shape type is not VERTEX or COMPOUND", SALOME::BAD_PARAM);
1436   }
1437
1438   //  GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine();
1439   //  GEOM::GEOM_IMeasureOperations_var measureOp = geomGen->GetIMeasureOperations(this->GetImpl()->GetStudyId());
1440   //  if (CORBA::is_nil(measureOp))
1441   //    return false;
1442   //
1443   //  CORBA::Double x, y, z;
1444   //  x = y = z = 0.;
1445   //  measureOp->PointCoordinates(theVertex, x, y, z);
1446
1447   std::string theFaceEntry = theFace->GetStudyEntry();
1448   std::string theVertexEntry = theVertex->GetStudyEntry();
1449   
1450   GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine();
1451   SMESH_Gen_i *smeshGen = SMESH_Gen_i::GetSMESHGen();
1452   string aName;
1453   
1454   if (theFaceEntry.empty()) {
1455     if (theFace->GetShapeType() == GEOM::FACE)
1456       aName = "Face_";
1457     if (theFace->GetShapeType() == GEOM::COMPOUND)
1458       aName = "Compound_";
1459     aName += theFace->GetEntry();
1460     SALOMEDS::SObject_ptr theSFace = geomGen->PublishInStudy(smeshGen->GetCurrentStudy(), NULL, theFace, aName.c_str());
1461     if (!theSFace->_is_nil())
1462       theFaceEntry = theSFace->GetID();
1463   }
1464   if (theFaceEntry.empty())
1465     THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM );
1466   
1467   if (theVertexEntry.empty()) {
1468     if (theVertex->GetShapeType() == GEOM::VERTEX)
1469       aName = "Vertex_";
1470     if (theVertex->GetShapeType() == GEOM::COMPOUND)
1471       aName = "Compound_";
1472     aName += theVertex->GetEntry();
1473     SALOMEDS::SObject_ptr theSVertex = geomGen->PublishInStudy(smeshGen->GetCurrentStudy(), NULL, theVertex, aName.c_str());
1474     if (!theSVertex->_is_nil())
1475       theVertexEntry = theSVertex->GetID();
1476   }
1477   if (theVertexEntry.empty())
1478     THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM );
1479   
1480   MESSAGE("IDL : UnsetEnforcedVertexGeom ( "<< theFaceEntry << ", " << theVertexEntry << ")");
1481
1482   try {
1483     return UnsetEnforcedVertexEntry(theFaceEntry.c_str(), 0, 0, 0, theVertexEntry.c_str());
1484   } catch (SALOME_Exception& ex) {
1485     THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
1486   }
1487 }
1488
1489 bool BLSURFPlugin_Hypothesis_i::UnsetEnforcedVertices(GEOM::GEOM_Object_ptr theFace) throw (SALOME::SALOME_Exception) {
1490   ASSERT(myBaseImpl);
1491
1492   if ((theFace->GetShapeType() != GEOM::FACE) && (theFace->GetShapeType() != GEOM::COMPOUND)) {
1493     MESSAGE("theFace shape type is not FACE or COMPOUND");
1494     THROW_SALOME_CORBA_EXCEPTION("theFace shape type is not FACE or COMPOUND", SALOME::BAD_PARAM);
1495   }
1496
1497   string theFaceEntry = theFace->GetStudyEntry();
1498   
1499   if (theFaceEntry.empty()) {
1500     GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine();
1501     SMESH_Gen_i *smeshGen = SMESH_Gen_i::GetSMESHGen();
1502     string aName;
1503     if (theFace->GetShapeType() == GEOM::FACE)
1504       aName = "Face_";
1505     if (theFace->GetShapeType() == GEOM::COMPOUND)
1506       aName = "Compound_";
1507     aName += theFace->GetEntry();
1508     SALOMEDS::SObject_ptr theSFace = geomGen->PublishInStudy(smeshGen->GetCurrentStudy(), NULL, theFace, aName.c_str());
1509     if (!theSFace->_is_nil())
1510       theFaceEntry = theSFace->GetID();
1511   }
1512   if (theFaceEntry.empty())
1513     THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM );
1514   
1515   MESSAGE("IDL : GetName : " << theFace->GetName());
1516   MESSAGE("IDL : UnsetEnforcedVertices ( "<< theFaceEntry << ")");
1517
1518   try {
1519     return UnsetEnforcedVerticesEntry(theFaceEntry.c_str());
1520   } catch (SALOME_Exception& ex) {
1521     THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
1522   }
1523 }
1524
1525 /*!
1526  * Set/get/unset an enforced vertex on geom object given by entry
1527  */
1528 bool BLSURFPlugin_Hypothesis_i::SetEnforcedVertexEntry(const char* theFaceEntry, CORBA::Double x, CORBA::Double y,
1529     CORBA::Double z, const char* theVertexName, const char* theVertexEntry, const char* theGroupName)
1530     throw (SALOME::SALOME_Exception) {
1531   ASSERT(myBaseImpl);
1532   MESSAGE("IDL : SetEnforcedVertexEntry(" << theFaceEntry << ", " << x << ", " << y << ", " << z << ", \"" << theVertexName << "\", \"" << theVertexEntry << "\", \"" << theGroupName << "\")");
1533   bool newValue = false;
1534
1535   if (string(theVertexEntry).empty()) {
1536     try {
1537       ::BLSURFPlugin_Hypothesis::TEnfVertexCoordsList coordsList =
1538           this->GetImpl()->GetEnfVertexCoordsList(theFaceEntry);
1539       ::BLSURFPlugin_Hypothesis::TEnfVertexCoords coords;
1540       coords.push_back(x);
1541       coords.push_back(y);
1542       coords.push_back(z);
1543       if (coordsList.find(coords) == coordsList.end()) {
1544         MESSAGE("Coords not found: add it in coordsList");
1545         newValue = true;
1546       } else {
1547         MESSAGE("Coords already found, compare names");
1548         ::BLSURFPlugin_Hypothesis::TEnfVertex *enfVertex = this->GetImpl()->GetEnfVertex(coords);
1549         if ((enfVertex->name != theVertexName) || (enfVertex->grpName != theGroupName)) {
1550           MESSAGE("The names are different: update");
1551 //          this->GetImpl()->ClearEnforcedVertex(theFaceEntry, x, y, z);
1552           newValue = true;
1553         }
1554         else {
1555           MESSAGE("The names are identical");
1556         }
1557       }
1558     } catch (const std::invalid_argument& ex) {
1559       // no enforced vertex for entry
1560       MESSAGE("Face entry not found : add it to the list");
1561       newValue = true;
1562     }
1563     if (newValue)
1564       if (string(theVertexName).empty())
1565         if (string(theGroupName).empty())
1566           SMESH::TPythonDump() << _this() << ".SetEnforcedVertex(" << theFaceEntry << ", " << x << ", " << y << ", " << z << ")";
1567         else
1568           SMESH::TPythonDump() << _this() << ".SetEnforcedVertexWithGroup(" << theFaceEntry << ", " << x << ", " << y << ", " << z << ", \"" << theGroupName << "\")";
1569       else
1570         if (string(theGroupName).empty())
1571           SMESH::TPythonDump() << _this() << ".SetEnforcedVertexNamed(" << theFaceEntry << ", " << x << ", " << y << ", " << z << ", \"" << theVertexName << "\")";
1572         else
1573           SMESH::TPythonDump() << _this() << ".SetEnforcedVertexNamedWithGroup(" << theFaceEntry << ", " << x << ", " << y << ", " << z << ", \"" 
1574                                           << theVertexName << "\", \"" << theGroupName << "\")";
1575   } else {
1576     try {
1577       ::BLSURFPlugin_Hypothesis::TEntryList enfVertexEntryList = this->GetImpl()->GetEnfVertexEntryList(theFaceEntry);
1578       ::BLSURFPlugin_Hypothesis::TEntryList::const_iterator it = enfVertexEntryList.find(theVertexEntry);
1579       if ( it == enfVertexEntryList.end()) {
1580         MESSAGE("Geom entry not found: add it in enfVertexEntryList");
1581         newValue = true;
1582       }
1583       else {
1584         MESSAGE("Geom entry already found, compare names");
1585         ::BLSURFPlugin_Hypothesis::TEnfVertex *enfVertex = this->GetImpl()->GetEnfVertex((*it));
1586         if ((enfVertex->name != theVertexName) || (enfVertex->grpName != theGroupName)) {
1587           MESSAGE("The names are different: update");
1588 //          this->GetImpl()->ClearEnforcedVertex(theFaceEntry, x, y, z);
1589           newValue = true;
1590         }
1591         else {
1592           MESSAGE("The names are identical");
1593         }
1594       }
1595     } catch (const std::invalid_argument& ex) {
1596       // no enforced vertex for entry
1597       MESSAGE("Face entry not found : add it to the list");
1598       newValue = true;
1599     }
1600     if (newValue)
1601         if (string(theGroupName).empty())
1602           SMESH::TPythonDump() << _this() << ".SetEnforcedVertexGeom(" << theFaceEntry << ", " << theVertexEntry << ")";
1603         else
1604           SMESH::TPythonDump() << _this() << ".SetEnforcedVertexGeomWithGroup(" << theFaceEntry << ", " << theVertexEntry << ", \"" << theGroupName << "\")";
1605   }
1606
1607   if (newValue)
1608     this->GetImpl()->SetEnforcedVertex(theFaceEntry, theVertexName, theVertexEntry, theGroupName, x, y, z);
1609
1610   MESSAGE("IDL : SetEnforcedVertexEntry END");
1611   return newValue;
1612 }
1613
1614 BLSURFPlugin::TEnfVertexList* BLSURFPlugin_Hypothesis_i::GetEnforcedVerticesEntry(const char* entry)
1615     throw (SALOME::SALOME_Exception) {
1616   ASSERT(myBaseImpl);
1617   MESSAGE("ENGINE : GetEnforcedVerticesEntry START ENTRY : " << entry);
1618
1619   try {
1620     BLSURFPlugin::TEnfVertexList_var vertexList = new BLSURFPlugin::TEnfVertexList();
1621     ::BLSURFPlugin_Hypothesis::TEnfVertexList _vList = this->GetImpl()->GetEnfVertexList(entry);
1622     vertexList->length(_vList.size());
1623     MESSAGE("Number of enforced vertices: " << vertexList->length());
1624     ::BLSURFPlugin_Hypothesis::TEnfVertexList::const_iterator evlIt = _vList.begin();
1625     for (int i = 0; evlIt != _vList.end(); ++evlIt, ++i) {
1626       ::BLSURFPlugin_Hypothesis::TEnfVertex *_enfVertex = (*evlIt);
1627
1628       BLSURFPlugin::TEnfVertex_var enfVertex = new BLSURFPlugin::TEnfVertex();
1629
1630       // Name
1631       enfVertex->name = CORBA::string_dup(_enfVertex->name.c_str());
1632       // Geom Vertex Entry
1633       enfVertex->geomEntry = CORBA::string_dup(_enfVertex->geomEntry.c_str());
1634       // Coords
1635       BLSURFPlugin::TEnfVertexCoords_var coords = new BLSURFPlugin::TEnfVertexCoords();
1636       coords->length(_enfVertex->coords.size());
1637       for (int ind=0;ind<coords->length();ind++)
1638         coords[ind] = _enfVertex->coords[ind];
1639       enfVertex->coords = coords;
1640       // Group Name
1641       enfVertex->grpName = CORBA::string_dup(_enfVertex->grpName.c_str());
1642       // Face entry list
1643       BLSURFPlugin::TEntryList_var faceEntryList = new BLSURFPlugin::TEntryList();
1644       faceEntryList->length(_enfVertex->faceEntries.size());
1645       ::BLSURFPlugin_Hypothesis::TEntryList::const_iterator it_entry = _enfVertex->faceEntries.begin();
1646       for (int ind = 0; it_entry != _enfVertex->faceEntries.end();++it_entry, ++ind)
1647         faceEntryList[ind] = CORBA::string_dup((*it_entry).c_str());
1648       enfVertex->faceEntries = faceEntryList;
1649
1650       vertexList[i] = enfVertex;
1651     }
1652     MESSAGE("ENGINE : GetEnforcedVerticesEntry END ENTRY : " << entry);
1653     return vertexList._retn();
1654   } catch (const std::invalid_argument& ex) {
1655     SALOME::ExceptionStruct ExDescription;
1656     ExDescription.text = ex.what();
1657     ExDescription.type = SALOME::BAD_PARAM;
1658     ExDescription.sourceFile = "BLSURFPlugin_Hypothesis_i::GetEnforcedVerticesEntry(entry)";
1659     ExDescription.lineNumber = 1385;
1660     throw SALOME::SALOME_Exception(ExDescription);
1661   } catch (const std::exception& ex) {
1662     std::cout << "Exception: " << ex.what() << std::endl;
1663     THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
1664   }
1665 }
1666
1667 bool BLSURFPlugin_Hypothesis_i::UnsetEnforcedVertexEntry(const char* theFaceEntry, CORBA::Double x, CORBA::Double y,
1668     CORBA::Double z, const char* theVertexEntry) throw (SALOME::SALOME_Exception) {
1669   ASSERT(myBaseImpl);
1670   MESSAGE("IDL : UnsetEnforcedVertexEntry(" << theFaceEntry << "," << x << "," << y << "," << z << ", " << theVertexEntry << ")");
1671
1672   try {
1673     this->GetImpl()->ClearEnforcedVertex(theFaceEntry, x, y, z, theVertexEntry);
1674
1675     if (string(theVertexEntry).empty())
1676       SMESH::TPythonDump() << _this() << ".UnsetEnforcedVertex(" << theFaceEntry << ", " << x << ", " << y << ", " << z
1677           << ")";
1678     else
1679       SMESH::TPythonDump() << _this() << ".UnsetEnforcedVertexGeom(" << theFaceEntry << ", " << theVertexEntry << ")";
1680
1681   } catch (const std::invalid_argument& ex) {
1682     return false;
1683   } catch (const std::exception& ex) {
1684     std::cout << "Exception: " << ex.what() << std::endl;
1685     THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
1686   }
1687
1688   MESSAGE("ENGINE : UnsetEnforcedVertexEntry END ENTRY : " << theFaceEntry);
1689   return true;
1690 }
1691
1692 //bool BLSURFPlugin_Hypothesis_i::UnsetEnforcedVertexEntryWithPoint(const char* theFaceEntry, const char* theVertexEntry,
1693 //    CORBA::Double x, CORBA::Double y, CORBA::Double z) throw (SALOME::SALOME_Exception) {
1694 //  MESSAGE("IDL : UnsetEnforcedVertexEntryWithPoint START theFaceEntry=" << theFaceEntry << ", theVertexEntry=" << theVertexEntry);
1695 //
1696 //  bool ret = false;
1697 //
1698 //  try {
1699 //    ret = _unsetEnfVertex(theFaceEntry, x, y, z);
1700 //  } catch (SALOME_Exception& ex) {
1701 //    THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
1702 //  }
1703 //
1704 //  if (ret)
1705 //    SMESH::TPythonDump() << _this() << ".UnsetEnforcedVertexWithPoint(" << theFaceEntry << ", " << theVertexEntry
1706 //        << ")";
1707 //
1708 //  MESSAGE("IDL : UnsetEnforcedVertexEntryWithPoint END ENTRY : " << theFaceEntry);
1709 //  return ret;
1710 //}
1711
1712 bool BLSURFPlugin_Hypothesis_i::UnsetEnforcedVerticesEntry(const char* theFaceEntry) throw (SALOME::SALOME_Exception) {
1713   ASSERT(myBaseImpl);
1714   MESSAGE("IDL : UnsetEnforcedVerticesEntry(" << theFaceEntry << ")");
1715
1716   try {
1717     this->GetImpl()->ClearEnforcedVertices(theFaceEntry);
1718     SMESH::TPythonDump() << _this() << ".UnsetEnforcedVertices(" << theFaceEntry << ")";
1719   } catch (const std::invalid_argument& ex) {
1720     return false;
1721   } catch (const std::exception& ex) {
1722     THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
1723   }
1724
1725   MESSAGE("IDL : UnsetEnforcedVerticesEntry END ENTRY : " << theFaceEntry);
1726   return true;
1727 }
1728
1729 /* TODO GROUPS
1730  char* BLSURFPlugin_Hypothesis_i::GetEnforcedVertexGroupName(CORBA::Double x, CORBA::Double y, CORBA::Double z)
1731  throw (SALOME::SALOME_Exception)
1732  {
1733  ASSERT(myBaseImpl);
1734  MESSAGE("ENGINE : GetEnforcedVertexGroupName START ");
1735  try {
1736  return CORBA::string_dup( this->GetImpl()->GetEnforcedVertexGroupName(x, y, z).c_str());
1737  }
1738  catch (const std::invalid_argument& ex) {
1739  SALOME::ExceptionStruct ExDescription;
1740  ExDescription.text = ex.what();
1741  ExDescription.type = SALOME::BAD_PARAM;
1742  ExDescription.sourceFile = "BLSURFPlugin_Hypothesis_i::GetEnforcedVertexGroupName(entry)";
1743  ExDescription.lineNumber = 1146;
1744  throw SALOME::SALOME_Exception(ExDescription);
1745  }
1746  catch (SALOME_Exception& ex) {
1747  THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
1748  }
1749  MESSAGE("ENGINE : GetEnforcedVertexGroupName END ");
1750  return 0;
1751  }
1752
1753
1754  void BLSURFPlugin_Hypothesis_i::SetEnforcedVertexGroupName(CORBA::Double x, CORBA::Double y, CORBA::Double z, const char* groupName)
1755  throw (SALOME::SALOME_Exception)
1756  {
1757  ASSERT(myBaseImpl);
1758  MESSAGE("ENGINE : SetEnforcedVertexGroupName START ");
1759  try {
1760  this->GetImpl()->SetEnforcedVertexGroupName(x, y, z, groupName);
1761  }
1762  catch (const std::invalid_argument& ex) {
1763  SALOME::ExceptionStruct ExDescription;
1764  ExDescription.text = ex.what();
1765  ExDescription.type = SALOME::BAD_PARAM;
1766  ExDescription.sourceFile = "BLSURFPlugin_Hypothesis::SetEnforcedVertexGroupName(x,y,z)";
1767  ExDescription.lineNumber = 1170;
1768  throw SALOME::SALOME_Exception(ExDescription);
1769  }
1770  catch (SALOME_Exception& ex) {
1771  THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
1772  }
1773
1774  SMESH::TPythonDump() << _this() << ".SetEnforcedVertexGroupName("
1775  << x << ", " << y << ", " << z << ", '" << groupName << "' )";
1776
1777  MESSAGE("ENGINE : SetEnforcedVertexGroupName END ");
1778  }
1779  */
1780 ///////////////////////
1781
1782
1783 //=============================================================================
1784 /*!
1785  *  BLSURFPlugin_Hypothesis_i::GetImpl
1786  *
1787  *  Get implementation
1788  */
1789 //=============================================================================
1790 ::BLSURFPlugin_Hypothesis* BLSURFPlugin_Hypothesis_i::GetImpl() {
1791   // MESSAGE("BLSURFPlugin_Hypothesis_i::GetImpl");
1792   return (::BLSURFPlugin_Hypothesis*) myBaseImpl;
1793 }
1794
1795 //================================================================================
1796 /*!
1797  * \brief Verify whether hypothesis supports given entity type 
1798  * \param type - dimension (see SMESH::Dimension enumeration)
1799  * \retval CORBA::Boolean - TRUE if dimension is supported, FALSE otherwise
1800  * 
1801  * Verify whether hypothesis supports given entity type (see SMESH::Dimension enumeration)
1802  */
1803 //================================================================================  
1804 CORBA::Boolean BLSURFPlugin_Hypothesis_i::IsDimSupported(SMESH::Dimension type) {
1805   return type == SMESH::DIM_2D;
1806 }