1 // Copyright (C) 2007-2014 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
102 const char* intOptionNames[] = { "hinterpol_flag", // ok default = 0
103 "hmean_flag", // ok default = 0
104 "max_number_of_points_per_patch", // default = 100000
105 "prox_nb_layer", // detects the volumic proximity of surfaces
108 const char* doubleOptionNames[] = { "surface_intersections_processing_max_cost",// default = 15
109 "periodic_tolerance", // default = diag/100
114 const char* charOptionNames[] = { "required_entities", // default = "respect"
115 "tags", // default = "respect"
119 // PreCAD advanced options
120 const char* preCADboolOptionNames[] = { "closed_geometry", // default = 0
121 "create_tag_on_collision", // default = 1
122 "debug", // default = 0
123 "remove_tiny_edges", // default = 0
126 const char* preCADintOptionNames[] = { "manifold_geometry", // default = 0
129 const char* preCADdoubleOptionNames[] = { "periodic_tolerance", // default = diag * 1e-5
130 "sewing_tolerance", // default = diag * 5e-4
131 "tiny_edge_length", // default = diag * 1e-5
134 const char* preCADcharOptionNames[] = { "required_entities", // default = "respect"
135 "tags", // default = "respect"
140 while (boolOptionNames[i][0])
141 _option2value[boolOptionNames[i++]].clear();
144 while (preCADboolOptionNames[i][0])
145 _preCADoption2value[preCADboolOptionNames[i++]].clear();
148 while (intOptionNames[i][0])
149 _option2value[intOptionNames[i++]].clear();
152 while (preCADintOptionNames[i][0])
153 _preCADoption2value[preCADintOptionNames[i++]].clear();
156 while (doubleOptionNames[i][0]) {
157 _doubleOptions.insert(doubleOptionNames[i]);
158 _option2value[doubleOptionNames[i++]].clear();
161 while (preCADdoubleOptionNames[i][0]) {
162 _preCADdoubleOptions.insert(preCADdoubleOptionNames[i]);
163 _preCADoption2value[preCADdoubleOptionNames[i++]].clear();
166 while (charOptionNames[i][0]) {
167 _charOptions.insert(charOptionNames[i]);
168 _option2value[charOptionNames[i++]].clear();
171 while (preCADcharOptionNames[i][0]) {
172 _preCADcharOptions.insert(preCADcharOptionNames[i]);
173 _preCADoption2value[preCADcharOptionNames[i++]].clear();
180 _faceEntryEnfVertexListMap.clear();
181 _enfVertexList.clear();
182 _faceEntryCoordsListMap.clear();
183 _coordsEnfVertexMap.clear();
184 _faceEntryEnfVertexEntryListMap.clear();
185 _enfVertexEntryEnfVertexMap.clear();
186 _groupNameNodeIDMap.clear();
189 _groupNameEnfVertexListMap.clear();
190 _enfVertexGroupNameMap.clear();
194 TopoDS_Shape BLSURFPlugin_Hypothesis::entryToShape(std::string entry)
196 MESSAGE("BLSURFPlugin_Hypothesis::entryToShape "<<entry );
197 GEOM::GEOM_Object_var aGeomObj;
198 SMESH_Gen_i* smeshGen_i = SMESH_Gen_i::GetSMESHGen();
199 SALOMEDS::Study_ptr myStudy = smeshGen_i->GetCurrentStudy();
201 TopoDS_Shape S = TopoDS_Shape();
202 SALOMEDS::SObject_var aSObj = myStudy->FindObjectID( entry.c_str() );
203 if (!aSObj->_is_nil() ) {
204 CORBA::Object_var obj = aSObj->GetObject();
205 aGeomObj = GEOM::GEOM_Object::_narrow(obj);
208 if ( !aGeomObj->_is_nil() )
209 S = smeshGen_i->GeomObjectToShape( aGeomObj.in() );
213 //=============================================================================
214 void BLSURFPlugin_Hypothesis::SetPhysicalMesh(PhysicalMesh thePhysicalMesh) {
215 if (thePhysicalMesh != _physicalMesh) {
216 _physicalMesh = thePhysicalMesh;
217 NotifySubMeshesHypothesisModification();
221 //=============================================================================
222 void BLSURFPlugin_Hypothesis::SetGeometricMesh(GeometricMesh theGeometricMesh) {
223 if (theGeometricMesh != _geometricMesh) {
224 _geometricMesh = theGeometricMesh;
225 // switch (_geometricMesh) {
228 // _angleMesh = GetDefaultAngleMesh();
229 // _gradation = GetDefaultGradation();
232 NotifySubMeshesHypothesisModification();
236 //=============================================================================
237 void BLSURFPlugin_Hypothesis::SetPhySize(double theVal, bool isRelative) {
238 if ((theVal != _phySize) || (isRelative != _phySizeRel)) {
239 _phySizeRel = isRelative;
241 _phySize = GetMaxSize();
242 MESSAGE("Warning: nul physical size is not allowed");
246 NotifySubMeshesHypothesisModification();
250 //=============================================================================
251 void BLSURFPlugin_Hypothesis::SetMinSize(double theMinSize, bool isRelative) {
252 if ((theMinSize != _minSize) || (isRelative != _minSizeRel)) {
253 _minSizeRel = isRelative;
254 _minSize = theMinSize;
255 NotifySubMeshesHypothesisModification();
259 //=============================================================================
260 void BLSURFPlugin_Hypothesis::SetMaxSize(double theMaxSize, bool isRelative) {
261 if ((theMaxSize != _maxSize) || (isRelative != _maxSizeRel)) {
262 _maxSizeRel = isRelative;
263 _maxSize = theMaxSize;
264 NotifySubMeshesHypothesisModification();
268 //=============================================================================
269 void BLSURFPlugin_Hypothesis::SetGradation(double theVal) {
270 if (theVal != _gradation) {
272 NotifySubMeshesHypothesisModification();
276 //=============================================================================
277 void BLSURFPlugin_Hypothesis::SetQuadAllowed(bool theVal) {
278 if (theVal != _quadAllowed) {
279 _quadAllowed = theVal;
280 NotifySubMeshesHypothesisModification();
284 //=============================================================================
285 void BLSURFPlugin_Hypothesis::SetAngleMesh(double theVal) {
286 if (theVal != _angleMesh) {
288 NotifySubMeshesHypothesisModification();
292 //=============================================================================
293 void BLSURFPlugin_Hypothesis::SetChordalError(double theDistance) {
294 if (theDistance != _chordalError) {
295 _chordalError = theDistance;
296 NotifySubMeshesHypothesisModification();
300 //=============================================================================
301 void BLSURFPlugin_Hypothesis::SetAnisotropic(bool theVal) {
302 if (theVal != _anisotropic) {
303 _anisotropic = theVal;
304 NotifySubMeshesHypothesisModification();
308 //=============================================================================
309 void BLSURFPlugin_Hypothesis::SetAnisotropicRatio(double theVal) {
310 if (theVal != _anisotropicRatio) {
311 _anisotropicRatio = theVal;
312 NotifySubMeshesHypothesisModification();
316 //=============================================================================
317 void BLSURFPlugin_Hypothesis::SetRemoveTinyEdges(bool theVal) {
318 if (theVal != _removeTinyEdges) {
319 _removeTinyEdges = theVal;
320 NotifySubMeshesHypothesisModification();
324 //=============================================================================
325 void BLSURFPlugin_Hypothesis::SetTinyEdgeLength(double theVal) {
326 if (theVal != _tinyEdgeLength) {
327 _tinyEdgeLength = theVal;
328 NotifySubMeshesHypothesisModification();
332 //=============================================================================
333 void BLSURFPlugin_Hypothesis::SetBadElementRemoval(bool theVal) {
334 if (theVal != _badElementRemoval) {
335 _badElementRemoval = theVal;
336 NotifySubMeshesHypothesisModification();
340 //=============================================================================
341 void BLSURFPlugin_Hypothesis::SetBadElementAspectRatio(double theVal) {
342 if (theVal != _badElementAspectRatio) {
343 _badElementAspectRatio = theVal;
344 NotifySubMeshesHypothesisModification();
348 //=============================================================================
349 void BLSURFPlugin_Hypothesis::SetOptimizeMesh(bool theVal) {
350 if (theVal != _optimizeMesh) {
351 _optimizeMesh = theVal;
352 NotifySubMeshesHypothesisModification();
356 //=============================================================================
357 void BLSURFPlugin_Hypothesis::SetQuadraticMesh(bool theVal) {
358 if (theVal != _quadraticMesh) {
359 _quadraticMesh = theVal;
360 NotifySubMeshesHypothesisModification();
364 //=============================================================================
365 void BLSURFPlugin_Hypothesis::SetTopology(Topology theTopology) {
366 if (theTopology != _topology) {
367 _topology = theTopology;
368 NotifySubMeshesHypothesisModification();
372 //=============================================================================
373 void BLSURFPlugin_Hypothesis::SetVerbosity(int theVal) {
374 if (theVal != _verb) {
376 NotifySubMeshesHypothesisModification();
380 //=============================================================================
381 void BLSURFPlugin_Hypothesis::SetPreCADMergeEdges(bool theVal) {
382 if (theVal != _preCADMergeEdges) {
383 // SetTopology(PreCAD);
384 _preCADMergeEdges = theVal;
385 NotifySubMeshesHypothesisModification();
389 //=============================================================================
390 void BLSURFPlugin_Hypothesis::SetPreCADProcess3DTopology(bool theVal) {
391 if (theVal != _preCADProcess3DTopology) {
392 // SetTopology(PreCAD);
393 _preCADProcess3DTopology = theVal;
394 NotifySubMeshesHypothesisModification();
398 //=============================================================================
399 void BLSURFPlugin_Hypothesis::SetPreCADDiscardInput(bool theVal) {
400 if (theVal != _preCADDiscardInput) {
401 // SetTopology(PreCAD);
402 _preCADDiscardInput = theVal;
403 NotifySubMeshesHypothesisModification();
407 //=============================================================================
408 // void BLSURFPlugin_Hypothesis::SetGMFFile(const std::string& theFileName, bool isBinary)
409 void BLSURFPlugin_Hypothesis::SetGMFFile(const std::string& theFileName)
411 _GMFFileName = theFileName;
412 // _GMFFileMode = isBinary;
413 NotifySubMeshesHypothesisModification();
416 //=============================================================================
417 void BLSURFPlugin_Hypothesis::SetOptionValue(const std::string& optionName, const std::string& optionValue)
418 throw (std::invalid_argument) {
419 TOptionValues::iterator op_val = _option2value.find(optionName);
420 if (op_val == _option2value.end()) {
421 std::string msg = "Unknown MG-CADSurf option: '" + optionName + "'";
422 throw std::invalid_argument(msg);
424 if (op_val->second != optionValue) {
425 const char* ptr = optionValue.c_str();
426 // strip white spaces
427 while (ptr[0] == ' ')
430 while (i != 0 && ptr[i - 1] == ' ')
434 std::string typeName;
437 } else if (_charOptions.find(optionName) != _charOptions.end()) {
438 // do not check strings
439 } else if (_doubleOptions.find(optionName) != _doubleOptions.end()) {
440 // check if value is double
442 strtod(ptr, &endPtr);
443 typeOk = (ptr != endPtr);
446 // check if value is int
448 strtol(ptr, &endPtr, 10);
449 typeOk = (ptr != endPtr);
450 typeName = "integer";
453 std::string msg = "Advanced option '" + optionName + "' = '" + optionValue + "' but must be " + typeName;
454 throw std::invalid_argument(msg);
456 op_val->second = optionValue;
457 NotifySubMeshesHypothesisModification();
461 //=============================================================================
462 void BLSURFPlugin_Hypothesis::SetPreCADOptionValue(const std::string& optionName, const std::string& optionValue)
463 throw (std::invalid_argument) {
464 TOptionValues::iterator op_val = _preCADoption2value.find(optionName);
465 if (op_val == _preCADoption2value.end()) {
466 std::string msg = "Unknown MG-CADSurf option: '" + optionName + "'";
467 throw std::invalid_argument(msg);
469 if (op_val->second != optionValue) {
470 const char* ptr = optionValue.c_str();
471 // strip white spaces
472 while (ptr[0] == ' ')
475 while (i != 0 && ptr[i - 1] == ' ')
479 std::string typeName;
482 } else if (_preCADcharOptions.find(optionName) != _preCADcharOptions.end()) {
483 // do not check strings
484 } else if (_preCADdoubleOptions.find(optionName) != _preCADdoubleOptions.end()) {
485 // check if value is double
487 strtod(ptr, &endPtr);
488 typeOk = (ptr != endPtr);
491 // check if value is int
493 strtol(ptr, &endPtr, 10);
494 typeOk = (ptr != endPtr);
495 typeName = "integer";
498 std::string msg = "PreCAD advanced option '" + optionName + "' = '" + optionValue + "' but must be " + typeName;
499 throw std::invalid_argument(msg);
501 op_val->second = optionValue;
502 NotifySubMeshesHypothesisModification();
506 //=============================================================================
507 std::string BLSURFPlugin_Hypothesis::GetOptionValue(const std::string& optionName) throw (std::invalid_argument) {
508 TOptionValues::iterator op_val = _option2value.find(optionName);
509 if (op_val == _option2value.end()) {
510 std::string msg = "Unknown MG-CADSurf option: <";
511 msg += optionName + ">";
512 throw std::invalid_argument(msg);
514 return op_val->second;
517 //=============================================================================
518 std::string BLSURFPlugin_Hypothesis::GetPreCADOptionValue(const std::string& optionName) throw (std::invalid_argument) {
519 TOptionValues::iterator op_val = _preCADoption2value.find(optionName);
520 if (op_val == _preCADoption2value.end()) {
521 std::string msg = "Unknown PRECAD option: <";
522 msg += optionName + ">";
523 throw std::invalid_argument(msg);
525 return op_val->second;
528 //=============================================================================
529 void BLSURFPlugin_Hypothesis::ClearOption(const std::string& optionName) {
530 TOptionValues::iterator op_val = _option2value.find(optionName);
531 if (op_val != _option2value.end())
532 op_val->second.clear();
535 //=============================================================================
536 void BLSURFPlugin_Hypothesis::ClearPreCADOption(const std::string& optionName) {
537 TOptionValues::iterator op_val = _preCADoption2value.find(optionName);
538 if (op_val != _preCADoption2value.end())
539 op_val->second.clear();
542 //=======================================================================
543 //function : SetSizeMapEntry
544 //=======================================================================
545 void BLSURFPlugin_Hypothesis::SetSizeMapEntry(const std::string& entry, const std::string& sizeMap) {
546 if (_sizeMap[entry].compare(sizeMap) != 0) {
547 SetPhysicalMesh(PhysicalLocalSize);
548 _sizeMap[entry] = sizeMap;
549 NotifySubMeshesHypothesisModification();
553 //=======================================================================
554 //function : GetSizeMapEntry
555 //=======================================================================
556 std::string BLSURFPlugin_Hypothesis::GetSizeMapEntry(const std::string& entry) {
557 TSizeMap::iterator it = _sizeMap.find(entry);
558 if (it != _sizeMap.end())
561 return "No_Such_Entry";
565 * \brief Return the size maps
567 BLSURFPlugin_Hypothesis::TSizeMap BLSURFPlugin_Hypothesis::GetSizeMapEntries(const BLSURFPlugin_Hypothesis* hyp) {
568 return hyp ? hyp->_GetSizeMapEntries() : GetDefaultSizeMap();
571 //=======================================================================
572 //function : SetAttractorEntry
573 //=======================================================================
574 void BLSURFPlugin_Hypothesis::SetAttractorEntry(const std::string& entry, const std::string& attractor) {
575 if (_attractors[entry].compare(attractor) != 0) {
576 SetPhysicalMesh(PhysicalLocalSize);
577 _attractors[entry] = attractor;
578 NotifySubMeshesHypothesisModification();
582 //=======================================================================
583 //function : GetAttractorEntry
584 //=======================================================================
585 std::string BLSURFPlugin_Hypothesis::GetAttractorEntry(const std::string& entry) {
586 TSizeMap::iterator it = _attractors.find(entry);
587 if (it != _attractors.end())
590 return "No_Such_Entry";
594 * \brief Return the attractors
596 BLSURFPlugin_Hypothesis::TSizeMap BLSURFPlugin_Hypothesis::GetAttractorEntries(const BLSURFPlugin_Hypothesis* hyp) {
597 return hyp ? hyp->_GetAttractorEntries() : GetDefaultSizeMap();
600 //=======================================================================
601 //function : SetClassAttractorEntry
602 //=======================================================================
603 void BLSURFPlugin_Hypothesis::SetClassAttractorEntry(const std::string& entry, const std::string& attEntry, double StartSize, double EndSize, double ActionRadius, double ConstantRadius)
605 SetPhysicalMesh(PhysicalLocalSize);
607 // The new attractor can't be defined on the same face as another sizemap
608 TSizeMap::iterator it = _sizeMap.find( entry );
609 if ( it != _sizeMap.end() ) {
611 NotifySubMeshesHypothesisModification();
614 TSizeMap::iterator itAt = _attractors.find( entry );
615 if ( itAt != _attractors.end() ) {
616 _attractors.erase(itAt);
617 NotifySubMeshesHypothesisModification();
621 const TopoDS_Shape AttractorShape = BLSURFPlugin_Hypothesis::entryToShape(attEntry);
622 const TopoDS_Face FaceShape = TopoDS::Face(BLSURFPlugin_Hypothesis::entryToShape(entry));
623 TAttractorMap::iterator attIt = _classAttractors.find(entry);
624 for ( ; attIt != _classAttractors.end(); ++attIt )
625 if ( attIt->first == entry &&
626 attIt->second->GetAttractorEntry() == attEntry )
628 bool attExists = (attIt != _classAttractors.end());
630 BLSURFPlugin_Attractor* myAttractor;
632 myAttractor = new BLSURFPlugin_Attractor(FaceShape, AttractorShape, attEntry);//, 0.1 );
633 _classAttractors.insert( make_pair( entry, myAttractor ));
636 myAttractor = attIt->second;
638 // if (!myAttractor->IsMapBuilt())
639 // myAttractor->BuildMap();
640 myAttractor->SetParameters(StartSize, EndSize, ActionRadius, ConstantRadius);
642 NotifySubMeshesHypothesisModification();
645 //=======================================================================
646 //function : SetConstantSizeOnAdjacentFaces
647 //=======================================================================
648 // TODO uncomment and test (include the needed .hxx)
649 // SetConstantSizeOnAdjacentFaces(myShape, att_entry, startSize, endSize = user_size, const_dist ) {
650 // TopTools_IndexedMapOfShapListOdShape anEdge2FaceMap;
651 // TopExp::MapShapesAnAncestors(myShape,TopAbs_EDGE, TopAbs_FACE, anEdge2FaceMap);
652 // TopTools_IndexedMapOfShapListOdShape::iterator it;
653 // for (it = anEdge2FaceMap.begin();it != anEdge2FaceMap.end();it++){
654 // SetClassAttractorEntry((*it).first, att_entry, startSize, endSize, 0, const_dist)
662 //=======================================================================
663 //function : GetClassAttractorEntry
664 //=======================================================================
665 // BLSURFPlugin_Attractor& BLSURFPlugin_Hypothesis::GetClassAttractorEntry(const std::string& entry)
667 // TAttractorMap::iterator it = _classAttractors.find( entry );
668 // if ( it != _classAttractors.end() )
669 // return it->second;
671 // return "No_Such_Entry";
675 * \brief Return the map of attractor instances
677 BLSURFPlugin_Hypothesis::TAttractorMap BLSURFPlugin_Hypothesis::GetClassAttractorEntries(const BLSURFPlugin_Hypothesis* hyp)
679 return hyp ? hyp->_GetClassAttractorEntries():GetDefaultAttractorMap();
682 //=======================================================================
683 //function : ClearEntry
684 //=======================================================================
685 void BLSURFPlugin_Hypothesis::ClearEntry(const std::string& entry,
686 const char * attEntry/*=0*/)
688 TSizeMap::iterator it = _sizeMap.find( entry );
690 if ( it != _sizeMap.end() ) {
692 NotifySubMeshesHypothesisModification();
695 TSizeMap::iterator itAt = _attractors.find( entry );
696 if ( itAt != _attractors.end() ) {
697 _attractors.erase(itAt);
698 NotifySubMeshesHypothesisModification();
701 TAttractorMap::iterator it_clAt = _classAttractors.find( entry );
702 if ( it_clAt != _classAttractors.end() ) {
704 if ( !attEntry || it_clAt->second->GetAttractorEntry() == attEntry )
705 _classAttractors.erase( it_clAt++ );
709 while ( it_clAt != _classAttractors.end() );
710 MESSAGE("_classAttractors.size() = "<<_classAttractors.size())
711 NotifySubMeshesHypothesisModification();
714 std::cout<<"No_Such_Entry"<<std::endl;
719 //=======================================================================
720 //function : ClearSizeMaps
721 //=======================================================================
722 void BLSURFPlugin_Hypothesis::ClearSizeMaps() {
725 _classAttractors.clear();
728 // Enable internal enforced vertices on specific face if requested by user
730 ////=======================================================================
731 ////function : SetInternalEnforcedVertex
732 ////=======================================================================
733 //void BLSURFPlugin_Hypothesis::SetInternalEnforcedVertex(TEntry theFaceEntry,
734 // bool toEnforceInternalVertices,
735 // TEnfGroupName theGroupName) {
737 // MESSAGE("BLSURFPlugin_Hypothesis::SetInternalEnforcedVertex("<< theFaceEntry << ", "
738 // << toEnforceInternalVertices << ", " << theGroupName << ")");
740 // TFaceEntryInternalVerticesList::iterator it = _faceEntryInternalVerticesList.find(theFaceEntry);
741 // if (it != _faceEntryInternalVerticesList.end()) {
742 // if (!toEnforceInternalVertices) {
743 // _faceEntryInternalVerticesList.erase(it);
747 // if (toEnforceInternalVertices) {
748 // _faceEntryInternalVerticesList.insert(theFaceEntry);
753 // // Take care of groups
757 //=======================================================================
758 //function : SetEnforcedVertex
759 //=======================================================================
760 bool BLSURFPlugin_Hypothesis::SetEnforcedVertex(TEntry theFaceEntry, TEnfName theVertexName, TEntry theVertexEntry,
761 TEnfGroupName theGroupName, double x, double y, double z) {
763 MESSAGE("BLSURFPlugin_Hypothesis::SetEnforcedVertex("<< theFaceEntry << ", "
764 << x << ", " << y << ", " << z << ", " << theVertexName << ", " << theVertexEntry << ", " << theGroupName << ")");
766 SetPhysicalMesh(PhysicalLocalSize);
768 // TEnfVertexList::iterator it;
769 bool toNotify = false;
770 bool toCreate = true;
772 TEnfVertex *oldEnVertex;
773 TEnfVertex *newEnfVertex = new TEnfVertex();
774 newEnfVertex->name = theVertexName;
775 newEnfVertex->geomEntry = theVertexEntry;
776 newEnfVertex->coords.clear();
777 if (theVertexEntry == "") {
778 newEnfVertex->coords.push_back(x);
779 newEnfVertex->coords.push_back(y);
780 newEnfVertex->coords.push_back(z);
782 newEnfVertex->grpName = theGroupName;
783 newEnfVertex->faceEntries.clear();
784 newEnfVertex->faceEntries.insert(theFaceEntry);
787 // update _enfVertexList
788 TEnfVertexList::iterator it = _enfVertexList.find(newEnfVertex);
789 if (it != _enfVertexList.end()) {
792 MESSAGE("Enforced Vertex was found => Update");
793 if (oldEnVertex->name != theVertexName) {
794 MESSAGE("Update name from \"" << oldEnVertex->name << "\" to \"" << theVertexName << "\"");
795 oldEnVertex->name = theVertexName;
798 if (oldEnVertex->grpName != theGroupName) {
799 MESSAGE("Update group name from \"" << oldEnVertex->grpName << "\" to \"" << theGroupName << "\"");
800 oldEnVertex->grpName = theGroupName;
803 TEntryList::iterator it_faceEntries = oldEnVertex->faceEntries.find(theFaceEntry);
804 if (it_faceEntries == oldEnVertex->faceEntries.end()) {
805 MESSAGE("Update face list by adding \"" << theFaceEntry << "\"");
806 oldEnVertex->faceEntries.insert(theFaceEntry);
807 _faceEntryEnfVertexListMap[theFaceEntry].insert(oldEnVertex);
811 // update map coords / enf vertex if needed
812 if (oldEnVertex->coords.size()) {
813 _coordsEnfVertexMap[oldEnVertex->coords] = oldEnVertex;
814 _faceEntryCoordsListMap[theFaceEntry].insert(oldEnVertex->coords);
817 // update map geom entry / enf vertex if needed
818 if (oldEnVertex->geomEntry != "") {
819 _enfVertexEntryEnfVertexMap[oldEnVertex->geomEntry] = oldEnVertex;
820 _faceEntryEnfVertexEntryListMap[theFaceEntry].insert(oldEnVertex->geomEntry);
825 // //////// CREATE ////////////
828 MESSAGE("Creating new enforced vertex");
829 _faceEntryEnfVertexListMap[theFaceEntry].insert(newEnfVertex);
830 _enfVertexList.insert(newEnfVertex);
831 if (theVertexEntry == "") {
832 _faceEntryCoordsListMap[theFaceEntry].insert(newEnfVertex->coords);
833 _coordsEnfVertexMap[newEnfVertex->coords] = newEnfVertex;
836 _faceEntryEnfVertexEntryListMap[theFaceEntry].insert(newEnfVertex->geomEntry);
837 _enfVertexEntryEnfVertexMap[newEnfVertex->geomEntry] = newEnfVertex;
842 NotifySubMeshesHypothesisModification();
844 MESSAGE("BLSURFPlugin_Hypothesis::SetEnforcedVertex END");
849 //=======================================================================
850 //function : GetEnforcedVertices
851 //=======================================================================
853 BLSURFPlugin_Hypothesis::TEnfVertexList BLSURFPlugin_Hypothesis::GetEnfVertexList(const TEntry& theFaceEntry)
854 throw (std::invalid_argument) {
856 if (_faceEntryEnfVertexListMap.count(theFaceEntry) > 0)
857 return _faceEntryEnfVertexListMap[theFaceEntry];
859 return GetDefaultEnfVertexList();
861 std::ostringstream msg;
862 msg << "No enforced vertex for face entry " << theFaceEntry;
863 throw std::invalid_argument(msg.str());
866 //=======================================================================
867 //function : GetEnfVertexCoordsList
868 //=======================================================================
870 BLSURFPlugin_Hypothesis::TEnfVertexCoordsList BLSURFPlugin_Hypothesis::GetEnfVertexCoordsList(
871 const TEntry& theFaceEntry) throw (std::invalid_argument) {
873 if (_faceEntryCoordsListMap.count(theFaceEntry) > 0)
874 return _faceEntryCoordsListMap[theFaceEntry];
876 std::ostringstream msg;
877 msg << "No enforced vertex coords for face entry " << theFaceEntry;
878 throw std::invalid_argument(msg.str());
881 //=======================================================================
882 //function : GetEnfVertexEntryList
883 //=======================================================================
885 BLSURFPlugin_Hypothesis::TEntryList BLSURFPlugin_Hypothesis::GetEnfVertexEntryList(const TEntry& theFaceEntry)
886 throw (std::invalid_argument) {
888 if (_faceEntryEnfVertexEntryListMap.count(theFaceEntry) > 0)
889 return _faceEntryEnfVertexEntryListMap[theFaceEntry];
891 std::ostringstream msg;
892 msg << "No enforced vertex entry for face entry " << theFaceEntry;
893 throw std::invalid_argument(msg.str());
896 //=======================================================================
897 //function : GetEnfVertex(TEnfVertexCoords coords)
898 //=======================================================================
900 BLSURFPlugin_Hypothesis::TEnfVertex* BLSURFPlugin_Hypothesis::GetEnfVertex(TEnfVertexCoords coords)
901 throw (std::invalid_argument) {
903 if (_coordsEnfVertexMap.count(coords) > 0)
904 return _coordsEnfVertexMap[coords];
906 std::ostringstream msg;
907 msg << "No enforced vertex with coords (" << coords[0] << ", " << coords[1] << ", " << coords[2] << ")";
908 throw std::invalid_argument(msg.str());
911 //=======================================================================
912 //function : GetEnfVertex(const TEntry& theEnfVertexEntry)
913 //=======================================================================
915 BLSURFPlugin_Hypothesis::TEnfVertex* BLSURFPlugin_Hypothesis::GetEnfVertex(const TEntry& theEnfVertexEntry)
916 throw (std::invalid_argument) {
918 if (_enfVertexEntryEnfVertexMap.count(theEnfVertexEntry) > 0)
919 return _enfVertexEntryEnfVertexMap[theEnfVertexEntry];
921 std::ostringstream msg;
922 msg << "No enforced vertex with entry " << theEnfVertexEntry;
923 throw std::invalid_argument(msg.str());
926 //Enable internal enforced vertices on specific face if requested by user
927 ////=======================================================================
928 ////function : GetInternalEnforcedVertex
929 ////=======================================================================
931 //bool BLSURFPlugin_Hypothesis::GetInternalEnforcedVertex(const TEntry& theFaceEntry)
933 // if (_faceEntryInternalVerticesList.count(theFaceEntry) > 0)
938 //=======================================================================
939 //function : ClearEnforcedVertex
940 //=======================================================================
942 bool BLSURFPlugin_Hypothesis::ClearEnforcedVertex(const TEntry& theFaceEntry, double x, double y, double z,
943 const TEntry& theVertexEntry) throw (std::invalid_argument) {
945 bool toNotify = false;
946 std::ostringstream msg;
947 TEnfVertex *oldEnfVertex;
948 TEnfVertexCoords coords;
954 // check that enf vertex with given enf vertex entry exists
955 TEnfVertexEntryEnfVertexMap::iterator it_enfVertexEntry = _enfVertexEntryEnfVertexMap.find(theVertexEntry);
956 if (it_enfVertexEntry != _enfVertexEntryEnfVertexMap.end()) {
958 MESSAGE("Found enforced vertex with geom entry " << theVertexEntry);
959 oldEnfVertex = it_enfVertexEntry->second;
961 _enfVertexEntryEnfVertexMap.erase(it_enfVertexEntry);
963 TEntryList& enfVertexEntryList = _faceEntryEnfVertexEntryListMap[theFaceEntry];
964 enfVertexEntryList.erase(theVertexEntry);
965 if (enfVertexEntryList.size() == 0)
966 _faceEntryEnfVertexEntryListMap.erase(theFaceEntry);
967 // TFaceEntryEnfVertexEntryListMap::iterator it_entry_entry = _faceEntryEnfVertexEntryListMap.find(theFaceEntry);
968 // TEntryList::iterator it_entryList = it_entry_entry->second.find(theVertexEntry);
969 // it_entry_entry->second.erase(it_entryList);
970 // if (it_entry_entry->second.size() == 0)
971 // _faceEntryEnfVertexEntryListMap.erase(it_entry_entry);
974 MESSAGE("Enforced vertex with geom entry " << theVertexEntry << " not found");
975 msg << "No enforced vertex with geom entry " << theVertexEntry;
976 // check that enf vertex with given coords exists
977 TCoordsEnfVertexMap::iterator it_coords_enf = _coordsEnfVertexMap.find(coords);
978 if (it_coords_enf != _coordsEnfVertexMap.end()) {
980 MESSAGE("Found enforced vertex with coords " << x << ", " << y << ", " << z);
981 oldEnfVertex = it_coords_enf->second;
983 _coordsEnfVertexMap.erase(it_coords_enf);
985 TEnfVertexCoordsList& enfVertexCoordsList = _faceEntryCoordsListMap[theFaceEntry];
986 enfVertexCoordsList.erase(coords);
987 if (enfVertexCoordsList.size() == 0)
988 _faceEntryCoordsListMap.erase(theFaceEntry);
989 // TFaceEntryCoordsListMap::iterator it_entry_coords = _faceEntryCoordsListMap.find(theFaceEntry);
990 // TEnfVertexCoordsList::iterator it_coordsList = it_entry_coords->second.find(coords);
991 // it_entry_coords->second.erase(it_coordsList);
992 // if (it_entry_coords->second.size() == 0)
993 // _faceEntryCoordsListMap.erase(it_entry_coords);
996 MESSAGE("Enforced vertex with coords " << x << ", " << y << ", " << z << " not found");
998 msg << "No enforced vertex at " << x << ", " << y << ", " << z;
999 throw std::invalid_argument(msg.str());
1003 MESSAGE("Remove enf vertex from _enfVertexList");
1005 // update _enfVertexList
1006 TEnfVertexList::iterator it = _enfVertexList.find(oldEnfVertex);
1007 if (it != _enfVertexList.end()) {
1008 (*it)->faceEntries.erase(theFaceEntry);
1009 if ((*it)->faceEntries.size() == 0){
1010 _enfVertexList.erase(it);
1016 // update _faceEntryEnfVertexListMap
1017 TEnfVertexList& currentEnfVertexList = _faceEntryEnfVertexListMap[theFaceEntry];
1018 currentEnfVertexList.erase(oldEnfVertex);
1020 if (currentEnfVertexList.size() == 0) {
1021 MESSAGE("Remove _faceEntryEnfVertexListMap[" << theFaceEntry <<"]");
1022 _faceEntryEnfVertexListMap.erase(theFaceEntry);
1027 NotifySubMeshesHypothesisModification();
1032 //=======================================================================
1033 //function : ClearEnforcedVertices
1034 //=======================================================================
1036 bool BLSURFPlugin_Hypothesis::ClearEnforcedVertices(const TEntry& theFaceEntry) throw (std::invalid_argument) {
1038 bool toNotify = false;
1039 TEnfVertex *oldEnfVertex;
1041 TFaceEntryCoordsListMap::iterator it_entry_coords = _faceEntryCoordsListMap.find(theFaceEntry);
1042 if (it_entry_coords != _faceEntryCoordsListMap.end()) {
1044 TEnfVertexCoordsList coordsList = it_entry_coords->second;
1045 TEnfVertexCoordsList::iterator it_coordsList = coordsList.begin();
1046 for (; it_coordsList != coordsList.end(); ++it_coordsList) {
1047 TEnfVertexCoords coords = (*it_coordsList);
1048 oldEnfVertex = _coordsEnfVertexMap[coords];
1049 _coordsEnfVertexMap.erase(coords);
1050 // update _enfVertexList
1051 TEnfVertexList::iterator it = _enfVertexList.find(oldEnfVertex);
1052 if (it != _enfVertexList.end()) {
1053 (*it)->faceEntries.erase(theFaceEntry);
1054 if ((*it)->faceEntries.size() == 0){
1055 _enfVertexList.erase(it);
1061 _faceEntryCoordsListMap.erase(it_entry_coords);
1062 _faceEntryEnfVertexListMap.erase(theFaceEntry);
1065 TFaceEntryEnfVertexEntryListMap::iterator it_entry_entry = _faceEntryEnfVertexEntryListMap.find(theFaceEntry);
1066 if (it_entry_entry != _faceEntryEnfVertexEntryListMap.end()) {
1068 TEntryList enfVertexEntryList = it_entry_entry->second;
1069 TEntryList::iterator it_enfVertexEntryList = enfVertexEntryList.begin();
1070 for (; it_enfVertexEntryList != enfVertexEntryList.end(); ++it_enfVertexEntryList) {
1071 TEntry enfVertexEntry = (*it_enfVertexEntryList);
1072 oldEnfVertex = _enfVertexEntryEnfVertexMap[enfVertexEntry];
1073 _enfVertexEntryEnfVertexMap.erase(enfVertexEntry);
1074 // update _enfVertexList
1075 TEnfVertexList::iterator it = _enfVertexList.find(oldEnfVertex);
1076 if (it != _enfVertexList.end()) {
1077 (*it)->faceEntries.erase(theFaceEntry);
1078 if ((*it)->faceEntries.size() == 0){
1079 _enfVertexList.erase(it);
1085 _faceEntryEnfVertexEntryListMap.erase(it_entry_entry);
1086 _faceEntryEnfVertexListMap.erase(theFaceEntry);
1090 NotifySubMeshesHypothesisModification();
1093 // std::ostringstream msg;
1094 // msg << "No enforced vertex for " << theFaceEntry;
1095 // throw std::invalid_argument(msg.str());
1098 //=======================================================================
1099 //function : ClearAllEnforcedVertices
1100 //=======================================================================
1101 void BLSURFPlugin_Hypothesis::ClearAllEnforcedVertices() {
1102 _faceEntryEnfVertexListMap.clear();
1103 _enfVertexList.clear();
1104 _faceEntryCoordsListMap.clear();
1105 _coordsEnfVertexMap.clear();
1106 _faceEntryEnfVertexEntryListMap.clear();
1107 _enfVertexEntryEnfVertexMap.clear();
1108 // Enable internal enforced vertices on specific face if requested by user
1109 // _faceEntryInternalVerticesList.clear();
1110 NotifySubMeshesHypothesisModification();
1113 //================================================================================
1115 * \brief Return the enforced vertices
1117 //================================================================================
1120 BLSURFPlugin_Hypothesis::TFaceEntryEnfVertexListMap BLSURFPlugin_Hypothesis::GetAllEnforcedVerticesByFace(
1121 const BLSURFPlugin_Hypothesis* hyp) {
1122 return hyp ? hyp->_GetAllEnforcedVerticesByFace() : GetDefaultFaceEntryEnfVertexListMap();
1125 //Enable internal enforced vertices on specific face if requested by user
1126 //BLSURFPlugin_Hypothesis::TFaceEntryInternalVerticesList BLSURFPlugin_Hypothesis::GetAllInternalEnforcedVerticesByFace(
1127 // const BLSURFPlugin_Hypothesis* hyp) {
1128 // return hyp ? hyp->_GetAllInternalEnforcedVerticesByFace() : GetDefaultFaceEntryInternalVerticesMap();
1131 bool BLSURFPlugin_Hypothesis::GetInternalEnforcedVertexAllFaces(const BLSURFPlugin_Hypothesis* hyp)
1133 return hyp ? hyp->_GetInternalEnforcedVertexAllFaces() : GetDefaultInternalEnforcedVertex();
1136 BLSURFPlugin_Hypothesis::TEnfGroupName BLSURFPlugin_Hypothesis::GetInternalEnforcedVertexAllFacesGroup(const BLSURFPlugin_Hypothesis* hyp)
1138 return hyp ? hyp->_GetInternalEnforcedVertexAllFacesGroup() : BLSURFPlugin_Hypothesis::TEnfGroupName();
1141 BLSURFPlugin_Hypothesis::TEnfVertexList BLSURFPlugin_Hypothesis::GetAllEnforcedVertices(
1142 const BLSURFPlugin_Hypothesis* hyp) {
1143 return hyp ? hyp->_GetAllEnforcedVertices() : GetDefaultEnfVertexList();
1146 BLSURFPlugin_Hypothesis::TFaceEntryCoordsListMap BLSURFPlugin_Hypothesis::GetAllCoordsByFace(
1147 const BLSURFPlugin_Hypothesis* hyp) {
1148 return hyp ? hyp->_GetAllCoordsByFace() : GetDefaultFaceEntryCoordsListMap();
1151 BLSURFPlugin_Hypothesis::TCoordsEnfVertexMap BLSURFPlugin_Hypothesis::GetAllEnforcedVerticesByCoords(
1152 const BLSURFPlugin_Hypothesis* hyp) {
1153 return hyp ? hyp->_GetAllEnforcedVerticesByCoords() : GetDefaultCoordsEnfVertexMap();
1156 BLSURFPlugin_Hypothesis::TFaceEntryEnfVertexEntryListMap BLSURFPlugin_Hypothesis::GetAllEnfVertexEntriesByFace(
1157 const BLSURFPlugin_Hypothesis* hyp) {
1158 return hyp ? hyp->_GetAllEnfVertexEntriesByFace() : GetDefaultFaceEntryEnfVertexEntryListMap();
1161 BLSURFPlugin_Hypothesis::TEnfVertexEntryEnfVertexMap BLSURFPlugin_Hypothesis::GetAllEnforcedVerticesByEnfVertexEntry(
1162 const BLSURFPlugin_Hypothesis* hyp) {
1163 return hyp ? hyp->_GetAllEnforcedVerticesByEnfVertexEntry() : GetDefaultEnfVertexEntryEnfVertexMap();
1166 std::set<int> BLSURFPlugin_Hypothesis::GetEnfVertexNodeIDs(TEnfGroupName theGroupName) throw (std::invalid_argument)
1168 TGroupNameNodeIDMap::const_iterator it = _groupNameNodeIDMap.find(theGroupName);
1169 if (it != _groupNameNodeIDMap.end()) {
1172 std::ostringstream msg;
1173 msg << "No group " << theGroupName;
1174 throw std::invalid_argument(msg.str());
1177 void BLSURFPlugin_Hypothesis::AddEnfVertexNodeID(TEnfGroupName theGroupName,int theNodeID)
1179 _groupNameNodeIDMap[theGroupName].insert(theNodeID);
1182 void BLSURFPlugin_Hypothesis::RemoveEnfVertexNodeID(TEnfGroupName theGroupName,int theNodeID) throw (std::invalid_argument)
1184 TGroupNameNodeIDMap::iterator it = _groupNameNodeIDMap.find(theGroupName);
1185 if (it != _groupNameNodeIDMap.end()) {
1186 std::set<int>::iterator IDit = it->second.find(theNodeID);
1187 if (IDit != it->second.end())
1188 it->second.erase(IDit);
1189 std::ostringstream msg;
1190 msg << "No node IDs " << theNodeID << " for group " << theGroupName;
1191 throw std::invalid_argument(msg.str());
1193 std::ostringstream msg;
1194 msg << "No group " << theGroupName;
1195 throw std::invalid_argument(msg.str());
1199 //=============================================================================
1200 void BLSURFPlugin_Hypothesis::SetInternalEnforcedVertexAllFaces(bool toEnforceInternalVertices) {
1201 if (toEnforceInternalVertices != _enforcedInternalVerticesAllFaces) {
1202 _enforcedInternalVerticesAllFaces = toEnforceInternalVertices;
1203 if (toEnforceInternalVertices)
1204 SetPhysicalMesh(PhysicalLocalSize);
1205 NotifySubMeshesHypothesisModification();
1210 //=============================================================================
1211 void BLSURFPlugin_Hypothesis::SetInternalEnforcedVertexAllFacesGroup(BLSURFPlugin_Hypothesis::TEnfGroupName theGroupName) {
1212 if (string(theGroupName) != string(_enforcedInternalVerticesAllFacesGroup)) {
1213 _enforcedInternalVerticesAllFacesGroup = theGroupName;
1214 NotifySubMeshesHypothesisModification();
1218 //=============================================================================
1219 BLSURFPlugin_Hypothesis::TPreCadPeriodicityVector BLSURFPlugin_Hypothesis::GetPreCadFacesPeriodicityVector(
1220 const BLSURFPlugin_Hypothesis* hyp) {
1221 return hyp ? hyp->_GetPreCadFacesPeriodicityVector() : GetDefaultPreCadFacesPeriodicityVector();
1224 //=============================================================================
1225 BLSURFPlugin_Hypothesis::TPreCadPeriodicityVector BLSURFPlugin_Hypothesis::GetPreCadEdgesPeriodicityVector(
1226 const BLSURFPlugin_Hypothesis* hyp) {
1227 return hyp ? hyp->_GetPreCadEdgesPeriodicityVector() : GetDefaultPreCadEdgesPeriodicityVector();
1230 //=============================================================================
1231 BLSURFPlugin_Hypothesis::TFacesPeriodicityVector BLSURFPlugin_Hypothesis::GetFacesPeriodicityVector(
1232 const BLSURFPlugin_Hypothesis* hyp) {
1233 return hyp ? hyp->_GetFacesPeriodicityVector() : GetDefaultFacesPeriodicityVector();
1236 //=============================================================================
1237 BLSURFPlugin_Hypothesis::TEdgesPeriodicityVector BLSURFPlugin_Hypothesis::GetEdgesPeriodicityVector(
1238 const BLSURFPlugin_Hypothesis* hyp){
1239 return hyp ? hyp->_GetEdgesPeriodicityVector() : GetDefaultEdgesPeriodicityVector();
1242 //=============================================================================
1243 BLSURFPlugin_Hypothesis::TVerticesPeriodicityVector BLSURFPlugin_Hypothesis::GetVerticesPeriodicityVector(
1244 const BLSURFPlugin_Hypothesis* hyp){
1245 return hyp ? hyp->_GetVerticesPeriodicityVector() : GetDefaultVerticesPeriodicityVector();
1248 //=======================================================================
1249 //function : ClearAllEnforcedVertices
1250 //=======================================================================
1251 void BLSURFPlugin_Hypothesis::ClearPreCadPeriodicityVectors() {
1252 _preCadFacesPeriodicityVector.clear();
1253 _preCadEdgesPeriodicityVector.clear();
1254 NotifySubMeshesHypothesisModification();
1257 //=======================================================================
1258 //function : AddPreCadFacesPeriodicity
1259 //=======================================================================
1260 void BLSURFPlugin_Hypothesis::AddPreCadFacesPeriodicity(TEntry theFace1Entry, TEntry theFace2Entry,
1261 vector<string> &theSourceVerticesEntries, vector<string> &theTargetVerticesEntries) {
1263 TPreCadPeriodicity preCadFacesPeriodicity;
1264 preCadFacesPeriodicity.shape1Entry = theFace1Entry;
1265 preCadFacesPeriodicity.shape2Entry = theFace2Entry;
1266 preCadFacesPeriodicity.theSourceVerticesEntries = theSourceVerticesEntries;
1267 preCadFacesPeriodicity.theTargetVerticesEntries = theTargetVerticesEntries;
1269 _preCadFacesPeriodicityVector.push_back(preCadFacesPeriodicity);
1271 NotifySubMeshesHypothesisModification();
1274 //=======================================================================
1275 //function : AddPreCadEdgesPeriodicity
1276 //=======================================================================
1277 void BLSURFPlugin_Hypothesis::AddPreCadEdgesPeriodicity(TEntry theEdge1Entry, TEntry theEdge2Entry,
1278 vector<string> &theSourceVerticesEntries, vector<string> &theTargetVerticesEntries) {
1280 TPreCadPeriodicity preCadEdgesPeriodicity;
1281 preCadEdgesPeriodicity.shape1Entry = theEdge1Entry;
1282 preCadEdgesPeriodicity.shape2Entry = theEdge2Entry;
1283 preCadEdgesPeriodicity.theSourceVerticesEntries = theSourceVerticesEntries;
1284 preCadEdgesPeriodicity.theTargetVerticesEntries = theTargetVerticesEntries;
1286 _preCadEdgesPeriodicityVector.push_back(preCadEdgesPeriodicity);
1288 NotifySubMeshesHypothesisModification();
1291 //=======================================================================
1292 //function : AddFacePeriodicity
1293 //=======================================================================
1294 void BLSURFPlugin_Hypothesis::AddFacePeriodicity(TEntry theFace1Entry, TEntry theFace2Entry) {
1296 std::pair< TEntry, TEntry > pairOfFacesEntries = std::make_pair(theFace1Entry, theFace2Entry);
1298 _facesPeriodicityVector.push_back(pairOfFacesEntries);
1300 // Removed for performance reason since AddFacePeriodicity is called multiple times (one time for each face)
1301 // Does not affect the behaviour since it is only called via python, not via GUI.
1302 //NotifySubMeshesHypothesisModification();
1306 //=======================================================================
1307 //function : AddEdgePeriodicity
1308 //=======================================================================
1309 void BLSURFPlugin_Hypothesis::AddEdgePeriodicity(TEntry theFace1Entry, TEntry theEdge1Entry, TEntry theFace2Entry, TEntry theEdge2Entry, int edge_orientation) {
1311 TEdgePeriodicity edgePeriodicity;
1312 edgePeriodicity.theFace1Entry = theFace1Entry;
1313 edgePeriodicity.theEdge1Entry = theEdge1Entry;
1314 edgePeriodicity.theFace2Entry = theFace2Entry;
1315 edgePeriodicity.theEdge2Entry = theEdge2Entry;
1316 edgePeriodicity.edge_orientation = edge_orientation;
1318 _edgesPeriodicityVector.push_back(edgePeriodicity);
1320 // Removed for performance reason since AddEdgePeriodicity is called multiple times (one time for each edge)
1321 // Does not affect the behaviour since it is only called via python, not via GUI.
1322 //NotifySubMeshesHypothesisModification();
1325 //=======================================================================
1326 //function : AddVertexPeriodicity
1327 //=======================================================================
1328 void BLSURFPlugin_Hypothesis::AddVertexPeriodicity(TEntry theEdge1Entry, TEntry theVertex1Entry, TEntry theEdge2Entry, TEntry theVertex2Entry) {
1330 TVertexPeriodicity vertexPeriodicity;
1331 vertexPeriodicity.theEdge1Entry = theEdge1Entry;
1332 vertexPeriodicity.theVertex1Entry = theVertex1Entry;
1333 vertexPeriodicity.theEdge2Entry = theEdge2Entry;
1334 vertexPeriodicity.theVertex2Entry = theVertex2Entry;
1336 _verticesPeriodicityVector.push_back(vertexPeriodicity);
1338 // Removed for performance reason since AddVertexPeriodicity is called multiple times (one time for each vertex)
1339 // Does not affect the behaviour since it is only called via python, not via GUI.
1340 //NotifySubMeshesHypothesisModification();
1343 //=============================================================================
1344 std::ostream & BLSURFPlugin_Hypothesis::SaveTo(std::ostream & save) {
1345 // We must keep at least the same number of arguments when increasing the SALOME version
1346 // When MG-CADSurf becomes CADMESH, some parameters were fused into a single one. Thus the same
1347 // parameter can be written several times to keep the old global number of parameters.
1349 // Treat old options which are now in the advanced options
1350 TOptionValues::iterator op_val;
1352 int _preCADRemoveNanoEdges = -1;
1353 double _preCADEpsNano = -1.0;
1354 op_val = _option2value.find("respect_geometry");
1355 if (op_val != _option2value.end()) {
1356 std::string value = op_val->second;
1358 _decimesh = value.compare("1") == 0 ? 1 : 0;
1360 op_val = _preCADoption2value.find("remove_tiny_edges");
1361 if (op_val != _preCADoption2value.end()) {
1362 std::string value = op_val->second;
1364 _preCADRemoveNanoEdges = value.compare("1") == 0 ? 1 : 0;
1366 op_val = _preCADoption2value.find("tiny_edge_length");
1367 if (op_val != _preCADoption2value.end()) {
1368 std::string value = op_val->second;
1370 _preCADEpsNano = strtod(value.c_str(), NULL);
1373 save << " " << (int) _topology << " " << (int) _physicalMesh << " " << (int) _geometricMesh << " " << _phySize << " "
1374 << _angleMesh << " " << _gradation << " " << (int) _quadAllowed << " " << _decimesh;
1375 save << " " << _minSize << " " << _maxSize << " " << _angleMesh << " " << _minSize << " " << _maxSize << " " << _verb;
1376 save << " " << (int) _preCADMergeEdges << " " << _preCADRemoveNanoEdges << " " << (int) _preCADDiscardInput << " " << _preCADEpsNano ;
1377 save << " " << (int) _enforcedInternalVerticesAllFaces;
1378 save << " " << (int) _phySizeRel << " " << (int) _minSizeRel << " " << (int) _maxSizeRel << " " << _chordalError ;
1379 save << " " << (int) _anisotropic << " " << _anisotropicRatio << " " << (int) _removeTinyEdges << " " << _tinyEdgeLength ;
1380 save << " " << (int) _badElementRemoval << " " << _badElementAspectRatio << " " << (int) _optimizeMesh << " " << (int) _quadraticMesh ;
1381 save << " " << (int) _preCADProcess3DTopology;
1383 op_val = _option2value.begin();
1384 if (op_val != _option2value.end()) {
1385 save << " " << "__OPTIONS_BEGIN__";
1386 for (; op_val != _option2value.end(); ++op_val) {
1387 if (!op_val->second.empty())
1388 save << " " << op_val->first << " " << op_val->second << "%#"; // "%#" is a mark of value end
1390 save << " " << "__OPTIONS_END__";
1393 op_val = _preCADoption2value.begin();
1394 if (op_val != _preCADoption2value.end()) {
1395 save << " " << "__PRECAD_OPTIONS_BEGIN__";
1396 for (; op_val != _preCADoption2value.end(); ++op_val) {
1397 if (!op_val->second.empty())
1398 save << " " << op_val->first << " " << op_val->second << "%#"; // "%#" is a mark of value end
1400 save << " " << "__PRECAD_OPTIONS_END__";
1403 TSizeMap::iterator it_sm = _sizeMap.begin();
1404 if (it_sm != _sizeMap.end()) {
1405 save << " " << "__SIZEMAP_BEGIN__";
1406 for (; it_sm != _sizeMap.end(); ++it_sm) {
1407 save << " " << it_sm->first << " " << it_sm->second << "%#"; // "%#" is a mark of value end
1409 save << " " << "__SIZEMAP_END__";
1412 TSizeMap::iterator it_at = _attractors.begin();
1413 if (it_at != _attractors.end()) {
1414 save << " " << "__ATTRACTORS_BEGIN__";
1415 for (; it_at != _attractors.end(); ++it_at) {
1416 save << " " << it_at->first << " " << it_at->second << "%#"; // "%#" is a mark of value end
1418 save << " " << "__ATTRACTORS_END__";
1421 TAttractorMap::iterator it_At = _classAttractors.begin();
1422 if (it_At != _classAttractors.end()) {
1423 std::ostringstream test;
1424 save << " " << "__NEW_ATTRACTORS_BEGIN__";
1425 test << " " << "__NEW_ATTRACTORS_BEGIN__";
1426 for (; it_At != _classAttractors.end(); ++it_At) {
1427 std::vector<double> attParams;
1428 attParams = it_At->second->GetParameters();
1429 // double step = it_At->second->GetStep();
1430 save << " " << it_At->first;
1431 save << " " << it_At->second->GetAttractorEntry();
1432 save << " " << attParams[0] << " " << attParams[1] << " " << attParams[2] << " " << attParams[3];
1433 // save << " " << step;
1434 test << " " << it_At->first;
1435 test << " " << it_At->second->GetAttractorEntry();
1436 test << " " << attParams[0] << " " << attParams[1] << " " << attParams[2] << " " << attParams[3];
1437 // test << " " << step;
1439 save << " " << "__NEW_ATTRACTORS_END__";
1440 test << " " << "__NEW_ATTRACTORS_END__";
1441 MESSAGE(" Attractor hypothesis saved as "<<test.str())
1444 TEnfVertexList::const_iterator it_enf = _enfVertexList.begin();
1445 if (it_enf != _enfVertexList.end()) {
1446 save << " " << "__ENFORCED_VERTICES_BEGIN__";
1447 for (; it_enf != _enfVertexList.end(); ++it_enf) {
1448 TEnfVertex *enfVertex = (*it_enf);
1449 save << " " << "__BEGIN_VERTEX__";
1450 if (!enfVertex->name.empty()) {
1451 save << " " << "__BEGIN_NAME__";
1452 save << " " << enfVertex->name;
1453 save << " " << "__END_NAME__";
1455 if (!enfVertex->geomEntry.empty()) {
1456 save << " " << "__BEGIN_ENTRY__";
1457 save << " " << enfVertex->geomEntry;
1458 save << " " << "__END_ENTRY__";
1460 if (!enfVertex->grpName.empty()) {
1461 save << " " << "__BEGIN_GROUP__";
1462 save << " " << enfVertex->grpName;
1463 save << " " << "__END_GROUP__";
1465 if (enfVertex->coords.size()) {
1466 save << " " << "__BEGIN_COORDS__";
1467 for (int i=0;i<enfVertex->coords.size();i++)
1468 save << " " << enfVertex->coords[i];
1469 save << " " << "__END_COORDS__";
1471 TEntryList::const_iterator faceEntriesIt = enfVertex->faceEntries.begin();
1472 bool hasFaces = false;
1473 if (faceEntriesIt != enfVertex->faceEntries.end()) {
1475 save << " " << "__BEGIN_FACELIST__";
1477 for (; faceEntriesIt != enfVertex->faceEntries.end(); ++faceEntriesIt)
1478 save << " " << (*faceEntriesIt);
1480 save << " " << "__END_FACELIST__";
1481 save << " " << "__END_VERTEX__";
1483 save << " " << "__ENFORCED_VERTICES_END__";
1488 SavePreCADPeriodicity(save, "FACES");
1489 SavePreCADPeriodicity(save, "EDGES");
1491 SaveFacesPeriodicity(save);
1492 SaveEdgesPeriodicity(save);
1493 SaveVerticesPeriodicity(save);
1498 void BLSURFPlugin_Hypothesis::SaveFacesPeriodicity(std::ostream & save){
1500 TFacesPeriodicityVector::const_iterator it_faces_periodicity = _facesPeriodicityVector.begin();
1501 if (it_faces_periodicity != _facesPeriodicityVector.end()) {
1502 MESSAGE("__FACES_PERIODICITY_BEGIN__");
1503 save << " " << "__FACES_PERIODICITY_BEGIN__";
1504 for (; it_faces_periodicity != _facesPeriodicityVector.end(); ++it_faces_periodicity) {
1505 TFacesPeriodicity periodicity_i = (*it_faces_periodicity);
1506 save << " " << "__BEGIN_PERIODICITY_DESCRIPTION__";
1507 save << " " << "__BEGIN_ENTRY1__";
1508 save << " " << periodicity_i.first;
1509 save << " " << "__END_ENTRY1__";
1510 save << " " << "__BEGIN_ENTRY2__";
1511 save << " " << periodicity_i.second;
1512 save << " " << "__END_ENTRY2__";
1513 save << " " << "__END_PERIODICITY_DESCRIPTION__";
1515 save << " " << "__FACES_PERIODICITY_END__";
1516 MESSAGE("__FACES_PERIODICITY_END__");
1520 void BLSURFPlugin_Hypothesis::SaveEdgesPeriodicity(std::ostream & save){
1522 TEdgesPeriodicityVector::const_iterator it_edges_periodicity = _edgesPeriodicityVector.begin();
1523 if (it_edges_periodicity != _edgesPeriodicityVector.end()) {
1524 save << " " << "__EDGES_PERIODICITY_BEGIN__";
1525 MESSAGE("__EDGES_PERIODICITY_BEGIN__");
1526 for (; it_edges_periodicity != _edgesPeriodicityVector.end(); ++it_edges_periodicity) {
1527 TEdgePeriodicity periodicity_i = (*it_edges_periodicity);
1528 save << " " << "__BEGIN_PERIODICITY_DESCRIPTION__";
1529 if (! periodicity_i.theFace1Entry.empty()){
1530 save << " " << "__BEGIN_FACE1__";
1531 save << " " << periodicity_i.theFace1Entry;
1532 save << " " << "__END_FACE1__";
1534 save << " " << "__BEGIN_EDGE1__";
1535 save << " " << periodicity_i.theEdge1Entry;
1536 save << " " << "__END_EDGE1__";
1537 if (! periodicity_i.theFace2Entry.empty()){
1538 save << " " << "__BEGIN_FACE2__";
1539 save << " " << periodicity_i.theFace2Entry;
1540 save << " " << "__END_FACE2__";
1542 save << " " << "__BEGIN_EDGE2__";
1543 save << " " << periodicity_i.theEdge2Entry;
1544 save << " " << "__END_EDGE2__";
1545 save << " " << "__BEGIN_EDGE_ORIENTATION__";
1546 save << " " << periodicity_i.edge_orientation;
1547 save << " " << "__END_EDGE_ORIENTATION__";
1548 save << " " << "__END_PERIODICITY_DESCRIPTION__";
1550 save << " " << "__EDGES_PERIODICITY_END__";
1551 MESSAGE("__EDGES_PERIODICITY_END__");
1555 void BLSURFPlugin_Hypothesis::SaveVerticesPeriodicity(std::ostream & save){
1557 TVerticesPeriodicityVector::const_iterator it_vertices_periodicity = _verticesPeriodicityVector.begin();
1558 if (it_vertices_periodicity != _verticesPeriodicityVector.end()) {
1559 MESSAGE("__VERTICES_PERIODICITY_BEGIN__");
1560 save << " " << "__VERTICES_PERIODICITY_BEGIN__";
1561 for (; it_vertices_periodicity != _verticesPeriodicityVector.end(); ++it_vertices_periodicity) {
1562 TVertexPeriodicity periodicity_i = (*it_vertices_periodicity);
1563 save << " " << "__BEGIN_PERIODICITY_DESCRIPTION__";
1564 save << " " << "__BEGIN_EDGE1__";
1565 save << " " << periodicity_i.theEdge1Entry;
1566 save << " " << "__END_EDGE1__";
1567 save << " " << "__BEGIN_VERTEX1__";
1568 save << " " << periodicity_i.theVertex1Entry;
1569 save << " " << "__END_VERTEX1__";
1570 save << " " << "__BEGIN_EDGE2__";
1571 save << " " << periodicity_i.theEdge2Entry;
1572 save << " " << "__END_EDGE2__";
1573 save << " " << "__BEGIN_VERTEX2__";
1574 save << " " << periodicity_i.theVertex2Entry;
1575 save << " " << "__END_VERTEX2__";
1576 save << " " << "__END_PERIODICITY_DESCRIPTION__";
1578 save << " " << "__VERTICES_PERIODICITY_END__";
1579 MESSAGE("__VERTICES_PERIODICITY_END__");
1583 void BLSURFPlugin_Hypothesis::SavePreCADPeriodicity(std::ostream & save, const char* shapeType) {
1584 TPreCadPeriodicityVector precad_periodicity;
1585 if (shapeType == "FACES")
1586 precad_periodicity = _preCadFacesPeriodicityVector;
1588 precad_periodicity = _preCadEdgesPeriodicityVector;
1589 TPreCadPeriodicityVector::const_iterator it_precad_periodicity = precad_periodicity.begin();
1590 if (it_precad_periodicity != precad_periodicity.end()) {
1591 save << " " << "__PRECAD_" << shapeType << "_PERIODICITY_BEGIN__";
1592 for (; it_precad_periodicity != precad_periodicity.end(); ++it_precad_periodicity) {
1593 TPreCadPeriodicity periodicity_i = (*it_precad_periodicity);
1594 save << " " << "__BEGIN_PERIODICITY_DESCRIPTION__";
1595 if (!periodicity_i.shape1Entry.empty()) {
1596 save << " " << "__BEGIN_ENTRY1__";
1597 save << " " << periodicity_i.shape1Entry;
1598 save << " " << "__END_ENTRY1__";
1600 if (!periodicity_i.shape2Entry.empty()) {
1601 save << " " << "__BEGIN_ENTRY2__";
1602 save << " " << periodicity_i.shape2Entry;
1603 save << " " << "__END_ENTRY2__";
1606 std::vector<std::string>::const_iterator sourceVerticesEntriesIt = periodicity_i.theSourceVerticesEntries.begin();
1607 bool hasSourceVertices = false;
1608 if (sourceVerticesEntriesIt != periodicity_i.theSourceVerticesEntries.end()) {
1609 hasSourceVertices = true;
1610 save << " " << "__BEGIN_SOURCE_VERTICES_LIST__";
1612 for (; sourceVerticesEntriesIt != periodicity_i.theSourceVerticesEntries.end(); ++sourceVerticesEntriesIt)
1613 save << " " << (*sourceVerticesEntriesIt);
1614 if (hasSourceVertices)
1615 save << " " << "__END_SOURCE_VERTICES_LIST__";
1617 std::vector<std::string>::const_iterator targetVerticesEntriesIt = periodicity_i.theTargetVerticesEntries.begin();
1618 bool hasTargetVertices = false;
1619 if (targetVerticesEntriesIt != periodicity_i.theTargetVerticesEntries.end()) {
1620 hasTargetVertices = true;
1621 save << " " << "__BEGIN_TARGET_VERTICES_LIST__";
1623 for (; targetVerticesEntriesIt != periodicity_i.theTargetVerticesEntries.end(); ++targetVerticesEntriesIt)
1624 save << " " << (*targetVerticesEntriesIt);
1625 if (hasTargetVertices)
1626 save << " " << "__END_TARGET_VERTICES_LIST__";
1628 save << " " << "__END_PERIODICITY_DESCRIPTION__";
1630 save << " " << "__PRECAD_" << shapeType << "_PERIODICITY_END__";
1635 //=============================================================================
1636 std::istream & BLSURFPlugin_Hypothesis::LoadFrom(std::istream & load) {
1640 std::string option_or_sm;
1644 _topology = (Topology) i;
1646 load.clear(std::ios::badbit | load.rdstate());
1650 _physicalMesh = (PhysicalMesh) i;
1652 load.clear(std::ios::badbit | load.rdstate());
1656 _geometricMesh = (GeometricMesh) i;
1658 load.clear(std::ios::badbit | load.rdstate());
1660 isOK = (load >> val);
1664 load.clear(std::ios::badbit | load.rdstate());
1666 isOK = (load >> val);
1670 load.clear(std::ios::badbit | load.rdstate());
1672 isOK = (load >> val);
1676 load.clear(std::ios::badbit | load.rdstate());
1680 _quadAllowed = (bool) i;
1682 load.clear(std::ios::badbit | load.rdstate());
1686 if ( i != -1) { // if value is -1, then this is no longer a standard option
1687 std::string & value = _option2value["respect_geometry"];
1688 bool _decimesh = (bool) i;
1689 value = _decimesh ? "1" : "0";
1693 load.clear(std::ios::badbit | load.rdstate());
1695 isOK = (load >> val);
1699 load.clear(std::ios::badbit | load.rdstate());
1701 isOK = (load >> val);
1705 load.clear(std::ios::badbit | load.rdstate());
1707 isOK = (load >> val);
1709 // former parameter: get min value
1710 _angleMesh = min(val,_angleMesh);
1712 load.clear(std::ios::badbit | load.rdstate());
1714 isOK = (load >> val);
1716 // former parameter: get min value
1717 _minSize = min(val,_minSize);
1719 load.clear(std::ios::badbit | load.rdstate());
1721 isOK = (load >> val);
1723 // former parameter: get max value
1724 _maxSize = max(val,_maxSize);
1726 load.clear(std::ios::badbit | load.rdstate());
1732 load.clear(std::ios::badbit | load.rdstate());
1736 _preCADMergeEdges = (bool) i;
1738 load.clear(std::ios::badbit | load.rdstate());
1742 if ( i != -1) { // if value is -1, then this is no longer a standard option
1743 std::string & value = _preCADoption2value["remove_tiny_edges"];
1744 bool _preCADRemoveNanoEdges = (bool) i;
1745 value = _preCADRemoveNanoEdges ? "1" : "0";
1749 load.clear(std::ios::badbit | load.rdstate());
1753 _preCADDiscardInput = (bool) i;
1755 load.clear(std::ios::badbit | load.rdstate());
1757 isOK = (load >> val);
1758 if (isOK) { // _preCADEpsNano
1759 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
1760 std::string & value = _preCADoption2value["tiny_edge_length"];
1761 std::ostringstream oss;
1767 load.clear(std::ios::badbit | load.rdstate());
1771 _enforcedInternalVerticesAllFaces = (bool) i;
1773 load.clear(std::ios::badbit | load.rdstate());
1775 // New options with MeshGems-CADSurf
1777 bool hasCADSurfOptions = false;
1778 bool hasOptions = false;
1779 bool hasPreCADOptions = false;
1780 bool hasSizeMap = false;
1781 bool hasAttractor = false;
1782 bool hasNewAttractor = false;
1783 bool hasEnforcedVertex = false;
1784 bool hasPreCADFacesPeriodicity = false;
1785 bool hasPreCADEdgesPeriodicity = false;
1786 bool hasFacesPeriodicity = false;
1787 bool hasEdgesPeriodicity = false;
1788 bool hasVerticesPeriodicity = false;
1790 isOK = (load >> option_or_sm);
1792 if ( (option_or_sm == "1")||(option_or_sm == "0") ) {
1793 i = atoi(option_or_sm.c_str());
1794 hasCADSurfOptions = true;
1795 _phySizeRel = (bool) i;
1797 if (option_or_sm == "__OPTIONS_BEGIN__")
1799 else if (option_or_sm == "__PRECAD_OPTIONS_BEGIN__")
1800 hasPreCADOptions = true;
1801 else if (option_or_sm == "__SIZEMAP_BEGIN__")
1803 else if (option_or_sm == "__ATTRACTORS_BEGIN__")
1804 hasAttractor = true;
1805 else if (option_or_sm == "__NEW_ATTRACTORS_BEGIN__")
1806 hasNewAttractor = true;
1807 else if (option_or_sm == "__ENFORCED_VERTICES_BEGIN__")
1808 hasEnforcedVertex = true;
1809 else if (option_or_sm == "__PRECAD_FACES_PERIODICITY_BEGIN__")
1810 hasPreCADFacesPeriodicity = true;
1811 else if (option_or_sm == "__PRECAD_EDGES_PERIODICITY_BEGIN__")
1812 hasPreCADEdgesPeriodicity = true;
1813 else if (option_or_sm == "__FACES_PERIODICITY_BEGIN__")
1814 hasFacesPeriodicity = true;
1815 else if (option_or_sm == "__EDGES_PERIODICITY_BEGIN__")
1816 hasEdgesPeriodicity = true;
1817 else if (option_or_sm == "__VERTICES_PERIODICITY_BEGIN__")
1818 hasVerticesPeriodicity = true;
1820 if (isOK && hasCADSurfOptions) {
1823 _minSizeRel = (bool) i;
1825 load.clear(std::ios::badbit | load.rdstate());
1829 _maxSizeRel = (bool) i;
1831 load.clear(std::ios::badbit | load.rdstate());
1833 isOK = (load >> val);
1835 _chordalError = val;
1837 load.clear(std::ios::badbit | load.rdstate());
1841 _anisotropic = (bool) i;
1843 load.clear(std::ios::badbit | load.rdstate());
1845 isOK = (load >> val);
1847 _anisotropicRatio = val;
1849 load.clear(std::ios::badbit | load.rdstate());
1853 _removeTinyEdges = (bool) i;
1855 load.clear(std::ios::badbit | load.rdstate());
1857 isOK = (load >> val);
1859 _tinyEdgeLength = val;
1861 load.clear(std::ios::badbit | load.rdstate());
1865 _badElementRemoval = (bool) i;
1867 load.clear(std::ios::badbit | load.rdstate());
1869 isOK = (load >> val);
1871 _badElementAspectRatio = val;
1873 load.clear(std::ios::badbit | load.rdstate());
1877 _optimizeMesh = (bool) i;
1879 load.clear(std::ios::badbit | load.rdstate());
1883 _quadraticMesh = (bool) i;
1885 load.clear(std::ios::badbit | load.rdstate());
1889 _preCADProcess3DTopology = (bool) i;
1891 load.clear(std::ios::badbit | load.rdstate());
1896 if (hasCADSurfOptions) {
1897 isOK = (load >> option_or_sm);
1899 if (option_or_sm == "__OPTIONS_BEGIN__")
1901 else if (option_or_sm == "__PRECAD_OPTIONS_BEGIN__")
1902 hasPreCADOptions = true;
1903 else if (option_or_sm == "__SIZEMAP_BEGIN__")
1905 else if (option_or_sm == "__ATTRACTORS_BEGIN__")
1906 hasAttractor = true;
1907 else if (option_or_sm == "__NEW_ATTRACTORS_BEGIN__")
1908 hasNewAttractor = true;
1909 else if (option_or_sm == "__ENFORCED_VERTICES_BEGIN__")
1910 hasEnforcedVertex = true;
1911 else if (option_or_sm == "__PRECAD_FACES_PERIODICITY_BEGIN__")
1912 hasPreCADFacesPeriodicity = true;
1913 else if (option_or_sm == "__PRECAD_EDGES_PERIODICITY_BEGIN__")
1914 hasPreCADEdgesPeriodicity = true;
1915 else if (option_or_sm == "__FACES_PERIODICITY_BEGIN__")
1916 hasFacesPeriodicity = true;
1917 else if (option_or_sm == "__EDGES_PERIODICITY_BEGIN__")
1918 hasEdgesPeriodicity = true;
1919 else if (option_or_sm == "__VERTICES_PERIODICITY_BEGIN__")
1920 hasVerticesPeriodicity = true;
1923 std::string optName, optValue;
1924 while (isOK && hasOptions) {
1925 isOK = (load >> optName);
1927 if (optName == "__OPTIONS_END__")
1929 isOK = (load >> optValue);
1932 std::string & value = _option2value[optName];
1934 int len = value.size();
1935 // continue reading until "%#" encountered
1936 while (value[len - 1] != '#' || value[len - 2] != '%') {
1937 isOK = (load >> optValue);
1946 value[len - 2] = '\0'; //cut off "%#"
1951 isOK = (load >> option_or_sm);
1953 if (option_or_sm == "__PRECAD_OPTIONS_BEGIN__")
1954 hasPreCADOptions = true;
1955 else if (option_or_sm == "__SIZEMAP_BEGIN__")
1957 else if (option_or_sm == "__ATTRACTORS_BEGIN__")
1958 hasAttractor = true;
1959 else if (option_or_sm == "__NEW_ATTRACTORS_BEGIN__")
1960 hasNewAttractor = true;
1961 else if (option_or_sm == "__ENFORCED_VERTICES_BEGIN__")
1962 hasEnforcedVertex = true;
1963 else if (option_or_sm == "__PRECAD_FACES_PERIODICITY_BEGIN__")
1964 hasPreCADFacesPeriodicity = true;
1965 else if (option_or_sm == "__PRECAD_EDGES_PERIODICITY_BEGIN__")
1966 hasPreCADEdgesPeriodicity = true;
1967 else if (option_or_sm == "__FACES_PERIODICITY_BEGIN__")
1968 hasFacesPeriodicity = true;
1969 else if (option_or_sm == "__EDGES_PERIODICITY_BEGIN__")
1970 hasEdgesPeriodicity = true;
1971 else if (option_or_sm == "__VERTICES_PERIODICITY_BEGIN__")
1972 hasVerticesPeriodicity = true;
1975 while (isOK && hasPreCADOptions) {
1976 isOK = (load >> optName);
1978 if (optName == "__PRECAD_OPTIONS_END__")
1980 isOK = (load >> optValue);
1983 std::string & value = _preCADoption2value[optName];
1985 int len = value.size();
1986 // continue reading until "%#" encountered
1987 while (value[len - 1] != '#' || value[len - 2] != '%') {
1988 isOK = (load >> optValue);
1997 value[len - 2] = '\0'; //cut off "%#"
2001 if (hasPreCADOptions) {
2002 isOK = (load >> option_or_sm);
2004 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 smEntry, smValue;
2025 while (isOK && hasSizeMap) {
2026 isOK = (load >> smEntry);
2028 if (smEntry == "__SIZEMAP_END__")
2030 isOK = (load >> smValue);
2033 std::string & value2 = _sizeMap[smEntry];
2035 int len2 = value2.size();
2036 // continue reading until "%#" encountered
2037 while (value2[len2 - 1] != '#' || value2[len2 - 2] != '%') {
2038 isOK = (load >> smValue);
2042 len2 = value2.size();
2047 value2[len2 - 2] = '\0'; //cut off "%#"
2052 isOK = (load >> option_or_sm);
2054 if (option_or_sm == "__ATTRACTORS_BEGIN__")
2055 hasAttractor = true;
2056 if (option_or_sm == "__NEW_ATTRACTORS_BEGIN__")
2057 hasNewAttractor = true;
2058 else if (option_or_sm == "__ENFORCED_VERTICES_BEGIN__")
2059 hasEnforcedVertex = true;
2060 else if (option_or_sm == "__PRECAD_FACES_PERIODICITY_BEGIN__")
2061 hasPreCADFacesPeriodicity = true;
2062 else if (option_or_sm == "__PRECAD_EDGES_PERIODICITY_BEGIN__")
2063 hasPreCADEdgesPeriodicity = true;
2064 else if (option_or_sm == "__FACES_PERIODICITY_BEGIN__")
2065 hasFacesPeriodicity = true;
2066 else if (option_or_sm == "__EDGES_PERIODICITY_BEGIN__")
2067 hasEdgesPeriodicity = true;
2068 else if (option_or_sm == "__VERTICES_PERIODICITY_BEGIN__")
2069 hasVerticesPeriodicity = true;
2072 std::string atEntry, atValue;
2073 while (isOK && hasAttractor) {
2074 isOK = (load >> atEntry);
2076 if (atEntry == "__ATTRACTORS_END__")
2078 isOK = (load >> atValue);
2081 std::string & value3 = _attractors[atEntry];
2083 int len3 = value3.size();
2084 // continue reading until "%#" encountered
2085 while (value3[len3 - 1] != '#' || value3[len3 - 2] != '%') {
2086 isOK = (load >> atValue);
2090 len3 = value3.size();
2095 value3[len3 - 2] = '\0'; //cut off "%#"
2100 isOK = (load >> option_or_sm);
2102 if (option_or_sm == "__NEW_ATTRACTORS_BEGIN__")
2103 hasNewAttractor = true;
2104 else if (option_or_sm == "__ENFORCED_VERTICES_BEGIN__")
2105 hasEnforcedVertex = true;
2106 else if (option_or_sm == "__PRECAD_FACES_PERIODICITY_BEGIN__")
2107 hasPreCADFacesPeriodicity = true;
2108 else if (option_or_sm == "__PRECAD_EDGES_PERIODICITY_BEGIN__")
2109 hasPreCADEdgesPeriodicity = true;
2110 else if (option_or_sm == "__FACES_PERIODICITY_BEGIN__")
2111 hasFacesPeriodicity = true;
2112 else if (option_or_sm == "__EDGES_PERIODICITY_BEGIN__")
2113 hasEdgesPeriodicity = true;
2114 else if (option_or_sm == "__VERTICES_PERIODICITY_BEGIN__")
2115 hasVerticesPeriodicity = true;
2118 std::string newAtFaceEntry, atTestString;
2119 std::string newAtShapeEntry;
2120 double attParams[4];
2122 while (isOK && hasNewAttractor) {
2123 //std::cout<<"Load new attractor"<<std::endl;
2124 isOK = (load >> newAtFaceEntry);
2126 if (newAtFaceEntry == "__NEW_ATTRACTORS_END__")
2128 isOK = (load >> newAtShapeEntry);
2131 isOK = (load >> attParams[0]>>attParams[1]>>attParams[2]>>attParams[3]); //>>step);
2134 MESSAGE(" LOADING ATTRACTOR HYPOTHESIS ")
2135 const TopoDS_Shape attractorShape = BLSURFPlugin_Hypothesis::entryToShape(newAtShapeEntry);
2136 const TopoDS_Face faceShape = TopoDS::Face(BLSURFPlugin_Hypothesis::entryToShape(newAtFaceEntry));
2137 BLSURFPlugin_Attractor* attractor = new BLSURFPlugin_Attractor(faceShape, attractorShape, newAtShapeEntry);//, step);
2138 attractor->SetParameters(attParams[0], attParams[1], attParams[2], attParams[3]);
2139 //attractor->BuildMap();
2140 _classAttractors.insert( make_pair( newAtFaceEntry, attractor ));
2145 if (hasNewAttractor) {
2146 isOK = (load >> option_or_sm);
2148 if (option_or_sm == "__ENFORCED_VERTICES_BEGIN__")
2149 hasEnforcedVertex = true;
2150 else if (option_or_sm == "__PRECAD_FACES_PERIODICITY_BEGIN__")
2151 hasPreCADFacesPeriodicity = true;
2152 else if (option_or_sm == "__PRECAD_EDGES_PERIODICITY_BEGIN__")
2153 hasPreCADEdgesPeriodicity = true;
2154 else if (option_or_sm == "__FACES_PERIODICITY_BEGIN__")
2155 hasFacesPeriodicity = true;
2156 else if (option_or_sm == "__EDGES_PERIODICITY_BEGIN__")
2157 hasEdgesPeriodicity = true;
2158 else if (option_or_sm == "__VERTICES_PERIODICITY_BEGIN__")
2159 hasVerticesPeriodicity = true;
2164 // Here is a example of the saved stream:
2165 // __ENFORCED_VERTICES_BEGIN__
2166 // __BEGIN_VERTEX__ => no name, no entry
2167 // __BEGIN_GROUP__ mon groupe __END_GROUP__
2168 // __BEGIN_COORDS__ 10 10 10 __END_COORDS__
2169 // __BEGIN_FACELIST__ 0:1:1:1:1 __END_FACELIST__
2171 // __BEGIN_VERTEX__ => no coords
2172 // __BEGIN_NAME__ mes points __END_NAME__
2173 // __BEGIN_ENTRY__ 0:1:1:4 __END_ENTRY__
2174 // __BEGIN_GROUP__ mon groupe __END_GROUP__
2175 // __BEGIN_FACELIST__ 0:1:1:1:3 __END_FACELIST__
2177 // __ENFORCED_VERTICES_END__
2180 std::string enfSeparator;
2181 std::string enfName;
2182 std::string enfGeomEntry;
2183 std::string enfGroup;
2184 TEntryList enfFaceEntryList;
2185 double enfCoords[3];
2186 bool hasCoords = false;
2188 _faceEntryEnfVertexListMap.clear();
2189 _enfVertexList.clear();
2190 _faceEntryCoordsListMap.clear();
2191 _coordsEnfVertexMap.clear();
2192 _faceEntryEnfVertexEntryListMap.clear();
2193 _enfVertexEntryEnfVertexMap.clear();
2196 while (isOK && hasEnforcedVertex) {
2197 isOK = (load >> enfSeparator); // __BEGIN_VERTEX__
2198 TEnfVertex *enfVertex = new TEnfVertex();
2199 // MESSAGE("enfSeparator: " <<enfSeparator);
2200 if (enfSeparator == "__ENFORCED_VERTICES_END__")
2201 break; // __ENFORCED_VERTICES_END__
2202 if (enfSeparator != "__BEGIN_VERTEX__")
2203 throw std::exception();
2206 isOK = (load >> enfSeparator);
2207 MESSAGE("enfSeparator: " <<enfSeparator);
2208 if (enfSeparator == "__END_VERTEX__") {
2210 enfVertex->name = enfName;
2211 enfVertex->geomEntry = enfGeomEntry;
2212 enfVertex->grpName = enfGroup;
2213 enfVertex->coords.clear();
2215 enfVertex->coords.assign(enfCoords,enfCoords+3);
2216 enfVertex->faceEntries = enfFaceEntryList;
2218 _enfVertexList.insert(enfVertex);
2220 if (enfVertex->coords.size()) {
2221 _coordsEnfVertexMap[enfVertex->coords] = enfVertex;
2222 for (TEntryList::const_iterator it = enfVertex->faceEntries.begin() ; it != enfVertex->faceEntries.end(); ++it) {
2223 _faceEntryCoordsListMap[(*it)].insert(enfVertex->coords);
2224 _faceEntryEnfVertexListMap[(*it)].insert(enfVertex);
2227 if (!enfVertex->geomEntry.empty()) {
2228 _enfVertexEntryEnfVertexMap[enfVertex->geomEntry] = enfVertex;
2229 for (TEntryList::const_iterator it = enfVertex->faceEntries.begin() ; it != enfVertex->faceEntries.end(); ++it) {
2230 _faceEntryEnfVertexEntryListMap[(*it)].insert(enfVertex->geomEntry);
2231 _faceEntryEnfVertexListMap[(*it)].insert(enfVertex);
2236 enfGeomEntry.clear();
2238 enfFaceEntryList.clear();
2240 break; // __END_VERTEX__
2243 if (enfSeparator == "__BEGIN_NAME__") { // __BEGIN_NAME__
2244 while (isOK && (enfSeparator != "__END_NAME__")) {
2245 isOK = (load >> enfSeparator);
2246 if (enfSeparator != "__END_NAME__") {
2247 if (!enfName.empty())
2249 enfName += enfSeparator;
2252 MESSAGE("enfName: " <<enfName);
2255 if (enfSeparator == "__BEGIN_ENTRY__") { // __BEGIN_ENTRY__
2256 isOK = (load >> enfGeomEntry);
2257 isOK = (load >> enfSeparator); // __END_ENTRY__
2258 if (enfSeparator != "__END_ENTRY__")
2259 throw std::exception();
2260 MESSAGE("enfGeomEntry: " <<enfGeomEntry);
2263 if (enfSeparator == "__BEGIN_GROUP__") { // __BEGIN_GROUP__
2264 while (isOK && (enfSeparator != "__END_GROUP__")) {
2265 isOK = (load >> enfSeparator);
2266 if (enfSeparator != "__END_GROUP__") {
2267 if (!enfGroup.empty())
2269 enfGroup += enfSeparator;
2272 MESSAGE("enfGroup: " <<enfGroup);
2275 if (enfSeparator == "__BEGIN_COORDS__") { // __BEGIN_COORDS__
2277 isOK = (load >> enfCoords[0] >> enfCoords[1] >> enfCoords[2]);
2278 isOK = (load >> enfSeparator); // __END_COORDS__
2279 if (enfSeparator != "__END_COORDS__")
2280 throw std::exception();
2281 MESSAGE("enfCoords: " << enfCoords[0] <<","<< enfCoords[1] <<","<< enfCoords[2]);
2284 if (enfSeparator == "__BEGIN_FACELIST__") { // __BEGIN_FACELIST__
2285 while (isOK && (enfSeparator != "__END_FACELIST__")) {
2286 isOK = (load >> enfSeparator);
2287 if (enfSeparator != "__END_FACELIST__") {
2288 enfFaceEntryList.insert(enfSeparator);
2289 MESSAGE(enfSeparator << " was inserted into enfFaceEntryList");
2298 if (hasPreCADFacesPeriodicity){
2299 LoadPreCADPeriodicity(load, "FACES");
2301 isOK = (load >> option_or_sm);
2303 if (option_or_sm == "__PRECAD_EDGES_PERIODICITY_BEGIN__")
2304 hasPreCADEdgesPeriodicity = true;
2305 else if (option_or_sm == "__FACES_PERIODICITY_BEGIN__")
2306 hasFacesPeriodicity = true;
2307 else if (option_or_sm == "__EDGES_PERIODICITY_BEGIN__")
2308 hasEdgesPeriodicity = true;
2309 else if (option_or_sm == "__VERTICES_PERIODICITY_BEGIN__")
2310 hasVerticesPeriodicity = true;
2313 if (hasPreCADEdgesPeriodicity){
2314 LoadPreCADPeriodicity(load, "EDGES");
2316 isOK = (load >> option_or_sm);
2318 if (option_or_sm == "__FACES_PERIODICITY_BEGIN__")
2319 hasFacesPeriodicity = true;
2320 else if (option_or_sm == "__EDGES_PERIODICITY_BEGIN__")
2321 hasEdgesPeriodicity = true;
2322 else if (option_or_sm == "__VERTICES_PERIODICITY_BEGIN__")
2323 hasVerticesPeriodicity = true;
2326 if (hasFacesPeriodicity){
2327 LoadFacesPeriodicity(load);
2329 isOK = (load >> option_or_sm);
2331 if (option_or_sm == "__EDGES_PERIODICITY_BEGIN__")
2332 hasEdgesPeriodicity = true;
2333 else if (option_or_sm == "__VERTICES_PERIODICITY_BEGIN__")
2334 hasVerticesPeriodicity = true;
2337 if (hasEdgesPeriodicity){
2338 LoadEdgesPeriodicity(load);
2340 isOK = (load >> option_or_sm);
2342 if (option_or_sm == "__VERTICES_PERIODICITY_BEGIN__")
2343 hasVerticesPeriodicity = true;
2346 if (hasVerticesPeriodicity)
2347 LoadVerticesPeriodicity(load);
2352 void BLSURFPlugin_Hypothesis::LoadFacesPeriodicity(std::istream & load){
2356 std::string periodicitySeparator;
2360 _facesPeriodicityVector.clear();
2363 isOK = (load >> periodicitySeparator); // __BEGIN_PERIODICITY_DESCRIPTION__
2364 MESSAGE("periodicitySeparator 1: " <<periodicitySeparator);
2365 TFacesPeriodicity *periodicity_i = new TFacesPeriodicity();
2366 if (periodicitySeparator == "__FACES_PERIODICITY_END__")
2367 break; // __FACES_PERIODICITY_END__
2368 if (periodicitySeparator != "__BEGIN_PERIODICITY_DESCRIPTION__"){
2369 MESSAGE("//" << periodicitySeparator << "//");
2370 throw std::exception();
2374 isOK = (load >> periodicitySeparator);
2375 MESSAGE("periodicitySeparator 2: " <<periodicitySeparator);
2376 if (periodicitySeparator == "__END_PERIODICITY_DESCRIPTION__") {
2378 periodicity_i->first = shape1Entry;
2379 periodicity_i->second = shape2Entry;
2381 _facesPeriodicityVector.push_back(*periodicity_i);
2383 break; // __END_PERIODICITY_DESCRIPTION__
2386 if (periodicitySeparator == "__BEGIN_ENTRY1__") { // __BEGIN_ENTRY1__
2387 isOK = (load >> shape1Entry);
2388 isOK = (load >> periodicitySeparator); // __END_ENTRY1__
2389 if (periodicitySeparator != "__END_ENTRY1__")
2390 throw std::exception();
2391 MESSAGE("shape1Entry: " <<shape1Entry);
2394 if (periodicitySeparator == "__BEGIN_ENTRY2__") { // __BEGIN_ENTRY2__
2395 isOK = (load >> shape2Entry);
2396 isOK = (load >> periodicitySeparator); // __END_ENTRY2__
2397 if (periodicitySeparator != "__END_ENTRY2__")
2398 throw std::exception();
2399 MESSAGE("shape2Entry: " <<shape2Entry);
2406 void BLSURFPlugin_Hypothesis::LoadEdgesPeriodicity(std::istream & load){
2410 std::string periodicitySeparator;
2411 TEntry theFace1Entry;
2412 TEntry theEdge1Entry;
2413 TEntry theFace2Entry;
2414 TEntry theEdge2Entry;
2415 int edge_orientation = 0;
2417 _edgesPeriodicityVector.clear();
2420 isOK = (load >> periodicitySeparator); // __BEGIN_PERIODICITY_DESCRIPTION__
2421 MESSAGE("periodicitySeparator 1: " <<periodicitySeparator);
2422 TEdgePeriodicity *periodicity_i = new TEdgePeriodicity();
2423 if (periodicitySeparator == "__EDGES_PERIODICITY_END__")
2424 break; // __EDGES_PERIODICITY_END__
2425 if (periodicitySeparator != "__BEGIN_PERIODICITY_DESCRIPTION__"){
2426 MESSAGE("//" << periodicitySeparator << "//");
2427 throw std::exception();
2431 isOK = (load >> periodicitySeparator);
2432 MESSAGE("periodicitySeparator 2: " <<periodicitySeparator);
2433 if (periodicitySeparator == "__END_PERIODICITY_DESCRIPTION__") {
2435 periodicity_i->theFace1Entry = theFace1Entry;
2436 periodicity_i->theEdge1Entry = theEdge1Entry;
2437 periodicity_i->theFace2Entry = theFace2Entry;
2438 periodicity_i->theEdge2Entry = theEdge2Entry;
2439 periodicity_i->edge_orientation = edge_orientation;
2441 _edgesPeriodicityVector.push_back(*periodicity_i);
2443 break; // __END_PERIODICITY_DESCRIPTION__
2446 if (periodicitySeparator == "__BEGIN_FACE1__") { // __BEGIN_FACE1__
2447 isOK = (load >> theFace1Entry);
2448 MESSAGE("//" << theFace1Entry << "//");
2449 isOK = (load >> periodicitySeparator); // __END_FACE1__
2450 if (periodicitySeparator != "__END_FACE1__"){
2451 MESSAGE("//" << periodicitySeparator << "//");
2452 throw std::exception();
2454 MESSAGE("theFace1Entry: " <<theFace1Entry);
2457 if (periodicitySeparator == "__BEGIN_EDGE1__") { // __BEGIN_EDGE1__
2458 isOK = (load >> theEdge1Entry);
2459 isOK = (load >> periodicitySeparator); // __END_EDGE1__
2460 if (periodicitySeparator != "__END_EDGE1__")
2461 throw std::exception();
2462 MESSAGE("theEdge1Entry: " <<theEdge1Entry);
2465 if (periodicitySeparator == "__BEGIN_FACE2__") { // __BEGIN_FACE2__
2466 isOK = (load >> theFace2Entry);
2467 isOK = (load >> periodicitySeparator); // __END_FACE2__
2468 if (periodicitySeparator != "__END_FACE2__")
2469 throw std::exception();
2470 MESSAGE("theFace2Entry: " <<theFace2Entry);
2473 if (periodicitySeparator == "__BEGIN_EDGE2__") { // __BEGIN_EDGE2__
2474 isOK = (load >> theEdge2Entry);
2475 isOK = (load >> periodicitySeparator); // __END_EDGE2__
2476 if (periodicitySeparator != "__END_EDGE2__")
2477 throw std::exception();
2478 MESSAGE("theEdge2Entry: " <<theEdge2Entry);
2481 if (periodicitySeparator == "__BEGIN_EDGE_ORIENTATION__") { // __BEGIN_EDGE_ORIENTATION__
2482 isOK = (load >> edge_orientation);
2483 isOK = (load >> periodicitySeparator); // __END_EDGE_ORIENTATION__
2484 if (periodicitySeparator != "__END_EDGE_ORIENTATION__")
2485 throw std::exception();
2486 MESSAGE("edge_orientation: " <<edge_orientation);
2492 void BLSURFPlugin_Hypothesis::LoadVerticesPeriodicity(std::istream & load){
2496 std::string periodicitySeparator;
2497 TEntry theEdge1Entry;
2498 TEntry theVertex1Entry;
2499 TEntry theEdge2Entry;
2500 TEntry theVertex2Entry;
2502 _verticesPeriodicityVector.clear();
2505 isOK = (load >> periodicitySeparator); // __BEGIN_PERIODICITY_DESCRIPTION__
2506 MESSAGE("periodicitySeparator 1: " <<periodicitySeparator);
2507 TVertexPeriodicity *periodicity_i = new TVertexPeriodicity();
2508 if (periodicitySeparator == "__VERTICES_PERIODICITY_END__")
2509 break; // __VERTICES_PERIODICITY_END__
2510 if (periodicitySeparator != "__BEGIN_PERIODICITY_DESCRIPTION__"){
2511 MESSAGE("//" << periodicitySeparator << "//");
2512 throw std::exception();
2516 isOK = (load >> periodicitySeparator);
2517 MESSAGE("periodicitySeparator 2: " <<periodicitySeparator);
2518 if (periodicitySeparator == "__END_PERIODICITY_DESCRIPTION__") {
2520 periodicity_i->theEdge1Entry = theEdge1Entry;
2521 periodicity_i->theVertex1Entry = theVertex1Entry;
2522 periodicity_i->theEdge2Entry = theEdge2Entry;
2523 periodicity_i->theVertex2Entry = theVertex2Entry;
2525 _verticesPeriodicityVector.push_back(*periodicity_i);
2527 break; // __END_PERIODICITY_DESCRIPTION__
2530 if (periodicitySeparator == "__BEGIN_EDGE1__") { // __BEGIN_EDGE1__
2531 isOK = (load >> theEdge1Entry);
2532 isOK = (load >> periodicitySeparator); // __END_EDGE1__
2533 if (periodicitySeparator != "__END_EDGE1__")
2534 throw std::exception();
2535 MESSAGE("theEdge1Entry: " <<theEdge1Entry);
2538 if (periodicitySeparator == "__BEGIN_VERTEX1__") { // __BEGIN_VERTEX1__
2539 isOK = (load >> theVertex1Entry);
2540 isOK = (load >> periodicitySeparator); // __END_VERTEX1__
2541 if (periodicitySeparator != "__END_VERTEX1__")
2542 throw std::exception();
2543 MESSAGE("theVertex1Entry: " <<theVertex1Entry);
2546 if (periodicitySeparator == "__BEGIN_EDGE2__") { // __BEGIN_EDGE2__
2547 isOK = (load >> theEdge2Entry);
2548 isOK = (load >> periodicitySeparator); // __END_EDGE2__
2549 if (periodicitySeparator != "__END_EDGE2__")
2550 throw std::exception();
2551 MESSAGE("theEdge2Entry: " <<theEdge2Entry);
2554 if (periodicitySeparator == "__BEGIN_VERTEX2__") { // __BEGIN_VERTEX2__
2555 isOK = (load >> theVertex2Entry);
2556 isOK = (load >> periodicitySeparator); // __END_VERTEX2__
2557 if (periodicitySeparator != "__END_VERTEX2__")
2558 throw std::exception();
2559 MESSAGE("theVertex2Entry: " <<theVertex2Entry);
2565 void BLSURFPlugin_Hypothesis::LoadPreCADPeriodicity(std::istream & load, const char* shapeType) {
2569 std::string periodicitySeparator;
2572 std::vector<std::string> theSourceVerticesEntries;
2573 std::vector<std::string> theTargetVerticesEntries;
2575 bool hasSourceVertices = false;
2576 bool hasTargetVertices = false;
2578 if (shapeType == "FACES")
2579 _preCadFacesPeriodicityVector.clear();
2581 _preCadEdgesPeriodicityVector.clear();
2585 isOK = (load >> periodicitySeparator); // __BEGIN_PERIODICITY_DESCRIPTION__
2586 MESSAGE("periodicitySeparator 1: " <<periodicitySeparator);
2587 TPreCadPeriodicity *periodicity_i = new TPreCadPeriodicity();
2588 // MESSAGE("periodicitySeparator: " <<periodicitySeparator);
2589 std::string endSeparator = "__PRECAD_" + std::string(shapeType) + "_PERIODICITY_END__";
2590 if (periodicitySeparator == endSeparator)
2591 break; // __PRECAD_FACES_PERIODICITY_END__
2592 if (periodicitySeparator != "__BEGIN_PERIODICITY_DESCRIPTION__"){
2593 MESSAGE("//" << endSeparator << "//");
2594 MESSAGE("//" << periodicitySeparator << "//");
2595 throw std::exception();
2599 isOK = (load >> periodicitySeparator);
2600 MESSAGE("periodicitySeparator 2: " <<periodicitySeparator);
2601 if (periodicitySeparator == "__END_PERIODICITY_DESCRIPTION__") {
2603 periodicity_i->shape1Entry = shape1Entry;
2604 periodicity_i->shape2Entry = shape2Entry;
2606 MESSAGE("theSourceVerticesEntries.size(): " << theSourceVerticesEntries.size());
2607 MESSAGE("theTargetVerticesEntries.size(): " << theTargetVerticesEntries.size());
2609 if (hasSourceVertices)
2610 periodicity_i->theSourceVerticesEntries = theSourceVerticesEntries;
2611 if (hasTargetVertices)
2612 periodicity_i->theTargetVerticesEntries = theTargetVerticesEntries;
2614 if (shapeType == "FACES")
2615 _preCadFacesPeriodicityVector.push_back(*periodicity_i);
2617 _preCadEdgesPeriodicityVector.push_back(*periodicity_i);
2619 theSourceVerticesEntries.clear();
2620 theTargetVerticesEntries.clear();
2621 hasSourceVertices = false;
2622 hasTargetVertices = false;
2623 break; // __END_PERIODICITY_DESCRIPTION__
2626 if (periodicitySeparator == "__BEGIN_ENTRY1__") { // __BEGIN_ENTRY1__
2627 isOK = (load >> shape1Entry);
2628 isOK = (load >> periodicitySeparator); // __END_ENTRY1__
2629 if (periodicitySeparator != "__END_ENTRY1__")
2630 throw std::exception();
2631 MESSAGE("shape1Entry: " <<shape1Entry);
2634 if (periodicitySeparator == "__BEGIN_ENTRY2__") { // __BEGIN_ENTRY2__
2635 isOK = (load >> shape2Entry);
2636 isOK = (load >> periodicitySeparator); // __END_ENTRY2__
2637 if (periodicitySeparator != "__END_ENTRY2__")
2638 throw std::exception();
2639 MESSAGE("shape2Entry: " <<shape2Entry);
2642 if (periodicitySeparator == "__BEGIN_SOURCE_VERTICES_LIST__") { // __BEGIN_SOURCE_VERTICES_LIST__
2643 hasSourceVertices = true;
2644 while (isOK && (periodicitySeparator != "__END_SOURCE_VERTICES_LIST__")) {
2645 isOK = (load >> periodicitySeparator);
2646 if (periodicitySeparator != "__END_SOURCE_VERTICES_LIST__") {
2647 theSourceVerticesEntries.push_back(periodicitySeparator);
2648 MESSAGE("theSourceVerticesEntries: " <<periodicitySeparator);
2653 if (periodicitySeparator == "__BEGIN_TARGET_VERTICES_LIST__") { // __BEGIN_TARGET_VERTICES_LIST__
2654 hasTargetVertices = true;
2655 while (isOK && (periodicitySeparator != "__END_TARGET_VERTICES_LIST__")) {
2656 isOK = (load >> periodicitySeparator);
2657 if (periodicitySeparator != "__END_TARGET_VERTICES_LIST__") {
2658 theTargetVerticesEntries.push_back(periodicitySeparator);
2659 MESSAGE("theTargetVerticesEntries: " <<periodicitySeparator);
2667 //=============================================================================
2668 std::ostream & operator <<(std::ostream & save, BLSURFPlugin_Hypothesis & hyp) {
2669 return hyp.SaveTo(save);
2672 //=============================================================================
2673 std::istream & operator >>(std::istream & load, BLSURFPlugin_Hypothesis & hyp) {
2674 return hyp.LoadFrom(load);
2677 //================================================================================
2679 * \brief Does nothing
2681 //================================================================================
2683 bool BLSURFPlugin_Hypothesis::SetParametersByMesh(const SMESH_Mesh* theMesh, const TopoDS_Shape& theShape) {
2687 //================================================================================
2689 * \brief Returns default global constant physical size given a default value of element length ratio
2691 //================================================================================
2693 double BLSURFPlugin_Hypothesis::GetDefaultPhySize(double diagonal, double bbSegmentation) {
2694 if (bbSegmentation != 0 && diagonal != 0)
2695 return diagonal / bbSegmentation ;
2699 //================================================================================
2701 * \brief Returns default min size given a default value of element length ratio
2703 //================================================================================
2705 double BLSURFPlugin_Hypothesis::GetDefaultMinSize(double diagonal) {
2707 return diagonal / 1000.0 ;
2708 return undefinedDouble();
2711 //================================================================================
2713 * \brief Returns default max size given a default value of element length ratio
2715 //================================================================================
2717 double BLSURFPlugin_Hypothesis::GetDefaultMaxSize(double diagonal) {
2719 return diagonal / 5.0 ;
2720 return undefinedDouble();
2723 //================================================================================
2725 * \brief Returns default chordal error given a default value of element length ratio
2727 //================================================================================
2729 double BLSURFPlugin_Hypothesis::GetDefaultChordalError(double diagonal) {
2732 return undefinedDouble();
2735 //================================================================================
2737 * \brief Returns default tiny edge length given a default value of element length ratio
2739 //================================================================================
2741 double BLSURFPlugin_Hypothesis::GetDefaultTinyEdgeLength(double diagonal) {
2743 return diagonal * 1e-6 ;
2744 return undefinedDouble();
2747 //=============================================================================
2749 * \brief Initialize my parameter values by default parameters.
2750 * \retval bool - true if parameter values have been successfully defined
2752 //=============================================================================
2754 bool BLSURFPlugin_Hypothesis::SetParametersByDefaults(const TDefaults& dflts, const SMESH_Mesh* theMesh) {
2755 double diagonal = dflts._elemLength*_gen->GetBoundaryBoxSegmentation();
2756 _phySize = GetDefaultPhySize(diagonal, _gen->GetBoundaryBoxSegmentation());
2757 _minSize = GetDefaultMinSize(diagonal);
2758 _maxSize = GetDefaultMaxSize(diagonal);
2759 _chordalError = GetDefaultChordalError(diagonal);
2760 _tinyEdgeLength = GetDefaultTinyEdgeLength(diagonal);
2763 // return bool(_phySize = dflts._elemLength);