1 // Copyright (C) 2007-2016 CEA/DEN, EDF R&D
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, or (at your option) any later version.
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.
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
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
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)
27 #include "BLSURFPlugin_Hypothesis.hxx"
28 #include "BLSURFPlugin_Attractor.hxx"
29 #include "SMESH_Gen_i.hxx"
30 #include <utilities.h>
36 #include "ShapeAnalysis.hxx"
39 #include CORBA_CLIENT_HEADER(SALOMEDS)
40 #include CORBA_CLIENT_HEADER(GEOM_Gen)
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 _maxSize(GetDefaultMaxSize()),
51 _minSizeRel(GetDefaultMinSizeRel()),
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 _preCADRemoveTinyUVEdges(GetDefaultPreCADRemoveTinyUVEdges()),
69 _preCADRemoveDuplicateCADFaces(GetDefaultPreCADRemoveDuplicateCADFaces()),
70 _preCADProcess3DTopology(GetDefaultPreCADProcess3DTopology()),
71 _preCADDiscardInput(GetDefaultPreCADDiscardInput()),
72 _sizeMap(GetDefaultSizeMap()),
73 _attractors(GetDefaultSizeMap()),
74 _classAttractors(GetDefaultAttractorMap()),
75 _faceEntryEnfVertexListMap(GetDefaultFaceEntryEnfVertexListMap()),
76 _enfVertexList(GetDefaultEnfVertexList()),
77 _faceEntryCoordsListMap(GetDefaultFaceEntryCoordsListMap()),
78 _coordsEnfVertexMap(GetDefaultCoordsEnfVertexMap()),
79 _faceEntryEnfVertexEntryListMap(GetDefaultFaceEntryEnfVertexEntryListMap()),
80 _enfVertexEntryEnfVertexMap(GetDefaultEnfVertexEntryEnfVertexMap()),
81 _groupNameNodeIDMap(GetDefaultGroupNameNodeIDMap()),
82 _enforcedInternalVerticesAllFaces(GetDefaultInternalEnforcedVertex()),
83 _preCadFacesPeriodicityVector(GetDefaultPreCadFacesPeriodicityVector()),
84 _preCadEdgesPeriodicityVector(GetDefaultPreCadEdgesPeriodicityVector()),
85 _GMFFileName(GetDefaultGMFFile())
90 // _GMFFileMode = false; // GMF ascii mode
92 const char* boolOptionNames[] = { "correct_surface_intersections", // default = 1
93 "create_tag_on_collision", // default = 1
94 "debug", // default = 0
95 "enforce_cad_edge_sizes", // default = 0
96 "frontal", // ok default = 1
97 "jacobian_rectification_respect_geometry", // default = 1
98 "proximity", // default = 0
99 "rectify_jacobian", // default = 1
100 "respect_geometry", // default = 1
101 "optimise_tiny_edges", // default = 0
102 "tiny_edge_avoid_surface_intersections", // default = 1
103 "tiny_edge_respect_geometry", // default = 0
107 const char* intOptionNames[] = { "hinterpol_flag", // ok default = 0
108 "hmean_flag", // ok default = 0
109 "max_number_of_points_per_patch", // default = 100000
110 "prox_nb_layer", // detects the volumic proximity of surfaces
113 const char* doubleOptionNames[] = { "surface_intersections_processing_max_cost",// default = 15
114 "periodic_tolerance", // default = diag/100
117 "tiny_edge_optimisation_length", // default = diag * 1e-6
120 const char* charOptionNames[] = { "required_entities", // default = "respect"
121 "tags", // default = "respect"
125 // PreCAD advanced options
126 const char* preCADboolOptionNames[] = { "closed_geometry", // default = 0
127 "create_tag_on_collision", // default = 1
128 "debug", // default = 0
129 "remove_tiny_edges", // default = 0
132 const char* preCADintOptionNames[] = { "manifold_geometry", // default = 0
135 const char* preCADdoubleOptionNames[] = { "periodic_tolerance", // default = diag * 1e-5
136 "sewing_tolerance", // default = diag * 5e-4
137 "tiny_edge_length", // default = diag * 1e-5
140 const char* preCADcharOptionNames[] = { "required_entities", // default = "respect"
141 "tags", // default = "respect"
146 while (boolOptionNames[i][0])
147 _option2value[boolOptionNames[i++]].clear();
150 while (preCADboolOptionNames[i][0])
151 _preCADoption2value[preCADboolOptionNames[i++]].clear();
154 while (intOptionNames[i][0])
155 _option2value[intOptionNames[i++]].clear();
158 while (preCADintOptionNames[i][0])
159 _preCADoption2value[preCADintOptionNames[i++]].clear();
162 while (doubleOptionNames[i][0]) {
163 _doubleOptions.insert(doubleOptionNames[i]);
164 _option2value[doubleOptionNames[i++]].clear();
167 while (preCADdoubleOptionNames[i][0]) {
168 _preCADdoubleOptions.insert(preCADdoubleOptionNames[i]);
169 _preCADoption2value[preCADdoubleOptionNames[i++]].clear();
172 while (charOptionNames[i][0]) {
173 _charOptions.insert(charOptionNames[i]);
174 _option2value[charOptionNames[i++]].clear();
177 while (preCADcharOptionNames[i][0]) {
178 _preCADcharOptions.insert(preCADcharOptionNames[i]);
179 _preCADoption2value[preCADcharOptionNames[i++]].clear();
186 _faceEntryEnfVertexListMap.clear();
187 _enfVertexList.clear();
188 _faceEntryCoordsListMap.clear();
189 _coordsEnfVertexMap.clear();
190 _faceEntryEnfVertexEntryListMap.clear();
191 _enfVertexEntryEnfVertexMap.clear();
192 _groupNameNodeIDMap.clear();
195 _groupNameEnfVertexListMap.clear();
196 _enfVertexGroupNameMap.clear();
200 TopoDS_Shape BLSURFPlugin_Hypothesis::entryToShape(std::string entry)
202 MESSAGE("BLSURFPlugin_Hypothesis::entryToShape "<<entry );
203 GEOM::GEOM_Object_var aGeomObj;
204 SMESH_Gen_i* smeshGen_i = SMESH_Gen_i::GetSMESHGen();
205 SALOMEDS::Study_ptr myStudy = smeshGen_i->GetCurrentStudy();
207 TopoDS_Shape S = TopoDS_Shape();
208 SALOMEDS::SObject_var aSObj = myStudy->FindObjectID( entry.c_str() );
209 if (!aSObj->_is_nil() ) {
210 CORBA::Object_var obj = aSObj->GetObject();
211 aGeomObj = GEOM::GEOM_Object::_narrow(obj);
214 if ( !aGeomObj->_is_nil() )
215 S = smeshGen_i->GeomObjectToShape( aGeomObj.in() );
219 //=============================================================================
220 void BLSURFPlugin_Hypothesis::SetPhysicalMesh(PhysicalMesh thePhysicalMesh) {
221 if (thePhysicalMesh != _physicalMesh) {
222 _physicalMesh = thePhysicalMesh;
223 NotifySubMeshesHypothesisModification();
227 //=============================================================================
228 void BLSURFPlugin_Hypothesis::SetGeometricMesh(GeometricMesh theGeometricMesh) {
229 if (theGeometricMesh != _geometricMesh) {
230 _geometricMesh = theGeometricMesh;
231 // switch (_geometricMesh) {
234 // _angleMesh = GetDefaultAngleMesh();
235 // _gradation = GetDefaultGradation();
238 NotifySubMeshesHypothesisModification();
242 //=============================================================================
243 void BLSURFPlugin_Hypothesis::SetPhySize(double theVal, bool isRelative) {
244 if ((theVal != _phySize) || (isRelative != _phySizeRel)) {
245 _phySizeRel = isRelative;
247 _phySize = GetMaxSize();
248 MESSAGE("Warning: nul physical size is not allowed");
252 NotifySubMeshesHypothesisModification();
256 //=============================================================================
257 void BLSURFPlugin_Hypothesis::SetMinSize(double theMinSize, bool isRelative) {
258 if ((theMinSize != _minSize) || (isRelative != _minSizeRel)) {
259 _minSizeRel = isRelative;
260 _minSize = theMinSize;
261 NotifySubMeshesHypothesisModification();
265 //=============================================================================
266 void BLSURFPlugin_Hypothesis::SetMaxSize(double theMaxSize, bool isRelative) {
267 if ((theMaxSize != _maxSize) || (isRelative != _maxSizeRel)) {
268 _maxSizeRel = isRelative;
269 _maxSize = theMaxSize;
270 NotifySubMeshesHypothesisModification();
274 //=============================================================================
275 void BLSURFPlugin_Hypothesis::SetGradation(double theVal) {
276 if (theVal != _gradation) {
278 NotifySubMeshesHypothesisModification();
282 //=============================================================================
283 void BLSURFPlugin_Hypothesis::SetQuadAllowed(bool theVal) {
284 if (theVal != _quadAllowed) {
285 _quadAllowed = theVal;
286 NotifySubMeshesHypothesisModification();
290 //=============================================================================
291 void BLSURFPlugin_Hypothesis::SetAngleMesh(double theVal) {
292 if (theVal != _angleMesh) {
294 NotifySubMeshesHypothesisModification();
298 //=============================================================================
299 void BLSURFPlugin_Hypothesis::SetChordalError(double theDistance) {
300 if (theDistance != _chordalError) {
301 _chordalError = theDistance;
302 NotifySubMeshesHypothesisModification();
306 //=============================================================================
307 void BLSURFPlugin_Hypothesis::SetAnisotropic(bool theVal) {
308 if (theVal != _anisotropic) {
309 _anisotropic = theVal;
310 NotifySubMeshesHypothesisModification();
314 //=============================================================================
315 void BLSURFPlugin_Hypothesis::SetAnisotropicRatio(double theVal) {
316 if (theVal != _anisotropicRatio) {
317 _anisotropicRatio = theVal;
318 NotifySubMeshesHypothesisModification();
322 //=============================================================================
323 void BLSURFPlugin_Hypothesis::SetRemoveTinyEdges(bool theVal) {
324 if (theVal != _removeTinyEdges) {
325 _removeTinyEdges = theVal;
326 NotifySubMeshesHypothesisModification();
330 //=============================================================================
331 void BLSURFPlugin_Hypothesis::SetTinyEdgeLength(double theVal) {
332 if (theVal != _tinyEdgeLength) {
333 _tinyEdgeLength = theVal;
334 NotifySubMeshesHypothesisModification();
338 //=============================================================================
339 void BLSURFPlugin_Hypothesis::SetBadElementRemoval(bool theVal) {
340 if (theVal != _badElementRemoval) {
341 _badElementRemoval = theVal;
342 NotifySubMeshesHypothesisModification();
346 //=============================================================================
347 void BLSURFPlugin_Hypothesis::SetBadElementAspectRatio(double theVal) {
348 if (theVal != _badElementAspectRatio) {
349 _badElementAspectRatio = theVal;
350 NotifySubMeshesHypothesisModification();
354 //=============================================================================
355 void BLSURFPlugin_Hypothesis::SetOptimizeMesh(bool theVal) {
356 if (theVal != _optimizeMesh) {
357 _optimizeMesh = theVal;
358 NotifySubMeshesHypothesisModification();
362 //=============================================================================
363 void BLSURFPlugin_Hypothesis::SetQuadraticMesh(bool theVal) {
364 if (theVal != _quadraticMesh) {
365 _quadraticMesh = theVal;
366 NotifySubMeshesHypothesisModification();
370 //=============================================================================
371 void BLSURFPlugin_Hypothesis::SetTopology(Topology theTopology) {
372 if (theTopology != _topology) {
373 _topology = theTopology;
374 NotifySubMeshesHypothesisModification();
378 //=============================================================================
379 void BLSURFPlugin_Hypothesis::SetVerbosity(int theVal) {
380 if (theVal != _verb) {
382 NotifySubMeshesHypothesisModification();
386 //=============================================================================
387 void BLSURFPlugin_Hypothesis::SetPreCADMergeEdges(bool theVal) {
388 if (theVal != _preCADMergeEdges) {
389 // SetTopology(PreCAD);
390 _preCADMergeEdges = theVal;
391 NotifySubMeshesHypothesisModification();
395 //=============================================================================
396 void BLSURFPlugin_Hypothesis::SetPreCADRemoveTinyUVEdges(bool theVal) {
397 if (theVal != _preCADRemoveTinyUVEdges) {
398 // SetTopology(PreCAD);
399 _preCADRemoveTinyUVEdges = theVal;
400 NotifySubMeshesHypothesisModification();
404 //=============================================================================
405 void BLSURFPlugin_Hypothesis::SetPreCADRemoveDuplicateCADFaces(bool theVal) {
406 if (theVal != _preCADRemoveDuplicateCADFaces) {
407 // SetTopology(PreCAD);
408 _preCADRemoveDuplicateCADFaces = theVal;
409 NotifySubMeshesHypothesisModification();
413 //=============================================================================
414 void BLSURFPlugin_Hypothesis::SetPreCADProcess3DTopology(bool theVal) {
415 if (theVal != _preCADProcess3DTopology) {
416 // SetTopology(PreCAD);
417 _preCADProcess3DTopology = theVal;
418 NotifySubMeshesHypothesisModification();
422 //=============================================================================
423 void BLSURFPlugin_Hypothesis::SetPreCADDiscardInput(bool theVal) {
424 if (theVal != _preCADDiscardInput) {
425 // SetTopology(PreCAD);
426 _preCADDiscardInput = theVal;
427 NotifySubMeshesHypothesisModification();
431 //=============================================================================
432 // void BLSURFPlugin_Hypothesis::SetGMFFile(const std::string& theFileName, bool isBinary)
433 void BLSURFPlugin_Hypothesis::SetGMFFile(const std::string& theFileName)
435 _GMFFileName = theFileName;
436 // _GMFFileMode = isBinary;
437 NotifySubMeshesHypothesisModification();
440 //=============================================================================
441 void BLSURFPlugin_Hypothesis::SetOptionValue(const std::string& optionName, const std::string& optionValue)
442 throw (std::invalid_argument) {
443 TOptionValues::iterator op_val = _option2value.find(optionName);
444 if (op_val == _option2value.end()) {
445 std::string msg = "Unknown MG-CADSurf option: '" + optionName + "'";
446 throw std::invalid_argument(msg);
448 if (op_val->second != optionValue) {
449 const char* ptr = optionValue.c_str();
450 // strip white spaces
451 while (ptr[0] == ' ')
454 while (i != 0 && ptr[i - 1] == ' ')
458 std::string typeName;
461 } else if (_charOptions.find(optionName) != _charOptions.end()) {
462 // do not check strings
463 } else if (_doubleOptions.find(optionName) != _doubleOptions.end()) {
464 // check if value is double
466 strtod(ptr, &endPtr);
467 typeOk = (ptr != endPtr);
470 // check if value is int
472 strtol(ptr, &endPtr, 10);
473 typeOk = (ptr != endPtr);
474 typeName = "integer";
477 std::string msg = "Advanced option '" + optionName + "' = '" + optionValue + "' but must be " + typeName;
478 throw std::invalid_argument(msg);
480 op_val->second = optionValue;
481 NotifySubMeshesHypothesisModification();
485 //=============================================================================
486 void BLSURFPlugin_Hypothesis::SetPreCADOptionValue(const std::string& optionName, const std::string& optionValue)
487 throw (std::invalid_argument) {
488 TOptionValues::iterator op_val = _preCADoption2value.find(optionName);
489 if (op_val == _preCADoption2value.end()) {
490 std::string msg = "Unknown MG-CADSurf option: '" + optionName + "'";
491 throw std::invalid_argument(msg);
493 if (op_val->second != optionValue) {
494 const char* ptr = optionValue.c_str();
495 // strip white spaces
496 while (ptr[0] == ' ')
499 while (i != 0 && ptr[i - 1] == ' ')
503 std::string typeName;
506 } else if (_preCADcharOptions.find(optionName) != _preCADcharOptions.end()) {
507 // do not check strings
508 } else if (_preCADdoubleOptions.find(optionName) != _preCADdoubleOptions.end()) {
509 // check if value is double
511 strtod(ptr, &endPtr);
512 typeOk = (ptr != endPtr);
515 // check if value is int
517 strtol(ptr, &endPtr, 10);
518 typeOk = (ptr != endPtr);
519 typeName = "integer";
522 std::string msg = "PreCAD advanced option '" + optionName + "' = '" + optionValue + "' but must be " + typeName;
523 throw std::invalid_argument(msg);
525 op_val->second = optionValue;
526 NotifySubMeshesHypothesisModification();
530 //=============================================================================
531 std::string BLSURFPlugin_Hypothesis::GetOptionValue(const std::string& optionName) throw (std::invalid_argument) {
532 TOptionValues::iterator op_val = _option2value.find(optionName);
533 if (op_val == _option2value.end()) {
534 std::string msg = "Unknown MG-CADSurf option: <";
535 msg += optionName + ">";
536 throw std::invalid_argument(msg);
538 return op_val->second;
541 //=============================================================================
542 std::string BLSURFPlugin_Hypothesis::GetPreCADOptionValue(const std::string& optionName) throw (std::invalid_argument) {
543 TOptionValues::iterator op_val = _preCADoption2value.find(optionName);
544 if (op_val == _preCADoption2value.end()) {
545 std::string msg = "Unknown PRECAD option: <";
546 msg += optionName + ">";
547 throw std::invalid_argument(msg);
549 return op_val->second;
552 //=============================================================================
553 void BLSURFPlugin_Hypothesis::ClearOption(const std::string& optionName) {
554 TOptionValues::iterator op_val = _customOption2value.find(optionName);
555 if (op_val != _customOption2value.end())
556 _customOption2value.erase(op_val);
558 op_val = _option2value.find(optionName);
559 if (op_val != _option2value.end())
560 op_val->second.clear();
564 //=============================================================================
565 void BLSURFPlugin_Hypothesis::ClearPreCADOption(const std::string& optionName) {
566 TOptionValues::iterator op_val = _customPreCADOption2value.find(optionName);
567 if (op_val != _customPreCADOption2value.end())
568 _customPreCADOption2value.erase(op_val);
570 op_val = _preCADoption2value.find(optionName);
571 if (op_val != _preCADoption2value.end())
572 op_val->second.clear();
576 //=============================================================================
577 void BLSURFPlugin_Hypothesis::AddOption(const std::string& optionName, const std::string& optionValue)
579 TOptionValues::iterator op_val = _option2value.find(optionName);
580 if (op_val != _option2value.end()) {
581 if (op_val->second != optionValue)
582 op_val->second = optionValue;
585 op_val = _customOption2value.find(optionName);
586 if (op_val == _customOption2value.end())
587 _customOption2value[optionName] = optionValue;
588 else if (op_val->second != optionValue)
589 op_val->second = optionValue;
591 NotifySubMeshesHypothesisModification();
594 //=============================================================================
595 void BLSURFPlugin_Hypothesis::AddPreCADOption(const std::string& optionName, const std::string& optionValue)
597 TOptionValues::iterator op_val = _preCADoption2value.find(optionName);
598 if (op_val != _preCADoption2value.end()) {
599 if (op_val->second != optionValue)
600 op_val->second = optionValue;
603 op_val = _customPreCADOption2value.find(optionName);
604 if (op_val == _customPreCADOption2value.end())
605 _customPreCADOption2value[optionName] = optionValue;
606 else if (op_val->second != optionValue)
607 op_val->second = optionValue;
609 NotifySubMeshesHypothesisModification();
612 //=============================================================================
613 std::string BLSURFPlugin_Hypothesis::GetOption(const std::string& optionName)
615 TOptionValues::iterator op_val = _customOption2value.find(optionName);
616 if (op_val != _customOption2value.end())
617 return op_val->second;
622 //=============================================================================
623 std::string BLSURFPlugin_Hypothesis::GetPreCADOption(const std::string& optionName)
625 TOptionValues::iterator op_val = _customPreCADOption2value.find(optionName);
626 if (op_val != _customPreCADOption2value.end())
627 return op_val->second;
632 //=======================================================================
633 //function : SetSizeMapEntry
634 //=======================================================================
635 void BLSURFPlugin_Hypothesis::SetSizeMapEntry(const std::string& entry, const std::string& sizeMap) {
636 if (_sizeMap[entry].compare(sizeMap) != 0) {
637 SetPhysicalMesh(PhysicalLocalSize);
638 _sizeMap[entry] = sizeMap;
639 NotifySubMeshesHypothesisModification();
643 //=======================================================================
644 //function : GetSizeMapEntry
645 //=======================================================================
646 std::string BLSURFPlugin_Hypothesis::GetSizeMapEntry(const std::string& entry) {
647 TSizeMap::iterator it = _sizeMap.find(entry);
648 if (it != _sizeMap.end())
651 return "No_Such_Entry";
655 * \brief Return the size maps
657 BLSURFPlugin_Hypothesis::TSizeMap BLSURFPlugin_Hypothesis::GetSizeMapEntries(const BLSURFPlugin_Hypothesis* hyp) {
658 return hyp ? hyp->_GetSizeMapEntries() : GetDefaultSizeMap();
661 //=======================================================================
662 //function : SetAttractorEntry
663 //=======================================================================
664 void BLSURFPlugin_Hypothesis::SetAttractorEntry(const std::string& entry, const std::string& attractor) {
665 if (_attractors[entry].compare(attractor) != 0) {
666 SetPhysicalMesh(PhysicalLocalSize);
667 _attractors[entry] = attractor;
668 NotifySubMeshesHypothesisModification();
672 //=======================================================================
673 //function : GetAttractorEntry
674 //=======================================================================
675 std::string BLSURFPlugin_Hypothesis::GetAttractorEntry(const std::string& entry) {
676 TSizeMap::iterator it = _attractors.find(entry);
677 if (it != _attractors.end())
680 return "No_Such_Entry";
684 * \brief Return the attractors
686 BLSURFPlugin_Hypothesis::TSizeMap BLSURFPlugin_Hypothesis::GetAttractorEntries(const BLSURFPlugin_Hypothesis* hyp) {
687 return hyp ? hyp->_GetAttractorEntries() : GetDefaultSizeMap();
690 //=======================================================================
691 //function : SetClassAttractorEntry
692 //=======================================================================
693 void BLSURFPlugin_Hypothesis::SetClassAttractorEntry(const std::string& entry, const std::string& attEntry, double StartSize, double EndSize, double ActionRadius, double ConstantRadius)
695 SetPhysicalMesh(PhysicalLocalSize);
697 // The new attractor can't be defined on the same face as another sizemap
698 TSizeMap::iterator it = _sizeMap.find( entry );
699 if ( it != _sizeMap.end() ) {
701 NotifySubMeshesHypothesisModification();
704 TSizeMap::iterator itAt = _attractors.find( entry );
705 if ( itAt != _attractors.end() ) {
706 _attractors.erase(itAt);
707 NotifySubMeshesHypothesisModification();
711 const TopoDS_Shape AttractorShape = BLSURFPlugin_Hypothesis::entryToShape(attEntry);
712 const TopoDS_Face FaceShape = TopoDS::Face(BLSURFPlugin_Hypothesis::entryToShape(entry));
713 TAttractorMap::iterator attIt = _classAttractors.find(entry);
714 for ( ; attIt != _classAttractors.end(); ++attIt )
715 if ( attIt->first == entry &&
716 attIt->second->GetAttractorEntry() == attEntry )
718 bool attExists = (attIt != _classAttractors.end());
720 BLSURFPlugin_Attractor* myAttractor;
722 myAttractor = new BLSURFPlugin_Attractor(FaceShape, AttractorShape, attEntry);//, 0.1 );
723 _classAttractors.insert( make_pair( entry, myAttractor ));
726 myAttractor = attIt->second;
728 // if (!myAttractor->IsMapBuilt())
729 // myAttractor->BuildMap();
730 myAttractor->SetParameters(StartSize, EndSize, ActionRadius, ConstantRadius);
732 NotifySubMeshesHypothesisModification();
735 //=======================================================================
736 //function : SetConstantSizeOnAdjacentFaces
737 //=======================================================================
738 // TODO uncomment and test (include the needed .hxx)
739 // SetConstantSizeOnAdjacentFaces(myShape, att_entry, startSize, endSize = user_size, const_dist ) {
740 // TopTools_IndexedMapOfShapListOdShape anEdge2FaceMap;
741 // TopExp::MapShapesAnAncestors(myShape,TopAbs_EDGE, TopAbs_FACE, anEdge2FaceMap);
742 // TopTools_IndexedMapOfShapListOdShape::iterator it;
743 // for (it = anEdge2FaceMap.begin();it != anEdge2FaceMap.end();it++){
744 // SetClassAttractorEntry((*it).first, att_entry, startSize, endSize, 0, const_dist)
752 //=======================================================================
753 //function : GetClassAttractorEntry
754 //=======================================================================
755 // BLSURFPlugin_Attractor& BLSURFPlugin_Hypothesis::GetClassAttractorEntry(const std::string& entry)
757 // TAttractorMap::iterator it = _classAttractors.find( entry );
758 // if ( it != _classAttractors.end() )
759 // return it->second;
761 // return "No_Such_Entry";
765 * \brief Return the map of attractor instances
767 BLSURFPlugin_Hypothesis::TAttractorMap BLSURFPlugin_Hypothesis::GetClassAttractorEntries(const BLSURFPlugin_Hypothesis* hyp)
769 return hyp ? hyp->_GetClassAttractorEntries():GetDefaultAttractorMap();
772 //=======================================================================
773 //function : ClearEntry
774 //=======================================================================
775 void BLSURFPlugin_Hypothesis::ClearEntry(const std::string& entry,
776 const char * attEntry/*=0*/)
778 TSizeMap::iterator it = _sizeMap.find( entry );
780 if ( it != _sizeMap.end() ) {
782 NotifySubMeshesHypothesisModification();
785 TSizeMap::iterator itAt = _attractors.find( entry );
786 if ( itAt != _attractors.end() ) {
787 _attractors.erase(itAt);
788 NotifySubMeshesHypothesisModification();
791 TAttractorMap::iterator it_clAt = _classAttractors.find( entry );
792 if ( it_clAt != _classAttractors.end() ) {
794 if ( !attEntry || it_clAt->second->GetAttractorEntry() == attEntry )
795 _classAttractors.erase( it_clAt++ );
799 while ( it_clAt != _classAttractors.end() );
800 MESSAGE("_classAttractors.size() = "<<_classAttractors.size())
801 NotifySubMeshesHypothesisModification();
804 std::cout<<"No_Such_Entry"<<std::endl;
809 //=======================================================================
810 //function : ClearSizeMaps
811 //=======================================================================
812 void BLSURFPlugin_Hypothesis::ClearSizeMaps() {
815 _classAttractors.clear();
818 // Enable internal enforced vertices on specific face if requested by user
820 ////=======================================================================
821 ////function : SetInternalEnforcedVertex
822 ////=======================================================================
823 //void BLSURFPlugin_Hypothesis::SetInternalEnforcedVertex(TEntry theFaceEntry,
824 // bool toEnforceInternalVertices,
825 // TEnfGroupName theGroupName) {
827 // MESSAGE("BLSURFPlugin_Hypothesis::SetInternalEnforcedVertex("<< theFaceEntry << ", "
828 // << toEnforceInternalVertices << ", " << theGroupName << ")");
830 // TFaceEntryInternalVerticesList::iterator it = _faceEntryInternalVerticesList.find(theFaceEntry);
831 // if (it != _faceEntryInternalVerticesList.end()) {
832 // if (!toEnforceInternalVertices) {
833 // _faceEntryInternalVerticesList.erase(it);
837 // if (toEnforceInternalVertices) {
838 // _faceEntryInternalVerticesList.insert(theFaceEntry);
843 // // Take care of groups
847 //=======================================================================
848 //function : SetEnforcedVertex
849 //=======================================================================
850 bool BLSURFPlugin_Hypothesis::SetEnforcedVertex(TEntry theFaceEntry, TEnfName theVertexName, TEntry theVertexEntry,
851 TEnfGroupName theGroupName, double x, double y, double z) {
853 MESSAGE("BLSURFPlugin_Hypothesis::SetEnforcedVertex("<< theFaceEntry << ", "
854 << x << ", " << y << ", " << z << ", " << theVertexName << ", " << theVertexEntry << ", " << theGroupName << ")");
856 SetPhysicalMesh(PhysicalLocalSize);
858 // TEnfVertexList::iterator it;
859 bool toNotify = false;
860 bool toCreate = true;
862 TEnfVertex *oldEnVertex;
863 TEnfVertex *newEnfVertex = new TEnfVertex();
864 newEnfVertex->name = theVertexName;
865 newEnfVertex->geomEntry = theVertexEntry;
866 newEnfVertex->coords.clear();
867 if (theVertexEntry == "") {
868 newEnfVertex->coords.push_back(x);
869 newEnfVertex->coords.push_back(y);
870 newEnfVertex->coords.push_back(z);
872 newEnfVertex->grpName = theGroupName;
873 newEnfVertex->faceEntries.clear();
874 newEnfVertex->faceEntries.insert(theFaceEntry);
877 // update _enfVertexList
878 TEnfVertexList::iterator it = _enfVertexList.find(newEnfVertex);
879 if (it != _enfVertexList.end()) {
882 MESSAGE("Enforced Vertex was found => Update");
883 if (oldEnVertex->name != theVertexName) {
884 MESSAGE("Update name from \"" << oldEnVertex->name << "\" to \"" << theVertexName << "\"");
885 oldEnVertex->name = theVertexName;
888 if (oldEnVertex->grpName != theGroupName) {
889 MESSAGE("Update group name from \"" << oldEnVertex->grpName << "\" to \"" << theGroupName << "\"");
890 oldEnVertex->grpName = theGroupName;
893 TEntryList::iterator it_faceEntries = oldEnVertex->faceEntries.find(theFaceEntry);
894 if (it_faceEntries == oldEnVertex->faceEntries.end()) {
895 MESSAGE("Update face list by adding \"" << theFaceEntry << "\"");
896 oldEnVertex->faceEntries.insert(theFaceEntry);
897 _faceEntryEnfVertexListMap[theFaceEntry].insert(oldEnVertex);
901 // update map coords / enf vertex if needed
902 if (oldEnVertex->coords.size()) {
903 _coordsEnfVertexMap[oldEnVertex->coords] = oldEnVertex;
904 _faceEntryCoordsListMap[theFaceEntry].insert(oldEnVertex->coords);
907 // update map geom entry / enf vertex if needed
908 if (oldEnVertex->geomEntry != "") {
909 _enfVertexEntryEnfVertexMap[oldEnVertex->geomEntry] = oldEnVertex;
910 _faceEntryEnfVertexEntryListMap[theFaceEntry].insert(oldEnVertex->geomEntry);
915 // //////// CREATE ////////////
918 MESSAGE("Creating new enforced vertex");
919 _faceEntryEnfVertexListMap[theFaceEntry].insert(newEnfVertex);
920 _enfVertexList.insert(newEnfVertex);
921 if (theVertexEntry == "") {
922 _faceEntryCoordsListMap[theFaceEntry].insert(newEnfVertex->coords);
923 _coordsEnfVertexMap[newEnfVertex->coords] = newEnfVertex;
926 _faceEntryEnfVertexEntryListMap[theFaceEntry].insert(newEnfVertex->geomEntry);
927 _enfVertexEntryEnfVertexMap[newEnfVertex->geomEntry] = newEnfVertex;
932 NotifySubMeshesHypothesisModification();
934 MESSAGE("BLSURFPlugin_Hypothesis::SetEnforcedVertex END");
939 //=======================================================================
940 //function : GetEnforcedVertices
941 //=======================================================================
943 BLSURFPlugin_Hypothesis::TEnfVertexList BLSURFPlugin_Hypothesis::GetEnfVertexList(const TEntry& theFaceEntry)
944 throw (std::invalid_argument) {
946 if (_faceEntryEnfVertexListMap.count(theFaceEntry) > 0)
947 return _faceEntryEnfVertexListMap[theFaceEntry];
949 return GetDefaultEnfVertexList();
951 std::ostringstream msg;
952 msg << "No enforced vertex for face entry " << theFaceEntry;
953 throw std::invalid_argument(msg.str());
956 //=======================================================================
957 //function : GetEnfVertexCoordsList
958 //=======================================================================
960 BLSURFPlugin_Hypothesis::TEnfVertexCoordsList BLSURFPlugin_Hypothesis::GetEnfVertexCoordsList(
961 const TEntry& theFaceEntry) throw (std::invalid_argument) {
963 if (_faceEntryCoordsListMap.count(theFaceEntry) > 0)
964 return _faceEntryCoordsListMap[theFaceEntry];
966 std::ostringstream msg;
967 msg << "No enforced vertex coords for face entry " << theFaceEntry;
968 throw std::invalid_argument(msg.str());
971 //=======================================================================
972 //function : GetEnfVertexEntryList
973 //=======================================================================
975 BLSURFPlugin_Hypothesis::TEntryList BLSURFPlugin_Hypothesis::GetEnfVertexEntryList(const TEntry& theFaceEntry)
976 throw (std::invalid_argument) {
978 if (_faceEntryEnfVertexEntryListMap.count(theFaceEntry) > 0)
979 return _faceEntryEnfVertexEntryListMap[theFaceEntry];
981 std::ostringstream msg;
982 msg << "No enforced vertex entry for face entry " << theFaceEntry;
983 throw std::invalid_argument(msg.str());
986 //=======================================================================
987 //function : GetEnfVertex(TEnfVertexCoords coords)
988 //=======================================================================
990 BLSURFPlugin_Hypothesis::TEnfVertex* BLSURFPlugin_Hypothesis::GetEnfVertex(TEnfVertexCoords coords)
991 throw (std::invalid_argument) {
993 if (_coordsEnfVertexMap.count(coords) > 0)
994 return _coordsEnfVertexMap[coords];
996 std::ostringstream msg;
997 msg << "No enforced vertex with coords (" << coords[0] << ", " << coords[1] << ", " << coords[2] << ")";
998 throw std::invalid_argument(msg.str());
1001 //=======================================================================
1002 //function : GetEnfVertex(const TEntry& theEnfVertexEntry)
1003 //=======================================================================
1005 BLSURFPlugin_Hypothesis::TEnfVertex* BLSURFPlugin_Hypothesis::GetEnfVertex(const TEntry& theEnfVertexEntry)
1006 throw (std::invalid_argument) {
1008 if (_enfVertexEntryEnfVertexMap.count(theEnfVertexEntry) > 0)
1009 return _enfVertexEntryEnfVertexMap[theEnfVertexEntry];
1011 std::ostringstream msg;
1012 msg << "No enforced vertex with entry " << theEnfVertexEntry;
1013 throw std::invalid_argument(msg.str());
1016 //Enable internal enforced vertices on specific face if requested by user
1017 ////=======================================================================
1018 ////function : GetInternalEnforcedVertex
1019 ////=======================================================================
1021 //bool BLSURFPlugin_Hypothesis::GetInternalEnforcedVertex(const TEntry& theFaceEntry)
1023 // if (_faceEntryInternalVerticesList.count(theFaceEntry) > 0)
1028 //=======================================================================
1029 //function : ClearEnforcedVertex
1030 //=======================================================================
1032 bool BLSURFPlugin_Hypothesis::ClearEnforcedVertex(const TEntry& theFaceEntry, double x, double y, double z,
1033 const TEntry& theVertexEntry) throw (std::invalid_argument) {
1035 bool toNotify = false;
1036 std::ostringstream msg;
1037 TEnfVertex *oldEnfVertex;
1038 TEnfVertexCoords coords;
1040 coords.push_back(x);
1041 coords.push_back(y);
1042 coords.push_back(z);
1044 // check that enf vertex with given enf vertex entry exists
1045 TEnfVertexEntryEnfVertexMap::iterator it_enfVertexEntry = _enfVertexEntryEnfVertexMap.find(theVertexEntry);
1046 if (it_enfVertexEntry != _enfVertexEntryEnfVertexMap.end()) {
1048 MESSAGE("Found enforced vertex with geom entry " << theVertexEntry);
1049 oldEnfVertex = it_enfVertexEntry->second;
1051 _enfVertexEntryEnfVertexMap.erase(it_enfVertexEntry);
1053 TEntryList& enfVertexEntryList = _faceEntryEnfVertexEntryListMap[theFaceEntry];
1054 enfVertexEntryList.erase(theVertexEntry);
1055 if (enfVertexEntryList.size() == 0)
1056 _faceEntryEnfVertexEntryListMap.erase(theFaceEntry);
1057 // TFaceEntryEnfVertexEntryListMap::iterator it_entry_entry = _faceEntryEnfVertexEntryListMap.find(theFaceEntry);
1058 // TEntryList::iterator it_entryList = it_entry_entry->second.find(theVertexEntry);
1059 // it_entry_entry->second.erase(it_entryList);
1060 // if (it_entry_entry->second.size() == 0)
1061 // _faceEntryEnfVertexEntryListMap.erase(it_entry_entry);
1064 MESSAGE("Enforced vertex with geom entry " << theVertexEntry << " not found");
1065 msg << "No enforced vertex with geom entry " << theVertexEntry;
1066 // check that enf vertex with given coords exists
1067 TCoordsEnfVertexMap::iterator it_coords_enf = _coordsEnfVertexMap.find(coords);
1068 if (it_coords_enf != _coordsEnfVertexMap.end()) {
1070 MESSAGE("Found enforced vertex with coords " << x << ", " << y << ", " << z);
1071 oldEnfVertex = it_coords_enf->second;
1073 _coordsEnfVertexMap.erase(it_coords_enf);
1075 TEnfVertexCoordsList& enfVertexCoordsList = _faceEntryCoordsListMap[theFaceEntry];
1076 enfVertexCoordsList.erase(coords);
1077 if (enfVertexCoordsList.size() == 0)
1078 _faceEntryCoordsListMap.erase(theFaceEntry);
1079 // TFaceEntryCoordsListMap::iterator it_entry_coords = _faceEntryCoordsListMap.find(theFaceEntry);
1080 // TEnfVertexCoordsList::iterator it_coordsList = it_entry_coords->second.find(coords);
1081 // it_entry_coords->second.erase(it_coordsList);
1082 // if (it_entry_coords->second.size() == 0)
1083 // _faceEntryCoordsListMap.erase(it_entry_coords);
1086 MESSAGE("Enforced vertex with coords " << x << ", " << y << ", " << z << " not found");
1088 msg << "No enforced vertex at " << x << ", " << y << ", " << z;
1089 throw std::invalid_argument(msg.str());
1093 MESSAGE("Remove enf vertex from _enfVertexList");
1095 // update _enfVertexList
1096 TEnfVertexList::iterator it = _enfVertexList.find(oldEnfVertex);
1097 if (it != _enfVertexList.end()) {
1098 (*it)->faceEntries.erase(theFaceEntry);
1099 if ((*it)->faceEntries.size() == 0){
1100 _enfVertexList.erase(it);
1106 // update _faceEntryEnfVertexListMap
1107 TEnfVertexList& currentEnfVertexList = _faceEntryEnfVertexListMap[theFaceEntry];
1108 currentEnfVertexList.erase(oldEnfVertex);
1110 if (currentEnfVertexList.size() == 0) {
1111 MESSAGE("Remove _faceEntryEnfVertexListMap[" << theFaceEntry <<"]");
1112 _faceEntryEnfVertexListMap.erase(theFaceEntry);
1117 NotifySubMeshesHypothesisModification();
1122 //=======================================================================
1123 //function : ClearEnforcedVertices
1124 //=======================================================================
1126 bool BLSURFPlugin_Hypothesis::ClearEnforcedVertices(const TEntry& theFaceEntry) throw (std::invalid_argument) {
1128 bool toNotify = false;
1129 TEnfVertex *oldEnfVertex;
1131 TFaceEntryCoordsListMap::iterator it_entry_coords = _faceEntryCoordsListMap.find(theFaceEntry);
1132 if (it_entry_coords != _faceEntryCoordsListMap.end()) {
1134 TEnfVertexCoordsList coordsList = it_entry_coords->second;
1135 TEnfVertexCoordsList::iterator it_coordsList = coordsList.begin();
1136 for (; it_coordsList != coordsList.end(); ++it_coordsList) {
1137 TEnfVertexCoords coords = (*it_coordsList);
1138 oldEnfVertex = _coordsEnfVertexMap[coords];
1139 _coordsEnfVertexMap.erase(coords);
1140 // update _enfVertexList
1141 TEnfVertexList::iterator it = _enfVertexList.find(oldEnfVertex);
1142 if (it != _enfVertexList.end()) {
1143 (*it)->faceEntries.erase(theFaceEntry);
1144 if ((*it)->faceEntries.size() == 0){
1145 _enfVertexList.erase(it);
1151 _faceEntryCoordsListMap.erase(it_entry_coords);
1152 _faceEntryEnfVertexListMap.erase(theFaceEntry);
1155 TFaceEntryEnfVertexEntryListMap::iterator it_entry_entry = _faceEntryEnfVertexEntryListMap.find(theFaceEntry);
1156 if (it_entry_entry != _faceEntryEnfVertexEntryListMap.end()) {
1158 TEntryList enfVertexEntryList = it_entry_entry->second;
1159 TEntryList::iterator it_enfVertexEntryList = enfVertexEntryList.begin();
1160 for (; it_enfVertexEntryList != enfVertexEntryList.end(); ++it_enfVertexEntryList) {
1161 TEntry enfVertexEntry = (*it_enfVertexEntryList);
1162 oldEnfVertex = _enfVertexEntryEnfVertexMap[enfVertexEntry];
1163 _enfVertexEntryEnfVertexMap.erase(enfVertexEntry);
1164 // update _enfVertexList
1165 TEnfVertexList::iterator it = _enfVertexList.find(oldEnfVertex);
1166 if (it != _enfVertexList.end()) {
1167 (*it)->faceEntries.erase(theFaceEntry);
1168 if ((*it)->faceEntries.size() == 0){
1169 _enfVertexList.erase(it);
1175 _faceEntryEnfVertexEntryListMap.erase(it_entry_entry);
1176 _faceEntryEnfVertexListMap.erase(theFaceEntry);
1180 NotifySubMeshesHypothesisModification();
1183 // std::ostringstream msg;
1184 // msg << "No enforced vertex for " << theFaceEntry;
1185 // throw std::invalid_argument(msg.str());
1188 //=======================================================================
1189 //function : ClearAllEnforcedVertices
1190 //=======================================================================
1191 void BLSURFPlugin_Hypothesis::ClearAllEnforcedVertices() {
1192 _faceEntryEnfVertexListMap.clear();
1193 _enfVertexList.clear();
1194 _faceEntryCoordsListMap.clear();
1195 _coordsEnfVertexMap.clear();
1196 _faceEntryEnfVertexEntryListMap.clear();
1197 _enfVertexEntryEnfVertexMap.clear();
1198 // Enable internal enforced vertices on specific face if requested by user
1199 // _faceEntryInternalVerticesList.clear();
1200 NotifySubMeshesHypothesisModification();
1203 //================================================================================
1205 * \brief Return the enforced vertices
1207 //================================================================================
1210 BLSURFPlugin_Hypothesis::TFaceEntryEnfVertexListMap BLSURFPlugin_Hypothesis::GetAllEnforcedVerticesByFace(
1211 const BLSURFPlugin_Hypothesis* hyp) {
1212 return hyp ? hyp->_GetAllEnforcedVerticesByFace() : GetDefaultFaceEntryEnfVertexListMap();
1215 //Enable internal enforced vertices on specific face if requested by user
1216 //BLSURFPlugin_Hypothesis::TFaceEntryInternalVerticesList BLSURFPlugin_Hypothesis::GetAllInternalEnforcedVerticesByFace(
1217 // const BLSURFPlugin_Hypothesis* hyp) {
1218 // return hyp ? hyp->_GetAllInternalEnforcedVerticesByFace() : GetDefaultFaceEntryInternalVerticesMap();
1221 bool BLSURFPlugin_Hypothesis::GetInternalEnforcedVertexAllFaces(const BLSURFPlugin_Hypothesis* hyp)
1223 return hyp ? hyp->_GetInternalEnforcedVertexAllFaces() : GetDefaultInternalEnforcedVertex();
1226 BLSURFPlugin_Hypothesis::TEnfGroupName BLSURFPlugin_Hypothesis::GetInternalEnforcedVertexAllFacesGroup(const BLSURFPlugin_Hypothesis* hyp)
1228 return hyp ? hyp->_GetInternalEnforcedVertexAllFacesGroup() : BLSURFPlugin_Hypothesis::TEnfGroupName();
1231 BLSURFPlugin_Hypothesis::TEnfVertexList BLSURFPlugin_Hypothesis::GetAllEnforcedVertices(
1232 const BLSURFPlugin_Hypothesis* hyp) {
1233 return hyp ? hyp->_GetAllEnforcedVertices() : GetDefaultEnfVertexList();
1236 BLSURFPlugin_Hypothesis::TFaceEntryCoordsListMap BLSURFPlugin_Hypothesis::GetAllCoordsByFace(
1237 const BLSURFPlugin_Hypothesis* hyp) {
1238 return hyp ? hyp->_GetAllCoordsByFace() : GetDefaultFaceEntryCoordsListMap();
1241 BLSURFPlugin_Hypothesis::TCoordsEnfVertexMap BLSURFPlugin_Hypothesis::GetAllEnforcedVerticesByCoords(
1242 const BLSURFPlugin_Hypothesis* hyp) {
1243 return hyp ? hyp->_GetAllEnforcedVerticesByCoords() : GetDefaultCoordsEnfVertexMap();
1246 BLSURFPlugin_Hypothesis::TFaceEntryEnfVertexEntryListMap BLSURFPlugin_Hypothesis::GetAllEnfVertexEntriesByFace(
1247 const BLSURFPlugin_Hypothesis* hyp) {
1248 return hyp ? hyp->_GetAllEnfVertexEntriesByFace() : GetDefaultFaceEntryEnfVertexEntryListMap();
1251 BLSURFPlugin_Hypothesis::TEnfVertexEntryEnfVertexMap BLSURFPlugin_Hypothesis::GetAllEnforcedVerticesByEnfVertexEntry(
1252 const BLSURFPlugin_Hypothesis* hyp) {
1253 return hyp ? hyp->_GetAllEnforcedVerticesByEnfVertexEntry() : GetDefaultEnfVertexEntryEnfVertexMap();
1256 std::set<int> BLSURFPlugin_Hypothesis::GetEnfVertexNodeIDs(TEnfGroupName theGroupName) throw (std::invalid_argument)
1258 TGroupNameNodeIDMap::const_iterator it = _groupNameNodeIDMap.find(theGroupName);
1259 if (it != _groupNameNodeIDMap.end()) {
1262 std::ostringstream msg;
1263 msg << "No group " << theGroupName;
1264 throw std::invalid_argument(msg.str());
1267 void BLSURFPlugin_Hypothesis::AddEnfVertexNodeID(TEnfGroupName theGroupName,int theNodeID)
1269 _groupNameNodeIDMap[theGroupName].insert(theNodeID);
1272 void BLSURFPlugin_Hypothesis::RemoveEnfVertexNodeID(TEnfGroupName theGroupName,int theNodeID) throw (std::invalid_argument)
1274 TGroupNameNodeIDMap::iterator it = _groupNameNodeIDMap.find(theGroupName);
1275 if (it != _groupNameNodeIDMap.end()) {
1276 std::set<int>::iterator IDit = it->second.find(theNodeID);
1277 if (IDit != it->second.end())
1278 it->second.erase(IDit);
1279 std::ostringstream msg;
1280 msg << "No node IDs " << theNodeID << " for group " << theGroupName;
1281 throw std::invalid_argument(msg.str());
1283 std::ostringstream msg;
1284 msg << "No group " << theGroupName;
1285 throw std::invalid_argument(msg.str());
1289 //=============================================================================
1290 void BLSURFPlugin_Hypothesis::SetInternalEnforcedVertexAllFaces(bool toEnforceInternalVertices) {
1291 if (toEnforceInternalVertices != _enforcedInternalVerticesAllFaces) {
1292 _enforcedInternalVerticesAllFaces = toEnforceInternalVertices;
1293 if (toEnforceInternalVertices)
1294 SetPhysicalMesh(PhysicalLocalSize);
1295 NotifySubMeshesHypothesisModification();
1300 //=============================================================================
1301 void BLSURFPlugin_Hypothesis::SetInternalEnforcedVertexAllFacesGroup(BLSURFPlugin_Hypothesis::TEnfGroupName theGroupName) {
1302 if (std::string(theGroupName) != std::string(_enforcedInternalVerticesAllFacesGroup)) {
1303 _enforcedInternalVerticesAllFacesGroup = theGroupName;
1304 NotifySubMeshesHypothesisModification();
1308 //=============================================================================
1309 BLSURFPlugin_Hypothesis::TPreCadPeriodicityVector BLSURFPlugin_Hypothesis::GetPreCadFacesPeriodicityVector(
1310 const BLSURFPlugin_Hypothesis* hyp) {
1311 return hyp ? hyp->_GetPreCadFacesPeriodicityVector() : GetDefaultPreCadFacesPeriodicityVector();
1314 //=============================================================================
1315 BLSURFPlugin_Hypothesis::TPreCadPeriodicityVector BLSURFPlugin_Hypothesis::GetPreCadEdgesPeriodicityVector(
1316 const BLSURFPlugin_Hypothesis* hyp) {
1317 return hyp ? hyp->_GetPreCadEdgesPeriodicityVector() : GetDefaultPreCadEdgesPeriodicityVector();
1320 //=============================================================================
1321 BLSURFPlugin_Hypothesis::TFacesPeriodicityVector BLSURFPlugin_Hypothesis::GetFacesPeriodicityVector(
1322 const BLSURFPlugin_Hypothesis* hyp) {
1323 return hyp ? hyp->_GetFacesPeriodicityVector() : GetDefaultFacesPeriodicityVector();
1326 //=============================================================================
1327 BLSURFPlugin_Hypothesis::TEdgesPeriodicityVector BLSURFPlugin_Hypothesis::GetEdgesPeriodicityVector(
1328 const BLSURFPlugin_Hypothesis* hyp){
1329 return hyp ? hyp->_GetEdgesPeriodicityVector() : GetDefaultEdgesPeriodicityVector();
1332 //=============================================================================
1333 BLSURFPlugin_Hypothesis::TVerticesPeriodicityVector BLSURFPlugin_Hypothesis::GetVerticesPeriodicityVector(
1334 const BLSURFPlugin_Hypothesis* hyp){
1335 return hyp ? hyp->_GetVerticesPeriodicityVector() : GetDefaultVerticesPeriodicityVector();
1338 //=======================================================================
1339 //function : ClearAllEnforcedVertices
1340 //=======================================================================
1341 void BLSURFPlugin_Hypothesis::ClearPreCadPeriodicityVectors() {
1342 _preCadFacesPeriodicityVector.clear();
1343 _preCadEdgesPeriodicityVector.clear();
1344 NotifySubMeshesHypothesisModification();
1347 //=======================================================================
1348 //function : AddPreCadFacesPeriodicity
1349 //=======================================================================
1350 void BLSURFPlugin_Hypothesis::AddPreCadFacesPeriodicity(TEntry theFace1Entry, TEntry theFace2Entry,
1351 std::vector<std::string> &theSourceVerticesEntries, std::vector<std::string> &theTargetVerticesEntries) {
1353 TPreCadPeriodicity preCadFacesPeriodicity;
1354 preCadFacesPeriodicity.shape1Entry = theFace1Entry;
1355 preCadFacesPeriodicity.shape2Entry = theFace2Entry;
1356 preCadFacesPeriodicity.theSourceVerticesEntries = theSourceVerticesEntries;
1357 preCadFacesPeriodicity.theTargetVerticesEntries = theTargetVerticesEntries;
1359 _preCadFacesPeriodicityVector.push_back(preCadFacesPeriodicity);
1361 NotifySubMeshesHypothesisModification();
1364 //=======================================================================
1365 //function : AddPreCadEdgesPeriodicity
1366 //=======================================================================
1367 void BLSURFPlugin_Hypothesis::AddPreCadEdgesPeriodicity(TEntry theEdge1Entry, TEntry theEdge2Entry,
1368 std::vector<std::string> &theSourceVerticesEntries, std::vector<std::string> &theTargetVerticesEntries) {
1370 TPreCadPeriodicity preCadEdgesPeriodicity;
1371 preCadEdgesPeriodicity.shape1Entry = theEdge1Entry;
1372 preCadEdgesPeriodicity.shape2Entry = theEdge2Entry;
1373 preCadEdgesPeriodicity.theSourceVerticesEntries = theSourceVerticesEntries;
1374 preCadEdgesPeriodicity.theTargetVerticesEntries = theTargetVerticesEntries;
1376 _preCadEdgesPeriodicityVector.push_back(preCadEdgesPeriodicity);
1378 NotifySubMeshesHypothesisModification();
1381 //=============================================================================
1382 std::ostream & BLSURFPlugin_Hypothesis::SaveTo(std::ostream & save) {
1383 // We must keep at least the same number of arguments when increasing the SALOME version
1384 // When MG-CADSurf becomes CADMESH, some parameters were fused into a single one. Thus the same
1385 // parameter can be written several times to keep the old global number of parameters.
1387 // Treat old options which are now in the advanced options
1388 TOptionValues::iterator op_val;
1390 int _preCADRemoveNanoEdges = -1;
1391 double _preCADEpsNano = -1.0;
1392 op_val = _option2value.find("respect_geometry");
1393 if (op_val != _option2value.end()) {
1394 std::string value = op_val->second;
1396 _decimesh = value.compare("1") == 0 ? 1 : 0;
1398 op_val = _preCADoption2value.find("remove_tiny_edges");
1399 if (op_val != _preCADoption2value.end()) {
1400 std::string value = op_val->second;
1402 _preCADRemoveNanoEdges = value.compare("1") == 0 ? 1 : 0;
1404 op_val = _preCADoption2value.find("tiny_edge_length");
1405 if (op_val != _preCADoption2value.end()) {
1406 std::string value = op_val->second;
1408 _preCADEpsNano = strtod(value.c_str(), NULL);
1411 save << " " << (int) _topology << " " << (int) _physicalMesh << " " << (int) _geometricMesh << " " << _phySize << " "
1412 << _angleMesh << " " << _gradation << " " << (int) _quadAllowed << " " << _decimesh;
1413 save << " " << _minSize << " " << _maxSize << " " << _angleMesh << " " << _minSize << " " << _maxSize << " " << _verb;
1414 save << " " << (int) _preCADMergeEdges << " " << _preCADRemoveNanoEdges << " " << (int) _preCADDiscardInput << " " << _preCADEpsNano ;
1415 save << " " << (int) _enforcedInternalVerticesAllFaces;
1416 save << " " << (int) _phySizeRel << " " << (int) _minSizeRel << " " << (int) _maxSizeRel << " " << _chordalError ;
1417 save << " " << (int) _anisotropic << " " << _anisotropicRatio << " " << (int) _removeTinyEdges << " " << _tinyEdgeLength ;
1418 save << " " << (int) _badElementRemoval << " " << _badElementAspectRatio << " " << (int) _optimizeMesh << " " << (int) _quadraticMesh ;
1419 save << " " << (int) _preCADProcess3DTopology << " " << (int) _preCADRemoveDuplicateCADFaces << " " << (int) _preCADRemoveTinyUVEdges;
1421 op_val = _option2value.begin();
1422 if (op_val != _option2value.end()) {
1423 save << " " << "__OPTIONS_BEGIN__";
1424 for (; op_val != _option2value.end(); ++op_val) {
1425 if (!op_val->second.empty())
1426 save << " " << op_val->first << " " << op_val->second << "%#"; // "%#" is a mark of value end
1428 save << " " << "__OPTIONS_END__";
1431 op_val = _customOption2value.begin();
1432 if (op_val != _customOption2value.end()) {
1433 save << " " << "__CUSTOM_OPTIONS_BEGIN__";
1434 for (; op_val != _customOption2value.end(); ++op_val) {
1435 if (!op_val->second.empty())
1436 save << " " << op_val->first << " " << op_val->second << "%#"; // "%#" is a mark of value end
1438 save << " " << "__CUSTOM_OPTIONS_END__";
1441 op_val = _preCADoption2value.begin();
1442 if (op_val != _preCADoption2value.end()) {
1443 save << " " << "__PRECAD_OPTIONS_BEGIN__";
1444 for (; op_val != _preCADoption2value.end(); ++op_val) {
1445 if (!op_val->second.empty())
1446 save << " " << op_val->first << " " << op_val->second << "%#"; // "%#" is a mark of value end
1448 save << " " << "__PRECAD_OPTIONS_END__";
1451 op_val = _customPreCADOption2value.begin();
1452 if (op_val != _customPreCADOption2value.end()) {
1453 save << " " << "__CUSTOM_PRECAD_OPTIONS_BEGIN__";
1454 for (; op_val != _customPreCADOption2value.end(); ++op_val) {
1455 if (!op_val->second.empty())
1456 save << " " << op_val->first << " " << op_val->second << "%#"; // "%#" is a mark of value end
1458 save << " " << "__CUSTOM_PRECAD_OPTIONS_END__";
1461 TSizeMap::iterator it_sm = _sizeMap.begin();
1462 if (it_sm != _sizeMap.end()) {
1463 save << " " << "__SIZEMAP_BEGIN__";
1464 for (; it_sm != _sizeMap.end(); ++it_sm) {
1465 save << " " << it_sm->first << " " << it_sm->second << "%#"; // "%#" is a mark of value end
1467 save << " " << "__SIZEMAP_END__";
1470 TSizeMap::iterator it_at = _attractors.begin();
1471 if (it_at != _attractors.end()) {
1472 save << " " << "__ATTRACTORS_BEGIN__";
1473 for (; it_at != _attractors.end(); ++it_at) {
1474 save << " " << it_at->first << " " << it_at->second << "%#"; // "%#" is a mark of value end
1476 save << " " << "__ATTRACTORS_END__";
1479 TAttractorMap::iterator it_At = _classAttractors.begin();
1480 if (it_At != _classAttractors.end()) {
1481 std::ostringstream test;
1482 save << " " << "__NEW_ATTRACTORS_BEGIN__";
1483 test << " " << "__NEW_ATTRACTORS_BEGIN__";
1484 for (; it_At != _classAttractors.end(); ++it_At) {
1485 std::vector<double> attParams;
1486 attParams = it_At->second->GetParameters();
1487 // double step = it_At->second->GetStep();
1488 save << " " << it_At->first;
1489 save << " " << it_At->second->GetAttractorEntry();
1490 save << " " << attParams[0] << " " << attParams[1] << " " << attParams[2] << " " << attParams[3];
1491 // save << " " << step;
1492 test << " " << it_At->first;
1493 test << " " << it_At->second->GetAttractorEntry();
1494 test << " " << attParams[0] << " " << attParams[1] << " " << attParams[2] << " " << attParams[3];
1495 // test << " " << step;
1497 save << " " << "__NEW_ATTRACTORS_END__";
1498 test << " " << "__NEW_ATTRACTORS_END__";
1499 MESSAGE(" Attractor hypothesis saved as "<<test.str())
1502 TEnfVertexList::const_iterator it_enf = _enfVertexList.begin();
1503 if (it_enf != _enfVertexList.end()) {
1504 save << " " << "__ENFORCED_VERTICES_BEGIN__";
1505 for (; it_enf != _enfVertexList.end(); ++it_enf) {
1506 TEnfVertex *enfVertex = (*it_enf);
1507 save << " " << "__BEGIN_VERTEX__";
1508 if (!enfVertex->name.empty()) {
1509 save << " " << "__BEGIN_NAME__";
1510 save << " " << enfVertex->name;
1511 save << " " << "__END_NAME__";
1513 if (!enfVertex->geomEntry.empty()) {
1514 save << " " << "__BEGIN_ENTRY__";
1515 save << " " << enfVertex->geomEntry;
1516 save << " " << "__END_ENTRY__";
1518 if (!enfVertex->grpName.empty()) {
1519 save << " " << "__BEGIN_GROUP__";
1520 save << " " << enfVertex->grpName;
1521 save << " " << "__END_GROUP__";
1523 if (enfVertex->coords.size()) {
1524 save << " " << "__BEGIN_COORDS__";
1525 for ( size_t i = 0; i < enfVertex->coords.size(); i++ )
1526 save << " " << enfVertex->coords[i];
1527 save << " " << "__END_COORDS__";
1529 TEntryList::const_iterator faceEntriesIt = enfVertex->faceEntries.begin();
1530 bool hasFaces = false;
1531 if (faceEntriesIt != enfVertex->faceEntries.end()) {
1533 save << " " << "__BEGIN_FACELIST__";
1535 for (; faceEntriesIt != enfVertex->faceEntries.end(); ++faceEntriesIt)
1536 save << " " << (*faceEntriesIt);
1538 save << " " << "__END_FACELIST__";
1539 save << " " << "__END_VERTEX__";
1541 save << " " << "__ENFORCED_VERTICES_END__";
1546 SavePreCADPeriodicity(save, "FACES");
1547 SavePreCADPeriodicity(save, "EDGES");
1549 SaveFacesPeriodicity(save);
1550 SaveEdgesPeriodicity(save);
1551 SaveVerticesPeriodicity(save);
1556 void BLSURFPlugin_Hypothesis::SaveFacesPeriodicity(std::ostream & save){
1558 TFacesPeriodicityVector::const_iterator it_faces_periodicity = _facesPeriodicityVector.begin();
1559 if (it_faces_periodicity != _facesPeriodicityVector.end()) {
1560 MESSAGE("__FACES_PERIODICITY_BEGIN__");
1561 save << " " << "__FACES_PERIODICITY_BEGIN__";
1562 for (; it_faces_periodicity != _facesPeriodicityVector.end(); ++it_faces_periodicity) {
1563 TFacesPeriodicity periodicity_i = (*it_faces_periodicity);
1564 save << " " << "__BEGIN_PERIODICITY_DESCRIPTION__";
1565 save << " " << "__BEGIN_ENTRY1__";
1566 save << " " << periodicity_i.first;
1567 save << " " << "__END_ENTRY1__";
1568 save << " " << "__BEGIN_ENTRY2__";
1569 save << " " << periodicity_i.second;
1570 save << " " << "__END_ENTRY2__";
1571 save << " " << "__END_PERIODICITY_DESCRIPTION__";
1573 save << " " << "__FACES_PERIODICITY_END__";
1574 MESSAGE("__FACES_PERIODICITY_END__");
1578 void BLSURFPlugin_Hypothesis::SaveEdgesPeriodicity(std::ostream & save){
1580 TEdgesPeriodicityVector::const_iterator it_edges_periodicity = _edgesPeriodicityVector.begin();
1581 if (it_edges_periodicity != _edgesPeriodicityVector.end()) {
1582 save << " " << "__EDGES_PERIODICITY_BEGIN__";
1583 MESSAGE("__EDGES_PERIODICITY_BEGIN__");
1584 for (; it_edges_periodicity != _edgesPeriodicityVector.end(); ++it_edges_periodicity) {
1585 TEdgePeriodicity periodicity_i = (*it_edges_periodicity);
1586 save << " " << "__BEGIN_PERIODICITY_DESCRIPTION__";
1587 if (! periodicity_i.theFace1Entry.empty()){
1588 save << " " << "__BEGIN_FACE1__";
1589 save << " " << periodicity_i.theFace1Entry;
1590 save << " " << "__END_FACE1__";
1592 save << " " << "__BEGIN_EDGE1__";
1593 save << " " << periodicity_i.theEdge1Entry;
1594 save << " " << "__END_EDGE1__";
1595 if (! periodicity_i.theFace2Entry.empty()){
1596 save << " " << "__BEGIN_FACE2__";
1597 save << " " << periodicity_i.theFace2Entry;
1598 save << " " << "__END_FACE2__";
1600 save << " " << "__BEGIN_EDGE2__";
1601 save << " " << periodicity_i.theEdge2Entry;
1602 save << " " << "__END_EDGE2__";
1603 save << " " << "__BEGIN_EDGE_ORIENTATION__";
1604 save << " " << periodicity_i.edge_orientation;
1605 save << " " << "__END_EDGE_ORIENTATION__";
1606 save << " " << "__END_PERIODICITY_DESCRIPTION__";
1608 save << " " << "__EDGES_PERIODICITY_END__";
1609 MESSAGE("__EDGES_PERIODICITY_END__");
1613 void BLSURFPlugin_Hypothesis::SaveVerticesPeriodicity(std::ostream & save){
1615 TVerticesPeriodicityVector::const_iterator it_vertices_periodicity = _verticesPeriodicityVector.begin();
1616 if (it_vertices_periodicity != _verticesPeriodicityVector.end()) {
1617 MESSAGE("__VERTICES_PERIODICITY_BEGIN__");
1618 save << " " << "__VERTICES_PERIODICITY_BEGIN__";
1619 for (; it_vertices_periodicity != _verticesPeriodicityVector.end(); ++it_vertices_periodicity) {
1620 TVertexPeriodicity periodicity_i = (*it_vertices_periodicity);
1621 save << " " << "__BEGIN_PERIODICITY_DESCRIPTION__";
1622 save << " " << "__BEGIN_EDGE1__";
1623 save << " " << periodicity_i.theEdge1Entry;
1624 save << " " << "__END_EDGE1__";
1625 save << " " << "__BEGIN_VERTEX1__";
1626 save << " " << periodicity_i.theVertex1Entry;
1627 save << " " << "__END_VERTEX1__";
1628 save << " " << "__BEGIN_EDGE2__";
1629 save << " " << periodicity_i.theEdge2Entry;
1630 save << " " << "__END_EDGE2__";
1631 save << " " << "__BEGIN_VERTEX2__";
1632 save << " " << periodicity_i.theVertex2Entry;
1633 save << " " << "__END_VERTEX2__";
1634 save << " " << "__END_PERIODICITY_DESCRIPTION__";
1636 save << " " << "__VERTICES_PERIODICITY_END__";
1637 MESSAGE("__VERTICES_PERIODICITY_END__");
1641 void BLSURFPlugin_Hypothesis::SavePreCADPeriodicity(std::ostream & save, const char* shapeType) {
1642 TPreCadPeriodicityVector precad_periodicity;
1643 if ( shapeType && strcmp( shapeType, "FACES" ) == 0 )
1644 precad_periodicity = _preCadFacesPeriodicityVector;
1646 precad_periodicity = _preCadEdgesPeriodicityVector;
1647 TPreCadPeriodicityVector::const_iterator it_precad_periodicity = precad_periodicity.begin();
1648 if (it_precad_periodicity != precad_periodicity.end()) {
1649 save << " " << "__PRECAD_" << shapeType << "_PERIODICITY_BEGIN__";
1650 for (; it_precad_periodicity != precad_periodicity.end(); ++it_precad_periodicity) {
1651 TPreCadPeriodicity periodicity_i = (*it_precad_periodicity);
1652 save << " " << "__BEGIN_PERIODICITY_DESCRIPTION__";
1653 if (!periodicity_i.shape1Entry.empty()) {
1654 save << " " << "__BEGIN_ENTRY1__";
1655 save << " " << periodicity_i.shape1Entry;
1656 save << " " << "__END_ENTRY1__";
1658 if (!periodicity_i.shape2Entry.empty()) {
1659 save << " " << "__BEGIN_ENTRY2__";
1660 save << " " << periodicity_i.shape2Entry;
1661 save << " " << "__END_ENTRY2__";
1664 std::vector<std::string>::const_iterator sourceVerticesEntriesIt = periodicity_i.theSourceVerticesEntries.begin();
1665 bool hasSourceVertices = false;
1666 if (sourceVerticesEntriesIt != periodicity_i.theSourceVerticesEntries.end()) {
1667 hasSourceVertices = true;
1668 save << " " << "__BEGIN_SOURCE_VERTICES_LIST__";
1670 for (; sourceVerticesEntriesIt != periodicity_i.theSourceVerticesEntries.end(); ++sourceVerticesEntriesIt)
1671 save << " " << (*sourceVerticesEntriesIt);
1672 if (hasSourceVertices)
1673 save << " " << "__END_SOURCE_VERTICES_LIST__";
1675 std::vector<std::string>::const_iterator targetVerticesEntriesIt = periodicity_i.theTargetVerticesEntries.begin();
1676 bool hasTargetVertices = false;
1677 if (targetVerticesEntriesIt != periodicity_i.theTargetVerticesEntries.end()) {
1678 hasTargetVertices = true;
1679 save << " " << "__BEGIN_TARGET_VERTICES_LIST__";
1681 for (; targetVerticesEntriesIt != periodicity_i.theTargetVerticesEntries.end(); ++targetVerticesEntriesIt)
1682 save << " " << (*targetVerticesEntriesIt);
1683 if (hasTargetVertices)
1684 save << " " << "__END_TARGET_VERTICES_LIST__";
1686 save << " " << "__END_PERIODICITY_DESCRIPTION__";
1688 save << " " << "__PRECAD_" << shapeType << "_PERIODICITY_END__";
1693 //=============================================================================
1694 std::istream & BLSURFPlugin_Hypothesis::LoadFrom(std::istream & load) {
1698 std::string option_or_sm;
1700 isOK = static_cast<bool>(load >> i);
1702 _topology = (Topology) i;
1704 load.clear(std::ios::badbit | load.rdstate());
1706 isOK = static_cast<bool>(load >> i);
1708 _physicalMesh = (PhysicalMesh) i;
1710 load.clear(std::ios::badbit | load.rdstate());
1712 isOK = static_cast<bool>(load >> i);
1714 _geometricMesh = (GeometricMesh) i;
1716 load.clear(std::ios::badbit | load.rdstate());
1718 isOK = static_cast<bool>(load >> val);
1722 load.clear(std::ios::badbit | load.rdstate());
1724 isOK = static_cast<bool>(load >> val);
1728 load.clear(std::ios::badbit | load.rdstate());
1730 isOK = static_cast<bool>(load >> val);
1734 load.clear(std::ios::badbit | load.rdstate());
1736 isOK = static_cast<bool>(load >> i);
1738 _quadAllowed = (bool) i;
1740 load.clear(std::ios::badbit | load.rdstate());
1742 isOK = static_cast<bool>(load >> i);
1744 if ( i != -1) { // if value is -1, then this is no longer a standard option
1745 std::string & value = _option2value["respect_geometry"];
1746 bool _decimesh = (bool) i;
1747 value = _decimesh ? "1" : "0";
1751 load.clear(std::ios::badbit | load.rdstate());
1753 isOK = static_cast<bool>(load >> val);
1757 load.clear(std::ios::badbit | load.rdstate());
1759 isOK = static_cast<bool>(load >> val);
1763 load.clear(std::ios::badbit | load.rdstate());
1765 isOK = static_cast<bool>(load >> val);
1767 // former parameter: get min value
1768 _angleMesh = std::min(val,_angleMesh);
1770 load.clear(std::ios::badbit | load.rdstate());
1772 isOK = static_cast<bool>(load >> val);
1774 // former parameter: get min value
1775 _minSize = std::min(val,_minSize);
1777 load.clear(std::ios::badbit | load.rdstate());
1779 isOK = static_cast<bool>(load >> val);
1781 // former parameter: get max value
1782 _maxSize = std::max(val,_maxSize);
1784 load.clear(std::ios::badbit | load.rdstate());
1786 isOK = static_cast<bool>(load >> i);
1790 load.clear(std::ios::badbit | load.rdstate());
1792 isOK = static_cast<bool>(load >> i);
1794 _preCADMergeEdges = (bool) i;
1796 load.clear(std::ios::badbit | load.rdstate());
1798 isOK = static_cast<bool>(load >> i);
1800 if ( i != -1) { // if value is -1, then this is no longer a standard option
1801 std::string & value = _preCADoption2value["remove_tiny_edges"];
1802 bool _preCADRemoveNanoEdges = (bool) i;
1803 value = _preCADRemoveNanoEdges ? "1" : "0";
1807 load.clear(std::ios::badbit | load.rdstate());
1809 isOK = static_cast<bool>(load >> i);
1811 _preCADDiscardInput = (bool) i;
1813 load.clear(std::ios::badbit | load.rdstate());
1815 isOK = static_cast<bool>(load >> val);
1816 if (isOK) { // _preCADEpsNano
1817 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
1818 std::string & value = _preCADoption2value["tiny_edge_length"];
1819 std::ostringstream oss;
1825 load.clear(std::ios::badbit | load.rdstate());
1827 isOK = static_cast<bool>(load >> i);
1829 _enforcedInternalVerticesAllFaces = (bool) i;
1831 load.clear(std::ios::badbit | load.rdstate());
1833 // New options with MeshGems-CADSurf
1835 bool hasCADSurfOptions = false;
1836 bool hasOptions = false;
1837 bool hasCustomOptions = false;
1838 bool hasPreCADOptions = false;
1839 bool hasCustomPreCADOptions = false;
1840 bool hasSizeMap = false;
1841 bool hasAttractor = false;
1842 bool hasNewAttractor = false;
1843 bool hasEnforcedVertex = false;
1844 bool hasPreCADFacesPeriodicity = false;
1845 bool hasPreCADEdgesPeriodicity = false;
1846 bool hasFacesPeriodicity = false;
1847 bool hasEdgesPeriodicity = false;
1848 bool hasVerticesPeriodicity = false;
1850 isOK = static_cast<bool>(load >> option_or_sm);
1852 if ( (option_or_sm == "1")||(option_or_sm == "0") ) {
1853 i = atoi(option_or_sm.c_str());
1854 hasCADSurfOptions = true;
1855 _phySizeRel = (bool) i;
1857 if (option_or_sm == "__OPTIONS_BEGIN__")
1859 else if (option_or_sm == "__CUSTOM_OPTIONS_BEGIN__")
1860 hasCustomOptions = true;
1861 else if (option_or_sm == "__PRECAD_OPTIONS_BEGIN__")
1862 hasPreCADOptions = true;
1863 else if (option_or_sm == "__CUSTOM_PRECAD_OPTIONS_BEGIN__")
1864 hasCustomPreCADOptions = true;
1865 else if (option_or_sm == "__SIZEMAP_BEGIN__")
1867 else if (option_or_sm == "__ATTRACTORS_BEGIN__")
1868 hasAttractor = true;
1869 else if (option_or_sm == "__NEW_ATTRACTORS_BEGIN__")
1870 hasNewAttractor = true;
1871 else if (option_or_sm == "__ENFORCED_VERTICES_BEGIN__")
1872 hasEnforcedVertex = true;
1873 else if (option_or_sm == "__PRECAD_FACES_PERIODICITY_BEGIN__")
1874 hasPreCADFacesPeriodicity = true;
1875 else if (option_or_sm == "__PRECAD_EDGES_PERIODICITY_BEGIN__")
1876 hasPreCADEdgesPeriodicity = true;
1877 else if (option_or_sm == "__FACES_PERIODICITY_BEGIN__")
1878 hasFacesPeriodicity = true;
1879 else if (option_or_sm == "__EDGES_PERIODICITY_BEGIN__")
1880 hasEdgesPeriodicity = true;
1881 else if (option_or_sm == "__VERTICES_PERIODICITY_BEGIN__")
1882 hasVerticesPeriodicity = true;
1884 if (isOK && hasCADSurfOptions) {
1885 isOK = static_cast<bool>(load >> i);
1887 _minSizeRel = (bool) i;
1889 load.clear(std::ios::badbit | load.rdstate());
1891 isOK = static_cast<bool>(load >> i);
1893 _maxSizeRel = (bool) i;
1895 load.clear(std::ios::badbit | load.rdstate());
1897 isOK = static_cast<bool>(load >> val);
1899 _chordalError = val;
1901 load.clear(std::ios::badbit | load.rdstate());
1903 isOK = static_cast<bool>(load >> i);
1905 _anisotropic = (bool) i;
1907 load.clear(std::ios::badbit | load.rdstate());
1909 isOK = static_cast<bool>(load >> val);
1911 _anisotropicRatio = val;
1913 load.clear(std::ios::badbit | load.rdstate());
1915 isOK = static_cast<bool>(load >> i);
1917 _removeTinyEdges = (bool) i;
1919 load.clear(std::ios::badbit | load.rdstate());
1921 isOK = static_cast<bool>(load >> val);
1923 _tinyEdgeLength = val;
1925 load.clear(std::ios::badbit | load.rdstate());
1927 isOK = static_cast<bool>(load >> i);
1929 _badElementRemoval = (bool) i;
1931 load.clear(std::ios::badbit | load.rdstate());
1933 isOK = static_cast<bool>(load >> val);
1935 _badElementAspectRatio = val;
1937 load.clear(std::ios::badbit | load.rdstate());
1939 isOK = static_cast<bool>(load >> i);
1941 _optimizeMesh = (bool) i;
1943 load.clear(std::ios::badbit | load.rdstate());
1945 isOK = static_cast<bool>(load >> i);
1947 _quadraticMesh = (bool) i;
1949 load.clear(std::ios::badbit | load.rdstate());
1951 isOK = static_cast<bool>(load >> i);
1953 _preCADProcess3DTopology = (bool) i;
1955 load.clear(std::ios::badbit | load.rdstate());
1957 isOK = static_cast<bool>(load >> i);
1959 _preCADRemoveDuplicateCADFaces = (bool) i;
1961 load.clear(std::ios::badbit | load.rdstate());
1963 isOK = static_cast<bool>(load >> i);
1965 _preCADRemoveTinyUVEdges = (bool) i;
1967 load.clear(std::ios::badbit | load.rdstate());
1972 if (hasCADSurfOptions) {
1973 isOK = static_cast<bool>(load >> option_or_sm);
1975 if (option_or_sm == "__OPTIONS_BEGIN__")
1977 else if (option_or_sm == "__CUSTOM_OPTIONS_BEGIN__")
1978 hasCustomOptions = true;
1979 else if (option_or_sm == "__PRECAD_OPTIONS_BEGIN__")
1980 hasPreCADOptions = true;
1981 else if (option_or_sm == "__CUSTOM_PRECAD_OPTIONS_BEGIN__")
1982 hasCustomPreCADOptions = true;
1983 else if (option_or_sm == "__SIZEMAP_BEGIN__")
1985 else if (option_or_sm == "__ATTRACTORS_BEGIN__")
1986 hasAttractor = true;
1987 else if (option_or_sm == "__NEW_ATTRACTORS_BEGIN__")
1988 hasNewAttractor = true;
1989 else if (option_or_sm == "__ENFORCED_VERTICES_BEGIN__")
1990 hasEnforcedVertex = true;
1991 else if (option_or_sm == "__PRECAD_FACES_PERIODICITY_BEGIN__")
1992 hasPreCADFacesPeriodicity = true;
1993 else if (option_or_sm == "__PRECAD_EDGES_PERIODICITY_BEGIN__")
1994 hasPreCADEdgesPeriodicity = true;
1995 else if (option_or_sm == "__FACES_PERIODICITY_BEGIN__")
1996 hasFacesPeriodicity = true;
1997 else if (option_or_sm == "__EDGES_PERIODICITY_BEGIN__")
1998 hasEdgesPeriodicity = true;
1999 else if (option_or_sm == "__VERTICES_PERIODICITY_BEGIN__")
2000 hasVerticesPeriodicity = true;
2004 std::string optName, optValue;
2005 while (isOK && hasOptions) {
2006 isOK = static_cast<bool>(load >> optName);
2008 if (optName == "__OPTIONS_END__")
2010 isOK = static_cast<bool>(load >> optValue);
2013 std::string & value = _option2value[optName];
2015 int len = value.size();
2016 // continue reading until "%#" encountered
2017 while (value[len - 1] != '#' || value[len - 2] != '%') {
2018 isOK = static_cast<bool>(load >> optValue);
2027 value[len - 2] = '\0'; //cut off "%#"
2032 isOK = static_cast<bool>(load >> option_or_sm);
2034 if (option_or_sm == "__CUSTOM_OPTIONS_BEGIN__")
2035 hasCustomOptions = true;
2036 else if (option_or_sm == "__PRECAD_OPTIONS_BEGIN__")
2037 hasPreCADOptions = true;
2038 else if (option_or_sm == "__CUSTOM_PRECAD_OPTIONS_BEGIN__")
2039 hasCustomPreCADOptions = true;
2040 else if (option_or_sm == "__SIZEMAP_BEGIN__")
2042 else if (option_or_sm == "__ATTRACTORS_BEGIN__")
2043 hasAttractor = true;
2044 else if (option_or_sm == "__NEW_ATTRACTORS_BEGIN__")
2045 hasNewAttractor = true;
2046 else if (option_or_sm == "__ENFORCED_VERTICES_BEGIN__")
2047 hasEnforcedVertex = true;
2048 else if (option_or_sm == "__PRECAD_FACES_PERIODICITY_BEGIN__")
2049 hasPreCADFacesPeriodicity = true;
2050 else if (option_or_sm == "__PRECAD_EDGES_PERIODICITY_BEGIN__")
2051 hasPreCADEdgesPeriodicity = true;
2052 else if (option_or_sm == "__FACES_PERIODICITY_BEGIN__")
2053 hasFacesPeriodicity = true;
2054 else if (option_or_sm == "__EDGES_PERIODICITY_BEGIN__")
2055 hasEdgesPeriodicity = true;
2056 else if (option_or_sm == "__VERTICES_PERIODICITY_BEGIN__")
2057 hasVerticesPeriodicity = true;
2061 while (isOK && hasCustomOptions) {
2062 isOK = static_cast<bool>(load >> optName);
2064 if (optName == "__CUSTOM_OPTIONS_END__")
2066 isOK = static_cast<bool>(load >> optValue);
2069 std::string& value = optValue;
2070 int len = value.size();
2071 // continue reading until "%#" encountered
2072 while (value[len - 1] != '#' || value[len - 2] != '%') {
2073 isOK = static_cast<bool>(load >> optValue);
2082 _customOption2value[optName] = value.substr(0,len-2);
2083 value[len - 2] = '\0'; //cut off "%#"
2087 if (hasCustomOptions) {
2088 isOK = static_cast<bool>(load >> option_or_sm);
2090 if (option_or_sm == "__PRECAD_OPTIONS_BEGIN__")
2091 hasPreCADOptions = true;
2092 else if (option_or_sm == "__CUSTOM_PRECAD_OPTIONS_BEGIN__")
2093 hasCustomPreCADOptions = true;
2094 else if (option_or_sm == "__SIZEMAP_BEGIN__")
2096 else if (option_or_sm == "__ATTRACTORS_BEGIN__")
2097 hasAttractor = true;
2098 else if (option_or_sm == "__NEW_ATTRACTORS_BEGIN__")
2099 hasNewAttractor = true;
2100 else if (option_or_sm == "__ENFORCED_VERTICES_BEGIN__")
2101 hasEnforcedVertex = true;
2102 else if (option_or_sm == "__PRECAD_FACES_PERIODICITY_BEGIN__")
2103 hasPreCADFacesPeriodicity = true;
2104 else if (option_or_sm == "__PRECAD_EDGES_PERIODICITY_BEGIN__")
2105 hasPreCADEdgesPeriodicity = true;
2106 else if (option_or_sm == "__FACES_PERIODICITY_BEGIN__")
2107 hasFacesPeriodicity = true;
2108 else if (option_or_sm == "__EDGES_PERIODICITY_BEGIN__")
2109 hasEdgesPeriodicity = true;
2110 else if (option_or_sm == "__VERTICES_PERIODICITY_BEGIN__")
2111 hasVerticesPeriodicity = true;
2115 while (isOK && hasPreCADOptions) {
2116 isOK = static_cast<bool>(load >> optName);
2118 if (optName == "__PRECAD_OPTIONS_END__")
2120 isOK = static_cast<bool>(load >> optValue);
2123 std::string & value = _preCADoption2value[optName];
2125 int len = value.size();
2126 // continue reading until "%#" encountered
2127 while (value[len - 1] != '#' || value[len - 2] != '%') {
2128 isOK = static_cast<bool>(load >> optValue);
2137 value[len - 2] = '\0'; //cut off "%#"
2141 if (hasPreCADOptions) {
2142 isOK = static_cast<bool>(load >> option_or_sm);
2144 if (option_or_sm == "__CUSTOM_PRECAD_OPTIONS_BEGIN__")
2145 hasCustomPreCADOptions = true;
2146 else if (option_or_sm == "__SIZEMAP_BEGIN__")
2148 else if (option_or_sm == "__ATTRACTORS_BEGIN__")
2149 hasAttractor = true;
2150 else if (option_or_sm == "__NEW_ATTRACTORS_BEGIN__")
2151 hasNewAttractor = true;
2152 else if (option_or_sm == "__ENFORCED_VERTICES_BEGIN__")
2153 hasEnforcedVertex = true;
2154 else if (option_or_sm == "__PRECAD_FACES_PERIODICITY_BEGIN__")
2155 hasPreCADFacesPeriodicity = true;
2156 else if (option_or_sm == "__PRECAD_EDGES_PERIODICITY_BEGIN__")
2157 hasPreCADEdgesPeriodicity = true;
2158 else if (option_or_sm == "__FACES_PERIODICITY_BEGIN__")
2159 hasFacesPeriodicity = true;
2160 else if (option_or_sm == "__EDGES_PERIODICITY_BEGIN__")
2161 hasEdgesPeriodicity = true;
2162 else if (option_or_sm == "__VERTICES_PERIODICITY_BEGIN__")
2163 hasVerticesPeriodicity = true;
2167 while (isOK && hasCustomPreCADOptions) {
2168 isOK = static_cast<bool>(load >> optName);
2170 if (optName == "__CUSTOM_PRECAD_OPTIONS_END__")
2172 isOK = static_cast<bool>(load >> optValue);
2175 std::string& value = optValue;
2176 int len = value.size();
2177 // continue reading until "%#" encountered
2178 while (value[len - 1] != '#' || value[len - 2] != '%') {
2179 isOK = static_cast<bool>(load >> optValue);
2188 _customPreCADOption2value[optName] = value.substr(0,len-2);
2189 value[len - 2] = '\0'; //cut off "%#"
2193 if (hasCustomPreCADOptions) {
2194 isOK = static_cast<bool>(load >> option_or_sm);
2196 if (option_or_sm == "__SIZEMAP_BEGIN__")
2198 else if (option_or_sm == "__ATTRACTORS_BEGIN__")
2199 hasAttractor = true;
2200 else if (option_or_sm == "__NEW_ATTRACTORS_BEGIN__")
2201 hasNewAttractor = true;
2202 else if (option_or_sm == "__ENFORCED_VERTICES_BEGIN__")
2203 hasEnforcedVertex = true;
2204 else if (option_or_sm == "__PRECAD_FACES_PERIODICITY_BEGIN__")
2205 hasPreCADFacesPeriodicity = true;
2206 else if (option_or_sm == "__PRECAD_EDGES_PERIODICITY_BEGIN__")
2207 hasPreCADEdgesPeriodicity = true;
2208 else if (option_or_sm == "__FACES_PERIODICITY_BEGIN__")
2209 hasFacesPeriodicity = true;
2210 else if (option_or_sm == "__EDGES_PERIODICITY_BEGIN__")
2211 hasEdgesPeriodicity = true;
2212 else if (option_or_sm == "__VERTICES_PERIODICITY_BEGIN__")
2213 hasVerticesPeriodicity = true;
2217 std::string smEntry, smValue;
2218 while (isOK && hasSizeMap) {
2219 isOK = static_cast<bool>(load >> smEntry);
2221 if (smEntry == "__SIZEMAP_END__")
2223 isOK = static_cast<bool>(load >> smValue);
2226 std::string & value2 = _sizeMap[smEntry];
2228 int len2 = value2.size();
2229 // continue reading until "%#" encountered
2230 while (value2[len2 - 1] != '#' || value2[len2 - 2] != '%') {
2231 isOK = static_cast<bool>(load >> smValue);
2235 len2 = value2.size();
2240 value2[len2 - 2] = '\0'; //cut off "%#"
2245 isOK = static_cast<bool>(load >> option_or_sm);
2247 if (option_or_sm == "__ATTRACTORS_BEGIN__")
2248 hasAttractor = true;
2249 if (option_or_sm == "__NEW_ATTRACTORS_BEGIN__")
2250 hasNewAttractor = true;
2251 else if (option_or_sm == "__ENFORCED_VERTICES_BEGIN__")
2252 hasEnforcedVertex = true;
2253 else if (option_or_sm == "__PRECAD_FACES_PERIODICITY_BEGIN__")
2254 hasPreCADFacesPeriodicity = true;
2255 else if (option_or_sm == "__PRECAD_EDGES_PERIODICITY_BEGIN__")
2256 hasPreCADEdgesPeriodicity = true;
2257 else if (option_or_sm == "__FACES_PERIODICITY_BEGIN__")
2258 hasFacesPeriodicity = true;
2259 else if (option_or_sm == "__EDGES_PERIODICITY_BEGIN__")
2260 hasEdgesPeriodicity = true;
2261 else if (option_or_sm == "__VERTICES_PERIODICITY_BEGIN__")
2262 hasVerticesPeriodicity = true;
2265 std::string atEntry, atValue;
2266 while (isOK && hasAttractor) {
2267 isOK = static_cast<bool>(load >> atEntry);
2269 if (atEntry == "__ATTRACTORS_END__")
2271 isOK = static_cast<bool>(load >> atValue);
2274 std::string & value3 = _attractors[atEntry];
2276 int len3 = value3.size();
2277 // continue reading until "%#" encountered
2278 while (value3[len3 - 1] != '#' || value3[len3 - 2] != '%') {
2279 isOK = static_cast<bool>(load >> atValue);
2283 len3 = value3.size();
2288 value3[len3 - 2] = '\0'; //cut off "%#"
2293 isOK = static_cast<bool>(load >> option_or_sm);
2295 if (option_or_sm == "__NEW_ATTRACTORS_BEGIN__")
2296 hasNewAttractor = true;
2297 else if (option_or_sm == "__ENFORCED_VERTICES_BEGIN__")
2298 hasEnforcedVertex = true;
2299 else if (option_or_sm == "__PRECAD_FACES_PERIODICITY_BEGIN__")
2300 hasPreCADFacesPeriodicity = true;
2301 else if (option_or_sm == "__PRECAD_EDGES_PERIODICITY_BEGIN__")
2302 hasPreCADEdgesPeriodicity = true;
2303 else if (option_or_sm == "__FACES_PERIODICITY_BEGIN__")
2304 hasFacesPeriodicity = true;
2305 else if (option_or_sm == "__EDGES_PERIODICITY_BEGIN__")
2306 hasEdgesPeriodicity = true;
2307 else if (option_or_sm == "__VERTICES_PERIODICITY_BEGIN__")
2308 hasVerticesPeriodicity = true;
2312 std::string newAtFaceEntry, atTestString;
2313 std::string newAtShapeEntry;
2314 double attParams[4];
2316 while (isOK && hasNewAttractor) {
2317 //std::cout<<"Load new attractor"<<std::endl;
2318 isOK = static_cast<bool>(load >> newAtFaceEntry);
2320 if (newAtFaceEntry == "__NEW_ATTRACTORS_END__")
2322 isOK = static_cast<bool>(load >> newAtShapeEntry);
2325 isOK = static_cast<bool>(load >> attParams[0]>>attParams[1]>>attParams[2]>>attParams[3]); //>>step);
2328 MESSAGE(" LOADING ATTRACTOR HYPOTHESIS ")
2329 const TopoDS_Shape attractorShape = BLSURFPlugin_Hypothesis::entryToShape(newAtShapeEntry);
2330 const TopoDS_Face faceShape = TopoDS::Face(BLSURFPlugin_Hypothesis::entryToShape(newAtFaceEntry));
2331 BLSURFPlugin_Attractor* attractor = new BLSURFPlugin_Attractor(faceShape, attractorShape, newAtShapeEntry);//, step);
2332 attractor->SetParameters(attParams[0], attParams[1], attParams[2], attParams[3]);
2333 //attractor->BuildMap();
2334 _classAttractors.insert( make_pair( newAtFaceEntry, attractor ));
2339 if (hasNewAttractor) {
2340 isOK = static_cast<bool>(load >> option_or_sm);
2342 if (option_or_sm == "__ENFORCED_VERTICES_BEGIN__")
2343 hasEnforcedVertex = true;
2344 else if (option_or_sm == "__PRECAD_FACES_PERIODICITY_BEGIN__")
2345 hasPreCADFacesPeriodicity = true;
2346 else if (option_or_sm == "__PRECAD_EDGES_PERIODICITY_BEGIN__")
2347 hasPreCADEdgesPeriodicity = true;
2348 else if (option_or_sm == "__FACES_PERIODICITY_BEGIN__")
2349 hasFacesPeriodicity = true;
2350 else if (option_or_sm == "__EDGES_PERIODICITY_BEGIN__")
2351 hasEdgesPeriodicity = true;
2352 else if (option_or_sm == "__VERTICES_PERIODICITY_BEGIN__")
2353 hasVerticesPeriodicity = true;
2359 // Here is a example of the saved stream:
2360 // __ENFORCED_VERTICES_BEGIN__
2361 // __BEGIN_VERTEX__ => no name, no entry
2362 // __BEGIN_GROUP__ mon groupe __END_GROUP__
2363 // __BEGIN_COORDS__ 10 10 10 __END_COORDS__
2364 // __BEGIN_FACELIST__ 0:1:1:1:1 __END_FACELIST__
2366 // __BEGIN_VERTEX__ => no coords
2367 // __BEGIN_NAME__ mes points __END_NAME__
2368 // __BEGIN_ENTRY__ 0:1:1:4 __END_ENTRY__
2369 // __BEGIN_GROUP__ mon groupe __END_GROUP__
2370 // __BEGIN_FACELIST__ 0:1:1:1:3 __END_FACELIST__
2372 // __ENFORCED_VERTICES_END__
2375 std::string enfSeparator;
2376 std::string enfName;
2377 std::string enfGeomEntry;
2378 std::string enfGroup;
2379 TEntryList enfFaceEntryList;
2380 double enfCoords[3];
2381 bool hasCoords = false;
2383 _faceEntryEnfVertexListMap.clear();
2384 _enfVertexList.clear();
2385 _faceEntryCoordsListMap.clear();
2386 _coordsEnfVertexMap.clear();
2387 _faceEntryEnfVertexEntryListMap.clear();
2388 _enfVertexEntryEnfVertexMap.clear();
2391 while (isOK && hasEnforcedVertex) {
2392 isOK = static_cast<bool>(load >> enfSeparator); // __BEGIN_VERTEX__
2393 TEnfVertex *enfVertex = new TEnfVertex();
2394 // MESSAGE("enfSeparator: " <<enfSeparator);
2395 if (enfSeparator == "__ENFORCED_VERTICES_END__")
2396 break; // __ENFORCED_VERTICES_END__
2397 if (enfSeparator != "__BEGIN_VERTEX__")
2398 throw std::exception();
2401 isOK = static_cast<bool>(load >> enfSeparator);
2402 MESSAGE("enfSeparator: " <<enfSeparator);
2403 if (enfSeparator == "__END_VERTEX__") {
2405 enfVertex->name = enfName;
2406 enfVertex->geomEntry = enfGeomEntry;
2407 enfVertex->grpName = enfGroup;
2408 enfVertex->coords.clear();
2410 enfVertex->coords.assign(enfCoords,enfCoords+3);
2411 enfVertex->faceEntries = enfFaceEntryList;
2413 _enfVertexList.insert(enfVertex);
2415 if (enfVertex->coords.size()) {
2416 _coordsEnfVertexMap[enfVertex->coords] = enfVertex;
2417 for (TEntryList::const_iterator it = enfVertex->faceEntries.begin() ; it != enfVertex->faceEntries.end(); ++it) {
2418 _faceEntryCoordsListMap[(*it)].insert(enfVertex->coords);
2419 _faceEntryEnfVertexListMap[(*it)].insert(enfVertex);
2422 if (!enfVertex->geomEntry.empty()) {
2423 _enfVertexEntryEnfVertexMap[enfVertex->geomEntry] = enfVertex;
2424 for (TEntryList::const_iterator it = enfVertex->faceEntries.begin() ; it != enfVertex->faceEntries.end(); ++it) {
2425 _faceEntryEnfVertexEntryListMap[(*it)].insert(enfVertex->geomEntry);
2426 _faceEntryEnfVertexListMap[(*it)].insert(enfVertex);
2431 enfGeomEntry.clear();
2433 enfFaceEntryList.clear();
2435 break; // __END_VERTEX__
2438 if (enfSeparator == "__BEGIN_NAME__") { // __BEGIN_NAME__
2439 while (isOK && (enfSeparator != "__END_NAME__")) {
2440 isOK = static_cast<bool>(load >> enfSeparator);
2441 if (enfSeparator != "__END_NAME__") {
2442 if (!enfName.empty())
2444 enfName += enfSeparator;
2447 MESSAGE("enfName: " <<enfName);
2450 if (enfSeparator == "__BEGIN_ENTRY__") { // __BEGIN_ENTRY__
2451 isOK = static_cast<bool>(load >> enfGeomEntry);
2452 isOK = static_cast<bool>(load >> enfSeparator); // __END_ENTRY__
2453 if (enfSeparator != "__END_ENTRY__")
2454 throw std::exception();
2455 MESSAGE("enfGeomEntry: " <<enfGeomEntry);
2458 if (enfSeparator == "__BEGIN_GROUP__") { // __BEGIN_GROUP__
2459 while (isOK && (enfSeparator != "__END_GROUP__")) {
2460 isOK = static_cast<bool>(load >> enfSeparator);
2461 if (enfSeparator != "__END_GROUP__") {
2462 if (!enfGroup.empty())
2464 enfGroup += enfSeparator;
2467 MESSAGE("enfGroup: " <<enfGroup);
2470 if (enfSeparator == "__BEGIN_COORDS__") { // __BEGIN_COORDS__
2472 isOK = static_cast<bool>(load >> enfCoords[0] >> enfCoords[1] >> enfCoords[2]);
2473 isOK = static_cast<bool>(load >> enfSeparator); // __END_COORDS__
2474 if (enfSeparator != "__END_COORDS__")
2475 throw std::exception();
2476 MESSAGE("enfCoords: " << enfCoords[0] <<","<< enfCoords[1] <<","<< enfCoords[2]);
2479 if (enfSeparator == "__BEGIN_FACELIST__") { // __BEGIN_FACELIST__
2480 while (isOK && (enfSeparator != "__END_FACELIST__")) {
2481 isOK = static_cast<bool>(load >> enfSeparator);
2482 if (enfSeparator != "__END_FACELIST__") {
2483 enfFaceEntryList.insert(enfSeparator);
2484 MESSAGE(enfSeparator << " was inserted into enfFaceEntryList");
2493 if (hasPreCADFacesPeriodicity){
2494 LoadPreCADPeriodicity(load, "FACES");
2496 isOK = static_cast<bool>(load >> option_or_sm);
2498 if (option_or_sm == "__PRECAD_EDGES_PERIODICITY_BEGIN__")
2499 hasPreCADEdgesPeriodicity = true;
2500 else if (option_or_sm == "__FACES_PERIODICITY_BEGIN__")
2501 hasFacesPeriodicity = true;
2502 else if (option_or_sm == "__EDGES_PERIODICITY_BEGIN__")
2503 hasEdgesPeriodicity = true;
2504 else if (option_or_sm == "__VERTICES_PERIODICITY_BEGIN__")
2505 hasVerticesPeriodicity = true;
2509 if (hasPreCADEdgesPeriodicity){
2510 LoadPreCADPeriodicity(load, "EDGES");
2512 isOK = static_cast<bool>(load >> option_or_sm);
2514 if (option_or_sm == "__FACES_PERIODICITY_BEGIN__")
2515 hasFacesPeriodicity = true;
2516 else if (option_or_sm == "__EDGES_PERIODICITY_BEGIN__")
2517 hasEdgesPeriodicity = true;
2518 else if (option_or_sm == "__VERTICES_PERIODICITY_BEGIN__")
2519 hasVerticesPeriodicity = true;
2523 if (hasFacesPeriodicity){
2524 LoadFacesPeriodicity(load);
2526 isOK = static_cast<bool>(load >> option_or_sm);
2528 if (option_or_sm == "__EDGES_PERIODICITY_BEGIN__")
2529 hasEdgesPeriodicity = true;
2530 else if (option_or_sm == "__VERTICES_PERIODICITY_BEGIN__")
2531 hasVerticesPeriodicity = true;
2535 if (hasEdgesPeriodicity){
2536 LoadEdgesPeriodicity(load);
2538 isOK = static_cast<bool>(load >> option_or_sm);
2540 if (option_or_sm == "__VERTICES_PERIODICITY_BEGIN__")
2541 hasVerticesPeriodicity = true;
2544 if (hasVerticesPeriodicity)
2545 LoadVerticesPeriodicity(load);
2550 void BLSURFPlugin_Hypothesis::LoadFacesPeriodicity(std::istream & load){
2554 std::string periodicitySeparator;
2558 _facesPeriodicityVector.clear();
2561 isOK = static_cast<bool>(load >> periodicitySeparator); // __BEGIN_PERIODICITY_DESCRIPTION__
2562 MESSAGE("periodicitySeparator 1: " <<periodicitySeparator);
2563 TFacesPeriodicity *periodicity_i = new TFacesPeriodicity();
2564 if (periodicitySeparator == "__FACES_PERIODICITY_END__")
2565 break; // __FACES_PERIODICITY_END__
2566 if (periodicitySeparator != "__BEGIN_PERIODICITY_DESCRIPTION__"){
2567 MESSAGE("//" << periodicitySeparator << "//");
2568 throw std::exception();
2572 isOK = static_cast<bool>(load >> periodicitySeparator);
2573 MESSAGE("periodicitySeparator 2: " <<periodicitySeparator);
2574 if (periodicitySeparator == "__END_PERIODICITY_DESCRIPTION__") {
2576 periodicity_i->first = shape1Entry;
2577 periodicity_i->second = shape2Entry;
2579 _facesPeriodicityVector.push_back(*periodicity_i);
2581 break; // __END_PERIODICITY_DESCRIPTION__
2584 if (periodicitySeparator == "__BEGIN_ENTRY1__") { // __BEGIN_ENTRY1__
2585 isOK = static_cast<bool>(load >> shape1Entry);
2586 isOK = static_cast<bool>(load >> periodicitySeparator); // __END_ENTRY1__
2587 if (periodicitySeparator != "__END_ENTRY1__")
2588 throw std::exception();
2589 MESSAGE("shape1Entry: " <<shape1Entry);
2592 if (periodicitySeparator == "__BEGIN_ENTRY2__") { // __BEGIN_ENTRY2__
2593 isOK = static_cast<bool>(load >> shape2Entry);
2594 isOK = static_cast<bool>(load >> periodicitySeparator); // __END_ENTRY2__
2595 if (periodicitySeparator != "__END_ENTRY2__")
2596 throw std::exception();
2597 MESSAGE("shape2Entry: " <<shape2Entry);
2604 void BLSURFPlugin_Hypothesis::LoadEdgesPeriodicity(std::istream & load){
2608 std::string periodicitySeparator;
2609 TEntry theFace1Entry;
2610 TEntry theEdge1Entry;
2611 TEntry theFace2Entry;
2612 TEntry theEdge2Entry;
2613 int edge_orientation = 0;
2615 _edgesPeriodicityVector.clear();
2618 isOK = static_cast<bool>(load >> periodicitySeparator); // __BEGIN_PERIODICITY_DESCRIPTION__
2619 MESSAGE("periodicitySeparator 1: " <<periodicitySeparator);
2620 TEdgePeriodicity *periodicity_i = new TEdgePeriodicity();
2621 if (periodicitySeparator == "__EDGES_PERIODICITY_END__")
2622 break; // __EDGES_PERIODICITY_END__
2623 if (periodicitySeparator != "__BEGIN_PERIODICITY_DESCRIPTION__"){
2624 MESSAGE("//" << periodicitySeparator << "//");
2625 throw std::exception();
2629 isOK = static_cast<bool>(load >> periodicitySeparator);
2630 MESSAGE("periodicitySeparator 2: " <<periodicitySeparator);
2631 if (periodicitySeparator == "__END_PERIODICITY_DESCRIPTION__") {
2633 periodicity_i->theFace1Entry = theFace1Entry;
2634 periodicity_i->theEdge1Entry = theEdge1Entry;
2635 periodicity_i->theFace2Entry = theFace2Entry;
2636 periodicity_i->theEdge2Entry = theEdge2Entry;
2637 periodicity_i->edge_orientation = edge_orientation;
2639 _edgesPeriodicityVector.push_back(*periodicity_i);
2641 break; // __END_PERIODICITY_DESCRIPTION__
2644 if (periodicitySeparator == "__BEGIN_FACE1__") { // __BEGIN_FACE1__
2645 isOK = static_cast<bool>(load >> theFace1Entry);
2646 MESSAGE("//" << theFace1Entry << "//");
2647 isOK = static_cast<bool>(load >> periodicitySeparator); // __END_FACE1__
2648 if (periodicitySeparator != "__END_FACE1__"){
2649 MESSAGE("//" << periodicitySeparator << "//");
2650 throw std::exception();
2652 MESSAGE("theFace1Entry: " <<theFace1Entry);
2655 if (periodicitySeparator == "__BEGIN_EDGE1__") { // __BEGIN_EDGE1__
2656 isOK = static_cast<bool>(load >> theEdge1Entry);
2657 isOK = static_cast<bool>(load >> periodicitySeparator); // __END_EDGE1__
2658 if (periodicitySeparator != "__END_EDGE1__")
2659 throw std::exception();
2660 MESSAGE("theEdge1Entry: " <<theEdge1Entry);
2663 if (periodicitySeparator == "__BEGIN_FACE2__") { // __BEGIN_FACE2__
2664 isOK = static_cast<bool>(load >> theFace2Entry);
2665 isOK = static_cast<bool>(load >> periodicitySeparator); // __END_FACE2__
2666 if (periodicitySeparator != "__END_FACE2__")
2667 throw std::exception();
2668 MESSAGE("theFace2Entry: " <<theFace2Entry);
2671 if (periodicitySeparator == "__BEGIN_EDGE2__") { // __BEGIN_EDGE2__
2672 isOK = static_cast<bool>(load >> theEdge2Entry);
2673 isOK = static_cast<bool>(load >> periodicitySeparator); // __END_EDGE2__
2674 if (periodicitySeparator != "__END_EDGE2__")
2675 throw std::exception();
2676 MESSAGE("theEdge2Entry: " <<theEdge2Entry);
2679 if (periodicitySeparator == "__BEGIN_EDGE_ORIENTATION__") { // __BEGIN_EDGE_ORIENTATION__
2680 isOK = static_cast<bool>(load >> edge_orientation);
2681 isOK = static_cast<bool>(load >> periodicitySeparator); // __END_EDGE_ORIENTATION__
2682 if (periodicitySeparator != "__END_EDGE_ORIENTATION__")
2683 throw std::exception();
2684 MESSAGE("edge_orientation: " <<edge_orientation);
2690 void BLSURFPlugin_Hypothesis::LoadVerticesPeriodicity(std::istream & load){
2694 std::string periodicitySeparator;
2695 TEntry theEdge1Entry;
2696 TEntry theVertex1Entry;
2697 TEntry theEdge2Entry;
2698 TEntry theVertex2Entry;
2700 _verticesPeriodicityVector.clear();
2703 isOK = static_cast<bool>(load >> periodicitySeparator); // __BEGIN_PERIODICITY_DESCRIPTION__
2704 MESSAGE("periodicitySeparator 1: " <<periodicitySeparator);
2705 TVertexPeriodicity *periodicity_i = new TVertexPeriodicity();
2706 if (periodicitySeparator == "__VERTICES_PERIODICITY_END__")
2707 break; // __VERTICES_PERIODICITY_END__
2708 if (periodicitySeparator != "__BEGIN_PERIODICITY_DESCRIPTION__"){
2709 MESSAGE("//" << periodicitySeparator << "//");
2710 throw std::exception();
2714 isOK = static_cast<bool>(load >> periodicitySeparator);
2715 MESSAGE("periodicitySeparator 2: " <<periodicitySeparator);
2716 if (periodicitySeparator == "__END_PERIODICITY_DESCRIPTION__") {
2718 periodicity_i->theEdge1Entry = theEdge1Entry;
2719 periodicity_i->theVertex1Entry = theVertex1Entry;
2720 periodicity_i->theEdge2Entry = theEdge2Entry;
2721 periodicity_i->theVertex2Entry = theVertex2Entry;
2723 _verticesPeriodicityVector.push_back(*periodicity_i);
2725 break; // __END_PERIODICITY_DESCRIPTION__
2728 if (periodicitySeparator == "__BEGIN_EDGE1__") { // __BEGIN_EDGE1__
2729 isOK = static_cast<bool>(load >> theEdge1Entry);
2730 isOK = static_cast<bool>(load >> periodicitySeparator); // __END_EDGE1__
2731 if (periodicitySeparator != "__END_EDGE1__")
2732 throw std::exception();
2733 MESSAGE("theEdge1Entry: " <<theEdge1Entry);
2736 if (periodicitySeparator == "__BEGIN_VERTEX1__") { // __BEGIN_VERTEX1__
2737 isOK = static_cast<bool>(load >> theVertex1Entry);
2738 isOK = static_cast<bool>(load >> periodicitySeparator); // __END_VERTEX1__
2739 if (periodicitySeparator != "__END_VERTEX1__")
2740 throw std::exception();
2741 MESSAGE("theVertex1Entry: " <<theVertex1Entry);
2744 if (periodicitySeparator == "__BEGIN_EDGE2__") { // __BEGIN_EDGE2__
2745 isOK = static_cast<bool>(load >> theEdge2Entry);
2746 isOK = static_cast<bool>(load >> periodicitySeparator); // __END_EDGE2__
2747 if (periodicitySeparator != "__END_EDGE2__")
2748 throw std::exception();
2749 MESSAGE("theEdge2Entry: " <<theEdge2Entry);
2752 if (periodicitySeparator == "__BEGIN_VERTEX2__") { // __BEGIN_VERTEX2__
2753 isOK = static_cast<bool>(load >> theVertex2Entry);
2754 isOK = static_cast<bool>(load >> periodicitySeparator); // __END_VERTEX2__
2755 if (periodicitySeparator != "__END_VERTEX2__")
2756 throw std::exception();
2757 MESSAGE("theVertex2Entry: " <<theVertex2Entry);
2763 void BLSURFPlugin_Hypothesis::LoadPreCADPeriodicity(std::istream & load, const char* shapeType) {
2767 std::string periodicitySeparator;
2770 std::vector<std::string> theSourceVerticesEntries;
2771 std::vector<std::string> theTargetVerticesEntries;
2773 bool hasSourceVertices = false;
2774 bool hasTargetVertices = false;
2776 if ( shapeType && strcmp( shapeType, "FACES") == 0 )
2777 _preCadFacesPeriodicityVector.clear();
2779 _preCadEdgesPeriodicityVector.clear();
2783 isOK = static_cast<bool>(load >> periodicitySeparator); // __BEGIN_PERIODICITY_DESCRIPTION__
2784 MESSAGE("periodicitySeparator 1: " <<periodicitySeparator);
2785 TPreCadPeriodicity *periodicity_i = new TPreCadPeriodicity();
2786 // MESSAGE("periodicitySeparator: " <<periodicitySeparator);
2787 std::string endSeparator = "__PRECAD_" + std::string(shapeType) + "_PERIODICITY_END__";
2788 if (periodicitySeparator == endSeparator)
2789 break; // __PRECAD_FACES_PERIODICITY_END__
2790 if (periodicitySeparator != "__BEGIN_PERIODICITY_DESCRIPTION__"){
2791 MESSAGE("//" << endSeparator << "//");
2792 MESSAGE("//" << periodicitySeparator << "//");
2793 throw std::exception();
2797 isOK = static_cast<bool>(load >> periodicitySeparator);
2798 MESSAGE("periodicitySeparator 2: " <<periodicitySeparator);
2799 if (periodicitySeparator == "__END_PERIODICITY_DESCRIPTION__") {
2801 periodicity_i->shape1Entry = shape1Entry;
2802 periodicity_i->shape2Entry = shape2Entry;
2804 MESSAGE("theSourceVerticesEntries.size(): " << theSourceVerticesEntries.size());
2805 MESSAGE("theTargetVerticesEntries.size(): " << theTargetVerticesEntries.size());
2807 if (hasSourceVertices)
2808 periodicity_i->theSourceVerticesEntries = theSourceVerticesEntries;
2809 if (hasTargetVertices)
2810 periodicity_i->theTargetVerticesEntries = theTargetVerticesEntries;
2812 if ( shapeType && strcmp( shapeType, "FACES" ))
2813 _preCadFacesPeriodicityVector.push_back(*periodicity_i);
2815 _preCadEdgesPeriodicityVector.push_back(*periodicity_i);
2817 theSourceVerticesEntries.clear();
2818 theTargetVerticesEntries.clear();
2819 hasSourceVertices = false;
2820 hasTargetVertices = false;
2821 break; // __END_PERIODICITY_DESCRIPTION__
2824 if (periodicitySeparator == "__BEGIN_ENTRY1__") { // __BEGIN_ENTRY1__
2825 isOK = static_cast<bool>(load >> shape1Entry);
2826 isOK = static_cast<bool>(load >> periodicitySeparator); // __END_ENTRY1__
2827 if (periodicitySeparator != "__END_ENTRY1__")
2828 throw std::exception();
2829 MESSAGE("shape1Entry: " <<shape1Entry);
2832 if (periodicitySeparator == "__BEGIN_ENTRY2__") { // __BEGIN_ENTRY2__
2833 isOK = static_cast<bool>(load >> shape2Entry);
2834 isOK = static_cast<bool>(load >> periodicitySeparator); // __END_ENTRY2__
2835 if (periodicitySeparator != "__END_ENTRY2__")
2836 throw std::exception();
2837 MESSAGE("shape2Entry: " <<shape2Entry);
2840 if (periodicitySeparator == "__BEGIN_SOURCE_VERTICES_LIST__") { // __BEGIN_SOURCE_VERTICES_LIST__
2841 hasSourceVertices = true;
2842 while (isOK && (periodicitySeparator != "__END_SOURCE_VERTICES_LIST__")) {
2843 isOK = static_cast<bool>(load >> periodicitySeparator);
2844 if (periodicitySeparator != "__END_SOURCE_VERTICES_LIST__") {
2845 theSourceVerticesEntries.push_back(periodicitySeparator);
2846 MESSAGE("theSourceVerticesEntries: " <<periodicitySeparator);
2851 if (periodicitySeparator == "__BEGIN_TARGET_VERTICES_LIST__") { // __BEGIN_TARGET_VERTICES_LIST__
2852 hasTargetVertices = true;
2853 while (isOK && (periodicitySeparator != "__END_TARGET_VERTICES_LIST__")) {
2854 isOK = static_cast<bool>(load >> periodicitySeparator);
2855 if (periodicitySeparator != "__END_TARGET_VERTICES_LIST__") {
2856 theTargetVerticesEntries.push_back(periodicitySeparator);
2857 MESSAGE("theTargetVerticesEntries: " <<periodicitySeparator);
2865 //=============================================================================
2866 std::ostream & operator <<(std::ostream & save, BLSURFPlugin_Hypothesis & hyp) {
2867 return hyp.SaveTo(save);
2870 //=============================================================================
2871 std::istream & operator >>(std::istream & load, BLSURFPlugin_Hypothesis & hyp) {
2872 return hyp.LoadFrom(load);
2875 //================================================================================
2877 * \brief Does nothing
2879 //================================================================================
2881 bool BLSURFPlugin_Hypothesis::SetParametersByMesh(const SMESH_Mesh* theMesh, const TopoDS_Shape& theShape) {
2885 //================================================================================
2887 * \brief Returns default global constant physical size given a default value of element length ratio
2889 //================================================================================
2891 double BLSURFPlugin_Hypothesis::GetDefaultPhySize(double diagonal, double bbSegmentation) {
2892 if (bbSegmentation != 0 && diagonal != 0)
2893 return diagonal / bbSegmentation ;
2897 //================================================================================
2899 * \brief Returns default min size given a default value of element length ratio
2901 //================================================================================
2903 double BLSURFPlugin_Hypothesis::GetDefaultMinSize(double diagonal) {
2905 return diagonal / 1000.0 ;
2906 return undefinedDouble();
2909 //================================================================================
2911 * \brief Returns default max size given a default value of element length ratio
2913 //================================================================================
2915 double BLSURFPlugin_Hypothesis::GetDefaultMaxSize(double diagonal) {
2917 return diagonal / 5.0 ;
2918 return undefinedDouble();
2921 //================================================================================
2923 * \brief Returns default chordal error given a default value of element length ratio
2925 //================================================================================
2927 double BLSURFPlugin_Hypothesis::GetDefaultChordalError(double diagonal) {
2930 return undefinedDouble();
2933 //================================================================================
2935 * \brief Returns default tiny edge length given a default value of element length ratio
2937 //================================================================================
2939 double BLSURFPlugin_Hypothesis::GetDefaultTinyEdgeLength(double diagonal) {
2941 return diagonal * 1e-6 ;
2942 return undefinedDouble();
2945 //=============================================================================
2947 * \brief Initialize my parameter values by default parameters.
2948 * \retval bool - true if parameter values have been successfully defined
2950 //=============================================================================
2952 bool BLSURFPlugin_Hypothesis::SetParametersByDefaults(const TDefaults& dflts, const SMESH_Mesh* theMesh) {
2953 double diagonal = dflts._elemLength*_gen->GetBoundaryBoxSegmentation();
2954 _phySize = GetDefaultPhySize(diagonal, _gen->GetBoundaryBoxSegmentation());
2955 _minSize = GetDefaultMinSize(diagonal);
2956 _maxSize = GetDefaultMaxSize(diagonal);
2957 _chordalError = GetDefaultChordalError(diagonal);
2958 _tinyEdgeLength = GetDefaultTinyEdgeLength(diagonal);
2961 // return bool(_phySize = dflts._elemLength);