Salome HOME
IPAL0054628: Medial Axis failure and NETGEN SIGSEGV
[plugins/netgenplugin.git] / src / NETGENPlugin / NETGENPlugin_Hypothesis_i.cxx
1 // Copyright (C) 2007-2019  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License, or (at your option) any later version.
10 //
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 // Lesser General Public License for more details.
15 //
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19 //
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22
23 //  NETGENPlugin : C++ implementation
24 // File      : NETGENPlugin_Hypothesis_i.cxx
25 // Author    : Michael Sazonov (OCN)
26 // Date      : 03/04/2006
27 // Project   : SALOME
28 //=============================================================================
29 //
30 #include "NETGENPlugin_Hypothesis_i.hxx"
31 #include "SMESH_Gen.hxx"
32 #include "SMESH_PythonDump.hxx"
33
34 #include "Utils_CorbaException.hxx"
35 #include "utilities.h"
36
37 using namespace std;
38
39 //=============================================================================
40 /*!
41  *  Specialization of isToSetParameter<T> for double
42  */
43 //=============================================================================
44
45 template<>
46 bool NETGENPlugin_Hypothesis_i::isToSetParameter<double>(double curValue,
47                                                          double newValue,
48                                                          /*SettingMethod*/int meth)
49 {
50   return isToSetParameter(true, (fabs(curValue - newValue) < 1e-20), meth);
51 }
52
53 //=============================================================================
54 /*!
55  *  NETGENPlugin_Hypothesis_i::NETGENPlugin_Hypothesis_i
56  *
57  *  Constructor
58  */
59 //=============================================================================
60 NETGENPlugin_Hypothesis_i::
61 NETGENPlugin_Hypothesis_i (PortableServer::POA_ptr thePOA,
62                            ::SMESH_Gen*            theGenImpl)
63   : SALOME::GenericObj_i( thePOA ), 
64     SMESH_Hypothesis_i( thePOA ),
65     mySetMethodFlags(0)
66 {
67   myBaseImpl = new ::NETGENPlugin_Hypothesis (theGenImpl->GetANewId(),
68                                               theGenImpl);
69 }
70
71 //=============================================================================
72 /*!
73  *  NETGENPlugin_Hypothesis_i::~NETGENPlugin_Hypothesis_i
74  *
75  *  Destructor
76  */
77 //=============================================================================
78 NETGENPlugin_Hypothesis_i::~NETGENPlugin_Hypothesis_i()
79 {
80 }
81
82 //=============================================================================
83 /*!
84  *  NETGENPlugin_Hypothesis_i::SetMaxSize
85  *
86  *  Set MaxSize
87  */
88 //=============================================================================
89 void NETGENPlugin_Hypothesis_i::SetMaxSize (CORBA::Double theValue)
90 {
91   if ( isToSetParameter( GetMaxSize(), theValue, METH_SetMaxSize ))
92   {
93     this->GetImpl()->SetMaxSize(theValue);
94     SMESH::TPythonDump() << _this() << ".SetMaxSize( " << SMESH::TVar(theValue) << " )";
95   }
96 }
97
98 //=============================================================================
99 /*!
100  *  NETGENPlugin_Hypothesis_i::GetMaxSize
101  *
102  *  Get MaxSize
103  */
104 //=============================================================================
105 CORBA::Double NETGENPlugin_Hypothesis_i::GetMaxSize()
106 {
107   return this->GetImpl()->GetMaxSize();
108 }
109
110 //=============================================================================
111 /*!
112  *  NETGENPlugin_Hypothesis_i::SetMinSize
113  *
114  *  Set MinSize
115  */
116 //=============================================================================
117 void NETGENPlugin_Hypothesis_i::SetMinSize (CORBA::Double theValue)
118 {
119   if ( isToSetParameter( GetMinSize(), theValue, METH_SetMinSize ))
120   {
121     this->GetImpl()->SetMinSize(theValue);
122     SMESH::TPythonDump() << _this() << ".SetMinSize( " << SMESH::TVar(theValue) << " )";
123   }
124 }
125
126 //=============================================================================
127 /*!
128  *  NETGENPlugin_Hypothesis_i::GetMinSize
129  *
130  *  Get MinSize
131  */
132 //=============================================================================
133 CORBA::Double NETGENPlugin_Hypothesis_i::GetMinSize()
134 {
135   return this->GetImpl()->GetMinSize();
136 }
137
138 //=============================================================================
139 /*!
140  *  NETGENPlugin_Hypothesis_i::SetSecondOrder
141  *
142  *  Set SecondOrder flag
143  */
144 //=============================================================================
145 void NETGENPlugin_Hypothesis_i::SetSecondOrder (CORBA::Boolean theValue)
146 {
147   if ( isToSetParameter( GetSecondOrder(), theValue, METH_SetSecondOrder ))
148   {
149     this->GetImpl()->SetSecondOrder(theValue);
150     SMESH::TPythonDump() << _this() << ".SetSecondOrder( " << theValue << " )";
151   }
152 }
153
154 //=============================================================================
155 /*!
156  *  NETGENPlugin_Hypothesis_i::GetSecondOrder
157  *
158  *  Get SecondOrder flag
159  */
160 //=============================================================================
161 CORBA::Boolean NETGENPlugin_Hypothesis_i::GetSecondOrder()
162 {
163   return this->GetImpl()->GetSecondOrder();
164 }
165
166 //=============================================================================
167 /*!
168  *  NETGENPlugin_Hypothesis_i::SetOptimize
169  *
170  *  Set Optimize flag
171  */
172 //=============================================================================
173 void NETGENPlugin_Hypothesis_i::SetOptimize (CORBA::Boolean theValue)
174 {
175   if ( isToSetParameter( GetOptimize(), theValue, METH_SetOptimize ))
176   {
177     this->GetImpl()->SetOptimize(theValue);
178     SMESH::TPythonDump() << _this() << ".SetOptimize( " << theValue << " )";
179   }
180 }
181
182 //=============================================================================
183 /*!
184  *  NETGENPlugin_Hypothesis_i::GetOptimize
185  *
186  *  Get Optimize flag
187  */
188 //=============================================================================
189 CORBA::Boolean NETGENPlugin_Hypothesis_i::GetOptimize()
190 {
191   return this->GetImpl()->GetOptimize();
192 }
193
194 //=============================================================================
195 /*!
196  *  NETGENPlugin_Hypothesis_i::SetFineness
197  *
198  *  Set Fineness
199  */
200 //=============================================================================
201 void NETGENPlugin_Hypothesis_i::SetFineness (CORBA::Long theValue)
202 {
203   if ( isToSetParameter( GetFineness(), theValue, METH_SetFineness ))
204   {
205     this->GetImpl()->SetFineness((::NETGENPlugin_Hypothesis::Fineness)theValue);
206     SMESH::TPythonDump() << _this() << ".SetFineness( " << theValue << " )";
207   }
208 }
209
210 //=============================================================================
211 /*!
212  *  NETGENPlugin_Hypothesis_i::GetFineness
213  *
214  *  Get Fineness
215  */
216 //=============================================================================
217 CORBA::Long NETGENPlugin_Hypothesis_i::GetFineness()
218 {
219   return this->GetImpl()->GetFineness();
220 }
221
222 //=============================================================================
223 /*!
224  *  NETGENPlugin_Hypothesis_i::SetGrowthRate
225  *
226  *  Set GrowthRate
227  */
228 //=============================================================================
229 void NETGENPlugin_Hypothesis_i::SetGrowthRate (CORBA::Double theValue)
230 {
231   if ( isToSetParameter( GetGrowthRate(), theValue, METH_SetGrowthRate ))
232   {
233     this->GetImpl()->SetGrowthRate(theValue);
234     SMESH::TPythonDump() << _this() << ".SetGrowthRate( " << SMESH::TVar(theValue) << " )";
235   }
236 }
237
238 //=============================================================================
239 /*!
240  *  NETGENPlugin_Hypothesis_i::GetGrowthRate
241  *
242  *  Get GrowthRate
243  */
244 //=============================================================================
245 CORBA::Double NETGENPlugin_Hypothesis_i::GetGrowthRate()
246 {
247   return this->GetImpl()->GetGrowthRate();
248 }
249
250 //=============================================================================
251 /*!
252  *  NETGENPlugin_Hypothesis_i::SetNbSegPerEdge
253  *
254  *  Set NbSegPerEdge
255  */
256 //=============================================================================
257 void NETGENPlugin_Hypothesis_i::SetNbSegPerEdge (CORBA::Double theValue)
258 {
259   if ( isToSetParameter( GetNbSegPerEdge(), theValue, METH_SetNbSegPerEdge ))
260   {
261     this->GetImpl()->SetNbSegPerEdge(theValue);
262     SMESH::TPythonDump() << _this() << ".SetNbSegPerEdge( " << SMESH::TVar(theValue) << " )";
263   }
264 }
265
266 //=============================================================================
267 /*!
268  *  NETGENPlugin_Hypothesis_i::GetNbSegPerEdge
269  *
270  *  Get NbSegPerEdge
271  */
272 //=============================================================================
273 CORBA::Double NETGENPlugin_Hypothesis_i::GetNbSegPerEdge()
274 {
275   return this->GetImpl()->GetNbSegPerEdge();
276 }
277
278 //=============================================================================
279 /*!
280  *  NETGENPlugin_Hypothesis_i::SetNbSegPerRadius
281  *
282  *  Set NbSegPerRadius
283  */
284 //=============================================================================
285 void NETGENPlugin_Hypothesis_i::SetNbSegPerRadius (CORBA::Double theValue)
286 {
287   if ( isToSetParameter( GetNbSegPerRadius(), theValue, METH_SetNbSegPerRadius ))
288   {
289     this->GetImpl()->SetNbSegPerRadius(theValue);
290     SMESH::TPythonDump() << _this() << ".SetNbSegPerRadius( " << SMESH::TVar(theValue) << " )";
291   }
292 }
293
294 //=============================================================================
295 /*!
296  *  NETGENPlugin_Hypothesis_i::GetNbSegPerRadius
297  *
298  *  Get NbSegPerRadius
299  */
300 //=============================================================================
301 CORBA::Double NETGENPlugin_Hypothesis_i::GetNbSegPerRadius()
302 {
303   return this->GetImpl()->GetNbSegPerRadius();
304 }
305
306 //=============================================================================
307
308 void NETGENPlugin_Hypothesis_i::SetChordalErrorEnabled(CORBA::Boolean theValue)
309 {
310   if ( isToSetParameter( GetChordalErrorEnabled(), theValue, METH_SetChordalErrorEnabled ))
311   {
312     this->GetImpl()->SetChordalErrorEnabled(theValue);
313     SMESH::TPythonDump() << _this() << ".SetChordalErrorEnabled( " << theValue << " )";
314   }
315 }
316
317 CORBA::Boolean NETGENPlugin_Hypothesis_i::GetChordalErrorEnabled()
318 {
319   return GetImpl()->GetChordalErrorEnabled();
320 }
321
322 void NETGENPlugin_Hypothesis_i::SetChordalError(CORBA::Double theValue)
323 {
324   if ( isToSetParameter( GetChordalError(), theValue, METH_SetChordalError ))
325   {
326     this->GetImpl()->SetChordalError(theValue);
327     SMESH::TPythonDump() << _this() << ".SetChordalError( " << SMESH::TVar(theValue) << " )";
328   }
329 }
330
331 CORBA::Double NETGENPlugin_Hypothesis_i::GetChordalError()
332 {
333   return GetImpl()->GetChordalError();
334 }
335
336 //=============================================================================
337
338 void NETGENPlugin_Hypothesis_i::SetLocalSizeOnShape(GEOM::GEOM_Object_ptr GeomObj,
339                                                     CORBA::Double         localSize)
340   throw (SALOME::SALOME_Exception)
341 {
342   string entry;
343   entry = GeomObj->GetStudyEntry();
344   if ( entry.empty() )
345     THROW_SALOME_CORBA_EXCEPTION( "SetLocalSizeOnShape(), shape is not published in study!",
346                                   SALOME::BAD_PARAM );
347   SetLocalSizeOnEntry(entry.c_str(), localSize);
348 }
349
350 //=============================================================================
351
352 void NETGENPlugin_Hypothesis_i::SetLocalSizeOnEntry(const char*   entry,
353                                                     CORBA::Double localSize)
354 {
355   if ( isToSetParameter( GetLocalSizeOnEntry(entry), localSize, METH_SetLocalSizeOnEntry ))
356   {
357     this->GetImpl()->SetLocalSizeOnEntry(entry, localSize);
358     SMESH::TPythonDump()
359       << _this() << ".SetLocalSizeOnShape(" << entry << ", " << localSize << ")";
360   }
361 }
362
363 //=============================================================================
364
365 CORBA::Double NETGENPlugin_Hypothesis_i::GetLocalSizeOnEntry(const char* entry)
366 {
367   return this->GetImpl()->GetLocalSizeOnEntry(entry);
368 }
369
370 //=============================================================================
371
372 NETGENPlugin::string_array* NETGENPlugin_Hypothesis_i::GetLocalSizeEntries()
373 {
374   NETGENPlugin::string_array_var result = new NETGENPlugin::string_array();
375   const ::NETGENPlugin_Hypothesis::TLocalSize localSizes =
376     this->GetImpl()->GetLocalSizesAndEntries();
377   result->length(localSizes.size());
378   ::NETGENPlugin_Hypothesis::TLocalSize::const_iterator it = localSizes.begin();
379   for (int i=0 ; it != localSizes.end() ; i++, it++)
380     {
381       string entry = (*it).first;
382       result[i] = CORBA::string_dup(entry.c_str());
383     }
384   return result._retn();
385 }
386
387 //=============================================================================
388
389 void NETGENPlugin_Hypothesis_i::UnsetLocalSizeOnEntry(const char* entry)
390 {
391   this->GetImpl()->UnsetLocalSizeOnEntry(entry);
392   SMESH::TPythonDump() << _this() << ".UnsetLocalSizeOnEntry(\"" << entry << "\")";
393 }
394
395 //=============================================================================
396
397 void NETGENPlugin_Hypothesis_i::SetMeshSizeFile(const char* fileName)
398 {
399   if ( GetImpl()->GetMeshSizeFile() != fileName )
400   {
401     GetImpl()->SetMeshSizeFile( fileName );
402     SMESH::TPythonDump() << _this() << ".SetMeshSizeFile( '" << fileName << "' )";
403   }
404 }
405
406 //=============================================================================
407
408 char* NETGENPlugin_Hypothesis_i::GetMeshSizeFile()
409 {
410   return CORBA::string_dup( GetImpl()->GetMeshSizeFile().c_str() );
411 }
412
413 //=============================================================================
414
415 void NETGENPlugin_Hypothesis_i::SetQuadAllowed (CORBA::Boolean theValue)
416 {
417   if ( NETGENPlugin_Hypothesis_i::isToSetParameter( GetQuadAllowed(),
418                                                     theValue,
419                                                     METH_SetQuadAllowed ))
420   {
421     this->GetImpl()->SetQuadAllowed(theValue);
422     SMESH::TPythonDump() << _this() << ".SetQuadAllowed( " << theValue << " )";
423   }
424 }
425
426 //=============================================================================
427
428 CORBA::Boolean NETGENPlugin_Hypothesis_i::GetQuadAllowed()
429 {
430   return this->GetImpl()->GetQuadAllowed();
431 }
432
433 //=============================================================================
434
435 void NETGENPlugin_Hypothesis_i::SetUseSurfaceCurvature (CORBA::Boolean theValue)
436 {
437   if ( NETGENPlugin_Hypothesis_i::isToSetParameter( GetUseSurfaceCurvature(),
438                                                     theValue,
439                                                     METH_SetSurfaceCurvature ))
440   {
441     this->GetImpl()->SetSurfaceCurvature(theValue);
442     SMESH::TPythonDump() << _this() << ".SetUseSurfaceCurvature( " << theValue << " )";
443   }
444 }
445
446 //=============================================================================
447
448 CORBA::Boolean NETGENPlugin_Hypothesis_i::GetUseSurfaceCurvature()
449 {
450   return this->GetImpl()->GetSurfaceCurvature();
451 }
452
453 //=============================================================================
454
455 void NETGENPlugin_Hypothesis_i::SetFuseEdges (CORBA::Boolean theValue)
456 {
457   if ( NETGENPlugin_Hypothesis_i::isToSetParameter( GetFuseEdges(),
458                                                     theValue,
459                                                     METH_SetFuseEdges ))
460   {
461     this->GetImpl()->SetFuseEdges(theValue);
462     SMESH::TPythonDump() << _this() << ".SetFuseEdges( " << theValue << " )";
463   }
464 }
465
466 //=============================================================================
467
468 CORBA::Boolean NETGENPlugin_Hypothesis_i::GetFuseEdges()
469 {
470   return this->GetImpl()->GetFuseEdges();
471 }
472
473 //=======================================================================
474 //function : SetNbSurfOptSteps
475 //purpose  : 
476 //=======================================================================
477
478 void NETGENPlugin_Hypothesis_i::SetNbSurfOptSteps(CORBA::Short nb )
479 {
480   if ( GetNbSurfOptSteps() != nb )
481   {
482     this->GetImpl()->SetNbSurfOptSteps( nb );
483     SMESH::TPythonDump() << _this() << ".SetNbSurfOptSteps( " << SMESH::TVar(nb) << " )";
484   }
485 }
486
487 //=======================================================================
488 //function : GetNbSurfOptSteps
489 //purpose  :
490 //=======================================================================
491
492 CORBA::Short NETGENPlugin_Hypothesis_i::GetNbSurfOptSteps()
493 {
494   return GetImpl()->GetNbSurfOptSteps();
495 }
496
497 //=======================================================================
498 //function : SetNbVolOptSteps
499 //purpose  : 
500 //=======================================================================
501
502 void NETGENPlugin_Hypothesis_i::SetNbVolOptSteps(CORBA::Short nb )
503 {
504   if ( GetNbVolOptSteps() != nb )
505   {
506     this->GetImpl()->SetNbVolOptSteps( nb );
507     SMESH::TPythonDump() << _this() << ".SetNbVolOptSteps( " << SMESH::TVar(nb) << " )";
508   }
509
510 }
511
512 //=======================================================================
513 //function : GetNbVolOptSteps
514 //purpose  :
515 //=======================================================================
516
517 CORBA::Short NETGENPlugin_Hypothesis_i::GetNbVolOptSteps()
518 {
519   return GetImpl()->GetNbVolOptSteps();
520 }
521
522 //=======================================================================
523 //function : SetElemSizeWeight
524 //purpose  : 
525 //=======================================================================
526
527 void NETGENPlugin_Hypothesis_i::SetElemSizeWeight(CORBA::Double size )
528 {
529   if ( GetElemSizeWeight() != size )
530   {
531     this->GetImpl()->SetElemSizeWeight( size );
532     SMESH::TPythonDump() << _this() << ".SetElemSizeWeight( " << SMESH::TVar(size) << " )";
533   }
534 }
535
536 //=======================================================================
537 //function : GetElemSizeWeight
538 //purpose  :
539 //=======================================================================
540
541 CORBA::Double NETGENPlugin_Hypothesis_i::GetElemSizeWeight()
542 {
543   return GetImpl()->GetElemSizeWeight();
544 }
545
546 //=======================================================================
547 //function : SetWorstElemMeasure
548 //purpose  : 
549 //=======================================================================
550
551 void NETGENPlugin_Hypothesis_i::SetWorstElemMeasure(CORBA::Short val )
552 {
553   if ( GetWorstElemMeasure() != val )
554   {
555     this->GetImpl()->SetWorstElemMeasure( val );
556     SMESH::TPythonDump() << _this() << ".SetWorstElemMeasure( " << SMESH::TVar(val) << " )";
557   }
558 }
559
560 //=======================================================================
561 //function : GetWorstElemMeasure
562 //purpose  : 
563 //=======================================================================
564
565 CORBA::Short NETGENPlugin_Hypothesis_i::GetWorstElemMeasure()
566 {
567   return GetImpl()->GetWorstElemMeasure();
568 }
569
570 //=======================================================================
571 //function : SetUseDelauney
572 //purpose  : 
573 //=======================================================================
574
575 void NETGENPlugin_Hypothesis_i::SetUseDelauney(CORBA::Boolean toUse)
576 {
577   if ( GetUseDelauney() != toUse )
578   {
579     this->GetImpl()->SetUseDelauney( toUse );
580     SMESH::TPythonDump() << _this() << ".SetUseDelauney( " << toUse << " )";
581   }
582 }
583
584 //=======================================================================
585 //function : GetUseDelauney
586 //purpose  : 
587 //=======================================================================
588
589 CORBA::Boolean NETGENPlugin_Hypothesis_i::GetUseDelauney()
590 {
591   return GetImpl()->GetUseDelauney();
592 }
593
594 //=======================================================================
595 //function : SetCheckOverlapping
596 //purpose  : 
597 //=======================================================================
598
599 void NETGENPlugin_Hypothesis_i::SetCheckOverlapping(CORBA::Boolean toCheck )
600 {
601   if ( GetCheckOverlapping() != toCheck )
602   {
603     this->GetImpl()->SetCheckOverlapping( toCheck );
604     SMESH::TPythonDump() << _this() << ".SetCheckOverlapping( " << toCheck << " )";
605   }
606 }
607
608 //=======================================================================
609 //function : GetCheckOverlapping
610 //purpose  : 
611 //=======================================================================
612
613 CORBA::Boolean NETGENPlugin_Hypothesis_i::GetCheckOverlapping()
614 {
615   return GetImpl()->GetCheckOverlapping();
616 }
617
618 //=======================================================================
619 //function : SetCheckChartBoundary
620 //purpose  : 
621 //=======================================================================
622
623 void NETGENPlugin_Hypothesis_i::SetCheckChartBoundary(CORBA::Boolean toCheck )
624 {
625   if ( GetCheckChartBoundary() != toCheck )
626   {
627     this->GetImpl()->SetCheckChartBoundary( toCheck );
628     SMESH::TPythonDump() << _this() << ".SetCheckChartBoundary( " << toCheck << " )";
629   }
630 }
631
632 //=======================================================================
633 //function : GetCheckChartBoundary
634 //purpose  : Get implementation
635 //=======================================================================
636
637 CORBA::Boolean NETGENPlugin_Hypothesis_i::GetCheckChartBoundary()
638 {
639   return GetImpl()->GetCheckChartBoundary();
640 }
641
642 //=============================================================================
643 /*!
644  *  NETGENPlugin_Hypothesis_i::GetImpl
645  *
646  *  Get implementation
647  */
648 //=============================================================================
649 ::NETGENPlugin_Hypothesis* NETGENPlugin_Hypothesis_i::GetImpl()
650 {
651   return (::NETGENPlugin_Hypothesis*)myBaseImpl;
652 }
653
654 //================================================================================
655 /*!
656  * \brief Verify whether hypothesis supports given entity type 
657   * \param type - dimension (see SMESH::Dimension enumeration)
658   * \retval CORBA::Boolean - TRUE if dimension is supported, FALSE otherwise
659  * 
660  * Verify whether hypothesis supports given entity type (see SMESH::Dimension enumeration)
661  */
662 //================================================================================  
663 CORBA::Boolean NETGENPlugin_Hypothesis_i::IsDimSupported( SMESH::Dimension type )
664 {
665   return type == SMESH::DIM_3D;
666 }
667
668 //================================================================================
669 /*!
670  * \brief method intended to remove explicit treatment of Netgen hypotheses from SMESH_NoteBook
671  */
672 //================================================================================
673
674 int NETGENPlugin_Hypothesis_i::getParamIndex(const TCollection_AsciiString& method,
675                                              int nbVars) const
676 {
677   if ( method == "SetMaxSize"        ) return 0;
678   if ( method == "SetGrowthRate"     ) return 1;
679   if ( method == "SetNbSegPerEdge"   ) return 2;
680   if ( method == "SetNbSegPerRadius" ) return 3;
681   if ( method == "SetMinSize" )        return nbVars-1;
682
683   return SMESH_Hypothesis_i::getParamIndex( method, nbVars ); // return default value
684 }
685
686 //================================================================================
687 /*!
688  * \brief Method used to convert variable parameters stored in an old study
689  * into myMethod2VarParams. It should return a method name for an index of
690  * variable parameters. Index is countered from zero
691  */
692 //================================================================================
693
694 std::string NETGENPlugin_Hypothesis_i::getMethodOfParameter(const int paramIndex,
695                                                             int nbVars) const
696 {
697   switch ( paramIndex ) {
698   case 0: return "SetMaxSize";
699   case 1: return nbVars == 2 ? "SetMinSize" : "SetGrowthRate";
700   case 2: return "SetNbSegPerEdge";
701   case 3: return "SetNbSegPerRadius";
702   case 4: return "SetMinSize";
703   }
704   return "";
705 }
706
707 //================================================================================
708 /*!
709  * \brief Return geometry this hypothesis depends on. Return false if there is no geometry parameter
710  */
711 //================================================================================
712
713 bool
714 NETGENPlugin_Hypothesis_i::getObjectsDependOn( std::vector< std::string > & entryArray,
715                                                std::vector< int >         & subIDArray ) const
716 {
717   typedef ::NETGENPlugin_Hypothesis THyp;
718
719   const THyp* h = static_cast< ::NETGENPlugin_Hypothesis* >( myBaseImpl );
720   const THyp::TLocalSize& ls = h->GetLocalSizesAndEntries();
721
722   THyp::TLocalSize::const_iterator entry2size = ls.cbegin();
723   for ( ; entry2size != ls.cend(); ++entry2size )
724     entryArray.push_back( entry2size->first );
725
726   return true;
727 }
728
729 //================================================================================
730 /*!
731  * \brief Set new geometry instead of that returned by getObjectsDependOn()
732  */
733 //================================================================================
734
735 bool
736 NETGENPlugin_Hypothesis_i::setObjectsDependOn( std::vector< std::string > & entryArray,
737                                                std::vector< int >         & subIDArray )
738 {
739   typedef ::NETGENPlugin_Hypothesis THyp;
740
741   const THyp* h = static_cast< ::NETGENPlugin_Hypothesis* >( myBaseImpl );
742
743   THyp::TLocalSize& lsNew = const_cast< THyp::TLocalSize& >( h->GetLocalSizesAndEntries() );
744   THyp::TLocalSize ls;
745   lsNew.swap( ls );
746
747   THyp::TLocalSize::const_iterator entry2size = ls.cbegin();
748   for ( int i = 0; entry2size != ls.cend(); ++entry2size, ++i )
749     if ( !entryArray[ i ].empty() )
750       lsNew[ entryArray[ i ]] = entry2size->second;
751
752   return true;
753 }