]> SALOME platform Git repositories - plugins/blsurfplugin.git/blob - src/BLSURFPlugin/BLSURFPlugin_Hypothesis.cxx
Salome HOME
50716f7aa3c39c40f1959b7a98e628669eaa1697
[plugins/blsurfplugin.git] / src / BLSURFPlugin / BLSURFPlugin_Hypothesis.cxx
1 // Copyright (C) 2007-2013  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 //           & Aurelien ALLEAUME (DISTENE)
24 //           Size maps development: Nicolas GEIMER (OCC) & Gilles DAVID (EURIWARE)
25 // ---
26 //
27 #include "BLSURFPlugin_Hypothesis.hxx"
28 #include "BLSURFPlugin_Attractor.hxx"
29 #include "SMESH_Gen_i.hxx"
30 #include <utilities.h>
31 #include <cstring>
32 #include <iostream>
33 #include <sstream>
34
35 // cascade include
36 #include "ShapeAnalysis.hxx"
37
38 // CORBA includes
39 #include CORBA_CLIENT_HEADER(SALOMEDS)
40 #include CORBA_CLIENT_HEADER(GEOM_Gen)
41
42 //=============================================================================
43 BLSURFPlugin_Hypothesis::BLSURFPlugin_Hypothesis(int hypId, int studyId, SMESH_Gen * gen) :
44   SMESH_Hypothesis(hypId, studyId, gen), 
45   _physicalMesh(GetDefaultPhysicalMesh()),
46   _geometricMesh(GetDefaultGeometricMesh()),
47   _phySize(GetDefaultPhySize()),
48   _phySizeRel(GetDefaultPhySizeRel()),
49   _minSize(GetDefaultMinSize()),
50   _minSizeRel(GetDefaultMinSizeRel()),
51   _maxSize(GetDefaultMaxSize()),
52   _maxSizeRel(GetDefaultMaxSizeRel()),
53   _gradation(GetDefaultGradation()),
54   _quadAllowed(GetDefaultQuadAllowed()),
55   _angleMesh(GetDefaultAngleMesh()),
56   _chordalError(GetDefaultChordalError()), 
57   _anisotropic(GetDefaultAnisotropic()),
58   _anisotropicRatio(GetDefaultAnisotropicRatio()),
59   _removeTinyEdges(GetDefaultRemoveTinyEdges()),
60   _tinyEdgeLength(GetDefaultTinyEdgeLength()),
61   _badElementRemoval(GetDefaultBadElementRemoval()),
62   _badElementAspectRatio(GetDefaultBadElementAspectRatio()),
63   _optimizeMesh(GetDefaultOptimizeMesh()),
64   _quadraticMesh(GetDefaultQuadraticMesh()),
65   _verb(GetDefaultVerbosity()),
66   _topology(GetDefaultTopology()),
67   _preCADMergeEdges(GetDefaultPreCADMergeEdges()),
68   _preCADProcess3DTopology(GetDefaultPreCADProcess3DTopology()),
69   _preCADDiscardInput(GetDefaultPreCADDiscardInput()),
70   _sizeMap(GetDefaultSizeMap()),
71   _attractors(GetDefaultSizeMap()),
72   _classAttractors(GetDefaultAttractorMap()),
73   _faceEntryEnfVertexListMap(GetDefaultFaceEntryEnfVertexListMap()),
74   _enfVertexList(GetDefaultEnfVertexList()),
75   _faceEntryCoordsListMap(GetDefaultFaceEntryCoordsListMap()),
76   _coordsEnfVertexMap(GetDefaultCoordsEnfVertexMap()),
77   _faceEntryEnfVertexEntryListMap(GetDefaultFaceEntryEnfVertexEntryListMap()),
78   _enfVertexEntryEnfVertexMap(GetDefaultEnfVertexEntryEnfVertexMap()),
79   _groupNameNodeIDMap(GetDefaultGroupNameNodeIDMap()),
80   _GMFFileName(GetDefaultGMFFile()),
81   _enforcedInternalVerticesAllFaces(GetDefaultInternalEnforcedVertex()),
82   _preCadFacesPeriodicityVector(GetDefaultPreCadFacesPeriodicityVector()),
83   _preCadEdgesPeriodicityVector(GetDefaultPreCadEdgesPeriodicityVector())
84 {
85   _name = "BLSURF_Parameters";
86   _param_algo_dim = 2;
87   
88 //   _GMFFileMode = false; // GMF ascii mode
89
90   const char* boolOptionNames[] = {         "correct_surface_intersections",            // default = 1
91                                             "create_tag_on_collision",                  // default = 1
92                                             "debug",                                    // default = 0
93                                             "enforce_cad_edge_sizes",                   // default = 0
94                                             "frontal",                                  // ok default = 1
95                                             "jacobian_rectification_respect_geometry",  // default = 1
96                                             "proximity",                                // default = 0
97                                             "rectify_jacobian",                         // default = 1
98                                             "respect_geometry",                         // default = 1
99                                             "" // mark of end
100       };
101
102   const char* intOptionNames[] = {          "hinterpol_flag",                           // ok default = 0
103                                             "hmean_flag",                               // ok default = 0
104                                             "max_number_of_points_per_patch",           // default = 100000
105                                             "prox_nb_layer",                            // detects the volumic proximity of surfaces
106                                             "" // mark of end
107       };
108   const char* doubleOptionNames[] = {       "surface_intersections_processing_max_cost",// default = 15
109                                             "periodic_tolerance",                       // default = diag/100
110                                             "prox_ratio",
111                                             "" // mark of end
112       };
113   const char* charOptionNames[] = {         "required_entities",                        // default = "respect"
114                                             "tags",                                     // default = "respect"
115                                             "" // mark of end
116       };
117
118   // PreCAD advanced options
119   const char* preCADboolOptionNames[] = {   "closed_geometry",                          // default = 0
120                                             "create_tag_on_collision",                  // default = 1
121                                             "debug",                                    // default = 0 
122                                             "remove_tiny_edges",                        // default = 0
123                                             "" // mark of end
124       };
125   const char* preCADintOptionNames[] = {    "manifold_geometry",                        // default = 0
126                                             "" // mark of end
127       };
128   const char* preCADdoubleOptionNames[] = { "periodic_tolerance",                       // default = diag * 1e-5
129                                             "sewing_tolerance",                         // default = diag * 5e-4
130                                             "tiny_edge_length",                         // default = diag * 1e-5
131                                             "" // mark of end
132       };
133   const char* preCADcharOptionNames[] = {   "required_entities",                        // default = "respect"
134                                             "tags",                                     // default = "respect"
135                                             "" // mark of end
136       };
137   
138   int i = 0;
139   while (boolOptionNames[i][0])
140     _option2value[boolOptionNames[i++]].clear();
141   
142   i = 0;
143   while (preCADboolOptionNames[i][0])
144     _preCADoption2value[preCADboolOptionNames[i++]].clear();
145   
146   i = 0;
147   while (intOptionNames[i][0])
148     _option2value[intOptionNames[i++]].clear();
149   
150   i = 0;
151   while (preCADintOptionNames[i][0])
152     _preCADoption2value[preCADintOptionNames[i++]].clear();
153
154   i = 0;
155   while (doubleOptionNames[i][0]) {
156     _doubleOptions.insert(doubleOptionNames[i]);
157     _option2value[doubleOptionNames[i++]].clear();
158   }
159   i = 0;
160   while (preCADdoubleOptionNames[i][0]) {
161     _preCADdoubleOptions.insert(preCADdoubleOptionNames[i]);
162     _preCADoption2value[preCADdoubleOptionNames[i++]].clear();
163   }
164   i = 0;
165   while (charOptionNames[i][0]) {
166     _charOptions.insert(charOptionNames[i]);
167     _option2value[charOptionNames[i++]].clear();
168   }
169   i = 0;
170   while (preCADcharOptionNames[i][0]) {
171     _preCADdoubleOptions.insert(preCADcharOptionNames[i]);
172     _preCADoption2value[preCADdoubleOptionNames[i++]].clear();
173   }
174   
175
176       
177   _sizeMap.clear();
178   _attractors.clear();
179   _faceEntryEnfVertexListMap.clear();
180   _enfVertexList.clear();
181   _faceEntryCoordsListMap.clear();
182   _coordsEnfVertexMap.clear();
183   _faceEntryEnfVertexEntryListMap.clear();
184   _enfVertexEntryEnfVertexMap.clear();
185   _groupNameNodeIDMap.clear();
186
187   /* TODO GROUPS
188    _groupNameEnfVertexListMap.clear();
189    _enfVertexGroupNameMap.clear();
190    */
191 }
192
193 TopoDS_Shape BLSURFPlugin_Hypothesis::entryToShape(std::string entry)
194 {
195   MESSAGE("BLSURFPlugin_Hypothesis::entryToShape "<<entry );
196   GEOM::GEOM_Object_var aGeomObj;
197   SMESH_Gen_i* smeshGen_i = SMESH_Gen_i::GetSMESHGen();
198   SALOMEDS::Study_ptr myStudy = smeshGen_i->GetCurrentStudy();
199   
200   TopoDS_Shape S = TopoDS_Shape();
201   SALOMEDS::SObject_var aSObj = myStudy->FindObjectID( entry.c_str() );
202   if (!aSObj->_is_nil() ) {
203     CORBA::Object_var obj = aSObj->GetObject();
204     aGeomObj = GEOM::GEOM_Object::_narrow(obj);
205     aSObj->UnRegister();
206   }
207   if ( !aGeomObj->_is_nil() )
208     S = smeshGen_i->GeomObjectToShape( aGeomObj.in() );
209   return S;
210 }
211
212 //=============================================================================
213 void BLSURFPlugin_Hypothesis::SetPhysicalMesh(PhysicalMesh thePhysicalMesh) {
214   if (thePhysicalMesh != _physicalMesh) {
215     _physicalMesh = thePhysicalMesh;
216     NotifySubMeshesHypothesisModification();
217   }
218 }
219
220 //=============================================================================
221 void BLSURFPlugin_Hypothesis::SetGeometricMesh(GeometricMesh theGeometricMesh) {
222   if (theGeometricMesh != _geometricMesh) {
223     _geometricMesh = theGeometricMesh;
224 //     switch (_geometricMesh) {
225 //       case DefaultGeom:
226 //       default:
227 //         _angleMesh = GetDefaultAngleMesh();
228 //         _gradation = GetDefaultGradation();
229 //         break;
230 //     }
231     NotifySubMeshesHypothesisModification();
232   }
233 }
234
235 //=============================================================================
236 void BLSURFPlugin_Hypothesis::SetPhySize(double theVal, bool isRelative) {
237   if ((theVal != _phySize) || (isRelative != _phySizeRel)) {
238     _phySizeRel = isRelative;
239     if (theVal == 0) {
240       _phySize = GetMaxSize();
241       MESSAGE("Warning: nul physical size is not allowed");
242     }
243     else
244       _phySize = theVal;
245     NotifySubMeshesHypothesisModification();
246   }
247 }
248
249 //=============================================================================
250 void BLSURFPlugin_Hypothesis::SetMinSize(double theMinSize, bool isRelative) {
251   if ((theMinSize != _minSize) || (isRelative != _minSizeRel)) {
252     _minSizeRel = isRelative;
253     _minSize = theMinSize;
254     NotifySubMeshesHypothesisModification();
255   }
256 }
257
258 //=============================================================================
259 void BLSURFPlugin_Hypothesis::SetMaxSize(double theMaxSize, bool isRelative) {
260   if ((theMaxSize != _maxSize) || (isRelative != _maxSizeRel)) {
261     _maxSizeRel = isRelative;
262     _maxSize = theMaxSize;
263     NotifySubMeshesHypothesisModification();
264   }
265 }
266
267 //=============================================================================
268 void BLSURFPlugin_Hypothesis::SetGradation(double theVal) {
269   if (theVal != _gradation) {
270     _gradation = theVal;
271     NotifySubMeshesHypothesisModification();
272   }
273 }
274
275 //=============================================================================
276 void BLSURFPlugin_Hypothesis::SetQuadAllowed(bool theVal) {
277   if (theVal != _quadAllowed) {
278     _quadAllowed = theVal;
279     NotifySubMeshesHypothesisModification();
280   }
281 }
282
283 //=============================================================================
284 void BLSURFPlugin_Hypothesis::SetAngleMesh(double theVal) {
285   if (theVal != _angleMesh) {
286     _angleMesh = theVal;
287     NotifySubMeshesHypothesisModification();
288   }
289 }
290
291 //=============================================================================
292 void BLSURFPlugin_Hypothesis::SetChordalError(double theDistance) {
293   if (theDistance != _chordalError) {
294     _chordalError = theDistance;
295     NotifySubMeshesHypothesisModification();
296   }
297 }
298
299 //=============================================================================
300 void BLSURFPlugin_Hypothesis::SetAnisotropic(bool theVal) {
301   if (theVal != _anisotropic) {
302     _anisotropic = theVal;
303     NotifySubMeshesHypothesisModification();
304   }
305 }
306
307 //=============================================================================
308 void BLSURFPlugin_Hypothesis::SetAnisotropicRatio(double theVal) {
309   if (theVal != _anisotropicRatio) {
310     _anisotropicRatio = theVal;
311     NotifySubMeshesHypothesisModification();
312   }
313 }
314
315 //=============================================================================
316 void BLSURFPlugin_Hypothesis::SetRemoveTinyEdges(bool theVal) {
317   if (theVal != _removeTinyEdges) {
318     _removeTinyEdges = theVal;
319     NotifySubMeshesHypothesisModification();
320   }
321 }
322
323 //=============================================================================
324 void BLSURFPlugin_Hypothesis::SetTinyEdgeLength(double theVal) {
325   if (theVal != _tinyEdgeLength) {
326     _tinyEdgeLength = theVal;
327     NotifySubMeshesHypothesisModification();
328   }
329 }
330
331 //=============================================================================
332 void BLSURFPlugin_Hypothesis::SetBadElementRemoval(bool theVal) {
333   if (theVal != _badElementRemoval) {
334     _badElementRemoval = theVal;
335     NotifySubMeshesHypothesisModification();
336   }
337 }
338
339 //=============================================================================
340 void BLSURFPlugin_Hypothesis::SetBadElementAspectRatio(double theVal) {
341   if (theVal != _badElementAspectRatio) {
342     _badElementAspectRatio = theVal;
343     NotifySubMeshesHypothesisModification();
344   }
345 }
346
347 //=============================================================================
348 void BLSURFPlugin_Hypothesis::SetOptimizeMesh(bool theVal) {
349   if (theVal != _optimizeMesh) {
350     _optimizeMesh = theVal;
351     NotifySubMeshesHypothesisModification();
352   }
353 }
354
355 //=============================================================================
356 void BLSURFPlugin_Hypothesis::SetQuadraticMesh(bool theVal) {
357   if (theVal != _quadraticMesh) {
358     _quadraticMesh = theVal;
359     NotifySubMeshesHypothesisModification();
360   }
361 }
362
363 //=============================================================================
364 void BLSURFPlugin_Hypothesis::SetTopology(Topology theTopology) {
365   if (theTopology != _topology) {
366     _topology = theTopology;
367     NotifySubMeshesHypothesisModification();
368   }
369 }
370
371 //=============================================================================
372 void BLSURFPlugin_Hypothesis::SetVerbosity(int theVal) {
373   if (theVal != _verb) {
374     _verb = theVal;
375     NotifySubMeshesHypothesisModification();
376   }
377 }
378
379 //=============================================================================
380 void BLSURFPlugin_Hypothesis::SetPreCADMergeEdges(bool theVal) {
381   if (theVal != _preCADMergeEdges) {
382 //     SetTopology(PreCAD);
383     _preCADMergeEdges = theVal;
384     NotifySubMeshesHypothesisModification();
385   }
386 }
387
388 //=============================================================================
389 void BLSURFPlugin_Hypothesis::SetPreCADProcess3DTopology(bool theVal) {
390   if (theVal != _preCADProcess3DTopology) {
391 //     SetTopology(PreCAD);
392     _preCADProcess3DTopology = theVal;
393     NotifySubMeshesHypothesisModification();
394   }
395 }
396
397 //=============================================================================
398 void BLSURFPlugin_Hypothesis::SetPreCADDiscardInput(bool theVal) {
399   if (theVal != _preCADDiscardInput) {
400 //     SetTopology(PreCAD);
401     _preCADDiscardInput = theVal;
402     NotifySubMeshesHypothesisModification();
403   }
404 }
405
406 //=============================================================================
407 // void BLSURFPlugin_Hypothesis::SetGMFFile(const std::string& theFileName, bool isBinary)
408 void BLSURFPlugin_Hypothesis::SetGMFFile(const std::string& theFileName)
409 {
410   _GMFFileName = theFileName;
411 //   _GMFFileMode = isBinary;
412   NotifySubMeshesHypothesisModification();
413 }
414
415 //=============================================================================
416 void BLSURFPlugin_Hypothesis::SetOptionValue(const std::string& optionName, const std::string& optionValue)
417     throw (std::invalid_argument) {
418   TOptionValues::iterator op_val = _option2value.find(optionName);
419   if (op_val == _option2value.end()) {
420     std::string msg = "Unknown BLSURF option: '" + optionName + "'";
421     throw std::invalid_argument(msg);
422   }
423   if (op_val->second != optionValue) {
424     const char* ptr = optionValue.c_str();
425     // strip white spaces
426     while (ptr[0] == ' ')
427       ptr++;
428     int i = strlen(ptr);
429     while (i != 0 && ptr[i - 1] == ' ')
430       i--;
431     // check value type
432     bool typeOk = true;
433     std::string typeName;
434     if (i == 0) {
435       // empty string
436     } else if (_charOptions.find(optionName) != _charOptions.end()) {
437       // do not check strings
438     } else if (_doubleOptions.find(optionName) != _doubleOptions.end()) {
439       // check if value is double
440       char * endPtr;
441       strtod(ptr, &endPtr);
442       typeOk = (ptr != endPtr);
443       typeName = "real";
444     } else {
445       // check if value is int
446       char * endPtr;
447       strtol(ptr, &endPtr, 10);
448       typeOk = (ptr != endPtr);
449       typeName = "integer";
450     }
451     if (!typeOk) {
452       std::string msg = "Advanced option '" + optionName + "' = '" + optionValue + "' but must be " + typeName;
453       throw std::invalid_argument(msg);
454     }
455     op_val->second = optionValue;
456     NotifySubMeshesHypothesisModification();
457   }
458 }
459
460 //=============================================================================
461 void BLSURFPlugin_Hypothesis::SetPreCADOptionValue(const std::string& optionName, const std::string& optionValue)
462     throw (std::invalid_argument) {
463   TOptionValues::iterator op_val = _preCADoption2value.find(optionName);
464   if (op_val == _preCADoption2value.end()) {
465     std::string msg = "Unknown BLSURF option: '" + optionName + "'";
466     throw std::invalid_argument(msg);
467   }
468   if (op_val->second != optionValue) {
469     const char* ptr = optionValue.c_str();
470     // strip white spaces
471     while (ptr[0] == ' ')
472       ptr++;
473     int i = strlen(ptr);
474     while (i != 0 && ptr[i - 1] == ' ')
475       i--;
476     // check value type
477     bool typeOk = true;
478     std::string typeName;
479     if (i == 0) {
480       // empty string
481     } else if (_preCADdoubleOptions.find(optionName) != _preCADdoubleOptions.end()) {
482       // check if value is double
483       char * endPtr;
484       strtod(ptr, &endPtr);
485       typeOk = (ptr != endPtr);
486       typeName = "real";
487     } else {
488       // check if value is int
489       char * endPtr;
490       strtol(ptr, &endPtr, 10);
491       typeOk = (ptr != endPtr);
492       typeName = "integer";
493     }
494     if (!typeOk) {
495       std::string msg = "PreCAD advanced option '" + optionName + "' = '" + optionValue + "' but must be " + typeName;
496       throw std::invalid_argument(msg);
497     }
498     op_val->second = optionValue;
499     NotifySubMeshesHypothesisModification();
500   }
501 }
502
503 //=============================================================================
504 std::string BLSURFPlugin_Hypothesis::GetOptionValue(const std::string& optionName) throw (std::invalid_argument) {
505   TOptionValues::iterator op_val = _option2value.find(optionName);
506   if (op_val == _option2value.end()) {
507     std::string msg = "Unknown BLSURF option: <";
508     msg += optionName + ">";
509     throw std::invalid_argument(msg);
510   }
511   return op_val->second;
512 }
513
514 //=============================================================================
515 std::string BLSURFPlugin_Hypothesis::GetPreCADOptionValue(const std::string& optionName) throw (std::invalid_argument) {
516   TOptionValues::iterator op_val = _preCADoption2value.find(optionName);
517   if (op_val == _preCADoption2value.end()) {
518     std::string msg = "Unknown PRECAD option: <";
519     msg += optionName + ">";
520     throw std::invalid_argument(msg);
521   }
522   return op_val->second;
523 }
524
525 //=============================================================================
526 void BLSURFPlugin_Hypothesis::ClearOption(const std::string& optionName) {
527   TOptionValues::iterator op_val = _option2value.find(optionName);
528   if (op_val != _option2value.end())
529     op_val->second.clear();
530 }
531
532 //=============================================================================
533 void BLSURFPlugin_Hypothesis::ClearPreCADOption(const std::string& optionName) {
534   TOptionValues::iterator op_val = _preCADoption2value.find(optionName);
535   if (op_val != _preCADoption2value.end())
536     op_val->second.clear();
537 }
538
539 //=======================================================================
540 //function : SetSizeMapEntry
541 //=======================================================================
542 void BLSURFPlugin_Hypothesis::SetSizeMapEntry(const std::string& entry, const std::string& sizeMap) {
543   if (_sizeMap[entry].compare(sizeMap) != 0) {
544     SetPhysicalMesh(PhysicalLocalSize);
545     _sizeMap[entry] = sizeMap;
546     NotifySubMeshesHypothesisModification();
547   }
548 }
549
550 //=======================================================================
551 //function : GetSizeMapEntry
552 //=======================================================================
553 std::string BLSURFPlugin_Hypothesis::GetSizeMapEntry(const std::string& entry) {
554   TSizeMap::iterator it = _sizeMap.find(entry);
555   if (it != _sizeMap.end())
556     return it->second;
557   else
558     return "No_Such_Entry";
559 }
560
561 /*!
562  * \brief Return the size maps
563  */
564 BLSURFPlugin_Hypothesis::TSizeMap BLSURFPlugin_Hypothesis::GetSizeMapEntries(const BLSURFPlugin_Hypothesis* hyp) {
565   return hyp ? hyp->_GetSizeMapEntries() : GetDefaultSizeMap();
566 }
567
568 //=======================================================================
569 //function : SetAttractorEntry
570 //=======================================================================
571 void BLSURFPlugin_Hypothesis::SetAttractorEntry(const std::string& entry, const std::string& attractor) {
572   if (_attractors[entry].compare(attractor) != 0) {
573     SetPhysicalMesh(PhysicalLocalSize);
574     _attractors[entry] = attractor;
575     NotifySubMeshesHypothesisModification();
576   }
577 }
578
579 //=======================================================================
580 //function : GetAttractorEntry
581 //=======================================================================
582 std::string BLSURFPlugin_Hypothesis::GetAttractorEntry(const std::string& entry) {
583   TSizeMap::iterator it = _attractors.find(entry);
584   if (it != _attractors.end())
585     return it->second;
586   else
587     return "No_Such_Entry";
588 }
589
590 /*!
591  * \brief Return the attractors
592  */
593 BLSURFPlugin_Hypothesis::TSizeMap BLSURFPlugin_Hypothesis::GetAttractorEntries(const BLSURFPlugin_Hypothesis* hyp) {
594   return hyp ? hyp->_GetAttractorEntries() : GetDefaultSizeMap();
595 }
596
597 //=======================================================================
598 //function : SetClassAttractorEntry
599 //=======================================================================
600 void BLSURFPlugin_Hypothesis::SetClassAttractorEntry(const std::string& entry, const std::string& attEntry, double StartSize, double EndSize, double ActionRadius, double ConstantRadius)
601 {
602   SetPhysicalMesh(PhysicalLocalSize);
603
604   // The new attractor can't be defined on the same face as another sizemap
605   TSizeMap::iterator it  = _sizeMap.find( entry );
606   if ( it != _sizeMap.end() ) {
607     _sizeMap.erase(it);
608     NotifySubMeshesHypothesisModification();
609   }
610   else {
611     TSizeMap::iterator itAt  = _attractors.find( entry );
612     if ( itAt != _attractors.end() ) {
613       _attractors.erase(itAt);
614       NotifySubMeshesHypothesisModification();
615     }
616   }
617   
618   const TopoDS_Shape AttractorShape = BLSURFPlugin_Hypothesis::entryToShape(attEntry);
619   const TopoDS_Face FaceShape = TopoDS::Face(BLSURFPlugin_Hypothesis::entryToShape(entry));
620   bool attExists = (_classAttractors.find(entry) != _classAttractors.end());
621   double u1,u2,v1,v2, diag;
622   
623   if ( !attExists || (attExists && _classAttractors[entry]->GetAttractorEntry().compare(attEntry) != 0)){ 
624     ShapeAnalysis::GetFaceUVBounds(FaceShape,u1,u2,v1,v2);
625 //     diag = sqrt((u2 - u1) * (u2 - u1) + (v2 - v1) * (v2 - v1));  
626     BLSURFPlugin_Attractor* myAttractor = new BLSURFPlugin_Attractor(FaceShape, AttractorShape, attEntry);//, 0.1 ); // test 0.002 * diag); 
627     myAttractor->BuildMap();
628     myAttractor->SetParameters(StartSize, EndSize, ActionRadius, ConstantRadius);
629     _classAttractors[entry] = myAttractor;
630     NotifySubMeshesHypothesisModification();
631   }
632   else {
633     _classAttractors[entry]->SetParameters(StartSize, EndSize, ActionRadius, ConstantRadius);
634     if (!_classAttractors[entry]->IsMapBuilt()){
635       _classAttractors[entry]->BuildMap();
636     }
637     NotifySubMeshesHypothesisModification();
638   }
639     
640 }
641
642 //=======================================================================
643 //function : SetConstantSizeOnAdjacentFaces
644 //=======================================================================
645 // TODO uncomment and test (include the needed .hxx)
646 // SetConstantSizeOnAdjacentFaces(myShape, att_entry, startSize, endSize = user_size, const_dist  ) {
647 //   TopTools_IndexedMapOfShapListOdShape anEdge2FaceMap;
648 //   TopExp::MapShapesAnAncestors(myShape,TopAbs_EDGE, TopAbs_FACE, anEdge2FaceMap);
649 //   TopTools_IndexedMapOfShapListOdShape::iterator it;
650 //   for (it = anEdge2FaceMap.begin();it != anEdge2FaceMap.end();it++){
651 //       SetClassAttractorEntry((*it).first, att_entry, startSize, endSize, 0, const_dist)
652 //   }
653
654
655
656
657
658
659 //=======================================================================
660 //function : GetClassAttractorEntry
661 //=======================================================================
662 // BLSURFPlugin_Attractor&  BLSURFPlugin_Hypothesis::GetClassAttractorEntry(const std::string& entry)
663 // {
664 //  TAttractorMap::iterator it  = _classAttractors.find( entry );
665 //  if ( it != _classAttractors.end() )
666 //    return it->second;
667 //  else
668 //    return "No_Such_Entry";
669 // }
670 // 
671   /*!
672    * \brief Return the map of attractor instances
673    */
674 BLSURFPlugin_Hypothesis::TAttractorMap BLSURFPlugin_Hypothesis::GetClassAttractorEntries(const BLSURFPlugin_Hypothesis* hyp)
675 {
676     return hyp ? hyp->_GetClassAttractorEntries():GetDefaultAttractorMap();
677 }
678
679 //=======================================================================
680 //function : ClearEntry
681 //=======================================================================
682 void BLSURFPlugin_Hypothesis::ClearEntry(const std::string& entry)
683 {
684  TSizeMap::iterator it  = _sizeMap.find( entry );
685  
686  if ( it != _sizeMap.end() ) {
687    _sizeMap.erase(it);
688    NotifySubMeshesHypothesisModification();
689  }
690  else {
691    TSizeMap::iterator itAt  = _attractors.find( entry );
692    if ( itAt != _attractors.end() ) {
693      _attractors.erase(itAt);
694      NotifySubMeshesHypothesisModification();
695    }
696    else {
697      TAttractorMap::iterator it_clAt = _classAttractors.find( entry );
698      if ( it_clAt != _classAttractors.end() ) {
699        _classAttractors.erase(it_clAt);
700        MESSAGE("_classAttractors.size() = "<<_classAttractors.size())
701        NotifySubMeshesHypothesisModification();
702      }
703      else
704        std::cout<<"No_Such_Entry"<<std::endl;
705    }
706  }
707 }
708
709 //=======================================================================
710 //function : ClearSizeMaps
711 //=======================================================================
712 void BLSURFPlugin_Hypothesis::ClearSizeMaps() {
713   _sizeMap.clear();
714   _attractors.clear();
715   _classAttractors.clear();
716 }
717
718 // Enable internal enforced vertices on specific face if requested by user
719
720 ////=======================================================================
721 ////function : SetInternalEnforcedVertex
722 ////=======================================================================
723 //void BLSURFPlugin_Hypothesis::SetInternalEnforcedVertex(TEntry theFaceEntry,
724 //                                                        bool toEnforceInternalVertices,
725 //                                                        TEnfGroupName theGroupName) {
726
727 //  MESSAGE("BLSURFPlugin_Hypothesis::SetInternalEnforcedVertex("<< theFaceEntry << ", "
728 //      << toEnforceInternalVertices << ", " << theGroupName << ")");
729   
730 //  TFaceEntryInternalVerticesList::iterator it = _faceEntryInternalVerticesList.find(theFaceEntry);
731 //  if (it != _faceEntryInternalVerticesList.end()) {
732 //    if (!toEnforceInternalVertices) {
733 //      _faceEntryInternalVerticesList.erase(it);
734 //    }
735 //  }
736 //  else {
737 //    if (toEnforceInternalVertices) {
738 //      _faceEntryInternalVerticesList.insert(theFaceEntry);
739 //    }
740 //  }
741   
742 //  // TODO
743 //  // Take care of groups
744 //}
745
746
747 //=======================================================================
748 //function : SetEnforcedVertex
749 //=======================================================================
750 bool BLSURFPlugin_Hypothesis::SetEnforcedVertex(TEntry theFaceEntry, TEnfName theVertexName, TEntry theVertexEntry,
751                                                 TEnfGroupName theGroupName, double x, double y, double z) {
752
753   MESSAGE("BLSURFPlugin_Hypothesis::SetEnforcedVertex("<< theFaceEntry << ", "
754       << x << ", " << y << ", " << z << ", " << theVertexName << ", " << theVertexEntry << ", " << theGroupName << ")");
755
756   SetPhysicalMesh(PhysicalLocalSize);
757
758   //  TEnfVertexList::iterator it;
759   bool toNotify = false;
760   bool toCreate = true;
761
762   TEnfVertex *oldEnVertex;
763   TEnfVertex *newEnfVertex = new TEnfVertex();
764   newEnfVertex->name = theVertexName;
765   newEnfVertex->geomEntry = theVertexEntry;
766   newEnfVertex->coords.clear();
767   if (theVertexEntry == "") {
768     newEnfVertex->coords.push_back(x);
769     newEnfVertex->coords.push_back(y);
770     newEnfVertex->coords.push_back(z);
771   }
772   newEnfVertex->grpName = theGroupName;
773   newEnfVertex->faceEntries.clear();
774   newEnfVertex->faceEntries.insert(theFaceEntry);
775   
776   
777   // update _enfVertexList
778   TEnfVertexList::iterator it = _enfVertexList.find(newEnfVertex);
779   if (it != _enfVertexList.end()) {
780     toCreate = false;
781     oldEnVertex = (*it);
782     MESSAGE("Enforced Vertex was found => Update");
783     if (oldEnVertex->name != theVertexName) {
784       MESSAGE("Update name from \"" << oldEnVertex->name << "\" to \"" << theVertexName << "\"");
785       oldEnVertex->name = theVertexName;
786       toNotify = true;
787     }
788     if (oldEnVertex->grpName != theGroupName) {
789       MESSAGE("Update group name from \"" << oldEnVertex->grpName << "\" to \"" << theGroupName << "\"");
790       oldEnVertex->grpName = theGroupName;
791       toNotify = true;
792     }
793     TEntryList::iterator it_faceEntries = oldEnVertex->faceEntries.find(theFaceEntry);
794     if (it_faceEntries == oldEnVertex->faceEntries.end()) {
795       MESSAGE("Update face list by adding \"" << theFaceEntry << "\"");
796       oldEnVertex->faceEntries.insert(theFaceEntry);
797       _faceEntryEnfVertexListMap[theFaceEntry].insert(oldEnVertex);
798       toNotify = true;
799     }
800     if (toNotify) {
801       // update map coords / enf vertex if needed
802       if (oldEnVertex->coords.size()) {
803         _coordsEnfVertexMap[oldEnVertex->coords] = oldEnVertex;
804         _faceEntryCoordsListMap[theFaceEntry].insert(oldEnVertex->coords);
805       }
806
807       // update map geom entry / enf vertex if needed
808       if (oldEnVertex->geomEntry != "") {
809         _enfVertexEntryEnfVertexMap[oldEnVertex->geomEntry] = oldEnVertex;
810         _faceEntryEnfVertexEntryListMap[theFaceEntry].insert(oldEnVertex->geomEntry);
811       }
812     }
813   }
814
815 //   //////// CREATE ////////////
816   if (toCreate) {
817     toNotify = true;
818     MESSAGE("Creating new enforced vertex");
819     _faceEntryEnfVertexListMap[theFaceEntry].insert(newEnfVertex);
820     _enfVertexList.insert(newEnfVertex);
821     if (theVertexEntry == "") {
822       _faceEntryCoordsListMap[theFaceEntry].insert(newEnfVertex->coords);
823       _coordsEnfVertexMap[newEnfVertex->coords] = newEnfVertex;
824     }
825     else {
826       _faceEntryEnfVertexEntryListMap[theFaceEntry].insert(newEnfVertex->geomEntry);
827       _enfVertexEntryEnfVertexMap[newEnfVertex->geomEntry] = newEnfVertex;
828     }
829   }
830
831   if (toNotify)
832     NotifySubMeshesHypothesisModification();
833
834   MESSAGE("BLSURFPlugin_Hypothesis::SetEnforcedVertex END");
835   return toNotify;
836 }
837
838
839 //=======================================================================
840 //function : GetEnforcedVertices
841 //=======================================================================
842
843 BLSURFPlugin_Hypothesis::TEnfVertexList BLSURFPlugin_Hypothesis::GetEnfVertexList(const TEntry& theFaceEntry)
844     throw (std::invalid_argument) {
845
846   if (_faceEntryEnfVertexListMap.count(theFaceEntry) > 0)
847     return _faceEntryEnfVertexListMap[theFaceEntry];
848   else
849     return GetDefaultEnfVertexList();
850
851   std::ostringstream msg;
852   msg << "No enforced vertex for face entry " << theFaceEntry;
853   throw std::invalid_argument(msg.str());
854 }
855
856 //=======================================================================
857 //function : GetEnfVertexCoordsList
858 //=======================================================================
859
860 BLSURFPlugin_Hypothesis::TEnfVertexCoordsList BLSURFPlugin_Hypothesis::GetEnfVertexCoordsList(
861     const TEntry& theFaceEntry) throw (std::invalid_argument) {
862
863   if (_faceEntryCoordsListMap.count(theFaceEntry) > 0)
864     return _faceEntryCoordsListMap[theFaceEntry];
865
866   std::ostringstream msg;
867   msg << "No enforced vertex coords for face entry " << theFaceEntry;
868   throw std::invalid_argument(msg.str());
869 }
870
871 //=======================================================================
872 //function : GetEnfVertexEntryList
873 //=======================================================================
874
875 BLSURFPlugin_Hypothesis::TEntryList BLSURFPlugin_Hypothesis::GetEnfVertexEntryList(const TEntry& theFaceEntry)
876     throw (std::invalid_argument) {
877
878   if (_faceEntryEnfVertexEntryListMap.count(theFaceEntry) > 0)
879     return _faceEntryEnfVertexEntryListMap[theFaceEntry];
880
881   std::ostringstream msg;
882   msg << "No enforced vertex entry for face entry " << theFaceEntry;
883   throw std::invalid_argument(msg.str());
884 }
885
886 //=======================================================================
887 //function : GetEnfVertex(TEnfVertexCoords coords)
888 //=======================================================================
889
890 BLSURFPlugin_Hypothesis::TEnfVertex* BLSURFPlugin_Hypothesis::GetEnfVertex(TEnfVertexCoords coords)
891     throw (std::invalid_argument) {
892
893   if (_coordsEnfVertexMap.count(coords) > 0)
894     return _coordsEnfVertexMap[coords];
895
896   std::ostringstream msg;
897   msg << "No enforced vertex with coords (" << coords[0] << ", " << coords[1] << ", " << coords[2] << ")";
898   throw std::invalid_argument(msg.str());
899 }
900
901 //=======================================================================
902 //function : GetEnfVertex(const TEntry& theEnfVertexEntry)
903 //=======================================================================
904
905 BLSURFPlugin_Hypothesis::TEnfVertex* BLSURFPlugin_Hypothesis::GetEnfVertex(const TEntry& theEnfVertexEntry)
906     throw (std::invalid_argument) {
907
908   if (_enfVertexEntryEnfVertexMap.count(theEnfVertexEntry) > 0)
909     return _enfVertexEntryEnfVertexMap[theEnfVertexEntry];
910
911   std::ostringstream msg;
912   msg << "No enforced vertex with entry " << theEnfVertexEntry;
913   throw std::invalid_argument(msg.str());
914 }
915
916 //Enable internal enforced vertices on specific face if requested by user
917 ////=======================================================================
918 ////function : GetInternalEnforcedVertex
919 ////=======================================================================
920
921 //bool BLSURFPlugin_Hypothesis::GetInternalEnforcedVertex(const TEntry& theFaceEntry)
922 //{
923 //  if (_faceEntryInternalVerticesList.count(theFaceEntry) > 0)
924 //    return true;
925 //  return false;
926 //}
927
928 //=======================================================================
929 //function : ClearEnforcedVertex
930 //=======================================================================
931
932 bool BLSURFPlugin_Hypothesis::ClearEnforcedVertex(const TEntry& theFaceEntry, double x, double y, double z,
933     const TEntry& theVertexEntry) throw (std::invalid_argument) {
934
935   bool toNotify = false;
936   std::ostringstream msg;
937   TEnfVertex *oldEnfVertex;
938   TEnfVertexCoords coords;
939   coords.clear();
940   coords.push_back(x);
941   coords.push_back(y);
942   coords.push_back(z);
943
944   // check that enf vertex with given enf vertex entry exists
945   TEnfVertexEntryEnfVertexMap::iterator it_enfVertexEntry = _enfVertexEntryEnfVertexMap.find(theVertexEntry);
946   if (it_enfVertexEntry != _enfVertexEntryEnfVertexMap.end()) {
947     // Success
948     MESSAGE("Found enforced vertex with geom entry " << theVertexEntry);
949     oldEnfVertex = it_enfVertexEntry->second;
950
951     _enfVertexEntryEnfVertexMap.erase(it_enfVertexEntry);
952
953     TEntryList& enfVertexEntryList = _faceEntryEnfVertexEntryListMap[theFaceEntry];
954     enfVertexEntryList.erase(theVertexEntry);
955     if (enfVertexEntryList.size() == 0)
956       _faceEntryEnfVertexEntryListMap.erase(theFaceEntry);
957     //    TFaceEntryEnfVertexEntryListMap::iterator it_entry_entry = _faceEntryEnfVertexEntryListMap.find(theFaceEntry);
958     //    TEntryList::iterator it_entryList = it_entry_entry->second.find(theVertexEntry);
959     //    it_entry_entry->second.erase(it_entryList);
960     //    if (it_entry_entry->second.size() == 0)
961     //      _faceEntryEnfVertexEntryListMap.erase(it_entry_entry);
962   } else {
963     // Fail
964     MESSAGE("Enforced vertex with geom entry " << theVertexEntry << " not found");
965     msg << "No enforced vertex with geom entry " << theVertexEntry;
966     // check that enf vertex with given coords exists
967     TCoordsEnfVertexMap::iterator it_coords_enf = _coordsEnfVertexMap.find(coords);
968     if (it_coords_enf != _coordsEnfVertexMap.end()) {
969       // Success
970       MESSAGE("Found enforced vertex with coords " << x << ", " << y << ", " << z);
971       oldEnfVertex = it_coords_enf->second;
972
973       _coordsEnfVertexMap.erase(it_coords_enf);
974
975       TEnfVertexCoordsList& enfVertexCoordsList = _faceEntryCoordsListMap[theFaceEntry];
976       enfVertexCoordsList.erase(coords);
977       if (enfVertexCoordsList.size() == 0)
978         _faceEntryCoordsListMap.erase(theFaceEntry);
979       //      TFaceEntryCoordsListMap::iterator it_entry_coords = _faceEntryCoordsListMap.find(theFaceEntry);
980       //      TEnfVertexCoordsList::iterator it_coordsList = it_entry_coords->second.find(coords);
981       //      it_entry_coords->second.erase(it_coordsList);
982       //      if (it_entry_coords->second.size() == 0)
983       //        _faceEntryCoordsListMap.erase(it_entry_coords);
984     } else {
985       // Fail
986       MESSAGE("Enforced vertex with coords " << x << ", " << y << ", " << z << " not found");
987       msg << std::endl;
988       msg << "No enforced vertex at " << x << ", " << y << ", " << z;
989       throw std::invalid_argument(msg.str());
990     }
991   }
992
993   MESSAGE("Remove enf vertex from _enfVertexList");
994
995   // update _enfVertexList
996   TEnfVertexList::iterator it = _enfVertexList.find(oldEnfVertex);
997   if (it != _enfVertexList.end()) {
998     (*it)->faceEntries.erase(theFaceEntry);
999     if ((*it)->faceEntries.size() == 0){
1000       _enfVertexList.erase(it);
1001       toNotify = true;
1002     }
1003     MESSAGE("Done");
1004   }
1005
1006   // update _faceEntryEnfVertexListMap
1007   TEnfVertexList& currentEnfVertexList = _faceEntryEnfVertexListMap[theFaceEntry];
1008   currentEnfVertexList.erase(oldEnfVertex);
1009
1010   if (currentEnfVertexList.size() == 0) {
1011     MESSAGE("Remove _faceEntryEnfVertexListMap[" << theFaceEntry <<"]");
1012     _faceEntryEnfVertexListMap.erase(theFaceEntry);
1013     MESSAGE("Done");
1014   }
1015
1016   if (toNotify)
1017     NotifySubMeshesHypothesisModification();
1018
1019   return toNotify;
1020 }
1021
1022 //=======================================================================
1023 //function : ClearEnforcedVertices
1024 //=======================================================================
1025
1026 bool BLSURFPlugin_Hypothesis::ClearEnforcedVertices(const TEntry& theFaceEntry) throw (std::invalid_argument) {
1027
1028   bool toNotify = false;
1029   TEnfVertex *oldEnfVertex;
1030
1031   TFaceEntryCoordsListMap::iterator it_entry_coords = _faceEntryCoordsListMap.find(theFaceEntry);
1032   if (it_entry_coords != _faceEntryCoordsListMap.end()) {
1033     toNotify = true;
1034     TEnfVertexCoordsList coordsList = it_entry_coords->second;
1035     TEnfVertexCoordsList::iterator it_coordsList = coordsList.begin();
1036     for (; it_coordsList != coordsList.end(); ++it_coordsList) {
1037       TEnfVertexCoords coords = (*it_coordsList);
1038       oldEnfVertex = _coordsEnfVertexMap[coords];
1039       _coordsEnfVertexMap.erase(coords);
1040       // update _enfVertexList
1041       TEnfVertexList::iterator it = _enfVertexList.find(oldEnfVertex);
1042       if (it != _enfVertexList.end()) {
1043         (*it)->faceEntries.erase(theFaceEntry);
1044         if ((*it)->faceEntries.size() == 0){
1045           _enfVertexList.erase(it);
1046           toNotify = true;
1047         }
1048         MESSAGE("Done");
1049       }
1050     }
1051     _faceEntryCoordsListMap.erase(it_entry_coords);
1052     _faceEntryEnfVertexListMap.erase(theFaceEntry);
1053   }
1054
1055   TFaceEntryEnfVertexEntryListMap::iterator it_entry_entry = _faceEntryEnfVertexEntryListMap.find(theFaceEntry);
1056   if (it_entry_entry != _faceEntryEnfVertexEntryListMap.end()) {
1057     toNotify = true;
1058     TEntryList enfVertexEntryList = it_entry_entry->second;
1059     TEntryList::iterator it_enfVertexEntryList = enfVertexEntryList.begin();
1060     for (; it_enfVertexEntryList != enfVertexEntryList.end(); ++it_enfVertexEntryList) {
1061       TEntry enfVertexEntry = (*it_enfVertexEntryList);
1062       oldEnfVertex = _enfVertexEntryEnfVertexMap[enfVertexEntry];
1063       _enfVertexEntryEnfVertexMap.erase(enfVertexEntry);
1064       // update _enfVertexList
1065       TEnfVertexList::iterator it = _enfVertexList.find(oldEnfVertex);
1066       if (it != _enfVertexList.end()) {
1067         (*it)->faceEntries.erase(theFaceEntry);
1068         if ((*it)->faceEntries.size() == 0){
1069           _enfVertexList.erase(it);
1070           toNotify = true;
1071         }
1072         MESSAGE("Done");
1073       }
1074     }
1075     _faceEntryEnfVertexEntryListMap.erase(it_entry_entry);
1076     _faceEntryEnfVertexListMap.erase(theFaceEntry);
1077   }
1078
1079   if (toNotify)
1080     NotifySubMeshesHypothesisModification();
1081
1082   return toNotify;
1083   //  std::ostringstream msg;
1084   //  msg << "No enforced vertex for " << theFaceEntry;
1085   //  throw std::invalid_argument(msg.str());
1086 }
1087
1088 //=======================================================================
1089 //function : ClearAllEnforcedVertices
1090 //=======================================================================
1091 void BLSURFPlugin_Hypothesis::ClearAllEnforcedVertices() {
1092   _faceEntryEnfVertexListMap.clear();
1093   _enfVertexList.clear();
1094   _faceEntryCoordsListMap.clear();
1095   _coordsEnfVertexMap.clear();
1096   _faceEntryEnfVertexEntryListMap.clear();
1097   _enfVertexEntryEnfVertexMap.clear();
1098 //  Enable internal enforced vertices on specific face if requested by user
1099 //  _faceEntryInternalVerticesList.clear();
1100   NotifySubMeshesHypothesisModification();
1101 }
1102
1103 //================================================================================
1104 /*!
1105  * \brief Return the enforced vertices
1106  */
1107 //================================================================================
1108
1109
1110 BLSURFPlugin_Hypothesis::TFaceEntryEnfVertexListMap BLSURFPlugin_Hypothesis::GetAllEnforcedVerticesByFace(
1111     const BLSURFPlugin_Hypothesis* hyp) {
1112   return hyp ? hyp->_GetAllEnforcedVerticesByFace() : GetDefaultFaceEntryEnfVertexListMap();
1113 }
1114
1115 //Enable internal enforced vertices on specific face if requested by user
1116 //BLSURFPlugin_Hypothesis::TFaceEntryInternalVerticesList BLSURFPlugin_Hypothesis::GetAllInternalEnforcedVerticesByFace(
1117 //    const BLSURFPlugin_Hypothesis* hyp) {
1118 //  return hyp ? hyp->_GetAllInternalEnforcedVerticesByFace() : GetDefaultFaceEntryInternalVerticesMap();
1119 //}
1120
1121 bool BLSURFPlugin_Hypothesis::GetInternalEnforcedVertexAllFaces(const BLSURFPlugin_Hypothesis* hyp)
1122 {
1123   return hyp ? hyp->_GetInternalEnforcedVertexAllFaces() : GetDefaultInternalEnforcedVertex();
1124 }
1125
1126 BLSURFPlugin_Hypothesis::TEnfGroupName BLSURFPlugin_Hypothesis::GetInternalEnforcedVertexAllFacesGroup(const BLSURFPlugin_Hypothesis* hyp)
1127 {
1128   return hyp ? hyp->_GetInternalEnforcedVertexAllFacesGroup() : BLSURFPlugin_Hypothesis::TEnfGroupName();
1129 }
1130
1131 BLSURFPlugin_Hypothesis::TEnfVertexList BLSURFPlugin_Hypothesis::GetAllEnforcedVertices(
1132     const BLSURFPlugin_Hypothesis* hyp) {
1133   return hyp ? hyp->_GetAllEnforcedVertices() : GetDefaultEnfVertexList();
1134 }
1135
1136 BLSURFPlugin_Hypothesis::TFaceEntryCoordsListMap BLSURFPlugin_Hypothesis::GetAllCoordsByFace(
1137     const BLSURFPlugin_Hypothesis* hyp) {
1138   return hyp ? hyp->_GetAllCoordsByFace() : GetDefaultFaceEntryCoordsListMap();
1139 }
1140
1141 BLSURFPlugin_Hypothesis::TCoordsEnfVertexMap BLSURFPlugin_Hypothesis::GetAllEnforcedVerticesByCoords(
1142     const BLSURFPlugin_Hypothesis* hyp) {
1143   return hyp ? hyp->_GetAllEnforcedVerticesByCoords() : GetDefaultCoordsEnfVertexMap();
1144 }
1145
1146 BLSURFPlugin_Hypothesis::TFaceEntryEnfVertexEntryListMap BLSURFPlugin_Hypothesis::GetAllEnfVertexEntriesByFace(
1147     const BLSURFPlugin_Hypothesis* hyp) {
1148   return hyp ? hyp->_GetAllEnfVertexEntriesByFace() : GetDefaultFaceEntryEnfVertexEntryListMap();
1149 }
1150
1151 BLSURFPlugin_Hypothesis::TEnfVertexEntryEnfVertexMap BLSURFPlugin_Hypothesis::GetAllEnforcedVerticesByEnfVertexEntry(
1152     const BLSURFPlugin_Hypothesis* hyp) {
1153   return hyp ? hyp->_GetAllEnforcedVerticesByEnfVertexEntry() : GetDefaultEnfVertexEntryEnfVertexMap();
1154 }
1155
1156 std::set<int> BLSURFPlugin_Hypothesis::GetEnfVertexNodeIDs(TEnfGroupName theGroupName) throw (std::invalid_argument)
1157 {
1158   TGroupNameNodeIDMap::const_iterator it = _groupNameNodeIDMap.find(theGroupName);
1159   if (it != _groupNameNodeIDMap.end()) {
1160     return it->second;
1161   }
1162   std::ostringstream msg;
1163   msg << "No group " << theGroupName;
1164   throw std::invalid_argument(msg.str());
1165 }
1166
1167 void BLSURFPlugin_Hypothesis::AddEnfVertexNodeID(TEnfGroupName theGroupName,int theNodeID)
1168 {
1169   _groupNameNodeIDMap[theGroupName].insert(theNodeID);
1170 }
1171
1172 void BLSURFPlugin_Hypothesis::RemoveEnfVertexNodeID(TEnfGroupName theGroupName,int theNodeID) throw (std::invalid_argument)
1173 {
1174   TGroupNameNodeIDMap::iterator it = _groupNameNodeIDMap.find(theGroupName);
1175   if (it != _groupNameNodeIDMap.end()) {
1176     std::set<int>::iterator IDit = it->second.find(theNodeID);
1177     if (IDit != it->second.end())
1178       it->second.erase(IDit);
1179     std::ostringstream msg;
1180     msg << "No node IDs " << theNodeID << " for group " << theGroupName;
1181     throw std::invalid_argument(msg.str());
1182   }
1183   std::ostringstream msg;
1184   msg << "No group " << theGroupName;
1185   throw std::invalid_argument(msg.str());
1186 }
1187
1188
1189 //=============================================================================
1190 void BLSURFPlugin_Hypothesis::SetInternalEnforcedVertexAllFaces(bool toEnforceInternalVertices) {
1191   if (toEnforceInternalVertices != _enforcedInternalVerticesAllFaces) {
1192     _enforcedInternalVerticesAllFaces = toEnforceInternalVertices;
1193     if (toEnforceInternalVertices)
1194       SetPhysicalMesh(PhysicalLocalSize);
1195     NotifySubMeshesHypothesisModification();
1196   }
1197 }
1198
1199
1200 //=============================================================================
1201 void BLSURFPlugin_Hypothesis::SetInternalEnforcedVertexAllFacesGroup(BLSURFPlugin_Hypothesis::TEnfGroupName theGroupName) {
1202   if (string(theGroupName) != string(_enforcedInternalVerticesAllFacesGroup)) {
1203     _enforcedInternalVerticesAllFacesGroup = theGroupName;
1204     NotifySubMeshesHypothesisModification();
1205   }
1206 }
1207
1208 //=============================================================================
1209 BLSURFPlugin_Hypothesis::TPreCadPeriodicityVector BLSURFPlugin_Hypothesis::GetPreCadFacesPeriodicityVector(
1210     const BLSURFPlugin_Hypothesis* hyp) {
1211   return hyp ? hyp->_GetPreCadFacesPeriodicityVector() : GetDefaultPreCadFacesPeriodicityVector();
1212 }
1213
1214 //=============================================================================
1215 BLSURFPlugin_Hypothesis::TPreCadPeriodicityVector BLSURFPlugin_Hypothesis::GetPreCadEdgesPeriodicityVector(
1216     const BLSURFPlugin_Hypothesis* hyp) {
1217   return hyp ? hyp->_GetPreCadEdgesPeriodicityVector() : GetDefaultPreCadEdgesPeriodicityVector();
1218 }
1219
1220 //=============================================================================
1221 BLSURFPlugin_Hypothesis::TFacesPeriodicityVector BLSURFPlugin_Hypothesis::GetFacesPeriodicityVector(
1222     const BLSURFPlugin_Hypothesis* hyp) {
1223   return hyp ? hyp->_GetFacesPeriodicityVector() : GetDefaultFacesPeriodicityVector();
1224 }
1225
1226 //=============================================================================
1227 BLSURFPlugin_Hypothesis::TEdgesPeriodicityVector BLSURFPlugin_Hypothesis::GetEdgesPeriodicityVector(
1228     const BLSURFPlugin_Hypothesis* hyp){
1229   return hyp ? hyp->_GetEdgesPeriodicityVector() : GetDefaultEdgesPeriodicityVector();
1230 }
1231
1232 //=============================================================================
1233 BLSURFPlugin_Hypothesis::TVerticesPeriodicityVector BLSURFPlugin_Hypothesis::GetVerticesPeriodicityVector(
1234     const BLSURFPlugin_Hypothesis* hyp){
1235   return hyp ? hyp->_GetVerticesPeriodicityVector() : GetDefaultVerticesPeriodicityVector();
1236 }
1237
1238 //=======================================================================
1239 //function : ClearAllEnforcedVertices
1240 //=======================================================================
1241 void BLSURFPlugin_Hypothesis::ClearPreCadPeriodicityVectors() {
1242   _preCadFacesPeriodicityVector.clear();
1243   _preCadEdgesPeriodicityVector.clear();
1244   NotifySubMeshesHypothesisModification();
1245 }
1246
1247 //=======================================================================
1248 //function : AddPreCadFacesPeriodicity
1249 //=======================================================================
1250 void BLSURFPlugin_Hypothesis::AddPreCadFacesPeriodicity(TEntry theFace1Entry, TEntry theFace2Entry,
1251     vector<string> &theSourceVerticesEntries, vector<string> &theTargetVerticesEntries) {
1252
1253   TPreCadPeriodicity preCadFacesPeriodicity;
1254   preCadFacesPeriodicity.shape1Entry = theFace1Entry;
1255   preCadFacesPeriodicity.shape2Entry = theFace2Entry;
1256   preCadFacesPeriodicity.theSourceVerticesEntries = theSourceVerticesEntries;
1257   preCadFacesPeriodicity.theTargetVerticesEntries = theTargetVerticesEntries;
1258
1259   _preCadFacesPeriodicityVector.push_back(preCadFacesPeriodicity);
1260
1261   NotifySubMeshesHypothesisModification();
1262 }
1263
1264 //=======================================================================
1265 //function : AddPreCadEdgesPeriodicity
1266 //=======================================================================
1267 void BLSURFPlugin_Hypothesis::AddPreCadEdgesPeriodicity(TEntry theEdge1Entry, TEntry theEdge2Entry,
1268     vector<string> &theSourceVerticesEntries, vector<string> &theTargetVerticesEntries) {
1269
1270   TPreCadPeriodicity preCadEdgesPeriodicity;
1271   preCadEdgesPeriodicity.shape1Entry = theEdge1Entry;
1272   preCadEdgesPeriodicity.shape2Entry = theEdge2Entry;
1273   preCadEdgesPeriodicity.theSourceVerticesEntries = theSourceVerticesEntries;
1274   preCadEdgesPeriodicity.theTargetVerticesEntries = theTargetVerticesEntries;
1275
1276   _preCadEdgesPeriodicityVector.push_back(preCadEdgesPeriodicity);
1277
1278   NotifySubMeshesHypothesisModification();
1279 }
1280
1281 //=======================================================================
1282 //function : AddFacePeriodicity
1283 //=======================================================================
1284 void BLSURFPlugin_Hypothesis::AddFacePeriodicity(TEntry theFace1Entry, TEntry theFace2Entry) {
1285
1286   std::pair< TEntry, TEntry > pairOfFacesEntries = std::make_pair(theFace1Entry, theFace2Entry);
1287
1288   _facesPeriodicityVector.push_back(pairOfFacesEntries);
1289
1290   NotifySubMeshesHypothesisModification();
1291 }
1292
1293
1294 //=======================================================================
1295 //function : AddEdgePeriodicity
1296 //=======================================================================
1297 void BLSURFPlugin_Hypothesis::AddEdgePeriodicity(TEntry theFace1Entry, TEntry theEdge1Entry, TEntry theFace2Entry, TEntry theEdge2Entry, int edge_orientation) {
1298
1299   TEdgePeriodicity edgePeriodicity;
1300   edgePeriodicity.theFace1Entry = theFace1Entry;
1301   edgePeriodicity.theEdge1Entry = theEdge1Entry;
1302   edgePeriodicity.theFace2Entry = theFace2Entry;
1303   edgePeriodicity.theEdge2Entry = theEdge2Entry;
1304   edgePeriodicity.edge_orientation = edge_orientation;
1305
1306   _edgesPeriodicityVector.push_back(edgePeriodicity);
1307
1308   NotifySubMeshesHypothesisModification();
1309 }
1310
1311 //=======================================================================
1312 //function : AddVertexPeriodicity
1313 //=======================================================================
1314 void BLSURFPlugin_Hypothesis::AddVertexPeriodicity(TEntry theEdge1Entry, TEntry theVertex1Entry, TEntry theEdge2Entry, TEntry theVertex2Entry) {
1315
1316   TVertexPeriodicity vertexPeriodicity;
1317   vertexPeriodicity.theEdge1Entry = theEdge1Entry;
1318   vertexPeriodicity.theVertex1Entry = theVertex1Entry;
1319   vertexPeriodicity.theEdge2Entry = theEdge2Entry;
1320   vertexPeriodicity.theVertex2Entry = theVertex2Entry;
1321
1322   _verticesPeriodicityVector.push_back(vertexPeriodicity);
1323
1324   NotifySubMeshesHypothesisModification();
1325 }
1326
1327 //=============================================================================
1328 std::ostream & BLSURFPlugin_Hypothesis::SaveTo(std::ostream & save) {
1329    // We must keep at least the same number of arguments when increasing the SALOME version
1330    // When BLSURF becomes CADMESH, some parameters were fused into a single one. Thus the same
1331    // parameter can be written several times to keep the old global number of parameters.
1332
1333    // Treat old options which are now in the advanced options
1334    TOptionValues::iterator op_val;
1335    int _decimesh = -1;
1336    int _preCADRemoveNanoEdges = -1;
1337    double _preCADEpsNano = -1.0;
1338    op_val = _option2value.find("respect_geometry");
1339    if (op_val != _option2value.end()) {
1340      std::string value = op_val->second;
1341      if (!value.empty())
1342        _decimesh = value.compare("1") == 0 ? 1 : 0;
1343    }
1344    op_val = _preCADoption2value.find("remove_tiny_edges");
1345    if (op_val != _preCADoption2value.end()) {
1346      std::string value = op_val->second;
1347      if (!value.empty())
1348        _preCADRemoveNanoEdges = value.compare("1") == 0 ? 1 : 0;
1349    }
1350    op_val = _preCADoption2value.find("tiny_edge_length");
1351    if (op_val != _preCADoption2value.end()) {
1352      std::string value = op_val->second;
1353      if (!value.empty())
1354        _preCADEpsNano = strtod(value.c_str(), NULL);
1355    }
1356    
1357   save << " " << (int) _topology << " " << (int) _physicalMesh << " " << (int) _geometricMesh << " " << _phySize << " "
1358       << _angleMesh << " " << _gradation << " " << (int) _quadAllowed << " " << _decimesh;
1359   save << " " << _minSize << " " << _maxSize << " " << _angleMesh << " " << _minSize << " " << _maxSize << " " << _verb;
1360   save << " " << (int) _preCADMergeEdges << " " << _preCADRemoveNanoEdges << " " << (int) _preCADDiscardInput << " " << _preCADEpsNano ;
1361   save << " " << (int) _enforcedInternalVerticesAllFaces;
1362   save << " " << (int) _phySizeRel << " " << (int) _minSizeRel << " " << (int) _maxSizeRel << " " << _chordalError ;
1363   save << " " << (int) _anisotropic << " " << _anisotropicRatio << " " << (int) _removeTinyEdges << " " << _tinyEdgeLength ;
1364   save << " " << (int) _badElementRemoval << " " << _badElementAspectRatio << " " << (int) _optimizeMesh << " " << (int) _quadraticMesh ;
1365   save << " " << (int) _preCADProcess3DTopology;
1366
1367   op_val = _option2value.begin();
1368   if (op_val != _option2value.end()) {
1369     save << " " << "__OPTIONS_BEGIN__";
1370     for (; op_val != _option2value.end(); ++op_val) {
1371       if (!op_val->second.empty())
1372         save << " " << op_val->first << " " << op_val->second << "%#"; // "%#" is a mark of value end
1373     }
1374     save << " " << "__OPTIONS_END__";
1375   }
1376   
1377   op_val = _preCADoption2value.begin();
1378   if (op_val != _preCADoption2value.end()) {
1379     save << " " << "__PRECAD_OPTIONS_BEGIN__";
1380     for (; op_val != _preCADoption2value.end(); ++op_val) {
1381       if (!op_val->second.empty())
1382         save << " " << op_val->first << " " << op_val->second << "%#"; // "%#" is a mark of value end
1383     }
1384     save << " " << "__PRECAD_OPTIONS_END__";
1385   }
1386
1387   TSizeMap::iterator it_sm = _sizeMap.begin();
1388   if (it_sm != _sizeMap.end()) {
1389     save << " " << "__SIZEMAP_BEGIN__";
1390     for (; it_sm != _sizeMap.end(); ++it_sm) {
1391       save << " " << it_sm->first << " " << it_sm->second << "%#"; // "%#" is a mark of value end
1392     }
1393     save << " " << "__SIZEMAP_END__";
1394   }
1395
1396   TSizeMap::iterator it_at = _attractors.begin();
1397   if (it_at != _attractors.end()) {
1398     save << " " << "__ATTRACTORS_BEGIN__";
1399     for (; it_at != _attractors.end(); ++it_at) {
1400       save << " " << it_at->first << " " << it_at->second << "%#"; // "%#" is a mark of value end
1401     }
1402     save << " " << "__ATTRACTORS_END__";
1403   }
1404   
1405   TAttractorMap::iterator it_At = _classAttractors.begin();
1406   if (it_At != _classAttractors.end()) {
1407     std::ostringstream test;
1408     save << " " << "__NEW_ATTRACTORS_BEGIN__";
1409     test << " " << "__NEW_ATTRACTORS_BEGIN__";
1410     for (; it_At != _classAttractors.end(); ++it_At) {
1411       std::vector<double> attParams;
1412       attParams   = it_At->second->GetParameters();
1413 //       double step = it_At->second->GetStep();
1414       save << " " << it_At->first;
1415       save << " " << it_At->second->GetAttractorEntry();
1416       save << " " << attParams[0]  << " " <<  attParams[1] << " " <<  attParams[2] << " " <<  attParams[3];
1417 //       save << " " << step;
1418       test << " " << it_At->first;
1419       test << " " << it_At->second->GetAttractorEntry();
1420       test << " " << attParams[0]  << " " <<  attParams[1] << " " <<  attParams[2] << " " <<  attParams[3];
1421 //       test << " " << step;
1422     }
1423     save << " " << "__NEW_ATTRACTORS_END__";
1424     test << " " << "__NEW_ATTRACTORS_END__";
1425     MESSAGE(" Attractor hypothesis saved as "<<test.str())
1426   }
1427
1428   TEnfVertexList::const_iterator it_enf = _enfVertexList.begin();
1429   if (it_enf != _enfVertexList.end()) {
1430     save << " " << "__ENFORCED_VERTICES_BEGIN__";
1431     for (; it_enf != _enfVertexList.end(); ++it_enf) {
1432       TEnfVertex *enfVertex = (*it_enf);
1433       save << " " << "__BEGIN_VERTEX__";
1434       if (!enfVertex->name.empty()) {
1435         save << " " << "__BEGIN_NAME__";
1436         save << " " << enfVertex->name;
1437         save << " " << "__END_NAME__";
1438       }
1439       if (!enfVertex->geomEntry.empty()) {
1440         save << " " << "__BEGIN_ENTRY__";
1441         save << " " << enfVertex->geomEntry;
1442         save << " " << "__END_ENTRY__";
1443       }
1444       if (!enfVertex->grpName.empty()) {
1445         save << " " << "__BEGIN_GROUP__";
1446         save << " " << enfVertex->grpName;
1447         save << " " << "__END_GROUP__";
1448       }
1449       if (enfVertex->coords.size()) {
1450         save << " " << "__BEGIN_COORDS__";
1451         for (int i=0;i<enfVertex->coords.size();i++)
1452           save << " " << enfVertex->coords[i];
1453         save << " " << "__END_COORDS__";
1454       }
1455       TEntryList::const_iterator faceEntriesIt = enfVertex->faceEntries.begin();
1456       bool hasFaces = false;
1457       if (faceEntriesIt != enfVertex->faceEntries.end()) {
1458         hasFaces = true;
1459         save << " " << "__BEGIN_FACELIST__";
1460       }
1461       for (; faceEntriesIt != enfVertex->faceEntries.end(); ++faceEntriesIt)
1462         save << " " << (*faceEntriesIt);
1463       if (hasFaces)
1464         save << " " << "__END_FACELIST__";
1465       save << " " << "__END_VERTEX__";
1466     }
1467     save << " " << "__ENFORCED_VERTICES_END__";
1468   }
1469
1470   //PERIODICITY
1471
1472   SavePreCADPeriodicity(save, "FACES");
1473   SavePreCADPeriodicity(save, "EDGES");
1474
1475   SaveFacesPeriodicity(save);
1476   SaveEdgesPeriodicity(save);
1477   SaveVerticesPeriodicity(save);
1478
1479   return save;
1480 }
1481
1482 void BLSURFPlugin_Hypothesis::SaveFacesPeriodicity(std::ostream & save){
1483
1484   TFacesPeriodicityVector::const_iterator it_faces_periodicity = _facesPeriodicityVector.begin();
1485   if (it_faces_periodicity != _facesPeriodicityVector.end()) {
1486     MESSAGE("__FACES_PERIODICITY_BEGIN__");
1487     save << " " << "__FACES_PERIODICITY_BEGIN__";
1488     for (; it_faces_periodicity != _facesPeriodicityVector.end(); ++it_faces_periodicity) {
1489       TFacesPeriodicity periodicity_i = (*it_faces_periodicity);
1490       save << " " << "__BEGIN_PERIODICITY_DESCRIPTION__";
1491       save << " " << "__BEGIN_ENTRY1__";
1492       save << " " << periodicity_i.first;
1493       save << " " << "__END_ENTRY1__";
1494       save << " " << "__BEGIN_ENTRY2__";
1495       save << " " << periodicity_i.second;
1496       save << " " << "__END_ENTRY2__";
1497       save << " " << "__END_PERIODICITY_DESCRIPTION__";
1498     }
1499     save << " " << "__FACES_PERIODICITY_END__";
1500     MESSAGE("__FACES_PERIODICITY_END__");
1501   }
1502 }
1503
1504 void BLSURFPlugin_Hypothesis::SaveEdgesPeriodicity(std::ostream & save){
1505
1506   TEdgesPeriodicityVector::const_iterator it_edges_periodicity = _edgesPeriodicityVector.begin();
1507   if (it_edges_periodicity != _edgesPeriodicityVector.end()) {
1508     save << " " << "__EDGES_PERIODICITY_BEGIN__";
1509     MESSAGE("__EDGES_PERIODICITY_BEGIN__");
1510     for (; it_edges_periodicity != _edgesPeriodicityVector.end(); ++it_edges_periodicity) {
1511       TEdgePeriodicity periodicity_i = (*it_edges_periodicity);
1512       save << " " << "__BEGIN_PERIODICITY_DESCRIPTION__";
1513       if (not periodicity_i.theFace1Entry.empty()){
1514         save << " " << "__BEGIN_FACE1__";
1515         save << " " << periodicity_i.theFace1Entry;
1516         save << " " << "__END_FACE1__";
1517       }
1518       save << " " << "__BEGIN_EDGE1__";
1519       save << " " << periodicity_i.theEdge1Entry;
1520       save << " " << "__END_EDGE1__";
1521       if (not periodicity_i.theFace2Entry.empty()){
1522         save << " " << "__BEGIN_FACE2__";
1523         save << " " << periodicity_i.theFace2Entry;
1524         save << " " << "__END_FACE2__";
1525       }
1526       save << " " << "__BEGIN_EDGE2__";
1527       save << " " << periodicity_i.theEdge2Entry;
1528       save << " " << "__END_EDGE2__";
1529       save << " " << "__BEGIN_EDGE_ORIENTATION__";
1530       save << " " << periodicity_i.edge_orientation;
1531       save << " " << "__END_EDGE_ORIENTATION__";
1532       save << " " << "__END_PERIODICITY_DESCRIPTION__";
1533     }
1534     save << " " << "__EDGES_PERIODICITY_END__";
1535     MESSAGE("__EDGES_PERIODICITY_END__");
1536   }
1537 }
1538
1539 void BLSURFPlugin_Hypothesis::SaveVerticesPeriodicity(std::ostream & save){
1540
1541   TVerticesPeriodicityVector::const_iterator it_vertices_periodicity = _verticesPeriodicityVector.begin();
1542   if (it_vertices_periodicity != _verticesPeriodicityVector.end()) {
1543     MESSAGE("__VERTICES_PERIODICITY_BEGIN__");
1544     save << " " << "__VERTICES_PERIODICITY_BEGIN__";
1545     for (; it_vertices_periodicity != _verticesPeriodicityVector.end(); ++it_vertices_periodicity) {
1546       TVertexPeriodicity periodicity_i = (*it_vertices_periodicity);
1547       save << " " << "__BEGIN_PERIODICITY_DESCRIPTION__";
1548       save << " " << "__BEGIN_EDGE1__";
1549       save << " " << periodicity_i.theEdge1Entry;
1550       save << " " << "__END_EDGE1__";
1551       save << " " << "__BEGIN_VERTEX1__";
1552       save << " " << periodicity_i.theVertex1Entry;
1553       save << " " << "__END_VERTEX1__";
1554       save << " " << "__BEGIN_EDGE2__";
1555       save << " " << periodicity_i.theEdge2Entry;
1556       save << " " << "__END_EDGE2__";
1557       save << " " << "__BEGIN_VERTEX2__";
1558       save << " " << periodicity_i.theVertex2Entry;
1559       save << " " << "__END_VERTEX2__";
1560       save << " " << "__END_PERIODICITY_DESCRIPTION__";
1561     }
1562     save << " " << "__VERTICES_PERIODICITY_END__";
1563     MESSAGE("__VERTICES_PERIODICITY_END__");
1564   }
1565 }
1566
1567 void BLSURFPlugin_Hypothesis::SavePreCADPeriodicity(std::ostream & save, const char* shapeType) {
1568   TPreCadPeriodicityVector precad_periodicity;
1569   if (shapeType == "FACES")
1570     precad_periodicity = _preCadFacesPeriodicityVector;
1571   else
1572     precad_periodicity = _preCadEdgesPeriodicityVector;
1573   TPreCadPeriodicityVector::const_iterator it_precad_periodicity = precad_periodicity.begin();
1574   if (it_precad_periodicity != precad_periodicity.end()) {
1575     save << " " << "__PRECAD_" << shapeType << "_PERIODICITY_BEGIN__";
1576     for (; it_precad_periodicity != precad_periodicity.end(); ++it_precad_periodicity) {
1577       TPreCadPeriodicity periodicity_i = (*it_precad_periodicity);
1578       save << " " << "__BEGIN_PERIODICITY_DESCRIPTION__";
1579       if (!periodicity_i.shape1Entry.empty()) {
1580         save << " " << "__BEGIN_ENTRY1__";
1581         save << " " << periodicity_i.shape1Entry;
1582         save << " " << "__END_ENTRY1__";
1583       }
1584       if (!periodicity_i.shape2Entry.empty()) {
1585         save << " " << "__BEGIN_ENTRY2__";
1586         save << " " << periodicity_i.shape2Entry;
1587         save << " " << "__END_ENTRY2__";
1588       }
1589
1590       std::vector<std::string>::const_iterator sourceVerticesEntriesIt = periodicity_i.theSourceVerticesEntries.begin();
1591       bool hasSourceVertices = false;
1592       if (sourceVerticesEntriesIt != periodicity_i.theSourceVerticesEntries.end()) {
1593         hasSourceVertices = true;
1594         save << " " << "__BEGIN_SOURCE_VERTICES_LIST__";
1595       }
1596       for (; sourceVerticesEntriesIt != periodicity_i.theSourceVerticesEntries.end(); ++sourceVerticesEntriesIt)
1597         save << " " << (*sourceVerticesEntriesIt);
1598       if (hasSourceVertices)
1599         save << " " << "__END_SOURCE_VERTICES_LIST__";
1600
1601       std::vector<std::string>::const_iterator targetVerticesEntriesIt = periodicity_i.theTargetVerticesEntries.begin();
1602       bool hasTargetVertices = false;
1603       if (targetVerticesEntriesIt != periodicity_i.theTargetVerticesEntries.end()) {
1604         hasTargetVertices = true;
1605         save << " " << "__BEGIN_TARGET_VERTICES_LIST__";
1606       }
1607       for (; targetVerticesEntriesIt != periodicity_i.theTargetVerticesEntries.end(); ++targetVerticesEntriesIt)
1608         save << " " << (*targetVerticesEntriesIt);
1609       if (hasTargetVertices)
1610         save << " " << "__END_TARGET_VERTICES_LIST__";
1611
1612       save << " " << "__END_PERIODICITY_DESCRIPTION__";
1613     }
1614     save << " " << "__PRECAD_" << shapeType << "_PERIODICITY_END__";
1615   }
1616
1617 }
1618
1619 //=============================================================================
1620 std::istream & BLSURFPlugin_Hypothesis::LoadFrom(std::istream & load) {
1621   bool isOK = true;
1622   int i;
1623   double val;
1624   std::string option_or_sm;
1625
1626   isOK = (load >> i);
1627   if (isOK)
1628     _topology = (Topology) i;
1629   else
1630     load.clear(std::ios::badbit | load.rdstate());
1631
1632   isOK = (load >> i);
1633   if (isOK)
1634     _physicalMesh = (PhysicalMesh) i;
1635   else
1636     load.clear(std::ios::badbit | load.rdstate());
1637
1638   isOK = (load >> i);
1639   if (isOK)
1640     _geometricMesh = (GeometricMesh) i;
1641   else
1642     load.clear(std::ios::badbit | load.rdstate());
1643
1644   isOK = (load >> val);
1645   if (isOK)
1646     _phySize = val;
1647   else
1648     load.clear(std::ios::badbit | load.rdstate());
1649
1650   isOK = (load >> val);
1651   if (isOK)
1652     _angleMesh = val;
1653   else
1654     load.clear(std::ios::badbit | load.rdstate());
1655
1656   isOK = (load >> val);
1657   if (isOK)
1658     _gradation = val;
1659   else
1660     load.clear(std::ios::badbit | load.rdstate());
1661
1662   isOK = (load >> i);
1663   if (isOK)
1664     _quadAllowed = (bool) i;
1665   else
1666     load.clear(std::ios::badbit | load.rdstate());
1667
1668   isOK = (load >> i);
1669   if (isOK) {
1670     if ( i != -1) { // if value is -1, then this is no longer a standard option
1671       std::string & value = _option2value["respect_geometry"];
1672       bool _decimesh = (bool) i;
1673       value = _decimesh ? "1" : "0";
1674     }
1675   }
1676   else
1677     load.clear(std::ios::badbit | load.rdstate());
1678
1679   isOK = (load >> val);
1680   if (isOK)
1681     _minSize = val;
1682   else
1683     load.clear(std::ios::badbit | load.rdstate());
1684
1685   isOK = (load >> val);
1686   if (isOK)
1687     _maxSize = val;
1688   else
1689     load.clear(std::ios::badbit | load.rdstate());
1690
1691   isOK = (load >> val);
1692   if (isOK)
1693     // former parameter: get min value
1694     _angleMesh = min(val,_angleMesh);
1695   else
1696     load.clear(std::ios::badbit | load.rdstate());
1697
1698   isOK = (load >> val);
1699   if (isOK)
1700     // former parameter: get min value
1701     _minSize = min(val,_minSize);
1702   else
1703     load.clear(std::ios::badbit | load.rdstate());
1704
1705   isOK = (load >> val);
1706   if (isOK)
1707     // former parameter: get max value
1708     _maxSize = max(val,_maxSize);
1709   else
1710     load.clear(std::ios::badbit | load.rdstate());
1711
1712   isOK = (load >> i);
1713   if (isOK)
1714     _verb = i;
1715   else
1716     load.clear(std::ios::badbit | load.rdstate());
1717
1718   isOK = (load >> i);
1719   if (isOK)
1720     _preCADMergeEdges = (bool) i;
1721   else
1722     load.clear(std::ios::badbit | load.rdstate());
1723
1724   isOK = (load >> i);
1725   if (isOK) {
1726     if ( i != -1) { // if value is -1, then this is no longer a standard option
1727       std::string & value = _preCADoption2value["remove_tiny_edges"];
1728       bool _preCADRemoveNanoEdges = (bool) i;
1729       value = _preCADRemoveNanoEdges ? "1" : "0";
1730     }
1731   }
1732   else
1733     load.clear(std::ios::badbit | load.rdstate());
1734
1735   isOK = (load >> i);
1736   if (isOK)
1737     _preCADDiscardInput = (bool) i;
1738   else
1739     load.clear(std::ios::badbit | load.rdstate());
1740
1741   isOK = (load >> val);
1742   if (isOK) { // _preCADEpsNano
1743     if ( (i + 1.0) < 1e-6 ) { // if value is -1, then this is no longer a standard option: get optional value "tiny_edge_length" instead
1744       std::string & value = _preCADoption2value["tiny_edge_length"];
1745       std::ostringstream oss;
1746       oss << i;
1747       value = oss.str();
1748     }
1749   }
1750   else
1751     load.clear(std::ios::badbit | load.rdstate());
1752
1753   isOK = (load >> i);
1754   if (isOK)
1755     _enforcedInternalVerticesAllFaces = (bool) i;
1756   else
1757     load.clear(std::ios::badbit | load.rdstate());
1758
1759   // New options with MeshGems-CADSurf
1760
1761   bool hasCADSurfOptions = false;
1762   bool hasOptions = false;
1763   bool hasPreCADOptions = false;
1764   bool hasSizeMap = false;
1765   bool hasAttractor = false;
1766   bool hasNewAttractor = false;
1767   bool hasEnforcedVertex = false;
1768   bool hasPreCADFacesPeriodicity = false;
1769   bool hasPreCADEdgesPeriodicity = false;
1770   bool hasFacesPeriodicity = false;
1771   bool hasEdgesPeriodicity = false;
1772   bool hasVerticesPeriodicity = false;
1773
1774   isOK = (load >> option_or_sm);
1775   if (isOK)
1776     if ( (option_or_sm == "1")||(option_or_sm == "0") ) {
1777       i = atoi(option_or_sm.c_str());
1778       hasCADSurfOptions = true;
1779       _phySizeRel = (bool) i;
1780     }
1781     if (option_or_sm == "__OPTIONS_BEGIN__")
1782       hasOptions = true;
1783     else if (option_or_sm == "__PRECAD_OPTIONS_BEGIN__")
1784       hasPreCADOptions = true;
1785     else if (option_or_sm == "__SIZEMAP_BEGIN__")
1786       hasSizeMap = true;
1787     else if (option_or_sm == "__ATTRACTORS_BEGIN__")
1788       hasAttractor = true;
1789     else if (option_or_sm == "__NEW_ATTRACTORS_BEGIN__")
1790       hasNewAttractor = true;
1791     else if (option_or_sm == "__ENFORCED_VERTICES_BEGIN__")
1792       hasEnforcedVertex = true;
1793     else if (option_or_sm == "__PRECAD_FACES_PERIODICITY_BEGIN__")
1794       hasPreCADFacesPeriodicity = true;
1795     else if (option_or_sm == "__PRECAD_EDGES_PERIODICITY_BEGIN__")
1796       hasPreCADEdgesPeriodicity = true;
1797     else if (option_or_sm == "__FACES_PERIODICITY_BEGIN__")
1798       hasFacesPeriodicity = true;
1799     else if (option_or_sm == "__EDGES_PERIODICITY_BEGIN__")
1800       hasEdgesPeriodicity = true;
1801     else if (option_or_sm == "__VERTICES_PERIODICITY_BEGIN__")
1802       hasVerticesPeriodicity = true;
1803
1804   if (isOK && hasCADSurfOptions) {
1805     isOK = (load >> i);
1806     if (isOK)
1807       _minSizeRel = (bool) i;
1808     else
1809       load.clear(std::ios::badbit | load.rdstate());
1810
1811     isOK = (load >> i);
1812     if (isOK)
1813       _maxSizeRel = (bool) i;
1814     else
1815       load.clear(std::ios::badbit | load.rdstate());
1816
1817     isOK = (load >> val);
1818     if (isOK)
1819       _chordalError = val;
1820     else
1821       load.clear(std::ios::badbit | load.rdstate());
1822
1823     isOK = (load >> i);
1824     if (isOK)
1825       _anisotropic = (bool) i;
1826     else
1827       load.clear(std::ios::badbit | load.rdstate());
1828
1829     isOK = (load >> val);
1830     if (isOK)
1831       _anisotropicRatio = val;
1832     else
1833       load.clear(std::ios::badbit | load.rdstate());
1834
1835     isOK = (load >> i);
1836     if (isOK)
1837       _removeTinyEdges = (bool) i;
1838     else
1839       load.clear(std::ios::badbit | load.rdstate());
1840
1841     isOK = (load >> val);
1842     if (isOK)
1843       _tinyEdgeLength = val;
1844     else
1845       load.clear(std::ios::badbit | load.rdstate());
1846
1847     isOK = (load >> i);
1848     if (isOK)
1849       _badElementRemoval = (bool) i;
1850     else
1851       load.clear(std::ios::badbit | load.rdstate());
1852
1853     isOK = (load >> val);
1854     if (isOK)
1855       _badElementAspectRatio = val;
1856     else
1857       load.clear(std::ios::badbit | load.rdstate());
1858
1859     isOK = (load >> i);
1860     if (isOK)
1861       _optimizeMesh = (bool) i;
1862     else
1863       load.clear(std::ios::badbit | load.rdstate());
1864
1865     isOK = (load >> i);
1866     if (isOK)
1867       _quadraticMesh = (bool) i;
1868     else
1869       load.clear(std::ios::badbit | load.rdstate());
1870
1871     isOK = (load >> i);
1872     if (isOK)
1873       _preCADProcess3DTopology = (bool) i;
1874     else
1875       load.clear(std::ios::badbit | load.rdstate());
1876
1877   }
1878   
1879
1880   if (hasCADSurfOptions) {
1881     isOK = (load >> option_or_sm);
1882     if (isOK)
1883       if (option_or_sm == "__OPTIONS_BEGIN__")
1884         hasOptions = true;
1885       else if (option_or_sm == "__PRECAD_OPTIONS_BEGIN__")
1886         hasPreCADOptions = true;
1887       else if (option_or_sm == "__SIZEMAP_BEGIN__")
1888         hasSizeMap = true;
1889       else if (option_or_sm == "__ATTRACTORS_BEGIN__")
1890         hasAttractor = true;
1891       else if (option_or_sm == "__NEW_ATTRACTORS_BEGIN__")
1892         hasNewAttractor = true;
1893       else if (option_or_sm == "__ENFORCED_VERTICES_BEGIN__")
1894         hasEnforcedVertex = true;
1895       else if (option_or_sm == "__PRECAD_FACES_PERIODICITY_BEGIN__")
1896         hasPreCADFacesPeriodicity = true;
1897       else if (option_or_sm == "__PRECAD_EDGES_PERIODICITY_BEGIN__")
1898         hasPreCADEdgesPeriodicity = true;
1899       else if (option_or_sm == "__FACES_PERIODICITY_BEGIN__")
1900         hasFacesPeriodicity = true;
1901       else if (option_or_sm == "__EDGES_PERIODICITY_BEGIN__")
1902         hasEdgesPeriodicity = true;
1903       else if (option_or_sm == "__VERTICES_PERIODICITY_BEGIN__")
1904         hasVerticesPeriodicity = true;
1905   }
1906   
1907   std::string optName, optValue;
1908   while (isOK && hasOptions) {
1909     isOK = (load >> optName);
1910     if (isOK) {
1911       if (optName == "__OPTIONS_END__")
1912         break;
1913       isOK = (load >> optValue);
1914     }
1915     if (isOK) {
1916       std::string & value = _option2value[optName];
1917       value = optValue;
1918       int len = value.size();
1919       // continue reading until "%#" encountered
1920       while (value[len - 1] != '#' || value[len - 2] != '%') {
1921         isOK = (load >> optValue);
1922         if (isOK) {
1923           value += " ";
1924           value += optValue;
1925           len = value.size();
1926         } else {
1927           break;
1928         }
1929       }
1930       value[len - 2] = '\0'; //cut off "%#"
1931     }
1932   }
1933
1934   if (hasOptions) {
1935     isOK = (load >> option_or_sm);
1936     if (isOK)
1937       if (option_or_sm == "__PRECAD_OPTIONS_BEGIN__")
1938         hasPreCADOptions = true;
1939       else if (option_or_sm == "__SIZEMAP_BEGIN__")
1940         hasSizeMap = true;
1941       else if (option_or_sm == "__ATTRACTORS_BEGIN__")
1942         hasAttractor = true;
1943       else if (option_or_sm == "__NEW_ATTRACTORS_BEGIN__")
1944         hasNewAttractor = true;
1945       else if (option_or_sm == "__ENFORCED_VERTICES_BEGIN__")
1946         hasEnforcedVertex = true;
1947       else if (option_or_sm == "__PRECAD_FACES_PERIODICITY_BEGIN__")
1948         hasPreCADFacesPeriodicity = true;
1949       else if (option_or_sm == "__PRECAD_EDGES_PERIODICITY_BEGIN__")
1950         hasPreCADEdgesPeriodicity = true;
1951       else if (option_or_sm == "__FACES_PERIODICITY_BEGIN__")
1952         hasFacesPeriodicity = true;
1953       else if (option_or_sm == "__EDGES_PERIODICITY_BEGIN__")
1954         hasEdgesPeriodicity = true;
1955       else if (option_or_sm == "__VERTICES_PERIODICITY_BEGIN__")
1956         hasVerticesPeriodicity = true;
1957   }
1958
1959   while (isOK && hasPreCADOptions) {
1960     isOK = (load >> optName);
1961     if (isOK) {
1962       if (optName == "__PRECAD_OPTIONS_END__")
1963         break;
1964       isOK = (load >> optValue);
1965     }
1966     if (isOK) {
1967       std::string & value = _preCADoption2value[optName];
1968       value = optValue;
1969       int len = value.size();
1970       // continue reading until "%#" encountered
1971       while (value[len - 1] != '#' || value[len - 2] != '%') {
1972         isOK = (load >> optValue);
1973         if (isOK) {
1974           value += " ";
1975           value += optValue;
1976           len = value.size();
1977         } else {
1978           break;
1979         }
1980       }
1981       value[len - 2] = '\0'; //cut off "%#"
1982     }
1983   }
1984
1985   if (hasPreCADOptions) {
1986     isOK = (load >> option_or_sm);
1987     if (isOK)
1988       if (option_or_sm == "__SIZEMAP_BEGIN__")
1989         hasSizeMap = true;
1990       else if (option_or_sm == "__ATTRACTORS_BEGIN__")
1991         hasAttractor = true;
1992       else if (option_or_sm == "__NEW_ATTRACTORS_BEGIN__")
1993         hasNewAttractor = true;
1994       else if (option_or_sm == "__ENFORCED_VERTICES_BEGIN__")
1995         hasEnforcedVertex = true;
1996       else if (option_or_sm == "__PRECAD_FACES_PERIODICITY_BEGIN__")
1997         hasPreCADFacesPeriodicity = true;
1998       else if (option_or_sm == "__PRECAD_EDGES_PERIODICITY_BEGIN__")
1999         hasPreCADEdgesPeriodicity = true;
2000       else if (option_or_sm == "__FACES_PERIODICITY_BEGIN__")
2001         hasFacesPeriodicity = true;
2002       else if (option_or_sm == "__EDGES_PERIODICITY_BEGIN__")
2003         hasEdgesPeriodicity = true;
2004       else if (option_or_sm == "__VERTICES_PERIODICITY_BEGIN__")
2005         hasVerticesPeriodicity = true;
2006   }
2007   
2008   std::string smEntry, smValue;
2009   while (isOK && hasSizeMap) {
2010     isOK = (load >> smEntry);
2011     if (isOK) {
2012       if (smEntry == "__SIZEMAP_END__")
2013         break;
2014       isOK = (load >> smValue);
2015     }
2016     if (isOK) {
2017       std::string & value2 = _sizeMap[smEntry];
2018       value2 = smValue;
2019       int len2 = value2.size();
2020       // continue reading until "%#" encountered
2021       while (value2[len2 - 1] != '#' || value2[len2 - 2] != '%') {
2022         isOK = (load >> smValue);
2023         if (isOK) {
2024           value2 += " ";
2025           value2 += smValue;
2026           len2 = value2.size();
2027         } else {
2028           break;
2029         }
2030       }
2031       value2[len2 - 2] = '\0'; //cut off "%#"
2032     }
2033   }
2034
2035   if (hasSizeMap) {
2036     isOK = (load >> option_or_sm);
2037     if (isOK)
2038       if (option_or_sm == "__ATTRACTORS_BEGIN__")
2039         hasAttractor = true;
2040       if (option_or_sm == "__NEW_ATTRACTORS_BEGIN__")
2041         hasNewAttractor = true;
2042       else if (option_or_sm == "__ENFORCED_VERTICES_BEGIN__")
2043         hasEnforcedVertex = true;
2044       else if (option_or_sm == "__PRECAD_FACES_PERIODICITY_BEGIN__")
2045         hasPreCADFacesPeriodicity = true;
2046       else if (option_or_sm == "__PRECAD_EDGES_PERIODICITY_BEGIN__")
2047         hasPreCADEdgesPeriodicity = true;
2048       else if (option_or_sm == "__FACES_PERIODICITY_BEGIN__")
2049         hasFacesPeriodicity = true;
2050       else if (option_or_sm == "__EDGES_PERIODICITY_BEGIN__")
2051         hasEdgesPeriodicity = true;
2052       else if (option_or_sm == "__VERTICES_PERIODICITY_BEGIN__")
2053         hasVerticesPeriodicity = true;
2054   }
2055
2056   std::string atEntry, atValue;
2057   while (isOK && hasAttractor) {
2058     isOK = (load >> atEntry);
2059     if (isOK) {
2060       if (atEntry == "__ATTRACTORS_END__")
2061         break;
2062       isOK = (load >> atValue);
2063     }
2064     if (isOK) {
2065       std::string & value3 = _attractors[atEntry];
2066       value3 = atValue;
2067       int len3 = value3.size();
2068       // continue reading until "%#" encountered
2069       while (value3[len3 - 1] != '#' || value3[len3 - 2] != '%') {
2070         isOK = (load >> atValue);
2071         if (isOK) {
2072           value3 += " ";
2073           value3 += atValue;
2074           len3 = value3.size();
2075         } else {
2076           break;
2077         }
2078       }
2079       value3[len3 - 2] = '\0'; //cut off "%#"
2080     }
2081   }
2082
2083   if (hasAttractor) {
2084     isOK = (load >> option_or_sm);
2085     if (isOK)
2086       if (option_or_sm == "__NEW_ATTRACTORS_BEGIN__")
2087         hasNewAttractor = true;
2088       else if (option_or_sm == "__ENFORCED_VERTICES_BEGIN__")
2089         hasEnforcedVertex = true;
2090       else if (option_or_sm == "__PRECAD_FACES_PERIODICITY_BEGIN__")
2091         hasPreCADFacesPeriodicity = true;
2092       else if (option_or_sm == "__PRECAD_EDGES_PERIODICITY_BEGIN__")
2093         hasPreCADEdgesPeriodicity = true;
2094       else if (option_or_sm == "__FACES_PERIODICITY_BEGIN__")
2095         hasFacesPeriodicity = true;
2096       else if (option_or_sm == "__EDGES_PERIODICITY_BEGIN__")
2097         hasEdgesPeriodicity = true;
2098       else if (option_or_sm == "__VERTICES_PERIODICITY_BEGIN__")
2099         hasVerticesPeriodicity = true;
2100   }
2101
2102   std::string newAtFaceEntry, atTestString;
2103   std::string newAtShapeEntry;
2104   double attParams[4];
2105   double step;
2106   while (isOK && hasNewAttractor) {
2107     std::cout<<"Load new attractor"<<std::endl;
2108     isOK = (load >> newAtFaceEntry);
2109     if (isOK) {
2110       if (newAtFaceEntry == "__NEW_ATTRACTORS_END__")
2111         break;
2112       isOK = (load >> newAtShapeEntry);
2113       if (!isOK)
2114     break;
2115       isOK = (load >> attParams[0]>>attParams[1]>>attParams[2]>>attParams[3]); //>>step);
2116     }
2117     if (isOK) {
2118       MESSAGE(" LOADING ATTRACTOR HYPOTHESIS ")
2119       const TopoDS_Shape attractorShape = BLSURFPlugin_Hypothesis::entryToShape(newAtShapeEntry);
2120       const TopoDS_Face faceShape = TopoDS::Face(BLSURFPlugin_Hypothesis::entryToShape(newAtFaceEntry));
2121       BLSURFPlugin_Attractor* attractor = new BLSURFPlugin_Attractor(faceShape, attractorShape, newAtShapeEntry);//, step);
2122       attractor->SetParameters(attParams[0], attParams[1], attParams[2], attParams[3]);
2123       attractor->BuildMap();                     
2124       _classAttractors[newAtFaceEntry]=attractor;
2125     }
2126   }
2127   
2128   
2129   if (hasNewAttractor) {
2130     isOK = (load >> option_or_sm);
2131     if (isOK)
2132       if (option_or_sm == "__ENFORCED_VERTICES_BEGIN__")
2133         hasEnforcedVertex = true;
2134       else if (option_or_sm == "__PRECAD_FACES_PERIODICITY_BEGIN__")
2135         hasPreCADFacesPeriodicity = true;
2136       else if (option_or_sm == "__PRECAD_EDGES_PERIODICITY_BEGIN__")
2137         hasPreCADEdgesPeriodicity = true;
2138       else if (option_or_sm == "__FACES_PERIODICITY_BEGIN__")
2139         hasFacesPeriodicity = true;
2140       else if (option_or_sm == "__EDGES_PERIODICITY_BEGIN__")
2141         hasEdgesPeriodicity = true;
2142       else if (option_or_sm == "__VERTICES_PERIODICITY_BEGIN__")
2143         hasVerticesPeriodicity = true;
2144   }
2145
2146
2147 // 
2148 // Here is a example of the saved stream:
2149 // __ENFORCED_VERTICES_BEGIN__ 
2150 // __BEGIN_VERTEX__  => no name, no entry
2151 // __BEGIN_GROUP__ mon groupe __END_GROUP__
2152 // __BEGIN_COORDS__ 10 10 10 __END_COORDS__ 
2153 // __BEGIN_FACELIST__ 0:1:1:1:1 __END_FACELIST__ 
2154 // __END_VERTEX__ 
2155 // __BEGIN_VERTEX__ => no coords
2156 // __BEGIN_NAME__ mes points __END_NAME__ 
2157 // __BEGIN_ENTRY__ 0:1:1:4 __END_ENTRY__
2158 // __BEGIN_GROUP__ mon groupe __END_GROUP__
2159 // __BEGIN_FACELIST__ 0:1:1:1:3 __END_FACELIST__
2160 // __END_VERTEX__ 
2161 // __ENFORCED_VERTICES_END__
2162 // 
2163
2164   std::string enfSeparator;
2165   std::string enfName;
2166   std::string enfGeomEntry;
2167   std::string enfGroup;
2168   TEntryList enfFaceEntryList;
2169   double enfCoords[3];
2170   bool hasCoords = false;
2171   
2172   _faceEntryEnfVertexListMap.clear();
2173   _enfVertexList.clear();
2174   _faceEntryCoordsListMap.clear();
2175   _coordsEnfVertexMap.clear();
2176   _faceEntryEnfVertexEntryListMap.clear();
2177   _enfVertexEntryEnfVertexMap.clear();
2178   
2179   
2180   while (isOK && hasEnforcedVertex) {
2181     isOK = (load >> enfSeparator); // __BEGIN_VERTEX__
2182     TEnfVertex *enfVertex = new TEnfVertex();
2183 //     MESSAGE("enfSeparator: " <<enfSeparator);
2184     if (enfSeparator == "__ENFORCED_VERTICES_END__")
2185       break; // __ENFORCED_VERTICES_END__
2186     if (enfSeparator != "__BEGIN_VERTEX__")
2187       throw std::exception();
2188     
2189     while (isOK) {
2190       isOK = (load >> enfSeparator);
2191       MESSAGE("enfSeparator: " <<enfSeparator);
2192       if (enfSeparator == "__END_VERTEX__") {
2193         
2194         enfVertex->name = enfName;
2195         enfVertex->geomEntry = enfGeomEntry;
2196         enfVertex->grpName = enfGroup;
2197         enfVertex->coords.clear();
2198         if (hasCoords)
2199           enfVertex->coords.assign(enfCoords,enfCoords+3);
2200         enfVertex->faceEntries = enfFaceEntryList;
2201         
2202         _enfVertexList.insert(enfVertex);
2203         
2204         if (enfVertex->coords.size()) {
2205           _coordsEnfVertexMap[enfVertex->coords] = enfVertex;
2206           for (TEntryList::const_iterator it = enfVertex->faceEntries.begin() ; it != enfVertex->faceEntries.end(); ++it) {
2207             _faceEntryCoordsListMap[(*it)].insert(enfVertex->coords);
2208             _faceEntryEnfVertexListMap[(*it)].insert(enfVertex);
2209           }
2210         }
2211         if (!enfVertex->geomEntry.empty()) {
2212           _enfVertexEntryEnfVertexMap[enfVertex->geomEntry] = enfVertex;
2213           for (TEntryList::const_iterator it = enfVertex->faceEntries.begin() ; it != enfVertex->faceEntries.end(); ++it) {
2214             _faceEntryEnfVertexEntryListMap[(*it)].insert(enfVertex->geomEntry);
2215             _faceEntryEnfVertexListMap[(*it)].insert(enfVertex);
2216           }
2217         }
2218         
2219         enfName.clear();
2220         enfGeomEntry.clear();
2221         enfGroup.clear();
2222         enfFaceEntryList.clear();
2223         hasCoords = false;
2224         break; // __END_VERTEX__
2225       }
2226         
2227       if (enfSeparator == "__BEGIN_NAME__") {  // __BEGIN_NAME__
2228         while (isOK && (enfSeparator != "__END_NAME__")) {
2229           isOK = (load >> enfSeparator);
2230           if (enfSeparator != "__END_NAME__") {
2231             if (!enfName.empty())
2232               enfName += " ";
2233             enfName += enfSeparator;
2234           }
2235         }
2236         MESSAGE("enfName: " <<enfName);
2237       }
2238         
2239       if (enfSeparator == "__BEGIN_ENTRY__") {  // __BEGIN_ENTRY__
2240         isOK = (load >> enfGeomEntry);
2241         isOK = (load >> enfSeparator); // __END_ENTRY__
2242         if (enfSeparator != "__END_ENTRY__")
2243           throw std::exception();
2244         MESSAGE("enfGeomEntry: " <<enfGeomEntry);
2245       }
2246         
2247       if (enfSeparator == "__BEGIN_GROUP__") {  // __BEGIN_GROUP__
2248         while (isOK && (enfSeparator != "__END_GROUP__")) {
2249           isOK = (load >> enfSeparator);
2250           if (enfSeparator != "__END_GROUP__") {
2251             if (!enfGroup.empty())
2252               enfGroup += " ";
2253             enfGroup += enfSeparator;
2254           }
2255         }
2256         MESSAGE("enfGroup: " <<enfGroup);
2257       }
2258         
2259       if (enfSeparator == "__BEGIN_COORDS__") {  // __BEGIN_COORDS__
2260         hasCoords = true;
2261         isOK = (load >> enfCoords[0] >> enfCoords[1] >> enfCoords[2]);
2262         isOK = (load >> enfSeparator); // __END_COORDS__
2263         if (enfSeparator != "__END_COORDS__")
2264           throw std::exception();
2265         MESSAGE("enfCoords: " << enfCoords[0] <<","<< enfCoords[1] <<","<< enfCoords[2]);
2266       } 
2267         
2268       if (enfSeparator == "__BEGIN_FACELIST__") {  // __BEGIN_FACELIST__
2269         while (isOK && (enfSeparator != "__END_FACELIST__")) {
2270           isOK = (load >> enfSeparator);
2271           if (enfSeparator != "__END_FACELIST__") {
2272             enfFaceEntryList.insert(enfSeparator);
2273             MESSAGE(enfSeparator << " was inserted into enfFaceEntryList");
2274           }
2275         }
2276       } 
2277     }
2278   }
2279
2280   // PERIODICITY
2281
2282   if (hasPreCADFacesPeriodicity){
2283     LoadPreCADPeriodicity(load, "FACES");
2284
2285     isOK = (load >> option_or_sm);
2286     if (isOK)
2287       if (option_or_sm == "__PRECAD_EDGES_PERIODICITY_BEGIN__")
2288         hasPreCADEdgesPeriodicity = true;
2289       else if (option_or_sm == "__FACES_PERIODICITY_BEGIN__")
2290         hasFacesPeriodicity = true;
2291       else if (option_or_sm == "__EDGES_PERIODICITY_BEGIN__")
2292         hasEdgesPeriodicity = true;
2293       else if (option_or_sm == "__VERTICES_PERIODICITY_BEGIN__")
2294         hasVerticesPeriodicity = true;
2295   }
2296
2297   if (hasPreCADEdgesPeriodicity){
2298     LoadPreCADPeriodicity(load, "EDGES");
2299
2300     isOK = (load >> option_or_sm);
2301     if (isOK)
2302       if (option_or_sm == "__FACES_PERIODICITY_BEGIN__")
2303         hasFacesPeriodicity = true;
2304       else if (option_or_sm == "__EDGES_PERIODICITY_BEGIN__")
2305         hasEdgesPeriodicity = true;
2306       else if (option_or_sm == "__VERTICES_PERIODICITY_BEGIN__")
2307         hasVerticesPeriodicity = true;
2308   }
2309
2310   if (hasFacesPeriodicity){
2311       LoadFacesPeriodicity(load);
2312
2313     isOK = (load >> option_or_sm);
2314     if (isOK)
2315       if (option_or_sm == "__EDGES_PERIODICITY_BEGIN__")
2316         hasEdgesPeriodicity = true;
2317       else if (option_or_sm == "__VERTICES_PERIODICITY_BEGIN__")
2318         hasVerticesPeriodicity = true;
2319   }
2320
2321   if (hasEdgesPeriodicity){
2322       LoadEdgesPeriodicity(load);
2323
2324     isOK = (load >> option_or_sm);
2325     if (isOK)
2326       if (option_or_sm == "__VERTICES_PERIODICITY_BEGIN__")
2327         hasVerticesPeriodicity = true;
2328   }
2329
2330   if (hasVerticesPeriodicity)
2331       LoadVerticesPeriodicity(load);
2332
2333   return load;
2334 }
2335
2336 void BLSURFPlugin_Hypothesis::LoadFacesPeriodicity(std::istream & load){
2337
2338   bool isOK = true;
2339
2340   std::string periodicitySeparator;
2341   TEntry shape1Entry;
2342   TEntry shape2Entry;
2343
2344   _facesPeriodicityVector.clear();
2345
2346   while (isOK) {
2347     isOK = (load >> periodicitySeparator); // __BEGIN_PERIODICITY_DESCRIPTION__
2348     MESSAGE("periodicitySeparator 1: " <<periodicitySeparator);
2349     TFacesPeriodicity *periodicity_i = new TFacesPeriodicity();
2350     if (periodicitySeparator == "__FACES_PERIODICITY_END__")
2351       break; // __FACES_PERIODICITY_END__
2352     if (periodicitySeparator != "__BEGIN_PERIODICITY_DESCRIPTION__"){
2353       MESSAGE("//" << periodicitySeparator << "//");
2354       throw std::exception();
2355     }
2356
2357     while (isOK) {
2358       isOK = (load >> periodicitySeparator);
2359       MESSAGE("periodicitySeparator 2: " <<periodicitySeparator);
2360       if (periodicitySeparator == "__END_PERIODICITY_DESCRIPTION__") {
2361
2362         periodicity_i->first = shape1Entry;
2363         periodicity_i->second = shape2Entry;
2364
2365         _facesPeriodicityVector.push_back(*periodicity_i);
2366
2367         break; // __END_PERIODICITY_DESCRIPTION__
2368       }
2369
2370       if (periodicitySeparator == "__BEGIN_ENTRY1__") {  // __BEGIN_ENTRY1__
2371         isOK = (load >> shape1Entry);
2372         isOK = (load >> periodicitySeparator); // __END_ENTRY1__
2373         if (periodicitySeparator != "__END_ENTRY1__")
2374           throw std::exception();
2375         MESSAGE("shape1Entry: " <<shape1Entry);
2376       }
2377
2378       if (periodicitySeparator == "__BEGIN_ENTRY2__") {  // __BEGIN_ENTRY2__
2379         isOK = (load >> shape2Entry);
2380         isOK = (load >> periodicitySeparator); // __END_ENTRY2__
2381         if (periodicitySeparator != "__END_ENTRY2__")
2382           throw std::exception();
2383         MESSAGE("shape2Entry: " <<shape2Entry);
2384       }
2385     }
2386   }
2387 }
2388
2389
2390 void BLSURFPlugin_Hypothesis::LoadEdgesPeriodicity(std::istream & load){
2391
2392   bool isOK = true;
2393
2394   std::string periodicitySeparator;
2395   TEntry theFace1Entry;
2396   TEntry theEdge1Entry;
2397   TEntry theFace2Entry;
2398   TEntry theEdge2Entry;
2399   int edge_orientation = 0;
2400
2401   _edgesPeriodicityVector.clear();
2402
2403   while (isOK) {
2404     isOK = (load >> periodicitySeparator); // __BEGIN_PERIODICITY_DESCRIPTION__
2405     MESSAGE("periodicitySeparator 1: " <<periodicitySeparator);
2406     TEdgePeriodicity *periodicity_i = new TEdgePeriodicity();
2407     if (periodicitySeparator == "__EDGES_PERIODICITY_END__")
2408       break; // __EDGES_PERIODICITY_END__
2409     if (periodicitySeparator != "__BEGIN_PERIODICITY_DESCRIPTION__"){
2410       MESSAGE("//" << periodicitySeparator << "//");
2411       throw std::exception();
2412     }
2413
2414     while (isOK) {
2415       isOK = (load >> periodicitySeparator);
2416       MESSAGE("periodicitySeparator 2: " <<periodicitySeparator);
2417       if (periodicitySeparator == "__END_PERIODICITY_DESCRIPTION__") {
2418
2419         periodicity_i->theFace1Entry = theFace1Entry;
2420         periodicity_i->theEdge1Entry = theEdge1Entry;
2421         periodicity_i->theFace2Entry = theFace2Entry;
2422         periodicity_i->theEdge2Entry = theEdge2Entry;
2423         periodicity_i->edge_orientation = edge_orientation;
2424
2425         _edgesPeriodicityVector.push_back(*periodicity_i);
2426
2427         break; // __END_PERIODICITY_DESCRIPTION__
2428       }
2429
2430       if (periodicitySeparator == "__BEGIN_FACE1__") {  // __BEGIN_FACE1__
2431         isOK = (load >> theFace1Entry);
2432         MESSAGE("//" << theFace1Entry << "//");
2433         isOK = (load >> periodicitySeparator); // __END_FACE1__
2434         if (periodicitySeparator != "__END_FACE1__"){
2435           MESSAGE("//" << periodicitySeparator << "//");
2436           throw std::exception();
2437         }
2438         MESSAGE("theFace1Entry: " <<theFace1Entry);
2439       }
2440
2441       if (periodicitySeparator == "__BEGIN_EDGE1__") {  // __BEGIN_EDGE1__
2442         isOK = (load >> theEdge1Entry);
2443         isOK = (load >> periodicitySeparator); // __END_EDGE1__
2444         if (periodicitySeparator != "__END_EDGE1__")
2445           throw std::exception();
2446         MESSAGE("theEdge1Entry: " <<theEdge1Entry);
2447       }
2448
2449       if (periodicitySeparator == "__BEGIN_FACE2__") {  // __BEGIN_FACE2__
2450         isOK = (load >> theFace2Entry);
2451         isOK = (load >> periodicitySeparator); // __END_FACE2__
2452         if (periodicitySeparator != "__END_FACE2__")
2453           throw std::exception();
2454         MESSAGE("theFace2Entry: " <<theFace2Entry);
2455       }
2456
2457       if (periodicitySeparator == "__BEGIN_EDGE2__") {  // __BEGIN_EDGE2__
2458         isOK = (load >> theEdge2Entry);
2459         isOK = (load >> periodicitySeparator); // __END_EDGE2__
2460         if (periodicitySeparator != "__END_EDGE2__")
2461           throw std::exception();
2462         MESSAGE("theEdge2Entry: " <<theEdge2Entry);
2463       }
2464
2465       if (periodicitySeparator == "__BEGIN_EDGE_ORIENTATION__") {  // __BEGIN_EDGE_ORIENTATION__
2466         isOK = (load >> edge_orientation);
2467         isOK = (load >> periodicitySeparator); // __END_EDGE_ORIENTATION__
2468         if (periodicitySeparator != "__END_EDGE_ORIENTATION__")
2469           throw std::exception();
2470         MESSAGE("edge_orientation: " <<edge_orientation);
2471       }
2472     }
2473   }
2474 }
2475
2476 void BLSURFPlugin_Hypothesis::LoadVerticesPeriodicity(std::istream & load){
2477
2478   bool isOK = true;
2479
2480   std::string periodicitySeparator;
2481   TEntry theEdge1Entry;
2482   TEntry theVertex1Entry;
2483   TEntry theEdge2Entry;
2484   TEntry theVertex2Entry;
2485
2486   _verticesPeriodicityVector.clear();
2487
2488   while (isOK) {
2489     isOK = (load >> periodicitySeparator); // __BEGIN_PERIODICITY_DESCRIPTION__
2490     MESSAGE("periodicitySeparator 1: " <<periodicitySeparator);
2491     TVertexPeriodicity *periodicity_i = new TVertexPeriodicity();
2492     if (periodicitySeparator == "__VERTICES_PERIODICITY_END__")
2493       break; // __VERTICES_PERIODICITY_END__
2494     if (periodicitySeparator != "__BEGIN_PERIODICITY_DESCRIPTION__"){
2495       MESSAGE("//" << periodicitySeparator << "//");
2496       throw std::exception();
2497     }
2498
2499     while (isOK) {
2500       isOK = (load >> periodicitySeparator);
2501       MESSAGE("periodicitySeparator 2: " <<periodicitySeparator);
2502       if (periodicitySeparator == "__END_PERIODICITY_DESCRIPTION__") {
2503
2504         periodicity_i->theEdge1Entry = theEdge1Entry;
2505         periodicity_i->theVertex1Entry = theVertex1Entry;
2506         periodicity_i->theEdge2Entry = theEdge2Entry;
2507         periodicity_i->theVertex2Entry = theVertex2Entry;
2508
2509         _verticesPeriodicityVector.push_back(*periodicity_i);
2510
2511         break; // __END_PERIODICITY_DESCRIPTION__
2512       }
2513
2514       if (periodicitySeparator == "__BEGIN_EDGE1__") {  // __BEGIN_EDGE1__
2515         isOK = (load >> theEdge1Entry);
2516         isOK = (load >> periodicitySeparator); // __END_EDGE1__
2517         if (periodicitySeparator != "__END_EDGE1__")
2518           throw std::exception();
2519         MESSAGE("theEdge1Entry: " <<theEdge1Entry);
2520       }
2521
2522       if (periodicitySeparator == "__BEGIN_VERTEX1__") {  // __BEGIN_VERTEX1__
2523         isOK = (load >> theVertex1Entry);
2524         isOK = (load >> periodicitySeparator); // __END_VERTEX1__
2525         if (periodicitySeparator != "__END_VERTEX1__")
2526           throw std::exception();
2527         MESSAGE("theVertex1Entry: " <<theVertex1Entry);
2528       }
2529
2530       if (periodicitySeparator == "__BEGIN_EDGE2__") {  // __BEGIN_EDGE2__
2531         isOK = (load >> theEdge2Entry);
2532         isOK = (load >> periodicitySeparator); // __END_EDGE2__
2533         if (periodicitySeparator != "__END_EDGE2__")
2534           throw std::exception();
2535         MESSAGE("theEdge2Entry: " <<theEdge2Entry);
2536       }
2537
2538       if (periodicitySeparator == "__BEGIN_VERTEX2__") {  // __BEGIN_VERTEX2__
2539         isOK = (load >> theVertex2Entry);
2540         isOK = (load >> periodicitySeparator); // __END_VERTEX2__
2541         if (periodicitySeparator != "__END_VERTEX2__")
2542           throw std::exception();
2543         MESSAGE("theVertex2Entry: " <<theVertex2Entry);
2544       }
2545     }
2546   }
2547 }
2548
2549 void BLSURFPlugin_Hypothesis::LoadPreCADPeriodicity(std::istream & load, const char* shapeType) {
2550
2551   bool isOK = true;
2552
2553   std::string periodicitySeparator;
2554   TEntry shape1Entry;
2555   TEntry shape2Entry;
2556   std::vector<std::string> theSourceVerticesEntries;
2557   std::vector<std::string> theTargetVerticesEntries;
2558
2559   bool hasSourceVertices = false;
2560   bool hasTargetVertices = false;
2561
2562   if (shapeType == "FACES")
2563     _preCadFacesPeriodicityVector.clear();
2564   else
2565     _preCadEdgesPeriodicityVector.clear();
2566
2567
2568   while (isOK) {
2569     isOK = (load >> periodicitySeparator); // __BEGIN_PERIODICITY_DESCRIPTION__
2570     MESSAGE("periodicitySeparator 1: " <<periodicitySeparator);
2571     TPreCadPeriodicity *periodicity_i = new TPreCadPeriodicity();
2572 //     MESSAGE("periodicitySeparator: " <<periodicitySeparator);
2573     std::string endSeparator = "__PRECAD_" + std::string(shapeType) + "_PERIODICITY_END__";
2574     if (periodicitySeparator == endSeparator)
2575       break; // __PRECAD_FACES_PERIODICITY_END__
2576     if (periodicitySeparator != "__BEGIN_PERIODICITY_DESCRIPTION__"){
2577       MESSAGE("//" << endSeparator << "//");
2578       MESSAGE("//" << periodicitySeparator << "//");
2579       throw std::exception();
2580     }
2581
2582     while (isOK) {
2583       isOK = (load >> periodicitySeparator);
2584       MESSAGE("periodicitySeparator 2: " <<periodicitySeparator);
2585       if (periodicitySeparator == "__END_PERIODICITY_DESCRIPTION__") {
2586
2587         periodicity_i->shape1Entry = shape1Entry;
2588         periodicity_i->shape2Entry = shape2Entry;
2589
2590         MESSAGE("theSourceVerticesEntries.size(): " << theSourceVerticesEntries.size());
2591         MESSAGE("theTargetVerticesEntries.size(): " << theTargetVerticesEntries.size());
2592
2593         if (hasSourceVertices)
2594           periodicity_i->theSourceVerticesEntries = theSourceVerticesEntries;
2595         if (hasTargetVertices)
2596           periodicity_i->theTargetVerticesEntries = theTargetVerticesEntries;
2597
2598         if (shapeType == "FACES")
2599           _preCadFacesPeriodicityVector.push_back(*periodicity_i);
2600         else
2601           _preCadEdgesPeriodicityVector.push_back(*periodicity_i);
2602
2603         theSourceVerticesEntries.clear();
2604         theTargetVerticesEntries.clear();
2605         hasSourceVertices = false;
2606         hasTargetVertices = false;
2607         break; // __END_PERIODICITY_DESCRIPTION__
2608       }
2609
2610       if (periodicitySeparator == "__BEGIN_ENTRY1__") {  // __BEGIN_ENTRY1__
2611         isOK = (load >> shape1Entry);
2612         isOK = (load >> periodicitySeparator); // __END_ENTRY1__
2613         if (periodicitySeparator != "__END_ENTRY1__")
2614           throw std::exception();
2615         MESSAGE("shape1Entry: " <<shape1Entry);
2616       }
2617
2618       if (periodicitySeparator == "__BEGIN_ENTRY2__") {  // __BEGIN_ENTRY2__
2619         isOK = (load >> shape2Entry);
2620         isOK = (load >> periodicitySeparator); // __END_ENTRY2__
2621         if (periodicitySeparator != "__END_ENTRY2__")
2622           throw std::exception();
2623         MESSAGE("shape2Entry: " <<shape2Entry);
2624       }
2625
2626       if (periodicitySeparator == "__BEGIN_SOURCE_VERTICES_LIST__") {  // __BEGIN_SOURCE_VERTICES_LIST__
2627         hasSourceVertices = true;
2628         while (isOK && (periodicitySeparator != "__END_SOURCE_VERTICES_LIST__")) {
2629           isOK = (load >> periodicitySeparator);
2630           if (periodicitySeparator != "__END_SOURCE_VERTICES_LIST__") {
2631             theSourceVerticesEntries.push_back(periodicitySeparator);
2632             MESSAGE("theSourceVerticesEntries: " <<periodicitySeparator);
2633           }
2634         }
2635       }
2636
2637       if (periodicitySeparator == "__BEGIN_TARGET_VERTICES_LIST__") {  // __BEGIN_TARGET_VERTICES_LIST__
2638         hasTargetVertices = true;
2639         while (isOK && (periodicitySeparator != "__END_TARGET_VERTICES_LIST__")) {
2640           isOK = (load >> periodicitySeparator);
2641           if (periodicitySeparator != "__END_TARGET_VERTICES_LIST__") {
2642             theTargetVerticesEntries.push_back(periodicitySeparator);
2643             MESSAGE("theTargetVerticesEntries: " <<periodicitySeparator);
2644           }
2645         }
2646       }
2647     }
2648   }
2649 }
2650
2651 //=============================================================================
2652 std::ostream & operator <<(std::ostream & save, BLSURFPlugin_Hypothesis & hyp) {
2653   return hyp.SaveTo(save);
2654 }
2655
2656 //=============================================================================
2657 std::istream & operator >>(std::istream & load, BLSURFPlugin_Hypothesis & hyp) {
2658   return hyp.LoadFrom(load);
2659 }
2660
2661 //================================================================================
2662 /*!
2663  * \brief Does nothing
2664  */
2665 //================================================================================
2666
2667 bool BLSURFPlugin_Hypothesis::SetParametersByMesh(const SMESH_Mesh* theMesh, const TopoDS_Shape& theShape) {
2668   return false;
2669 }
2670
2671 //================================================================================
2672 /*!
2673  * \brief Returns default global constant physical size given a default value of element length ratio
2674  */
2675 //================================================================================
2676
2677 double BLSURFPlugin_Hypothesis::GetDefaultPhySize(double diagonal, double bbSegmentation) {
2678   if (bbSegmentation != 0 && diagonal != 0)
2679     return diagonal / bbSegmentation ;
2680   return 10;
2681 }
2682
2683 //================================================================================
2684 /*!
2685  * \brief Returns default min size given a default value of element length ratio
2686  */
2687 //================================================================================
2688
2689 double BLSURFPlugin_Hypothesis::GetDefaultMinSize(double diagonal) {
2690   if (diagonal != 0)
2691     return diagonal / 1000.0 ;
2692   return undefinedDouble();
2693 }
2694
2695 //================================================================================
2696 /*!
2697  * \brief Returns default max size given a default value of element length ratio
2698  */
2699 //================================================================================
2700
2701 double BLSURFPlugin_Hypothesis::GetDefaultMaxSize(double diagonal) {
2702   if (diagonal != 0)
2703     return diagonal / 5.0 ;
2704   return undefinedDouble();
2705 }
2706
2707 //================================================================================
2708 /*!
2709  * \brief Returns default chordal error given a default value of element length ratio
2710  */
2711 //================================================================================
2712
2713 double BLSURFPlugin_Hypothesis::GetDefaultChordalError(double diagonal) {
2714   if (diagonal != 0)
2715     return diagonal;
2716   return undefinedDouble();
2717 }
2718
2719 //================================================================================
2720 /*!
2721  * \brief Returns default tiny edge length given a default value of element length ratio
2722  */
2723 //================================================================================
2724
2725 double BLSURFPlugin_Hypothesis::GetDefaultTinyEdgeLength(double diagonal) {
2726   if (diagonal != 0)
2727     return diagonal * 1e-6 ;
2728   return undefinedDouble();
2729 }
2730
2731 //=============================================================================
2732 /*!
2733  * \brief Initialize my parameter values by default parameters.
2734  *  \retval bool - true if parameter values have been successfully defined
2735  */
2736 //=============================================================================
2737
2738 bool BLSURFPlugin_Hypothesis::SetParametersByDefaults(const TDefaults& dflts, const SMESH_Mesh* theMesh) {
2739   double diagonal = dflts._elemLength*_gen->GetBoundaryBoxSegmentation();
2740   _phySize = GetDefaultPhySize(diagonal, _gen->GetBoundaryBoxSegmentation());
2741   _minSize = GetDefaultMinSize(diagonal);
2742   _maxSize = GetDefaultMaxSize(diagonal);
2743   _chordalError = GetDefaultChordalError(diagonal);
2744   _tinyEdgeLength = GetDefaultTinyEdgeLength(diagonal);
2745
2746   return true;
2747 //   return bool(_phySize = dflts._elemLength);
2748 }