1 // Copyright (C) 2007-2015 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 _minSizeRel(GetDefaultMinSizeRel()),
51 _maxSize(GetDefaultMaxSize()),
52 _maxSizeRel(GetDefaultMaxSizeRel()),
53 _gradation(GetDefaultGradation()),
54 _quadAllowed(GetDefaultQuadAllowed()),
55 _angleMesh(GetDefaultAngleMesh()),
56 _chordalError(GetDefaultChordalError()),
57 _anisotropic(GetDefaultAnisotropic()),
58 _anisotropicRatio(GetDefaultAnisotropicRatio()),
59 _removeTinyEdges(GetDefaultRemoveTinyEdges()),
60 _tinyEdgeLength(GetDefaultTinyEdgeLength()),
61 _badElementRemoval(GetDefaultBadElementRemoval()),
62 _badElementAspectRatio(GetDefaultBadElementAspectRatio()),
63 _optimizeMesh(GetDefaultOptimizeMesh()),
64 _quadraticMesh(GetDefaultQuadraticMesh()),
65 _verb(GetDefaultVerbosity()),
66 _topology(GetDefaultTopology()),
67 _preCADMergeEdges(GetDefaultPreCADMergeEdges()),
68 _preCADProcess3DTopology(GetDefaultPreCADProcess3DTopology()),
69 _preCADDiscardInput(GetDefaultPreCADDiscardInput()),
70 _sizeMap(GetDefaultSizeMap()),
71 _attractors(GetDefaultSizeMap()),
72 _classAttractors(GetDefaultAttractorMap()),
73 _faceEntryEnfVertexListMap(GetDefaultFaceEntryEnfVertexListMap()),
74 _enfVertexList(GetDefaultEnfVertexList()),
75 _faceEntryCoordsListMap(GetDefaultFaceEntryCoordsListMap()),
76 _coordsEnfVertexMap(GetDefaultCoordsEnfVertexMap()),
77 _faceEntryEnfVertexEntryListMap(GetDefaultFaceEntryEnfVertexEntryListMap()),
78 _enfVertexEntryEnfVertexMap(GetDefaultEnfVertexEntryEnfVertexMap()),
79 _groupNameNodeIDMap(GetDefaultGroupNameNodeIDMap()),
80 _GMFFileName(GetDefaultGMFFile()),
81 _enforcedInternalVerticesAllFaces(GetDefaultInternalEnforcedVertex()),
82 _preCadFacesPeriodicityVector(GetDefaultPreCadFacesPeriodicityVector()),
83 _preCadEdgesPeriodicityVector(GetDefaultPreCadEdgesPeriodicityVector())
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 (string(theGroupName) != 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 vector<string> &theSourceVerticesEntries, vector<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 vector<string> &theSourceVerticesEntries, vector<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 (int 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 == "FACES")
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;
1735 _topology = (Topology) i;
1737 load.clear(std::ios::badbit | load.rdstate());
1741 _physicalMesh = (PhysicalMesh) i;
1743 load.clear(std::ios::badbit | load.rdstate());
1747 _geometricMesh = (GeometricMesh) i;
1749 load.clear(std::ios::badbit | load.rdstate());
1751 isOK = (load >> val);
1755 load.clear(std::ios::badbit | load.rdstate());
1757 isOK = (load >> val);
1761 load.clear(std::ios::badbit | load.rdstate());
1763 isOK = (load >> val);
1767 load.clear(std::ios::badbit | load.rdstate());
1771 _quadAllowed = (bool) i;
1773 load.clear(std::ios::badbit | load.rdstate());
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 = (load >> val);
1790 load.clear(std::ios::badbit | load.rdstate());
1792 isOK = (load >> val);
1796 load.clear(std::ios::badbit | load.rdstate());
1798 isOK = (load >> val);
1800 // former parameter: get min value
1801 _angleMesh = min(val,_angleMesh);
1803 load.clear(std::ios::badbit | load.rdstate());
1805 isOK = (load >> val);
1807 // former parameter: get min value
1808 _minSize = min(val,_minSize);
1810 load.clear(std::ios::badbit | load.rdstate());
1812 isOK = (load >> val);
1814 // former parameter: get max value
1815 _maxSize = max(val,_maxSize);
1817 load.clear(std::ios::badbit | load.rdstate());
1823 load.clear(std::ios::badbit | load.rdstate());
1827 _preCADMergeEdges = (bool) i;
1829 load.clear(std::ios::badbit | load.rdstate());
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());
1844 _preCADDiscardInput = (bool) i;
1846 load.clear(std::ios::badbit | load.rdstate());
1848 isOK = (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());
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 = (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) {
1920 _minSizeRel = (bool) i;
1922 load.clear(std::ios::badbit | load.rdstate());
1926 _maxSizeRel = (bool) i;
1928 load.clear(std::ios::badbit | load.rdstate());
1930 isOK = (load >> val);
1932 _chordalError = val;
1934 load.clear(std::ios::badbit | load.rdstate());
1938 _anisotropic = (bool) i;
1940 load.clear(std::ios::badbit | load.rdstate());
1942 isOK = (load >> val);
1944 _anisotropicRatio = val;
1946 load.clear(std::ios::badbit | load.rdstate());
1950 _removeTinyEdges = (bool) i;
1952 load.clear(std::ios::badbit | load.rdstate());
1954 isOK = (load >> val);
1956 _tinyEdgeLength = val;
1958 load.clear(std::ios::badbit | load.rdstate());
1962 _badElementRemoval = (bool) i;
1964 load.clear(std::ios::badbit | load.rdstate());
1966 isOK = (load >> val);
1968 _badElementAspectRatio = val;
1970 load.clear(std::ios::badbit | load.rdstate());
1974 _optimizeMesh = (bool) i;
1976 load.clear(std::ios::badbit | load.rdstate());
1980 _quadraticMesh = (bool) i;
1982 load.clear(std::ios::badbit | load.rdstate());
1986 _preCADProcess3DTopology = (bool) i;
1988 load.clear(std::ios::badbit | load.rdstate());
1993 if (hasCADSurfOptions) {
1994 isOK = (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;
2024 std::string optName, optValue;
2025 while (isOK && hasOptions) {
2026 isOK = (load >> optName);
2028 if (optName == "__OPTIONS_END__")
2030 isOK = (load >> optValue);
2033 std::string & value = _option2value[optName];
2035 int len = value.size();
2036 // continue reading until "%#" encountered
2037 while (value[len - 1] != '#' || value[len - 2] != '%') {
2038 isOK = (load >> optValue);
2047 value[len - 2] = '\0'; //cut off "%#"
2052 isOK = (load >> option_or_sm);
2054 if (option_or_sm == "__CUSTOM_OPTIONS_BEGIN__")
2055 hasCustomOptions = true;
2056 else if (option_or_sm == "__PRECAD_OPTIONS_BEGIN__")
2057 hasPreCADOptions = true;
2058 else if (option_or_sm == "__CUSTOM_PRECAD_OPTIONS_BEGIN__")
2059 hasCustomPreCADOptions = true;
2060 else if (option_or_sm == "__SIZEMAP_BEGIN__")
2062 else if (option_or_sm == "__ATTRACTORS_BEGIN__")
2063 hasAttractor = true;
2064 else if (option_or_sm == "__NEW_ATTRACTORS_BEGIN__")
2065 hasNewAttractor = true;
2066 else if (option_or_sm == "__ENFORCED_VERTICES_BEGIN__")
2067 hasEnforcedVertex = true;
2068 else if (option_or_sm == "__PRECAD_FACES_PERIODICITY_BEGIN__")
2069 hasPreCADFacesPeriodicity = true;
2070 else if (option_or_sm == "__PRECAD_EDGES_PERIODICITY_BEGIN__")
2071 hasPreCADEdgesPeriodicity = true;
2072 else if (option_or_sm == "__FACES_PERIODICITY_BEGIN__")
2073 hasFacesPeriodicity = true;
2074 else if (option_or_sm == "__EDGES_PERIODICITY_BEGIN__")
2075 hasEdgesPeriodicity = true;
2076 else if (option_or_sm == "__VERTICES_PERIODICITY_BEGIN__")
2077 hasVerticesPeriodicity = true;
2080 while (isOK && hasCustomOptions) {
2081 isOK = (load >> optName);
2083 if (optName == "__CUSTOM_OPTIONS_END__")
2085 isOK = (load >> optValue);
2088 std::string& value = optValue;
2089 int len = value.size();
2090 // continue reading until "%#" encountered
2091 while (value[len - 1] != '#' || value[len - 2] != '%') {
2092 isOK = (load >> optValue);
2101 _customOption2value[optName] = value.substr(0,len-2);
2102 value[len - 2] = '\0'; //cut off "%#"
2106 if (hasCustomOptions) {
2107 isOK = (load >> option_or_sm);
2109 if (option_or_sm == "__PRECAD_OPTIONS_BEGIN__")
2110 hasPreCADOptions = true;
2111 else if (option_or_sm == "__CUSTOM_PRECAD_OPTIONS_BEGIN__")
2112 hasCustomPreCADOptions = true;
2113 else if (option_or_sm == "__SIZEMAP_BEGIN__")
2115 else if (option_or_sm == "__ATTRACTORS_BEGIN__")
2116 hasAttractor = true;
2117 else if (option_or_sm == "__NEW_ATTRACTORS_BEGIN__")
2118 hasNewAttractor = true;
2119 else if (option_or_sm == "__ENFORCED_VERTICES_BEGIN__")
2120 hasEnforcedVertex = true;
2121 else if (option_or_sm == "__PRECAD_FACES_PERIODICITY_BEGIN__")
2122 hasPreCADFacesPeriodicity = true;
2123 else if (option_or_sm == "__PRECAD_EDGES_PERIODICITY_BEGIN__")
2124 hasPreCADEdgesPeriodicity = true;
2125 else if (option_or_sm == "__FACES_PERIODICITY_BEGIN__")
2126 hasFacesPeriodicity = true;
2127 else if (option_or_sm == "__EDGES_PERIODICITY_BEGIN__")
2128 hasEdgesPeriodicity = true;
2129 else if (option_or_sm == "__VERTICES_PERIODICITY_BEGIN__")
2130 hasVerticesPeriodicity = true;
2133 while (isOK && hasPreCADOptions) {
2134 isOK = (load >> optName);
2136 if (optName == "__PRECAD_OPTIONS_END__")
2138 isOK = (load >> optValue);
2141 std::string & value = _preCADoption2value[optName];
2143 int len = value.size();
2144 // continue reading until "%#" encountered
2145 while (value[len - 1] != '#' || value[len - 2] != '%') {
2146 isOK = (load >> optValue);
2155 value[len - 2] = '\0'; //cut off "%#"
2159 if (hasPreCADOptions) {
2160 isOK = (load >> option_or_sm);
2162 if (option_or_sm == "__CUSTOM_PRECAD_OPTIONS_BEGIN__")
2163 hasCustomPreCADOptions = true;
2164 else if (option_or_sm == "__SIZEMAP_BEGIN__")
2166 else if (option_or_sm == "__ATTRACTORS_BEGIN__")
2167 hasAttractor = true;
2168 else if (option_or_sm == "__NEW_ATTRACTORS_BEGIN__")
2169 hasNewAttractor = true;
2170 else if (option_or_sm == "__ENFORCED_VERTICES_BEGIN__")
2171 hasEnforcedVertex = true;
2172 else if (option_or_sm == "__PRECAD_FACES_PERIODICITY_BEGIN__")
2173 hasPreCADFacesPeriodicity = true;
2174 else if (option_or_sm == "__PRECAD_EDGES_PERIODICITY_BEGIN__")
2175 hasPreCADEdgesPeriodicity = true;
2176 else if (option_or_sm == "__FACES_PERIODICITY_BEGIN__")
2177 hasFacesPeriodicity = true;
2178 else if (option_or_sm == "__EDGES_PERIODICITY_BEGIN__")
2179 hasEdgesPeriodicity = true;
2180 else if (option_or_sm == "__VERTICES_PERIODICITY_BEGIN__")
2181 hasVerticesPeriodicity = true;
2184 while (isOK && hasCustomPreCADOptions) {
2185 isOK = (load >> optName);
2187 if (optName == "__CUSTOM_PRECAD_OPTIONS_END__")
2189 isOK = (load >> optValue);
2192 std::string& value = optValue;
2193 int len = value.size();
2194 // continue reading until "%#" encountered
2195 while (value[len - 1] != '#' || value[len - 2] != '%') {
2196 isOK = (load >> optValue);
2205 _customPreCADOption2value[optName] = value.substr(0,len-2);
2206 value[len - 2] = '\0'; //cut off "%#"
2210 if (hasCustomPreCADOptions) {
2211 isOK = (load >> option_or_sm);
2213 if (option_or_sm == "__SIZEMAP_BEGIN__")
2215 else if (option_or_sm == "__ATTRACTORS_BEGIN__")
2216 hasAttractor = true;
2217 else if (option_or_sm == "__NEW_ATTRACTORS_BEGIN__")
2218 hasNewAttractor = true;
2219 else if (option_or_sm == "__ENFORCED_VERTICES_BEGIN__")
2220 hasEnforcedVertex = true;
2221 else if (option_or_sm == "__PRECAD_FACES_PERIODICITY_BEGIN__")
2222 hasPreCADFacesPeriodicity = true;
2223 else if (option_or_sm == "__PRECAD_EDGES_PERIODICITY_BEGIN__")
2224 hasPreCADEdgesPeriodicity = true;
2225 else if (option_or_sm == "__FACES_PERIODICITY_BEGIN__")
2226 hasFacesPeriodicity = true;
2227 else if (option_or_sm == "__EDGES_PERIODICITY_BEGIN__")
2228 hasEdgesPeriodicity = true;
2229 else if (option_or_sm == "__VERTICES_PERIODICITY_BEGIN__")
2230 hasVerticesPeriodicity = true;
2233 std::string smEntry, smValue;
2234 while (isOK && hasSizeMap) {
2235 isOK = (load >> smEntry);
2237 if (smEntry == "__SIZEMAP_END__")
2239 isOK = (load >> smValue);
2242 std::string & value2 = _sizeMap[smEntry];
2244 int len2 = value2.size();
2245 // continue reading until "%#" encountered
2246 while (value2[len2 - 1] != '#' || value2[len2 - 2] != '%') {
2247 isOK = (load >> smValue);
2251 len2 = value2.size();
2256 value2[len2 - 2] = '\0'; //cut off "%#"
2261 isOK = (load >> option_or_sm);
2263 if (option_or_sm == "__ATTRACTORS_BEGIN__")
2264 hasAttractor = true;
2265 if (option_or_sm == "__NEW_ATTRACTORS_BEGIN__")
2266 hasNewAttractor = true;
2267 else if (option_or_sm == "__ENFORCED_VERTICES_BEGIN__")
2268 hasEnforcedVertex = true;
2269 else if (option_or_sm == "__PRECAD_FACES_PERIODICITY_BEGIN__")
2270 hasPreCADFacesPeriodicity = true;
2271 else if (option_or_sm == "__PRECAD_EDGES_PERIODICITY_BEGIN__")
2272 hasPreCADEdgesPeriodicity = true;
2273 else if (option_or_sm == "__FACES_PERIODICITY_BEGIN__")
2274 hasFacesPeriodicity = true;
2275 else if (option_or_sm == "__EDGES_PERIODICITY_BEGIN__")
2276 hasEdgesPeriodicity = true;
2277 else if (option_or_sm == "__VERTICES_PERIODICITY_BEGIN__")
2278 hasVerticesPeriodicity = true;
2281 std::string atEntry, atValue;
2282 while (isOK && hasAttractor) {
2283 isOK = (load >> atEntry);
2285 if (atEntry == "__ATTRACTORS_END__")
2287 isOK = (load >> atValue);
2290 std::string & value3 = _attractors[atEntry];
2292 int len3 = value3.size();
2293 // continue reading until "%#" encountered
2294 while (value3[len3 - 1] != '#' || value3[len3 - 2] != '%') {
2295 isOK = (load >> atValue);
2299 len3 = value3.size();
2304 value3[len3 - 2] = '\0'; //cut off "%#"
2309 isOK = (load >> option_or_sm);
2311 if (option_or_sm == "__NEW_ATTRACTORS_BEGIN__")
2312 hasNewAttractor = true;
2313 else if (option_or_sm == "__ENFORCED_VERTICES_BEGIN__")
2314 hasEnforcedVertex = true;
2315 else if (option_or_sm == "__PRECAD_FACES_PERIODICITY_BEGIN__")
2316 hasPreCADFacesPeriodicity = true;
2317 else if (option_or_sm == "__PRECAD_EDGES_PERIODICITY_BEGIN__")
2318 hasPreCADEdgesPeriodicity = true;
2319 else if (option_or_sm == "__FACES_PERIODICITY_BEGIN__")
2320 hasFacesPeriodicity = true;
2321 else if (option_or_sm == "__EDGES_PERIODICITY_BEGIN__")
2322 hasEdgesPeriodicity = true;
2323 else if (option_or_sm == "__VERTICES_PERIODICITY_BEGIN__")
2324 hasVerticesPeriodicity = true;
2327 std::string newAtFaceEntry, atTestString;
2328 std::string newAtShapeEntry;
2329 double attParams[4];
2331 while (isOK && hasNewAttractor) {
2332 //std::cout<<"Load new attractor"<<std::endl;
2333 isOK = (load >> newAtFaceEntry);
2335 if (newAtFaceEntry == "__NEW_ATTRACTORS_END__")
2337 isOK = (load >> newAtShapeEntry);
2340 isOK = (load >> attParams[0]>>attParams[1]>>attParams[2]>>attParams[3]); //>>step);
2343 MESSAGE(" LOADING ATTRACTOR HYPOTHESIS ")
2344 const TopoDS_Shape attractorShape = BLSURFPlugin_Hypothesis::entryToShape(newAtShapeEntry);
2345 const TopoDS_Face faceShape = TopoDS::Face(BLSURFPlugin_Hypothesis::entryToShape(newAtFaceEntry));
2346 BLSURFPlugin_Attractor* attractor = new BLSURFPlugin_Attractor(faceShape, attractorShape, newAtShapeEntry);//, step);
2347 attractor->SetParameters(attParams[0], attParams[1], attParams[2], attParams[3]);
2348 //attractor->BuildMap();
2349 _classAttractors.insert( make_pair( newAtFaceEntry, attractor ));
2354 if (hasNewAttractor) {
2355 isOK = (load >> option_or_sm);
2357 if (option_or_sm == "__ENFORCED_VERTICES_BEGIN__")
2358 hasEnforcedVertex = true;
2359 else if (option_or_sm == "__PRECAD_FACES_PERIODICITY_BEGIN__")
2360 hasPreCADFacesPeriodicity = true;
2361 else if (option_or_sm == "__PRECAD_EDGES_PERIODICITY_BEGIN__")
2362 hasPreCADEdgesPeriodicity = true;
2363 else if (option_or_sm == "__FACES_PERIODICITY_BEGIN__")
2364 hasFacesPeriodicity = true;
2365 else if (option_or_sm == "__EDGES_PERIODICITY_BEGIN__")
2366 hasEdgesPeriodicity = true;
2367 else if (option_or_sm == "__VERTICES_PERIODICITY_BEGIN__")
2368 hasVerticesPeriodicity = true;
2373 // Here is a example of the saved stream:
2374 // __ENFORCED_VERTICES_BEGIN__
2375 // __BEGIN_VERTEX__ => no name, no entry
2376 // __BEGIN_GROUP__ mon groupe __END_GROUP__
2377 // __BEGIN_COORDS__ 10 10 10 __END_COORDS__
2378 // __BEGIN_FACELIST__ 0:1:1:1:1 __END_FACELIST__
2380 // __BEGIN_VERTEX__ => no coords
2381 // __BEGIN_NAME__ mes points __END_NAME__
2382 // __BEGIN_ENTRY__ 0:1:1:4 __END_ENTRY__
2383 // __BEGIN_GROUP__ mon groupe __END_GROUP__
2384 // __BEGIN_FACELIST__ 0:1:1:1:3 __END_FACELIST__
2386 // __ENFORCED_VERTICES_END__
2389 std::string enfSeparator;
2390 std::string enfName;
2391 std::string enfGeomEntry;
2392 std::string enfGroup;
2393 TEntryList enfFaceEntryList;
2394 double enfCoords[3];
2395 bool hasCoords = false;
2397 _faceEntryEnfVertexListMap.clear();
2398 _enfVertexList.clear();
2399 _faceEntryCoordsListMap.clear();
2400 _coordsEnfVertexMap.clear();
2401 _faceEntryEnfVertexEntryListMap.clear();
2402 _enfVertexEntryEnfVertexMap.clear();
2405 while (isOK && hasEnforcedVertex) {
2406 isOK = (load >> enfSeparator); // __BEGIN_VERTEX__
2407 TEnfVertex *enfVertex = new TEnfVertex();
2408 // MESSAGE("enfSeparator: " <<enfSeparator);
2409 if (enfSeparator == "__ENFORCED_VERTICES_END__")
2410 break; // __ENFORCED_VERTICES_END__
2411 if (enfSeparator != "__BEGIN_VERTEX__")
2412 throw std::exception();
2415 isOK = (load >> enfSeparator);
2416 MESSAGE("enfSeparator: " <<enfSeparator);
2417 if (enfSeparator == "__END_VERTEX__") {
2419 enfVertex->name = enfName;
2420 enfVertex->geomEntry = enfGeomEntry;
2421 enfVertex->grpName = enfGroup;
2422 enfVertex->coords.clear();
2424 enfVertex->coords.assign(enfCoords,enfCoords+3);
2425 enfVertex->faceEntries = enfFaceEntryList;
2427 _enfVertexList.insert(enfVertex);
2429 if (enfVertex->coords.size()) {
2430 _coordsEnfVertexMap[enfVertex->coords] = enfVertex;
2431 for (TEntryList::const_iterator it = enfVertex->faceEntries.begin() ; it != enfVertex->faceEntries.end(); ++it) {
2432 _faceEntryCoordsListMap[(*it)].insert(enfVertex->coords);
2433 _faceEntryEnfVertexListMap[(*it)].insert(enfVertex);
2436 if (!enfVertex->geomEntry.empty()) {
2437 _enfVertexEntryEnfVertexMap[enfVertex->geomEntry] = enfVertex;
2438 for (TEntryList::const_iterator it = enfVertex->faceEntries.begin() ; it != enfVertex->faceEntries.end(); ++it) {
2439 _faceEntryEnfVertexEntryListMap[(*it)].insert(enfVertex->geomEntry);
2440 _faceEntryEnfVertexListMap[(*it)].insert(enfVertex);
2445 enfGeomEntry.clear();
2447 enfFaceEntryList.clear();
2449 break; // __END_VERTEX__
2452 if (enfSeparator == "__BEGIN_NAME__") { // __BEGIN_NAME__
2453 while (isOK && (enfSeparator != "__END_NAME__")) {
2454 isOK = (load >> enfSeparator);
2455 if (enfSeparator != "__END_NAME__") {
2456 if (!enfName.empty())
2458 enfName += enfSeparator;
2461 MESSAGE("enfName: " <<enfName);
2464 if (enfSeparator == "__BEGIN_ENTRY__") { // __BEGIN_ENTRY__
2465 isOK = (load >> enfGeomEntry);
2466 isOK = (load >> enfSeparator); // __END_ENTRY__
2467 if (enfSeparator != "__END_ENTRY__")
2468 throw std::exception();
2469 MESSAGE("enfGeomEntry: " <<enfGeomEntry);
2472 if (enfSeparator == "__BEGIN_GROUP__") { // __BEGIN_GROUP__
2473 while (isOK && (enfSeparator != "__END_GROUP__")) {
2474 isOK = (load >> enfSeparator);
2475 if (enfSeparator != "__END_GROUP__") {
2476 if (!enfGroup.empty())
2478 enfGroup += enfSeparator;
2481 MESSAGE("enfGroup: " <<enfGroup);
2484 if (enfSeparator == "__BEGIN_COORDS__") { // __BEGIN_COORDS__
2486 isOK = (load >> enfCoords[0] >> enfCoords[1] >> enfCoords[2]);
2487 isOK = (load >> enfSeparator); // __END_COORDS__
2488 if (enfSeparator != "__END_COORDS__")
2489 throw std::exception();
2490 MESSAGE("enfCoords: " << enfCoords[0] <<","<< enfCoords[1] <<","<< enfCoords[2]);
2493 if (enfSeparator == "__BEGIN_FACELIST__") { // __BEGIN_FACELIST__
2494 while (isOK && (enfSeparator != "__END_FACELIST__")) {
2495 isOK = (load >> enfSeparator);
2496 if (enfSeparator != "__END_FACELIST__") {
2497 enfFaceEntryList.insert(enfSeparator);
2498 MESSAGE(enfSeparator << " was inserted into enfFaceEntryList");
2507 if (hasPreCADFacesPeriodicity){
2508 LoadPreCADPeriodicity(load, "FACES");
2510 isOK = (load >> option_or_sm);
2512 if (option_or_sm == "__PRECAD_EDGES_PERIODICITY_BEGIN__")
2513 hasPreCADEdgesPeriodicity = true;
2514 else if (option_or_sm == "__FACES_PERIODICITY_BEGIN__")
2515 hasFacesPeriodicity = true;
2516 else if (option_or_sm == "__EDGES_PERIODICITY_BEGIN__")
2517 hasEdgesPeriodicity = true;
2518 else if (option_or_sm == "__VERTICES_PERIODICITY_BEGIN__")
2519 hasVerticesPeriodicity = true;
2522 if (hasPreCADEdgesPeriodicity){
2523 LoadPreCADPeriodicity(load, "EDGES");
2525 isOK = (load >> option_or_sm);
2527 if (option_or_sm == "__FACES_PERIODICITY_BEGIN__")
2528 hasFacesPeriodicity = true;
2529 else if (option_or_sm == "__EDGES_PERIODICITY_BEGIN__")
2530 hasEdgesPeriodicity = true;
2531 else if (option_or_sm == "__VERTICES_PERIODICITY_BEGIN__")
2532 hasVerticesPeriodicity = true;
2535 if (hasFacesPeriodicity){
2536 LoadFacesPeriodicity(load);
2538 isOK = (load >> option_or_sm);
2540 if (option_or_sm == "__EDGES_PERIODICITY_BEGIN__")
2541 hasEdgesPeriodicity = true;
2542 else if (option_or_sm == "__VERTICES_PERIODICITY_BEGIN__")
2543 hasVerticesPeriodicity = true;
2546 if (hasEdgesPeriodicity){
2547 LoadEdgesPeriodicity(load);
2549 isOK = (load >> option_or_sm);
2551 if (option_or_sm == "__VERTICES_PERIODICITY_BEGIN__")
2552 hasVerticesPeriodicity = true;
2555 if (hasVerticesPeriodicity)
2556 LoadVerticesPeriodicity(load);
2561 void BLSURFPlugin_Hypothesis::LoadFacesPeriodicity(std::istream & load){
2565 std::string periodicitySeparator;
2569 _facesPeriodicityVector.clear();
2572 isOK = (load >> periodicitySeparator); // __BEGIN_PERIODICITY_DESCRIPTION__
2573 MESSAGE("periodicitySeparator 1: " <<periodicitySeparator);
2574 TFacesPeriodicity *periodicity_i = new TFacesPeriodicity();
2575 if (periodicitySeparator == "__FACES_PERIODICITY_END__")
2576 break; // __FACES_PERIODICITY_END__
2577 if (periodicitySeparator != "__BEGIN_PERIODICITY_DESCRIPTION__"){
2578 MESSAGE("//" << periodicitySeparator << "//");
2579 throw std::exception();
2583 isOK = (load >> periodicitySeparator);
2584 MESSAGE("periodicitySeparator 2: " <<periodicitySeparator);
2585 if (periodicitySeparator == "__END_PERIODICITY_DESCRIPTION__") {
2587 periodicity_i->first = shape1Entry;
2588 periodicity_i->second = shape2Entry;
2590 _facesPeriodicityVector.push_back(*periodicity_i);
2592 break; // __END_PERIODICITY_DESCRIPTION__
2595 if (periodicitySeparator == "__BEGIN_ENTRY1__") { // __BEGIN_ENTRY1__
2596 isOK = (load >> shape1Entry);
2597 isOK = (load >> periodicitySeparator); // __END_ENTRY1__
2598 if (periodicitySeparator != "__END_ENTRY1__")
2599 throw std::exception();
2600 MESSAGE("shape1Entry: " <<shape1Entry);
2603 if (periodicitySeparator == "__BEGIN_ENTRY2__") { // __BEGIN_ENTRY2__
2604 isOK = (load >> shape2Entry);
2605 isOK = (load >> periodicitySeparator); // __END_ENTRY2__
2606 if (periodicitySeparator != "__END_ENTRY2__")
2607 throw std::exception();
2608 MESSAGE("shape2Entry: " <<shape2Entry);
2615 void BLSURFPlugin_Hypothesis::LoadEdgesPeriodicity(std::istream & load){
2619 std::string periodicitySeparator;
2620 TEntry theFace1Entry;
2621 TEntry theEdge1Entry;
2622 TEntry theFace2Entry;
2623 TEntry theEdge2Entry;
2624 int edge_orientation = 0;
2626 _edgesPeriodicityVector.clear();
2629 isOK = (load >> periodicitySeparator); // __BEGIN_PERIODICITY_DESCRIPTION__
2630 MESSAGE("periodicitySeparator 1: " <<periodicitySeparator);
2631 TEdgePeriodicity *periodicity_i = new TEdgePeriodicity();
2632 if (periodicitySeparator == "__EDGES_PERIODICITY_END__")
2633 break; // __EDGES_PERIODICITY_END__
2634 if (periodicitySeparator != "__BEGIN_PERIODICITY_DESCRIPTION__"){
2635 MESSAGE("//" << periodicitySeparator << "//");
2636 throw std::exception();
2640 isOK = (load >> periodicitySeparator);
2641 MESSAGE("periodicitySeparator 2: " <<periodicitySeparator);
2642 if (periodicitySeparator == "__END_PERIODICITY_DESCRIPTION__") {
2644 periodicity_i->theFace1Entry = theFace1Entry;
2645 periodicity_i->theEdge1Entry = theEdge1Entry;
2646 periodicity_i->theFace2Entry = theFace2Entry;
2647 periodicity_i->theEdge2Entry = theEdge2Entry;
2648 periodicity_i->edge_orientation = edge_orientation;
2650 _edgesPeriodicityVector.push_back(*periodicity_i);
2652 break; // __END_PERIODICITY_DESCRIPTION__
2655 if (periodicitySeparator == "__BEGIN_FACE1__") { // __BEGIN_FACE1__
2656 isOK = (load >> theFace1Entry);
2657 MESSAGE("//" << theFace1Entry << "//");
2658 isOK = (load >> periodicitySeparator); // __END_FACE1__
2659 if (periodicitySeparator != "__END_FACE1__"){
2660 MESSAGE("//" << periodicitySeparator << "//");
2661 throw std::exception();
2663 MESSAGE("theFace1Entry: " <<theFace1Entry);
2666 if (periodicitySeparator == "__BEGIN_EDGE1__") { // __BEGIN_EDGE1__
2667 isOK = (load >> theEdge1Entry);
2668 isOK = (load >> periodicitySeparator); // __END_EDGE1__
2669 if (periodicitySeparator != "__END_EDGE1__")
2670 throw std::exception();
2671 MESSAGE("theEdge1Entry: " <<theEdge1Entry);
2674 if (periodicitySeparator == "__BEGIN_FACE2__") { // __BEGIN_FACE2__
2675 isOK = (load >> theFace2Entry);
2676 isOK = (load >> periodicitySeparator); // __END_FACE2__
2677 if (periodicitySeparator != "__END_FACE2__")
2678 throw std::exception();
2679 MESSAGE("theFace2Entry: " <<theFace2Entry);
2682 if (periodicitySeparator == "__BEGIN_EDGE2__") { // __BEGIN_EDGE2__
2683 isOK = (load >> theEdge2Entry);
2684 isOK = (load >> periodicitySeparator); // __END_EDGE2__
2685 if (periodicitySeparator != "__END_EDGE2__")
2686 throw std::exception();
2687 MESSAGE("theEdge2Entry: " <<theEdge2Entry);
2690 if (periodicitySeparator == "__BEGIN_EDGE_ORIENTATION__") { // __BEGIN_EDGE_ORIENTATION__
2691 isOK = (load >> edge_orientation);
2692 isOK = (load >> periodicitySeparator); // __END_EDGE_ORIENTATION__
2693 if (periodicitySeparator != "__END_EDGE_ORIENTATION__")
2694 throw std::exception();
2695 MESSAGE("edge_orientation: " <<edge_orientation);
2701 void BLSURFPlugin_Hypothesis::LoadVerticesPeriodicity(std::istream & load){
2705 std::string periodicitySeparator;
2706 TEntry theEdge1Entry;
2707 TEntry theVertex1Entry;
2708 TEntry theEdge2Entry;
2709 TEntry theVertex2Entry;
2711 _verticesPeriodicityVector.clear();
2714 isOK = (load >> periodicitySeparator); // __BEGIN_PERIODICITY_DESCRIPTION__
2715 MESSAGE("periodicitySeparator 1: " <<periodicitySeparator);
2716 TVertexPeriodicity *periodicity_i = new TVertexPeriodicity();
2717 if (periodicitySeparator == "__VERTICES_PERIODICITY_END__")
2718 break; // __VERTICES_PERIODICITY_END__
2719 if (periodicitySeparator != "__BEGIN_PERIODICITY_DESCRIPTION__"){
2720 MESSAGE("//" << periodicitySeparator << "//");
2721 throw std::exception();
2725 isOK = (load >> periodicitySeparator);
2726 MESSAGE("periodicitySeparator 2: " <<periodicitySeparator);
2727 if (periodicitySeparator == "__END_PERIODICITY_DESCRIPTION__") {
2729 periodicity_i->theEdge1Entry = theEdge1Entry;
2730 periodicity_i->theVertex1Entry = theVertex1Entry;
2731 periodicity_i->theEdge2Entry = theEdge2Entry;
2732 periodicity_i->theVertex2Entry = theVertex2Entry;
2734 _verticesPeriodicityVector.push_back(*periodicity_i);
2736 break; // __END_PERIODICITY_DESCRIPTION__
2739 if (periodicitySeparator == "__BEGIN_EDGE1__") { // __BEGIN_EDGE1__
2740 isOK = (load >> theEdge1Entry);
2741 isOK = (load >> periodicitySeparator); // __END_EDGE1__
2742 if (periodicitySeparator != "__END_EDGE1__")
2743 throw std::exception();
2744 MESSAGE("theEdge1Entry: " <<theEdge1Entry);
2747 if (periodicitySeparator == "__BEGIN_VERTEX1__") { // __BEGIN_VERTEX1__
2748 isOK = (load >> theVertex1Entry);
2749 isOK = (load >> periodicitySeparator); // __END_VERTEX1__
2750 if (periodicitySeparator != "__END_VERTEX1__")
2751 throw std::exception();
2752 MESSAGE("theVertex1Entry: " <<theVertex1Entry);
2755 if (periodicitySeparator == "__BEGIN_EDGE2__") { // __BEGIN_EDGE2__
2756 isOK = (load >> theEdge2Entry);
2757 isOK = (load >> periodicitySeparator); // __END_EDGE2__
2758 if (periodicitySeparator != "__END_EDGE2__")
2759 throw std::exception();
2760 MESSAGE("theEdge2Entry: " <<theEdge2Entry);
2763 if (periodicitySeparator == "__BEGIN_VERTEX2__") { // __BEGIN_VERTEX2__
2764 isOK = (load >> theVertex2Entry);
2765 isOK = (load >> periodicitySeparator); // __END_VERTEX2__
2766 if (periodicitySeparator != "__END_VERTEX2__")
2767 throw std::exception();
2768 MESSAGE("theVertex2Entry: " <<theVertex2Entry);
2774 void BLSURFPlugin_Hypothesis::LoadPreCADPeriodicity(std::istream & load, const char* shapeType) {
2778 std::string periodicitySeparator;
2781 std::vector<std::string> theSourceVerticesEntries;
2782 std::vector<std::string> theTargetVerticesEntries;
2784 bool hasSourceVertices = false;
2785 bool hasTargetVertices = false;
2787 if (shapeType == "FACES")
2788 _preCadFacesPeriodicityVector.clear();
2790 _preCadEdgesPeriodicityVector.clear();
2794 isOK = (load >> periodicitySeparator); // __BEGIN_PERIODICITY_DESCRIPTION__
2795 MESSAGE("periodicitySeparator 1: " <<periodicitySeparator);
2796 TPreCadPeriodicity *periodicity_i = new TPreCadPeriodicity();
2797 // MESSAGE("periodicitySeparator: " <<periodicitySeparator);
2798 std::string endSeparator = "__PRECAD_" + std::string(shapeType) + "_PERIODICITY_END__";
2799 if (periodicitySeparator == endSeparator)
2800 break; // __PRECAD_FACES_PERIODICITY_END__
2801 if (periodicitySeparator != "__BEGIN_PERIODICITY_DESCRIPTION__"){
2802 MESSAGE("//" << endSeparator << "//");
2803 MESSAGE("//" << periodicitySeparator << "//");
2804 throw std::exception();
2808 isOK = (load >> periodicitySeparator);
2809 MESSAGE("periodicitySeparator 2: " <<periodicitySeparator);
2810 if (periodicitySeparator == "__END_PERIODICITY_DESCRIPTION__") {
2812 periodicity_i->shape1Entry = shape1Entry;
2813 periodicity_i->shape2Entry = shape2Entry;
2815 MESSAGE("theSourceVerticesEntries.size(): " << theSourceVerticesEntries.size());
2816 MESSAGE("theTargetVerticesEntries.size(): " << theTargetVerticesEntries.size());
2818 if (hasSourceVertices)
2819 periodicity_i->theSourceVerticesEntries = theSourceVerticesEntries;
2820 if (hasTargetVertices)
2821 periodicity_i->theTargetVerticesEntries = theTargetVerticesEntries;
2823 if (shapeType == "FACES")
2824 _preCadFacesPeriodicityVector.push_back(*periodicity_i);
2826 _preCadEdgesPeriodicityVector.push_back(*periodicity_i);
2828 theSourceVerticesEntries.clear();
2829 theTargetVerticesEntries.clear();
2830 hasSourceVertices = false;
2831 hasTargetVertices = false;
2832 break; // __END_PERIODICITY_DESCRIPTION__
2835 if (periodicitySeparator == "__BEGIN_ENTRY1__") { // __BEGIN_ENTRY1__
2836 isOK = (load >> shape1Entry);
2837 isOK = (load >> periodicitySeparator); // __END_ENTRY1__
2838 if (periodicitySeparator != "__END_ENTRY1__")
2839 throw std::exception();
2840 MESSAGE("shape1Entry: " <<shape1Entry);
2843 if (periodicitySeparator == "__BEGIN_ENTRY2__") { // __BEGIN_ENTRY2__
2844 isOK = (load >> shape2Entry);
2845 isOK = (load >> periodicitySeparator); // __END_ENTRY2__
2846 if (periodicitySeparator != "__END_ENTRY2__")
2847 throw std::exception();
2848 MESSAGE("shape2Entry: " <<shape2Entry);
2851 if (periodicitySeparator == "__BEGIN_SOURCE_VERTICES_LIST__") { // __BEGIN_SOURCE_VERTICES_LIST__
2852 hasSourceVertices = true;
2853 while (isOK && (periodicitySeparator != "__END_SOURCE_VERTICES_LIST__")) {
2854 isOK = (load >> periodicitySeparator);
2855 if (periodicitySeparator != "__END_SOURCE_VERTICES_LIST__") {
2856 theSourceVerticesEntries.push_back(periodicitySeparator);
2857 MESSAGE("theSourceVerticesEntries: " <<periodicitySeparator);
2862 if (periodicitySeparator == "__BEGIN_TARGET_VERTICES_LIST__") { // __BEGIN_TARGET_VERTICES_LIST__
2863 hasTargetVertices = true;
2864 while (isOK && (periodicitySeparator != "__END_TARGET_VERTICES_LIST__")) {
2865 isOK = (load >> periodicitySeparator);
2866 if (periodicitySeparator != "__END_TARGET_VERTICES_LIST__") {
2867 theTargetVerticesEntries.push_back(periodicitySeparator);
2868 MESSAGE("theTargetVerticesEntries: " <<periodicitySeparator);
2876 //=============================================================================
2877 std::ostream & operator <<(std::ostream & save, BLSURFPlugin_Hypothesis & hyp) {
2878 return hyp.SaveTo(save);
2881 //=============================================================================
2882 std::istream & operator >>(std::istream & load, BLSURFPlugin_Hypothesis & hyp) {
2883 return hyp.LoadFrom(load);
2886 //================================================================================
2888 * \brief Does nothing
2890 //================================================================================
2892 bool BLSURFPlugin_Hypothesis::SetParametersByMesh(const SMESH_Mesh* theMesh, const TopoDS_Shape& theShape) {
2896 //================================================================================
2898 * \brief Returns default global constant physical size given a default value of element length ratio
2900 //================================================================================
2902 double BLSURFPlugin_Hypothesis::GetDefaultPhySize(double diagonal, double bbSegmentation) {
2903 if (bbSegmentation != 0 && diagonal != 0)
2904 return diagonal / bbSegmentation ;
2908 //================================================================================
2910 * \brief Returns default min size given a default value of element length ratio
2912 //================================================================================
2914 double BLSURFPlugin_Hypothesis::GetDefaultMinSize(double diagonal) {
2916 return diagonal / 1000.0 ;
2917 return undefinedDouble();
2920 //================================================================================
2922 * \brief Returns default max size given a default value of element length ratio
2924 //================================================================================
2926 double BLSURFPlugin_Hypothesis::GetDefaultMaxSize(double diagonal) {
2928 return diagonal / 5.0 ;
2929 return undefinedDouble();
2932 //================================================================================
2934 * \brief Returns default chordal error given a default value of element length ratio
2936 //================================================================================
2938 double BLSURFPlugin_Hypothesis::GetDefaultChordalError(double diagonal) {
2941 return undefinedDouble();
2944 //================================================================================
2946 * \brief Returns default tiny edge length given a default value of element length ratio
2948 //================================================================================
2950 double BLSURFPlugin_Hypothesis::GetDefaultTinyEdgeLength(double diagonal) {
2952 return diagonal * 1e-6 ;
2953 return undefinedDouble();
2956 //=============================================================================
2958 * \brief Initialize my parameter values by default parameters.
2959 * \retval bool - true if parameter values have been successfully defined
2961 //=============================================================================
2963 bool BLSURFPlugin_Hypothesis::SetParametersByDefaults(const TDefaults& dflts, const SMESH_Mesh* theMesh) {
2964 double diagonal = dflts._elemLength*_gen->GetBoundaryBoxSegmentation();
2965 _phySize = GetDefaultPhySize(diagonal, _gen->GetBoundaryBoxSegmentation());
2966 _minSize = GetDefaultMinSize(diagonal);
2967 _maxSize = GetDefaultMaxSize(diagonal);
2968 _chordalError = GetDefaultChordalError(diagonal);
2969 _tinyEdgeLength = GetDefaultTinyEdgeLength(diagonal);
2972 // return bool(_phySize = dflts._elemLength);