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 _preCADProcess3DTopology(GetDefaultPreCADProcess3DTopology()),
69 _preCADDiscardInput(GetDefaultPreCADDiscardInput()),
70 _sizeMap(GetDefaultSizeMap()),
71 _attractors(GetDefaultSizeMap()),
72 _classAttractors(GetDefaultAttractorMap()),
73 _faceEntryEnfVertexListMap(GetDefaultFaceEntryEnfVertexListMap()),
74 _enfVertexList(GetDefaultEnfVertexList()),
75 _faceEntryCoordsListMap(GetDefaultFaceEntryCoordsListMap()),
76 _coordsEnfVertexMap(GetDefaultCoordsEnfVertexMap()),
77 _faceEntryEnfVertexEntryListMap(GetDefaultFaceEntryEnfVertexEntryListMap()),
78 _enfVertexEntryEnfVertexMap(GetDefaultEnfVertexEntryEnfVertexMap()),
79 _groupNameNodeIDMap(GetDefaultGroupNameNodeIDMap()),
80 _enforcedInternalVerticesAllFaces(GetDefaultInternalEnforcedVertex()),
81 _preCadFacesPeriodicityVector(GetDefaultPreCadFacesPeriodicityVector()),
82 _preCadEdgesPeriodicityVector(GetDefaultPreCadEdgesPeriodicityVector()),
83 _GMFFileName(GetDefaultGMFFile())
88 // _GMFFileMode = false; // GMF ascii mode
90 const char* boolOptionNames[] = { "correct_surface_intersections", // default = 1
91 "create_tag_on_collision", // default = 1
92 "debug", // default = 0
93 "enforce_cad_edge_sizes", // default = 0
94 "frontal", // ok default = 1
95 "jacobian_rectification_respect_geometry", // default = 1
96 "proximity", // default = 0
97 "rectify_jacobian", // default = 1
98 "respect_geometry", // default = 1
99 "optimise_tiny_edges", // default = 0
100 "remove_duplicate_cad_faces", // default = 1
101 "tiny_edge_avoid_surface_intersections", // default = 1
102 "tiny_edge_respect_geometry", // default = 0
106 const char* intOptionNames[] = { "hinterpol_flag", // ok default = 0
107 "hmean_flag", // ok default = 0
108 "max_number_of_points_per_patch", // default = 100000
109 "prox_nb_layer", // detects the volumic proximity of surfaces
112 const char* doubleOptionNames[] = { "surface_intersections_processing_max_cost",// default = 15
113 "periodic_tolerance", // default = diag/100
116 "tiny_edge_optimisation_length", // default = diag * 1e-6
119 const char* charOptionNames[] = { "required_entities", // default = "respect"
120 "tags", // default = "respect"
124 // PreCAD advanced options
125 const char* preCADboolOptionNames[] = { "closed_geometry", // default = 0
126 "create_tag_on_collision", // default = 1
127 "debug", // default = 0
128 "remove_tiny_edges", // default = 0
131 const char* preCADintOptionNames[] = { "manifold_geometry", // default = 0
134 const char* preCADdoubleOptionNames[] = { "periodic_tolerance", // default = diag * 1e-5
135 "sewing_tolerance", // default = diag * 5e-4
136 "tiny_edge_length", // default = diag * 1e-5
139 const char* preCADcharOptionNames[] = { "required_entities", // default = "respect"
140 "tags", // default = "respect"
145 while (boolOptionNames[i][0])
146 _option2value[boolOptionNames[i++]].clear();
149 while (preCADboolOptionNames[i][0])
150 _preCADoption2value[preCADboolOptionNames[i++]].clear();
153 while (intOptionNames[i][0])
154 _option2value[intOptionNames[i++]].clear();
157 while (preCADintOptionNames[i][0])
158 _preCADoption2value[preCADintOptionNames[i++]].clear();
161 while (doubleOptionNames[i][0]) {
162 _doubleOptions.insert(doubleOptionNames[i]);
163 _option2value[doubleOptionNames[i++]].clear();
166 while (preCADdoubleOptionNames[i][0]) {
167 _preCADdoubleOptions.insert(preCADdoubleOptionNames[i]);
168 _preCADoption2value[preCADdoubleOptionNames[i++]].clear();
171 while (charOptionNames[i][0]) {
172 _charOptions.insert(charOptionNames[i]);
173 _option2value[charOptionNames[i++]].clear();
176 while (preCADcharOptionNames[i][0]) {
177 _preCADcharOptions.insert(preCADcharOptionNames[i]);
178 _preCADoption2value[preCADcharOptionNames[i++]].clear();
185 _faceEntryEnfVertexListMap.clear();
186 _enfVertexList.clear();
187 _faceEntryCoordsListMap.clear();
188 _coordsEnfVertexMap.clear();
189 _faceEntryEnfVertexEntryListMap.clear();
190 _enfVertexEntryEnfVertexMap.clear();
191 _groupNameNodeIDMap.clear();
194 _groupNameEnfVertexListMap.clear();
195 _enfVertexGroupNameMap.clear();
199 TopoDS_Shape BLSURFPlugin_Hypothesis::entryToShape(std::string entry)
201 MESSAGE("BLSURFPlugin_Hypothesis::entryToShape "<<entry );
202 GEOM::GEOM_Object_var aGeomObj;
203 SMESH_Gen_i* smeshGen_i = SMESH_Gen_i::GetSMESHGen();
204 SALOMEDS::Study_ptr myStudy = smeshGen_i->GetCurrentStudy();
206 TopoDS_Shape S = TopoDS_Shape();
207 SALOMEDS::SObject_var aSObj = myStudy->FindObjectID( entry.c_str() );
208 if (!aSObj->_is_nil() ) {
209 CORBA::Object_var obj = aSObj->GetObject();
210 aGeomObj = GEOM::GEOM_Object::_narrow(obj);
213 if ( !aGeomObj->_is_nil() )
214 S = smeshGen_i->GeomObjectToShape( aGeomObj.in() );
218 //=============================================================================
219 void BLSURFPlugin_Hypothesis::SetPhysicalMesh(PhysicalMesh thePhysicalMesh) {
220 if (thePhysicalMesh != _physicalMesh) {
221 _physicalMesh = thePhysicalMesh;
222 NotifySubMeshesHypothesisModification();
226 //=============================================================================
227 void BLSURFPlugin_Hypothesis::SetGeometricMesh(GeometricMesh theGeometricMesh) {
228 if (theGeometricMesh != _geometricMesh) {
229 _geometricMesh = theGeometricMesh;
230 // switch (_geometricMesh) {
233 // _angleMesh = GetDefaultAngleMesh();
234 // _gradation = GetDefaultGradation();
237 NotifySubMeshesHypothesisModification();
241 //=============================================================================
242 void BLSURFPlugin_Hypothesis::SetPhySize(double theVal, bool isRelative) {
243 if ((theVal != _phySize) || (isRelative != _phySizeRel)) {
244 _phySizeRel = isRelative;
246 _phySize = GetMaxSize();
247 MESSAGE("Warning: nul physical size is not allowed");
251 NotifySubMeshesHypothesisModification();
255 //=============================================================================
256 void BLSURFPlugin_Hypothesis::SetMinSize(double theMinSize, bool isRelative) {
257 if ((theMinSize != _minSize) || (isRelative != _minSizeRel)) {
258 _minSizeRel = isRelative;
259 _minSize = theMinSize;
260 NotifySubMeshesHypothesisModification();
264 //=============================================================================
265 void BLSURFPlugin_Hypothesis::SetMaxSize(double theMaxSize, bool isRelative) {
266 if ((theMaxSize != _maxSize) || (isRelative != _maxSizeRel)) {
267 _maxSizeRel = isRelative;
268 _maxSize = theMaxSize;
269 NotifySubMeshesHypothesisModification();
273 //=============================================================================
274 void BLSURFPlugin_Hypothesis::SetGradation(double theVal) {
275 if (theVal != _gradation) {
277 NotifySubMeshesHypothesisModification();
281 //=============================================================================
282 void BLSURFPlugin_Hypothesis::SetQuadAllowed(bool theVal) {
283 if (theVal != _quadAllowed) {
284 _quadAllowed = theVal;
285 NotifySubMeshesHypothesisModification();
289 //=============================================================================
290 void BLSURFPlugin_Hypothesis::SetAngleMesh(double theVal) {
291 if (theVal != _angleMesh) {
293 NotifySubMeshesHypothesisModification();
297 //=============================================================================
298 void BLSURFPlugin_Hypothesis::SetChordalError(double theDistance) {
299 if (theDistance != _chordalError) {
300 _chordalError = theDistance;
301 NotifySubMeshesHypothesisModification();
305 //=============================================================================
306 void BLSURFPlugin_Hypothesis::SetAnisotropic(bool theVal) {
307 if (theVal != _anisotropic) {
308 _anisotropic = theVal;
309 NotifySubMeshesHypothesisModification();
313 //=============================================================================
314 void BLSURFPlugin_Hypothesis::SetAnisotropicRatio(double theVal) {
315 if (theVal != _anisotropicRatio) {
316 _anisotropicRatio = theVal;
317 NotifySubMeshesHypothesisModification();
321 //=============================================================================
322 void BLSURFPlugin_Hypothesis::SetRemoveTinyEdges(bool theVal) {
323 if (theVal != _removeTinyEdges) {
324 _removeTinyEdges = theVal;
325 NotifySubMeshesHypothesisModification();
329 //=============================================================================
330 void BLSURFPlugin_Hypothesis::SetTinyEdgeLength(double theVal) {
331 if (theVal != _tinyEdgeLength) {
332 _tinyEdgeLength = theVal;
333 NotifySubMeshesHypothesisModification();
337 //=============================================================================
338 void BLSURFPlugin_Hypothesis::SetBadElementRemoval(bool theVal) {
339 if (theVal != _badElementRemoval) {
340 _badElementRemoval = theVal;
341 NotifySubMeshesHypothesisModification();
345 //=============================================================================
346 void BLSURFPlugin_Hypothesis::SetBadElementAspectRatio(double theVal) {
347 if (theVal != _badElementAspectRatio) {
348 _badElementAspectRatio = theVal;
349 NotifySubMeshesHypothesisModification();
353 //=============================================================================
354 void BLSURFPlugin_Hypothesis::SetOptimizeMesh(bool theVal) {
355 if (theVal != _optimizeMesh) {
356 _optimizeMesh = theVal;
357 NotifySubMeshesHypothesisModification();
361 //=============================================================================
362 void BLSURFPlugin_Hypothesis::SetQuadraticMesh(bool theVal) {
363 if (theVal != _quadraticMesh) {
364 _quadraticMesh = theVal;
365 NotifySubMeshesHypothesisModification();
369 //=============================================================================
370 void BLSURFPlugin_Hypothesis::SetTopology(Topology theTopology) {
371 if (theTopology != _topology) {
372 _topology = theTopology;
373 NotifySubMeshesHypothesisModification();
377 //=============================================================================
378 void BLSURFPlugin_Hypothesis::SetVerbosity(int theVal) {
379 if (theVal != _verb) {
381 NotifySubMeshesHypothesisModification();
385 //=============================================================================
386 void BLSURFPlugin_Hypothesis::SetPreCADMergeEdges(bool theVal) {
387 if (theVal != _preCADMergeEdges) {
388 // SetTopology(PreCAD);
389 _preCADMergeEdges = theVal;
390 NotifySubMeshesHypothesisModification();
394 //=============================================================================
395 void BLSURFPlugin_Hypothesis::SetPreCADProcess3DTopology(bool theVal) {
396 if (theVal != _preCADProcess3DTopology) {
397 // SetTopology(PreCAD);
398 _preCADProcess3DTopology = theVal;
399 NotifySubMeshesHypothesisModification();
403 //=============================================================================
404 void BLSURFPlugin_Hypothesis::SetPreCADDiscardInput(bool theVal) {
405 if (theVal != _preCADDiscardInput) {
406 // SetTopology(PreCAD);
407 _preCADDiscardInput = theVal;
408 NotifySubMeshesHypothesisModification();
412 //=============================================================================
413 // void BLSURFPlugin_Hypothesis::SetGMFFile(const std::string& theFileName, bool isBinary)
414 void BLSURFPlugin_Hypothesis::SetGMFFile(const std::string& theFileName)
416 _GMFFileName = theFileName;
417 // _GMFFileMode = isBinary;
418 NotifySubMeshesHypothesisModification();
421 //=============================================================================
422 void BLSURFPlugin_Hypothesis::SetOptionValue(const std::string& optionName, const std::string& optionValue)
423 throw (std::invalid_argument) {
424 TOptionValues::iterator op_val = _option2value.find(optionName);
425 if (op_val == _option2value.end()) {
426 std::string msg = "Unknown MG-CADSurf option: '" + optionName + "'";
427 throw std::invalid_argument(msg);
429 if (op_val->second != optionValue) {
430 const char* ptr = optionValue.c_str();
431 // strip white spaces
432 while (ptr[0] == ' ')
435 while (i != 0 && ptr[i - 1] == ' ')
439 std::string typeName;
442 } else if (_charOptions.find(optionName) != _charOptions.end()) {
443 // do not check strings
444 } else if (_doubleOptions.find(optionName) != _doubleOptions.end()) {
445 // check if value is double
447 strtod(ptr, &endPtr);
448 typeOk = (ptr != endPtr);
451 // check if value is int
453 strtol(ptr, &endPtr, 10);
454 typeOk = (ptr != endPtr);
455 typeName = "integer";
458 std::string msg = "Advanced option '" + optionName + "' = '" + optionValue + "' but must be " + typeName;
459 throw std::invalid_argument(msg);
461 op_val->second = optionValue;
462 NotifySubMeshesHypothesisModification();
466 //=============================================================================
467 void BLSURFPlugin_Hypothesis::SetPreCADOptionValue(const std::string& optionName, const std::string& optionValue)
468 throw (std::invalid_argument) {
469 TOptionValues::iterator op_val = _preCADoption2value.find(optionName);
470 if (op_val == _preCADoption2value.end()) {
471 std::string msg = "Unknown MG-CADSurf option: '" + optionName + "'";
472 throw std::invalid_argument(msg);
474 if (op_val->second != optionValue) {
475 const char* ptr = optionValue.c_str();
476 // strip white spaces
477 while (ptr[0] == ' ')
480 while (i != 0 && ptr[i - 1] == ' ')
484 std::string typeName;
487 } else if (_preCADcharOptions.find(optionName) != _preCADcharOptions.end()) {
488 // do not check strings
489 } else if (_preCADdoubleOptions.find(optionName) != _preCADdoubleOptions.end()) {
490 // check if value is double
492 strtod(ptr, &endPtr);
493 typeOk = (ptr != endPtr);
496 // check if value is int
498 strtol(ptr, &endPtr, 10);
499 typeOk = (ptr != endPtr);
500 typeName = "integer";
503 std::string msg = "PreCAD advanced option '" + optionName + "' = '" + optionValue + "' but must be " + typeName;
504 throw std::invalid_argument(msg);
506 op_val->second = optionValue;
507 NotifySubMeshesHypothesisModification();
511 //=============================================================================
512 std::string BLSURFPlugin_Hypothesis::GetOptionValue(const std::string& optionName) throw (std::invalid_argument) {
513 TOptionValues::iterator op_val = _option2value.find(optionName);
514 if (op_val == _option2value.end()) {
515 std::string msg = "Unknown MG-CADSurf option: <";
516 msg += optionName + ">";
517 throw std::invalid_argument(msg);
519 return op_val->second;
522 //=============================================================================
523 std::string BLSURFPlugin_Hypothesis::GetPreCADOptionValue(const std::string& optionName) throw (std::invalid_argument) {
524 TOptionValues::iterator op_val = _preCADoption2value.find(optionName);
525 if (op_val == _preCADoption2value.end()) {
526 std::string msg = "Unknown PRECAD option: <";
527 msg += optionName + ">";
528 throw std::invalid_argument(msg);
530 return op_val->second;
533 //=============================================================================
534 void BLSURFPlugin_Hypothesis::ClearOption(const std::string& optionName) {
535 TOptionValues::iterator op_val = _customOption2value.find(optionName);
536 if (op_val != _customOption2value.end())
537 _customOption2value.erase(op_val);
539 op_val = _option2value.find(optionName);
540 if (op_val != _option2value.end())
541 op_val->second.clear();
545 //=============================================================================
546 void BLSURFPlugin_Hypothesis::ClearPreCADOption(const std::string& optionName) {
547 TOptionValues::iterator op_val = _customPreCADOption2value.find(optionName);
548 if (op_val != _customPreCADOption2value.end())
549 _customPreCADOption2value.erase(op_val);
551 op_val = _preCADoption2value.find(optionName);
552 if (op_val != _preCADoption2value.end())
553 op_val->second.clear();
557 //=============================================================================
558 void BLSURFPlugin_Hypothesis::AddOption(const std::string& optionName, const std::string& optionValue)
560 TOptionValues::iterator op_val = _option2value.find(optionName);
561 if (op_val != _option2value.end()) {
562 if (op_val->second != optionValue)
563 op_val->second = optionValue;
566 op_val = _customOption2value.find(optionName);
567 if (op_val == _customOption2value.end())
568 _customOption2value[optionName] = optionValue;
569 else if (op_val->second != optionValue)
570 op_val->second = optionValue;
572 NotifySubMeshesHypothesisModification();
575 //=============================================================================
576 void BLSURFPlugin_Hypothesis::AddPreCADOption(const std::string& optionName, const std::string& optionValue)
578 TOptionValues::iterator op_val = _preCADoption2value.find(optionName);
579 if (op_val != _preCADoption2value.end()) {
580 if (op_val->second != optionValue)
581 op_val->second = optionValue;
584 op_val = _customPreCADOption2value.find(optionName);
585 if (op_val == _customPreCADOption2value.end())
586 _customPreCADOption2value[optionName] = optionValue;
587 else if (op_val->second != optionValue)
588 op_val->second = optionValue;
590 NotifySubMeshesHypothesisModification();
593 //=============================================================================
594 std::string BLSURFPlugin_Hypothesis::GetOption(const std::string& optionName)
596 TOptionValues::iterator op_val = _customOption2value.find(optionName);
597 if (op_val != _customOption2value.end())
598 return op_val->second;
603 //=============================================================================
604 std::string BLSURFPlugin_Hypothesis::GetPreCADOption(const std::string& optionName)
606 TOptionValues::iterator op_val = _customPreCADOption2value.find(optionName);
607 if (op_val != _customPreCADOption2value.end())
608 return op_val->second;
613 //=======================================================================
614 //function : SetSizeMapEntry
615 //=======================================================================
616 void BLSURFPlugin_Hypothesis::SetSizeMapEntry(const std::string& entry, const std::string& sizeMap) {
617 if (_sizeMap[entry].compare(sizeMap) != 0) {
618 SetPhysicalMesh(PhysicalLocalSize);
619 _sizeMap[entry] = sizeMap;
620 NotifySubMeshesHypothesisModification();
624 //=======================================================================
625 //function : GetSizeMapEntry
626 //=======================================================================
627 std::string BLSURFPlugin_Hypothesis::GetSizeMapEntry(const std::string& entry) {
628 TSizeMap::iterator it = _sizeMap.find(entry);
629 if (it != _sizeMap.end())
632 return "No_Such_Entry";
636 * \brief Return the size maps
638 BLSURFPlugin_Hypothesis::TSizeMap BLSURFPlugin_Hypothesis::GetSizeMapEntries(const BLSURFPlugin_Hypothesis* hyp) {
639 return hyp ? hyp->_GetSizeMapEntries() : GetDefaultSizeMap();
642 //=======================================================================
643 //function : SetAttractorEntry
644 //=======================================================================
645 void BLSURFPlugin_Hypothesis::SetAttractorEntry(const std::string& entry, const std::string& attractor) {
646 if (_attractors[entry].compare(attractor) != 0) {
647 SetPhysicalMesh(PhysicalLocalSize);
648 _attractors[entry] = attractor;
649 NotifySubMeshesHypothesisModification();
653 //=======================================================================
654 //function : GetAttractorEntry
655 //=======================================================================
656 std::string BLSURFPlugin_Hypothesis::GetAttractorEntry(const std::string& entry) {
657 TSizeMap::iterator it = _attractors.find(entry);
658 if (it != _attractors.end())
661 return "No_Such_Entry";
665 * \brief Return the attractors
667 BLSURFPlugin_Hypothesis::TSizeMap BLSURFPlugin_Hypothesis::GetAttractorEntries(const BLSURFPlugin_Hypothesis* hyp) {
668 return hyp ? hyp->_GetAttractorEntries() : GetDefaultSizeMap();
671 //=======================================================================
672 //function : SetClassAttractorEntry
673 //=======================================================================
674 void BLSURFPlugin_Hypothesis::SetClassAttractorEntry(const std::string& entry, const std::string& attEntry, double StartSize, double EndSize, double ActionRadius, double ConstantRadius)
676 SetPhysicalMesh(PhysicalLocalSize);
678 // The new attractor can't be defined on the same face as another sizemap
679 TSizeMap::iterator it = _sizeMap.find( entry );
680 if ( it != _sizeMap.end() ) {
682 NotifySubMeshesHypothesisModification();
685 TSizeMap::iterator itAt = _attractors.find( entry );
686 if ( itAt != _attractors.end() ) {
687 _attractors.erase(itAt);
688 NotifySubMeshesHypothesisModification();
692 const TopoDS_Shape AttractorShape = BLSURFPlugin_Hypothesis::entryToShape(attEntry);
693 const TopoDS_Face FaceShape = TopoDS::Face(BLSURFPlugin_Hypothesis::entryToShape(entry));
694 TAttractorMap::iterator attIt = _classAttractors.find(entry);
695 for ( ; attIt != _classAttractors.end(); ++attIt )
696 if ( attIt->first == entry &&
697 attIt->second->GetAttractorEntry() == attEntry )
699 bool attExists = (attIt != _classAttractors.end());
701 BLSURFPlugin_Attractor* myAttractor;
703 myAttractor = new BLSURFPlugin_Attractor(FaceShape, AttractorShape, attEntry);//, 0.1 );
704 _classAttractors.insert( make_pair( entry, myAttractor ));
707 myAttractor = attIt->second;
709 // if (!myAttractor->IsMapBuilt())
710 // myAttractor->BuildMap();
711 myAttractor->SetParameters(StartSize, EndSize, ActionRadius, ConstantRadius);
713 NotifySubMeshesHypothesisModification();
716 //=======================================================================
717 //function : SetConstantSizeOnAdjacentFaces
718 //=======================================================================
719 // TODO uncomment and test (include the needed .hxx)
720 // SetConstantSizeOnAdjacentFaces(myShape, att_entry, startSize, endSize = user_size, const_dist ) {
721 // TopTools_IndexedMapOfShapListOdShape anEdge2FaceMap;
722 // TopExp::MapShapesAnAncestors(myShape,TopAbs_EDGE, TopAbs_FACE, anEdge2FaceMap);
723 // TopTools_IndexedMapOfShapListOdShape::iterator it;
724 // for (it = anEdge2FaceMap.begin();it != anEdge2FaceMap.end();it++){
725 // SetClassAttractorEntry((*it).first, att_entry, startSize, endSize, 0, const_dist)
733 //=======================================================================
734 //function : GetClassAttractorEntry
735 //=======================================================================
736 // BLSURFPlugin_Attractor& BLSURFPlugin_Hypothesis::GetClassAttractorEntry(const std::string& entry)
738 // TAttractorMap::iterator it = _classAttractors.find( entry );
739 // if ( it != _classAttractors.end() )
740 // return it->second;
742 // return "No_Such_Entry";
746 * \brief Return the map of attractor instances
748 BLSURFPlugin_Hypothesis::TAttractorMap BLSURFPlugin_Hypothesis::GetClassAttractorEntries(const BLSURFPlugin_Hypothesis* hyp)
750 return hyp ? hyp->_GetClassAttractorEntries():GetDefaultAttractorMap();
753 //=======================================================================
754 //function : ClearEntry
755 //=======================================================================
756 void BLSURFPlugin_Hypothesis::ClearEntry(const std::string& entry,
757 const char * attEntry/*=0*/)
759 TSizeMap::iterator it = _sizeMap.find( entry );
761 if ( it != _sizeMap.end() ) {
763 NotifySubMeshesHypothesisModification();
766 TSizeMap::iterator itAt = _attractors.find( entry );
767 if ( itAt != _attractors.end() ) {
768 _attractors.erase(itAt);
769 NotifySubMeshesHypothesisModification();
772 TAttractorMap::iterator it_clAt = _classAttractors.find( entry );
773 if ( it_clAt != _classAttractors.end() ) {
775 if ( !attEntry || it_clAt->second->GetAttractorEntry() == attEntry )
776 _classAttractors.erase( it_clAt++ );
780 while ( it_clAt != _classAttractors.end() );
781 MESSAGE("_classAttractors.size() = "<<_classAttractors.size())
782 NotifySubMeshesHypothesisModification();
785 std::cout<<"No_Such_Entry"<<std::endl;
790 //=======================================================================
791 //function : ClearSizeMaps
792 //=======================================================================
793 void BLSURFPlugin_Hypothesis::ClearSizeMaps() {
796 _classAttractors.clear();
799 // Enable internal enforced vertices on specific face if requested by user
801 ////=======================================================================
802 ////function : SetInternalEnforcedVertex
803 ////=======================================================================
804 //void BLSURFPlugin_Hypothesis::SetInternalEnforcedVertex(TEntry theFaceEntry,
805 // bool toEnforceInternalVertices,
806 // TEnfGroupName theGroupName) {
808 // MESSAGE("BLSURFPlugin_Hypothesis::SetInternalEnforcedVertex("<< theFaceEntry << ", "
809 // << toEnforceInternalVertices << ", " << theGroupName << ")");
811 // TFaceEntryInternalVerticesList::iterator it = _faceEntryInternalVerticesList.find(theFaceEntry);
812 // if (it != _faceEntryInternalVerticesList.end()) {
813 // if (!toEnforceInternalVertices) {
814 // _faceEntryInternalVerticesList.erase(it);
818 // if (toEnforceInternalVertices) {
819 // _faceEntryInternalVerticesList.insert(theFaceEntry);
824 // // Take care of groups
828 //=======================================================================
829 //function : SetEnforcedVertex
830 //=======================================================================
831 bool BLSURFPlugin_Hypothesis::SetEnforcedVertex(TEntry theFaceEntry, TEnfName theVertexName, TEntry theVertexEntry,
832 TEnfGroupName theGroupName, double x, double y, double z) {
834 MESSAGE("BLSURFPlugin_Hypothesis::SetEnforcedVertex("<< theFaceEntry << ", "
835 << x << ", " << y << ", " << z << ", " << theVertexName << ", " << theVertexEntry << ", " << theGroupName << ")");
837 SetPhysicalMesh(PhysicalLocalSize);
839 // TEnfVertexList::iterator it;
840 bool toNotify = false;
841 bool toCreate = true;
843 TEnfVertex *oldEnVertex;
844 TEnfVertex *newEnfVertex = new TEnfVertex();
845 newEnfVertex->name = theVertexName;
846 newEnfVertex->geomEntry = theVertexEntry;
847 newEnfVertex->coords.clear();
848 if (theVertexEntry == "") {
849 newEnfVertex->coords.push_back(x);
850 newEnfVertex->coords.push_back(y);
851 newEnfVertex->coords.push_back(z);
853 newEnfVertex->grpName = theGroupName;
854 newEnfVertex->faceEntries.clear();
855 newEnfVertex->faceEntries.insert(theFaceEntry);
858 // update _enfVertexList
859 TEnfVertexList::iterator it = _enfVertexList.find(newEnfVertex);
860 if (it != _enfVertexList.end()) {
863 MESSAGE("Enforced Vertex was found => Update");
864 if (oldEnVertex->name != theVertexName) {
865 MESSAGE("Update name from \"" << oldEnVertex->name << "\" to \"" << theVertexName << "\"");
866 oldEnVertex->name = theVertexName;
869 if (oldEnVertex->grpName != theGroupName) {
870 MESSAGE("Update group name from \"" << oldEnVertex->grpName << "\" to \"" << theGroupName << "\"");
871 oldEnVertex->grpName = theGroupName;
874 TEntryList::iterator it_faceEntries = oldEnVertex->faceEntries.find(theFaceEntry);
875 if (it_faceEntries == oldEnVertex->faceEntries.end()) {
876 MESSAGE("Update face list by adding \"" << theFaceEntry << "\"");
877 oldEnVertex->faceEntries.insert(theFaceEntry);
878 _faceEntryEnfVertexListMap[theFaceEntry].insert(oldEnVertex);
882 // update map coords / enf vertex if needed
883 if (oldEnVertex->coords.size()) {
884 _coordsEnfVertexMap[oldEnVertex->coords] = oldEnVertex;
885 _faceEntryCoordsListMap[theFaceEntry].insert(oldEnVertex->coords);
888 // update map geom entry / enf vertex if needed
889 if (oldEnVertex->geomEntry != "") {
890 _enfVertexEntryEnfVertexMap[oldEnVertex->geomEntry] = oldEnVertex;
891 _faceEntryEnfVertexEntryListMap[theFaceEntry].insert(oldEnVertex->geomEntry);
896 // //////// CREATE ////////////
899 MESSAGE("Creating new enforced vertex");
900 _faceEntryEnfVertexListMap[theFaceEntry].insert(newEnfVertex);
901 _enfVertexList.insert(newEnfVertex);
902 if (theVertexEntry == "") {
903 _faceEntryCoordsListMap[theFaceEntry].insert(newEnfVertex->coords);
904 _coordsEnfVertexMap[newEnfVertex->coords] = newEnfVertex;
907 _faceEntryEnfVertexEntryListMap[theFaceEntry].insert(newEnfVertex->geomEntry);
908 _enfVertexEntryEnfVertexMap[newEnfVertex->geomEntry] = newEnfVertex;
913 NotifySubMeshesHypothesisModification();
915 MESSAGE("BLSURFPlugin_Hypothesis::SetEnforcedVertex END");
920 //=======================================================================
921 //function : GetEnforcedVertices
922 //=======================================================================
924 BLSURFPlugin_Hypothesis::TEnfVertexList BLSURFPlugin_Hypothesis::GetEnfVertexList(const TEntry& theFaceEntry)
925 throw (std::invalid_argument) {
927 if (_faceEntryEnfVertexListMap.count(theFaceEntry) > 0)
928 return _faceEntryEnfVertexListMap[theFaceEntry];
930 return GetDefaultEnfVertexList();
932 std::ostringstream msg;
933 msg << "No enforced vertex for face entry " << theFaceEntry;
934 throw std::invalid_argument(msg.str());
937 //=======================================================================
938 //function : GetEnfVertexCoordsList
939 //=======================================================================
941 BLSURFPlugin_Hypothesis::TEnfVertexCoordsList BLSURFPlugin_Hypothesis::GetEnfVertexCoordsList(
942 const TEntry& theFaceEntry) throw (std::invalid_argument) {
944 if (_faceEntryCoordsListMap.count(theFaceEntry) > 0)
945 return _faceEntryCoordsListMap[theFaceEntry];
947 std::ostringstream msg;
948 msg << "No enforced vertex coords for face entry " << theFaceEntry;
949 throw std::invalid_argument(msg.str());
952 //=======================================================================
953 //function : GetEnfVertexEntryList
954 //=======================================================================
956 BLSURFPlugin_Hypothesis::TEntryList BLSURFPlugin_Hypothesis::GetEnfVertexEntryList(const TEntry& theFaceEntry)
957 throw (std::invalid_argument) {
959 if (_faceEntryEnfVertexEntryListMap.count(theFaceEntry) > 0)
960 return _faceEntryEnfVertexEntryListMap[theFaceEntry];
962 std::ostringstream msg;
963 msg << "No enforced vertex entry for face entry " << theFaceEntry;
964 throw std::invalid_argument(msg.str());
967 //=======================================================================
968 //function : GetEnfVertex(TEnfVertexCoords coords)
969 //=======================================================================
971 BLSURFPlugin_Hypothesis::TEnfVertex* BLSURFPlugin_Hypothesis::GetEnfVertex(TEnfVertexCoords coords)
972 throw (std::invalid_argument) {
974 if (_coordsEnfVertexMap.count(coords) > 0)
975 return _coordsEnfVertexMap[coords];
977 std::ostringstream msg;
978 msg << "No enforced vertex with coords (" << coords[0] << ", " << coords[1] << ", " << coords[2] << ")";
979 throw std::invalid_argument(msg.str());
982 //=======================================================================
983 //function : GetEnfVertex(const TEntry& theEnfVertexEntry)
984 //=======================================================================
986 BLSURFPlugin_Hypothesis::TEnfVertex* BLSURFPlugin_Hypothesis::GetEnfVertex(const TEntry& theEnfVertexEntry)
987 throw (std::invalid_argument) {
989 if (_enfVertexEntryEnfVertexMap.count(theEnfVertexEntry) > 0)
990 return _enfVertexEntryEnfVertexMap[theEnfVertexEntry];
992 std::ostringstream msg;
993 msg << "No enforced vertex with entry " << theEnfVertexEntry;
994 throw std::invalid_argument(msg.str());
997 //Enable internal enforced vertices on specific face if requested by user
998 ////=======================================================================
999 ////function : GetInternalEnforcedVertex
1000 ////=======================================================================
1002 //bool BLSURFPlugin_Hypothesis::GetInternalEnforcedVertex(const TEntry& theFaceEntry)
1004 // if (_faceEntryInternalVerticesList.count(theFaceEntry) > 0)
1009 //=======================================================================
1010 //function : ClearEnforcedVertex
1011 //=======================================================================
1013 bool BLSURFPlugin_Hypothesis::ClearEnforcedVertex(const TEntry& theFaceEntry, double x, double y, double z,
1014 const TEntry& theVertexEntry) throw (std::invalid_argument) {
1016 bool toNotify = false;
1017 std::ostringstream msg;
1018 TEnfVertex *oldEnfVertex;
1019 TEnfVertexCoords coords;
1021 coords.push_back(x);
1022 coords.push_back(y);
1023 coords.push_back(z);
1025 // check that enf vertex with given enf vertex entry exists
1026 TEnfVertexEntryEnfVertexMap::iterator it_enfVertexEntry = _enfVertexEntryEnfVertexMap.find(theVertexEntry);
1027 if (it_enfVertexEntry != _enfVertexEntryEnfVertexMap.end()) {
1029 MESSAGE("Found enforced vertex with geom entry " << theVertexEntry);
1030 oldEnfVertex = it_enfVertexEntry->second;
1032 _enfVertexEntryEnfVertexMap.erase(it_enfVertexEntry);
1034 TEntryList& enfVertexEntryList = _faceEntryEnfVertexEntryListMap[theFaceEntry];
1035 enfVertexEntryList.erase(theVertexEntry);
1036 if (enfVertexEntryList.size() == 0)
1037 _faceEntryEnfVertexEntryListMap.erase(theFaceEntry);
1038 // TFaceEntryEnfVertexEntryListMap::iterator it_entry_entry = _faceEntryEnfVertexEntryListMap.find(theFaceEntry);
1039 // TEntryList::iterator it_entryList = it_entry_entry->second.find(theVertexEntry);
1040 // it_entry_entry->second.erase(it_entryList);
1041 // if (it_entry_entry->second.size() == 0)
1042 // _faceEntryEnfVertexEntryListMap.erase(it_entry_entry);
1045 MESSAGE("Enforced vertex with geom entry " << theVertexEntry << " not found");
1046 msg << "No enforced vertex with geom entry " << theVertexEntry;
1047 // check that enf vertex with given coords exists
1048 TCoordsEnfVertexMap::iterator it_coords_enf = _coordsEnfVertexMap.find(coords);
1049 if (it_coords_enf != _coordsEnfVertexMap.end()) {
1051 MESSAGE("Found enforced vertex with coords " << x << ", " << y << ", " << z);
1052 oldEnfVertex = it_coords_enf->second;
1054 _coordsEnfVertexMap.erase(it_coords_enf);
1056 TEnfVertexCoordsList& enfVertexCoordsList = _faceEntryCoordsListMap[theFaceEntry];
1057 enfVertexCoordsList.erase(coords);
1058 if (enfVertexCoordsList.size() == 0)
1059 _faceEntryCoordsListMap.erase(theFaceEntry);
1060 // TFaceEntryCoordsListMap::iterator it_entry_coords = _faceEntryCoordsListMap.find(theFaceEntry);
1061 // TEnfVertexCoordsList::iterator it_coordsList = it_entry_coords->second.find(coords);
1062 // it_entry_coords->second.erase(it_coordsList);
1063 // if (it_entry_coords->second.size() == 0)
1064 // _faceEntryCoordsListMap.erase(it_entry_coords);
1067 MESSAGE("Enforced vertex with coords " << x << ", " << y << ", " << z << " not found");
1069 msg << "No enforced vertex at " << x << ", " << y << ", " << z;
1070 throw std::invalid_argument(msg.str());
1074 MESSAGE("Remove enf vertex from _enfVertexList");
1076 // update _enfVertexList
1077 TEnfVertexList::iterator it = _enfVertexList.find(oldEnfVertex);
1078 if (it != _enfVertexList.end()) {
1079 (*it)->faceEntries.erase(theFaceEntry);
1080 if ((*it)->faceEntries.size() == 0){
1081 _enfVertexList.erase(it);
1087 // update _faceEntryEnfVertexListMap
1088 TEnfVertexList& currentEnfVertexList = _faceEntryEnfVertexListMap[theFaceEntry];
1089 currentEnfVertexList.erase(oldEnfVertex);
1091 if (currentEnfVertexList.size() == 0) {
1092 MESSAGE("Remove _faceEntryEnfVertexListMap[" << theFaceEntry <<"]");
1093 _faceEntryEnfVertexListMap.erase(theFaceEntry);
1098 NotifySubMeshesHypothesisModification();
1103 //=======================================================================
1104 //function : ClearEnforcedVertices
1105 //=======================================================================
1107 bool BLSURFPlugin_Hypothesis::ClearEnforcedVertices(const TEntry& theFaceEntry) throw (std::invalid_argument) {
1109 bool toNotify = false;
1110 TEnfVertex *oldEnfVertex;
1112 TFaceEntryCoordsListMap::iterator it_entry_coords = _faceEntryCoordsListMap.find(theFaceEntry);
1113 if (it_entry_coords != _faceEntryCoordsListMap.end()) {
1115 TEnfVertexCoordsList coordsList = it_entry_coords->second;
1116 TEnfVertexCoordsList::iterator it_coordsList = coordsList.begin();
1117 for (; it_coordsList != coordsList.end(); ++it_coordsList) {
1118 TEnfVertexCoords coords = (*it_coordsList);
1119 oldEnfVertex = _coordsEnfVertexMap[coords];
1120 _coordsEnfVertexMap.erase(coords);
1121 // update _enfVertexList
1122 TEnfVertexList::iterator it = _enfVertexList.find(oldEnfVertex);
1123 if (it != _enfVertexList.end()) {
1124 (*it)->faceEntries.erase(theFaceEntry);
1125 if ((*it)->faceEntries.size() == 0){
1126 _enfVertexList.erase(it);
1132 _faceEntryCoordsListMap.erase(it_entry_coords);
1133 _faceEntryEnfVertexListMap.erase(theFaceEntry);
1136 TFaceEntryEnfVertexEntryListMap::iterator it_entry_entry = _faceEntryEnfVertexEntryListMap.find(theFaceEntry);
1137 if (it_entry_entry != _faceEntryEnfVertexEntryListMap.end()) {
1139 TEntryList enfVertexEntryList = it_entry_entry->second;
1140 TEntryList::iterator it_enfVertexEntryList = enfVertexEntryList.begin();
1141 for (; it_enfVertexEntryList != enfVertexEntryList.end(); ++it_enfVertexEntryList) {
1142 TEntry enfVertexEntry = (*it_enfVertexEntryList);
1143 oldEnfVertex = _enfVertexEntryEnfVertexMap[enfVertexEntry];
1144 _enfVertexEntryEnfVertexMap.erase(enfVertexEntry);
1145 // update _enfVertexList
1146 TEnfVertexList::iterator it = _enfVertexList.find(oldEnfVertex);
1147 if (it != _enfVertexList.end()) {
1148 (*it)->faceEntries.erase(theFaceEntry);
1149 if ((*it)->faceEntries.size() == 0){
1150 _enfVertexList.erase(it);
1156 _faceEntryEnfVertexEntryListMap.erase(it_entry_entry);
1157 _faceEntryEnfVertexListMap.erase(theFaceEntry);
1161 NotifySubMeshesHypothesisModification();
1164 // std::ostringstream msg;
1165 // msg << "No enforced vertex for " << theFaceEntry;
1166 // throw std::invalid_argument(msg.str());
1169 //=======================================================================
1170 //function : ClearAllEnforcedVertices
1171 //=======================================================================
1172 void BLSURFPlugin_Hypothesis::ClearAllEnforcedVertices() {
1173 _faceEntryEnfVertexListMap.clear();
1174 _enfVertexList.clear();
1175 _faceEntryCoordsListMap.clear();
1176 _coordsEnfVertexMap.clear();
1177 _faceEntryEnfVertexEntryListMap.clear();
1178 _enfVertexEntryEnfVertexMap.clear();
1179 // Enable internal enforced vertices on specific face if requested by user
1180 // _faceEntryInternalVerticesList.clear();
1181 NotifySubMeshesHypothesisModification();
1184 //================================================================================
1186 * \brief Return the enforced vertices
1188 //================================================================================
1191 BLSURFPlugin_Hypothesis::TFaceEntryEnfVertexListMap BLSURFPlugin_Hypothesis::GetAllEnforcedVerticesByFace(
1192 const BLSURFPlugin_Hypothesis* hyp) {
1193 return hyp ? hyp->_GetAllEnforcedVerticesByFace() : GetDefaultFaceEntryEnfVertexListMap();
1196 //Enable internal enforced vertices on specific face if requested by user
1197 //BLSURFPlugin_Hypothesis::TFaceEntryInternalVerticesList BLSURFPlugin_Hypothesis::GetAllInternalEnforcedVerticesByFace(
1198 // const BLSURFPlugin_Hypothesis* hyp) {
1199 // return hyp ? hyp->_GetAllInternalEnforcedVerticesByFace() : GetDefaultFaceEntryInternalVerticesMap();
1202 bool BLSURFPlugin_Hypothesis::GetInternalEnforcedVertexAllFaces(const BLSURFPlugin_Hypothesis* hyp)
1204 return hyp ? hyp->_GetInternalEnforcedVertexAllFaces() : GetDefaultInternalEnforcedVertex();
1207 BLSURFPlugin_Hypothesis::TEnfGroupName BLSURFPlugin_Hypothesis::GetInternalEnforcedVertexAllFacesGroup(const BLSURFPlugin_Hypothesis* hyp)
1209 return hyp ? hyp->_GetInternalEnforcedVertexAllFacesGroup() : BLSURFPlugin_Hypothesis::TEnfGroupName();
1212 BLSURFPlugin_Hypothesis::TEnfVertexList BLSURFPlugin_Hypothesis::GetAllEnforcedVertices(
1213 const BLSURFPlugin_Hypothesis* hyp) {
1214 return hyp ? hyp->_GetAllEnforcedVertices() : GetDefaultEnfVertexList();
1217 BLSURFPlugin_Hypothesis::TFaceEntryCoordsListMap BLSURFPlugin_Hypothesis::GetAllCoordsByFace(
1218 const BLSURFPlugin_Hypothesis* hyp) {
1219 return hyp ? hyp->_GetAllCoordsByFace() : GetDefaultFaceEntryCoordsListMap();
1222 BLSURFPlugin_Hypothesis::TCoordsEnfVertexMap BLSURFPlugin_Hypothesis::GetAllEnforcedVerticesByCoords(
1223 const BLSURFPlugin_Hypothesis* hyp) {
1224 return hyp ? hyp->_GetAllEnforcedVerticesByCoords() : GetDefaultCoordsEnfVertexMap();
1227 BLSURFPlugin_Hypothesis::TFaceEntryEnfVertexEntryListMap BLSURFPlugin_Hypothesis::GetAllEnfVertexEntriesByFace(
1228 const BLSURFPlugin_Hypothesis* hyp) {
1229 return hyp ? hyp->_GetAllEnfVertexEntriesByFace() : GetDefaultFaceEntryEnfVertexEntryListMap();
1232 BLSURFPlugin_Hypothesis::TEnfVertexEntryEnfVertexMap BLSURFPlugin_Hypothesis::GetAllEnforcedVerticesByEnfVertexEntry(
1233 const BLSURFPlugin_Hypothesis* hyp) {
1234 return hyp ? hyp->_GetAllEnforcedVerticesByEnfVertexEntry() : GetDefaultEnfVertexEntryEnfVertexMap();
1237 std::set<int> BLSURFPlugin_Hypothesis::GetEnfVertexNodeIDs(TEnfGroupName theGroupName) throw (std::invalid_argument)
1239 TGroupNameNodeIDMap::const_iterator it = _groupNameNodeIDMap.find(theGroupName);
1240 if (it != _groupNameNodeIDMap.end()) {
1243 std::ostringstream msg;
1244 msg << "No group " << theGroupName;
1245 throw std::invalid_argument(msg.str());
1248 void BLSURFPlugin_Hypothesis::AddEnfVertexNodeID(TEnfGroupName theGroupName,int theNodeID)
1250 _groupNameNodeIDMap[theGroupName].insert(theNodeID);
1253 void BLSURFPlugin_Hypothesis::RemoveEnfVertexNodeID(TEnfGroupName theGroupName,int theNodeID) throw (std::invalid_argument)
1255 TGroupNameNodeIDMap::iterator it = _groupNameNodeIDMap.find(theGroupName);
1256 if (it != _groupNameNodeIDMap.end()) {
1257 std::set<int>::iterator IDit = it->second.find(theNodeID);
1258 if (IDit != it->second.end())
1259 it->second.erase(IDit);
1260 std::ostringstream msg;
1261 msg << "No node IDs " << theNodeID << " for group " << theGroupName;
1262 throw std::invalid_argument(msg.str());
1264 std::ostringstream msg;
1265 msg << "No group " << theGroupName;
1266 throw std::invalid_argument(msg.str());
1270 //=============================================================================
1271 void BLSURFPlugin_Hypothesis::SetInternalEnforcedVertexAllFaces(bool toEnforceInternalVertices) {
1272 if (toEnforceInternalVertices != _enforcedInternalVerticesAllFaces) {
1273 _enforcedInternalVerticesAllFaces = toEnforceInternalVertices;
1274 if (toEnforceInternalVertices)
1275 SetPhysicalMesh(PhysicalLocalSize);
1276 NotifySubMeshesHypothesisModification();
1281 //=============================================================================
1282 void BLSURFPlugin_Hypothesis::SetInternalEnforcedVertexAllFacesGroup(BLSURFPlugin_Hypothesis::TEnfGroupName theGroupName) {
1283 if (std::string(theGroupName) != std::string(_enforcedInternalVerticesAllFacesGroup)) {
1284 _enforcedInternalVerticesAllFacesGroup = theGroupName;
1285 NotifySubMeshesHypothesisModification();
1289 //=============================================================================
1290 BLSURFPlugin_Hypothesis::TPreCadPeriodicityVector BLSURFPlugin_Hypothesis::GetPreCadFacesPeriodicityVector(
1291 const BLSURFPlugin_Hypothesis* hyp) {
1292 return hyp ? hyp->_GetPreCadFacesPeriodicityVector() : GetDefaultPreCadFacesPeriodicityVector();
1295 //=============================================================================
1296 BLSURFPlugin_Hypothesis::TPreCadPeriodicityVector BLSURFPlugin_Hypothesis::GetPreCadEdgesPeriodicityVector(
1297 const BLSURFPlugin_Hypothesis* hyp) {
1298 return hyp ? hyp->_GetPreCadEdgesPeriodicityVector() : GetDefaultPreCadEdgesPeriodicityVector();
1301 //=============================================================================
1302 BLSURFPlugin_Hypothesis::TFacesPeriodicityVector BLSURFPlugin_Hypothesis::GetFacesPeriodicityVector(
1303 const BLSURFPlugin_Hypothesis* hyp) {
1304 return hyp ? hyp->_GetFacesPeriodicityVector() : GetDefaultFacesPeriodicityVector();
1307 //=============================================================================
1308 BLSURFPlugin_Hypothesis::TEdgesPeriodicityVector BLSURFPlugin_Hypothesis::GetEdgesPeriodicityVector(
1309 const BLSURFPlugin_Hypothesis* hyp){
1310 return hyp ? hyp->_GetEdgesPeriodicityVector() : GetDefaultEdgesPeriodicityVector();
1313 //=============================================================================
1314 BLSURFPlugin_Hypothesis::TVerticesPeriodicityVector BLSURFPlugin_Hypothesis::GetVerticesPeriodicityVector(
1315 const BLSURFPlugin_Hypothesis* hyp){
1316 return hyp ? hyp->_GetVerticesPeriodicityVector() : GetDefaultVerticesPeriodicityVector();
1319 //=======================================================================
1320 //function : ClearAllEnforcedVertices
1321 //=======================================================================
1322 void BLSURFPlugin_Hypothesis::ClearPreCadPeriodicityVectors() {
1323 _preCadFacesPeriodicityVector.clear();
1324 _preCadEdgesPeriodicityVector.clear();
1325 NotifySubMeshesHypothesisModification();
1328 //=======================================================================
1329 //function : AddPreCadFacesPeriodicity
1330 //=======================================================================
1331 void BLSURFPlugin_Hypothesis::AddPreCadFacesPeriodicity(TEntry theFace1Entry, TEntry theFace2Entry,
1332 std::vector<std::string> &theSourceVerticesEntries, std::vector<std::string> &theTargetVerticesEntries) {
1334 TPreCadPeriodicity preCadFacesPeriodicity;
1335 preCadFacesPeriodicity.shape1Entry = theFace1Entry;
1336 preCadFacesPeriodicity.shape2Entry = theFace2Entry;
1337 preCadFacesPeriodicity.theSourceVerticesEntries = theSourceVerticesEntries;
1338 preCadFacesPeriodicity.theTargetVerticesEntries = theTargetVerticesEntries;
1340 _preCadFacesPeriodicityVector.push_back(preCadFacesPeriodicity);
1342 NotifySubMeshesHypothesisModification();
1345 //=======================================================================
1346 //function : AddPreCadEdgesPeriodicity
1347 //=======================================================================
1348 void BLSURFPlugin_Hypothesis::AddPreCadEdgesPeriodicity(TEntry theEdge1Entry, TEntry theEdge2Entry,
1349 std::vector<std::string> &theSourceVerticesEntries, std::vector<std::string> &theTargetVerticesEntries) {
1351 TPreCadPeriodicity preCadEdgesPeriodicity;
1352 preCadEdgesPeriodicity.shape1Entry = theEdge1Entry;
1353 preCadEdgesPeriodicity.shape2Entry = theEdge2Entry;
1354 preCadEdgesPeriodicity.theSourceVerticesEntries = theSourceVerticesEntries;
1355 preCadEdgesPeriodicity.theTargetVerticesEntries = theTargetVerticesEntries;
1357 _preCadEdgesPeriodicityVector.push_back(preCadEdgesPeriodicity);
1359 NotifySubMeshesHypothesisModification();
1362 //=======================================================================
1363 //function : AddFacePeriodicity
1364 //=======================================================================
1365 void BLSURFPlugin_Hypothesis::AddFacePeriodicity(TEntry theFace1Entry, TEntry theFace2Entry) {
1367 std::pair< TEntry, TEntry > pairOfFacesEntries = std::make_pair(theFace1Entry, theFace2Entry);
1369 _facesPeriodicityVector.push_back(pairOfFacesEntries);
1371 // Removed for performance reason since AddFacePeriodicity is called multiple times (one time for each face)
1372 // Does not affect the behaviour since it is only called via python, not via GUI.
1373 //NotifySubMeshesHypothesisModification();
1377 //=======================================================================
1378 //function : AddEdgePeriodicity
1379 //=======================================================================
1380 void BLSURFPlugin_Hypothesis::AddEdgePeriodicity(TEntry theFace1Entry, TEntry theEdge1Entry, TEntry theFace2Entry, TEntry theEdge2Entry, int edge_orientation) {
1382 TEdgePeriodicity edgePeriodicity;
1383 edgePeriodicity.theFace1Entry = theFace1Entry;
1384 edgePeriodicity.theEdge1Entry = theEdge1Entry;
1385 edgePeriodicity.theFace2Entry = theFace2Entry;
1386 edgePeriodicity.theEdge2Entry = theEdge2Entry;
1387 edgePeriodicity.edge_orientation = edge_orientation;
1389 _edgesPeriodicityVector.push_back(edgePeriodicity);
1391 // Removed for performance reason since AddEdgePeriodicity is called multiple times (one time for each edge)
1392 // Does not affect the behaviour since it is only called via python, not via GUI.
1393 //NotifySubMeshesHypothesisModification();
1396 //=======================================================================
1397 //function : AddVertexPeriodicity
1398 //=======================================================================
1399 void BLSURFPlugin_Hypothesis::AddVertexPeriodicity(TEntry theEdge1Entry, TEntry theVertex1Entry, TEntry theEdge2Entry, TEntry theVertex2Entry) {
1401 TVertexPeriodicity vertexPeriodicity;
1402 vertexPeriodicity.theEdge1Entry = theEdge1Entry;
1403 vertexPeriodicity.theVertex1Entry = theVertex1Entry;
1404 vertexPeriodicity.theEdge2Entry = theEdge2Entry;
1405 vertexPeriodicity.theVertex2Entry = theVertex2Entry;
1407 _verticesPeriodicityVector.push_back(vertexPeriodicity);
1409 // Removed for performance reason since AddVertexPeriodicity is called multiple times (one time for each vertex)
1410 // Does not affect the behaviour since it is only called via python, not via GUI.
1411 //NotifySubMeshesHypothesisModification();
1414 //=============================================================================
1415 std::ostream & BLSURFPlugin_Hypothesis::SaveTo(std::ostream & save) {
1416 // We must keep at least the same number of arguments when increasing the SALOME version
1417 // When MG-CADSurf becomes CADMESH, some parameters were fused into a single one. Thus the same
1418 // parameter can be written several times to keep the old global number of parameters.
1420 // Treat old options which are now in the advanced options
1421 TOptionValues::iterator op_val;
1423 int _preCADRemoveNanoEdges = -1;
1424 double _preCADEpsNano = -1.0;
1425 op_val = _option2value.find("respect_geometry");
1426 if (op_val != _option2value.end()) {
1427 std::string value = op_val->second;
1429 _decimesh = value.compare("1") == 0 ? 1 : 0;
1431 op_val = _preCADoption2value.find("remove_tiny_edges");
1432 if (op_val != _preCADoption2value.end()) {
1433 std::string value = op_val->second;
1435 _preCADRemoveNanoEdges = value.compare("1") == 0 ? 1 : 0;
1437 op_val = _preCADoption2value.find("tiny_edge_length");
1438 if (op_val != _preCADoption2value.end()) {
1439 std::string value = op_val->second;
1441 _preCADEpsNano = strtod(value.c_str(), NULL);
1444 save << " " << (int) _topology << " " << (int) _physicalMesh << " " << (int) _geometricMesh << " " << _phySize << " "
1445 << _angleMesh << " " << _gradation << " " << (int) _quadAllowed << " " << _decimesh;
1446 save << " " << _minSize << " " << _maxSize << " " << _angleMesh << " " << _minSize << " " << _maxSize << " " << _verb;
1447 save << " " << (int) _preCADMergeEdges << " " << _preCADRemoveNanoEdges << " " << (int) _preCADDiscardInput << " " << _preCADEpsNano ;
1448 save << " " << (int) _enforcedInternalVerticesAllFaces;
1449 save << " " << (int) _phySizeRel << " " << (int) _minSizeRel << " " << (int) _maxSizeRel << " " << _chordalError ;
1450 save << " " << (int) _anisotropic << " " << _anisotropicRatio << " " << (int) _removeTinyEdges << " " << _tinyEdgeLength ;
1451 save << " " << (int) _badElementRemoval << " " << _badElementAspectRatio << " " << (int) _optimizeMesh << " " << (int) _quadraticMesh ;
1452 save << " " << (int) _preCADProcess3DTopology;
1454 op_val = _option2value.begin();
1455 if (op_val != _option2value.end()) {
1456 save << " " << "__OPTIONS_BEGIN__";
1457 for (; op_val != _option2value.end(); ++op_val) {
1458 if (!op_val->second.empty())
1459 save << " " << op_val->first << " " << op_val->second << "%#"; // "%#" is a mark of value end
1461 save << " " << "__OPTIONS_END__";
1464 op_val = _customOption2value.begin();
1465 if (op_val != _customOption2value.end()) {
1466 save << " " << "__CUSTOM_OPTIONS_BEGIN__";
1467 for (; op_val != _customOption2value.end(); ++op_val) {
1468 if (!op_val->second.empty())
1469 save << " " << op_val->first << " " << op_val->second << "%#"; // "%#" is a mark of value end
1471 save << " " << "__CUSTOM_OPTIONS_END__";
1474 op_val = _preCADoption2value.begin();
1475 if (op_val != _preCADoption2value.end()) {
1476 save << " " << "__PRECAD_OPTIONS_BEGIN__";
1477 for (; op_val != _preCADoption2value.end(); ++op_val) {
1478 if (!op_val->second.empty())
1479 save << " " << op_val->first << " " << op_val->second << "%#"; // "%#" is a mark of value end
1481 save << " " << "__PRECAD_OPTIONS_END__";
1484 op_val = _customPreCADOption2value.begin();
1485 if (op_val != _customPreCADOption2value.end()) {
1486 save << " " << "__CUSTOM_PRECAD_OPTIONS_BEGIN__";
1487 for (; op_val != _customPreCADOption2value.end(); ++op_val) {
1488 if (!op_val->second.empty())
1489 save << " " << op_val->first << " " << op_val->second << "%#"; // "%#" is a mark of value end
1491 save << " " << "__CUSTOM_PRECAD_OPTIONS_END__";
1494 TSizeMap::iterator it_sm = _sizeMap.begin();
1495 if (it_sm != _sizeMap.end()) {
1496 save << " " << "__SIZEMAP_BEGIN__";
1497 for (; it_sm != _sizeMap.end(); ++it_sm) {
1498 save << " " << it_sm->first << " " << it_sm->second << "%#"; // "%#" is a mark of value end
1500 save << " " << "__SIZEMAP_END__";
1503 TSizeMap::iterator it_at = _attractors.begin();
1504 if (it_at != _attractors.end()) {
1505 save << " " << "__ATTRACTORS_BEGIN__";
1506 for (; it_at != _attractors.end(); ++it_at) {
1507 save << " " << it_at->first << " " << it_at->second << "%#"; // "%#" is a mark of value end
1509 save << " " << "__ATTRACTORS_END__";
1512 TAttractorMap::iterator it_At = _classAttractors.begin();
1513 if (it_At != _classAttractors.end()) {
1514 std::ostringstream test;
1515 save << " " << "__NEW_ATTRACTORS_BEGIN__";
1516 test << " " << "__NEW_ATTRACTORS_BEGIN__";
1517 for (; it_At != _classAttractors.end(); ++it_At) {
1518 std::vector<double> attParams;
1519 attParams = it_At->second->GetParameters();
1520 // double step = it_At->second->GetStep();
1521 save << " " << it_At->first;
1522 save << " " << it_At->second->GetAttractorEntry();
1523 save << " " << attParams[0] << " " << attParams[1] << " " << attParams[2] << " " << attParams[3];
1524 // save << " " << step;
1525 test << " " << it_At->first;
1526 test << " " << it_At->second->GetAttractorEntry();
1527 test << " " << attParams[0] << " " << attParams[1] << " " << attParams[2] << " " << attParams[3];
1528 // test << " " << step;
1530 save << " " << "__NEW_ATTRACTORS_END__";
1531 test << " " << "__NEW_ATTRACTORS_END__";
1532 MESSAGE(" Attractor hypothesis saved as "<<test.str())
1535 TEnfVertexList::const_iterator it_enf = _enfVertexList.begin();
1536 if (it_enf != _enfVertexList.end()) {
1537 save << " " << "__ENFORCED_VERTICES_BEGIN__";
1538 for (; it_enf != _enfVertexList.end(); ++it_enf) {
1539 TEnfVertex *enfVertex = (*it_enf);
1540 save << " " << "__BEGIN_VERTEX__";
1541 if (!enfVertex->name.empty()) {
1542 save << " " << "__BEGIN_NAME__";
1543 save << " " << enfVertex->name;
1544 save << " " << "__END_NAME__";
1546 if (!enfVertex->geomEntry.empty()) {
1547 save << " " << "__BEGIN_ENTRY__";
1548 save << " " << enfVertex->geomEntry;
1549 save << " " << "__END_ENTRY__";
1551 if (!enfVertex->grpName.empty()) {
1552 save << " " << "__BEGIN_GROUP__";
1553 save << " " << enfVertex->grpName;
1554 save << " " << "__END_GROUP__";
1556 if (enfVertex->coords.size()) {
1557 save << " " << "__BEGIN_COORDS__";
1558 for ( size_t i = 0; i < enfVertex->coords.size(); i++ )
1559 save << " " << enfVertex->coords[i];
1560 save << " " << "__END_COORDS__";
1562 TEntryList::const_iterator faceEntriesIt = enfVertex->faceEntries.begin();
1563 bool hasFaces = false;
1564 if (faceEntriesIt != enfVertex->faceEntries.end()) {
1566 save << " " << "__BEGIN_FACELIST__";
1568 for (; faceEntriesIt != enfVertex->faceEntries.end(); ++faceEntriesIt)
1569 save << " " << (*faceEntriesIt);
1571 save << " " << "__END_FACELIST__";
1572 save << " " << "__END_VERTEX__";
1574 save << " " << "__ENFORCED_VERTICES_END__";
1579 SavePreCADPeriodicity(save, "FACES");
1580 SavePreCADPeriodicity(save, "EDGES");
1582 SaveFacesPeriodicity(save);
1583 SaveEdgesPeriodicity(save);
1584 SaveVerticesPeriodicity(save);
1589 void BLSURFPlugin_Hypothesis::SaveFacesPeriodicity(std::ostream & save){
1591 TFacesPeriodicityVector::const_iterator it_faces_periodicity = _facesPeriodicityVector.begin();
1592 if (it_faces_periodicity != _facesPeriodicityVector.end()) {
1593 MESSAGE("__FACES_PERIODICITY_BEGIN__");
1594 save << " " << "__FACES_PERIODICITY_BEGIN__";
1595 for (; it_faces_periodicity != _facesPeriodicityVector.end(); ++it_faces_periodicity) {
1596 TFacesPeriodicity periodicity_i = (*it_faces_periodicity);
1597 save << " " << "__BEGIN_PERIODICITY_DESCRIPTION__";
1598 save << " " << "__BEGIN_ENTRY1__";
1599 save << " " << periodicity_i.first;
1600 save << " " << "__END_ENTRY1__";
1601 save << " " << "__BEGIN_ENTRY2__";
1602 save << " " << periodicity_i.second;
1603 save << " " << "__END_ENTRY2__";
1604 save << " " << "__END_PERIODICITY_DESCRIPTION__";
1606 save << " " << "__FACES_PERIODICITY_END__";
1607 MESSAGE("__FACES_PERIODICITY_END__");
1611 void BLSURFPlugin_Hypothesis::SaveEdgesPeriodicity(std::ostream & save){
1613 TEdgesPeriodicityVector::const_iterator it_edges_periodicity = _edgesPeriodicityVector.begin();
1614 if (it_edges_periodicity != _edgesPeriodicityVector.end()) {
1615 save << " " << "__EDGES_PERIODICITY_BEGIN__";
1616 MESSAGE("__EDGES_PERIODICITY_BEGIN__");
1617 for (; it_edges_periodicity != _edgesPeriodicityVector.end(); ++it_edges_periodicity) {
1618 TEdgePeriodicity periodicity_i = (*it_edges_periodicity);
1619 save << " " << "__BEGIN_PERIODICITY_DESCRIPTION__";
1620 if (! periodicity_i.theFace1Entry.empty()){
1621 save << " " << "__BEGIN_FACE1__";
1622 save << " " << periodicity_i.theFace1Entry;
1623 save << " " << "__END_FACE1__";
1625 save << " " << "__BEGIN_EDGE1__";
1626 save << " " << periodicity_i.theEdge1Entry;
1627 save << " " << "__END_EDGE1__";
1628 if (! periodicity_i.theFace2Entry.empty()){
1629 save << " " << "__BEGIN_FACE2__";
1630 save << " " << periodicity_i.theFace2Entry;
1631 save << " " << "__END_FACE2__";
1633 save << " " << "__BEGIN_EDGE2__";
1634 save << " " << periodicity_i.theEdge2Entry;
1635 save << " " << "__END_EDGE2__";
1636 save << " " << "__BEGIN_EDGE_ORIENTATION__";
1637 save << " " << periodicity_i.edge_orientation;
1638 save << " " << "__END_EDGE_ORIENTATION__";
1639 save << " " << "__END_PERIODICITY_DESCRIPTION__";
1641 save << " " << "__EDGES_PERIODICITY_END__";
1642 MESSAGE("__EDGES_PERIODICITY_END__");
1646 void BLSURFPlugin_Hypothesis::SaveVerticesPeriodicity(std::ostream & save){
1648 TVerticesPeriodicityVector::const_iterator it_vertices_periodicity = _verticesPeriodicityVector.begin();
1649 if (it_vertices_periodicity != _verticesPeriodicityVector.end()) {
1650 MESSAGE("__VERTICES_PERIODICITY_BEGIN__");
1651 save << " " << "__VERTICES_PERIODICITY_BEGIN__";
1652 for (; it_vertices_periodicity != _verticesPeriodicityVector.end(); ++it_vertices_periodicity) {
1653 TVertexPeriodicity periodicity_i = (*it_vertices_periodicity);
1654 save << " " << "__BEGIN_PERIODICITY_DESCRIPTION__";
1655 save << " " << "__BEGIN_EDGE1__";
1656 save << " " << periodicity_i.theEdge1Entry;
1657 save << " " << "__END_EDGE1__";
1658 save << " " << "__BEGIN_VERTEX1__";
1659 save << " " << periodicity_i.theVertex1Entry;
1660 save << " " << "__END_VERTEX1__";
1661 save << " " << "__BEGIN_EDGE2__";
1662 save << " " << periodicity_i.theEdge2Entry;
1663 save << " " << "__END_EDGE2__";
1664 save << " " << "__BEGIN_VERTEX2__";
1665 save << " " << periodicity_i.theVertex2Entry;
1666 save << " " << "__END_VERTEX2__";
1667 save << " " << "__END_PERIODICITY_DESCRIPTION__";
1669 save << " " << "__VERTICES_PERIODICITY_END__";
1670 MESSAGE("__VERTICES_PERIODICITY_END__");
1674 void BLSURFPlugin_Hypothesis::SavePreCADPeriodicity(std::ostream & save, const char* shapeType) {
1675 TPreCadPeriodicityVector precad_periodicity;
1676 if ( shapeType && strcmp( shapeType, "FACES" ) == 0 )
1677 precad_periodicity = _preCadFacesPeriodicityVector;
1679 precad_periodicity = _preCadEdgesPeriodicityVector;
1680 TPreCadPeriodicityVector::const_iterator it_precad_periodicity = precad_periodicity.begin();
1681 if (it_precad_periodicity != precad_periodicity.end()) {
1682 save << " " << "__PRECAD_" << shapeType << "_PERIODICITY_BEGIN__";
1683 for (; it_precad_periodicity != precad_periodicity.end(); ++it_precad_periodicity) {
1684 TPreCadPeriodicity periodicity_i = (*it_precad_periodicity);
1685 save << " " << "__BEGIN_PERIODICITY_DESCRIPTION__";
1686 if (!periodicity_i.shape1Entry.empty()) {
1687 save << " " << "__BEGIN_ENTRY1__";
1688 save << " " << periodicity_i.shape1Entry;
1689 save << " " << "__END_ENTRY1__";
1691 if (!periodicity_i.shape2Entry.empty()) {
1692 save << " " << "__BEGIN_ENTRY2__";
1693 save << " " << periodicity_i.shape2Entry;
1694 save << " " << "__END_ENTRY2__";
1697 std::vector<std::string>::const_iterator sourceVerticesEntriesIt = periodicity_i.theSourceVerticesEntries.begin();
1698 bool hasSourceVertices = false;
1699 if (sourceVerticesEntriesIt != periodicity_i.theSourceVerticesEntries.end()) {
1700 hasSourceVertices = true;
1701 save << " " << "__BEGIN_SOURCE_VERTICES_LIST__";
1703 for (; sourceVerticesEntriesIt != periodicity_i.theSourceVerticesEntries.end(); ++sourceVerticesEntriesIt)
1704 save << " " << (*sourceVerticesEntriesIt);
1705 if (hasSourceVertices)
1706 save << " " << "__END_SOURCE_VERTICES_LIST__";
1708 std::vector<std::string>::const_iterator targetVerticesEntriesIt = periodicity_i.theTargetVerticesEntries.begin();
1709 bool hasTargetVertices = false;
1710 if (targetVerticesEntriesIt != periodicity_i.theTargetVerticesEntries.end()) {
1711 hasTargetVertices = true;
1712 save << " " << "__BEGIN_TARGET_VERTICES_LIST__";
1714 for (; targetVerticesEntriesIt != periodicity_i.theTargetVerticesEntries.end(); ++targetVerticesEntriesIt)
1715 save << " " << (*targetVerticesEntriesIt);
1716 if (hasTargetVertices)
1717 save << " " << "__END_TARGET_VERTICES_LIST__";
1719 save << " " << "__END_PERIODICITY_DESCRIPTION__";
1721 save << " " << "__PRECAD_" << shapeType << "_PERIODICITY_END__";
1726 //=============================================================================
1727 std::istream & BLSURFPlugin_Hypothesis::LoadFrom(std::istream & load) {
1731 std::string option_or_sm;
1733 isOK = static_cast<bool>(load >> i);
1735 _topology = (Topology) i;
1737 load.clear(std::ios::badbit | load.rdstate());
1739 isOK = static_cast<bool>(load >> i);
1741 _physicalMesh = (PhysicalMesh) i;
1743 load.clear(std::ios::badbit | load.rdstate());
1745 isOK = static_cast<bool>(load >> i);
1747 _geometricMesh = (GeometricMesh) i;
1749 load.clear(std::ios::badbit | load.rdstate());
1751 isOK = static_cast<bool>(load >> val);
1755 load.clear(std::ios::badbit | load.rdstate());
1757 isOK = static_cast<bool>(load >> val);
1761 load.clear(std::ios::badbit | load.rdstate());
1763 isOK = static_cast<bool>(load >> val);
1767 load.clear(std::ios::badbit | load.rdstate());
1769 isOK = static_cast<bool>(load >> i);
1771 _quadAllowed = (bool) i;
1773 load.clear(std::ios::badbit | load.rdstate());
1775 isOK = static_cast<bool>(load >> i);
1777 if ( i != -1) { // if value is -1, then this is no longer a standard option
1778 std::string & value = _option2value["respect_geometry"];
1779 bool _decimesh = (bool) i;
1780 value = _decimesh ? "1" : "0";
1784 load.clear(std::ios::badbit | load.rdstate());
1786 isOK = static_cast<bool>(load >> val);
1790 load.clear(std::ios::badbit | load.rdstate());
1792 isOK = static_cast<bool>(load >> val);
1796 load.clear(std::ios::badbit | load.rdstate());
1798 isOK = static_cast<bool>(load >> val);
1800 // former parameter: get min value
1801 _angleMesh = std::min(val,_angleMesh);
1803 load.clear(std::ios::badbit | load.rdstate());
1805 isOK = static_cast<bool>(load >> val);
1807 // former parameter: get min value
1808 _minSize = std::min(val,_minSize);
1810 load.clear(std::ios::badbit | load.rdstate());
1812 isOK = static_cast<bool>(load >> val);
1814 // former parameter: get max value
1815 _maxSize = std::max(val,_maxSize);
1817 load.clear(std::ios::badbit | load.rdstate());
1819 isOK = static_cast<bool>(load >> i);
1823 load.clear(std::ios::badbit | load.rdstate());
1825 isOK = static_cast<bool>(load >> i);
1827 _preCADMergeEdges = (bool) i;
1829 load.clear(std::ios::badbit | load.rdstate());
1831 isOK = static_cast<bool>(load >> i);
1833 if ( i != -1) { // if value is -1, then this is no longer a standard option
1834 std::string & value = _preCADoption2value["remove_tiny_edges"];
1835 bool _preCADRemoveNanoEdges = (bool) i;
1836 value = _preCADRemoveNanoEdges ? "1" : "0";
1840 load.clear(std::ios::badbit | load.rdstate());
1842 isOK = static_cast<bool>(load >> i);
1844 _preCADDiscardInput = (bool) i;
1846 load.clear(std::ios::badbit | load.rdstate());
1848 isOK = static_cast<bool>(load >> val);
1849 if (isOK) { // _preCADEpsNano
1850 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
1851 std::string & value = _preCADoption2value["tiny_edge_length"];
1852 std::ostringstream oss;
1858 load.clear(std::ios::badbit | load.rdstate());
1860 isOK = static_cast<bool>(load >> i);
1862 _enforcedInternalVerticesAllFaces = (bool) i;
1864 load.clear(std::ios::badbit | load.rdstate());
1866 // New options with MeshGems-CADSurf
1868 bool hasCADSurfOptions = false;
1869 bool hasOptions = false;
1870 bool hasCustomOptions = false;
1871 bool hasPreCADOptions = false;
1872 bool hasCustomPreCADOptions = false;
1873 bool hasSizeMap = false;
1874 bool hasAttractor = false;
1875 bool hasNewAttractor = false;
1876 bool hasEnforcedVertex = false;
1877 bool hasPreCADFacesPeriodicity = false;
1878 bool hasPreCADEdgesPeriodicity = false;
1879 bool hasFacesPeriodicity = false;
1880 bool hasEdgesPeriodicity = false;
1881 bool hasVerticesPeriodicity = false;
1883 isOK = static_cast<bool>(load >> option_or_sm);
1885 if ( (option_or_sm == "1")||(option_or_sm == "0") ) {
1886 i = atoi(option_or_sm.c_str());
1887 hasCADSurfOptions = true;
1888 _phySizeRel = (bool) i;
1890 if (option_or_sm == "__OPTIONS_BEGIN__")
1892 else if (option_or_sm == "__CUSTOM_OPTIONS_BEGIN__")
1893 hasCustomOptions = true;
1894 else if (option_or_sm == "__PRECAD_OPTIONS_BEGIN__")
1895 hasPreCADOptions = true;
1896 else if (option_or_sm == "__CUSTOM_PRECAD_OPTIONS_BEGIN__")
1897 hasCustomPreCADOptions = true;
1898 else if (option_or_sm == "__SIZEMAP_BEGIN__")
1900 else if (option_or_sm == "__ATTRACTORS_BEGIN__")
1901 hasAttractor = true;
1902 else if (option_or_sm == "__NEW_ATTRACTORS_BEGIN__")
1903 hasNewAttractor = true;
1904 else if (option_or_sm == "__ENFORCED_VERTICES_BEGIN__")
1905 hasEnforcedVertex = true;
1906 else if (option_or_sm == "__PRECAD_FACES_PERIODICITY_BEGIN__")
1907 hasPreCADFacesPeriodicity = true;
1908 else if (option_or_sm == "__PRECAD_EDGES_PERIODICITY_BEGIN__")
1909 hasPreCADEdgesPeriodicity = true;
1910 else if (option_or_sm == "__FACES_PERIODICITY_BEGIN__")
1911 hasFacesPeriodicity = true;
1912 else if (option_or_sm == "__EDGES_PERIODICITY_BEGIN__")
1913 hasEdgesPeriodicity = true;
1914 else if (option_or_sm == "__VERTICES_PERIODICITY_BEGIN__")
1915 hasVerticesPeriodicity = true;
1917 if (isOK && hasCADSurfOptions) {
1918 isOK = static_cast<bool>(load >> i);
1920 _minSizeRel = (bool) i;
1922 load.clear(std::ios::badbit | load.rdstate());
1924 isOK = static_cast<bool>(load >> i);
1926 _maxSizeRel = (bool) i;
1928 load.clear(std::ios::badbit | load.rdstate());
1930 isOK = static_cast<bool>(load >> val);
1932 _chordalError = val;
1934 load.clear(std::ios::badbit | load.rdstate());
1936 isOK = static_cast<bool>(load >> i);
1938 _anisotropic = (bool) i;
1940 load.clear(std::ios::badbit | load.rdstate());
1942 isOK = static_cast<bool>(load >> val);
1944 _anisotropicRatio = val;
1946 load.clear(std::ios::badbit | load.rdstate());
1948 isOK = static_cast<bool>(load >> i);
1950 _removeTinyEdges = (bool) i;
1952 load.clear(std::ios::badbit | load.rdstate());
1954 isOK = static_cast<bool>(load >> val);
1956 _tinyEdgeLength = val;
1958 load.clear(std::ios::badbit | load.rdstate());
1960 isOK = static_cast<bool>(load >> i);
1962 _badElementRemoval = (bool) i;
1964 load.clear(std::ios::badbit | load.rdstate());
1966 isOK = static_cast<bool>(load >> val);
1968 _badElementAspectRatio = val;
1970 load.clear(std::ios::badbit | load.rdstate());
1972 isOK = static_cast<bool>(load >> i);
1974 _optimizeMesh = (bool) i;
1976 load.clear(std::ios::badbit | load.rdstate());
1978 isOK = static_cast<bool>(load >> i);
1980 _quadraticMesh = (bool) i;
1982 load.clear(std::ios::badbit | load.rdstate());
1984 isOK = static_cast<bool>(load >> i);
1986 _preCADProcess3DTopology = (bool) i;
1988 load.clear(std::ios::badbit | load.rdstate());
1993 if (hasCADSurfOptions) {
1994 isOK = static_cast<bool>(load >> option_or_sm);
1996 if (option_or_sm == "__OPTIONS_BEGIN__")
1998 else if (option_or_sm == "__CUSTOM_OPTIONS_BEGIN__")
1999 hasCustomOptions = true;
2000 else if (option_or_sm == "__PRECAD_OPTIONS_BEGIN__")
2001 hasPreCADOptions = true;
2002 else if (option_or_sm == "__CUSTOM_PRECAD_OPTIONS_BEGIN__")
2003 hasCustomPreCADOptions = true;
2004 else if (option_or_sm == "__SIZEMAP_BEGIN__")
2006 else if (option_or_sm == "__ATTRACTORS_BEGIN__")
2007 hasAttractor = true;
2008 else if (option_or_sm == "__NEW_ATTRACTORS_BEGIN__")
2009 hasNewAttractor = true;
2010 else if (option_or_sm == "__ENFORCED_VERTICES_BEGIN__")
2011 hasEnforcedVertex = true;
2012 else if (option_or_sm == "__PRECAD_FACES_PERIODICITY_BEGIN__")
2013 hasPreCADFacesPeriodicity = true;
2014 else if (option_or_sm == "__PRECAD_EDGES_PERIODICITY_BEGIN__")
2015 hasPreCADEdgesPeriodicity = true;
2016 else if (option_or_sm == "__FACES_PERIODICITY_BEGIN__")
2017 hasFacesPeriodicity = true;
2018 else if (option_or_sm == "__EDGES_PERIODICITY_BEGIN__")
2019 hasEdgesPeriodicity = true;
2020 else if (option_or_sm == "__VERTICES_PERIODICITY_BEGIN__")
2021 hasVerticesPeriodicity = true;
2025 std::string optName, optValue;
2026 while (isOK && hasOptions) {
2027 isOK = static_cast<bool>(load >> optName);
2029 if (optName == "__OPTIONS_END__")
2031 isOK = static_cast<bool>(load >> optValue);
2034 std::string & value = _option2value[optName];
2036 int len = value.size();
2037 // continue reading until "%#" encountered
2038 while (value[len - 1] != '#' || value[len - 2] != '%') {
2039 isOK = static_cast<bool>(load >> optValue);
2048 value[len - 2] = '\0'; //cut off "%#"
2053 isOK = static_cast<bool>(load >> option_or_sm);
2055 if (option_or_sm == "__CUSTOM_OPTIONS_BEGIN__")
2056 hasCustomOptions = true;
2057 else if (option_or_sm == "__PRECAD_OPTIONS_BEGIN__")
2058 hasPreCADOptions = true;
2059 else if (option_or_sm == "__CUSTOM_PRECAD_OPTIONS_BEGIN__")
2060 hasCustomPreCADOptions = true;
2061 else if (option_or_sm == "__SIZEMAP_BEGIN__")
2063 else if (option_or_sm == "__ATTRACTORS_BEGIN__")
2064 hasAttractor = true;
2065 else if (option_or_sm == "__NEW_ATTRACTORS_BEGIN__")
2066 hasNewAttractor = true;
2067 else if (option_or_sm == "__ENFORCED_VERTICES_BEGIN__")
2068 hasEnforcedVertex = true;
2069 else if (option_or_sm == "__PRECAD_FACES_PERIODICITY_BEGIN__")
2070 hasPreCADFacesPeriodicity = true;
2071 else if (option_or_sm == "__PRECAD_EDGES_PERIODICITY_BEGIN__")
2072 hasPreCADEdgesPeriodicity = true;
2073 else if (option_or_sm == "__FACES_PERIODICITY_BEGIN__")
2074 hasFacesPeriodicity = true;
2075 else if (option_or_sm == "__EDGES_PERIODICITY_BEGIN__")
2076 hasEdgesPeriodicity = true;
2077 else if (option_or_sm == "__VERTICES_PERIODICITY_BEGIN__")
2078 hasVerticesPeriodicity = true;
2082 while (isOK && hasCustomOptions) {
2083 isOK = static_cast<bool>(load >> optName);
2085 if (optName == "__CUSTOM_OPTIONS_END__")
2087 isOK = static_cast<bool>(load >> optValue);
2090 std::string& value = optValue;
2091 int len = value.size();
2092 // continue reading until "%#" encountered
2093 while (value[len - 1] != '#' || value[len - 2] != '%') {
2094 isOK = static_cast<bool>(load >> optValue);
2103 _customOption2value[optName] = value.substr(0,len-2);
2104 value[len - 2] = '\0'; //cut off "%#"
2108 if (hasCustomOptions) {
2109 isOK = static_cast<bool>(load >> option_or_sm);
2111 if (option_or_sm == "__PRECAD_OPTIONS_BEGIN__")
2112 hasPreCADOptions = true;
2113 else if (option_or_sm == "__CUSTOM_PRECAD_OPTIONS_BEGIN__")
2114 hasCustomPreCADOptions = true;
2115 else if (option_or_sm == "__SIZEMAP_BEGIN__")
2117 else if (option_or_sm == "__ATTRACTORS_BEGIN__")
2118 hasAttractor = true;
2119 else if (option_or_sm == "__NEW_ATTRACTORS_BEGIN__")
2120 hasNewAttractor = true;
2121 else if (option_or_sm == "__ENFORCED_VERTICES_BEGIN__")
2122 hasEnforcedVertex = true;
2123 else if (option_or_sm == "__PRECAD_FACES_PERIODICITY_BEGIN__")
2124 hasPreCADFacesPeriodicity = true;
2125 else if (option_or_sm == "__PRECAD_EDGES_PERIODICITY_BEGIN__")
2126 hasPreCADEdgesPeriodicity = true;
2127 else if (option_or_sm == "__FACES_PERIODICITY_BEGIN__")
2128 hasFacesPeriodicity = true;
2129 else if (option_or_sm == "__EDGES_PERIODICITY_BEGIN__")
2130 hasEdgesPeriodicity = true;
2131 else if (option_or_sm == "__VERTICES_PERIODICITY_BEGIN__")
2132 hasVerticesPeriodicity = true;
2136 while (isOK && hasPreCADOptions) {
2137 isOK = static_cast<bool>(load >> optName);
2139 if (optName == "__PRECAD_OPTIONS_END__")
2141 isOK = static_cast<bool>(load >> optValue);
2144 std::string & value = _preCADoption2value[optName];
2146 int len = value.size();
2147 // continue reading until "%#" encountered
2148 while (value[len - 1] != '#' || value[len - 2] != '%') {
2149 isOK = static_cast<bool>(load >> optValue);
2158 value[len - 2] = '\0'; //cut off "%#"
2162 if (hasPreCADOptions) {
2163 isOK = static_cast<bool>(load >> option_or_sm);
2165 if (option_or_sm == "__CUSTOM_PRECAD_OPTIONS_BEGIN__")
2166 hasCustomPreCADOptions = true;
2167 else if (option_or_sm == "__SIZEMAP_BEGIN__")
2169 else if (option_or_sm == "__ATTRACTORS_BEGIN__")
2170 hasAttractor = true;
2171 else if (option_or_sm == "__NEW_ATTRACTORS_BEGIN__")
2172 hasNewAttractor = true;
2173 else if (option_or_sm == "__ENFORCED_VERTICES_BEGIN__")
2174 hasEnforcedVertex = true;
2175 else if (option_or_sm == "__PRECAD_FACES_PERIODICITY_BEGIN__")
2176 hasPreCADFacesPeriodicity = true;
2177 else if (option_or_sm == "__PRECAD_EDGES_PERIODICITY_BEGIN__")
2178 hasPreCADEdgesPeriodicity = true;
2179 else if (option_or_sm == "__FACES_PERIODICITY_BEGIN__")
2180 hasFacesPeriodicity = true;
2181 else if (option_or_sm == "__EDGES_PERIODICITY_BEGIN__")
2182 hasEdgesPeriodicity = true;
2183 else if (option_or_sm == "__VERTICES_PERIODICITY_BEGIN__")
2184 hasVerticesPeriodicity = true;
2188 while (isOK && hasCustomPreCADOptions) {
2189 isOK = static_cast<bool>(load >> optName);
2191 if (optName == "__CUSTOM_PRECAD_OPTIONS_END__")
2193 isOK = static_cast<bool>(load >> optValue);
2196 std::string& value = optValue;
2197 int len = value.size();
2198 // continue reading until "%#" encountered
2199 while (value[len - 1] != '#' || value[len - 2] != '%') {
2200 isOK = static_cast<bool>(load >> optValue);
2209 _customPreCADOption2value[optName] = value.substr(0,len-2);
2210 value[len - 2] = '\0'; //cut off "%#"
2214 if (hasCustomPreCADOptions) {
2215 isOK = static_cast<bool>(load >> option_or_sm);
2217 if (option_or_sm == "__SIZEMAP_BEGIN__")
2219 else if (option_or_sm == "__ATTRACTORS_BEGIN__")
2220 hasAttractor = true;
2221 else if (option_or_sm == "__NEW_ATTRACTORS_BEGIN__")
2222 hasNewAttractor = true;
2223 else if (option_or_sm == "__ENFORCED_VERTICES_BEGIN__")
2224 hasEnforcedVertex = true;
2225 else if (option_or_sm == "__PRECAD_FACES_PERIODICITY_BEGIN__")
2226 hasPreCADFacesPeriodicity = true;
2227 else if (option_or_sm == "__PRECAD_EDGES_PERIODICITY_BEGIN__")
2228 hasPreCADEdgesPeriodicity = true;
2229 else if (option_or_sm == "__FACES_PERIODICITY_BEGIN__")
2230 hasFacesPeriodicity = true;
2231 else if (option_or_sm == "__EDGES_PERIODICITY_BEGIN__")
2232 hasEdgesPeriodicity = true;
2233 else if (option_or_sm == "__VERTICES_PERIODICITY_BEGIN__")
2234 hasVerticesPeriodicity = true;
2238 std::string smEntry, smValue;
2239 while (isOK && hasSizeMap) {
2240 isOK = static_cast<bool>(load >> smEntry);
2242 if (smEntry == "__SIZEMAP_END__")
2244 isOK = static_cast<bool>(load >> smValue);
2247 std::string & value2 = _sizeMap[smEntry];
2249 int len2 = value2.size();
2250 // continue reading until "%#" encountered
2251 while (value2[len2 - 1] != '#' || value2[len2 - 2] != '%') {
2252 isOK = static_cast<bool>(load >> smValue);
2256 len2 = value2.size();
2261 value2[len2 - 2] = '\0'; //cut off "%#"
2266 isOK = static_cast<bool>(load >> option_or_sm);
2268 if (option_or_sm == "__ATTRACTORS_BEGIN__")
2269 hasAttractor = true;
2270 if (option_or_sm == "__NEW_ATTRACTORS_BEGIN__")
2271 hasNewAttractor = true;
2272 else if (option_or_sm == "__ENFORCED_VERTICES_BEGIN__")
2273 hasEnforcedVertex = true;
2274 else if (option_or_sm == "__PRECAD_FACES_PERIODICITY_BEGIN__")
2275 hasPreCADFacesPeriodicity = true;
2276 else if (option_or_sm == "__PRECAD_EDGES_PERIODICITY_BEGIN__")
2277 hasPreCADEdgesPeriodicity = true;
2278 else if (option_or_sm == "__FACES_PERIODICITY_BEGIN__")
2279 hasFacesPeriodicity = true;
2280 else if (option_or_sm == "__EDGES_PERIODICITY_BEGIN__")
2281 hasEdgesPeriodicity = true;
2282 else if (option_or_sm == "__VERTICES_PERIODICITY_BEGIN__")
2283 hasVerticesPeriodicity = true;
2286 std::string atEntry, atValue;
2287 while (isOK && hasAttractor) {
2288 isOK = static_cast<bool>(load >> atEntry);
2290 if (atEntry == "__ATTRACTORS_END__")
2292 isOK = static_cast<bool>(load >> atValue);
2295 std::string & value3 = _attractors[atEntry];
2297 int len3 = value3.size();
2298 // continue reading until "%#" encountered
2299 while (value3[len3 - 1] != '#' || value3[len3 - 2] != '%') {
2300 isOK = static_cast<bool>(load >> atValue);
2304 len3 = value3.size();
2309 value3[len3 - 2] = '\0'; //cut off "%#"
2314 isOK = static_cast<bool>(load >> option_or_sm);
2316 if (option_or_sm == "__NEW_ATTRACTORS_BEGIN__")
2317 hasNewAttractor = true;
2318 else if (option_or_sm == "__ENFORCED_VERTICES_BEGIN__")
2319 hasEnforcedVertex = true;
2320 else if (option_or_sm == "__PRECAD_FACES_PERIODICITY_BEGIN__")
2321 hasPreCADFacesPeriodicity = true;
2322 else if (option_or_sm == "__PRECAD_EDGES_PERIODICITY_BEGIN__")
2323 hasPreCADEdgesPeriodicity = true;
2324 else if (option_or_sm == "__FACES_PERIODICITY_BEGIN__")
2325 hasFacesPeriodicity = true;
2326 else if (option_or_sm == "__EDGES_PERIODICITY_BEGIN__")
2327 hasEdgesPeriodicity = true;
2328 else if (option_or_sm == "__VERTICES_PERIODICITY_BEGIN__")
2329 hasVerticesPeriodicity = true;
2333 std::string newAtFaceEntry, atTestString;
2334 std::string newAtShapeEntry;
2335 double attParams[4];
2337 while (isOK && hasNewAttractor) {
2338 //std::cout<<"Load new attractor"<<std::endl;
2339 isOK = static_cast<bool>(load >> newAtFaceEntry);
2341 if (newAtFaceEntry == "__NEW_ATTRACTORS_END__")
2343 isOK = static_cast<bool>(load >> newAtShapeEntry);
2346 isOK = static_cast<bool>(load >> attParams[0]>>attParams[1]>>attParams[2]>>attParams[3]); //>>step);
2349 MESSAGE(" LOADING ATTRACTOR HYPOTHESIS ")
2350 const TopoDS_Shape attractorShape = BLSURFPlugin_Hypothesis::entryToShape(newAtShapeEntry);
2351 const TopoDS_Face faceShape = TopoDS::Face(BLSURFPlugin_Hypothesis::entryToShape(newAtFaceEntry));
2352 BLSURFPlugin_Attractor* attractor = new BLSURFPlugin_Attractor(faceShape, attractorShape, newAtShapeEntry);//, step);
2353 attractor->SetParameters(attParams[0], attParams[1], attParams[2], attParams[3]);
2354 //attractor->BuildMap();
2355 _classAttractors.insert( make_pair( newAtFaceEntry, attractor ));
2360 if (hasNewAttractor) {
2361 isOK = static_cast<bool>(load >> option_or_sm);
2363 if (option_or_sm == "__ENFORCED_VERTICES_BEGIN__")
2364 hasEnforcedVertex = true;
2365 else if (option_or_sm == "__PRECAD_FACES_PERIODICITY_BEGIN__")
2366 hasPreCADFacesPeriodicity = true;
2367 else if (option_or_sm == "__PRECAD_EDGES_PERIODICITY_BEGIN__")
2368 hasPreCADEdgesPeriodicity = true;
2369 else if (option_or_sm == "__FACES_PERIODICITY_BEGIN__")
2370 hasFacesPeriodicity = true;
2371 else if (option_or_sm == "__EDGES_PERIODICITY_BEGIN__")
2372 hasEdgesPeriodicity = true;
2373 else if (option_or_sm == "__VERTICES_PERIODICITY_BEGIN__")
2374 hasVerticesPeriodicity = true;
2380 // Here is a example of the saved stream:
2381 // __ENFORCED_VERTICES_BEGIN__
2382 // __BEGIN_VERTEX__ => no name, no entry
2383 // __BEGIN_GROUP__ mon groupe __END_GROUP__
2384 // __BEGIN_COORDS__ 10 10 10 __END_COORDS__
2385 // __BEGIN_FACELIST__ 0:1:1:1:1 __END_FACELIST__
2387 // __BEGIN_VERTEX__ => no coords
2388 // __BEGIN_NAME__ mes points __END_NAME__
2389 // __BEGIN_ENTRY__ 0:1:1:4 __END_ENTRY__
2390 // __BEGIN_GROUP__ mon groupe __END_GROUP__
2391 // __BEGIN_FACELIST__ 0:1:1:1:3 __END_FACELIST__
2393 // __ENFORCED_VERTICES_END__
2396 std::string enfSeparator;
2397 std::string enfName;
2398 std::string enfGeomEntry;
2399 std::string enfGroup;
2400 TEntryList enfFaceEntryList;
2401 double enfCoords[3];
2402 bool hasCoords = false;
2404 _faceEntryEnfVertexListMap.clear();
2405 _enfVertexList.clear();
2406 _faceEntryCoordsListMap.clear();
2407 _coordsEnfVertexMap.clear();
2408 _faceEntryEnfVertexEntryListMap.clear();
2409 _enfVertexEntryEnfVertexMap.clear();
2412 while (isOK && hasEnforcedVertex) {
2413 isOK = static_cast<bool>(load >> enfSeparator); // __BEGIN_VERTEX__
2414 TEnfVertex *enfVertex = new TEnfVertex();
2415 // MESSAGE("enfSeparator: " <<enfSeparator);
2416 if (enfSeparator == "__ENFORCED_VERTICES_END__")
2417 break; // __ENFORCED_VERTICES_END__
2418 if (enfSeparator != "__BEGIN_VERTEX__")
2419 throw std::exception();
2422 isOK = static_cast<bool>(load >> enfSeparator);
2423 MESSAGE("enfSeparator: " <<enfSeparator);
2424 if (enfSeparator == "__END_VERTEX__") {
2426 enfVertex->name = enfName;
2427 enfVertex->geomEntry = enfGeomEntry;
2428 enfVertex->grpName = enfGroup;
2429 enfVertex->coords.clear();
2431 enfVertex->coords.assign(enfCoords,enfCoords+3);
2432 enfVertex->faceEntries = enfFaceEntryList;
2434 _enfVertexList.insert(enfVertex);
2436 if (enfVertex->coords.size()) {
2437 _coordsEnfVertexMap[enfVertex->coords] = enfVertex;
2438 for (TEntryList::const_iterator it = enfVertex->faceEntries.begin() ; it != enfVertex->faceEntries.end(); ++it) {
2439 _faceEntryCoordsListMap[(*it)].insert(enfVertex->coords);
2440 _faceEntryEnfVertexListMap[(*it)].insert(enfVertex);
2443 if (!enfVertex->geomEntry.empty()) {
2444 _enfVertexEntryEnfVertexMap[enfVertex->geomEntry] = enfVertex;
2445 for (TEntryList::const_iterator it = enfVertex->faceEntries.begin() ; it != enfVertex->faceEntries.end(); ++it) {
2446 _faceEntryEnfVertexEntryListMap[(*it)].insert(enfVertex->geomEntry);
2447 _faceEntryEnfVertexListMap[(*it)].insert(enfVertex);
2452 enfGeomEntry.clear();
2454 enfFaceEntryList.clear();
2456 break; // __END_VERTEX__
2459 if (enfSeparator == "__BEGIN_NAME__") { // __BEGIN_NAME__
2460 while (isOK && (enfSeparator != "__END_NAME__")) {
2461 isOK = static_cast<bool>(load >> enfSeparator);
2462 if (enfSeparator != "__END_NAME__") {
2463 if (!enfName.empty())
2465 enfName += enfSeparator;
2468 MESSAGE("enfName: " <<enfName);
2471 if (enfSeparator == "__BEGIN_ENTRY__") { // __BEGIN_ENTRY__
2472 isOK = static_cast<bool>(load >> enfGeomEntry);
2473 isOK = static_cast<bool>(load >> enfSeparator); // __END_ENTRY__
2474 if (enfSeparator != "__END_ENTRY__")
2475 throw std::exception();
2476 MESSAGE("enfGeomEntry: " <<enfGeomEntry);
2479 if (enfSeparator == "__BEGIN_GROUP__") { // __BEGIN_GROUP__
2480 while (isOK && (enfSeparator != "__END_GROUP__")) {
2481 isOK = static_cast<bool>(load >> enfSeparator);
2482 if (enfSeparator != "__END_GROUP__") {
2483 if (!enfGroup.empty())
2485 enfGroup += enfSeparator;
2488 MESSAGE("enfGroup: " <<enfGroup);
2491 if (enfSeparator == "__BEGIN_COORDS__") { // __BEGIN_COORDS__
2493 isOK = static_cast<bool>(load >> enfCoords[0] >> enfCoords[1] >> enfCoords[2]);
2494 isOK = static_cast<bool>(load >> enfSeparator); // __END_COORDS__
2495 if (enfSeparator != "__END_COORDS__")
2496 throw std::exception();
2497 MESSAGE("enfCoords: " << enfCoords[0] <<","<< enfCoords[1] <<","<< enfCoords[2]);
2500 if (enfSeparator == "__BEGIN_FACELIST__") { // __BEGIN_FACELIST__
2501 while (isOK && (enfSeparator != "__END_FACELIST__")) {
2502 isOK = static_cast<bool>(load >> enfSeparator);
2503 if (enfSeparator != "__END_FACELIST__") {
2504 enfFaceEntryList.insert(enfSeparator);
2505 MESSAGE(enfSeparator << " was inserted into enfFaceEntryList");
2514 if (hasPreCADFacesPeriodicity){
2515 LoadPreCADPeriodicity(load, "FACES");
2517 isOK = static_cast<bool>(load >> option_or_sm);
2519 if (option_or_sm == "__PRECAD_EDGES_PERIODICITY_BEGIN__")
2520 hasPreCADEdgesPeriodicity = true;
2521 else if (option_or_sm == "__FACES_PERIODICITY_BEGIN__")
2522 hasFacesPeriodicity = true;
2523 else if (option_or_sm == "__EDGES_PERIODICITY_BEGIN__")
2524 hasEdgesPeriodicity = true;
2525 else if (option_or_sm == "__VERTICES_PERIODICITY_BEGIN__")
2526 hasVerticesPeriodicity = true;
2530 if (hasPreCADEdgesPeriodicity){
2531 LoadPreCADPeriodicity(load, "EDGES");
2533 isOK = static_cast<bool>(load >> option_or_sm);
2535 if (option_or_sm == "__FACES_PERIODICITY_BEGIN__")
2536 hasFacesPeriodicity = true;
2537 else if (option_or_sm == "__EDGES_PERIODICITY_BEGIN__")
2538 hasEdgesPeriodicity = true;
2539 else if (option_or_sm == "__VERTICES_PERIODICITY_BEGIN__")
2540 hasVerticesPeriodicity = true;
2544 if (hasFacesPeriodicity){
2545 LoadFacesPeriodicity(load);
2547 isOK = static_cast<bool>(load >> option_or_sm);
2549 if (option_or_sm == "__EDGES_PERIODICITY_BEGIN__")
2550 hasEdgesPeriodicity = true;
2551 else if (option_or_sm == "__VERTICES_PERIODICITY_BEGIN__")
2552 hasVerticesPeriodicity = true;
2556 if (hasEdgesPeriodicity){
2557 LoadEdgesPeriodicity(load);
2559 isOK = static_cast<bool>(load >> option_or_sm);
2561 if (option_or_sm == "__VERTICES_PERIODICITY_BEGIN__")
2562 hasVerticesPeriodicity = true;
2565 if (hasVerticesPeriodicity)
2566 LoadVerticesPeriodicity(load);
2571 void BLSURFPlugin_Hypothesis::LoadFacesPeriodicity(std::istream & load){
2575 std::string periodicitySeparator;
2579 _facesPeriodicityVector.clear();
2582 isOK = static_cast<bool>(load >> periodicitySeparator); // __BEGIN_PERIODICITY_DESCRIPTION__
2583 MESSAGE("periodicitySeparator 1: " <<periodicitySeparator);
2584 TFacesPeriodicity *periodicity_i = new TFacesPeriodicity();
2585 if (periodicitySeparator == "__FACES_PERIODICITY_END__")
2586 break; // __FACES_PERIODICITY_END__
2587 if (periodicitySeparator != "__BEGIN_PERIODICITY_DESCRIPTION__"){
2588 MESSAGE("//" << periodicitySeparator << "//");
2589 throw std::exception();
2593 isOK = static_cast<bool>(load >> periodicitySeparator);
2594 MESSAGE("periodicitySeparator 2: " <<periodicitySeparator);
2595 if (periodicitySeparator == "__END_PERIODICITY_DESCRIPTION__") {
2597 periodicity_i->first = shape1Entry;
2598 periodicity_i->second = shape2Entry;
2600 _facesPeriodicityVector.push_back(*periodicity_i);
2602 break; // __END_PERIODICITY_DESCRIPTION__
2605 if (periodicitySeparator == "__BEGIN_ENTRY1__") { // __BEGIN_ENTRY1__
2606 isOK = static_cast<bool>(load >> shape1Entry);
2607 isOK = static_cast<bool>(load >> periodicitySeparator); // __END_ENTRY1__
2608 if (periodicitySeparator != "__END_ENTRY1__")
2609 throw std::exception();
2610 MESSAGE("shape1Entry: " <<shape1Entry);
2613 if (periodicitySeparator == "__BEGIN_ENTRY2__") { // __BEGIN_ENTRY2__
2614 isOK = static_cast<bool>(load >> shape2Entry);
2615 isOK = static_cast<bool>(load >> periodicitySeparator); // __END_ENTRY2__
2616 if (periodicitySeparator != "__END_ENTRY2__")
2617 throw std::exception();
2618 MESSAGE("shape2Entry: " <<shape2Entry);
2625 void BLSURFPlugin_Hypothesis::LoadEdgesPeriodicity(std::istream & load){
2629 std::string periodicitySeparator;
2630 TEntry theFace1Entry;
2631 TEntry theEdge1Entry;
2632 TEntry theFace2Entry;
2633 TEntry theEdge2Entry;
2634 int edge_orientation = 0;
2636 _edgesPeriodicityVector.clear();
2639 isOK = static_cast<bool>(load >> periodicitySeparator); // __BEGIN_PERIODICITY_DESCRIPTION__
2640 MESSAGE("periodicitySeparator 1: " <<periodicitySeparator);
2641 TEdgePeriodicity *periodicity_i = new TEdgePeriodicity();
2642 if (periodicitySeparator == "__EDGES_PERIODICITY_END__")
2643 break; // __EDGES_PERIODICITY_END__
2644 if (periodicitySeparator != "__BEGIN_PERIODICITY_DESCRIPTION__"){
2645 MESSAGE("//" << periodicitySeparator << "//");
2646 throw std::exception();
2650 isOK = static_cast<bool>(load >> periodicitySeparator);
2651 MESSAGE("periodicitySeparator 2: " <<periodicitySeparator);
2652 if (periodicitySeparator == "__END_PERIODICITY_DESCRIPTION__") {
2654 periodicity_i->theFace1Entry = theFace1Entry;
2655 periodicity_i->theEdge1Entry = theEdge1Entry;
2656 periodicity_i->theFace2Entry = theFace2Entry;
2657 periodicity_i->theEdge2Entry = theEdge2Entry;
2658 periodicity_i->edge_orientation = edge_orientation;
2660 _edgesPeriodicityVector.push_back(*periodicity_i);
2662 break; // __END_PERIODICITY_DESCRIPTION__
2665 if (periodicitySeparator == "__BEGIN_FACE1__") { // __BEGIN_FACE1__
2666 isOK = static_cast<bool>(load >> theFace1Entry);
2667 MESSAGE("//" << theFace1Entry << "//");
2668 isOK = static_cast<bool>(load >> periodicitySeparator); // __END_FACE1__
2669 if (periodicitySeparator != "__END_FACE1__"){
2670 MESSAGE("//" << periodicitySeparator << "//");
2671 throw std::exception();
2673 MESSAGE("theFace1Entry: " <<theFace1Entry);
2676 if (periodicitySeparator == "__BEGIN_EDGE1__") { // __BEGIN_EDGE1__
2677 isOK = static_cast<bool>(load >> theEdge1Entry);
2678 isOK = static_cast<bool>(load >> periodicitySeparator); // __END_EDGE1__
2679 if (periodicitySeparator != "__END_EDGE1__")
2680 throw std::exception();
2681 MESSAGE("theEdge1Entry: " <<theEdge1Entry);
2684 if (periodicitySeparator == "__BEGIN_FACE2__") { // __BEGIN_FACE2__
2685 isOK = static_cast<bool>(load >> theFace2Entry);
2686 isOK = static_cast<bool>(load >> periodicitySeparator); // __END_FACE2__
2687 if (periodicitySeparator != "__END_FACE2__")
2688 throw std::exception();
2689 MESSAGE("theFace2Entry: " <<theFace2Entry);
2692 if (periodicitySeparator == "__BEGIN_EDGE2__") { // __BEGIN_EDGE2__
2693 isOK = static_cast<bool>(load >> theEdge2Entry);
2694 isOK = static_cast<bool>(load >> periodicitySeparator); // __END_EDGE2__
2695 if (periodicitySeparator != "__END_EDGE2__")
2696 throw std::exception();
2697 MESSAGE("theEdge2Entry: " <<theEdge2Entry);
2700 if (periodicitySeparator == "__BEGIN_EDGE_ORIENTATION__") { // __BEGIN_EDGE_ORIENTATION__
2701 isOK = static_cast<bool>(load >> edge_orientation);
2702 isOK = static_cast<bool>(load >> periodicitySeparator); // __END_EDGE_ORIENTATION__
2703 if (periodicitySeparator != "__END_EDGE_ORIENTATION__")
2704 throw std::exception();
2705 MESSAGE("edge_orientation: " <<edge_orientation);
2711 void BLSURFPlugin_Hypothesis::LoadVerticesPeriodicity(std::istream & load){
2715 std::string periodicitySeparator;
2716 TEntry theEdge1Entry;
2717 TEntry theVertex1Entry;
2718 TEntry theEdge2Entry;
2719 TEntry theVertex2Entry;
2721 _verticesPeriodicityVector.clear();
2724 isOK = static_cast<bool>(load >> periodicitySeparator); // __BEGIN_PERIODICITY_DESCRIPTION__
2725 MESSAGE("periodicitySeparator 1: " <<periodicitySeparator);
2726 TVertexPeriodicity *periodicity_i = new TVertexPeriodicity();
2727 if (periodicitySeparator == "__VERTICES_PERIODICITY_END__")
2728 break; // __VERTICES_PERIODICITY_END__
2729 if (periodicitySeparator != "__BEGIN_PERIODICITY_DESCRIPTION__"){
2730 MESSAGE("//" << periodicitySeparator << "//");
2731 throw std::exception();
2735 isOK = static_cast<bool>(load >> periodicitySeparator);
2736 MESSAGE("periodicitySeparator 2: " <<periodicitySeparator);
2737 if (periodicitySeparator == "__END_PERIODICITY_DESCRIPTION__") {
2739 periodicity_i->theEdge1Entry = theEdge1Entry;
2740 periodicity_i->theVertex1Entry = theVertex1Entry;
2741 periodicity_i->theEdge2Entry = theEdge2Entry;
2742 periodicity_i->theVertex2Entry = theVertex2Entry;
2744 _verticesPeriodicityVector.push_back(*periodicity_i);
2746 break; // __END_PERIODICITY_DESCRIPTION__
2749 if (periodicitySeparator == "__BEGIN_EDGE1__") { // __BEGIN_EDGE1__
2750 isOK = static_cast<bool>(load >> theEdge1Entry);
2751 isOK = static_cast<bool>(load >> periodicitySeparator); // __END_EDGE1__
2752 if (periodicitySeparator != "__END_EDGE1__")
2753 throw std::exception();
2754 MESSAGE("theEdge1Entry: " <<theEdge1Entry);
2757 if (periodicitySeparator == "__BEGIN_VERTEX1__") { // __BEGIN_VERTEX1__
2758 isOK = static_cast<bool>(load >> theVertex1Entry);
2759 isOK = static_cast<bool>(load >> periodicitySeparator); // __END_VERTEX1__
2760 if (periodicitySeparator != "__END_VERTEX1__")
2761 throw std::exception();
2762 MESSAGE("theVertex1Entry: " <<theVertex1Entry);
2765 if (periodicitySeparator == "__BEGIN_EDGE2__") { // __BEGIN_EDGE2__
2766 isOK = static_cast<bool>(load >> theEdge2Entry);
2767 isOK = static_cast<bool>(load >> periodicitySeparator); // __END_EDGE2__
2768 if (periodicitySeparator != "__END_EDGE2__")
2769 throw std::exception();
2770 MESSAGE("theEdge2Entry: " <<theEdge2Entry);
2773 if (periodicitySeparator == "__BEGIN_VERTEX2__") { // __BEGIN_VERTEX2__
2774 isOK = static_cast<bool>(load >> theVertex2Entry);
2775 isOK = static_cast<bool>(load >> periodicitySeparator); // __END_VERTEX2__
2776 if (periodicitySeparator != "__END_VERTEX2__")
2777 throw std::exception();
2778 MESSAGE("theVertex2Entry: " <<theVertex2Entry);
2784 void BLSURFPlugin_Hypothesis::LoadPreCADPeriodicity(std::istream & load, const char* shapeType) {
2788 std::string periodicitySeparator;
2791 std::vector<std::string> theSourceVerticesEntries;
2792 std::vector<std::string> theTargetVerticesEntries;
2794 bool hasSourceVertices = false;
2795 bool hasTargetVertices = false;
2797 if ( shapeType && strcmp( shapeType, "FACES") == 0 )
2798 _preCadFacesPeriodicityVector.clear();
2800 _preCadEdgesPeriodicityVector.clear();
2804 isOK = static_cast<bool>(load >> periodicitySeparator); // __BEGIN_PERIODICITY_DESCRIPTION__
2805 MESSAGE("periodicitySeparator 1: " <<periodicitySeparator);
2806 TPreCadPeriodicity *periodicity_i = new TPreCadPeriodicity();
2807 // MESSAGE("periodicitySeparator: " <<periodicitySeparator);
2808 std::string endSeparator = "__PRECAD_" + std::string(shapeType) + "_PERIODICITY_END__";
2809 if (periodicitySeparator == endSeparator)
2810 break; // __PRECAD_FACES_PERIODICITY_END__
2811 if (periodicitySeparator != "__BEGIN_PERIODICITY_DESCRIPTION__"){
2812 MESSAGE("//" << endSeparator << "//");
2813 MESSAGE("//" << periodicitySeparator << "//");
2814 throw std::exception();
2818 isOK = static_cast<bool>(load >> periodicitySeparator);
2819 MESSAGE("periodicitySeparator 2: " <<periodicitySeparator);
2820 if (periodicitySeparator == "__END_PERIODICITY_DESCRIPTION__") {
2822 periodicity_i->shape1Entry = shape1Entry;
2823 periodicity_i->shape2Entry = shape2Entry;
2825 MESSAGE("theSourceVerticesEntries.size(): " << theSourceVerticesEntries.size());
2826 MESSAGE("theTargetVerticesEntries.size(): " << theTargetVerticesEntries.size());
2828 if (hasSourceVertices)
2829 periodicity_i->theSourceVerticesEntries = theSourceVerticesEntries;
2830 if (hasTargetVertices)
2831 periodicity_i->theTargetVerticesEntries = theTargetVerticesEntries;
2833 if ( shapeType && strcmp( shapeType, "FACES" ))
2834 _preCadFacesPeriodicityVector.push_back(*periodicity_i);
2836 _preCadEdgesPeriodicityVector.push_back(*periodicity_i);
2838 theSourceVerticesEntries.clear();
2839 theTargetVerticesEntries.clear();
2840 hasSourceVertices = false;
2841 hasTargetVertices = false;
2842 break; // __END_PERIODICITY_DESCRIPTION__
2845 if (periodicitySeparator == "__BEGIN_ENTRY1__") { // __BEGIN_ENTRY1__
2846 isOK = static_cast<bool>(load >> shape1Entry);
2847 isOK = static_cast<bool>(load >> periodicitySeparator); // __END_ENTRY1__
2848 if (periodicitySeparator != "__END_ENTRY1__")
2849 throw std::exception();
2850 MESSAGE("shape1Entry: " <<shape1Entry);
2853 if (periodicitySeparator == "__BEGIN_ENTRY2__") { // __BEGIN_ENTRY2__
2854 isOK = static_cast<bool>(load >> shape2Entry);
2855 isOK = static_cast<bool>(load >> periodicitySeparator); // __END_ENTRY2__
2856 if (periodicitySeparator != "__END_ENTRY2__")
2857 throw std::exception();
2858 MESSAGE("shape2Entry: " <<shape2Entry);
2861 if (periodicitySeparator == "__BEGIN_SOURCE_VERTICES_LIST__") { // __BEGIN_SOURCE_VERTICES_LIST__
2862 hasSourceVertices = true;
2863 while (isOK && (periodicitySeparator != "__END_SOURCE_VERTICES_LIST__")) {
2864 isOK = static_cast<bool>(load >> periodicitySeparator);
2865 if (periodicitySeparator != "__END_SOURCE_VERTICES_LIST__") {
2866 theSourceVerticesEntries.push_back(periodicitySeparator);
2867 MESSAGE("theSourceVerticesEntries: " <<periodicitySeparator);
2872 if (periodicitySeparator == "__BEGIN_TARGET_VERTICES_LIST__") { // __BEGIN_TARGET_VERTICES_LIST__
2873 hasTargetVertices = true;
2874 while (isOK && (periodicitySeparator != "__END_TARGET_VERTICES_LIST__")) {
2875 isOK = static_cast<bool>(load >> periodicitySeparator);
2876 if (periodicitySeparator != "__END_TARGET_VERTICES_LIST__") {
2877 theTargetVerticesEntries.push_back(periodicitySeparator);
2878 MESSAGE("theTargetVerticesEntries: " <<periodicitySeparator);
2886 //=============================================================================
2887 std::ostream & operator <<(std::ostream & save, BLSURFPlugin_Hypothesis & hyp) {
2888 return hyp.SaveTo(save);
2891 //=============================================================================
2892 std::istream & operator >>(std::istream & load, BLSURFPlugin_Hypothesis & hyp) {
2893 return hyp.LoadFrom(load);
2896 //================================================================================
2898 * \brief Does nothing
2900 //================================================================================
2902 bool BLSURFPlugin_Hypothesis::SetParametersByMesh(const SMESH_Mesh* theMesh, const TopoDS_Shape& theShape) {
2906 //================================================================================
2908 * \brief Returns default global constant physical size given a default value of element length ratio
2910 //================================================================================
2912 double BLSURFPlugin_Hypothesis::GetDefaultPhySize(double diagonal, double bbSegmentation) {
2913 if (bbSegmentation != 0 && diagonal != 0)
2914 return diagonal / bbSegmentation ;
2918 //================================================================================
2920 * \brief Returns default min size given a default value of element length ratio
2922 //================================================================================
2924 double BLSURFPlugin_Hypothesis::GetDefaultMinSize(double diagonal) {
2926 return diagonal / 1000.0 ;
2927 return undefinedDouble();
2930 //================================================================================
2932 * \brief Returns default max size given a default value of element length ratio
2934 //================================================================================
2936 double BLSURFPlugin_Hypothesis::GetDefaultMaxSize(double diagonal) {
2938 return diagonal / 5.0 ;
2939 return undefinedDouble();
2942 //================================================================================
2944 * \brief Returns default chordal error given a default value of element length ratio
2946 //================================================================================
2948 double BLSURFPlugin_Hypothesis::GetDefaultChordalError(double diagonal) {
2951 return undefinedDouble();
2954 //================================================================================
2956 * \brief Returns default tiny edge length given a default value of element length ratio
2958 //================================================================================
2960 double BLSURFPlugin_Hypothesis::GetDefaultTinyEdgeLength(double diagonal) {
2962 return diagonal * 1e-6 ;
2963 return undefinedDouble();
2966 //=============================================================================
2968 * \brief Initialize my parameter values by default parameters.
2969 * \retval bool - true if parameter values have been successfully defined
2971 //=============================================================================
2973 bool BLSURFPlugin_Hypothesis::SetParametersByDefaults(const TDefaults& dflts, const SMESH_Mesh* theMesh) {
2974 double diagonal = dflts._elemLength*_gen->GetBoundaryBoxSegmentation();
2975 _phySize = GetDefaultPhySize(diagonal, _gen->GetBoundaryBoxSegmentation());
2976 _minSize = GetDefaultMinSize(diagonal);
2977 _maxSize = GetDefaultMaxSize(diagonal);
2978 _chordalError = GetDefaultChordalError(diagonal);
2979 _tinyEdgeLength = GetDefaultTinyEdgeLength(diagonal);
2982 // return bool(_phySize = dflts._elemLength);