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 _preCADRemoveDuplicateCADFaces(GetDefaultPreCADRemoveDuplicateCADFaces()),
69 _preCADProcess3DTopology(GetDefaultPreCADProcess3DTopology()),
70 _preCADDiscardInput(GetDefaultPreCADDiscardInput()),
71 _sizeMap(GetDefaultSizeMap()),
72 _attractors(GetDefaultSizeMap()),
73 _classAttractors(GetDefaultAttractorMap()),
74 _faceEntryEnfVertexListMap(GetDefaultFaceEntryEnfVertexListMap()),
75 _enfVertexList(GetDefaultEnfVertexList()),
76 _faceEntryCoordsListMap(GetDefaultFaceEntryCoordsListMap()),
77 _coordsEnfVertexMap(GetDefaultCoordsEnfVertexMap()),
78 _faceEntryEnfVertexEntryListMap(GetDefaultFaceEntryEnfVertexEntryListMap()),
79 _enfVertexEntryEnfVertexMap(GetDefaultEnfVertexEntryEnfVertexMap()),
80 _groupNameNodeIDMap(GetDefaultGroupNameNodeIDMap()),
81 _enforcedInternalVerticesAllFaces(GetDefaultInternalEnforcedVertex()),
82 _preCadFacesPeriodicityVector(GetDefaultPreCadFacesPeriodicityVector()),
83 _preCadEdgesPeriodicityVector(GetDefaultPreCadEdgesPeriodicityVector()),
84 _GMFFileName(GetDefaultGMFFile())
89 // _GMFFileMode = false; // GMF ascii mode
91 const char* boolOptionNames[] = { "correct_surface_intersections", // default = 1
92 "create_tag_on_collision", // default = 1
93 "debug", // default = 0
94 "enforce_cad_edge_sizes", // default = 0
95 "frontal", // ok default = 1
96 "jacobian_rectification_respect_geometry", // default = 1
97 "proximity", // default = 0
98 "rectify_jacobian", // default = 1
99 "respect_geometry", // default = 1
100 "optimise_tiny_edges", // default = 0
101 "remove_duplicate_cad_faces", // default = 1
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::SetPreCADRemoveDuplicateCADFaces(bool theVal) {
397 if (theVal != _preCADRemoveDuplicateCADFaces) {
398 // SetTopology(PreCAD);
399 _preCADRemoveDuplicateCADFaces = theVal;
400 NotifySubMeshesHypothesisModification();
404 //=============================================================================
405 void BLSURFPlugin_Hypothesis::SetPreCADProcess3DTopology(bool theVal) {
406 if (theVal != _preCADProcess3DTopology) {
407 // SetTopology(PreCAD);
408 _preCADProcess3DTopology = theVal;
409 NotifySubMeshesHypothesisModification();
413 //=============================================================================
414 void BLSURFPlugin_Hypothesis::SetPreCADDiscardInput(bool theVal) {
415 if (theVal != _preCADDiscardInput) {
416 // SetTopology(PreCAD);
417 _preCADDiscardInput = theVal;
418 NotifySubMeshesHypothesisModification();
422 //=============================================================================
423 // void BLSURFPlugin_Hypothesis::SetGMFFile(const std::string& theFileName, bool isBinary)
424 void BLSURFPlugin_Hypothesis::SetGMFFile(const std::string& theFileName)
426 _GMFFileName = theFileName;
427 // _GMFFileMode = isBinary;
428 NotifySubMeshesHypothesisModification();
431 //=============================================================================
432 void BLSURFPlugin_Hypothesis::SetOptionValue(const std::string& optionName, const std::string& optionValue)
433 throw (std::invalid_argument) {
434 TOptionValues::iterator op_val = _option2value.find(optionName);
435 if (op_val == _option2value.end()) {
436 std::string msg = "Unknown MG-CADSurf option: '" + optionName + "'";
437 throw std::invalid_argument(msg);
439 if (op_val->second != optionValue) {
440 const char* ptr = optionValue.c_str();
441 // strip white spaces
442 while (ptr[0] == ' ')
445 while (i != 0 && ptr[i - 1] == ' ')
449 std::string typeName;
452 } else if (_charOptions.find(optionName) != _charOptions.end()) {
453 // do not check strings
454 } else if (_doubleOptions.find(optionName) != _doubleOptions.end()) {
455 // check if value is double
457 strtod(ptr, &endPtr);
458 typeOk = (ptr != endPtr);
461 // check if value is int
463 strtol(ptr, &endPtr, 10);
464 typeOk = (ptr != endPtr);
465 typeName = "integer";
468 std::string msg = "Advanced option '" + optionName + "' = '" + optionValue + "' but must be " + typeName;
469 throw std::invalid_argument(msg);
471 op_val->second = optionValue;
472 NotifySubMeshesHypothesisModification();
476 //=============================================================================
477 void BLSURFPlugin_Hypothesis::SetPreCADOptionValue(const std::string& optionName, const std::string& optionValue)
478 throw (std::invalid_argument) {
479 TOptionValues::iterator op_val = _preCADoption2value.find(optionName);
480 if (op_val == _preCADoption2value.end()) {
481 std::string msg = "Unknown MG-CADSurf option: '" + optionName + "'";
482 throw std::invalid_argument(msg);
484 if (op_val->second != optionValue) {
485 const char* ptr = optionValue.c_str();
486 // strip white spaces
487 while (ptr[0] == ' ')
490 while (i != 0 && ptr[i - 1] == ' ')
494 std::string typeName;
497 } else if (_preCADcharOptions.find(optionName) != _preCADcharOptions.end()) {
498 // do not check strings
499 } else if (_preCADdoubleOptions.find(optionName) != _preCADdoubleOptions.end()) {
500 // check if value is double
502 strtod(ptr, &endPtr);
503 typeOk = (ptr != endPtr);
506 // check if value is int
508 strtol(ptr, &endPtr, 10);
509 typeOk = (ptr != endPtr);
510 typeName = "integer";
513 std::string msg = "PreCAD advanced option '" + optionName + "' = '" + optionValue + "' but must be " + typeName;
514 throw std::invalid_argument(msg);
516 op_val->second = optionValue;
517 NotifySubMeshesHypothesisModification();
521 //=============================================================================
522 std::string BLSURFPlugin_Hypothesis::GetOptionValue(const std::string& optionName) throw (std::invalid_argument) {
523 TOptionValues::iterator op_val = _option2value.find(optionName);
524 if (op_val == _option2value.end()) {
525 std::string msg = "Unknown MG-CADSurf option: <";
526 msg += optionName + ">";
527 throw std::invalid_argument(msg);
529 return op_val->second;
532 //=============================================================================
533 std::string BLSURFPlugin_Hypothesis::GetPreCADOptionValue(const std::string& optionName) throw (std::invalid_argument) {
534 TOptionValues::iterator op_val = _preCADoption2value.find(optionName);
535 if (op_val == _preCADoption2value.end()) {
536 std::string msg = "Unknown PRECAD option: <";
537 msg += optionName + ">";
538 throw std::invalid_argument(msg);
540 return op_val->second;
543 //=============================================================================
544 void BLSURFPlugin_Hypothesis::ClearOption(const std::string& optionName) {
545 TOptionValues::iterator op_val = _customOption2value.find(optionName);
546 if (op_val != _customOption2value.end())
547 _customOption2value.erase(op_val);
549 op_val = _option2value.find(optionName);
550 if (op_val != _option2value.end())
551 op_val->second.clear();
555 //=============================================================================
556 void BLSURFPlugin_Hypothesis::ClearPreCADOption(const std::string& optionName) {
557 TOptionValues::iterator op_val = _customPreCADOption2value.find(optionName);
558 if (op_val != _customPreCADOption2value.end())
559 _customPreCADOption2value.erase(op_val);
561 op_val = _preCADoption2value.find(optionName);
562 if (op_val != _preCADoption2value.end())
563 op_val->second.clear();
567 //=============================================================================
568 void BLSURFPlugin_Hypothesis::AddOption(const std::string& optionName, const std::string& optionValue)
570 TOptionValues::iterator op_val = _option2value.find(optionName);
571 if (op_val != _option2value.end()) {
572 if (op_val->second != optionValue)
573 op_val->second = optionValue;
576 op_val = _customOption2value.find(optionName);
577 if (op_val == _customOption2value.end())
578 _customOption2value[optionName] = optionValue;
579 else if (op_val->second != optionValue)
580 op_val->second = optionValue;
582 NotifySubMeshesHypothesisModification();
585 //=============================================================================
586 void BLSURFPlugin_Hypothesis::AddPreCADOption(const std::string& optionName, const std::string& optionValue)
588 TOptionValues::iterator op_val = _preCADoption2value.find(optionName);
589 if (op_val != _preCADoption2value.end()) {
590 if (op_val->second != optionValue)
591 op_val->second = optionValue;
594 op_val = _customPreCADOption2value.find(optionName);
595 if (op_val == _customPreCADOption2value.end())
596 _customPreCADOption2value[optionName] = optionValue;
597 else if (op_val->second != optionValue)
598 op_val->second = optionValue;
600 NotifySubMeshesHypothesisModification();
603 //=============================================================================
604 std::string BLSURFPlugin_Hypothesis::GetOption(const std::string& optionName)
606 TOptionValues::iterator op_val = _customOption2value.find(optionName);
607 if (op_val != _customOption2value.end())
608 return op_val->second;
613 //=============================================================================
614 std::string BLSURFPlugin_Hypothesis::GetPreCADOption(const std::string& optionName)
616 TOptionValues::iterator op_val = _customPreCADOption2value.find(optionName);
617 if (op_val != _customPreCADOption2value.end())
618 return op_val->second;
623 //=======================================================================
624 //function : SetSizeMapEntry
625 //=======================================================================
626 void BLSURFPlugin_Hypothesis::SetSizeMapEntry(const std::string& entry, const std::string& sizeMap) {
627 if (_sizeMap[entry].compare(sizeMap) != 0) {
628 SetPhysicalMesh(PhysicalLocalSize);
629 _sizeMap[entry] = sizeMap;
630 NotifySubMeshesHypothesisModification();
634 //=======================================================================
635 //function : GetSizeMapEntry
636 //=======================================================================
637 std::string BLSURFPlugin_Hypothesis::GetSizeMapEntry(const std::string& entry) {
638 TSizeMap::iterator it = _sizeMap.find(entry);
639 if (it != _sizeMap.end())
642 return "No_Such_Entry";
646 * \brief Return the size maps
648 BLSURFPlugin_Hypothesis::TSizeMap BLSURFPlugin_Hypothesis::GetSizeMapEntries(const BLSURFPlugin_Hypothesis* hyp) {
649 return hyp ? hyp->_GetSizeMapEntries() : GetDefaultSizeMap();
652 //=======================================================================
653 //function : SetAttractorEntry
654 //=======================================================================
655 void BLSURFPlugin_Hypothesis::SetAttractorEntry(const std::string& entry, const std::string& attractor) {
656 if (_attractors[entry].compare(attractor) != 0) {
657 SetPhysicalMesh(PhysicalLocalSize);
658 _attractors[entry] = attractor;
659 NotifySubMeshesHypothesisModification();
663 //=======================================================================
664 //function : GetAttractorEntry
665 //=======================================================================
666 std::string BLSURFPlugin_Hypothesis::GetAttractorEntry(const std::string& entry) {
667 TSizeMap::iterator it = _attractors.find(entry);
668 if (it != _attractors.end())
671 return "No_Such_Entry";
675 * \brief Return the attractors
677 BLSURFPlugin_Hypothesis::TSizeMap BLSURFPlugin_Hypothesis::GetAttractorEntries(const BLSURFPlugin_Hypothesis* hyp) {
678 return hyp ? hyp->_GetAttractorEntries() : GetDefaultSizeMap();
681 //=======================================================================
682 //function : SetClassAttractorEntry
683 //=======================================================================
684 void BLSURFPlugin_Hypothesis::SetClassAttractorEntry(const std::string& entry, const std::string& attEntry, double StartSize, double EndSize, double ActionRadius, double ConstantRadius)
686 SetPhysicalMesh(PhysicalLocalSize);
688 // The new attractor can't be defined on the same face as another sizemap
689 TSizeMap::iterator it = _sizeMap.find( entry );
690 if ( it != _sizeMap.end() ) {
692 NotifySubMeshesHypothesisModification();
695 TSizeMap::iterator itAt = _attractors.find( entry );
696 if ( itAt != _attractors.end() ) {
697 _attractors.erase(itAt);
698 NotifySubMeshesHypothesisModification();
702 const TopoDS_Shape AttractorShape = BLSURFPlugin_Hypothesis::entryToShape(attEntry);
703 const TopoDS_Face FaceShape = TopoDS::Face(BLSURFPlugin_Hypothesis::entryToShape(entry));
704 TAttractorMap::iterator attIt = _classAttractors.find(entry);
705 for ( ; attIt != _classAttractors.end(); ++attIt )
706 if ( attIt->first == entry &&
707 attIt->second->GetAttractorEntry() == attEntry )
709 bool attExists = (attIt != _classAttractors.end());
711 BLSURFPlugin_Attractor* myAttractor;
713 myAttractor = new BLSURFPlugin_Attractor(FaceShape, AttractorShape, attEntry);//, 0.1 );
714 _classAttractors.insert( make_pair( entry, myAttractor ));
717 myAttractor = attIt->second;
719 // if (!myAttractor->IsMapBuilt())
720 // myAttractor->BuildMap();
721 myAttractor->SetParameters(StartSize, EndSize, ActionRadius, ConstantRadius);
723 NotifySubMeshesHypothesisModification();
726 //=======================================================================
727 //function : SetConstantSizeOnAdjacentFaces
728 //=======================================================================
729 // TODO uncomment and test (include the needed .hxx)
730 // SetConstantSizeOnAdjacentFaces(myShape, att_entry, startSize, endSize = user_size, const_dist ) {
731 // TopTools_IndexedMapOfShapListOdShape anEdge2FaceMap;
732 // TopExp::MapShapesAnAncestors(myShape,TopAbs_EDGE, TopAbs_FACE, anEdge2FaceMap);
733 // TopTools_IndexedMapOfShapListOdShape::iterator it;
734 // for (it = anEdge2FaceMap.begin();it != anEdge2FaceMap.end();it++){
735 // SetClassAttractorEntry((*it).first, att_entry, startSize, endSize, 0, const_dist)
743 //=======================================================================
744 //function : GetClassAttractorEntry
745 //=======================================================================
746 // BLSURFPlugin_Attractor& BLSURFPlugin_Hypothesis::GetClassAttractorEntry(const std::string& entry)
748 // TAttractorMap::iterator it = _classAttractors.find( entry );
749 // if ( it != _classAttractors.end() )
750 // return it->second;
752 // return "No_Such_Entry";
756 * \brief Return the map of attractor instances
758 BLSURFPlugin_Hypothesis::TAttractorMap BLSURFPlugin_Hypothesis::GetClassAttractorEntries(const BLSURFPlugin_Hypothesis* hyp)
760 return hyp ? hyp->_GetClassAttractorEntries():GetDefaultAttractorMap();
763 //=======================================================================
764 //function : ClearEntry
765 //=======================================================================
766 void BLSURFPlugin_Hypothesis::ClearEntry(const std::string& entry,
767 const char * attEntry/*=0*/)
769 TSizeMap::iterator it = _sizeMap.find( entry );
771 if ( it != _sizeMap.end() ) {
773 NotifySubMeshesHypothesisModification();
776 TSizeMap::iterator itAt = _attractors.find( entry );
777 if ( itAt != _attractors.end() ) {
778 _attractors.erase(itAt);
779 NotifySubMeshesHypothesisModification();
782 TAttractorMap::iterator it_clAt = _classAttractors.find( entry );
783 if ( it_clAt != _classAttractors.end() ) {
785 if ( !attEntry || it_clAt->second->GetAttractorEntry() == attEntry )
786 _classAttractors.erase( it_clAt++ );
790 while ( it_clAt != _classAttractors.end() );
791 MESSAGE("_classAttractors.size() = "<<_classAttractors.size())
792 NotifySubMeshesHypothesisModification();
795 std::cout<<"No_Such_Entry"<<std::endl;
800 //=======================================================================
801 //function : ClearSizeMaps
802 //=======================================================================
803 void BLSURFPlugin_Hypothesis::ClearSizeMaps() {
806 _classAttractors.clear();
809 // Enable internal enforced vertices on specific face if requested by user
811 ////=======================================================================
812 ////function : SetInternalEnforcedVertex
813 ////=======================================================================
814 //void BLSURFPlugin_Hypothesis::SetInternalEnforcedVertex(TEntry theFaceEntry,
815 // bool toEnforceInternalVertices,
816 // TEnfGroupName theGroupName) {
818 // MESSAGE("BLSURFPlugin_Hypothesis::SetInternalEnforcedVertex("<< theFaceEntry << ", "
819 // << toEnforceInternalVertices << ", " << theGroupName << ")");
821 // TFaceEntryInternalVerticesList::iterator it = _faceEntryInternalVerticesList.find(theFaceEntry);
822 // if (it != _faceEntryInternalVerticesList.end()) {
823 // if (!toEnforceInternalVertices) {
824 // _faceEntryInternalVerticesList.erase(it);
828 // if (toEnforceInternalVertices) {
829 // _faceEntryInternalVerticesList.insert(theFaceEntry);
834 // // Take care of groups
838 //=======================================================================
839 //function : SetEnforcedVertex
840 //=======================================================================
841 bool BLSURFPlugin_Hypothesis::SetEnforcedVertex(TEntry theFaceEntry, TEnfName theVertexName, TEntry theVertexEntry,
842 TEnfGroupName theGroupName, double x, double y, double z) {
844 MESSAGE("BLSURFPlugin_Hypothesis::SetEnforcedVertex("<< theFaceEntry << ", "
845 << x << ", " << y << ", " << z << ", " << theVertexName << ", " << theVertexEntry << ", " << theGroupName << ")");
847 SetPhysicalMesh(PhysicalLocalSize);
849 // TEnfVertexList::iterator it;
850 bool toNotify = false;
851 bool toCreate = true;
853 TEnfVertex *oldEnVertex;
854 TEnfVertex *newEnfVertex = new TEnfVertex();
855 newEnfVertex->name = theVertexName;
856 newEnfVertex->geomEntry = theVertexEntry;
857 newEnfVertex->coords.clear();
858 if (theVertexEntry == "") {
859 newEnfVertex->coords.push_back(x);
860 newEnfVertex->coords.push_back(y);
861 newEnfVertex->coords.push_back(z);
863 newEnfVertex->grpName = theGroupName;
864 newEnfVertex->faceEntries.clear();
865 newEnfVertex->faceEntries.insert(theFaceEntry);
868 // update _enfVertexList
869 TEnfVertexList::iterator it = _enfVertexList.find(newEnfVertex);
870 if (it != _enfVertexList.end()) {
873 MESSAGE("Enforced Vertex was found => Update");
874 if (oldEnVertex->name != theVertexName) {
875 MESSAGE("Update name from \"" << oldEnVertex->name << "\" to \"" << theVertexName << "\"");
876 oldEnVertex->name = theVertexName;
879 if (oldEnVertex->grpName != theGroupName) {
880 MESSAGE("Update group name from \"" << oldEnVertex->grpName << "\" to \"" << theGroupName << "\"");
881 oldEnVertex->grpName = theGroupName;
884 TEntryList::iterator it_faceEntries = oldEnVertex->faceEntries.find(theFaceEntry);
885 if (it_faceEntries == oldEnVertex->faceEntries.end()) {
886 MESSAGE("Update face list by adding \"" << theFaceEntry << "\"");
887 oldEnVertex->faceEntries.insert(theFaceEntry);
888 _faceEntryEnfVertexListMap[theFaceEntry].insert(oldEnVertex);
892 // update map coords / enf vertex if needed
893 if (oldEnVertex->coords.size()) {
894 _coordsEnfVertexMap[oldEnVertex->coords] = oldEnVertex;
895 _faceEntryCoordsListMap[theFaceEntry].insert(oldEnVertex->coords);
898 // update map geom entry / enf vertex if needed
899 if (oldEnVertex->geomEntry != "") {
900 _enfVertexEntryEnfVertexMap[oldEnVertex->geomEntry] = oldEnVertex;
901 _faceEntryEnfVertexEntryListMap[theFaceEntry].insert(oldEnVertex->geomEntry);
906 // //////// CREATE ////////////
909 MESSAGE("Creating new enforced vertex");
910 _faceEntryEnfVertexListMap[theFaceEntry].insert(newEnfVertex);
911 _enfVertexList.insert(newEnfVertex);
912 if (theVertexEntry == "") {
913 _faceEntryCoordsListMap[theFaceEntry].insert(newEnfVertex->coords);
914 _coordsEnfVertexMap[newEnfVertex->coords] = newEnfVertex;
917 _faceEntryEnfVertexEntryListMap[theFaceEntry].insert(newEnfVertex->geomEntry);
918 _enfVertexEntryEnfVertexMap[newEnfVertex->geomEntry] = newEnfVertex;
923 NotifySubMeshesHypothesisModification();
925 MESSAGE("BLSURFPlugin_Hypothesis::SetEnforcedVertex END");
930 //=======================================================================
931 //function : GetEnforcedVertices
932 //=======================================================================
934 BLSURFPlugin_Hypothesis::TEnfVertexList BLSURFPlugin_Hypothesis::GetEnfVertexList(const TEntry& theFaceEntry)
935 throw (std::invalid_argument) {
937 if (_faceEntryEnfVertexListMap.count(theFaceEntry) > 0)
938 return _faceEntryEnfVertexListMap[theFaceEntry];
940 return GetDefaultEnfVertexList();
942 std::ostringstream msg;
943 msg << "No enforced vertex for face entry " << theFaceEntry;
944 throw std::invalid_argument(msg.str());
947 //=======================================================================
948 //function : GetEnfVertexCoordsList
949 //=======================================================================
951 BLSURFPlugin_Hypothesis::TEnfVertexCoordsList BLSURFPlugin_Hypothesis::GetEnfVertexCoordsList(
952 const TEntry& theFaceEntry) throw (std::invalid_argument) {
954 if (_faceEntryCoordsListMap.count(theFaceEntry) > 0)
955 return _faceEntryCoordsListMap[theFaceEntry];
957 std::ostringstream msg;
958 msg << "No enforced vertex coords for face entry " << theFaceEntry;
959 throw std::invalid_argument(msg.str());
962 //=======================================================================
963 //function : GetEnfVertexEntryList
964 //=======================================================================
966 BLSURFPlugin_Hypothesis::TEntryList BLSURFPlugin_Hypothesis::GetEnfVertexEntryList(const TEntry& theFaceEntry)
967 throw (std::invalid_argument) {
969 if (_faceEntryEnfVertexEntryListMap.count(theFaceEntry) > 0)
970 return _faceEntryEnfVertexEntryListMap[theFaceEntry];
972 std::ostringstream msg;
973 msg << "No enforced vertex entry for face entry " << theFaceEntry;
974 throw std::invalid_argument(msg.str());
977 //=======================================================================
978 //function : GetEnfVertex(TEnfVertexCoords coords)
979 //=======================================================================
981 BLSURFPlugin_Hypothesis::TEnfVertex* BLSURFPlugin_Hypothesis::GetEnfVertex(TEnfVertexCoords coords)
982 throw (std::invalid_argument) {
984 if (_coordsEnfVertexMap.count(coords) > 0)
985 return _coordsEnfVertexMap[coords];
987 std::ostringstream msg;
988 msg << "No enforced vertex with coords (" << coords[0] << ", " << coords[1] << ", " << coords[2] << ")";
989 throw std::invalid_argument(msg.str());
992 //=======================================================================
993 //function : GetEnfVertex(const TEntry& theEnfVertexEntry)
994 //=======================================================================
996 BLSURFPlugin_Hypothesis::TEnfVertex* BLSURFPlugin_Hypothesis::GetEnfVertex(const TEntry& theEnfVertexEntry)
997 throw (std::invalid_argument) {
999 if (_enfVertexEntryEnfVertexMap.count(theEnfVertexEntry) > 0)
1000 return _enfVertexEntryEnfVertexMap[theEnfVertexEntry];
1002 std::ostringstream msg;
1003 msg << "No enforced vertex with entry " << theEnfVertexEntry;
1004 throw std::invalid_argument(msg.str());
1007 //Enable internal enforced vertices on specific face if requested by user
1008 ////=======================================================================
1009 ////function : GetInternalEnforcedVertex
1010 ////=======================================================================
1012 //bool BLSURFPlugin_Hypothesis::GetInternalEnforcedVertex(const TEntry& theFaceEntry)
1014 // if (_faceEntryInternalVerticesList.count(theFaceEntry) > 0)
1019 //=======================================================================
1020 //function : ClearEnforcedVertex
1021 //=======================================================================
1023 bool BLSURFPlugin_Hypothesis::ClearEnforcedVertex(const TEntry& theFaceEntry, double x, double y, double z,
1024 const TEntry& theVertexEntry) throw (std::invalid_argument) {
1026 bool toNotify = false;
1027 std::ostringstream msg;
1028 TEnfVertex *oldEnfVertex;
1029 TEnfVertexCoords coords;
1031 coords.push_back(x);
1032 coords.push_back(y);
1033 coords.push_back(z);
1035 // check that enf vertex with given enf vertex entry exists
1036 TEnfVertexEntryEnfVertexMap::iterator it_enfVertexEntry = _enfVertexEntryEnfVertexMap.find(theVertexEntry);
1037 if (it_enfVertexEntry != _enfVertexEntryEnfVertexMap.end()) {
1039 MESSAGE("Found enforced vertex with geom entry " << theVertexEntry);
1040 oldEnfVertex = it_enfVertexEntry->second;
1042 _enfVertexEntryEnfVertexMap.erase(it_enfVertexEntry);
1044 TEntryList& enfVertexEntryList = _faceEntryEnfVertexEntryListMap[theFaceEntry];
1045 enfVertexEntryList.erase(theVertexEntry);
1046 if (enfVertexEntryList.size() == 0)
1047 _faceEntryEnfVertexEntryListMap.erase(theFaceEntry);
1048 // TFaceEntryEnfVertexEntryListMap::iterator it_entry_entry = _faceEntryEnfVertexEntryListMap.find(theFaceEntry);
1049 // TEntryList::iterator it_entryList = it_entry_entry->second.find(theVertexEntry);
1050 // it_entry_entry->second.erase(it_entryList);
1051 // if (it_entry_entry->second.size() == 0)
1052 // _faceEntryEnfVertexEntryListMap.erase(it_entry_entry);
1055 MESSAGE("Enforced vertex with geom entry " << theVertexEntry << " not found");
1056 msg << "No enforced vertex with geom entry " << theVertexEntry;
1057 // check that enf vertex with given coords exists
1058 TCoordsEnfVertexMap::iterator it_coords_enf = _coordsEnfVertexMap.find(coords);
1059 if (it_coords_enf != _coordsEnfVertexMap.end()) {
1061 MESSAGE("Found enforced vertex with coords " << x << ", " << y << ", " << z);
1062 oldEnfVertex = it_coords_enf->second;
1064 _coordsEnfVertexMap.erase(it_coords_enf);
1066 TEnfVertexCoordsList& enfVertexCoordsList = _faceEntryCoordsListMap[theFaceEntry];
1067 enfVertexCoordsList.erase(coords);
1068 if (enfVertexCoordsList.size() == 0)
1069 _faceEntryCoordsListMap.erase(theFaceEntry);
1070 // TFaceEntryCoordsListMap::iterator it_entry_coords = _faceEntryCoordsListMap.find(theFaceEntry);
1071 // TEnfVertexCoordsList::iterator it_coordsList = it_entry_coords->second.find(coords);
1072 // it_entry_coords->second.erase(it_coordsList);
1073 // if (it_entry_coords->second.size() == 0)
1074 // _faceEntryCoordsListMap.erase(it_entry_coords);
1077 MESSAGE("Enforced vertex with coords " << x << ", " << y << ", " << z << " not found");
1079 msg << "No enforced vertex at " << x << ", " << y << ", " << z;
1080 throw std::invalid_argument(msg.str());
1084 MESSAGE("Remove enf vertex from _enfVertexList");
1086 // update _enfVertexList
1087 TEnfVertexList::iterator it = _enfVertexList.find(oldEnfVertex);
1088 if (it != _enfVertexList.end()) {
1089 (*it)->faceEntries.erase(theFaceEntry);
1090 if ((*it)->faceEntries.size() == 0){
1091 _enfVertexList.erase(it);
1097 // update _faceEntryEnfVertexListMap
1098 TEnfVertexList& currentEnfVertexList = _faceEntryEnfVertexListMap[theFaceEntry];
1099 currentEnfVertexList.erase(oldEnfVertex);
1101 if (currentEnfVertexList.size() == 0) {
1102 MESSAGE("Remove _faceEntryEnfVertexListMap[" << theFaceEntry <<"]");
1103 _faceEntryEnfVertexListMap.erase(theFaceEntry);
1108 NotifySubMeshesHypothesisModification();
1113 //=======================================================================
1114 //function : ClearEnforcedVertices
1115 //=======================================================================
1117 bool BLSURFPlugin_Hypothesis::ClearEnforcedVertices(const TEntry& theFaceEntry) throw (std::invalid_argument) {
1119 bool toNotify = false;
1120 TEnfVertex *oldEnfVertex;
1122 TFaceEntryCoordsListMap::iterator it_entry_coords = _faceEntryCoordsListMap.find(theFaceEntry);
1123 if (it_entry_coords != _faceEntryCoordsListMap.end()) {
1125 TEnfVertexCoordsList coordsList = it_entry_coords->second;
1126 TEnfVertexCoordsList::iterator it_coordsList = coordsList.begin();
1127 for (; it_coordsList != coordsList.end(); ++it_coordsList) {
1128 TEnfVertexCoords coords = (*it_coordsList);
1129 oldEnfVertex = _coordsEnfVertexMap[coords];
1130 _coordsEnfVertexMap.erase(coords);
1131 // update _enfVertexList
1132 TEnfVertexList::iterator it = _enfVertexList.find(oldEnfVertex);
1133 if (it != _enfVertexList.end()) {
1134 (*it)->faceEntries.erase(theFaceEntry);
1135 if ((*it)->faceEntries.size() == 0){
1136 _enfVertexList.erase(it);
1142 _faceEntryCoordsListMap.erase(it_entry_coords);
1143 _faceEntryEnfVertexListMap.erase(theFaceEntry);
1146 TFaceEntryEnfVertexEntryListMap::iterator it_entry_entry = _faceEntryEnfVertexEntryListMap.find(theFaceEntry);
1147 if (it_entry_entry != _faceEntryEnfVertexEntryListMap.end()) {
1149 TEntryList enfVertexEntryList = it_entry_entry->second;
1150 TEntryList::iterator it_enfVertexEntryList = enfVertexEntryList.begin();
1151 for (; it_enfVertexEntryList != enfVertexEntryList.end(); ++it_enfVertexEntryList) {
1152 TEntry enfVertexEntry = (*it_enfVertexEntryList);
1153 oldEnfVertex = _enfVertexEntryEnfVertexMap[enfVertexEntry];
1154 _enfVertexEntryEnfVertexMap.erase(enfVertexEntry);
1155 // update _enfVertexList
1156 TEnfVertexList::iterator it = _enfVertexList.find(oldEnfVertex);
1157 if (it != _enfVertexList.end()) {
1158 (*it)->faceEntries.erase(theFaceEntry);
1159 if ((*it)->faceEntries.size() == 0){
1160 _enfVertexList.erase(it);
1166 _faceEntryEnfVertexEntryListMap.erase(it_entry_entry);
1167 _faceEntryEnfVertexListMap.erase(theFaceEntry);
1171 NotifySubMeshesHypothesisModification();
1174 // std::ostringstream msg;
1175 // msg << "No enforced vertex for " << theFaceEntry;
1176 // throw std::invalid_argument(msg.str());
1179 //=======================================================================
1180 //function : ClearAllEnforcedVertices
1181 //=======================================================================
1182 void BLSURFPlugin_Hypothesis::ClearAllEnforcedVertices() {
1183 _faceEntryEnfVertexListMap.clear();
1184 _enfVertexList.clear();
1185 _faceEntryCoordsListMap.clear();
1186 _coordsEnfVertexMap.clear();
1187 _faceEntryEnfVertexEntryListMap.clear();
1188 _enfVertexEntryEnfVertexMap.clear();
1189 // Enable internal enforced vertices on specific face if requested by user
1190 // _faceEntryInternalVerticesList.clear();
1191 NotifySubMeshesHypothesisModification();
1194 //================================================================================
1196 * \brief Return the enforced vertices
1198 //================================================================================
1201 BLSURFPlugin_Hypothesis::TFaceEntryEnfVertexListMap BLSURFPlugin_Hypothesis::GetAllEnforcedVerticesByFace(
1202 const BLSURFPlugin_Hypothesis* hyp) {
1203 return hyp ? hyp->_GetAllEnforcedVerticesByFace() : GetDefaultFaceEntryEnfVertexListMap();
1206 //Enable internal enforced vertices on specific face if requested by user
1207 //BLSURFPlugin_Hypothesis::TFaceEntryInternalVerticesList BLSURFPlugin_Hypothesis::GetAllInternalEnforcedVerticesByFace(
1208 // const BLSURFPlugin_Hypothesis* hyp) {
1209 // return hyp ? hyp->_GetAllInternalEnforcedVerticesByFace() : GetDefaultFaceEntryInternalVerticesMap();
1212 bool BLSURFPlugin_Hypothesis::GetInternalEnforcedVertexAllFaces(const BLSURFPlugin_Hypothesis* hyp)
1214 return hyp ? hyp->_GetInternalEnforcedVertexAllFaces() : GetDefaultInternalEnforcedVertex();
1217 BLSURFPlugin_Hypothesis::TEnfGroupName BLSURFPlugin_Hypothesis::GetInternalEnforcedVertexAllFacesGroup(const BLSURFPlugin_Hypothesis* hyp)
1219 return hyp ? hyp->_GetInternalEnforcedVertexAllFacesGroup() : BLSURFPlugin_Hypothesis::TEnfGroupName();
1222 BLSURFPlugin_Hypothesis::TEnfVertexList BLSURFPlugin_Hypothesis::GetAllEnforcedVertices(
1223 const BLSURFPlugin_Hypothesis* hyp) {
1224 return hyp ? hyp->_GetAllEnforcedVertices() : GetDefaultEnfVertexList();
1227 BLSURFPlugin_Hypothesis::TFaceEntryCoordsListMap BLSURFPlugin_Hypothesis::GetAllCoordsByFace(
1228 const BLSURFPlugin_Hypothesis* hyp) {
1229 return hyp ? hyp->_GetAllCoordsByFace() : GetDefaultFaceEntryCoordsListMap();
1232 BLSURFPlugin_Hypothesis::TCoordsEnfVertexMap BLSURFPlugin_Hypothesis::GetAllEnforcedVerticesByCoords(
1233 const BLSURFPlugin_Hypothesis* hyp) {
1234 return hyp ? hyp->_GetAllEnforcedVerticesByCoords() : GetDefaultCoordsEnfVertexMap();
1237 BLSURFPlugin_Hypothesis::TFaceEntryEnfVertexEntryListMap BLSURFPlugin_Hypothesis::GetAllEnfVertexEntriesByFace(
1238 const BLSURFPlugin_Hypothesis* hyp) {
1239 return hyp ? hyp->_GetAllEnfVertexEntriesByFace() : GetDefaultFaceEntryEnfVertexEntryListMap();
1242 BLSURFPlugin_Hypothesis::TEnfVertexEntryEnfVertexMap BLSURFPlugin_Hypothesis::GetAllEnforcedVerticesByEnfVertexEntry(
1243 const BLSURFPlugin_Hypothesis* hyp) {
1244 return hyp ? hyp->_GetAllEnforcedVerticesByEnfVertexEntry() : GetDefaultEnfVertexEntryEnfVertexMap();
1247 std::set<int> BLSURFPlugin_Hypothesis::GetEnfVertexNodeIDs(TEnfGroupName theGroupName) throw (std::invalid_argument)
1249 TGroupNameNodeIDMap::const_iterator it = _groupNameNodeIDMap.find(theGroupName);
1250 if (it != _groupNameNodeIDMap.end()) {
1253 std::ostringstream msg;
1254 msg << "No group " << theGroupName;
1255 throw std::invalid_argument(msg.str());
1258 void BLSURFPlugin_Hypothesis::AddEnfVertexNodeID(TEnfGroupName theGroupName,int theNodeID)
1260 _groupNameNodeIDMap[theGroupName].insert(theNodeID);
1263 void BLSURFPlugin_Hypothesis::RemoveEnfVertexNodeID(TEnfGroupName theGroupName,int theNodeID) throw (std::invalid_argument)
1265 TGroupNameNodeIDMap::iterator it = _groupNameNodeIDMap.find(theGroupName);
1266 if (it != _groupNameNodeIDMap.end()) {
1267 std::set<int>::iterator IDit = it->second.find(theNodeID);
1268 if (IDit != it->second.end())
1269 it->second.erase(IDit);
1270 std::ostringstream msg;
1271 msg << "No node IDs " << theNodeID << " for group " << theGroupName;
1272 throw std::invalid_argument(msg.str());
1274 std::ostringstream msg;
1275 msg << "No group " << theGroupName;
1276 throw std::invalid_argument(msg.str());
1280 //=============================================================================
1281 void BLSURFPlugin_Hypothesis::SetInternalEnforcedVertexAllFaces(bool toEnforceInternalVertices) {
1282 if (toEnforceInternalVertices != _enforcedInternalVerticesAllFaces) {
1283 _enforcedInternalVerticesAllFaces = toEnforceInternalVertices;
1284 if (toEnforceInternalVertices)
1285 SetPhysicalMesh(PhysicalLocalSize);
1286 NotifySubMeshesHypothesisModification();
1291 //=============================================================================
1292 void BLSURFPlugin_Hypothesis::SetInternalEnforcedVertexAllFacesGroup(BLSURFPlugin_Hypothesis::TEnfGroupName theGroupName) {
1293 if (std::string(theGroupName) != std::string(_enforcedInternalVerticesAllFacesGroup)) {
1294 _enforcedInternalVerticesAllFacesGroup = theGroupName;
1295 NotifySubMeshesHypothesisModification();
1299 //=============================================================================
1300 BLSURFPlugin_Hypothesis::TPreCadPeriodicityVector BLSURFPlugin_Hypothesis::GetPreCadFacesPeriodicityVector(
1301 const BLSURFPlugin_Hypothesis* hyp) {
1302 return hyp ? hyp->_GetPreCadFacesPeriodicityVector() : GetDefaultPreCadFacesPeriodicityVector();
1305 //=============================================================================
1306 BLSURFPlugin_Hypothesis::TPreCadPeriodicityVector BLSURFPlugin_Hypothesis::GetPreCadEdgesPeriodicityVector(
1307 const BLSURFPlugin_Hypothesis* hyp) {
1308 return hyp ? hyp->_GetPreCadEdgesPeriodicityVector() : GetDefaultPreCadEdgesPeriodicityVector();
1311 //=============================================================================
1312 BLSURFPlugin_Hypothesis::TFacesPeriodicityVector BLSURFPlugin_Hypothesis::GetFacesPeriodicityVector(
1313 const BLSURFPlugin_Hypothesis* hyp) {
1314 return hyp ? hyp->_GetFacesPeriodicityVector() : GetDefaultFacesPeriodicityVector();
1317 //=============================================================================
1318 BLSURFPlugin_Hypothesis::TEdgesPeriodicityVector BLSURFPlugin_Hypothesis::GetEdgesPeriodicityVector(
1319 const BLSURFPlugin_Hypothesis* hyp){
1320 return hyp ? hyp->_GetEdgesPeriodicityVector() : GetDefaultEdgesPeriodicityVector();
1323 //=============================================================================
1324 BLSURFPlugin_Hypothesis::TVerticesPeriodicityVector BLSURFPlugin_Hypothesis::GetVerticesPeriodicityVector(
1325 const BLSURFPlugin_Hypothesis* hyp){
1326 return hyp ? hyp->_GetVerticesPeriodicityVector() : GetDefaultVerticesPeriodicityVector();
1329 //=======================================================================
1330 //function : ClearAllEnforcedVertices
1331 //=======================================================================
1332 void BLSURFPlugin_Hypothesis::ClearPreCadPeriodicityVectors() {
1333 _preCadFacesPeriodicityVector.clear();
1334 _preCadEdgesPeriodicityVector.clear();
1335 NotifySubMeshesHypothesisModification();
1338 //=======================================================================
1339 //function : AddPreCadFacesPeriodicity
1340 //=======================================================================
1341 void BLSURFPlugin_Hypothesis::AddPreCadFacesPeriodicity(TEntry theFace1Entry, TEntry theFace2Entry,
1342 std::vector<std::string> &theSourceVerticesEntries, std::vector<std::string> &theTargetVerticesEntries) {
1344 TPreCadPeriodicity preCadFacesPeriodicity;
1345 preCadFacesPeriodicity.shape1Entry = theFace1Entry;
1346 preCadFacesPeriodicity.shape2Entry = theFace2Entry;
1347 preCadFacesPeriodicity.theSourceVerticesEntries = theSourceVerticesEntries;
1348 preCadFacesPeriodicity.theTargetVerticesEntries = theTargetVerticesEntries;
1350 _preCadFacesPeriodicityVector.push_back(preCadFacesPeriodicity);
1352 NotifySubMeshesHypothesisModification();
1355 //=======================================================================
1356 //function : AddPreCadEdgesPeriodicity
1357 //=======================================================================
1358 void BLSURFPlugin_Hypothesis::AddPreCadEdgesPeriodicity(TEntry theEdge1Entry, TEntry theEdge2Entry,
1359 std::vector<std::string> &theSourceVerticesEntries, std::vector<std::string> &theTargetVerticesEntries) {
1361 TPreCadPeriodicity preCadEdgesPeriodicity;
1362 preCadEdgesPeriodicity.shape1Entry = theEdge1Entry;
1363 preCadEdgesPeriodicity.shape2Entry = theEdge2Entry;
1364 preCadEdgesPeriodicity.theSourceVerticesEntries = theSourceVerticesEntries;
1365 preCadEdgesPeriodicity.theTargetVerticesEntries = theTargetVerticesEntries;
1367 _preCadEdgesPeriodicityVector.push_back(preCadEdgesPeriodicity);
1369 NotifySubMeshesHypothesisModification();
1372 //=============================================================================
1373 std::ostream & BLSURFPlugin_Hypothesis::SaveTo(std::ostream & save) {
1374 // We must keep at least the same number of arguments when increasing the SALOME version
1375 // When MG-CADSurf becomes CADMESH, some parameters were fused into a single one. Thus the same
1376 // parameter can be written several times to keep the old global number of parameters.
1378 // Treat old options which are now in the advanced options
1379 TOptionValues::iterator op_val;
1381 int _preCADRemoveNanoEdges = -1;
1382 double _preCADEpsNano = -1.0;
1383 op_val = _option2value.find("respect_geometry");
1384 if (op_val != _option2value.end()) {
1385 std::string value = op_val->second;
1387 _decimesh = value.compare("1") == 0 ? 1 : 0;
1389 op_val = _preCADoption2value.find("remove_tiny_edges");
1390 if (op_val != _preCADoption2value.end()) {
1391 std::string value = op_val->second;
1393 _preCADRemoveNanoEdges = value.compare("1") == 0 ? 1 : 0;
1395 op_val = _preCADoption2value.find("tiny_edge_length");
1396 if (op_val != _preCADoption2value.end()) {
1397 std::string value = op_val->second;
1399 _preCADEpsNano = strtod(value.c_str(), NULL);
1402 save << " " << (int) _topology << " " << (int) _physicalMesh << " " << (int) _geometricMesh << " " << _phySize << " "
1403 << _angleMesh << " " << _gradation << " " << (int) _quadAllowed << " " << _decimesh;
1404 save << " " << _minSize << " " << _maxSize << " " << _angleMesh << " " << _minSize << " " << _maxSize << " " << _verb;
1405 save << " " << (int) _preCADMergeEdges << " " << _preCADRemoveNanoEdges << " " << (int) _preCADDiscardInput << " " << _preCADEpsNano ;
1406 save << " " << (int) _enforcedInternalVerticesAllFaces;
1407 save << " " << (int) _phySizeRel << " " << (int) _minSizeRel << " " << (int) _maxSizeRel << " " << _chordalError ;
1408 save << " " << (int) _anisotropic << " " << _anisotropicRatio << " " << (int) _removeTinyEdges << " " << _tinyEdgeLength ;
1409 save << " " << (int) _badElementRemoval << " " << _badElementAspectRatio << " " << (int) _optimizeMesh << " " << (int) _quadraticMesh ;
1410 save << " " << (int) _preCADProcess3DTopology << " " << (int) _preCADRemoveDuplicateCADFaces;
1412 op_val = _option2value.begin();
1413 if (op_val != _option2value.end()) {
1414 save << " " << "__OPTIONS_BEGIN__";
1415 for (; op_val != _option2value.end(); ++op_val) {
1416 if (!op_val->second.empty())
1417 save << " " << op_val->first << " " << op_val->second << "%#"; // "%#" is a mark of value end
1419 save << " " << "__OPTIONS_END__";
1422 op_val = _customOption2value.begin();
1423 if (op_val != _customOption2value.end()) {
1424 save << " " << "__CUSTOM_OPTIONS_BEGIN__";
1425 for (; op_val != _customOption2value.end(); ++op_val) {
1426 if (!op_val->second.empty())
1427 save << " " << op_val->first << " " << op_val->second << "%#"; // "%#" is a mark of value end
1429 save << " " << "__CUSTOM_OPTIONS_END__";
1432 op_val = _preCADoption2value.begin();
1433 if (op_val != _preCADoption2value.end()) {
1434 save << " " << "__PRECAD_OPTIONS_BEGIN__";
1435 for (; op_val != _preCADoption2value.end(); ++op_val) {
1436 if (!op_val->second.empty())
1437 save << " " << op_val->first << " " << op_val->second << "%#"; // "%#" is a mark of value end
1439 save << " " << "__PRECAD_OPTIONS_END__";
1442 op_val = _customPreCADOption2value.begin();
1443 if (op_val != _customPreCADOption2value.end()) {
1444 save << " " << "__CUSTOM_PRECAD_OPTIONS_BEGIN__";
1445 for (; op_val != _customPreCADOption2value.end(); ++op_val) {
1446 if (!op_val->second.empty())
1447 save << " " << op_val->first << " " << op_val->second << "%#"; // "%#" is a mark of value end
1449 save << " " << "__CUSTOM_PRECAD_OPTIONS_END__";
1452 TSizeMap::iterator it_sm = _sizeMap.begin();
1453 if (it_sm != _sizeMap.end()) {
1454 save << " " << "__SIZEMAP_BEGIN__";
1455 for (; it_sm != _sizeMap.end(); ++it_sm) {
1456 save << " " << it_sm->first << " " << it_sm->second << "%#"; // "%#" is a mark of value end
1458 save << " " << "__SIZEMAP_END__";
1461 TSizeMap::iterator it_at = _attractors.begin();
1462 if (it_at != _attractors.end()) {
1463 save << " " << "__ATTRACTORS_BEGIN__";
1464 for (; it_at != _attractors.end(); ++it_at) {
1465 save << " " << it_at->first << " " << it_at->second << "%#"; // "%#" is a mark of value end
1467 save << " " << "__ATTRACTORS_END__";
1470 TAttractorMap::iterator it_At = _classAttractors.begin();
1471 if (it_At != _classAttractors.end()) {
1472 std::ostringstream test;
1473 save << " " << "__NEW_ATTRACTORS_BEGIN__";
1474 test << " " << "__NEW_ATTRACTORS_BEGIN__";
1475 for (; it_At != _classAttractors.end(); ++it_At) {
1476 std::vector<double> attParams;
1477 attParams = it_At->second->GetParameters();
1478 // double step = it_At->second->GetStep();
1479 save << " " << it_At->first;
1480 save << " " << it_At->second->GetAttractorEntry();
1481 save << " " << attParams[0] << " " << attParams[1] << " " << attParams[2] << " " << attParams[3];
1482 // save << " " << step;
1483 test << " " << it_At->first;
1484 test << " " << it_At->second->GetAttractorEntry();
1485 test << " " << attParams[0] << " " << attParams[1] << " " << attParams[2] << " " << attParams[3];
1486 // test << " " << step;
1488 save << " " << "__NEW_ATTRACTORS_END__";
1489 test << " " << "__NEW_ATTRACTORS_END__";
1490 MESSAGE(" Attractor hypothesis saved as "<<test.str())
1493 TEnfVertexList::const_iterator it_enf = _enfVertexList.begin();
1494 if (it_enf != _enfVertexList.end()) {
1495 save << " " << "__ENFORCED_VERTICES_BEGIN__";
1496 for (; it_enf != _enfVertexList.end(); ++it_enf) {
1497 TEnfVertex *enfVertex = (*it_enf);
1498 save << " " << "__BEGIN_VERTEX__";
1499 if (!enfVertex->name.empty()) {
1500 save << " " << "__BEGIN_NAME__";
1501 save << " " << enfVertex->name;
1502 save << " " << "__END_NAME__";
1504 if (!enfVertex->geomEntry.empty()) {
1505 save << " " << "__BEGIN_ENTRY__";
1506 save << " " << enfVertex->geomEntry;
1507 save << " " << "__END_ENTRY__";
1509 if (!enfVertex->grpName.empty()) {
1510 save << " " << "__BEGIN_GROUP__";
1511 save << " " << enfVertex->grpName;
1512 save << " " << "__END_GROUP__";
1514 if (enfVertex->coords.size()) {
1515 save << " " << "__BEGIN_COORDS__";
1516 for ( size_t i = 0; i < enfVertex->coords.size(); i++ )
1517 save << " " << enfVertex->coords[i];
1518 save << " " << "__END_COORDS__";
1520 TEntryList::const_iterator faceEntriesIt = enfVertex->faceEntries.begin();
1521 bool hasFaces = false;
1522 if (faceEntriesIt != enfVertex->faceEntries.end()) {
1524 save << " " << "__BEGIN_FACELIST__";
1526 for (; faceEntriesIt != enfVertex->faceEntries.end(); ++faceEntriesIt)
1527 save << " " << (*faceEntriesIt);
1529 save << " " << "__END_FACELIST__";
1530 save << " " << "__END_VERTEX__";
1532 save << " " << "__ENFORCED_VERTICES_END__";
1537 SavePreCADPeriodicity(save, "FACES");
1538 SavePreCADPeriodicity(save, "EDGES");
1540 SaveFacesPeriodicity(save);
1541 SaveEdgesPeriodicity(save);
1542 SaveVerticesPeriodicity(save);
1547 void BLSURFPlugin_Hypothesis::SaveFacesPeriodicity(std::ostream & save){
1549 TFacesPeriodicityVector::const_iterator it_faces_periodicity = _facesPeriodicityVector.begin();
1550 if (it_faces_periodicity != _facesPeriodicityVector.end()) {
1551 MESSAGE("__FACES_PERIODICITY_BEGIN__");
1552 save << " " << "__FACES_PERIODICITY_BEGIN__";
1553 for (; it_faces_periodicity != _facesPeriodicityVector.end(); ++it_faces_periodicity) {
1554 TFacesPeriodicity periodicity_i = (*it_faces_periodicity);
1555 save << " " << "__BEGIN_PERIODICITY_DESCRIPTION__";
1556 save << " " << "__BEGIN_ENTRY1__";
1557 save << " " << periodicity_i.first;
1558 save << " " << "__END_ENTRY1__";
1559 save << " " << "__BEGIN_ENTRY2__";
1560 save << " " << periodicity_i.second;
1561 save << " " << "__END_ENTRY2__";
1562 save << " " << "__END_PERIODICITY_DESCRIPTION__";
1564 save << " " << "__FACES_PERIODICITY_END__";
1565 MESSAGE("__FACES_PERIODICITY_END__");
1569 void BLSURFPlugin_Hypothesis::SaveEdgesPeriodicity(std::ostream & save){
1571 TEdgesPeriodicityVector::const_iterator it_edges_periodicity = _edgesPeriodicityVector.begin();
1572 if (it_edges_periodicity != _edgesPeriodicityVector.end()) {
1573 save << " " << "__EDGES_PERIODICITY_BEGIN__";
1574 MESSAGE("__EDGES_PERIODICITY_BEGIN__");
1575 for (; it_edges_periodicity != _edgesPeriodicityVector.end(); ++it_edges_periodicity) {
1576 TEdgePeriodicity periodicity_i = (*it_edges_periodicity);
1577 save << " " << "__BEGIN_PERIODICITY_DESCRIPTION__";
1578 if (! periodicity_i.theFace1Entry.empty()){
1579 save << " " << "__BEGIN_FACE1__";
1580 save << " " << periodicity_i.theFace1Entry;
1581 save << " " << "__END_FACE1__";
1583 save << " " << "__BEGIN_EDGE1__";
1584 save << " " << periodicity_i.theEdge1Entry;
1585 save << " " << "__END_EDGE1__";
1586 if (! periodicity_i.theFace2Entry.empty()){
1587 save << " " << "__BEGIN_FACE2__";
1588 save << " " << periodicity_i.theFace2Entry;
1589 save << " " << "__END_FACE2__";
1591 save << " " << "__BEGIN_EDGE2__";
1592 save << " " << periodicity_i.theEdge2Entry;
1593 save << " " << "__END_EDGE2__";
1594 save << " " << "__BEGIN_EDGE_ORIENTATION__";
1595 save << " " << periodicity_i.edge_orientation;
1596 save << " " << "__END_EDGE_ORIENTATION__";
1597 save << " " << "__END_PERIODICITY_DESCRIPTION__";
1599 save << " " << "__EDGES_PERIODICITY_END__";
1600 MESSAGE("__EDGES_PERIODICITY_END__");
1604 void BLSURFPlugin_Hypothesis::SaveVerticesPeriodicity(std::ostream & save){
1606 TVerticesPeriodicityVector::const_iterator it_vertices_periodicity = _verticesPeriodicityVector.begin();
1607 if (it_vertices_periodicity != _verticesPeriodicityVector.end()) {
1608 MESSAGE("__VERTICES_PERIODICITY_BEGIN__");
1609 save << " " << "__VERTICES_PERIODICITY_BEGIN__";
1610 for (; it_vertices_periodicity != _verticesPeriodicityVector.end(); ++it_vertices_periodicity) {
1611 TVertexPeriodicity periodicity_i = (*it_vertices_periodicity);
1612 save << " " << "__BEGIN_PERIODICITY_DESCRIPTION__";
1613 save << " " << "__BEGIN_EDGE1__";
1614 save << " " << periodicity_i.theEdge1Entry;
1615 save << " " << "__END_EDGE1__";
1616 save << " " << "__BEGIN_VERTEX1__";
1617 save << " " << periodicity_i.theVertex1Entry;
1618 save << " " << "__END_VERTEX1__";
1619 save << " " << "__BEGIN_EDGE2__";
1620 save << " " << periodicity_i.theEdge2Entry;
1621 save << " " << "__END_EDGE2__";
1622 save << " " << "__BEGIN_VERTEX2__";
1623 save << " " << periodicity_i.theVertex2Entry;
1624 save << " " << "__END_VERTEX2__";
1625 save << " " << "__END_PERIODICITY_DESCRIPTION__";
1627 save << " " << "__VERTICES_PERIODICITY_END__";
1628 MESSAGE("__VERTICES_PERIODICITY_END__");
1632 void BLSURFPlugin_Hypothesis::SavePreCADPeriodicity(std::ostream & save, const char* shapeType) {
1633 TPreCadPeriodicityVector precad_periodicity;
1634 if ( shapeType && strcmp( shapeType, "FACES" ) == 0 )
1635 precad_periodicity = _preCadFacesPeriodicityVector;
1637 precad_periodicity = _preCadEdgesPeriodicityVector;
1638 TPreCadPeriodicityVector::const_iterator it_precad_periodicity = precad_periodicity.begin();
1639 if (it_precad_periodicity != precad_periodicity.end()) {
1640 save << " " << "__PRECAD_" << shapeType << "_PERIODICITY_BEGIN__";
1641 for (; it_precad_periodicity != precad_periodicity.end(); ++it_precad_periodicity) {
1642 TPreCadPeriodicity periodicity_i = (*it_precad_periodicity);
1643 save << " " << "__BEGIN_PERIODICITY_DESCRIPTION__";
1644 if (!periodicity_i.shape1Entry.empty()) {
1645 save << " " << "__BEGIN_ENTRY1__";
1646 save << " " << periodicity_i.shape1Entry;
1647 save << " " << "__END_ENTRY1__";
1649 if (!periodicity_i.shape2Entry.empty()) {
1650 save << " " << "__BEGIN_ENTRY2__";
1651 save << " " << periodicity_i.shape2Entry;
1652 save << " " << "__END_ENTRY2__";
1655 std::vector<std::string>::const_iterator sourceVerticesEntriesIt = periodicity_i.theSourceVerticesEntries.begin();
1656 bool hasSourceVertices = false;
1657 if (sourceVerticesEntriesIt != periodicity_i.theSourceVerticesEntries.end()) {
1658 hasSourceVertices = true;
1659 save << " " << "__BEGIN_SOURCE_VERTICES_LIST__";
1661 for (; sourceVerticesEntriesIt != periodicity_i.theSourceVerticesEntries.end(); ++sourceVerticesEntriesIt)
1662 save << " " << (*sourceVerticesEntriesIt);
1663 if (hasSourceVertices)
1664 save << " " << "__END_SOURCE_VERTICES_LIST__";
1666 std::vector<std::string>::const_iterator targetVerticesEntriesIt = periodicity_i.theTargetVerticesEntries.begin();
1667 bool hasTargetVertices = false;
1668 if (targetVerticesEntriesIt != periodicity_i.theTargetVerticesEntries.end()) {
1669 hasTargetVertices = true;
1670 save << " " << "__BEGIN_TARGET_VERTICES_LIST__";
1672 for (; targetVerticesEntriesIt != periodicity_i.theTargetVerticesEntries.end(); ++targetVerticesEntriesIt)
1673 save << " " << (*targetVerticesEntriesIt);
1674 if (hasTargetVertices)
1675 save << " " << "__END_TARGET_VERTICES_LIST__";
1677 save << " " << "__END_PERIODICITY_DESCRIPTION__";
1679 save << " " << "__PRECAD_" << shapeType << "_PERIODICITY_END__";
1684 //=============================================================================
1685 std::istream & BLSURFPlugin_Hypothesis::LoadFrom(std::istream & load) {
1689 std::string option_or_sm;
1691 isOK = static_cast<bool>(load >> i);
1693 _topology = (Topology) i;
1695 load.clear(std::ios::badbit | load.rdstate());
1697 isOK = static_cast<bool>(load >> i);
1699 _physicalMesh = (PhysicalMesh) i;
1701 load.clear(std::ios::badbit | load.rdstate());
1703 isOK = static_cast<bool>(load >> i);
1705 _geometricMesh = (GeometricMesh) i;
1707 load.clear(std::ios::badbit | load.rdstate());
1709 isOK = static_cast<bool>(load >> val);
1713 load.clear(std::ios::badbit | load.rdstate());
1715 isOK = static_cast<bool>(load >> val);
1719 load.clear(std::ios::badbit | load.rdstate());
1721 isOK = static_cast<bool>(load >> val);
1725 load.clear(std::ios::badbit | load.rdstate());
1727 isOK = static_cast<bool>(load >> i);
1729 _quadAllowed = (bool) i;
1731 load.clear(std::ios::badbit | load.rdstate());
1733 isOK = static_cast<bool>(load >> i);
1735 if ( i != -1) { // if value is -1, then this is no longer a standard option
1736 std::string & value = _option2value["respect_geometry"];
1737 bool _decimesh = (bool) i;
1738 value = _decimesh ? "1" : "0";
1742 load.clear(std::ios::badbit | load.rdstate());
1744 isOK = static_cast<bool>(load >> val);
1748 load.clear(std::ios::badbit | load.rdstate());
1750 isOK = static_cast<bool>(load >> val);
1754 load.clear(std::ios::badbit | load.rdstate());
1756 isOK = static_cast<bool>(load >> val);
1758 // former parameter: get min value
1759 _angleMesh = std::min(val,_angleMesh);
1761 load.clear(std::ios::badbit | load.rdstate());
1763 isOK = static_cast<bool>(load >> val);
1765 // former parameter: get min value
1766 _minSize = std::min(val,_minSize);
1768 load.clear(std::ios::badbit | load.rdstate());
1770 isOK = static_cast<bool>(load >> val);
1772 // former parameter: get max value
1773 _maxSize = std::max(val,_maxSize);
1775 load.clear(std::ios::badbit | load.rdstate());
1777 isOK = static_cast<bool>(load >> i);
1781 load.clear(std::ios::badbit | load.rdstate());
1783 isOK = static_cast<bool>(load >> i);
1785 _preCADMergeEdges = (bool) i;
1787 load.clear(std::ios::badbit | load.rdstate());
1789 isOK = static_cast<bool>(load >> i);
1791 if ( i != -1) { // if value is -1, then this is no longer a standard option
1792 std::string & value = _preCADoption2value["remove_tiny_edges"];
1793 bool _preCADRemoveNanoEdges = (bool) i;
1794 value = _preCADRemoveNanoEdges ? "1" : "0";
1798 load.clear(std::ios::badbit | load.rdstate());
1800 isOK = static_cast<bool>(load >> i);
1802 _preCADDiscardInput = (bool) i;
1804 load.clear(std::ios::badbit | load.rdstate());
1806 isOK = static_cast<bool>(load >> val);
1807 if (isOK) { // _preCADEpsNano
1808 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
1809 std::string & value = _preCADoption2value["tiny_edge_length"];
1810 std::ostringstream oss;
1816 load.clear(std::ios::badbit | load.rdstate());
1818 isOK = static_cast<bool>(load >> i);
1820 _enforcedInternalVerticesAllFaces = (bool) i;
1822 load.clear(std::ios::badbit | load.rdstate());
1824 // New options with MeshGems-CADSurf
1826 bool hasCADSurfOptions = false;
1827 bool hasOptions = false;
1828 bool hasCustomOptions = false;
1829 bool hasPreCADOptions = false;
1830 bool hasCustomPreCADOptions = false;
1831 bool hasSizeMap = false;
1832 bool hasAttractor = false;
1833 bool hasNewAttractor = false;
1834 bool hasEnforcedVertex = false;
1835 bool hasPreCADFacesPeriodicity = false;
1836 bool hasPreCADEdgesPeriodicity = false;
1837 bool hasFacesPeriodicity = false;
1838 bool hasEdgesPeriodicity = false;
1839 bool hasVerticesPeriodicity = false;
1841 isOK = static_cast<bool>(load >> option_or_sm);
1843 if ( (option_or_sm == "1")||(option_or_sm == "0") ) {
1844 i = atoi(option_or_sm.c_str());
1845 hasCADSurfOptions = true;
1846 _phySizeRel = (bool) i;
1848 if (option_or_sm == "__OPTIONS_BEGIN__")
1850 else if (option_or_sm == "__CUSTOM_OPTIONS_BEGIN__")
1851 hasCustomOptions = true;
1852 else if (option_or_sm == "__PRECAD_OPTIONS_BEGIN__")
1853 hasPreCADOptions = true;
1854 else if (option_or_sm == "__CUSTOM_PRECAD_OPTIONS_BEGIN__")
1855 hasCustomPreCADOptions = true;
1856 else if (option_or_sm == "__SIZEMAP_BEGIN__")
1858 else if (option_or_sm == "__ATTRACTORS_BEGIN__")
1859 hasAttractor = true;
1860 else if (option_or_sm == "__NEW_ATTRACTORS_BEGIN__")
1861 hasNewAttractor = true;
1862 else if (option_or_sm == "__ENFORCED_VERTICES_BEGIN__")
1863 hasEnforcedVertex = true;
1864 else if (option_or_sm == "__PRECAD_FACES_PERIODICITY_BEGIN__")
1865 hasPreCADFacesPeriodicity = true;
1866 else if (option_or_sm == "__PRECAD_EDGES_PERIODICITY_BEGIN__")
1867 hasPreCADEdgesPeriodicity = true;
1868 else if (option_or_sm == "__FACES_PERIODICITY_BEGIN__")
1869 hasFacesPeriodicity = true;
1870 else if (option_or_sm == "__EDGES_PERIODICITY_BEGIN__")
1871 hasEdgesPeriodicity = true;
1872 else if (option_or_sm == "__VERTICES_PERIODICITY_BEGIN__")
1873 hasVerticesPeriodicity = true;
1875 if (isOK && hasCADSurfOptions) {
1876 isOK = static_cast<bool>(load >> i);
1878 _minSizeRel = (bool) i;
1880 load.clear(std::ios::badbit | load.rdstate());
1882 isOK = static_cast<bool>(load >> i);
1884 _maxSizeRel = (bool) i;
1886 load.clear(std::ios::badbit | load.rdstate());
1888 isOK = static_cast<bool>(load >> val);
1890 _chordalError = val;
1892 load.clear(std::ios::badbit | load.rdstate());
1894 isOK = static_cast<bool>(load >> i);
1896 _anisotropic = (bool) i;
1898 load.clear(std::ios::badbit | load.rdstate());
1900 isOK = static_cast<bool>(load >> val);
1902 _anisotropicRatio = val;
1904 load.clear(std::ios::badbit | load.rdstate());
1906 isOK = static_cast<bool>(load >> i);
1908 _removeTinyEdges = (bool) i;
1910 load.clear(std::ios::badbit | load.rdstate());
1912 isOK = static_cast<bool>(load >> val);
1914 _tinyEdgeLength = val;
1916 load.clear(std::ios::badbit | load.rdstate());
1918 isOK = static_cast<bool>(load >> i);
1920 _badElementRemoval = (bool) i;
1922 load.clear(std::ios::badbit | load.rdstate());
1924 isOK = static_cast<bool>(load >> val);
1926 _badElementAspectRatio = val;
1928 load.clear(std::ios::badbit | load.rdstate());
1930 isOK = static_cast<bool>(load >> i);
1932 _optimizeMesh = (bool) i;
1934 load.clear(std::ios::badbit | load.rdstate());
1936 isOK = static_cast<bool>(load >> i);
1938 _quadraticMesh = (bool) i;
1940 load.clear(std::ios::badbit | load.rdstate());
1942 isOK = static_cast<bool>(load >> i);
1944 _preCADProcess3DTopology = (bool) i;
1946 load.clear(std::ios::badbit | load.rdstate());
1948 isOK = static_cast<bool>(load >> i);
1950 _preCADRemoveDuplicateCADFaces = (bool) i;
1952 load.clear(std::ios::badbit | load.rdstate());
1957 if (hasCADSurfOptions) {
1958 isOK = static_cast<bool>(load >> option_or_sm);
1960 if (option_or_sm == "__OPTIONS_BEGIN__")
1962 else if (option_or_sm == "__CUSTOM_OPTIONS_BEGIN__")
1963 hasCustomOptions = true;
1964 else if (option_or_sm == "__PRECAD_OPTIONS_BEGIN__")
1965 hasPreCADOptions = true;
1966 else if (option_or_sm == "__CUSTOM_PRECAD_OPTIONS_BEGIN__")
1967 hasCustomPreCADOptions = true;
1968 else if (option_or_sm == "__SIZEMAP_BEGIN__")
1970 else if (option_or_sm == "__ATTRACTORS_BEGIN__")
1971 hasAttractor = true;
1972 else if (option_or_sm == "__NEW_ATTRACTORS_BEGIN__")
1973 hasNewAttractor = true;
1974 else if (option_or_sm == "__ENFORCED_VERTICES_BEGIN__")
1975 hasEnforcedVertex = true;
1976 else if (option_or_sm == "__PRECAD_FACES_PERIODICITY_BEGIN__")
1977 hasPreCADFacesPeriodicity = true;
1978 else if (option_or_sm == "__PRECAD_EDGES_PERIODICITY_BEGIN__")
1979 hasPreCADEdgesPeriodicity = true;
1980 else if (option_or_sm == "__FACES_PERIODICITY_BEGIN__")
1981 hasFacesPeriodicity = true;
1982 else if (option_or_sm == "__EDGES_PERIODICITY_BEGIN__")
1983 hasEdgesPeriodicity = true;
1984 else if (option_or_sm == "__VERTICES_PERIODICITY_BEGIN__")
1985 hasVerticesPeriodicity = true;
1989 std::string optName, optValue;
1990 while (isOK && hasOptions) {
1991 isOK = static_cast<bool>(load >> optName);
1993 if (optName == "__OPTIONS_END__")
1995 isOK = static_cast<bool>(load >> optValue);
1998 std::string & value = _option2value[optName];
2000 int len = value.size();
2001 // continue reading until "%#" encountered
2002 while (value[len - 1] != '#' || value[len - 2] != '%') {
2003 isOK = static_cast<bool>(load >> optValue);
2012 value[len - 2] = '\0'; //cut off "%#"
2017 isOK = static_cast<bool>(load >> option_or_sm);
2019 if (option_or_sm == "__CUSTOM_OPTIONS_BEGIN__")
2020 hasCustomOptions = true;
2021 else if (option_or_sm == "__PRECAD_OPTIONS_BEGIN__")
2022 hasPreCADOptions = true;
2023 else if (option_or_sm == "__CUSTOM_PRECAD_OPTIONS_BEGIN__")
2024 hasCustomPreCADOptions = true;
2025 else if (option_or_sm == "__SIZEMAP_BEGIN__")
2027 else if (option_or_sm == "__ATTRACTORS_BEGIN__")
2028 hasAttractor = true;
2029 else if (option_or_sm == "__NEW_ATTRACTORS_BEGIN__")
2030 hasNewAttractor = true;
2031 else if (option_or_sm == "__ENFORCED_VERTICES_BEGIN__")
2032 hasEnforcedVertex = true;
2033 else if (option_or_sm == "__PRECAD_FACES_PERIODICITY_BEGIN__")
2034 hasPreCADFacesPeriodicity = true;
2035 else if (option_or_sm == "__PRECAD_EDGES_PERIODICITY_BEGIN__")
2036 hasPreCADEdgesPeriodicity = true;
2037 else if (option_or_sm == "__FACES_PERIODICITY_BEGIN__")
2038 hasFacesPeriodicity = true;
2039 else if (option_or_sm == "__EDGES_PERIODICITY_BEGIN__")
2040 hasEdgesPeriodicity = true;
2041 else if (option_or_sm == "__VERTICES_PERIODICITY_BEGIN__")
2042 hasVerticesPeriodicity = true;
2046 while (isOK && hasCustomOptions) {
2047 isOK = static_cast<bool>(load >> optName);
2049 if (optName == "__CUSTOM_OPTIONS_END__")
2051 isOK = static_cast<bool>(load >> optValue);
2054 std::string& value = optValue;
2055 int len = value.size();
2056 // continue reading until "%#" encountered
2057 while (value[len - 1] != '#' || value[len - 2] != '%') {
2058 isOK = static_cast<bool>(load >> optValue);
2067 _customOption2value[optName] = value.substr(0,len-2);
2068 value[len - 2] = '\0'; //cut off "%#"
2072 if (hasCustomOptions) {
2073 isOK = static_cast<bool>(load >> option_or_sm);
2075 if (option_or_sm == "__PRECAD_OPTIONS_BEGIN__")
2076 hasPreCADOptions = true;
2077 else if (option_or_sm == "__CUSTOM_PRECAD_OPTIONS_BEGIN__")
2078 hasCustomPreCADOptions = true;
2079 else if (option_or_sm == "__SIZEMAP_BEGIN__")
2081 else if (option_or_sm == "__ATTRACTORS_BEGIN__")
2082 hasAttractor = true;
2083 else if (option_or_sm == "__NEW_ATTRACTORS_BEGIN__")
2084 hasNewAttractor = true;
2085 else if (option_or_sm == "__ENFORCED_VERTICES_BEGIN__")
2086 hasEnforcedVertex = true;
2087 else if (option_or_sm == "__PRECAD_FACES_PERIODICITY_BEGIN__")
2088 hasPreCADFacesPeriodicity = true;
2089 else if (option_or_sm == "__PRECAD_EDGES_PERIODICITY_BEGIN__")
2090 hasPreCADEdgesPeriodicity = true;
2091 else if (option_or_sm == "__FACES_PERIODICITY_BEGIN__")
2092 hasFacesPeriodicity = true;
2093 else if (option_or_sm == "__EDGES_PERIODICITY_BEGIN__")
2094 hasEdgesPeriodicity = true;
2095 else if (option_or_sm == "__VERTICES_PERIODICITY_BEGIN__")
2096 hasVerticesPeriodicity = true;
2100 while (isOK && hasPreCADOptions) {
2101 isOK = static_cast<bool>(load >> optName);
2103 if (optName == "__PRECAD_OPTIONS_END__")
2105 isOK = static_cast<bool>(load >> optValue);
2108 std::string & value = _preCADoption2value[optName];
2110 int len = value.size();
2111 // continue reading until "%#" encountered
2112 while (value[len - 1] != '#' || value[len - 2] != '%') {
2113 isOK = static_cast<bool>(load >> optValue);
2122 value[len - 2] = '\0'; //cut off "%#"
2126 if (hasPreCADOptions) {
2127 isOK = static_cast<bool>(load >> option_or_sm);
2129 if (option_or_sm == "__CUSTOM_PRECAD_OPTIONS_BEGIN__")
2130 hasCustomPreCADOptions = true;
2131 else if (option_or_sm == "__SIZEMAP_BEGIN__")
2133 else if (option_or_sm == "__ATTRACTORS_BEGIN__")
2134 hasAttractor = true;
2135 else if (option_or_sm == "__NEW_ATTRACTORS_BEGIN__")
2136 hasNewAttractor = true;
2137 else if (option_or_sm == "__ENFORCED_VERTICES_BEGIN__")
2138 hasEnforcedVertex = true;
2139 else if (option_or_sm == "__PRECAD_FACES_PERIODICITY_BEGIN__")
2140 hasPreCADFacesPeriodicity = true;
2141 else if (option_or_sm == "__PRECAD_EDGES_PERIODICITY_BEGIN__")
2142 hasPreCADEdgesPeriodicity = true;
2143 else if (option_or_sm == "__FACES_PERIODICITY_BEGIN__")
2144 hasFacesPeriodicity = true;
2145 else if (option_or_sm == "__EDGES_PERIODICITY_BEGIN__")
2146 hasEdgesPeriodicity = true;
2147 else if (option_or_sm == "__VERTICES_PERIODICITY_BEGIN__")
2148 hasVerticesPeriodicity = true;
2152 while (isOK && hasCustomPreCADOptions) {
2153 isOK = static_cast<bool>(load >> optName);
2155 if (optName == "__CUSTOM_PRECAD_OPTIONS_END__")
2157 isOK = static_cast<bool>(load >> optValue);
2160 std::string& value = optValue;
2161 int len = value.size();
2162 // continue reading until "%#" encountered
2163 while (value[len - 1] != '#' || value[len - 2] != '%') {
2164 isOK = static_cast<bool>(load >> optValue);
2173 _customPreCADOption2value[optName] = value.substr(0,len-2);
2174 value[len - 2] = '\0'; //cut off "%#"
2178 if (hasCustomPreCADOptions) {
2179 isOK = static_cast<bool>(load >> option_or_sm);
2181 if (option_or_sm == "__SIZEMAP_BEGIN__")
2183 else if (option_or_sm == "__ATTRACTORS_BEGIN__")
2184 hasAttractor = true;
2185 else if (option_or_sm == "__NEW_ATTRACTORS_BEGIN__")
2186 hasNewAttractor = true;
2187 else if (option_or_sm == "__ENFORCED_VERTICES_BEGIN__")
2188 hasEnforcedVertex = true;
2189 else if (option_or_sm == "__PRECAD_FACES_PERIODICITY_BEGIN__")
2190 hasPreCADFacesPeriodicity = true;
2191 else if (option_or_sm == "__PRECAD_EDGES_PERIODICITY_BEGIN__")
2192 hasPreCADEdgesPeriodicity = true;
2193 else if (option_or_sm == "__FACES_PERIODICITY_BEGIN__")
2194 hasFacesPeriodicity = true;
2195 else if (option_or_sm == "__EDGES_PERIODICITY_BEGIN__")
2196 hasEdgesPeriodicity = true;
2197 else if (option_or_sm == "__VERTICES_PERIODICITY_BEGIN__")
2198 hasVerticesPeriodicity = true;
2202 std::string smEntry, smValue;
2203 while (isOK && hasSizeMap) {
2204 isOK = static_cast<bool>(load >> smEntry);
2206 if (smEntry == "__SIZEMAP_END__")
2208 isOK = static_cast<bool>(load >> smValue);
2211 std::string & value2 = _sizeMap[smEntry];
2213 int len2 = value2.size();
2214 // continue reading until "%#" encountered
2215 while (value2[len2 - 1] != '#' || value2[len2 - 2] != '%') {
2216 isOK = static_cast<bool>(load >> smValue);
2220 len2 = value2.size();
2225 value2[len2 - 2] = '\0'; //cut off "%#"
2230 isOK = static_cast<bool>(load >> option_or_sm);
2232 if (option_or_sm == "__ATTRACTORS_BEGIN__")
2233 hasAttractor = true;
2234 if (option_or_sm == "__NEW_ATTRACTORS_BEGIN__")
2235 hasNewAttractor = true;
2236 else if (option_or_sm == "__ENFORCED_VERTICES_BEGIN__")
2237 hasEnforcedVertex = true;
2238 else if (option_or_sm == "__PRECAD_FACES_PERIODICITY_BEGIN__")
2239 hasPreCADFacesPeriodicity = true;
2240 else if (option_or_sm == "__PRECAD_EDGES_PERIODICITY_BEGIN__")
2241 hasPreCADEdgesPeriodicity = true;
2242 else if (option_or_sm == "__FACES_PERIODICITY_BEGIN__")
2243 hasFacesPeriodicity = true;
2244 else if (option_or_sm == "__EDGES_PERIODICITY_BEGIN__")
2245 hasEdgesPeriodicity = true;
2246 else if (option_or_sm == "__VERTICES_PERIODICITY_BEGIN__")
2247 hasVerticesPeriodicity = true;
2250 std::string atEntry, atValue;
2251 while (isOK && hasAttractor) {
2252 isOK = static_cast<bool>(load >> atEntry);
2254 if (atEntry == "__ATTRACTORS_END__")
2256 isOK = static_cast<bool>(load >> atValue);
2259 std::string & value3 = _attractors[atEntry];
2261 int len3 = value3.size();
2262 // continue reading until "%#" encountered
2263 while (value3[len3 - 1] != '#' || value3[len3 - 2] != '%') {
2264 isOK = static_cast<bool>(load >> atValue);
2268 len3 = value3.size();
2273 value3[len3 - 2] = '\0'; //cut off "%#"
2278 isOK = static_cast<bool>(load >> option_or_sm);
2280 if (option_or_sm == "__NEW_ATTRACTORS_BEGIN__")
2281 hasNewAttractor = true;
2282 else if (option_or_sm == "__ENFORCED_VERTICES_BEGIN__")
2283 hasEnforcedVertex = true;
2284 else if (option_or_sm == "__PRECAD_FACES_PERIODICITY_BEGIN__")
2285 hasPreCADFacesPeriodicity = true;
2286 else if (option_or_sm == "__PRECAD_EDGES_PERIODICITY_BEGIN__")
2287 hasPreCADEdgesPeriodicity = true;
2288 else if (option_or_sm == "__FACES_PERIODICITY_BEGIN__")
2289 hasFacesPeriodicity = true;
2290 else if (option_or_sm == "__EDGES_PERIODICITY_BEGIN__")
2291 hasEdgesPeriodicity = true;
2292 else if (option_or_sm == "__VERTICES_PERIODICITY_BEGIN__")
2293 hasVerticesPeriodicity = true;
2297 std::string newAtFaceEntry, atTestString;
2298 std::string newAtShapeEntry;
2299 double attParams[4];
2301 while (isOK && hasNewAttractor) {
2302 //std::cout<<"Load new attractor"<<std::endl;
2303 isOK = static_cast<bool>(load >> newAtFaceEntry);
2305 if (newAtFaceEntry == "__NEW_ATTRACTORS_END__")
2307 isOK = static_cast<bool>(load >> newAtShapeEntry);
2310 isOK = static_cast<bool>(load >> attParams[0]>>attParams[1]>>attParams[2]>>attParams[3]); //>>step);
2313 MESSAGE(" LOADING ATTRACTOR HYPOTHESIS ")
2314 const TopoDS_Shape attractorShape = BLSURFPlugin_Hypothesis::entryToShape(newAtShapeEntry);
2315 const TopoDS_Face faceShape = TopoDS::Face(BLSURFPlugin_Hypothesis::entryToShape(newAtFaceEntry));
2316 BLSURFPlugin_Attractor* attractor = new BLSURFPlugin_Attractor(faceShape, attractorShape, newAtShapeEntry);//, step);
2317 attractor->SetParameters(attParams[0], attParams[1], attParams[2], attParams[3]);
2318 //attractor->BuildMap();
2319 _classAttractors.insert( make_pair( newAtFaceEntry, attractor ));
2324 if (hasNewAttractor) {
2325 isOK = static_cast<bool>(load >> option_or_sm);
2327 if (option_or_sm == "__ENFORCED_VERTICES_BEGIN__")
2328 hasEnforcedVertex = true;
2329 else if (option_or_sm == "__PRECAD_FACES_PERIODICITY_BEGIN__")
2330 hasPreCADFacesPeriodicity = true;
2331 else if (option_or_sm == "__PRECAD_EDGES_PERIODICITY_BEGIN__")
2332 hasPreCADEdgesPeriodicity = true;
2333 else if (option_or_sm == "__FACES_PERIODICITY_BEGIN__")
2334 hasFacesPeriodicity = true;
2335 else if (option_or_sm == "__EDGES_PERIODICITY_BEGIN__")
2336 hasEdgesPeriodicity = true;
2337 else if (option_or_sm == "__VERTICES_PERIODICITY_BEGIN__")
2338 hasVerticesPeriodicity = true;
2344 // Here is a example of the saved stream:
2345 // __ENFORCED_VERTICES_BEGIN__
2346 // __BEGIN_VERTEX__ => no name, no entry
2347 // __BEGIN_GROUP__ mon groupe __END_GROUP__
2348 // __BEGIN_COORDS__ 10 10 10 __END_COORDS__
2349 // __BEGIN_FACELIST__ 0:1:1:1:1 __END_FACELIST__
2351 // __BEGIN_VERTEX__ => no coords
2352 // __BEGIN_NAME__ mes points __END_NAME__
2353 // __BEGIN_ENTRY__ 0:1:1:4 __END_ENTRY__
2354 // __BEGIN_GROUP__ mon groupe __END_GROUP__
2355 // __BEGIN_FACELIST__ 0:1:1:1:3 __END_FACELIST__
2357 // __ENFORCED_VERTICES_END__
2360 std::string enfSeparator;
2361 std::string enfName;
2362 std::string enfGeomEntry;
2363 std::string enfGroup;
2364 TEntryList enfFaceEntryList;
2365 double enfCoords[3];
2366 bool hasCoords = false;
2368 _faceEntryEnfVertexListMap.clear();
2369 _enfVertexList.clear();
2370 _faceEntryCoordsListMap.clear();
2371 _coordsEnfVertexMap.clear();
2372 _faceEntryEnfVertexEntryListMap.clear();
2373 _enfVertexEntryEnfVertexMap.clear();
2376 while (isOK && hasEnforcedVertex) {
2377 isOK = static_cast<bool>(load >> enfSeparator); // __BEGIN_VERTEX__
2378 TEnfVertex *enfVertex = new TEnfVertex();
2379 // MESSAGE("enfSeparator: " <<enfSeparator);
2380 if (enfSeparator == "__ENFORCED_VERTICES_END__")
2381 break; // __ENFORCED_VERTICES_END__
2382 if (enfSeparator != "__BEGIN_VERTEX__")
2383 throw std::exception();
2386 isOK = static_cast<bool>(load >> enfSeparator);
2387 MESSAGE("enfSeparator: " <<enfSeparator);
2388 if (enfSeparator == "__END_VERTEX__") {
2390 enfVertex->name = enfName;
2391 enfVertex->geomEntry = enfGeomEntry;
2392 enfVertex->grpName = enfGroup;
2393 enfVertex->coords.clear();
2395 enfVertex->coords.assign(enfCoords,enfCoords+3);
2396 enfVertex->faceEntries = enfFaceEntryList;
2398 _enfVertexList.insert(enfVertex);
2400 if (enfVertex->coords.size()) {
2401 _coordsEnfVertexMap[enfVertex->coords] = enfVertex;
2402 for (TEntryList::const_iterator it = enfVertex->faceEntries.begin() ; it != enfVertex->faceEntries.end(); ++it) {
2403 _faceEntryCoordsListMap[(*it)].insert(enfVertex->coords);
2404 _faceEntryEnfVertexListMap[(*it)].insert(enfVertex);
2407 if (!enfVertex->geomEntry.empty()) {
2408 _enfVertexEntryEnfVertexMap[enfVertex->geomEntry] = enfVertex;
2409 for (TEntryList::const_iterator it = enfVertex->faceEntries.begin() ; it != enfVertex->faceEntries.end(); ++it) {
2410 _faceEntryEnfVertexEntryListMap[(*it)].insert(enfVertex->geomEntry);
2411 _faceEntryEnfVertexListMap[(*it)].insert(enfVertex);
2416 enfGeomEntry.clear();
2418 enfFaceEntryList.clear();
2420 break; // __END_VERTEX__
2423 if (enfSeparator == "__BEGIN_NAME__") { // __BEGIN_NAME__
2424 while (isOK && (enfSeparator != "__END_NAME__")) {
2425 isOK = static_cast<bool>(load >> enfSeparator);
2426 if (enfSeparator != "__END_NAME__") {
2427 if (!enfName.empty())
2429 enfName += enfSeparator;
2432 MESSAGE("enfName: " <<enfName);
2435 if (enfSeparator == "__BEGIN_ENTRY__") { // __BEGIN_ENTRY__
2436 isOK = static_cast<bool>(load >> enfGeomEntry);
2437 isOK = static_cast<bool>(load >> enfSeparator); // __END_ENTRY__
2438 if (enfSeparator != "__END_ENTRY__")
2439 throw std::exception();
2440 MESSAGE("enfGeomEntry: " <<enfGeomEntry);
2443 if (enfSeparator == "__BEGIN_GROUP__") { // __BEGIN_GROUP__
2444 while (isOK && (enfSeparator != "__END_GROUP__")) {
2445 isOK = static_cast<bool>(load >> enfSeparator);
2446 if (enfSeparator != "__END_GROUP__") {
2447 if (!enfGroup.empty())
2449 enfGroup += enfSeparator;
2452 MESSAGE("enfGroup: " <<enfGroup);
2455 if (enfSeparator == "__BEGIN_COORDS__") { // __BEGIN_COORDS__
2457 isOK = static_cast<bool>(load >> enfCoords[0] >> enfCoords[1] >> enfCoords[2]);
2458 isOK = static_cast<bool>(load >> enfSeparator); // __END_COORDS__
2459 if (enfSeparator != "__END_COORDS__")
2460 throw std::exception();
2461 MESSAGE("enfCoords: " << enfCoords[0] <<","<< enfCoords[1] <<","<< enfCoords[2]);
2464 if (enfSeparator == "__BEGIN_FACELIST__") { // __BEGIN_FACELIST__
2465 while (isOK && (enfSeparator != "__END_FACELIST__")) {
2466 isOK = static_cast<bool>(load >> enfSeparator);
2467 if (enfSeparator != "__END_FACELIST__") {
2468 enfFaceEntryList.insert(enfSeparator);
2469 MESSAGE(enfSeparator << " was inserted into enfFaceEntryList");
2478 if (hasPreCADFacesPeriodicity){
2479 LoadPreCADPeriodicity(load, "FACES");
2481 isOK = static_cast<bool>(load >> option_or_sm);
2483 if (option_or_sm == "__PRECAD_EDGES_PERIODICITY_BEGIN__")
2484 hasPreCADEdgesPeriodicity = true;
2485 else if (option_or_sm == "__FACES_PERIODICITY_BEGIN__")
2486 hasFacesPeriodicity = true;
2487 else if (option_or_sm == "__EDGES_PERIODICITY_BEGIN__")
2488 hasEdgesPeriodicity = true;
2489 else if (option_or_sm == "__VERTICES_PERIODICITY_BEGIN__")
2490 hasVerticesPeriodicity = true;
2494 if (hasPreCADEdgesPeriodicity){
2495 LoadPreCADPeriodicity(load, "EDGES");
2497 isOK = static_cast<bool>(load >> option_or_sm);
2499 if (option_or_sm == "__FACES_PERIODICITY_BEGIN__")
2500 hasFacesPeriodicity = true;
2501 else if (option_or_sm == "__EDGES_PERIODICITY_BEGIN__")
2502 hasEdgesPeriodicity = true;
2503 else if (option_or_sm == "__VERTICES_PERIODICITY_BEGIN__")
2504 hasVerticesPeriodicity = true;
2508 if (hasFacesPeriodicity){
2509 LoadFacesPeriodicity(load);
2511 isOK = static_cast<bool>(load >> option_or_sm);
2513 if (option_or_sm == "__EDGES_PERIODICITY_BEGIN__")
2514 hasEdgesPeriodicity = true;
2515 else if (option_or_sm == "__VERTICES_PERIODICITY_BEGIN__")
2516 hasVerticesPeriodicity = true;
2520 if (hasEdgesPeriodicity){
2521 LoadEdgesPeriodicity(load);
2523 isOK = static_cast<bool>(load >> option_or_sm);
2525 if (option_or_sm == "__VERTICES_PERIODICITY_BEGIN__")
2526 hasVerticesPeriodicity = true;
2529 if (hasVerticesPeriodicity)
2530 LoadVerticesPeriodicity(load);
2535 void BLSURFPlugin_Hypothesis::LoadFacesPeriodicity(std::istream & load){
2539 std::string periodicitySeparator;
2543 _facesPeriodicityVector.clear();
2546 isOK = static_cast<bool>(load >> periodicitySeparator); // __BEGIN_PERIODICITY_DESCRIPTION__
2547 MESSAGE("periodicitySeparator 1: " <<periodicitySeparator);
2548 TFacesPeriodicity *periodicity_i = new TFacesPeriodicity();
2549 if (periodicitySeparator == "__FACES_PERIODICITY_END__")
2550 break; // __FACES_PERIODICITY_END__
2551 if (periodicitySeparator != "__BEGIN_PERIODICITY_DESCRIPTION__"){
2552 MESSAGE("//" << periodicitySeparator << "//");
2553 throw std::exception();
2557 isOK = static_cast<bool>(load >> periodicitySeparator);
2558 MESSAGE("periodicitySeparator 2: " <<periodicitySeparator);
2559 if (periodicitySeparator == "__END_PERIODICITY_DESCRIPTION__") {
2561 periodicity_i->first = shape1Entry;
2562 periodicity_i->second = shape2Entry;
2564 _facesPeriodicityVector.push_back(*periodicity_i);
2566 break; // __END_PERIODICITY_DESCRIPTION__
2569 if (periodicitySeparator == "__BEGIN_ENTRY1__") { // __BEGIN_ENTRY1__
2570 isOK = static_cast<bool>(load >> shape1Entry);
2571 isOK = static_cast<bool>(load >> periodicitySeparator); // __END_ENTRY1__
2572 if (periodicitySeparator != "__END_ENTRY1__")
2573 throw std::exception();
2574 MESSAGE("shape1Entry: " <<shape1Entry);
2577 if (periodicitySeparator == "__BEGIN_ENTRY2__") { // __BEGIN_ENTRY2__
2578 isOK = static_cast<bool>(load >> shape2Entry);
2579 isOK = static_cast<bool>(load >> periodicitySeparator); // __END_ENTRY2__
2580 if (periodicitySeparator != "__END_ENTRY2__")
2581 throw std::exception();
2582 MESSAGE("shape2Entry: " <<shape2Entry);
2589 void BLSURFPlugin_Hypothesis::LoadEdgesPeriodicity(std::istream & load){
2593 std::string periodicitySeparator;
2594 TEntry theFace1Entry;
2595 TEntry theEdge1Entry;
2596 TEntry theFace2Entry;
2597 TEntry theEdge2Entry;
2598 int edge_orientation = 0;
2600 _edgesPeriodicityVector.clear();
2603 isOK = static_cast<bool>(load >> periodicitySeparator); // __BEGIN_PERIODICITY_DESCRIPTION__
2604 MESSAGE("periodicitySeparator 1: " <<periodicitySeparator);
2605 TEdgePeriodicity *periodicity_i = new TEdgePeriodicity();
2606 if (periodicitySeparator == "__EDGES_PERIODICITY_END__")
2607 break; // __EDGES_PERIODICITY_END__
2608 if (periodicitySeparator != "__BEGIN_PERIODICITY_DESCRIPTION__"){
2609 MESSAGE("//" << periodicitySeparator << "//");
2610 throw std::exception();
2614 isOK = static_cast<bool>(load >> periodicitySeparator);
2615 MESSAGE("periodicitySeparator 2: " <<periodicitySeparator);
2616 if (periodicitySeparator == "__END_PERIODICITY_DESCRIPTION__") {
2618 periodicity_i->theFace1Entry = theFace1Entry;
2619 periodicity_i->theEdge1Entry = theEdge1Entry;
2620 periodicity_i->theFace2Entry = theFace2Entry;
2621 periodicity_i->theEdge2Entry = theEdge2Entry;
2622 periodicity_i->edge_orientation = edge_orientation;
2624 _edgesPeriodicityVector.push_back(*periodicity_i);
2626 break; // __END_PERIODICITY_DESCRIPTION__
2629 if (periodicitySeparator == "__BEGIN_FACE1__") { // __BEGIN_FACE1__
2630 isOK = static_cast<bool>(load >> theFace1Entry);
2631 MESSAGE("//" << theFace1Entry << "//");
2632 isOK = static_cast<bool>(load >> periodicitySeparator); // __END_FACE1__
2633 if (periodicitySeparator != "__END_FACE1__"){
2634 MESSAGE("//" << periodicitySeparator << "//");
2635 throw std::exception();
2637 MESSAGE("theFace1Entry: " <<theFace1Entry);
2640 if (periodicitySeparator == "__BEGIN_EDGE1__") { // __BEGIN_EDGE1__
2641 isOK = static_cast<bool>(load >> theEdge1Entry);
2642 isOK = static_cast<bool>(load >> periodicitySeparator); // __END_EDGE1__
2643 if (periodicitySeparator != "__END_EDGE1__")
2644 throw std::exception();
2645 MESSAGE("theEdge1Entry: " <<theEdge1Entry);
2648 if (periodicitySeparator == "__BEGIN_FACE2__") { // __BEGIN_FACE2__
2649 isOK = static_cast<bool>(load >> theFace2Entry);
2650 isOK = static_cast<bool>(load >> periodicitySeparator); // __END_FACE2__
2651 if (periodicitySeparator != "__END_FACE2__")
2652 throw std::exception();
2653 MESSAGE("theFace2Entry: " <<theFace2Entry);
2656 if (periodicitySeparator == "__BEGIN_EDGE2__") { // __BEGIN_EDGE2__
2657 isOK = static_cast<bool>(load >> theEdge2Entry);
2658 isOK = static_cast<bool>(load >> periodicitySeparator); // __END_EDGE2__
2659 if (periodicitySeparator != "__END_EDGE2__")
2660 throw std::exception();
2661 MESSAGE("theEdge2Entry: " <<theEdge2Entry);
2664 if (periodicitySeparator == "__BEGIN_EDGE_ORIENTATION__") { // __BEGIN_EDGE_ORIENTATION__
2665 isOK = static_cast<bool>(load >> edge_orientation);
2666 isOK = static_cast<bool>(load >> periodicitySeparator); // __END_EDGE_ORIENTATION__
2667 if (periodicitySeparator != "__END_EDGE_ORIENTATION__")
2668 throw std::exception();
2669 MESSAGE("edge_orientation: " <<edge_orientation);
2675 void BLSURFPlugin_Hypothesis::LoadVerticesPeriodicity(std::istream & load){
2679 std::string periodicitySeparator;
2680 TEntry theEdge1Entry;
2681 TEntry theVertex1Entry;
2682 TEntry theEdge2Entry;
2683 TEntry theVertex2Entry;
2685 _verticesPeriodicityVector.clear();
2688 isOK = static_cast<bool>(load >> periodicitySeparator); // __BEGIN_PERIODICITY_DESCRIPTION__
2689 MESSAGE("periodicitySeparator 1: " <<periodicitySeparator);
2690 TVertexPeriodicity *periodicity_i = new TVertexPeriodicity();
2691 if (periodicitySeparator == "__VERTICES_PERIODICITY_END__")
2692 break; // __VERTICES_PERIODICITY_END__
2693 if (periodicitySeparator != "__BEGIN_PERIODICITY_DESCRIPTION__"){
2694 MESSAGE("//" << periodicitySeparator << "//");
2695 throw std::exception();
2699 isOK = static_cast<bool>(load >> periodicitySeparator);
2700 MESSAGE("periodicitySeparator 2: " <<periodicitySeparator);
2701 if (periodicitySeparator == "__END_PERIODICITY_DESCRIPTION__") {
2703 periodicity_i->theEdge1Entry = theEdge1Entry;
2704 periodicity_i->theVertex1Entry = theVertex1Entry;
2705 periodicity_i->theEdge2Entry = theEdge2Entry;
2706 periodicity_i->theVertex2Entry = theVertex2Entry;
2708 _verticesPeriodicityVector.push_back(*periodicity_i);
2710 break; // __END_PERIODICITY_DESCRIPTION__
2713 if (periodicitySeparator == "__BEGIN_EDGE1__") { // __BEGIN_EDGE1__
2714 isOK = static_cast<bool>(load >> theEdge1Entry);
2715 isOK = static_cast<bool>(load >> periodicitySeparator); // __END_EDGE1__
2716 if (periodicitySeparator != "__END_EDGE1__")
2717 throw std::exception();
2718 MESSAGE("theEdge1Entry: " <<theEdge1Entry);
2721 if (periodicitySeparator == "__BEGIN_VERTEX1__") { // __BEGIN_VERTEX1__
2722 isOK = static_cast<bool>(load >> theVertex1Entry);
2723 isOK = static_cast<bool>(load >> periodicitySeparator); // __END_VERTEX1__
2724 if (periodicitySeparator != "__END_VERTEX1__")
2725 throw std::exception();
2726 MESSAGE("theVertex1Entry: " <<theVertex1Entry);
2729 if (periodicitySeparator == "__BEGIN_EDGE2__") { // __BEGIN_EDGE2__
2730 isOK = static_cast<bool>(load >> theEdge2Entry);
2731 isOK = static_cast<bool>(load >> periodicitySeparator); // __END_EDGE2__
2732 if (periodicitySeparator != "__END_EDGE2__")
2733 throw std::exception();
2734 MESSAGE("theEdge2Entry: " <<theEdge2Entry);
2737 if (periodicitySeparator == "__BEGIN_VERTEX2__") { // __BEGIN_VERTEX2__
2738 isOK = static_cast<bool>(load >> theVertex2Entry);
2739 isOK = static_cast<bool>(load >> periodicitySeparator); // __END_VERTEX2__
2740 if (periodicitySeparator != "__END_VERTEX2__")
2741 throw std::exception();
2742 MESSAGE("theVertex2Entry: " <<theVertex2Entry);
2748 void BLSURFPlugin_Hypothesis::LoadPreCADPeriodicity(std::istream & load, const char* shapeType) {
2752 std::string periodicitySeparator;
2755 std::vector<std::string> theSourceVerticesEntries;
2756 std::vector<std::string> theTargetVerticesEntries;
2758 bool hasSourceVertices = false;
2759 bool hasTargetVertices = false;
2761 if ( shapeType && strcmp( shapeType, "FACES") == 0 )
2762 _preCadFacesPeriodicityVector.clear();
2764 _preCadEdgesPeriodicityVector.clear();
2768 isOK = static_cast<bool>(load >> periodicitySeparator); // __BEGIN_PERIODICITY_DESCRIPTION__
2769 MESSAGE("periodicitySeparator 1: " <<periodicitySeparator);
2770 TPreCadPeriodicity *periodicity_i = new TPreCadPeriodicity();
2771 // MESSAGE("periodicitySeparator: " <<periodicitySeparator);
2772 std::string endSeparator = "__PRECAD_" + std::string(shapeType) + "_PERIODICITY_END__";
2773 if (periodicitySeparator == endSeparator)
2774 break; // __PRECAD_FACES_PERIODICITY_END__
2775 if (periodicitySeparator != "__BEGIN_PERIODICITY_DESCRIPTION__"){
2776 MESSAGE("//" << endSeparator << "//");
2777 MESSAGE("//" << periodicitySeparator << "//");
2778 throw std::exception();
2782 isOK = static_cast<bool>(load >> periodicitySeparator);
2783 MESSAGE("periodicitySeparator 2: " <<periodicitySeparator);
2784 if (periodicitySeparator == "__END_PERIODICITY_DESCRIPTION__") {
2786 periodicity_i->shape1Entry = shape1Entry;
2787 periodicity_i->shape2Entry = shape2Entry;
2789 MESSAGE("theSourceVerticesEntries.size(): " << theSourceVerticesEntries.size());
2790 MESSAGE("theTargetVerticesEntries.size(): " << theTargetVerticesEntries.size());
2792 if (hasSourceVertices)
2793 periodicity_i->theSourceVerticesEntries = theSourceVerticesEntries;
2794 if (hasTargetVertices)
2795 periodicity_i->theTargetVerticesEntries = theTargetVerticesEntries;
2797 if ( shapeType && strcmp( shapeType, "FACES" ))
2798 _preCadFacesPeriodicityVector.push_back(*periodicity_i);
2800 _preCadEdgesPeriodicityVector.push_back(*periodicity_i);
2802 theSourceVerticesEntries.clear();
2803 theTargetVerticesEntries.clear();
2804 hasSourceVertices = false;
2805 hasTargetVertices = false;
2806 break; // __END_PERIODICITY_DESCRIPTION__
2809 if (periodicitySeparator == "__BEGIN_ENTRY1__") { // __BEGIN_ENTRY1__
2810 isOK = static_cast<bool>(load >> shape1Entry);
2811 isOK = static_cast<bool>(load >> periodicitySeparator); // __END_ENTRY1__
2812 if (periodicitySeparator != "__END_ENTRY1__")
2813 throw std::exception();
2814 MESSAGE("shape1Entry: " <<shape1Entry);
2817 if (periodicitySeparator == "__BEGIN_ENTRY2__") { // __BEGIN_ENTRY2__
2818 isOK = static_cast<bool>(load >> shape2Entry);
2819 isOK = static_cast<bool>(load >> periodicitySeparator); // __END_ENTRY2__
2820 if (periodicitySeparator != "__END_ENTRY2__")
2821 throw std::exception();
2822 MESSAGE("shape2Entry: " <<shape2Entry);
2825 if (periodicitySeparator == "__BEGIN_SOURCE_VERTICES_LIST__") { // __BEGIN_SOURCE_VERTICES_LIST__
2826 hasSourceVertices = true;
2827 while (isOK && (periodicitySeparator != "__END_SOURCE_VERTICES_LIST__")) {
2828 isOK = static_cast<bool>(load >> periodicitySeparator);
2829 if (periodicitySeparator != "__END_SOURCE_VERTICES_LIST__") {
2830 theSourceVerticesEntries.push_back(periodicitySeparator);
2831 MESSAGE("theSourceVerticesEntries: " <<periodicitySeparator);
2836 if (periodicitySeparator == "__BEGIN_TARGET_VERTICES_LIST__") { // __BEGIN_TARGET_VERTICES_LIST__
2837 hasTargetVertices = true;
2838 while (isOK && (periodicitySeparator != "__END_TARGET_VERTICES_LIST__")) {
2839 isOK = static_cast<bool>(load >> periodicitySeparator);
2840 if (periodicitySeparator != "__END_TARGET_VERTICES_LIST__") {
2841 theTargetVerticesEntries.push_back(periodicitySeparator);
2842 MESSAGE("theTargetVerticesEntries: " <<periodicitySeparator);
2850 //=============================================================================
2851 std::ostream & operator <<(std::ostream & save, BLSURFPlugin_Hypothesis & hyp) {
2852 return hyp.SaveTo(save);
2855 //=============================================================================
2856 std::istream & operator >>(std::istream & load, BLSURFPlugin_Hypothesis & hyp) {
2857 return hyp.LoadFrom(load);
2860 //================================================================================
2862 * \brief Does nothing
2864 //================================================================================
2866 bool BLSURFPlugin_Hypothesis::SetParametersByMesh(const SMESH_Mesh* theMesh, const TopoDS_Shape& theShape) {
2870 //================================================================================
2872 * \brief Returns default global constant physical size given a default value of element length ratio
2874 //================================================================================
2876 double BLSURFPlugin_Hypothesis::GetDefaultPhySize(double diagonal, double bbSegmentation) {
2877 if (bbSegmentation != 0 && diagonal != 0)
2878 return diagonal / bbSegmentation ;
2882 //================================================================================
2884 * \brief Returns default min size given a default value of element length ratio
2886 //================================================================================
2888 double BLSURFPlugin_Hypothesis::GetDefaultMinSize(double diagonal) {
2890 return diagonal / 1000.0 ;
2891 return undefinedDouble();
2894 //================================================================================
2896 * \brief Returns default max size given a default value of element length ratio
2898 //================================================================================
2900 double BLSURFPlugin_Hypothesis::GetDefaultMaxSize(double diagonal) {
2902 return diagonal / 5.0 ;
2903 return undefinedDouble();
2906 //================================================================================
2908 * \brief Returns default chordal error given a default value of element length ratio
2910 //================================================================================
2912 double BLSURFPlugin_Hypothesis::GetDefaultChordalError(double diagonal) {
2915 return undefinedDouble();
2918 //================================================================================
2920 * \brief Returns default tiny edge length given a default value of element length ratio
2922 //================================================================================
2924 double BLSURFPlugin_Hypothesis::GetDefaultTinyEdgeLength(double diagonal) {
2926 return diagonal * 1e-6 ;
2927 return undefinedDouble();
2930 //=============================================================================
2932 * \brief Initialize my parameter values by default parameters.
2933 * \retval bool - true if parameter values have been successfully defined
2935 //=============================================================================
2937 bool BLSURFPlugin_Hypothesis::SetParametersByDefaults(const TDefaults& dflts, const SMESH_Mesh* theMesh) {
2938 double diagonal = dflts._elemLength*_gen->GetBoundaryBoxSegmentation();
2939 _phySize = GetDefaultPhySize(diagonal, _gen->GetBoundaryBoxSegmentation());
2940 _minSize = GetDefaultMinSize(diagonal);
2941 _maxSize = GetDefaultMaxSize(diagonal);
2942 _chordalError = GetDefaultChordalError(diagonal);
2943 _tinyEdgeLength = GetDefaultTinyEdgeLength(diagonal);
2946 // return bool(_phySize = dflts._elemLength);