Salome HOME
Merge from V6_main_20120808 08Aug12
[plugins/blsurfplugin.git] / src / BLSURFPlugin / BLSURFPlugin_Hypothesis.cxx
1 // Copyright (C) 2007-2012  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), _topology(GetDefaultTopology()),
45   _physicalMesh(GetDefaultPhysicalMesh()),
46   _phySize(GetDefaultPhySize()),
47   _phyMax(GetDefaultMaxSize()),
48   _phyMin(GetDefaultMinSize()),
49   _hgeoMax(GetDefaultMaxSize()),
50   _hgeoMin(GetDefaultMinSize()), 
51   _geometricMesh(GetDefaultGeometricMesh()),
52   _angleMeshS(GetDefaultAngleMeshS()),
53   _angleMeshC(GetDefaultAngleMeshC()),
54   _gradation(GetDefaultGradation()),
55   _quadAllowed(GetDefaultQuadAllowed()),
56   _decimesh(GetDefaultDecimesh()),
57   _verb(GetDefaultVerbosity()),
58   _preCADMergeEdges(GetDefaultPreCADMergeEdges()),
59   _preCADRemoveNanoEdges(GetDefaultPreCADRemoveNanoEdges()),
60   _preCADDiscardInput(GetDefaultPreCADDiscardInput()),
61   _preCADEpsNano(GetDefaultPreCADEpsNano()),
62   _sizeMap(GetDefaultSizeMap()),
63   _attractors(GetDefaultSizeMap()),
64   _classAttractors(GetDefaultAttractorMap()),
65   _faceEntryEnfVertexListMap(GetDefaultFaceEntryEnfVertexListMap()),
66   _enfVertexList(GetDefaultEnfVertexList()),
67   _faceEntryCoordsListMap(GetDefaultFaceEntryCoordsListMap()),
68   _coordsEnfVertexMap(GetDefaultCoordsEnfVertexMap()),
69   _faceEntryEnfVertexEntryListMap(GetDefaultFaceEntryEnfVertexEntryListMap()),
70   _enfVertexEntryEnfVertexMap(GetDefaultEnfVertexEntryEnfVertexMap()),
71   _groupNameNodeIDMap(GetDefaultGroupNameNodeIDMap()),
72   _GMFFileName(GetDefaultGMFFile()),
73   _enforcedInternalVerticesAllFaces(GetDefaultInternalEnforcedVertex())
74 {
75   _name = "BLSURF_Parameters";
76   _param_algo_dim = 2;
77   
78 //   _GMFFileMode = false; // GMF ascii mode
79   
80   // to disable writing boundaries
81   //_phyMin = _phyMax = _hgeoMin = _hgeoMax = undefinedDouble();
82
83
84   const char* intOptionNames[] = { "addsurf_ivertex", "anisotropic", "background", "CheckAdjacentEdges", "CheckCloseEdges",
85       "CheckWellDefined", "coiter", "communication", "debug", "decim", "export_flag", "file_h", "frontal", "gridnu", "gridnv",
86       "hinterpol_flag", "hmean_flag", "intermedfile", "memory", "normals", "optim", "pardom_flag", "pinch", "refs",
87       "rigid", "surforient", "tconf", "topo_collapse",
88       "proximity", "prox_nb_layer", "prox_ratio", // detects the volumic proximity of surfaces
89       "" // mark of end
90       };
91   const char* doubleOptionNames[] = { "addsurf_angle", "addsurf_R", "addsurf_H", "addsurf_FG", "addsurf_r",
92       "addsurf_PA", "angle_compcurv", "angle_ridge", "anisotropic_ratio", "CoefRectangle", "eps_collapse", "eps_ends", "eps_pardom", "LSS",
93       "topo_eps1", "topo_eps2", "" // mark of end
94       };
95   const char* charOptionNames[] = { "export_format", "export_option", "import_option", "prefix", "" // mark of end
96       };
97
98   // PreCAD advanced options
99   const char* preCADintOptionNames[] = { "closed_geometry", "debug", "manifold_geometry", "create_tag_on_collision","" // mark of end
100       };
101   const char* preCADdoubleOptionNames[] = { "eps_nano_relative", "eps_sewing", "eps_sewing_relative", "periodic_tolerance",
102       "periodic_tolerance_relative", "periodic_split_tolerance", "periodic_split_tolerance_relative", "" // mark of end
103       };
104   
105   int i = 0;
106   while (intOptionNames[i][0])
107     _option2value[intOptionNames[i++]].clear();
108   
109   i = 0;
110   while (preCADintOptionNames[i][0])
111     _preCADoption2value[preCADintOptionNames[i++]].clear();
112
113   i = 0;
114   while (doubleOptionNames[i][0]) {
115     _doubleOptions.insert(doubleOptionNames[i]);
116     _option2value[doubleOptionNames[i++]].clear();
117   }
118   i = 0;
119   while (preCADdoubleOptionNames[i][0]) {
120     _preCADdoubleOptions.insert(preCADdoubleOptionNames[i]);
121     _preCADoption2value[preCADdoubleOptionNames[i++]].clear();
122   }
123   i = 0;
124   while (charOptionNames[i][0]) {
125     _charOptions.insert(charOptionNames[i]);
126     _option2value[charOptionNames[i++]].clear();
127   }
128   
129
130       
131   _sizeMap.clear();
132   _attractors.clear();
133   _faceEntryEnfVertexListMap.clear();
134   _enfVertexList.clear();
135   _faceEntryCoordsListMap.clear();
136   _coordsEnfVertexMap.clear();
137   _faceEntryEnfVertexEntryListMap.clear();
138   _enfVertexEntryEnfVertexMap.clear();
139   _groupNameNodeIDMap.clear();
140
141   /* TODO GROUPS
142    _groupNameEnfVertexListMap.clear();
143    _enfVertexGroupNameMap.clear();
144    */
145 }
146
147 TopoDS_Shape BLSURFPlugin_Hypothesis::entryToShape(std::string entry)
148 {
149   MESSAGE("BLSURFPlugin_Hypothesis::entryToShape "<<entry );
150   GEOM::GEOM_Object_var aGeomObj;
151   SMESH_Gen_i* smeshGen_i = SMESH_Gen_i::GetSMESHGen();
152   SALOMEDS::Study_ptr myStudy = smeshGen_i->GetCurrentStudy();
153   
154   TopoDS_Shape S = TopoDS_Shape();
155   SALOMEDS::SObject_var aSObj = myStudy->FindObjectID( entry.c_str() );
156   SALOMEDS::GenericAttribute_var anAttr;
157
158   if (!aSObj->_is_nil() && aSObj->FindAttribute(anAttr, "AttributeIOR")) {
159     SALOMEDS::AttributeIOR_var anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
160     CORBA::String_var aVal = anIOR->Value();
161     CORBA::Object_var obj = myStudy->ConvertIORToObject(aVal);
162     aGeomObj = GEOM::GEOM_Object::_narrow(obj);
163   }
164   if ( !aGeomObj->_is_nil() )
165     S = smeshGen_i->GeomObjectToShape( aGeomObj.in() );
166   return S;
167 }
168
169 //=============================================================================
170 void BLSURFPlugin_Hypothesis::SetTopology(Topology theTopology) {
171   if (theTopology != _topology) {
172     _topology = theTopology;
173     NotifySubMeshesHypothesisModification();
174   }
175 }
176
177 //=============================================================================
178 void BLSURFPlugin_Hypothesis::SetPhysicalMesh(PhysicalMesh thePhysicalMesh) {
179   if (thePhysicalMesh != _physicalMesh) {
180     _physicalMesh = thePhysicalMesh;
181     NotifySubMeshesHypothesisModification();
182   }
183 }
184
185 //=============================================================================
186 void BLSURFPlugin_Hypothesis::SetPhySize(double theVal) {
187   if (theVal != _phySize) {
188     if (theVal == 0) {
189       _phySize = GetPhyMax();
190       MESSAGE("Warning: nul physical size is not allowed");
191     }
192     else
193       _phySize = theVal;
194     NotifySubMeshesHypothesisModification();
195   }
196 }
197
198 //=============================================================================
199 void BLSURFPlugin_Hypothesis::SetPhyMin(double theMinSize) {
200   if (theMinSize != _phyMin) {
201     _phyMin = theMinSize;
202     NotifySubMeshesHypothesisModification();
203   }
204 }
205
206 //=============================================================================
207 void BLSURFPlugin_Hypothesis::SetPhyMax(double theMaxSize) {
208   if (theMaxSize != _phyMax) {
209     _phyMax = theMaxSize;
210     NotifySubMeshesHypothesisModification();
211   }
212 }
213
214 //=============================================================================
215 void BLSURFPlugin_Hypothesis::SetGeoMin(double theMinSize) {
216   if (theMinSize != _hgeoMin) {
217     _hgeoMin = theMinSize;
218     NotifySubMeshesHypothesisModification();
219   }
220 }
221
222 //=============================================================================
223 void BLSURFPlugin_Hypothesis::SetGeoMax(double theMaxSize) {
224   if (theMaxSize != _hgeoMax) {
225     _hgeoMax = theMaxSize;
226     NotifySubMeshesHypothesisModification();
227   }
228 }
229
230 //=============================================================================
231 void BLSURFPlugin_Hypothesis::SetGeometricMesh(GeometricMesh theGeometricMesh) {
232   if (theGeometricMesh != _geometricMesh) {
233     _geometricMesh = theGeometricMesh;
234     switch (_geometricMesh) {
235       case DefaultGeom:
236       default:
237         _angleMeshS = GetDefaultAngleMeshS();
238         _gradation = GetDefaultGradation();
239         break;
240     }
241     NotifySubMeshesHypothesisModification();
242   }
243 }
244
245 //=============================================================================
246 void BLSURFPlugin_Hypothesis::SetAngleMeshS(double theVal) {
247   if (theVal != _angleMeshS) {
248     _angleMeshS = theVal;
249     NotifySubMeshesHypothesisModification();
250   }
251 }
252
253 //=============================================================================
254 void BLSURFPlugin_Hypothesis::SetAngleMeshC(double theVal) {
255   if (theVal != _angleMeshC) {
256     _angleMeshC = theVal;
257     NotifySubMeshesHypothesisModification();
258   }
259 }
260
261 //=============================================================================
262 void BLSURFPlugin_Hypothesis::SetGradation(double theVal) {
263   if (theVal != _gradation) {
264     _gradation = theVal;
265     NotifySubMeshesHypothesisModification();
266   }
267 }
268
269 //=============================================================================
270 void BLSURFPlugin_Hypothesis::SetQuadAllowed(bool theVal) {
271   if (theVal != _quadAllowed) {
272     _quadAllowed = theVal;
273     NotifySubMeshesHypothesisModification();
274   }
275 }
276
277 //=============================================================================
278 void BLSURFPlugin_Hypothesis::SetDecimesh(bool theVal) {
279   if (theVal != _decimesh) {
280     _decimesh = theVal;
281     NotifySubMeshesHypothesisModification();
282   }
283 }
284
285 //=============================================================================
286 void BLSURFPlugin_Hypothesis::SetVerbosity(int theVal) {
287   if (theVal != _verb) {
288     _verb = theVal;
289     NotifySubMeshesHypothesisModification();
290   }
291 }
292
293 //=============================================================================
294 void BLSURFPlugin_Hypothesis::SetPreCADMergeEdges(bool theVal) {
295   if (theVal != _preCADMergeEdges) {
296     SetTopology(PreCAD);
297     _preCADMergeEdges = theVal;
298     NotifySubMeshesHypothesisModification();
299   }
300 }
301
302 //=============================================================================
303 void BLSURFPlugin_Hypothesis::SetPreCADRemoveNanoEdges(bool theVal) {
304   if (theVal != _preCADRemoveNanoEdges) {
305     SetTopology(PreCAD);
306     _preCADRemoveNanoEdges = theVal;
307     NotifySubMeshesHypothesisModification();
308   }
309 }
310
311 //=============================================================================
312 void BLSURFPlugin_Hypothesis::SetPreCADDiscardInput(bool theVal) {
313   if (theVal != _preCADDiscardInput) {
314     SetTopology(PreCAD);
315     _preCADDiscardInput = theVal;
316     NotifySubMeshesHypothesisModification();
317   }
318 }
319
320 //=============================================================================
321 void BLSURFPlugin_Hypothesis::SetPreCADEpsNano(double theVal) {
322   if (theVal != _preCADEpsNano) {
323     SetTopology(PreCAD);
324     _preCADEpsNano = theVal;
325     NotifySubMeshesHypothesisModification();
326   }
327 }
328
329 //=============================================================================
330 // void BLSURFPlugin_Hypothesis::SetGMFFile(const std::string& theFileName, bool isBinary)
331 void BLSURFPlugin_Hypothesis::SetGMFFile(const std::string& theFileName)
332 {
333   _GMFFileName = theFileName;
334 //   _GMFFileMode = isBinary;
335   NotifySubMeshesHypothesisModification();
336 }
337
338 //=============================================================================
339 void BLSURFPlugin_Hypothesis::SetOptionValue(const std::string& optionName, const std::string& optionValue)
340     throw (std::invalid_argument) {
341   TOptionValues::iterator op_val = _option2value.find(optionName);
342   if (op_val == _option2value.end()) {
343     std::string msg = "Unknown BLSURF option: '" + optionName + "'";
344     throw std::invalid_argument(msg);
345   }
346   if (op_val->second != optionValue) {
347     const char* ptr = optionValue.c_str();
348     // strip white spaces
349     while (ptr[0] == ' ')
350       ptr++;
351     int i = strlen(ptr);
352     while (i != 0 && ptr[i - 1] == ' ')
353       i--;
354     // check value type
355     bool typeOk = true;
356     std::string typeName;
357     if (i == 0) {
358       // empty string
359     } else if (_charOptions.find(optionName) != _charOptions.end()) {
360       // do not check strings
361     } else if (_doubleOptions.find(optionName) != _doubleOptions.end()) {
362       // check if value is double
363       char * endPtr;
364       strtod(ptr, &endPtr);
365       typeOk = (ptr != endPtr);
366       typeName = "real";
367     } else {
368       // check if value is int
369       char * endPtr;
370       strtol(ptr, &endPtr, 10);
371       typeOk = (ptr != endPtr);
372       typeName = "integer";
373     }
374     if (!typeOk) {
375       std::string msg = "Advanced option '" + optionName + "' = '" + optionValue + "' but must be " + typeName;
376       throw std::invalid_argument(msg);
377     }
378     op_val->second = optionValue;
379     NotifySubMeshesHypothesisModification();
380   }
381 }
382
383 //=============================================================================
384 void BLSURFPlugin_Hypothesis::SetPreCADOptionValue(const std::string& optionName, const std::string& optionValue)
385     throw (std::invalid_argument) {
386   TOptionValues::iterator op_val = _preCADoption2value.find(optionName);
387   if (op_val == _preCADoption2value.end()) {
388     std::string msg = "Unknown BLSURF option: '" + optionName + "'";
389     throw std::invalid_argument(msg);
390   }
391   if (op_val->second != optionValue) {
392     const char* ptr = optionValue.c_str();
393     // strip white spaces
394     while (ptr[0] == ' ')
395       ptr++;
396     int i = strlen(ptr);
397     while (i != 0 && ptr[i - 1] == ' ')
398       i--;
399     // check value type
400     bool typeOk = true;
401     std::string typeName;
402     if (i == 0) {
403       // empty string
404     } else if (_preCADdoubleOptions.find(optionName) != _preCADdoubleOptions.end()) {
405       // check if value is double
406       char * endPtr;
407       strtod(ptr, &endPtr);
408       typeOk = (ptr != endPtr);
409       typeName = "real";
410     } else {
411       // check if value is int
412       char * endPtr;
413       strtol(ptr, &endPtr, 10);
414       typeOk = (ptr != endPtr);
415       typeName = "integer";
416     }
417     if (!typeOk) {
418       std::string msg = "PreCAD advanced option '" + optionName + "' = '" + optionValue + "' but must be " + typeName;
419       throw std::invalid_argument(msg);
420     }
421     op_val->second = optionValue;
422     NotifySubMeshesHypothesisModification();
423   }
424 }
425
426 //=============================================================================
427 std::string BLSURFPlugin_Hypothesis::GetOptionValue(const std::string& optionName) throw (std::invalid_argument) {
428   TOptionValues::iterator op_val = _option2value.find(optionName);
429   if (op_val == _option2value.end()) {
430     std::string msg = "Unknown BLSURF option: <";
431     msg += optionName + ">";
432     throw std::invalid_argument(msg);
433   }
434   return op_val->second;
435 }
436
437 //=============================================================================
438 std::string BLSURFPlugin_Hypothesis::GetPreCADOptionValue(const std::string& optionName) throw (std::invalid_argument) {
439   TOptionValues::iterator op_val = _preCADoption2value.find(optionName);
440   if (op_val == _preCADoption2value.end()) {
441     std::string msg = "Unknown PRECAD option: <";
442     msg += optionName + ">";
443     throw std::invalid_argument(msg);
444   }
445   return op_val->second;
446 }
447
448 //=============================================================================
449 void BLSURFPlugin_Hypothesis::ClearOption(const std::string& optionName) {
450   TOptionValues::iterator op_val = _option2value.find(optionName);
451   if (op_val != _option2value.end())
452     op_val->second.clear();
453 }
454
455 //=============================================================================
456 void BLSURFPlugin_Hypothesis::ClearPreCADOption(const std::string& optionName) {
457   TOptionValues::iterator op_val = _preCADoption2value.find(optionName);
458   if (op_val != _preCADoption2value.end())
459     op_val->second.clear();
460 }
461
462 //=======================================================================
463 //function : SetSizeMapEntry
464 //=======================================================================
465 void BLSURFPlugin_Hypothesis::SetSizeMapEntry(const std::string& entry, const std::string& sizeMap) {
466   if (_sizeMap[entry].compare(sizeMap) != 0) {
467     SetPhysicalMesh(SizeMap);
468     _sizeMap[entry] = sizeMap;
469     NotifySubMeshesHypothesisModification();
470   }
471 }
472
473 //=======================================================================
474 //function : GetSizeMapEntry
475 //=======================================================================
476 std::string BLSURFPlugin_Hypothesis::GetSizeMapEntry(const std::string& entry) {
477   TSizeMap::iterator it = _sizeMap.find(entry);
478   if (it != _sizeMap.end())
479     return it->second;
480   else
481     return "No_Such_Entry";
482 }
483
484 /*!
485  * \brief Return the size maps
486  */
487 BLSURFPlugin_Hypothesis::TSizeMap BLSURFPlugin_Hypothesis::GetSizeMapEntries(const BLSURFPlugin_Hypothesis* hyp) {
488   return hyp ? hyp->_GetSizeMapEntries() : GetDefaultSizeMap();
489 }
490
491 //=======================================================================
492 //function : SetAttractorEntry
493 //=======================================================================
494 void BLSURFPlugin_Hypothesis::SetAttractorEntry(const std::string& entry, const std::string& attractor) {
495   if (_attractors[entry].compare(attractor) != 0) {
496     SetPhysicalMesh(SizeMap);
497     _attractors[entry] = attractor;
498     NotifySubMeshesHypothesisModification();
499   }
500 }
501
502 //=======================================================================
503 //function : GetAttractorEntry
504 //=======================================================================
505 std::string BLSURFPlugin_Hypothesis::GetAttractorEntry(const std::string& entry) {
506   TSizeMap::iterator it = _attractors.find(entry);
507   if (it != _attractors.end())
508     return it->second;
509   else
510     return "No_Such_Entry";
511 }
512
513 /*!
514  * \brief Return the attractors
515  */
516 BLSURFPlugin_Hypothesis::TSizeMap BLSURFPlugin_Hypothesis::GetAttractorEntries(const BLSURFPlugin_Hypothesis* hyp) {
517   return hyp ? hyp->_GetAttractorEntries() : GetDefaultSizeMap();
518 }
519
520 //=======================================================================
521 //function : SetClassAttractorEntry
522 //=======================================================================
523 void BLSURFPlugin_Hypothesis::SetClassAttractorEntry(const std::string& entry, const std::string& attEntry, double StartSize, double EndSize, double ActionRadius, double ConstantRadius)
524 {
525   SetPhysicalMesh(SizeMap);
526
527   // The new attractor can't be defined on the same face as another sizemap
528   TSizeMap::iterator it  = _sizeMap.find( entry );
529   if ( it != _sizeMap.end() ) {
530     _sizeMap.erase(it);
531     NotifySubMeshesHypothesisModification();
532   }
533   else {
534     TSizeMap::iterator itAt  = _attractors.find( entry );
535     if ( itAt != _attractors.end() ) {
536       _attractors.erase(itAt);
537       NotifySubMeshesHypothesisModification();
538     }
539   }
540   
541   const TopoDS_Shape AttractorShape = BLSURFPlugin_Hypothesis::entryToShape(attEntry);
542   const TopoDS_Face FaceShape = TopoDS::Face(BLSURFPlugin_Hypothesis::entryToShape(entry));
543   bool attExists = (_classAttractors.find(entry) != _classAttractors.end());
544   double u1,u2,v1,v2, diag;
545   
546   if ( !attExists || (attExists && _classAttractors[entry]->GetAttractorEntry().compare(attEntry) != 0)){ 
547     ShapeAnalysis::GetFaceUVBounds(FaceShape,u1,u2,v1,v2);
548 //     diag = sqrt((u2 - u1) * (u2 - u1) + (v2 - v1) * (v2 - v1));  
549     BLSURFPlugin_Attractor* myAttractor = new BLSURFPlugin_Attractor(FaceShape, AttractorShape, attEntry);//, 0.1 ); // test 0.002 * diag); 
550     myAttractor->BuildMap();
551     myAttractor->SetParameters(StartSize, EndSize, ActionRadius, ConstantRadius);
552     _classAttractors[entry] = myAttractor;
553     NotifySubMeshesHypothesisModification();
554   }
555   else {
556     _classAttractors[entry]->SetParameters(StartSize, EndSize, ActionRadius, ConstantRadius);
557     if (!_classAttractors[entry]->IsMapBuilt()){
558       _classAttractors[entry]->BuildMap();
559     }
560     NotifySubMeshesHypothesisModification();
561   }
562     
563 }
564
565 //=======================================================================
566 //function : SetConstantSizeOnAdjacentFaces
567 //=======================================================================
568 // TODO uncomment and test (include the needed .hxx)
569 // SetConstantSizeOnAdjacentFaces(myShape, att_entry, startSize, endSize = user_size, const_dist  ) {
570 //   TopTools_IndexedMapOfShapListOdShape anEdge2FaceMap;
571 //   TopExp::MapShapesAnAncestors(myShape,TopAbs_EDGE, TopAbs_FACE, anEdge2FaceMap);
572 //   TopTools_IndexedMapOfShapListOdShape::iterator it;
573 //   for (it = anEdge2FaceMap.begin();it != anEdge2FaceMap.end();it++){
574 //       SetClassAttractorEntry((*it).first, att_entry, startSize, endSize, 0, const_dist)
575 //   }
576
577
578
579
580
581
582 //=======================================================================
583 //function : GetClassAttractorEntry
584 //=======================================================================
585 // BLSURFPlugin_Attractor&  BLSURFPlugin_Hypothesis::GetClassAttractorEntry(const std::string& entry)
586 // {
587 //  TAttractorMap::iterator it  = _classAttractors.find( entry );
588 //  if ( it != _classAttractors.end() )
589 //    return it->second;
590 //  else
591 //    return "No_Such_Entry";
592 // }
593 // 
594   /*!
595    * \brief Return the map of attractor instances
596    */
597 BLSURFPlugin_Hypothesis::TAttractorMap BLSURFPlugin_Hypothesis::GetClassAttractorEntries(const BLSURFPlugin_Hypothesis* hyp)
598 {
599     return hyp ? hyp->_GetClassAttractorEntries():GetDefaultAttractorMap();
600 }
601
602 //=======================================================================
603 //function : ClearEntry
604 //=======================================================================
605 void BLSURFPlugin_Hypothesis::ClearEntry(const std::string& entry)
606 {
607  TSizeMap::iterator it  = _sizeMap.find( entry );
608  
609  if ( it != _sizeMap.end() ) {
610    _sizeMap.erase(it);
611    NotifySubMeshesHypothesisModification();
612  }
613  else {
614    TSizeMap::iterator itAt  = _attractors.find( entry );
615    if ( itAt != _attractors.end() ) {
616      _attractors.erase(itAt);
617      NotifySubMeshesHypothesisModification();
618    }
619    else {
620      TAttractorMap::iterator it_clAt = _classAttractors.find( entry );
621      if ( it_clAt != _classAttractors.end() ) {
622        _classAttractors.erase(it_clAt);
623        MESSAGE("_classAttractors.size() = "<<_classAttractors.size())
624        NotifySubMeshesHypothesisModification();
625      }
626      else
627        std::cout<<"No_Such_Entry"<<std::endl;
628    }
629  }
630 }
631
632 //=======================================================================
633 //function : ClearSizeMaps
634 //=======================================================================
635 void BLSURFPlugin_Hypothesis::ClearSizeMaps() {
636   _sizeMap.clear();
637   _attractors.clear();
638   _classAttractors.clear();
639 }
640
641 // Enable internal enforced vertices on specific face if requested by user
642
643 ////=======================================================================
644 ////function : SetInternalEnforcedVertex
645 ////=======================================================================
646 //void BLSURFPlugin_Hypothesis::SetInternalEnforcedVertex(TEntry theFaceEntry,
647 //                                                        bool toEnforceInternalVertices,
648 //                                                        TEnfGroupName theGroupName) {
649
650 //  MESSAGE("BLSURFPlugin_Hypothesis::SetInternalEnforcedVertex("<< theFaceEntry << ", "
651 //      << toEnforceInternalVertices << ", " << theGroupName << ")");
652   
653 //  TFaceEntryInternalVerticesList::iterator it = _faceEntryInternalVerticesList.find(theFaceEntry);
654 //  if (it != _faceEntryInternalVerticesList.end()) {
655 //    if (!toEnforceInternalVertices) {
656 //      _faceEntryInternalVerticesList.erase(it);
657 //    }
658 //  }
659 //  else {
660 //    if (toEnforceInternalVertices) {
661 //      _faceEntryInternalVerticesList.insert(theFaceEntry);
662 //    }
663 //  }
664   
665 //  // TODO
666 //  // Take care of groups
667 //}
668
669
670 //=======================================================================
671 //function : SetEnforcedVertex
672 //=======================================================================
673 bool BLSURFPlugin_Hypothesis::SetEnforcedVertex(TEntry theFaceEntry, TEnfName theVertexName, TEntry theVertexEntry,
674                                                 TEnfGroupName theGroupName, double x, double y, double z) {
675
676   MESSAGE("BLSURFPlugin_Hypothesis::SetEnforcedVertex("<< theFaceEntry << ", "
677       << x << ", " << y << ", " << z << ", " << theVertexName << ", " << theVertexEntry << ", " << theGroupName << ")");
678
679   SetPhysicalMesh(SizeMap);
680
681   //  TEnfVertexList::iterator it;
682   bool toNotify = false;
683   bool toCreate = true;
684
685   TEnfVertex *oldEnVertex;
686   TEnfVertex *newEnfVertex = new TEnfVertex();
687   newEnfVertex->name = theVertexName;
688   newEnfVertex->geomEntry = theVertexEntry;
689   newEnfVertex->coords.clear();
690   if (theVertexEntry == "") {
691     newEnfVertex->coords.push_back(x);
692     newEnfVertex->coords.push_back(y);
693     newEnfVertex->coords.push_back(z);
694   }
695   newEnfVertex->grpName = theGroupName;
696   newEnfVertex->faceEntries.clear();
697   newEnfVertex->faceEntries.insert(theFaceEntry);
698   
699   
700   // update _enfVertexList
701   TEnfVertexList::iterator it = _enfVertexList.find(newEnfVertex);
702   if (it != _enfVertexList.end()) {
703     toCreate = false;
704     oldEnVertex = (*it);
705     MESSAGE("Enforced Vertex was found => Update");
706     if (oldEnVertex->name != theVertexName) {
707       MESSAGE("Update name from \"" << oldEnVertex->name << "\" to \"" << theVertexName << "\"");
708       oldEnVertex->name = theVertexName;
709       toNotify = true;
710     }
711     if (oldEnVertex->grpName != theGroupName) {
712       MESSAGE("Update group name from \"" << oldEnVertex->grpName << "\" to \"" << theGroupName << "\"");
713       oldEnVertex->grpName = theGroupName;
714       toNotify = true;
715     }
716     TEntryList::iterator it_faceEntries = oldEnVertex->faceEntries.find(theFaceEntry);
717     if (it_faceEntries == oldEnVertex->faceEntries.end()) {
718       MESSAGE("Update face list by adding \"" << theFaceEntry << "\"");
719       oldEnVertex->faceEntries.insert(theFaceEntry);
720       _faceEntryEnfVertexListMap[theFaceEntry].insert(oldEnVertex);
721       toNotify = true;
722     }
723     if (toNotify) {
724       // update map coords / enf vertex if needed
725       if (oldEnVertex->coords.size()) {
726         _coordsEnfVertexMap[oldEnVertex->coords] = oldEnVertex;
727         _faceEntryCoordsListMap[theFaceEntry].insert(oldEnVertex->coords);
728       }
729
730       // update map geom entry / enf vertex if needed
731       if (oldEnVertex->geomEntry != "") {
732         _enfVertexEntryEnfVertexMap[oldEnVertex->geomEntry] = oldEnVertex;
733         _faceEntryEnfVertexEntryListMap[theFaceEntry].insert(oldEnVertex->geomEntry);
734       }
735     }
736   }
737
738 //   //////// CREATE ////////////
739   if (toCreate) {
740     toNotify = true;
741     MESSAGE("Creating new enforced vertex");
742     _faceEntryEnfVertexListMap[theFaceEntry].insert(newEnfVertex);
743     _enfVertexList.insert(newEnfVertex);
744     if (theVertexEntry == "") {
745       _faceEntryCoordsListMap[theFaceEntry].insert(newEnfVertex->coords);
746       _coordsEnfVertexMap[newEnfVertex->coords] = newEnfVertex;
747     }
748     else {
749       _faceEntryEnfVertexEntryListMap[theFaceEntry].insert(newEnfVertex->geomEntry);
750       _enfVertexEntryEnfVertexMap[newEnfVertex->geomEntry] = newEnfVertex;
751     }
752   }
753
754   if (toNotify)
755     NotifySubMeshesHypothesisModification();
756
757   MESSAGE("BLSURFPlugin_Hypothesis::SetEnforcedVertex END");
758   return toNotify;
759 }
760
761
762 //=======================================================================
763 //function : GetEnforcedVertices
764 //=======================================================================
765
766 BLSURFPlugin_Hypothesis::TEnfVertexList BLSURFPlugin_Hypothesis::GetEnfVertexList(const TEntry& theFaceEntry)
767     throw (std::invalid_argument) {
768
769   if (_faceEntryEnfVertexListMap.count(theFaceEntry) > 0)
770     return _faceEntryEnfVertexListMap[theFaceEntry];
771   else
772     return GetDefaultEnfVertexList();
773
774   std::ostringstream msg;
775   msg << "No enforced vertex for face entry " << theFaceEntry;
776   throw std::invalid_argument(msg.str());
777 }
778
779 //=======================================================================
780 //function : GetEnfVertexCoordsList
781 //=======================================================================
782
783 BLSURFPlugin_Hypothesis::TEnfVertexCoordsList BLSURFPlugin_Hypothesis::GetEnfVertexCoordsList(
784     const TEntry& theFaceEntry) throw (std::invalid_argument) {
785
786   if (_faceEntryCoordsListMap.count(theFaceEntry) > 0)
787     return _faceEntryCoordsListMap[theFaceEntry];
788
789   std::ostringstream msg;
790   msg << "No enforced vertex coords for face entry " << theFaceEntry;
791   throw std::invalid_argument(msg.str());
792 }
793
794 //=======================================================================
795 //function : GetEnfVertexEntryList
796 //=======================================================================
797
798 BLSURFPlugin_Hypothesis::TEntryList BLSURFPlugin_Hypothesis::GetEnfVertexEntryList(const TEntry& theFaceEntry)
799     throw (std::invalid_argument) {
800
801   if (_faceEntryEnfVertexEntryListMap.count(theFaceEntry) > 0)
802     return _faceEntryEnfVertexEntryListMap[theFaceEntry];
803
804   std::ostringstream msg;
805   msg << "No enforced vertex entry for face entry " << theFaceEntry;
806   throw std::invalid_argument(msg.str());
807 }
808
809 //=======================================================================
810 //function : GetEnfVertex(TEnfVertexCoords coords)
811 //=======================================================================
812
813 BLSURFPlugin_Hypothesis::TEnfVertex* BLSURFPlugin_Hypothesis::GetEnfVertex(TEnfVertexCoords coords)
814     throw (std::invalid_argument) {
815
816   if (_coordsEnfVertexMap.count(coords) > 0)
817     return _coordsEnfVertexMap[coords];
818
819   std::ostringstream msg;
820   msg << "No enforced vertex with coords (" << coords[0] << ", " << coords[1] << ", " << coords[2] << ")";
821   throw std::invalid_argument(msg.str());
822 }
823
824 //=======================================================================
825 //function : GetEnfVertex(const TEntry& theEnfVertexEntry)
826 //=======================================================================
827
828 BLSURFPlugin_Hypothesis::TEnfVertex* BLSURFPlugin_Hypothesis::GetEnfVertex(const TEntry& theEnfVertexEntry)
829     throw (std::invalid_argument) {
830
831   if (_enfVertexEntryEnfVertexMap.count(theEnfVertexEntry) > 0)
832     return _enfVertexEntryEnfVertexMap[theEnfVertexEntry];
833
834   std::ostringstream msg;
835   msg << "No enforced vertex with entry " << theEnfVertexEntry;
836   throw std::invalid_argument(msg.str());
837 }
838
839 //Enable internal enforced vertices on specific face if requested by user
840 ////=======================================================================
841 ////function : GetInternalEnforcedVertex
842 ////=======================================================================
843
844 //bool BLSURFPlugin_Hypothesis::GetInternalEnforcedVertex(const TEntry& theFaceEntry)
845 //{
846 //  if (_faceEntryInternalVerticesList.count(theFaceEntry) > 0)
847 //    return true;
848 //  return false;
849 //}
850
851 //=======================================================================
852 //function : ClearEnforcedVertex
853 //=======================================================================
854
855 bool BLSURFPlugin_Hypothesis::ClearEnforcedVertex(const TEntry& theFaceEntry, double x, double y, double z,
856     const TEntry& theVertexEntry) throw (std::invalid_argument) {
857
858   bool toNotify = false;
859   std::ostringstream msg;
860   TEnfVertex *oldEnfVertex;
861   TEnfVertexCoords coords;
862   coords.clear();
863   coords.push_back(x);
864   coords.push_back(y);
865   coords.push_back(z);
866
867   // check that enf vertex with given enf vertex entry exists
868   TEnfVertexEntryEnfVertexMap::iterator it_enfVertexEntry = _enfVertexEntryEnfVertexMap.find(theVertexEntry);
869   if (it_enfVertexEntry != _enfVertexEntryEnfVertexMap.end()) {
870     // Success
871     MESSAGE("Found enforced vertex with geom entry " << theVertexEntry);
872     oldEnfVertex = it_enfVertexEntry->second;
873
874     _enfVertexEntryEnfVertexMap.erase(it_enfVertexEntry);
875
876     TEntryList& enfVertexEntryList = _faceEntryEnfVertexEntryListMap[theFaceEntry];
877     enfVertexEntryList.erase(theVertexEntry);
878     if (enfVertexEntryList.size() == 0)
879       _faceEntryEnfVertexEntryListMap.erase(theFaceEntry);
880     //    TFaceEntryEnfVertexEntryListMap::iterator it_entry_entry = _faceEntryEnfVertexEntryListMap.find(theFaceEntry);
881     //    TEntryList::iterator it_entryList = it_entry_entry->second.find(theVertexEntry);
882     //    it_entry_entry->second.erase(it_entryList);
883     //    if (it_entry_entry->second.size() == 0)
884     //      _faceEntryEnfVertexEntryListMap.erase(it_entry_entry);
885   } else {
886     // Fail
887     MESSAGE("Enforced vertex with geom entry " << theVertexEntry << " not found");
888     msg << "No enforced vertex with geom entry " << theVertexEntry;
889     // check that enf vertex with given coords exists
890     TCoordsEnfVertexMap::iterator it_coords_enf = _coordsEnfVertexMap.find(coords);
891     if (it_coords_enf != _coordsEnfVertexMap.end()) {
892       // Success
893       MESSAGE("Found enforced vertex with coords " << x << ", " << y << ", " << z);
894       oldEnfVertex = it_coords_enf->second;
895
896       _coordsEnfVertexMap.erase(it_coords_enf);
897
898       TEnfVertexCoordsList& enfVertexCoordsList = _faceEntryCoordsListMap[theFaceEntry];
899       enfVertexCoordsList.erase(coords);
900       if (enfVertexCoordsList.size() == 0)
901         _faceEntryCoordsListMap.erase(theFaceEntry);
902       //      TFaceEntryCoordsListMap::iterator it_entry_coords = _faceEntryCoordsListMap.find(theFaceEntry);
903       //      TEnfVertexCoordsList::iterator it_coordsList = it_entry_coords->second.find(coords);
904       //      it_entry_coords->second.erase(it_coordsList);
905       //      if (it_entry_coords->second.size() == 0)
906       //        _faceEntryCoordsListMap.erase(it_entry_coords);
907     } else {
908       // Fail
909       MESSAGE("Enforced vertex with coords " << x << ", " << y << ", " << z << " not found");
910       msg << std::endl;
911       msg << "No enforced vertex at " << x << ", " << y << ", " << z;
912       throw std::invalid_argument(msg.str());
913     }
914   }
915
916   MESSAGE("Remove enf vertex from _enfVertexList");
917
918   // update _enfVertexList
919   TEnfVertexList::iterator it = _enfVertexList.find(oldEnfVertex);
920   if (it != _enfVertexList.end()) {
921     (*it)->faceEntries.erase(theFaceEntry);
922     if ((*it)->faceEntries.size() == 0){
923       _enfVertexList.erase(it);
924       toNotify = true;
925     }
926     MESSAGE("Done");
927   }
928
929   // update _faceEntryEnfVertexListMap
930   TEnfVertexList& currentEnfVertexList = _faceEntryEnfVertexListMap[theFaceEntry];
931   currentEnfVertexList.erase(oldEnfVertex);
932
933   if (currentEnfVertexList.size() == 0) {
934     MESSAGE("Remove _faceEntryEnfVertexListMap[" << theFaceEntry <<"]");
935     _faceEntryEnfVertexListMap.erase(theFaceEntry);
936     MESSAGE("Done");
937   }
938
939   if (toNotify)
940     NotifySubMeshesHypothesisModification();
941
942   return toNotify;
943 }
944
945 //=======================================================================
946 //function : ClearEnforcedVertices
947 //=======================================================================
948
949 bool BLSURFPlugin_Hypothesis::ClearEnforcedVertices(const TEntry& theFaceEntry) throw (std::invalid_argument) {
950
951   bool toNotify = false;
952   TEnfVertex *oldEnfVertex;
953
954   TFaceEntryCoordsListMap::iterator it_entry_coords = _faceEntryCoordsListMap.find(theFaceEntry);
955   if (it_entry_coords != _faceEntryCoordsListMap.end()) {
956     toNotify = true;
957     TEnfVertexCoordsList coordsList = it_entry_coords->second;
958     TEnfVertexCoordsList::iterator it_coordsList = coordsList.begin();
959     for (; it_coordsList != coordsList.end(); ++it_coordsList) {
960       TEnfVertexCoords coords = (*it_coordsList);
961       oldEnfVertex = _coordsEnfVertexMap[coords];
962       _coordsEnfVertexMap.erase(coords);
963       // update _enfVertexList
964       TEnfVertexList::iterator it = _enfVertexList.find(oldEnfVertex);
965       if (it != _enfVertexList.end()) {
966         (*it)->faceEntries.erase(theFaceEntry);
967         if ((*it)->faceEntries.size() == 0){
968           _enfVertexList.erase(it);
969           toNotify = true;
970         }
971         MESSAGE("Done");
972       }
973     }
974     _faceEntryCoordsListMap.erase(it_entry_coords);
975     _faceEntryEnfVertexListMap.erase(theFaceEntry);
976   }
977
978   TFaceEntryEnfVertexEntryListMap::iterator it_entry_entry = _faceEntryEnfVertexEntryListMap.find(theFaceEntry);
979   if (it_entry_entry != _faceEntryEnfVertexEntryListMap.end()) {
980     toNotify = true;
981     TEntryList enfVertexEntryList = it_entry_entry->second;
982     TEntryList::iterator it_enfVertexEntryList = enfVertexEntryList.begin();
983     for (; it_enfVertexEntryList != enfVertexEntryList.end(); ++it_enfVertexEntryList) {
984       TEntry enfVertexEntry = (*it_enfVertexEntryList);
985       oldEnfVertex = _enfVertexEntryEnfVertexMap[enfVertexEntry];
986       _enfVertexEntryEnfVertexMap.erase(enfVertexEntry);
987       // update _enfVertexList
988       TEnfVertexList::iterator it = _enfVertexList.find(oldEnfVertex);
989       if (it != _enfVertexList.end()) {
990         (*it)->faceEntries.erase(theFaceEntry);
991         if ((*it)->faceEntries.size() == 0){
992           _enfVertexList.erase(it);
993           toNotify = true;
994         }
995         MESSAGE("Done");
996       }
997     }
998     _faceEntryEnfVertexEntryListMap.erase(it_entry_entry);
999     _faceEntryEnfVertexListMap.erase(theFaceEntry);
1000   }
1001
1002   if (toNotify)
1003     NotifySubMeshesHypothesisModification();
1004
1005   return toNotify;
1006   //  std::ostringstream msg;
1007   //  msg << "No enforced vertex for " << theFaceEntry;
1008   //  throw std::invalid_argument(msg.str());
1009 }
1010
1011 //=======================================================================
1012 //function : ClearAllEnforcedVertices
1013 //=======================================================================
1014 void BLSURFPlugin_Hypothesis::ClearAllEnforcedVertices() {
1015   _faceEntryEnfVertexListMap.clear();
1016   _enfVertexList.clear();
1017   _faceEntryCoordsListMap.clear();
1018   _coordsEnfVertexMap.clear();
1019   _faceEntryEnfVertexEntryListMap.clear();
1020   _enfVertexEntryEnfVertexMap.clear();
1021 //  Enable internal enforced vertices on specific face if requested by user
1022 //  _faceEntryInternalVerticesList.clear();
1023   NotifySubMeshesHypothesisModification();
1024 }
1025
1026 //================================================================================
1027 /*!
1028  * \brief Return the enforced vertices
1029  */
1030 //================================================================================
1031
1032
1033 BLSURFPlugin_Hypothesis::TFaceEntryEnfVertexListMap BLSURFPlugin_Hypothesis::GetAllEnforcedVerticesByFace(
1034     const BLSURFPlugin_Hypothesis* hyp) {
1035   return hyp ? hyp->_GetAllEnforcedVerticesByFace() : GetDefaultFaceEntryEnfVertexListMap();
1036 }
1037
1038 //Enable internal enforced vertices on specific face if requested by user
1039 //BLSURFPlugin_Hypothesis::TFaceEntryInternalVerticesList BLSURFPlugin_Hypothesis::GetAllInternalEnforcedVerticesByFace(
1040 //    const BLSURFPlugin_Hypothesis* hyp) {
1041 //  return hyp ? hyp->_GetAllInternalEnforcedVerticesByFace() : GetDefaultFaceEntryInternalVerticesMap();
1042 //}
1043
1044 bool BLSURFPlugin_Hypothesis::GetInternalEnforcedVertexAllFaces(const BLSURFPlugin_Hypothesis* hyp)
1045 {
1046   return hyp ? hyp->_GetInternalEnforcedVertexAllFaces() : GetDefaultInternalEnforcedVertex();
1047 }
1048
1049 BLSURFPlugin_Hypothesis::TEnfGroupName BLSURFPlugin_Hypothesis::GetInternalEnforcedVertexAllFacesGroup(const BLSURFPlugin_Hypothesis* hyp)
1050 {
1051   return hyp ? hyp->_GetInternalEnforcedVertexAllFacesGroup() : BLSURFPlugin_Hypothesis::TEnfGroupName();
1052 }
1053
1054 BLSURFPlugin_Hypothesis::TEnfVertexList BLSURFPlugin_Hypothesis::GetAllEnforcedVertices(
1055     const BLSURFPlugin_Hypothesis* hyp) {
1056   return hyp ? hyp->_GetAllEnforcedVertices() : GetDefaultEnfVertexList();
1057 }
1058
1059 BLSURFPlugin_Hypothesis::TFaceEntryCoordsListMap BLSURFPlugin_Hypothesis::GetAllCoordsByFace(
1060     const BLSURFPlugin_Hypothesis* hyp) {
1061   return hyp ? hyp->_GetAllCoordsByFace() : GetDefaultFaceEntryCoordsListMap();
1062 }
1063
1064 BLSURFPlugin_Hypothesis::TCoordsEnfVertexMap BLSURFPlugin_Hypothesis::GetAllEnforcedVerticesByCoords(
1065     const BLSURFPlugin_Hypothesis* hyp) {
1066   return hyp ? hyp->_GetAllEnforcedVerticesByCoords() : GetDefaultCoordsEnfVertexMap();
1067 }
1068
1069 BLSURFPlugin_Hypothesis::TFaceEntryEnfVertexEntryListMap BLSURFPlugin_Hypothesis::GetAllEnfVertexEntriesByFace(
1070     const BLSURFPlugin_Hypothesis* hyp) {
1071   return hyp ? hyp->_GetAllEnfVertexEntriesByFace() : GetDefaultFaceEntryEnfVertexEntryListMap();
1072 }
1073
1074 BLSURFPlugin_Hypothesis::TEnfVertexEntryEnfVertexMap BLSURFPlugin_Hypothesis::GetAllEnforcedVerticesByEnfVertexEntry(
1075     const BLSURFPlugin_Hypothesis* hyp) {
1076   return hyp ? hyp->_GetAllEnforcedVerticesByEnfVertexEntry() : GetDefaultEnfVertexEntryEnfVertexMap();
1077 }
1078
1079 std::set<int> BLSURFPlugin_Hypothesis::GetEnfVertexNodeIDs(TEnfGroupName theGroupName) throw (std::invalid_argument)
1080 {
1081   TGroupNameNodeIDMap::const_iterator it = _groupNameNodeIDMap.find(theGroupName);
1082   if (it != _groupNameNodeIDMap.end()) {
1083     return it->second;
1084   }
1085   std::ostringstream msg;
1086   msg << "No group " << theGroupName;
1087   throw std::invalid_argument(msg.str());
1088 }
1089
1090 void BLSURFPlugin_Hypothesis::AddEnfVertexNodeID(TEnfGroupName theGroupName,int theNodeID)
1091 {
1092   _groupNameNodeIDMap[theGroupName].insert(theNodeID);
1093 }
1094
1095 void BLSURFPlugin_Hypothesis::RemoveEnfVertexNodeID(TEnfGroupName theGroupName,int theNodeID) throw (std::invalid_argument)
1096 {
1097   TGroupNameNodeIDMap::iterator it = _groupNameNodeIDMap.find(theGroupName);
1098   if (it != _groupNameNodeIDMap.end()) {
1099     std::set<int>::iterator IDit = it->second.find(theNodeID);
1100     if (IDit != it->second.end())
1101       it->second.erase(IDit);
1102     std::ostringstream msg;
1103     msg << "No node IDs " << theNodeID << " for group " << theGroupName;
1104     throw std::invalid_argument(msg.str());
1105   }
1106   std::ostringstream msg;
1107   msg << "No group " << theGroupName;
1108   throw std::invalid_argument(msg.str());
1109 }
1110
1111
1112 //=============================================================================
1113 void BLSURFPlugin_Hypothesis::SetInternalEnforcedVertexAllFaces(bool toEnforceInternalVertices) {
1114   if (toEnforceInternalVertices != _enforcedInternalVerticesAllFaces) {
1115     _enforcedInternalVerticesAllFaces = toEnforceInternalVertices;
1116     if (toEnforceInternalVertices)
1117       SetPhysicalMesh(SizeMap);
1118     NotifySubMeshesHypothesisModification();
1119   }
1120 }
1121
1122
1123 //=============================================================================
1124 void BLSURFPlugin_Hypothesis::SetInternalEnforcedVertexAllFacesGroup(BLSURFPlugin_Hypothesis::TEnfGroupName theGroupName) {
1125   if (string(theGroupName) != string(_enforcedInternalVerticesAllFacesGroup)) {
1126     _enforcedInternalVerticesAllFacesGroup = theGroupName;
1127     NotifySubMeshesHypothesisModification();
1128   }
1129 }
1130
1131 //=============================================================================
1132 std::ostream & BLSURFPlugin_Hypothesis::SaveTo(std::ostream & save) {
1133   save << " " << (int) _topology << " " << (int) _physicalMesh << " " << (int) _geometricMesh << " " << _phySize << " "
1134       << _angleMeshS << " " << _gradation << " " << (int) _quadAllowed << " " << (int) _decimesh;
1135   save << " " << _phyMin << " " << _phyMax << " " << _angleMeshC << " " << _hgeoMin << " " << _hgeoMax << " " << _verb;
1136   save << " " << (int) _preCADMergeEdges << " " << (int) _preCADRemoveNanoEdges << " " << (int) _preCADDiscardInput << " " << _preCADEpsNano ;
1137
1138   TOptionValues::iterator op_val = _option2value.begin();
1139   if (op_val != _option2value.end()) {
1140     save << " " << "__OPTIONS_BEGIN__";
1141     for (; op_val != _option2value.end(); ++op_val) {
1142       if (!op_val->second.empty())
1143         save << " " << op_val->first << " " << op_val->second << "%#"; // "%#" is a mark of value end
1144     }
1145     save << " " << "__OPTIONS_END__";
1146   }
1147   
1148   op_val = _preCADoption2value.begin();
1149   if (op_val != _preCADoption2value.end()) {
1150     save << " " << "__PRECAD_OPTIONS_BEGIN__";
1151     for (; op_val != _preCADoption2value.end(); ++op_val) {
1152       if (!op_val->second.empty())
1153         save << " " << op_val->first << " " << op_val->second << "%#"; // "%#" is a mark of value end
1154     }
1155     save << " " << "__PRECAD_OPTIONS_END__";
1156   }
1157
1158   TSizeMap::iterator it_sm = _sizeMap.begin();
1159   if (it_sm != _sizeMap.end()) {
1160     save << " " << "__SIZEMAP_BEGIN__";
1161     for (; it_sm != _sizeMap.end(); ++it_sm) {
1162       save << " " << it_sm->first << " " << it_sm->second << "%#"; // "%#" is a mark of value end
1163     }
1164     save << " " << "__SIZEMAP_END__";
1165   }
1166
1167   TSizeMap::iterator it_at = _attractors.begin();
1168   if (it_at != _attractors.end()) {
1169     save << " " << "__ATTRACTORS_BEGIN__";
1170     for (; it_at != _attractors.end(); ++it_at) {
1171       save << " " << it_at->first << " " << it_at->second << "%#"; // "%#" is a mark of value end
1172     }
1173     save << " " << "__ATTRACTORS_END__";
1174   }
1175   
1176   TAttractorMap::iterator it_At = _classAttractors.begin();
1177   if (it_At != _classAttractors.end()) {
1178     std::ostringstream test;
1179     save << " " << "__NEW_ATTRACTORS_BEGIN__";
1180     test << " " << "__NEW_ATTRACTORS_BEGIN__";
1181     for (; it_At != _classAttractors.end(); ++it_At) {
1182       std::vector<double> attParams;
1183       attParams   = it_At->second->GetParameters();
1184 //       double step = it_At->second->GetStep();
1185       save << " " << it_At->first;
1186       save << " " << it_At->second->GetAttractorEntry();
1187       save << " " << attParams[0]  << " " <<  attParams[1] << " " <<  attParams[2] << " " <<  attParams[3];
1188 //       save << " " << step;
1189       test << " " << it_At->first;
1190       test << " " << it_At->second->GetAttractorEntry();
1191       test << " " << attParams[0]  << " " <<  attParams[1] << " " <<  attParams[2] << " " <<  attParams[3];
1192 //       test << " " << step;
1193     }
1194     save << " " << "__NEW_ATTRACTORS_END__";
1195     test << " " << "__NEW_ATTRACTORS_END__";
1196     MESSAGE(" Attractor hypothesis saved as "<<test.str())
1197   }
1198
1199   TEnfVertexList::const_iterator it_enf = _enfVertexList.begin();
1200   if (it_enf != _enfVertexList.end()) {
1201     save << " " << "__ENFORCED_VERTICES_BEGIN__";
1202     for (; it_enf != _enfVertexList.end(); ++it_enf) {
1203       TEnfVertex *enfVertex = (*it_enf);
1204       save << " " << "__BEGIN_VERTEX__";
1205       if (!enfVertex->name.empty()) {
1206         save << " " << "__BEGIN_NAME__";
1207         save << " " << enfVertex->name;
1208         save << " " << "__END_NAME__";
1209       }
1210       if (!enfVertex->geomEntry.empty()) {
1211         save << " " << "__BEGIN_ENTRY__";
1212         save << " " << enfVertex->geomEntry;
1213         save << " " << "__END_ENTRY__";
1214       }
1215       if (!enfVertex->grpName.empty()) {
1216         save << " " << "__BEGIN_GROUP__";
1217         save << " " << enfVertex->grpName;
1218         save << " " << "__END_GROUP__";
1219       }
1220       if (enfVertex->coords.size()) {
1221         save << " " << "__BEGIN_COORDS__";
1222         for (int i=0;i<enfVertex->coords.size();i++)
1223           save << " " << enfVertex->coords[i];
1224         save << " " << "__END_COORDS__";
1225       }
1226       TEntryList::const_iterator faceEntriesIt = enfVertex->faceEntries.begin();
1227       bool hasFaces = false;
1228       if (faceEntriesIt != enfVertex->faceEntries.end()) {
1229         hasFaces = true;
1230         save << " " << "__BEGIN_FACELIST__";
1231       }
1232       for (; faceEntriesIt != enfVertex->faceEntries.end(); ++faceEntriesIt)
1233         save << " " << (*faceEntriesIt);
1234       if (hasFaces)
1235         save << " " << "__END_FACELIST__";
1236       save << " " << "__END_VERTEX__";
1237     }
1238     save << " " << "__ENFORCED_VERTICES_END__";
1239   }
1240
1241   return save;
1242 }
1243
1244 //=============================================================================
1245 std::istream & BLSURFPlugin_Hypothesis::LoadFrom(std::istream & load) {
1246   bool isOK = true;
1247   int i;
1248   double val;
1249
1250   isOK = (load >> i);
1251   if (isOK)
1252     _topology = (Topology) i;
1253   else
1254     load.clear(std::ios::badbit | load.rdstate());
1255
1256   isOK = (load >> i);
1257   if (isOK)
1258     _physicalMesh = (PhysicalMesh) i;
1259   else
1260     load.clear(std::ios::badbit | load.rdstate());
1261
1262   isOK = (load >> i);
1263   if (isOK)
1264     _geometricMesh = (GeometricMesh) i;
1265   else
1266     load.clear(std::ios::badbit | load.rdstate());
1267
1268   isOK = (load >> val);
1269   if (isOK)
1270     _phySize = val;
1271   else
1272     load.clear(std::ios::badbit | load.rdstate());
1273
1274   isOK = (load >> val);
1275   if (isOK)
1276     _angleMeshS = val;
1277   else
1278     load.clear(std::ios::badbit | load.rdstate());
1279
1280   isOK = (load >> val);
1281   if (isOK)
1282     _gradation = val;
1283   else
1284     load.clear(std::ios::badbit | load.rdstate());
1285
1286   isOK = (load >> i);
1287   if (isOK)
1288     _quadAllowed = (bool) i;
1289   else
1290     load.clear(std::ios::badbit | load.rdstate());
1291
1292   isOK = (load >> i);
1293   if (isOK)
1294     _decimesh = (bool) i;
1295   else
1296     load.clear(std::ios::badbit | load.rdstate());
1297
1298   isOK = (load >> val);
1299   if (isOK)
1300     _phyMin = val;
1301   else
1302     load.clear(std::ios::badbit | load.rdstate());
1303
1304   isOK = (load >> val);
1305   if (isOK)
1306     _phyMax = val;
1307   else
1308     load.clear(std::ios::badbit | load.rdstate());
1309
1310   isOK = (load >> val);
1311   if (isOK)
1312     _angleMeshC = val;
1313   else
1314     load.clear(std::ios::badbit | load.rdstate());
1315
1316   isOK = (load >> val);
1317   if (isOK)
1318     _hgeoMin = val;
1319   else
1320     load.clear(std::ios::badbit | load.rdstate());
1321
1322   isOK = (load >> val);
1323   if (isOK)
1324     _hgeoMax = val;
1325   else
1326     load.clear(std::ios::badbit | load.rdstate());
1327
1328   isOK = (load >> i);
1329   if (isOK)
1330     _verb = i;
1331   else
1332     load.clear(std::ios::badbit | load.rdstate());
1333
1334   isOK = (load >> i);
1335   if (isOK)
1336     _preCADMergeEdges = (bool) i;
1337   else
1338     load.clear(std::ios::badbit | load.rdstate());
1339
1340   isOK = (load >> i);
1341   if (isOK)
1342     _preCADRemoveNanoEdges = (bool) i;
1343   else
1344     load.clear(std::ios::badbit | load.rdstate());
1345
1346   isOK = (load >> i);
1347   if (isOK)
1348     _preCADDiscardInput = (bool) i;
1349   else
1350     load.clear(std::ios::badbit | load.rdstate());
1351
1352   isOK = (load >> val);
1353   if (isOK)
1354     _preCADEpsNano = val;
1355   else
1356     load.clear(std::ios::badbit | load.rdstate());
1357
1358   std::string option_or_sm;
1359   bool hasOptions = false;
1360   bool hasPreCADOptions = false;
1361   bool hasSizeMap = false;
1362   bool hasAttractor = false;
1363   bool hasNewAttractor = false;
1364   bool hasEnforcedVertex = false;
1365
1366   isOK = (load >> option_or_sm);
1367   if (isOK)
1368     if (option_or_sm == "__OPTIONS_BEGIN__")
1369       hasOptions = true;
1370     else if (option_or_sm == "__PRECAD_OPTIONS_BEGIN__")
1371       hasPreCADOptions = true;
1372     else if (option_or_sm == "__SIZEMAP_BEGIN__")
1373       hasSizeMap = true;
1374     else if (option_or_sm == "__ATTRACTORS_BEGIN__")
1375       hasAttractor = true;
1376     else if (option_or_sm == "__NEW_ATTRACTORS_BEGIN__")
1377       hasNewAttractor = true;
1378     else if (option_or_sm == "__ENFORCED_VERTICES_BEGIN__")
1379       hasEnforcedVertex = true;
1380
1381   std::string optName, optValue;
1382   while (isOK && hasOptions) {
1383     isOK = (load >> optName);
1384     if (isOK) {
1385       if (optName == "__OPTIONS_END__")
1386         break;
1387       isOK = (load >> optValue);
1388     }
1389     if (isOK) {
1390       std::string & value = _option2value[optName];
1391       value = optValue;
1392       int len = value.size();
1393       // continue reading until "%#" encountered
1394       while (value[len - 1] != '#' || value[len - 2] != '%') {
1395         isOK = (load >> optValue);
1396         if (isOK) {
1397           value += " ";
1398           value += optValue;
1399           len = value.size();
1400         } else {
1401           break;
1402         }
1403       }
1404       value[len - 2] = '\0'; //cut off "%#"
1405     }
1406   }
1407
1408   if (hasOptions) {
1409     isOK = (load >> option_or_sm);
1410     if (isOK)
1411       if (option_or_sm == "__PRECAD_OPTIONS_BEGIN__")
1412         hasPreCADOptions = true;
1413       else if (option_or_sm == "__SIZEMAP_BEGIN__")
1414         hasSizeMap = true;
1415       else if (option_or_sm == "__ATTRACTORS_BEGIN__")
1416         hasAttractor = true;
1417       else if (option_or_sm == "__NEW_ATTRACTORS_BEGIN__")
1418         hasNewAttractor = true;
1419       else if (option_or_sm == "__ENFORCED_VERTICES_BEGIN__")
1420         hasEnforcedVertex = true;
1421   }
1422
1423   while (isOK && hasPreCADOptions) {
1424     isOK = (load >> optName);
1425     if (isOK) {
1426       if (optName == "__PRECAD_OPTIONS_END__")
1427         break;
1428       isOK = (load >> optValue);
1429     }
1430     if (isOK) {
1431       std::string & value = _preCADoption2value[optName];
1432       value = optValue;
1433       int len = value.size();
1434       // continue reading until "%#" encountered
1435       while (value[len - 1] != '#' || value[len - 2] != '%') {
1436         isOK = (load >> optValue);
1437         if (isOK) {
1438           value += " ";
1439           value += optValue;
1440           len = value.size();
1441         } else {
1442           break;
1443         }
1444       }
1445       value[len - 2] = '\0'; //cut off "%#"
1446     }
1447   }
1448
1449   if (hasPreCADOptions) {
1450     isOK = (load >> option_or_sm);
1451     if (isOK)
1452       if (option_or_sm == "__SIZEMAP_BEGIN__")
1453         hasSizeMap = true;
1454       else if (option_or_sm == "__ATTRACTORS_BEGIN__")
1455         hasAttractor = true;
1456       else if (option_or_sm == "__NEW_ATTRACTORS_BEGIN__")
1457         hasNewAttractor = true;
1458       else if (option_or_sm == "__ENFORCED_VERTICES_BEGIN__")
1459         hasEnforcedVertex = true;
1460   }
1461   
1462   std::string smEntry, smValue;
1463   while (isOK && hasSizeMap) {
1464     isOK = (load >> smEntry);
1465     if (isOK) {
1466       if (smEntry == "__SIZEMAP_END__")
1467         break;
1468       isOK = (load >> smValue);
1469     }
1470     if (isOK) {
1471       std::string & value2 = _sizeMap[smEntry];
1472       value2 = smValue;
1473       int len2 = value2.size();
1474       // continue reading until "%#" encountered
1475       while (value2[len2 - 1] != '#' || value2[len2 - 2] != '%') {
1476         isOK = (load >> smValue);
1477         if (isOK) {
1478           value2 += " ";
1479           value2 += smValue;
1480           len2 = value2.size();
1481         } else {
1482           break;
1483         }
1484       }
1485       value2[len2 - 2] = '\0'; //cut off "%#"
1486     }
1487   }
1488
1489   if (hasSizeMap) {
1490     isOK = (load >> option_or_sm);
1491     if (isOK)
1492       if (option_or_sm == "__ATTRACTORS_BEGIN__")
1493         hasAttractor = true;
1494       if (option_or_sm == "__NEW_ATTRACTORS_BEGIN__")
1495         hasNewAttractor = true;
1496       else if (option_or_sm == "__ENFORCED_VERTICES_BEGIN__")
1497         hasEnforcedVertex = true;
1498   }
1499
1500   std::string atEntry, atValue;
1501   while (isOK && hasAttractor) {
1502     isOK = (load >> atEntry);
1503     if (isOK) {
1504       if (atEntry == "__ATTRACTORS_END__")
1505         break;
1506       isOK = (load >> atValue);
1507     }
1508     if (isOK) {
1509       std::string & value3 = _attractors[atEntry];
1510       value3 = atValue;
1511       int len3 = value3.size();
1512       // continue reading until "%#" encountered
1513       while (value3[len3 - 1] != '#' || value3[len3 - 2] != '%') {
1514         isOK = (load >> atValue);
1515         if (isOK) {
1516           value3 += " ";
1517           value3 += atValue;
1518           len3 = value3.size();
1519         } else {
1520           break;
1521         }
1522       }
1523       value3[len3 - 2] = '\0'; //cut off "%#"
1524     }
1525   }
1526
1527   if (hasAttractor) {
1528     isOK = (load >> option_or_sm);
1529     if (isOK)
1530       if (option_or_sm == "__NEW_ATTRACTORS_BEGIN__")
1531         hasNewAttractor = true;
1532       else if (option_or_sm == "__ENFORCED_VERTICES_BEGIN__")
1533         hasEnforcedVertex = true;
1534   }
1535
1536   std::string newAtFaceEntry, atTestString;
1537   std::string newAtShapeEntry;
1538   double attParams[4];
1539   double step;
1540   while (isOK && hasNewAttractor) {
1541     std::cout<<"Load new attractor"<<std::endl;
1542     isOK = (load >> newAtFaceEntry);
1543     if (isOK) {
1544       if (newAtFaceEntry == "__NEW_ATTRACTORS_END__")
1545         break;
1546       isOK = (load >> newAtShapeEntry);
1547       if (!isOK)
1548     break;
1549       isOK = (load >> attParams[0]>>attParams[1]>>attParams[2]>>attParams[3]); //>>step);
1550     }
1551     if (isOK) {
1552       MESSAGE(" LOADING ATTRACTOR HYPOTHESIS ")
1553       const TopoDS_Shape attractorShape = BLSURFPlugin_Hypothesis::entryToShape(newAtShapeEntry);
1554       const TopoDS_Face faceShape = TopoDS::Face(BLSURFPlugin_Hypothesis::entryToShape(newAtFaceEntry));
1555       BLSURFPlugin_Attractor* attractor = new BLSURFPlugin_Attractor(faceShape, attractorShape, newAtShapeEntry);//, step);
1556       attractor->SetParameters(attParams[0], attParams[1], attParams[2], attParams[3]);
1557       attractor->BuildMap();                     
1558       _classAttractors[newAtFaceEntry]=attractor;
1559     }
1560   }
1561   
1562   
1563   if (hasNewAttractor) {
1564     isOK = (load >> option_or_sm);
1565     if (isOK)
1566       if (option_or_sm == "__ENFORCED_VERTICES_BEGIN__")
1567         hasEnforcedVertex = true;
1568   }
1569
1570
1571 // 
1572 // Here is a example of the saved stream:
1573 // __ENFORCED_VERTICES_BEGIN__ 
1574 // __BEGIN_VERTEX__  => no name, no entry
1575 // __BEGIN_GROUP__ mon groupe __END_GROUP__
1576 // __BEGIN_COORDS__ 10 10 10 __END_COORDS__ 
1577 // __BEGIN_FACELIST__ 0:1:1:1:1 __END_FACELIST__ 
1578 // __END_VERTEX__ 
1579 // __BEGIN_VERTEX__ => no coords
1580 // __BEGIN_NAME__ mes points __END_NAME__ 
1581 // __BEGIN_ENTRY__ 0:1:1:4 __END_ENTRY__
1582 // __BEGIN_GROUP__ mon groupe __END_GROUP__
1583 // __BEGIN_FACELIST__ 0:1:1:1:3 __END_FACELIST__
1584 // __END_VERTEX__ 
1585 // __ENFORCED_VERTICES_END__
1586 // 
1587
1588   std::string enfSeparator;
1589   std::string enfName;
1590   std::string enfGeomEntry;
1591   std::string enfGroup;
1592   TEntryList enfFaceEntryList;
1593   double enfCoords[3];
1594   bool hasCoords = false;
1595   
1596   _faceEntryEnfVertexListMap.clear();
1597   _enfVertexList.clear();
1598   _faceEntryCoordsListMap.clear();
1599   _coordsEnfVertexMap.clear();
1600   _faceEntryEnfVertexEntryListMap.clear();
1601   _enfVertexEntryEnfVertexMap.clear();
1602   
1603   
1604   while (isOK && hasEnforcedVertex) {
1605     isOK = (load >> enfSeparator); // __BEGIN_VERTEX__
1606     TEnfVertex *enfVertex = new TEnfVertex();
1607 //     MESSAGE("enfSeparator: " <<enfSeparator);
1608     if (enfSeparator == "__ENFORCED_VERTICES_END__")
1609       break; // __ENFORCED_VERTICES_END__
1610     if (enfSeparator != "__BEGIN_VERTEX__")
1611       throw std::exception();
1612     
1613     while (isOK) {
1614       isOK = (load >> enfSeparator);
1615       MESSAGE("enfSeparator: " <<enfSeparator);
1616       if (enfSeparator == "__END_VERTEX__") {
1617         
1618         enfVertex->name = enfName;
1619         enfVertex->geomEntry = enfGeomEntry;
1620         enfVertex->grpName = enfGroup;
1621         enfVertex->coords.clear();
1622         if (hasCoords)
1623           enfVertex->coords.assign(enfCoords,enfCoords+3);
1624         enfVertex->faceEntries = enfFaceEntryList;
1625         
1626         _enfVertexList.insert(enfVertex);
1627         
1628         if (enfVertex->coords.size()) {
1629           _coordsEnfVertexMap[enfVertex->coords] = enfVertex;
1630           for (TEntryList::const_iterator it = enfVertex->faceEntries.begin() ; it != enfVertex->faceEntries.end(); ++it) {
1631             _faceEntryCoordsListMap[(*it)].insert(enfVertex->coords);
1632             _faceEntryEnfVertexListMap[(*it)].insert(enfVertex);
1633           }
1634         }
1635         if (!enfVertex->geomEntry.empty()) {
1636           _enfVertexEntryEnfVertexMap[enfVertex->geomEntry] = enfVertex;
1637           for (TEntryList::const_iterator it = enfVertex->faceEntries.begin() ; it != enfVertex->faceEntries.end(); ++it) {
1638             _faceEntryEnfVertexEntryListMap[(*it)].insert(enfVertex->geomEntry);
1639             _faceEntryEnfVertexListMap[(*it)].insert(enfVertex);
1640           }
1641         }
1642         
1643         enfName.clear();
1644         enfGeomEntry.clear();
1645         enfGroup.clear();
1646         enfFaceEntryList.clear();
1647         hasCoords = false;
1648         break; // __END_VERTEX__
1649       }
1650         
1651       if (enfSeparator == "__BEGIN_NAME__") {  // __BEGIN_NAME__
1652         while (isOK && (enfSeparator != "__END_NAME__")) {
1653           isOK = (load >> enfSeparator);
1654           if (enfSeparator != "__END_NAME__") {
1655             if (!enfName.empty())
1656               enfName += " ";
1657             enfName += enfSeparator;
1658           }
1659         }
1660         MESSAGE("enfName: " <<enfName);
1661       }
1662         
1663       if (enfSeparator == "__BEGIN_ENTRY__") {  // __BEGIN_ENTRY__
1664         isOK = (load >> enfGeomEntry);
1665         isOK = (load >> enfSeparator); // __END_ENTRY__
1666         if (enfSeparator != "__END_ENTRY__")
1667           throw std::exception();
1668         MESSAGE("enfGeomEntry: " <<enfGeomEntry);
1669       }
1670         
1671       if (enfSeparator == "__BEGIN_GROUP__") {  // __BEGIN_GROUP__
1672         while (isOK && (enfSeparator != "__END_GROUP__")) {
1673           isOK = (load >> enfSeparator);
1674           if (enfSeparator != "__END_GROUP__") {
1675             if (!enfGroup.empty())
1676               enfGroup += " ";
1677             enfGroup += enfSeparator;
1678           }
1679         }
1680         MESSAGE("enfGroup: " <<enfGroup);
1681       }
1682         
1683       if (enfSeparator == "__BEGIN_COORDS__") {  // __BEGIN_COORDS__
1684         hasCoords = true;
1685         isOK = (load >> enfCoords[0] >> enfCoords[1] >> enfCoords[2]);
1686         isOK = (load >> enfSeparator); // __END_COORDS__
1687         if (enfSeparator != "__END_COORDS__")
1688           throw std::exception();
1689         MESSAGE("enfCoords: " << enfCoords[0] <<","<< enfCoords[1] <<","<< enfCoords[2]);
1690       } 
1691         
1692       if (enfSeparator == "__BEGIN_FACELIST__") {  // __BEGIN_FACELIST__
1693         while (isOK && (enfSeparator != "__END_FACELIST__")) {
1694           isOK = (load >> enfSeparator);
1695           if (enfSeparator != "__END_FACELIST__") {
1696             enfFaceEntryList.insert(enfSeparator);
1697             MESSAGE(enfSeparator << " was inserted into enfFaceEntryList");
1698           }
1699         }
1700       } 
1701     }
1702   }
1703
1704   return load;
1705 }
1706
1707 //=============================================================================
1708 std::ostream & operator <<(std::ostream & save, BLSURFPlugin_Hypothesis & hyp) {
1709   return hyp.SaveTo(save);
1710 }
1711
1712 //=============================================================================
1713 std::istream & operator >>(std::istream & load, BLSURFPlugin_Hypothesis & hyp) {
1714   return hyp.LoadFrom(load);
1715 }
1716
1717 //================================================================================
1718 /*!
1719  * \brief Does nothing
1720  */
1721 //================================================================================
1722
1723 bool BLSURFPlugin_Hypothesis::SetParametersByMesh(const SMESH_Mesh* theMesh, const TopoDS_Shape& theShape) {
1724   return false;
1725 }
1726
1727 //=============================================================================
1728 /*!
1729  * \brief Initialize my parameter values by default parameters.
1730  *  \retval bool - true if parameter values have been successfully defined
1731  */
1732 //=============================================================================
1733
1734 bool BLSURFPlugin_Hypothesis::SetParametersByDefaults(const TDefaults& dflts, const SMESH_Mesh* theMesh) {
1735   return bool(_phySize = dflts._elemLength);
1736 }
1737
1738 //=============================================================================
1739 BLSURFPlugin_Hypothesis::Topology BLSURFPlugin_Hypothesis::GetDefaultTopology() {
1740   return FromCAD;
1741 }
1742
1743 //=============================================================================
1744 BLSURFPlugin_Hypothesis::PhysicalMesh BLSURFPlugin_Hypothesis::GetDefaultPhysicalMesh() {
1745   return PhysicalUserDefined;
1746 }
1747
1748 //=============================================================================
1749 double BLSURFPlugin_Hypothesis::GetDefaultPhySize() {
1750   return 10;
1751 }
1752
1753 //======================================================================
1754 double BLSURFPlugin_Hypothesis::GetDefaultMaxSize() {
1755   return undefinedDouble(); // 1e+4;
1756 }
1757
1758 //======================================================================
1759 double BLSURFPlugin_Hypothesis::GetDefaultMinSize() {
1760   return undefinedDouble(); //1e-4;
1761 }
1762
1763 //======================================================================
1764 BLSURFPlugin_Hypothesis::GeometricMesh BLSURFPlugin_Hypothesis::GetDefaultGeometricMesh() {
1765   return DefaultGeom;
1766 }
1767
1768 //=============================================================================
1769 double BLSURFPlugin_Hypothesis::GetDefaultAngleMeshS() {
1770   return 8;
1771 }
1772
1773 //=============================================================================
1774 double BLSURFPlugin_Hypothesis::GetDefaultGradation() {
1775   return 1.1;
1776 }
1777
1778 //=============================================================================
1779 bool BLSURFPlugin_Hypothesis::GetDefaultQuadAllowed() {
1780   return false;
1781 }
1782
1783 //=============================================================================
1784 bool BLSURFPlugin_Hypothesis::GetDefaultDecimesh() {
1785   return false;
1786 }
1787
1788 //======================================================================
1789 double BLSURFPlugin_Hypothesis::GetDefaultPreCADEpsNano() {
1790   return undefinedDouble(); //1e-4;
1791 }
1792
1793 //======================================================================
1794 std::string BLSURFPlugin_Hypothesis::GetDefaultGMFFile() {
1795   return "";
1796 }
1797
1798 //=============================================================================
1799 bool BLSURFPlugin_Hypothesis::GetDefaultInternalEnforcedVertex() {
1800   return false;
1801 }
1802