1 // Copyright (C) 2007-2013 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.
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())
85 _name = "BLSURF_Parameters";
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
113 const char* charOptionNames[] = { "required_entities", // default = "respect"
114 "tags", // default = "respect"
118 // PreCAD advanced options
119 const char* preCADboolOptionNames[] = { "closed_geometry", // default = 0
120 "create_tag_on_collision", // default = 1
121 "debug", // default = 0
122 "remove_tiny_edges", // default = 0
125 const char* preCADintOptionNames[] = { "manifold_geometry", // default = 0
128 const char* preCADdoubleOptionNames[] = { "periodic_tolerance", // default = diag * 1e-5
129 "sewing_tolerance", // default = diag * 5e-4
130 "tiny_edge_length", // default = diag * 1e-5
133 const char* preCADcharOptionNames[] = { "required_entities", // default = "respect"
134 "tags", // default = "respect"
139 while (boolOptionNames[i][0])
140 _option2value[boolOptionNames[i++]].clear();
143 while (preCADboolOptionNames[i][0])
144 _preCADoption2value[preCADboolOptionNames[i++]].clear();
147 while (intOptionNames[i][0])
148 _option2value[intOptionNames[i++]].clear();
151 while (preCADintOptionNames[i][0])
152 _preCADoption2value[preCADintOptionNames[i++]].clear();
155 while (doubleOptionNames[i][0]) {
156 _doubleOptions.insert(doubleOptionNames[i]);
157 _option2value[doubleOptionNames[i++]].clear();
160 while (preCADdoubleOptionNames[i][0]) {
161 _preCADdoubleOptions.insert(preCADdoubleOptionNames[i]);
162 _preCADoption2value[preCADdoubleOptionNames[i++]].clear();
165 while (charOptionNames[i][0]) {
166 _charOptions.insert(charOptionNames[i]);
167 _option2value[charOptionNames[i++]].clear();
170 while (preCADcharOptionNames[i][0]) {
171 _preCADdoubleOptions.insert(preCADcharOptionNames[i]);
172 _preCADoption2value[preCADdoubleOptionNames[i++]].clear();
179 _faceEntryEnfVertexListMap.clear();
180 _enfVertexList.clear();
181 _faceEntryCoordsListMap.clear();
182 _coordsEnfVertexMap.clear();
183 _faceEntryEnfVertexEntryListMap.clear();
184 _enfVertexEntryEnfVertexMap.clear();
185 _groupNameNodeIDMap.clear();
188 _groupNameEnfVertexListMap.clear();
189 _enfVertexGroupNameMap.clear();
193 TopoDS_Shape BLSURFPlugin_Hypothesis::entryToShape(std::string entry)
195 MESSAGE("BLSURFPlugin_Hypothesis::entryToShape "<<entry );
196 GEOM::GEOM_Object_var aGeomObj;
197 SMESH_Gen_i* smeshGen_i = SMESH_Gen_i::GetSMESHGen();
198 SALOMEDS::Study_ptr myStudy = smeshGen_i->GetCurrentStudy();
200 TopoDS_Shape S = TopoDS_Shape();
201 SALOMEDS::SObject_var aSObj = myStudy->FindObjectID( entry.c_str() );
202 if (!aSObj->_is_nil() ) {
203 CORBA::Object_var obj = aSObj->GetObject();
204 aGeomObj = GEOM::GEOM_Object::_narrow(obj);
207 if ( !aGeomObj->_is_nil() )
208 S = smeshGen_i->GeomObjectToShape( aGeomObj.in() );
212 //=============================================================================
213 void BLSURFPlugin_Hypothesis::SetPhysicalMesh(PhysicalMesh thePhysicalMesh) {
214 if (thePhysicalMesh != _physicalMesh) {
215 _physicalMesh = thePhysicalMesh;
216 NotifySubMeshesHypothesisModification();
220 //=============================================================================
221 void BLSURFPlugin_Hypothesis::SetGeometricMesh(GeometricMesh theGeometricMesh) {
222 if (theGeometricMesh != _geometricMesh) {
223 _geometricMesh = theGeometricMesh;
224 // switch (_geometricMesh) {
227 // _angleMesh = GetDefaultAngleMesh();
228 // _gradation = GetDefaultGradation();
231 NotifySubMeshesHypothesisModification();
235 //=============================================================================
236 void BLSURFPlugin_Hypothesis::SetPhySize(double theVal, bool isRelative) {
237 if ((theVal != _phySize) || (isRelative != _phySizeRel)) {
238 _phySizeRel = isRelative;
240 _phySize = GetMaxSize();
241 MESSAGE("Warning: nul physical size is not allowed");
245 NotifySubMeshesHypothesisModification();
249 //=============================================================================
250 void BLSURFPlugin_Hypothesis::SetMinSize(double theMinSize, bool isRelative) {
251 if ((theMinSize != _minSize) || (isRelative != _minSizeRel)) {
252 _minSizeRel = isRelative;
253 _minSize = theMinSize;
254 NotifySubMeshesHypothesisModification();
258 //=============================================================================
259 void BLSURFPlugin_Hypothesis::SetMaxSize(double theMaxSize, bool isRelative) {
260 if ((theMaxSize != _maxSize) || (isRelative != _maxSizeRel)) {
261 _maxSizeRel = isRelative;
262 _maxSize = theMaxSize;
263 NotifySubMeshesHypothesisModification();
267 //=============================================================================
268 void BLSURFPlugin_Hypothesis::SetGradation(double theVal) {
269 if (theVal != _gradation) {
271 NotifySubMeshesHypothesisModification();
275 //=============================================================================
276 void BLSURFPlugin_Hypothesis::SetQuadAllowed(bool theVal) {
277 if (theVal != _quadAllowed) {
278 _quadAllowed = theVal;
279 NotifySubMeshesHypothesisModification();
283 //=============================================================================
284 void BLSURFPlugin_Hypothesis::SetAngleMesh(double theVal) {
285 if (theVal != _angleMesh) {
287 NotifySubMeshesHypothesisModification();
291 //=============================================================================
292 void BLSURFPlugin_Hypothesis::SetChordalError(double theDistance) {
293 if (theDistance != _chordalError) {
294 _chordalError = theDistance;
295 NotifySubMeshesHypothesisModification();
299 //=============================================================================
300 void BLSURFPlugin_Hypothesis::SetAnisotropic(bool theVal) {
301 if (theVal != _anisotropic) {
302 _anisotropic = theVal;
303 NotifySubMeshesHypothesisModification();
307 //=============================================================================
308 void BLSURFPlugin_Hypothesis::SetAnisotropicRatio(double theVal) {
309 if (theVal != _anisotropicRatio) {
310 _anisotropicRatio = theVal;
311 NotifySubMeshesHypothesisModification();
315 //=============================================================================
316 void BLSURFPlugin_Hypothesis::SetRemoveTinyEdges(bool theVal) {
317 if (theVal != _removeTinyEdges) {
318 _removeTinyEdges = theVal;
319 NotifySubMeshesHypothesisModification();
323 //=============================================================================
324 void BLSURFPlugin_Hypothesis::SetTinyEdgeLength(double theVal) {
325 if (theVal != _tinyEdgeLength) {
326 _tinyEdgeLength = theVal;
327 NotifySubMeshesHypothesisModification();
331 //=============================================================================
332 void BLSURFPlugin_Hypothesis::SetBadElementRemoval(bool theVal) {
333 if (theVal != _badElementRemoval) {
334 _badElementRemoval = theVal;
335 NotifySubMeshesHypothesisModification();
339 //=============================================================================
340 void BLSURFPlugin_Hypothesis::SetBadElementAspectRatio(double theVal) {
341 if (theVal != _badElementAspectRatio) {
342 _badElementAspectRatio = theVal;
343 NotifySubMeshesHypothesisModification();
347 //=============================================================================
348 void BLSURFPlugin_Hypothesis::SetOptimizeMesh(bool theVal) {
349 if (theVal != _optimizeMesh) {
350 _optimizeMesh = theVal;
351 NotifySubMeshesHypothesisModification();
355 //=============================================================================
356 void BLSURFPlugin_Hypothesis::SetQuadraticMesh(bool theVal) {
357 if (theVal != _quadraticMesh) {
358 _quadraticMesh = theVal;
359 NotifySubMeshesHypothesisModification();
363 //=============================================================================
364 void BLSURFPlugin_Hypothesis::SetTopology(Topology theTopology) {
365 if (theTopology != _topology) {
366 _topology = theTopology;
367 NotifySubMeshesHypothesisModification();
371 //=============================================================================
372 void BLSURFPlugin_Hypothesis::SetVerbosity(int theVal) {
373 if (theVal != _verb) {
375 NotifySubMeshesHypothesisModification();
379 //=============================================================================
380 void BLSURFPlugin_Hypothesis::SetPreCADMergeEdges(bool theVal) {
381 if (theVal != _preCADMergeEdges) {
382 // SetTopology(PreCAD);
383 _preCADMergeEdges = theVal;
384 NotifySubMeshesHypothesisModification();
388 //=============================================================================
389 void BLSURFPlugin_Hypothesis::SetPreCADProcess3DTopology(bool theVal) {
390 if (theVal != _preCADProcess3DTopology) {
391 // SetTopology(PreCAD);
392 _preCADProcess3DTopology = theVal;
393 NotifySubMeshesHypothesisModification();
397 //=============================================================================
398 void BLSURFPlugin_Hypothesis::SetPreCADDiscardInput(bool theVal) {
399 if (theVal != _preCADDiscardInput) {
400 // SetTopology(PreCAD);
401 _preCADDiscardInput = theVal;
402 NotifySubMeshesHypothesisModification();
406 //=============================================================================
407 // void BLSURFPlugin_Hypothesis::SetGMFFile(const std::string& theFileName, bool isBinary)
408 void BLSURFPlugin_Hypothesis::SetGMFFile(const std::string& theFileName)
410 _GMFFileName = theFileName;
411 // _GMFFileMode = isBinary;
412 NotifySubMeshesHypothesisModification();
415 //=============================================================================
416 void BLSURFPlugin_Hypothesis::SetOptionValue(const std::string& optionName, const std::string& optionValue)
417 throw (std::invalid_argument) {
418 TOptionValues::iterator op_val = _option2value.find(optionName);
419 if (op_val == _option2value.end()) {
420 std::string msg = "Unknown BLSURF option: '" + optionName + "'";
421 throw std::invalid_argument(msg);
423 if (op_val->second != optionValue) {
424 const char* ptr = optionValue.c_str();
425 // strip white spaces
426 while (ptr[0] == ' ')
429 while (i != 0 && ptr[i - 1] == ' ')
433 std::string typeName;
436 } else if (_charOptions.find(optionName) != _charOptions.end()) {
437 // do not check strings
438 } else if (_doubleOptions.find(optionName) != _doubleOptions.end()) {
439 // check if value is double
441 strtod(ptr, &endPtr);
442 typeOk = (ptr != endPtr);
445 // check if value is int
447 strtol(ptr, &endPtr, 10);
448 typeOk = (ptr != endPtr);
449 typeName = "integer";
452 std::string msg = "Advanced option '" + optionName + "' = '" + optionValue + "' but must be " + typeName;
453 throw std::invalid_argument(msg);
455 op_val->second = optionValue;
456 NotifySubMeshesHypothesisModification();
460 //=============================================================================
461 void BLSURFPlugin_Hypothesis::SetPreCADOptionValue(const std::string& optionName, const std::string& optionValue)
462 throw (std::invalid_argument) {
463 TOptionValues::iterator op_val = _preCADoption2value.find(optionName);
464 if (op_val == _preCADoption2value.end()) {
465 std::string msg = "Unknown BLSURF option: '" + optionName + "'";
466 throw std::invalid_argument(msg);
468 if (op_val->second != optionValue) {
469 const char* ptr = optionValue.c_str();
470 // strip white spaces
471 while (ptr[0] == ' ')
474 while (i != 0 && ptr[i - 1] == ' ')
478 std::string typeName;
481 } else if (_preCADdoubleOptions.find(optionName) != _preCADdoubleOptions.end()) {
482 // check if value is double
484 strtod(ptr, &endPtr);
485 typeOk = (ptr != endPtr);
488 // check if value is int
490 strtol(ptr, &endPtr, 10);
491 typeOk = (ptr != endPtr);
492 typeName = "integer";
495 std::string msg = "PreCAD advanced option '" + optionName + "' = '" + optionValue + "' but must be " + typeName;
496 throw std::invalid_argument(msg);
498 op_val->second = optionValue;
499 NotifySubMeshesHypothesisModification();
503 //=============================================================================
504 std::string BLSURFPlugin_Hypothesis::GetOptionValue(const std::string& optionName) throw (std::invalid_argument) {
505 TOptionValues::iterator op_val = _option2value.find(optionName);
506 if (op_val == _option2value.end()) {
507 std::string msg = "Unknown BLSURF option: <";
508 msg += optionName + ">";
509 throw std::invalid_argument(msg);
511 return op_val->second;
514 //=============================================================================
515 std::string BLSURFPlugin_Hypothesis::GetPreCADOptionValue(const std::string& optionName) throw (std::invalid_argument) {
516 TOptionValues::iterator op_val = _preCADoption2value.find(optionName);
517 if (op_val == _preCADoption2value.end()) {
518 std::string msg = "Unknown PRECAD option: <";
519 msg += optionName + ">";
520 throw std::invalid_argument(msg);
522 return op_val->second;
525 //=============================================================================
526 void BLSURFPlugin_Hypothesis::ClearOption(const std::string& optionName) {
527 TOptionValues::iterator op_val = _option2value.find(optionName);
528 if (op_val != _option2value.end())
529 op_val->second.clear();
532 //=============================================================================
533 void BLSURFPlugin_Hypothesis::ClearPreCADOption(const std::string& optionName) {
534 TOptionValues::iterator op_val = _preCADoption2value.find(optionName);
535 if (op_val != _preCADoption2value.end())
536 op_val->second.clear();
539 //=======================================================================
540 //function : SetSizeMapEntry
541 //=======================================================================
542 void BLSURFPlugin_Hypothesis::SetSizeMapEntry(const std::string& entry, const std::string& sizeMap) {
543 if (_sizeMap[entry].compare(sizeMap) != 0) {
544 SetPhysicalMesh(PhysicalLocalSize);
545 _sizeMap[entry] = sizeMap;
546 NotifySubMeshesHypothesisModification();
550 //=======================================================================
551 //function : GetSizeMapEntry
552 //=======================================================================
553 std::string BLSURFPlugin_Hypothesis::GetSizeMapEntry(const std::string& entry) {
554 TSizeMap::iterator it = _sizeMap.find(entry);
555 if (it != _sizeMap.end())
558 return "No_Such_Entry";
562 * \brief Return the size maps
564 BLSURFPlugin_Hypothesis::TSizeMap BLSURFPlugin_Hypothesis::GetSizeMapEntries(const BLSURFPlugin_Hypothesis* hyp) {
565 return hyp ? hyp->_GetSizeMapEntries() : GetDefaultSizeMap();
568 //=======================================================================
569 //function : SetAttractorEntry
570 //=======================================================================
571 void BLSURFPlugin_Hypothesis::SetAttractorEntry(const std::string& entry, const std::string& attractor) {
572 if (_attractors[entry].compare(attractor) != 0) {
573 SetPhysicalMesh(PhysicalLocalSize);
574 _attractors[entry] = attractor;
575 NotifySubMeshesHypothesisModification();
579 //=======================================================================
580 //function : GetAttractorEntry
581 //=======================================================================
582 std::string BLSURFPlugin_Hypothesis::GetAttractorEntry(const std::string& entry) {
583 TSizeMap::iterator it = _attractors.find(entry);
584 if (it != _attractors.end())
587 return "No_Such_Entry";
591 * \brief Return the attractors
593 BLSURFPlugin_Hypothesis::TSizeMap BLSURFPlugin_Hypothesis::GetAttractorEntries(const BLSURFPlugin_Hypothesis* hyp) {
594 return hyp ? hyp->_GetAttractorEntries() : GetDefaultSizeMap();
597 //=======================================================================
598 //function : SetClassAttractorEntry
599 //=======================================================================
600 void BLSURFPlugin_Hypothesis::SetClassAttractorEntry(const std::string& entry, const std::string& attEntry, double StartSize, double EndSize, double ActionRadius, double ConstantRadius)
602 SetPhysicalMesh(PhysicalLocalSize);
604 // The new attractor can't be defined on the same face as another sizemap
605 TSizeMap::iterator it = _sizeMap.find( entry );
606 if ( it != _sizeMap.end() ) {
608 NotifySubMeshesHypothesisModification();
611 TSizeMap::iterator itAt = _attractors.find( entry );
612 if ( itAt != _attractors.end() ) {
613 _attractors.erase(itAt);
614 NotifySubMeshesHypothesisModification();
618 const TopoDS_Shape AttractorShape = BLSURFPlugin_Hypothesis::entryToShape(attEntry);
619 const TopoDS_Face FaceShape = TopoDS::Face(BLSURFPlugin_Hypothesis::entryToShape(entry));
620 bool attExists = (_classAttractors.find(entry) != _classAttractors.end());
621 double u1,u2,v1,v2, diag;
623 if ( !attExists || (attExists && _classAttractors[entry]->GetAttractorEntry().compare(attEntry) != 0)){
624 ShapeAnalysis::GetFaceUVBounds(FaceShape,u1,u2,v1,v2);
625 // diag = sqrt((u2 - u1) * (u2 - u1) + (v2 - v1) * (v2 - v1));
626 BLSURFPlugin_Attractor* myAttractor = new BLSURFPlugin_Attractor(FaceShape, AttractorShape, attEntry);//, 0.1 ); // test 0.002 * diag);
627 myAttractor->BuildMap();
628 myAttractor->SetParameters(StartSize, EndSize, ActionRadius, ConstantRadius);
629 _classAttractors[entry] = myAttractor;
630 NotifySubMeshesHypothesisModification();
633 _classAttractors[entry]->SetParameters(StartSize, EndSize, ActionRadius, ConstantRadius);
634 if (!_classAttractors[entry]->IsMapBuilt()){
635 _classAttractors[entry]->BuildMap();
637 NotifySubMeshesHypothesisModification();
642 //=======================================================================
643 //function : SetConstantSizeOnAdjacentFaces
644 //=======================================================================
645 // TODO uncomment and test (include the needed .hxx)
646 // SetConstantSizeOnAdjacentFaces(myShape, att_entry, startSize, endSize = user_size, const_dist ) {
647 // TopTools_IndexedMapOfShapListOdShape anEdge2FaceMap;
648 // TopExp::MapShapesAnAncestors(myShape,TopAbs_EDGE, TopAbs_FACE, anEdge2FaceMap);
649 // TopTools_IndexedMapOfShapListOdShape::iterator it;
650 // for (it = anEdge2FaceMap.begin();it != anEdge2FaceMap.end();it++){
651 // SetClassAttractorEntry((*it).first, att_entry, startSize, endSize, 0, const_dist)
659 //=======================================================================
660 //function : GetClassAttractorEntry
661 //=======================================================================
662 // BLSURFPlugin_Attractor& BLSURFPlugin_Hypothesis::GetClassAttractorEntry(const std::string& entry)
664 // TAttractorMap::iterator it = _classAttractors.find( entry );
665 // if ( it != _classAttractors.end() )
666 // return it->second;
668 // return "No_Such_Entry";
672 * \brief Return the map of attractor instances
674 BLSURFPlugin_Hypothesis::TAttractorMap BLSURFPlugin_Hypothesis::GetClassAttractorEntries(const BLSURFPlugin_Hypothesis* hyp)
676 return hyp ? hyp->_GetClassAttractorEntries():GetDefaultAttractorMap();
679 //=======================================================================
680 //function : ClearEntry
681 //=======================================================================
682 void BLSURFPlugin_Hypothesis::ClearEntry(const std::string& entry)
684 TSizeMap::iterator it = _sizeMap.find( entry );
686 if ( it != _sizeMap.end() ) {
688 NotifySubMeshesHypothesisModification();
691 TSizeMap::iterator itAt = _attractors.find( entry );
692 if ( itAt != _attractors.end() ) {
693 _attractors.erase(itAt);
694 NotifySubMeshesHypothesisModification();
697 TAttractorMap::iterator it_clAt = _classAttractors.find( entry );
698 if ( it_clAt != _classAttractors.end() ) {
699 _classAttractors.erase(it_clAt);
700 MESSAGE("_classAttractors.size() = "<<_classAttractors.size())
701 NotifySubMeshesHypothesisModification();
704 std::cout<<"No_Such_Entry"<<std::endl;
709 //=======================================================================
710 //function : ClearSizeMaps
711 //=======================================================================
712 void BLSURFPlugin_Hypothesis::ClearSizeMaps() {
715 _classAttractors.clear();
718 // Enable internal enforced vertices on specific face if requested by user
720 ////=======================================================================
721 ////function : SetInternalEnforcedVertex
722 ////=======================================================================
723 //void BLSURFPlugin_Hypothesis::SetInternalEnforcedVertex(TEntry theFaceEntry,
724 // bool toEnforceInternalVertices,
725 // TEnfGroupName theGroupName) {
727 // MESSAGE("BLSURFPlugin_Hypothesis::SetInternalEnforcedVertex("<< theFaceEntry << ", "
728 // << toEnforceInternalVertices << ", " << theGroupName << ")");
730 // TFaceEntryInternalVerticesList::iterator it = _faceEntryInternalVerticesList.find(theFaceEntry);
731 // if (it != _faceEntryInternalVerticesList.end()) {
732 // if (!toEnforceInternalVertices) {
733 // _faceEntryInternalVerticesList.erase(it);
737 // if (toEnforceInternalVertices) {
738 // _faceEntryInternalVerticesList.insert(theFaceEntry);
743 // // Take care of groups
747 //=======================================================================
748 //function : SetEnforcedVertex
749 //=======================================================================
750 bool BLSURFPlugin_Hypothesis::SetEnforcedVertex(TEntry theFaceEntry, TEnfName theVertexName, TEntry theVertexEntry,
751 TEnfGroupName theGroupName, double x, double y, double z) {
753 MESSAGE("BLSURFPlugin_Hypothesis::SetEnforcedVertex("<< theFaceEntry << ", "
754 << x << ", " << y << ", " << z << ", " << theVertexName << ", " << theVertexEntry << ", " << theGroupName << ")");
756 SetPhysicalMesh(PhysicalLocalSize);
758 // TEnfVertexList::iterator it;
759 bool toNotify = false;
760 bool toCreate = true;
762 TEnfVertex *oldEnVertex;
763 TEnfVertex *newEnfVertex = new TEnfVertex();
764 newEnfVertex->name = theVertexName;
765 newEnfVertex->geomEntry = theVertexEntry;
766 newEnfVertex->coords.clear();
767 if (theVertexEntry == "") {
768 newEnfVertex->coords.push_back(x);
769 newEnfVertex->coords.push_back(y);
770 newEnfVertex->coords.push_back(z);
772 newEnfVertex->grpName = theGroupName;
773 newEnfVertex->faceEntries.clear();
774 newEnfVertex->faceEntries.insert(theFaceEntry);
777 // update _enfVertexList
778 TEnfVertexList::iterator it = _enfVertexList.find(newEnfVertex);
779 if (it != _enfVertexList.end()) {
782 MESSAGE("Enforced Vertex was found => Update");
783 if (oldEnVertex->name != theVertexName) {
784 MESSAGE("Update name from \"" << oldEnVertex->name << "\" to \"" << theVertexName << "\"");
785 oldEnVertex->name = theVertexName;
788 if (oldEnVertex->grpName != theGroupName) {
789 MESSAGE("Update group name from \"" << oldEnVertex->grpName << "\" to \"" << theGroupName << "\"");
790 oldEnVertex->grpName = theGroupName;
793 TEntryList::iterator it_faceEntries = oldEnVertex->faceEntries.find(theFaceEntry);
794 if (it_faceEntries == oldEnVertex->faceEntries.end()) {
795 MESSAGE("Update face list by adding \"" << theFaceEntry << "\"");
796 oldEnVertex->faceEntries.insert(theFaceEntry);
797 _faceEntryEnfVertexListMap[theFaceEntry].insert(oldEnVertex);
801 // update map coords / enf vertex if needed
802 if (oldEnVertex->coords.size()) {
803 _coordsEnfVertexMap[oldEnVertex->coords] = oldEnVertex;
804 _faceEntryCoordsListMap[theFaceEntry].insert(oldEnVertex->coords);
807 // update map geom entry / enf vertex if needed
808 if (oldEnVertex->geomEntry != "") {
809 _enfVertexEntryEnfVertexMap[oldEnVertex->geomEntry] = oldEnVertex;
810 _faceEntryEnfVertexEntryListMap[theFaceEntry].insert(oldEnVertex->geomEntry);
815 // //////// CREATE ////////////
818 MESSAGE("Creating new enforced vertex");
819 _faceEntryEnfVertexListMap[theFaceEntry].insert(newEnfVertex);
820 _enfVertexList.insert(newEnfVertex);
821 if (theVertexEntry == "") {
822 _faceEntryCoordsListMap[theFaceEntry].insert(newEnfVertex->coords);
823 _coordsEnfVertexMap[newEnfVertex->coords] = newEnfVertex;
826 _faceEntryEnfVertexEntryListMap[theFaceEntry].insert(newEnfVertex->geomEntry);
827 _enfVertexEntryEnfVertexMap[newEnfVertex->geomEntry] = newEnfVertex;
832 NotifySubMeshesHypothesisModification();
834 MESSAGE("BLSURFPlugin_Hypothesis::SetEnforcedVertex END");
839 //=======================================================================
840 //function : GetEnforcedVertices
841 //=======================================================================
843 BLSURFPlugin_Hypothesis::TEnfVertexList BLSURFPlugin_Hypothesis::GetEnfVertexList(const TEntry& theFaceEntry)
844 throw (std::invalid_argument) {
846 if (_faceEntryEnfVertexListMap.count(theFaceEntry) > 0)
847 return _faceEntryEnfVertexListMap[theFaceEntry];
849 return GetDefaultEnfVertexList();
851 std::ostringstream msg;
852 msg << "No enforced vertex for face entry " << theFaceEntry;
853 throw std::invalid_argument(msg.str());
856 //=======================================================================
857 //function : GetEnfVertexCoordsList
858 //=======================================================================
860 BLSURFPlugin_Hypothesis::TEnfVertexCoordsList BLSURFPlugin_Hypothesis::GetEnfVertexCoordsList(
861 const TEntry& theFaceEntry) throw (std::invalid_argument) {
863 if (_faceEntryCoordsListMap.count(theFaceEntry) > 0)
864 return _faceEntryCoordsListMap[theFaceEntry];
866 std::ostringstream msg;
867 msg << "No enforced vertex coords for face entry " << theFaceEntry;
868 throw std::invalid_argument(msg.str());
871 //=======================================================================
872 //function : GetEnfVertexEntryList
873 //=======================================================================
875 BLSURFPlugin_Hypothesis::TEntryList BLSURFPlugin_Hypothesis::GetEnfVertexEntryList(const TEntry& theFaceEntry)
876 throw (std::invalid_argument) {
878 if (_faceEntryEnfVertexEntryListMap.count(theFaceEntry) > 0)
879 return _faceEntryEnfVertexEntryListMap[theFaceEntry];
881 std::ostringstream msg;
882 msg << "No enforced vertex entry for face entry " << theFaceEntry;
883 throw std::invalid_argument(msg.str());
886 //=======================================================================
887 //function : GetEnfVertex(TEnfVertexCoords coords)
888 //=======================================================================
890 BLSURFPlugin_Hypothesis::TEnfVertex* BLSURFPlugin_Hypothesis::GetEnfVertex(TEnfVertexCoords coords)
891 throw (std::invalid_argument) {
893 if (_coordsEnfVertexMap.count(coords) > 0)
894 return _coordsEnfVertexMap[coords];
896 std::ostringstream msg;
897 msg << "No enforced vertex with coords (" << coords[0] << ", " << coords[1] << ", " << coords[2] << ")";
898 throw std::invalid_argument(msg.str());
901 //=======================================================================
902 //function : GetEnfVertex(const TEntry& theEnfVertexEntry)
903 //=======================================================================
905 BLSURFPlugin_Hypothesis::TEnfVertex* BLSURFPlugin_Hypothesis::GetEnfVertex(const TEntry& theEnfVertexEntry)
906 throw (std::invalid_argument) {
908 if (_enfVertexEntryEnfVertexMap.count(theEnfVertexEntry) > 0)
909 return _enfVertexEntryEnfVertexMap[theEnfVertexEntry];
911 std::ostringstream msg;
912 msg << "No enforced vertex with entry " << theEnfVertexEntry;
913 throw std::invalid_argument(msg.str());
916 //Enable internal enforced vertices on specific face if requested by user
917 ////=======================================================================
918 ////function : GetInternalEnforcedVertex
919 ////=======================================================================
921 //bool BLSURFPlugin_Hypothesis::GetInternalEnforcedVertex(const TEntry& theFaceEntry)
923 // if (_faceEntryInternalVerticesList.count(theFaceEntry) > 0)
928 //=======================================================================
929 //function : ClearEnforcedVertex
930 //=======================================================================
932 bool BLSURFPlugin_Hypothesis::ClearEnforcedVertex(const TEntry& theFaceEntry, double x, double y, double z,
933 const TEntry& theVertexEntry) throw (std::invalid_argument) {
935 bool toNotify = false;
936 std::ostringstream msg;
937 TEnfVertex *oldEnfVertex;
938 TEnfVertexCoords coords;
944 // check that enf vertex with given enf vertex entry exists
945 TEnfVertexEntryEnfVertexMap::iterator it_enfVertexEntry = _enfVertexEntryEnfVertexMap.find(theVertexEntry);
946 if (it_enfVertexEntry != _enfVertexEntryEnfVertexMap.end()) {
948 MESSAGE("Found enforced vertex with geom entry " << theVertexEntry);
949 oldEnfVertex = it_enfVertexEntry->second;
951 _enfVertexEntryEnfVertexMap.erase(it_enfVertexEntry);
953 TEntryList& enfVertexEntryList = _faceEntryEnfVertexEntryListMap[theFaceEntry];
954 enfVertexEntryList.erase(theVertexEntry);
955 if (enfVertexEntryList.size() == 0)
956 _faceEntryEnfVertexEntryListMap.erase(theFaceEntry);
957 // TFaceEntryEnfVertexEntryListMap::iterator it_entry_entry = _faceEntryEnfVertexEntryListMap.find(theFaceEntry);
958 // TEntryList::iterator it_entryList = it_entry_entry->second.find(theVertexEntry);
959 // it_entry_entry->second.erase(it_entryList);
960 // if (it_entry_entry->second.size() == 0)
961 // _faceEntryEnfVertexEntryListMap.erase(it_entry_entry);
964 MESSAGE("Enforced vertex with geom entry " << theVertexEntry << " not found");
965 msg << "No enforced vertex with geom entry " << theVertexEntry;
966 // check that enf vertex with given coords exists
967 TCoordsEnfVertexMap::iterator it_coords_enf = _coordsEnfVertexMap.find(coords);
968 if (it_coords_enf != _coordsEnfVertexMap.end()) {
970 MESSAGE("Found enforced vertex with coords " << x << ", " << y << ", " << z);
971 oldEnfVertex = it_coords_enf->second;
973 _coordsEnfVertexMap.erase(it_coords_enf);
975 TEnfVertexCoordsList& enfVertexCoordsList = _faceEntryCoordsListMap[theFaceEntry];
976 enfVertexCoordsList.erase(coords);
977 if (enfVertexCoordsList.size() == 0)
978 _faceEntryCoordsListMap.erase(theFaceEntry);
979 // TFaceEntryCoordsListMap::iterator it_entry_coords = _faceEntryCoordsListMap.find(theFaceEntry);
980 // TEnfVertexCoordsList::iterator it_coordsList = it_entry_coords->second.find(coords);
981 // it_entry_coords->second.erase(it_coordsList);
982 // if (it_entry_coords->second.size() == 0)
983 // _faceEntryCoordsListMap.erase(it_entry_coords);
986 MESSAGE("Enforced vertex with coords " << x << ", " << y << ", " << z << " not found");
988 msg << "No enforced vertex at " << x << ", " << y << ", " << z;
989 throw std::invalid_argument(msg.str());
993 MESSAGE("Remove enf vertex from _enfVertexList");
995 // update _enfVertexList
996 TEnfVertexList::iterator it = _enfVertexList.find(oldEnfVertex);
997 if (it != _enfVertexList.end()) {
998 (*it)->faceEntries.erase(theFaceEntry);
999 if ((*it)->faceEntries.size() == 0){
1000 _enfVertexList.erase(it);
1006 // update _faceEntryEnfVertexListMap
1007 TEnfVertexList& currentEnfVertexList = _faceEntryEnfVertexListMap[theFaceEntry];
1008 currentEnfVertexList.erase(oldEnfVertex);
1010 if (currentEnfVertexList.size() == 0) {
1011 MESSAGE("Remove _faceEntryEnfVertexListMap[" << theFaceEntry <<"]");
1012 _faceEntryEnfVertexListMap.erase(theFaceEntry);
1017 NotifySubMeshesHypothesisModification();
1022 //=======================================================================
1023 //function : ClearEnforcedVertices
1024 //=======================================================================
1026 bool BLSURFPlugin_Hypothesis::ClearEnforcedVertices(const TEntry& theFaceEntry) throw (std::invalid_argument) {
1028 bool toNotify = false;
1029 TEnfVertex *oldEnfVertex;
1031 TFaceEntryCoordsListMap::iterator it_entry_coords = _faceEntryCoordsListMap.find(theFaceEntry);
1032 if (it_entry_coords != _faceEntryCoordsListMap.end()) {
1034 TEnfVertexCoordsList coordsList = it_entry_coords->second;
1035 TEnfVertexCoordsList::iterator it_coordsList = coordsList.begin();
1036 for (; it_coordsList != coordsList.end(); ++it_coordsList) {
1037 TEnfVertexCoords coords = (*it_coordsList);
1038 oldEnfVertex = _coordsEnfVertexMap[coords];
1039 _coordsEnfVertexMap.erase(coords);
1040 // update _enfVertexList
1041 TEnfVertexList::iterator it = _enfVertexList.find(oldEnfVertex);
1042 if (it != _enfVertexList.end()) {
1043 (*it)->faceEntries.erase(theFaceEntry);
1044 if ((*it)->faceEntries.size() == 0){
1045 _enfVertexList.erase(it);
1051 _faceEntryCoordsListMap.erase(it_entry_coords);
1052 _faceEntryEnfVertexListMap.erase(theFaceEntry);
1055 TFaceEntryEnfVertexEntryListMap::iterator it_entry_entry = _faceEntryEnfVertexEntryListMap.find(theFaceEntry);
1056 if (it_entry_entry != _faceEntryEnfVertexEntryListMap.end()) {
1058 TEntryList enfVertexEntryList = it_entry_entry->second;
1059 TEntryList::iterator it_enfVertexEntryList = enfVertexEntryList.begin();
1060 for (; it_enfVertexEntryList != enfVertexEntryList.end(); ++it_enfVertexEntryList) {
1061 TEntry enfVertexEntry = (*it_enfVertexEntryList);
1062 oldEnfVertex = _enfVertexEntryEnfVertexMap[enfVertexEntry];
1063 _enfVertexEntryEnfVertexMap.erase(enfVertexEntry);
1064 // update _enfVertexList
1065 TEnfVertexList::iterator it = _enfVertexList.find(oldEnfVertex);
1066 if (it != _enfVertexList.end()) {
1067 (*it)->faceEntries.erase(theFaceEntry);
1068 if ((*it)->faceEntries.size() == 0){
1069 _enfVertexList.erase(it);
1075 _faceEntryEnfVertexEntryListMap.erase(it_entry_entry);
1076 _faceEntryEnfVertexListMap.erase(theFaceEntry);
1080 NotifySubMeshesHypothesisModification();
1083 // std::ostringstream msg;
1084 // msg << "No enforced vertex for " << theFaceEntry;
1085 // throw std::invalid_argument(msg.str());
1088 //=======================================================================
1089 //function : ClearAllEnforcedVertices
1090 //=======================================================================
1091 void BLSURFPlugin_Hypothesis::ClearAllEnforcedVertices() {
1092 _faceEntryEnfVertexListMap.clear();
1093 _enfVertexList.clear();
1094 _faceEntryCoordsListMap.clear();
1095 _coordsEnfVertexMap.clear();
1096 _faceEntryEnfVertexEntryListMap.clear();
1097 _enfVertexEntryEnfVertexMap.clear();
1098 // Enable internal enforced vertices on specific face if requested by user
1099 // _faceEntryInternalVerticesList.clear();
1100 NotifySubMeshesHypothesisModification();
1103 //================================================================================
1105 * \brief Return the enforced vertices
1107 //================================================================================
1110 BLSURFPlugin_Hypothesis::TFaceEntryEnfVertexListMap BLSURFPlugin_Hypothesis::GetAllEnforcedVerticesByFace(
1111 const BLSURFPlugin_Hypothesis* hyp) {
1112 return hyp ? hyp->_GetAllEnforcedVerticesByFace() : GetDefaultFaceEntryEnfVertexListMap();
1115 //Enable internal enforced vertices on specific face if requested by user
1116 //BLSURFPlugin_Hypothesis::TFaceEntryInternalVerticesList BLSURFPlugin_Hypothesis::GetAllInternalEnforcedVerticesByFace(
1117 // const BLSURFPlugin_Hypothesis* hyp) {
1118 // return hyp ? hyp->_GetAllInternalEnforcedVerticesByFace() : GetDefaultFaceEntryInternalVerticesMap();
1121 bool BLSURFPlugin_Hypothesis::GetInternalEnforcedVertexAllFaces(const BLSURFPlugin_Hypothesis* hyp)
1123 return hyp ? hyp->_GetInternalEnforcedVertexAllFaces() : GetDefaultInternalEnforcedVertex();
1126 BLSURFPlugin_Hypothesis::TEnfGroupName BLSURFPlugin_Hypothesis::GetInternalEnforcedVertexAllFacesGroup(const BLSURFPlugin_Hypothesis* hyp)
1128 return hyp ? hyp->_GetInternalEnforcedVertexAllFacesGroup() : BLSURFPlugin_Hypothesis::TEnfGroupName();
1131 BLSURFPlugin_Hypothesis::TEnfVertexList BLSURFPlugin_Hypothesis::GetAllEnforcedVertices(
1132 const BLSURFPlugin_Hypothesis* hyp) {
1133 return hyp ? hyp->_GetAllEnforcedVertices() : GetDefaultEnfVertexList();
1136 BLSURFPlugin_Hypothesis::TFaceEntryCoordsListMap BLSURFPlugin_Hypothesis::GetAllCoordsByFace(
1137 const BLSURFPlugin_Hypothesis* hyp) {
1138 return hyp ? hyp->_GetAllCoordsByFace() : GetDefaultFaceEntryCoordsListMap();
1141 BLSURFPlugin_Hypothesis::TCoordsEnfVertexMap BLSURFPlugin_Hypothesis::GetAllEnforcedVerticesByCoords(
1142 const BLSURFPlugin_Hypothesis* hyp) {
1143 return hyp ? hyp->_GetAllEnforcedVerticesByCoords() : GetDefaultCoordsEnfVertexMap();
1146 BLSURFPlugin_Hypothesis::TFaceEntryEnfVertexEntryListMap BLSURFPlugin_Hypothesis::GetAllEnfVertexEntriesByFace(
1147 const BLSURFPlugin_Hypothesis* hyp) {
1148 return hyp ? hyp->_GetAllEnfVertexEntriesByFace() : GetDefaultFaceEntryEnfVertexEntryListMap();
1151 BLSURFPlugin_Hypothesis::TEnfVertexEntryEnfVertexMap BLSURFPlugin_Hypothesis::GetAllEnforcedVerticesByEnfVertexEntry(
1152 const BLSURFPlugin_Hypothesis* hyp) {
1153 return hyp ? hyp->_GetAllEnforcedVerticesByEnfVertexEntry() : GetDefaultEnfVertexEntryEnfVertexMap();
1156 std::set<int> BLSURFPlugin_Hypothesis::GetEnfVertexNodeIDs(TEnfGroupName theGroupName) throw (std::invalid_argument)
1158 TGroupNameNodeIDMap::const_iterator it = _groupNameNodeIDMap.find(theGroupName);
1159 if (it != _groupNameNodeIDMap.end()) {
1162 std::ostringstream msg;
1163 msg << "No group " << theGroupName;
1164 throw std::invalid_argument(msg.str());
1167 void BLSURFPlugin_Hypothesis::AddEnfVertexNodeID(TEnfGroupName theGroupName,int theNodeID)
1169 _groupNameNodeIDMap[theGroupName].insert(theNodeID);
1172 void BLSURFPlugin_Hypothesis::RemoveEnfVertexNodeID(TEnfGroupName theGroupName,int theNodeID) throw (std::invalid_argument)
1174 TGroupNameNodeIDMap::iterator it = _groupNameNodeIDMap.find(theGroupName);
1175 if (it != _groupNameNodeIDMap.end()) {
1176 std::set<int>::iterator IDit = it->second.find(theNodeID);
1177 if (IDit != it->second.end())
1178 it->second.erase(IDit);
1179 std::ostringstream msg;
1180 msg << "No node IDs " << theNodeID << " for group " << theGroupName;
1181 throw std::invalid_argument(msg.str());
1183 std::ostringstream msg;
1184 msg << "No group " << theGroupName;
1185 throw std::invalid_argument(msg.str());
1189 //=============================================================================
1190 void BLSURFPlugin_Hypothesis::SetInternalEnforcedVertexAllFaces(bool toEnforceInternalVertices) {
1191 if (toEnforceInternalVertices != _enforcedInternalVerticesAllFaces) {
1192 _enforcedInternalVerticesAllFaces = toEnforceInternalVertices;
1193 if (toEnforceInternalVertices)
1194 SetPhysicalMesh(PhysicalLocalSize);
1195 NotifySubMeshesHypothesisModification();
1200 //=============================================================================
1201 void BLSURFPlugin_Hypothesis::SetInternalEnforcedVertexAllFacesGroup(BLSURFPlugin_Hypothesis::TEnfGroupName theGroupName) {
1202 if (string(theGroupName) != string(_enforcedInternalVerticesAllFacesGroup)) {
1203 _enforcedInternalVerticesAllFacesGroup = theGroupName;
1204 NotifySubMeshesHypothesisModification();
1208 //=============================================================================
1209 BLSURFPlugin_Hypothesis::TPreCadPeriodicityVector BLSURFPlugin_Hypothesis::GetPreCadFacesPeriodicityVector(
1210 const BLSURFPlugin_Hypothesis* hyp) {
1211 return hyp ? hyp->_GetPreCadFacesPeriodicityVector() : GetDefaultPreCadFacesPeriodicityVector();
1214 //=============================================================================
1215 BLSURFPlugin_Hypothesis::TPreCadPeriodicityVector BLSURFPlugin_Hypothesis::GetPreCadEdgesPeriodicityVector(
1216 const BLSURFPlugin_Hypothesis* hyp) {
1217 return hyp ? hyp->_GetPreCadEdgesPeriodicityVector() : GetDefaultPreCadEdgesPeriodicityVector();
1220 //=============================================================================
1221 BLSURFPlugin_Hypothesis::TFacesPeriodicityVector BLSURFPlugin_Hypothesis::GetFacesPeriodicityVector(
1222 const BLSURFPlugin_Hypothesis* hyp) {
1223 return hyp ? hyp->_GetFacesPeriodicityVector() : GetDefaultFacesPeriodicityVector();
1226 //=============================================================================
1227 BLSURFPlugin_Hypothesis::TEdgesPeriodicityVector BLSURFPlugin_Hypothesis::GetEdgesPeriodicityVector(
1228 const BLSURFPlugin_Hypothesis* hyp){
1229 return hyp ? hyp->_GetEdgesPeriodicityVector() : GetDefaultEdgesPeriodicityVector();
1232 //=============================================================================
1233 BLSURFPlugin_Hypothesis::TVerticesPeriodicityVector BLSURFPlugin_Hypothesis::GetVerticesPeriodicityVector(
1234 const BLSURFPlugin_Hypothesis* hyp){
1235 return hyp ? hyp->_GetVerticesPeriodicityVector() : GetDefaultVerticesPeriodicityVector();
1238 //=======================================================================
1239 //function : ClearAllEnforcedVertices
1240 //=======================================================================
1241 void BLSURFPlugin_Hypothesis::ClearPreCadPeriodicityVectors() {
1242 _preCadFacesPeriodicityVector.clear();
1243 _preCadEdgesPeriodicityVector.clear();
1244 NotifySubMeshesHypothesisModification();
1247 //=======================================================================
1248 //function : AddPreCadFacesPeriodicity
1249 //=======================================================================
1250 void BLSURFPlugin_Hypothesis::AddPreCadFacesPeriodicity(TEntry theFace1Entry, TEntry theFace2Entry,
1251 vector<string> &theSourceVerticesEntries, vector<string> &theTargetVerticesEntries) {
1253 TPreCadPeriodicity preCadFacesPeriodicity;
1254 preCadFacesPeriodicity.shape1Entry = theFace1Entry;
1255 preCadFacesPeriodicity.shape2Entry = theFace2Entry;
1256 preCadFacesPeriodicity.theSourceVerticesEntries = theSourceVerticesEntries;
1257 preCadFacesPeriodicity.theTargetVerticesEntries = theTargetVerticesEntries;
1259 _preCadFacesPeriodicityVector.push_back(preCadFacesPeriodicity);
1261 NotifySubMeshesHypothesisModification();
1264 //=======================================================================
1265 //function : AddPreCadEdgesPeriodicity
1266 //=======================================================================
1267 void BLSURFPlugin_Hypothesis::AddPreCadEdgesPeriodicity(TEntry theEdge1Entry, TEntry theEdge2Entry,
1268 vector<string> &theSourceVerticesEntries, vector<string> &theTargetVerticesEntries) {
1270 TPreCadPeriodicity preCadEdgesPeriodicity;
1271 preCadEdgesPeriodicity.shape1Entry = theEdge1Entry;
1272 preCadEdgesPeriodicity.shape2Entry = theEdge2Entry;
1273 preCadEdgesPeriodicity.theSourceVerticesEntries = theSourceVerticesEntries;
1274 preCadEdgesPeriodicity.theTargetVerticesEntries = theTargetVerticesEntries;
1276 _preCadEdgesPeriodicityVector.push_back(preCadEdgesPeriodicity);
1278 NotifySubMeshesHypothesisModification();
1281 //=======================================================================
1282 //function : AddFacePeriodicity
1283 //=======================================================================
1284 void BLSURFPlugin_Hypothesis::AddFacePeriodicity(TEntry theFace1Entry, TEntry theFace2Entry) {
1286 std::pair< TEntry, TEntry > pairOfFacesEntries = std::make_pair(theFace1Entry, theFace2Entry);
1288 _facesPeriodicityVector.push_back(pairOfFacesEntries);
1290 NotifySubMeshesHypothesisModification();
1294 //=======================================================================
1295 //function : AddEdgePeriodicity
1296 //=======================================================================
1297 void BLSURFPlugin_Hypothesis::AddEdgePeriodicity(TEntry theFace1Entry, TEntry theEdge1Entry, TEntry theFace2Entry, TEntry theEdge2Entry, int edge_orientation) {
1299 TEdgePeriodicity edgePeriodicity;
1300 edgePeriodicity.theFace1Entry = theFace1Entry;
1301 edgePeriodicity.theEdge1Entry = theEdge1Entry;
1302 edgePeriodicity.theFace2Entry = theFace2Entry;
1303 edgePeriodicity.theEdge2Entry = theEdge2Entry;
1304 edgePeriodicity.edge_orientation = edge_orientation;
1306 _edgesPeriodicityVector.push_back(edgePeriodicity);
1308 NotifySubMeshesHypothesisModification();
1311 //=======================================================================
1312 //function : AddVertexPeriodicity
1313 //=======================================================================
1314 void BLSURFPlugin_Hypothesis::AddVertexPeriodicity(TEntry theEdge1Entry, TEntry theVertex1Entry, TEntry theEdge2Entry, TEntry theVertex2Entry) {
1316 TVertexPeriodicity vertexPeriodicity;
1317 vertexPeriodicity.theEdge1Entry = theEdge1Entry;
1318 vertexPeriodicity.theVertex1Entry = theVertex1Entry;
1319 vertexPeriodicity.theEdge2Entry = theEdge2Entry;
1320 vertexPeriodicity.theVertex2Entry = theVertex2Entry;
1322 _verticesPeriodicityVector.push_back(vertexPeriodicity);
1324 NotifySubMeshesHypothesisModification();
1327 //=============================================================================
1328 std::ostream & BLSURFPlugin_Hypothesis::SaveTo(std::ostream & save) {
1329 // We must keep at least the same number of arguments when increasing the SALOME version
1330 // When BLSURF becomes CADMESH, some parameters were fused into a single one. Thus the same
1331 // parameter can be written several times to keep the old global number of parameters.
1333 // Treat old options which are now in the advanced options
1334 TOptionValues::iterator op_val;
1336 int _preCADRemoveNanoEdges = -1;
1337 double _preCADEpsNano = -1.0;
1338 op_val = _option2value.find("respect_geometry");
1339 if (op_val != _option2value.end()) {
1340 std::string value = op_val->second;
1342 _decimesh = value.compare("1") == 0 ? 1 : 0;
1344 op_val = _preCADoption2value.find("remove_tiny_edges");
1345 if (op_val != _preCADoption2value.end()) {
1346 std::string value = op_val->second;
1348 _preCADRemoveNanoEdges = value.compare("1") == 0 ? 1 : 0;
1350 op_val = _preCADoption2value.find("tiny_edge_length");
1351 if (op_val != _preCADoption2value.end()) {
1352 std::string value = op_val->second;
1354 _preCADEpsNano = strtod(value.c_str(), NULL);
1357 save << " " << (int) _topology << " " << (int) _physicalMesh << " " << (int) _geometricMesh << " " << _phySize << " "
1358 << _angleMesh << " " << _gradation << " " << (int) _quadAllowed << " " << _decimesh;
1359 save << " " << _minSize << " " << _maxSize << " " << _angleMesh << " " << _minSize << " " << _maxSize << " " << _verb;
1360 save << " " << (int) _preCADMergeEdges << " " << _preCADRemoveNanoEdges << " " << (int) _preCADDiscardInput << " " << _preCADEpsNano ;
1361 save << " " << (int) _enforcedInternalVerticesAllFaces;
1362 save << " " << (int) _phySizeRel << " " << (int) _minSizeRel << " " << (int) _maxSizeRel << " " << _chordalError ;
1363 save << " " << (int) _anisotropic << " " << _anisotropicRatio << " " << (int) _removeTinyEdges << " " << _tinyEdgeLength ;
1364 save << " " << (int) _badElementRemoval << " " << _badElementAspectRatio << " " << (int) _optimizeMesh << " " << (int) _quadraticMesh ;
1365 save << " " << (int) _preCADProcess3DTopology;
1367 op_val = _option2value.begin();
1368 if (op_val != _option2value.end()) {
1369 save << " " << "__OPTIONS_BEGIN__";
1370 for (; op_val != _option2value.end(); ++op_val) {
1371 if (!op_val->second.empty())
1372 save << " " << op_val->first << " " << op_val->second << "%#"; // "%#" is a mark of value end
1374 save << " " << "__OPTIONS_END__";
1377 op_val = _preCADoption2value.begin();
1378 if (op_val != _preCADoption2value.end()) {
1379 save << " " << "__PRECAD_OPTIONS_BEGIN__";
1380 for (; op_val != _preCADoption2value.end(); ++op_val) {
1381 if (!op_val->second.empty())
1382 save << " " << op_val->first << " " << op_val->second << "%#"; // "%#" is a mark of value end
1384 save << " " << "__PRECAD_OPTIONS_END__";
1387 TSizeMap::iterator it_sm = _sizeMap.begin();
1388 if (it_sm != _sizeMap.end()) {
1389 save << " " << "__SIZEMAP_BEGIN__";
1390 for (; it_sm != _sizeMap.end(); ++it_sm) {
1391 save << " " << it_sm->first << " " << it_sm->second << "%#"; // "%#" is a mark of value end
1393 save << " " << "__SIZEMAP_END__";
1396 TSizeMap::iterator it_at = _attractors.begin();
1397 if (it_at != _attractors.end()) {
1398 save << " " << "__ATTRACTORS_BEGIN__";
1399 for (; it_at != _attractors.end(); ++it_at) {
1400 save << " " << it_at->first << " " << it_at->second << "%#"; // "%#" is a mark of value end
1402 save << " " << "__ATTRACTORS_END__";
1405 TAttractorMap::iterator it_At = _classAttractors.begin();
1406 if (it_At != _classAttractors.end()) {
1407 std::ostringstream test;
1408 save << " " << "__NEW_ATTRACTORS_BEGIN__";
1409 test << " " << "__NEW_ATTRACTORS_BEGIN__";
1410 for (; it_At != _classAttractors.end(); ++it_At) {
1411 std::vector<double> attParams;
1412 attParams = it_At->second->GetParameters();
1413 // double step = it_At->second->GetStep();
1414 save << " " << it_At->first;
1415 save << " " << it_At->second->GetAttractorEntry();
1416 save << " " << attParams[0] << " " << attParams[1] << " " << attParams[2] << " " << attParams[3];
1417 // save << " " << step;
1418 test << " " << it_At->first;
1419 test << " " << it_At->second->GetAttractorEntry();
1420 test << " " << attParams[0] << " " << attParams[1] << " " << attParams[2] << " " << attParams[3];
1421 // test << " " << step;
1423 save << " " << "__NEW_ATTRACTORS_END__";
1424 test << " " << "__NEW_ATTRACTORS_END__";
1425 MESSAGE(" Attractor hypothesis saved as "<<test.str())
1428 TEnfVertexList::const_iterator it_enf = _enfVertexList.begin();
1429 if (it_enf != _enfVertexList.end()) {
1430 save << " " << "__ENFORCED_VERTICES_BEGIN__";
1431 for (; it_enf != _enfVertexList.end(); ++it_enf) {
1432 TEnfVertex *enfVertex = (*it_enf);
1433 save << " " << "__BEGIN_VERTEX__";
1434 if (!enfVertex->name.empty()) {
1435 save << " " << "__BEGIN_NAME__";
1436 save << " " << enfVertex->name;
1437 save << " " << "__END_NAME__";
1439 if (!enfVertex->geomEntry.empty()) {
1440 save << " " << "__BEGIN_ENTRY__";
1441 save << " " << enfVertex->geomEntry;
1442 save << " " << "__END_ENTRY__";
1444 if (!enfVertex->grpName.empty()) {
1445 save << " " << "__BEGIN_GROUP__";
1446 save << " " << enfVertex->grpName;
1447 save << " " << "__END_GROUP__";
1449 if (enfVertex->coords.size()) {
1450 save << " " << "__BEGIN_COORDS__";
1451 for (int i=0;i<enfVertex->coords.size();i++)
1452 save << " " << enfVertex->coords[i];
1453 save << " " << "__END_COORDS__";
1455 TEntryList::const_iterator faceEntriesIt = enfVertex->faceEntries.begin();
1456 bool hasFaces = false;
1457 if (faceEntriesIt != enfVertex->faceEntries.end()) {
1459 save << " " << "__BEGIN_FACELIST__";
1461 for (; faceEntriesIt != enfVertex->faceEntries.end(); ++faceEntriesIt)
1462 save << " " << (*faceEntriesIt);
1464 save << " " << "__END_FACELIST__";
1465 save << " " << "__END_VERTEX__";
1467 save << " " << "__ENFORCED_VERTICES_END__";
1472 SavePreCADPeriodicity(save, "FACES");
1473 SavePreCADPeriodicity(save, "EDGES");
1475 SaveFacesPeriodicity(save);
1476 SaveEdgesPeriodicity(save);
1477 SaveVerticesPeriodicity(save);
1482 void BLSURFPlugin_Hypothesis::SaveFacesPeriodicity(std::ostream & save){
1484 TFacesPeriodicityVector::const_iterator it_faces_periodicity = _facesPeriodicityVector.begin();
1485 if (it_faces_periodicity != _facesPeriodicityVector.end()) {
1486 MESSAGE("__FACES_PERIODICITY_BEGIN__");
1487 save << " " << "__FACES_PERIODICITY_BEGIN__";
1488 for (; it_faces_periodicity != _facesPeriodicityVector.end(); ++it_faces_periodicity) {
1489 TFacesPeriodicity periodicity_i = (*it_faces_periodicity);
1490 save << " " << "__BEGIN_PERIODICITY_DESCRIPTION__";
1491 save << " " << "__BEGIN_ENTRY1__";
1492 save << " " << periodicity_i.first;
1493 save << " " << "__END_ENTRY1__";
1494 save << " " << "__BEGIN_ENTRY2__";
1495 save << " " << periodicity_i.second;
1496 save << " " << "__END_ENTRY2__";
1497 save << " " << "__END_PERIODICITY_DESCRIPTION__";
1499 save << " " << "__FACES_PERIODICITY_END__";
1500 MESSAGE("__FACES_PERIODICITY_END__");
1504 void BLSURFPlugin_Hypothesis::SaveEdgesPeriodicity(std::ostream & save){
1506 TEdgesPeriodicityVector::const_iterator it_edges_periodicity = _edgesPeriodicityVector.begin();
1507 if (it_edges_periodicity != _edgesPeriodicityVector.end()) {
1508 save << " " << "__EDGES_PERIODICITY_BEGIN__";
1509 MESSAGE("__EDGES_PERIODICITY_BEGIN__");
1510 for (; it_edges_periodicity != _edgesPeriodicityVector.end(); ++it_edges_periodicity) {
1511 TEdgePeriodicity periodicity_i = (*it_edges_periodicity);
1512 save << " " << "__BEGIN_PERIODICITY_DESCRIPTION__";
1513 if (not periodicity_i.theFace1Entry.empty()){
1514 save << " " << "__BEGIN_FACE1__";
1515 save << " " << periodicity_i.theFace1Entry;
1516 save << " " << "__END_FACE1__";
1518 save << " " << "__BEGIN_EDGE1__";
1519 save << " " << periodicity_i.theEdge1Entry;
1520 save << " " << "__END_EDGE1__";
1521 if (not periodicity_i.theFace2Entry.empty()){
1522 save << " " << "__BEGIN_FACE2__";
1523 save << " " << periodicity_i.theFace2Entry;
1524 save << " " << "__END_FACE2__";
1526 save << " " << "__BEGIN_EDGE2__";
1527 save << " " << periodicity_i.theEdge2Entry;
1528 save << " " << "__END_EDGE2__";
1529 save << " " << "__BEGIN_EDGE_ORIENTATION__";
1530 save << " " << periodicity_i.edge_orientation;
1531 save << " " << "__END_EDGE_ORIENTATION__";
1532 save << " " << "__END_PERIODICITY_DESCRIPTION__";
1534 save << " " << "__EDGES_PERIODICITY_END__";
1535 MESSAGE("__EDGES_PERIODICITY_END__");
1539 void BLSURFPlugin_Hypothesis::SaveVerticesPeriodicity(std::ostream & save){
1541 TVerticesPeriodicityVector::const_iterator it_vertices_periodicity = _verticesPeriodicityVector.begin();
1542 if (it_vertices_periodicity != _verticesPeriodicityVector.end()) {
1543 MESSAGE("__VERTICES_PERIODICITY_BEGIN__");
1544 save << " " << "__VERTICES_PERIODICITY_BEGIN__";
1545 for (; it_vertices_periodicity != _verticesPeriodicityVector.end(); ++it_vertices_periodicity) {
1546 TVertexPeriodicity periodicity_i = (*it_vertices_periodicity);
1547 save << " " << "__BEGIN_PERIODICITY_DESCRIPTION__";
1548 save << " " << "__BEGIN_EDGE1__";
1549 save << " " << periodicity_i.theEdge1Entry;
1550 save << " " << "__END_EDGE1__";
1551 save << " " << "__BEGIN_VERTEX1__";
1552 save << " " << periodicity_i.theVertex1Entry;
1553 save << " " << "__END_VERTEX1__";
1554 save << " " << "__BEGIN_EDGE2__";
1555 save << " " << periodicity_i.theEdge2Entry;
1556 save << " " << "__END_EDGE2__";
1557 save << " " << "__BEGIN_VERTEX2__";
1558 save << " " << periodicity_i.theVertex2Entry;
1559 save << " " << "__END_VERTEX2__";
1560 save << " " << "__END_PERIODICITY_DESCRIPTION__";
1562 save << " " << "__VERTICES_PERIODICITY_END__";
1563 MESSAGE("__VERTICES_PERIODICITY_END__");
1567 void BLSURFPlugin_Hypothesis::SavePreCADPeriodicity(std::ostream & save, const char* shapeType) {
1568 TPreCadPeriodicityVector precad_periodicity;
1569 if (shapeType == "FACES")
1570 precad_periodicity = _preCadFacesPeriodicityVector;
1572 precad_periodicity = _preCadEdgesPeriodicityVector;
1573 TPreCadPeriodicityVector::const_iterator it_precad_periodicity = precad_periodicity.begin();
1574 if (it_precad_periodicity != precad_periodicity.end()) {
1575 save << " " << "__PRECAD_" << shapeType << "_PERIODICITY_BEGIN__";
1576 for (; it_precad_periodicity != precad_periodicity.end(); ++it_precad_periodicity) {
1577 TPreCadPeriodicity periodicity_i = (*it_precad_periodicity);
1578 save << " " << "__BEGIN_PERIODICITY_DESCRIPTION__";
1579 if (!periodicity_i.shape1Entry.empty()) {
1580 save << " " << "__BEGIN_ENTRY1__";
1581 save << " " << periodicity_i.shape1Entry;
1582 save << " " << "__END_ENTRY1__";
1584 if (!periodicity_i.shape2Entry.empty()) {
1585 save << " " << "__BEGIN_ENTRY2__";
1586 save << " " << periodicity_i.shape2Entry;
1587 save << " " << "__END_ENTRY2__";
1590 std::vector<std::string>::const_iterator sourceVerticesEntriesIt = periodicity_i.theSourceVerticesEntries.begin();
1591 bool hasSourceVertices = false;
1592 if (sourceVerticesEntriesIt != periodicity_i.theSourceVerticesEntries.end()) {
1593 hasSourceVertices = true;
1594 save << " " << "__BEGIN_SOURCE_VERTICES_LIST__";
1596 for (; sourceVerticesEntriesIt != periodicity_i.theSourceVerticesEntries.end(); ++sourceVerticesEntriesIt)
1597 save << " " << (*sourceVerticesEntriesIt);
1598 if (hasSourceVertices)
1599 save << " " << "__END_SOURCE_VERTICES_LIST__";
1601 std::vector<std::string>::const_iterator targetVerticesEntriesIt = periodicity_i.theTargetVerticesEntries.begin();
1602 bool hasTargetVertices = false;
1603 if (targetVerticesEntriesIt != periodicity_i.theTargetVerticesEntries.end()) {
1604 hasTargetVertices = true;
1605 save << " " << "__BEGIN_TARGET_VERTICES_LIST__";
1607 for (; targetVerticesEntriesIt != periodicity_i.theTargetVerticesEntries.end(); ++targetVerticesEntriesIt)
1608 save << " " << (*targetVerticesEntriesIt);
1609 if (hasTargetVertices)
1610 save << " " << "__END_TARGET_VERTICES_LIST__";
1612 save << " " << "__END_PERIODICITY_DESCRIPTION__";
1614 save << " " << "__PRECAD_" << shapeType << "_PERIODICITY_END__";
1619 //=============================================================================
1620 std::istream & BLSURFPlugin_Hypothesis::LoadFrom(std::istream & load) {
1624 std::string option_or_sm;
1628 _topology = (Topology) i;
1630 load.clear(std::ios::badbit | load.rdstate());
1634 _physicalMesh = (PhysicalMesh) i;
1636 load.clear(std::ios::badbit | load.rdstate());
1640 _geometricMesh = (GeometricMesh) i;
1642 load.clear(std::ios::badbit | load.rdstate());
1644 isOK = (load >> val);
1648 load.clear(std::ios::badbit | load.rdstate());
1650 isOK = (load >> val);
1654 load.clear(std::ios::badbit | load.rdstate());
1656 isOK = (load >> val);
1660 load.clear(std::ios::badbit | load.rdstate());
1664 _quadAllowed = (bool) i;
1666 load.clear(std::ios::badbit | load.rdstate());
1670 if ( i != -1) { // if value is -1, then this is no longer a standard option
1671 std::string & value = _option2value["respect_geometry"];
1672 bool _decimesh = (bool) i;
1673 value = _decimesh ? "1" : "0";
1677 load.clear(std::ios::badbit | load.rdstate());
1679 isOK = (load >> val);
1683 load.clear(std::ios::badbit | load.rdstate());
1685 isOK = (load >> val);
1689 load.clear(std::ios::badbit | load.rdstate());
1691 isOK = (load >> val);
1693 // former parameter: get min value
1694 _angleMesh = min(val,_angleMesh);
1696 load.clear(std::ios::badbit | load.rdstate());
1698 isOK = (load >> val);
1700 // former parameter: get min value
1701 _minSize = min(val,_minSize);
1703 load.clear(std::ios::badbit | load.rdstate());
1705 isOK = (load >> val);
1707 // former parameter: get max value
1708 _maxSize = max(val,_maxSize);
1710 load.clear(std::ios::badbit | load.rdstate());
1716 load.clear(std::ios::badbit | load.rdstate());
1720 _preCADMergeEdges = (bool) i;
1722 load.clear(std::ios::badbit | load.rdstate());
1726 if ( i != -1) { // if value is -1, then this is no longer a standard option
1727 std::string & value = _preCADoption2value["remove_tiny_edges"];
1728 bool _preCADRemoveNanoEdges = (bool) i;
1729 value = _preCADRemoveNanoEdges ? "1" : "0";
1733 load.clear(std::ios::badbit | load.rdstate());
1737 _preCADDiscardInput = (bool) i;
1739 load.clear(std::ios::badbit | load.rdstate());
1741 isOK = (load >> val);
1742 if (isOK) { // _preCADEpsNano
1743 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
1744 std::string & value = _preCADoption2value["tiny_edge_length"];
1745 std::ostringstream oss;
1751 load.clear(std::ios::badbit | load.rdstate());
1755 _enforcedInternalVerticesAllFaces = (bool) i;
1757 load.clear(std::ios::badbit | load.rdstate());
1759 // New options with MeshGems-CADSurf
1761 bool hasCADSurfOptions = false;
1762 bool hasOptions = false;
1763 bool hasPreCADOptions = false;
1764 bool hasSizeMap = false;
1765 bool hasAttractor = false;
1766 bool hasNewAttractor = false;
1767 bool hasEnforcedVertex = false;
1768 bool hasPreCADFacesPeriodicity = false;
1769 bool hasPreCADEdgesPeriodicity = false;
1770 bool hasFacesPeriodicity = false;
1771 bool hasEdgesPeriodicity = false;
1772 bool hasVerticesPeriodicity = false;
1774 isOK = (load >> option_or_sm);
1776 if ( (option_or_sm == "1")||(option_or_sm == "0") ) {
1777 i = atoi(option_or_sm.c_str());
1778 hasCADSurfOptions = true;
1779 _phySizeRel = (bool) i;
1781 if (option_or_sm == "__OPTIONS_BEGIN__")
1783 else if (option_or_sm == "__PRECAD_OPTIONS_BEGIN__")
1784 hasPreCADOptions = true;
1785 else if (option_or_sm == "__SIZEMAP_BEGIN__")
1787 else if (option_or_sm == "__ATTRACTORS_BEGIN__")
1788 hasAttractor = true;
1789 else if (option_or_sm == "__NEW_ATTRACTORS_BEGIN__")
1790 hasNewAttractor = true;
1791 else if (option_or_sm == "__ENFORCED_VERTICES_BEGIN__")
1792 hasEnforcedVertex = true;
1793 else if (option_or_sm == "__PRECAD_FACES_PERIODICITY_BEGIN__")
1794 hasPreCADFacesPeriodicity = true;
1795 else if (option_or_sm == "__PRECAD_EDGES_PERIODICITY_BEGIN__")
1796 hasPreCADEdgesPeriodicity = true;
1797 else if (option_or_sm == "__FACES_PERIODICITY_BEGIN__")
1798 hasFacesPeriodicity = true;
1799 else if (option_or_sm == "__EDGES_PERIODICITY_BEGIN__")
1800 hasEdgesPeriodicity = true;
1801 else if (option_or_sm == "__VERTICES_PERIODICITY_BEGIN__")
1802 hasVerticesPeriodicity = true;
1804 if (isOK && hasCADSurfOptions) {
1807 _minSizeRel = (bool) i;
1809 load.clear(std::ios::badbit | load.rdstate());
1813 _maxSizeRel = (bool) i;
1815 load.clear(std::ios::badbit | load.rdstate());
1817 isOK = (load >> val);
1819 _chordalError = val;
1821 load.clear(std::ios::badbit | load.rdstate());
1825 _anisotropic = (bool) i;
1827 load.clear(std::ios::badbit | load.rdstate());
1829 isOK = (load >> val);
1831 _anisotropicRatio = val;
1833 load.clear(std::ios::badbit | load.rdstate());
1837 _removeTinyEdges = (bool) i;
1839 load.clear(std::ios::badbit | load.rdstate());
1841 isOK = (load >> val);
1843 _tinyEdgeLength = val;
1845 load.clear(std::ios::badbit | load.rdstate());
1849 _badElementRemoval = (bool) i;
1851 load.clear(std::ios::badbit | load.rdstate());
1853 isOK = (load >> val);
1855 _badElementAspectRatio = val;
1857 load.clear(std::ios::badbit | load.rdstate());
1861 _optimizeMesh = (bool) i;
1863 load.clear(std::ios::badbit | load.rdstate());
1867 _quadraticMesh = (bool) i;
1869 load.clear(std::ios::badbit | load.rdstate());
1873 _preCADProcess3DTopology = (bool) i;
1875 load.clear(std::ios::badbit | load.rdstate());
1880 if (hasCADSurfOptions) {
1881 isOK = (load >> option_or_sm);
1883 if (option_or_sm == "__OPTIONS_BEGIN__")
1885 else if (option_or_sm == "__PRECAD_OPTIONS_BEGIN__")
1886 hasPreCADOptions = true;
1887 else if (option_or_sm == "__SIZEMAP_BEGIN__")
1889 else if (option_or_sm == "__ATTRACTORS_BEGIN__")
1890 hasAttractor = true;
1891 else if (option_or_sm == "__NEW_ATTRACTORS_BEGIN__")
1892 hasNewAttractor = true;
1893 else if (option_or_sm == "__ENFORCED_VERTICES_BEGIN__")
1894 hasEnforcedVertex = true;
1895 else if (option_or_sm == "__PRECAD_FACES_PERIODICITY_BEGIN__")
1896 hasPreCADFacesPeriodicity = true;
1897 else if (option_or_sm == "__PRECAD_EDGES_PERIODICITY_BEGIN__")
1898 hasPreCADEdgesPeriodicity = true;
1899 else if (option_or_sm == "__FACES_PERIODICITY_BEGIN__")
1900 hasFacesPeriodicity = true;
1901 else if (option_or_sm == "__EDGES_PERIODICITY_BEGIN__")
1902 hasEdgesPeriodicity = true;
1903 else if (option_or_sm == "__VERTICES_PERIODICITY_BEGIN__")
1904 hasVerticesPeriodicity = true;
1907 std::string optName, optValue;
1908 while (isOK && hasOptions) {
1909 isOK = (load >> optName);
1911 if (optName == "__OPTIONS_END__")
1913 isOK = (load >> optValue);
1916 std::string & value = _option2value[optName];
1918 int len = value.size();
1919 // continue reading until "%#" encountered
1920 while (value[len - 1] != '#' || value[len - 2] != '%') {
1921 isOK = (load >> optValue);
1930 value[len - 2] = '\0'; //cut off "%#"
1935 isOK = (load >> option_or_sm);
1937 if (option_or_sm == "__PRECAD_OPTIONS_BEGIN__")
1938 hasPreCADOptions = true;
1939 else if (option_or_sm == "__SIZEMAP_BEGIN__")
1941 else if (option_or_sm == "__ATTRACTORS_BEGIN__")
1942 hasAttractor = true;
1943 else if (option_or_sm == "__NEW_ATTRACTORS_BEGIN__")
1944 hasNewAttractor = true;
1945 else if (option_or_sm == "__ENFORCED_VERTICES_BEGIN__")
1946 hasEnforcedVertex = true;
1947 else if (option_or_sm == "__PRECAD_FACES_PERIODICITY_BEGIN__")
1948 hasPreCADFacesPeriodicity = true;
1949 else if (option_or_sm == "__PRECAD_EDGES_PERIODICITY_BEGIN__")
1950 hasPreCADEdgesPeriodicity = true;
1951 else if (option_or_sm == "__FACES_PERIODICITY_BEGIN__")
1952 hasFacesPeriodicity = true;
1953 else if (option_or_sm == "__EDGES_PERIODICITY_BEGIN__")
1954 hasEdgesPeriodicity = true;
1955 else if (option_or_sm == "__VERTICES_PERIODICITY_BEGIN__")
1956 hasVerticesPeriodicity = true;
1959 while (isOK && hasPreCADOptions) {
1960 isOK = (load >> optName);
1962 if (optName == "__PRECAD_OPTIONS_END__")
1964 isOK = (load >> optValue);
1967 std::string & value = _preCADoption2value[optName];
1969 int len = value.size();
1970 // continue reading until "%#" encountered
1971 while (value[len - 1] != '#' || value[len - 2] != '%') {
1972 isOK = (load >> optValue);
1981 value[len - 2] = '\0'; //cut off "%#"
1985 if (hasPreCADOptions) {
1986 isOK = (load >> option_or_sm);
1988 if (option_or_sm == "__SIZEMAP_BEGIN__")
1990 else if (option_or_sm == "__ATTRACTORS_BEGIN__")
1991 hasAttractor = true;
1992 else if (option_or_sm == "__NEW_ATTRACTORS_BEGIN__")
1993 hasNewAttractor = true;
1994 else if (option_or_sm == "__ENFORCED_VERTICES_BEGIN__")
1995 hasEnforcedVertex = true;
1996 else if (option_or_sm == "__PRECAD_FACES_PERIODICITY_BEGIN__")
1997 hasPreCADFacesPeriodicity = true;
1998 else if (option_or_sm == "__PRECAD_EDGES_PERIODICITY_BEGIN__")
1999 hasPreCADEdgesPeriodicity = true;
2000 else if (option_or_sm == "__FACES_PERIODICITY_BEGIN__")
2001 hasFacesPeriodicity = true;
2002 else if (option_or_sm == "__EDGES_PERIODICITY_BEGIN__")
2003 hasEdgesPeriodicity = true;
2004 else if (option_or_sm == "__VERTICES_PERIODICITY_BEGIN__")
2005 hasVerticesPeriodicity = true;
2008 std::string smEntry, smValue;
2009 while (isOK && hasSizeMap) {
2010 isOK = (load >> smEntry);
2012 if (smEntry == "__SIZEMAP_END__")
2014 isOK = (load >> smValue);
2017 std::string & value2 = _sizeMap[smEntry];
2019 int len2 = value2.size();
2020 // continue reading until "%#" encountered
2021 while (value2[len2 - 1] != '#' || value2[len2 - 2] != '%') {
2022 isOK = (load >> smValue);
2026 len2 = value2.size();
2031 value2[len2 - 2] = '\0'; //cut off "%#"
2036 isOK = (load >> option_or_sm);
2038 if (option_or_sm == "__ATTRACTORS_BEGIN__")
2039 hasAttractor = true;
2040 if (option_or_sm == "__NEW_ATTRACTORS_BEGIN__")
2041 hasNewAttractor = true;
2042 else if (option_or_sm == "__ENFORCED_VERTICES_BEGIN__")
2043 hasEnforcedVertex = true;
2044 else if (option_or_sm == "__PRECAD_FACES_PERIODICITY_BEGIN__")
2045 hasPreCADFacesPeriodicity = true;
2046 else if (option_or_sm == "__PRECAD_EDGES_PERIODICITY_BEGIN__")
2047 hasPreCADEdgesPeriodicity = true;
2048 else if (option_or_sm == "__FACES_PERIODICITY_BEGIN__")
2049 hasFacesPeriodicity = true;
2050 else if (option_or_sm == "__EDGES_PERIODICITY_BEGIN__")
2051 hasEdgesPeriodicity = true;
2052 else if (option_or_sm == "__VERTICES_PERIODICITY_BEGIN__")
2053 hasVerticesPeriodicity = true;
2056 std::string atEntry, atValue;
2057 while (isOK && hasAttractor) {
2058 isOK = (load >> atEntry);
2060 if (atEntry == "__ATTRACTORS_END__")
2062 isOK = (load >> atValue);
2065 std::string & value3 = _attractors[atEntry];
2067 int len3 = value3.size();
2068 // continue reading until "%#" encountered
2069 while (value3[len3 - 1] != '#' || value3[len3 - 2] != '%') {
2070 isOK = (load >> atValue);
2074 len3 = value3.size();
2079 value3[len3 - 2] = '\0'; //cut off "%#"
2084 isOK = (load >> option_or_sm);
2086 if (option_or_sm == "__NEW_ATTRACTORS_BEGIN__")
2087 hasNewAttractor = true;
2088 else if (option_or_sm == "__ENFORCED_VERTICES_BEGIN__")
2089 hasEnforcedVertex = true;
2090 else if (option_or_sm == "__PRECAD_FACES_PERIODICITY_BEGIN__")
2091 hasPreCADFacesPeriodicity = true;
2092 else if (option_or_sm == "__PRECAD_EDGES_PERIODICITY_BEGIN__")
2093 hasPreCADEdgesPeriodicity = true;
2094 else if (option_or_sm == "__FACES_PERIODICITY_BEGIN__")
2095 hasFacesPeriodicity = true;
2096 else if (option_or_sm == "__EDGES_PERIODICITY_BEGIN__")
2097 hasEdgesPeriodicity = true;
2098 else if (option_or_sm == "__VERTICES_PERIODICITY_BEGIN__")
2099 hasVerticesPeriodicity = true;
2102 std::string newAtFaceEntry, atTestString;
2103 std::string newAtShapeEntry;
2104 double attParams[4];
2106 while (isOK && hasNewAttractor) {
2107 std::cout<<"Load new attractor"<<std::endl;
2108 isOK = (load >> newAtFaceEntry);
2110 if (newAtFaceEntry == "__NEW_ATTRACTORS_END__")
2112 isOK = (load >> newAtShapeEntry);
2115 isOK = (load >> attParams[0]>>attParams[1]>>attParams[2]>>attParams[3]); //>>step);
2118 MESSAGE(" LOADING ATTRACTOR HYPOTHESIS ")
2119 const TopoDS_Shape attractorShape = BLSURFPlugin_Hypothesis::entryToShape(newAtShapeEntry);
2120 const TopoDS_Face faceShape = TopoDS::Face(BLSURFPlugin_Hypothesis::entryToShape(newAtFaceEntry));
2121 BLSURFPlugin_Attractor* attractor = new BLSURFPlugin_Attractor(faceShape, attractorShape, newAtShapeEntry);//, step);
2122 attractor->SetParameters(attParams[0], attParams[1], attParams[2], attParams[3]);
2123 attractor->BuildMap();
2124 _classAttractors[newAtFaceEntry]=attractor;
2129 if (hasNewAttractor) {
2130 isOK = (load >> option_or_sm);
2132 if (option_or_sm == "__ENFORCED_VERTICES_BEGIN__")
2133 hasEnforcedVertex = true;
2134 else if (option_or_sm == "__PRECAD_FACES_PERIODICITY_BEGIN__")
2135 hasPreCADFacesPeriodicity = true;
2136 else if (option_or_sm == "__PRECAD_EDGES_PERIODICITY_BEGIN__")
2137 hasPreCADEdgesPeriodicity = true;
2138 else if (option_or_sm == "__FACES_PERIODICITY_BEGIN__")
2139 hasFacesPeriodicity = true;
2140 else if (option_or_sm == "__EDGES_PERIODICITY_BEGIN__")
2141 hasEdgesPeriodicity = true;
2142 else if (option_or_sm == "__VERTICES_PERIODICITY_BEGIN__")
2143 hasVerticesPeriodicity = true;
2148 // Here is a example of the saved stream:
2149 // __ENFORCED_VERTICES_BEGIN__
2150 // __BEGIN_VERTEX__ => no name, no entry
2151 // __BEGIN_GROUP__ mon groupe __END_GROUP__
2152 // __BEGIN_COORDS__ 10 10 10 __END_COORDS__
2153 // __BEGIN_FACELIST__ 0:1:1:1:1 __END_FACELIST__
2155 // __BEGIN_VERTEX__ => no coords
2156 // __BEGIN_NAME__ mes points __END_NAME__
2157 // __BEGIN_ENTRY__ 0:1:1:4 __END_ENTRY__
2158 // __BEGIN_GROUP__ mon groupe __END_GROUP__
2159 // __BEGIN_FACELIST__ 0:1:1:1:3 __END_FACELIST__
2161 // __ENFORCED_VERTICES_END__
2164 std::string enfSeparator;
2165 std::string enfName;
2166 std::string enfGeomEntry;
2167 std::string enfGroup;
2168 TEntryList enfFaceEntryList;
2169 double enfCoords[3];
2170 bool hasCoords = false;
2172 _faceEntryEnfVertexListMap.clear();
2173 _enfVertexList.clear();
2174 _faceEntryCoordsListMap.clear();
2175 _coordsEnfVertexMap.clear();
2176 _faceEntryEnfVertexEntryListMap.clear();
2177 _enfVertexEntryEnfVertexMap.clear();
2180 while (isOK && hasEnforcedVertex) {
2181 isOK = (load >> enfSeparator); // __BEGIN_VERTEX__
2182 TEnfVertex *enfVertex = new TEnfVertex();
2183 // MESSAGE("enfSeparator: " <<enfSeparator);
2184 if (enfSeparator == "__ENFORCED_VERTICES_END__")
2185 break; // __ENFORCED_VERTICES_END__
2186 if (enfSeparator != "__BEGIN_VERTEX__")
2187 throw std::exception();
2190 isOK = (load >> enfSeparator);
2191 MESSAGE("enfSeparator: " <<enfSeparator);
2192 if (enfSeparator == "__END_VERTEX__") {
2194 enfVertex->name = enfName;
2195 enfVertex->geomEntry = enfGeomEntry;
2196 enfVertex->grpName = enfGroup;
2197 enfVertex->coords.clear();
2199 enfVertex->coords.assign(enfCoords,enfCoords+3);
2200 enfVertex->faceEntries = enfFaceEntryList;
2202 _enfVertexList.insert(enfVertex);
2204 if (enfVertex->coords.size()) {
2205 _coordsEnfVertexMap[enfVertex->coords] = enfVertex;
2206 for (TEntryList::const_iterator it = enfVertex->faceEntries.begin() ; it != enfVertex->faceEntries.end(); ++it) {
2207 _faceEntryCoordsListMap[(*it)].insert(enfVertex->coords);
2208 _faceEntryEnfVertexListMap[(*it)].insert(enfVertex);
2211 if (!enfVertex->geomEntry.empty()) {
2212 _enfVertexEntryEnfVertexMap[enfVertex->geomEntry] = enfVertex;
2213 for (TEntryList::const_iterator it = enfVertex->faceEntries.begin() ; it != enfVertex->faceEntries.end(); ++it) {
2214 _faceEntryEnfVertexEntryListMap[(*it)].insert(enfVertex->geomEntry);
2215 _faceEntryEnfVertexListMap[(*it)].insert(enfVertex);
2220 enfGeomEntry.clear();
2222 enfFaceEntryList.clear();
2224 break; // __END_VERTEX__
2227 if (enfSeparator == "__BEGIN_NAME__") { // __BEGIN_NAME__
2228 while (isOK && (enfSeparator != "__END_NAME__")) {
2229 isOK = (load >> enfSeparator);
2230 if (enfSeparator != "__END_NAME__") {
2231 if (!enfName.empty())
2233 enfName += enfSeparator;
2236 MESSAGE("enfName: " <<enfName);
2239 if (enfSeparator == "__BEGIN_ENTRY__") { // __BEGIN_ENTRY__
2240 isOK = (load >> enfGeomEntry);
2241 isOK = (load >> enfSeparator); // __END_ENTRY__
2242 if (enfSeparator != "__END_ENTRY__")
2243 throw std::exception();
2244 MESSAGE("enfGeomEntry: " <<enfGeomEntry);
2247 if (enfSeparator == "__BEGIN_GROUP__") { // __BEGIN_GROUP__
2248 while (isOK && (enfSeparator != "__END_GROUP__")) {
2249 isOK = (load >> enfSeparator);
2250 if (enfSeparator != "__END_GROUP__") {
2251 if (!enfGroup.empty())
2253 enfGroup += enfSeparator;
2256 MESSAGE("enfGroup: " <<enfGroup);
2259 if (enfSeparator == "__BEGIN_COORDS__") { // __BEGIN_COORDS__
2261 isOK = (load >> enfCoords[0] >> enfCoords[1] >> enfCoords[2]);
2262 isOK = (load >> enfSeparator); // __END_COORDS__
2263 if (enfSeparator != "__END_COORDS__")
2264 throw std::exception();
2265 MESSAGE("enfCoords: " << enfCoords[0] <<","<< enfCoords[1] <<","<< enfCoords[2]);
2268 if (enfSeparator == "__BEGIN_FACELIST__") { // __BEGIN_FACELIST__
2269 while (isOK && (enfSeparator != "__END_FACELIST__")) {
2270 isOK = (load >> enfSeparator);
2271 if (enfSeparator != "__END_FACELIST__") {
2272 enfFaceEntryList.insert(enfSeparator);
2273 MESSAGE(enfSeparator << " was inserted into enfFaceEntryList");
2282 if (hasPreCADFacesPeriodicity){
2283 LoadPreCADPeriodicity(load, "FACES");
2285 isOK = (load >> option_or_sm);
2287 if (option_or_sm == "__PRECAD_EDGES_PERIODICITY_BEGIN__")
2288 hasPreCADEdgesPeriodicity = true;
2289 else if (option_or_sm == "__FACES_PERIODICITY_BEGIN__")
2290 hasFacesPeriodicity = true;
2291 else if (option_or_sm == "__EDGES_PERIODICITY_BEGIN__")
2292 hasEdgesPeriodicity = true;
2293 else if (option_or_sm == "__VERTICES_PERIODICITY_BEGIN__")
2294 hasVerticesPeriodicity = true;
2297 if (hasPreCADEdgesPeriodicity){
2298 LoadPreCADPeriodicity(load, "EDGES");
2300 isOK = (load >> option_or_sm);
2302 if (option_or_sm == "__FACES_PERIODICITY_BEGIN__")
2303 hasFacesPeriodicity = true;
2304 else if (option_or_sm == "__EDGES_PERIODICITY_BEGIN__")
2305 hasEdgesPeriodicity = true;
2306 else if (option_or_sm == "__VERTICES_PERIODICITY_BEGIN__")
2307 hasVerticesPeriodicity = true;
2310 if (hasFacesPeriodicity){
2311 LoadFacesPeriodicity(load);
2313 isOK = (load >> option_or_sm);
2315 if (option_or_sm == "__EDGES_PERIODICITY_BEGIN__")
2316 hasEdgesPeriodicity = true;
2317 else if (option_or_sm == "__VERTICES_PERIODICITY_BEGIN__")
2318 hasVerticesPeriodicity = true;
2321 if (hasEdgesPeriodicity){
2322 LoadEdgesPeriodicity(load);
2324 isOK = (load >> option_or_sm);
2326 if (option_or_sm == "__VERTICES_PERIODICITY_BEGIN__")
2327 hasVerticesPeriodicity = true;
2330 if (hasVerticesPeriodicity)
2331 LoadVerticesPeriodicity(load);
2336 void BLSURFPlugin_Hypothesis::LoadFacesPeriodicity(std::istream & load){
2340 std::string periodicitySeparator;
2344 _facesPeriodicityVector.clear();
2347 isOK = (load >> periodicitySeparator); // __BEGIN_PERIODICITY_DESCRIPTION__
2348 MESSAGE("periodicitySeparator 1: " <<periodicitySeparator);
2349 TFacesPeriodicity *periodicity_i = new TFacesPeriodicity();
2350 if (periodicitySeparator == "__FACES_PERIODICITY_END__")
2351 break; // __FACES_PERIODICITY_END__
2352 if (periodicitySeparator != "__BEGIN_PERIODICITY_DESCRIPTION__"){
2353 MESSAGE("//" << periodicitySeparator << "//");
2354 throw std::exception();
2358 isOK = (load >> periodicitySeparator);
2359 MESSAGE("periodicitySeparator 2: " <<periodicitySeparator);
2360 if (periodicitySeparator == "__END_PERIODICITY_DESCRIPTION__") {
2362 periodicity_i->first = shape1Entry;
2363 periodicity_i->second = shape2Entry;
2365 _facesPeriodicityVector.push_back(*periodicity_i);
2367 break; // __END_PERIODICITY_DESCRIPTION__
2370 if (periodicitySeparator == "__BEGIN_ENTRY1__") { // __BEGIN_ENTRY1__
2371 isOK = (load >> shape1Entry);
2372 isOK = (load >> periodicitySeparator); // __END_ENTRY1__
2373 if (periodicitySeparator != "__END_ENTRY1__")
2374 throw std::exception();
2375 MESSAGE("shape1Entry: " <<shape1Entry);
2378 if (periodicitySeparator == "__BEGIN_ENTRY2__") { // __BEGIN_ENTRY2__
2379 isOK = (load >> shape2Entry);
2380 isOK = (load >> periodicitySeparator); // __END_ENTRY2__
2381 if (periodicitySeparator != "__END_ENTRY2__")
2382 throw std::exception();
2383 MESSAGE("shape2Entry: " <<shape2Entry);
2390 void BLSURFPlugin_Hypothesis::LoadEdgesPeriodicity(std::istream & load){
2394 std::string periodicitySeparator;
2395 TEntry theFace1Entry;
2396 TEntry theEdge1Entry;
2397 TEntry theFace2Entry;
2398 TEntry theEdge2Entry;
2399 int edge_orientation = 0;
2401 _edgesPeriodicityVector.clear();
2404 isOK = (load >> periodicitySeparator); // __BEGIN_PERIODICITY_DESCRIPTION__
2405 MESSAGE("periodicitySeparator 1: " <<periodicitySeparator);
2406 TEdgePeriodicity *periodicity_i = new TEdgePeriodicity();
2407 if (periodicitySeparator == "__EDGES_PERIODICITY_END__")
2408 break; // __EDGES_PERIODICITY_END__
2409 if (periodicitySeparator != "__BEGIN_PERIODICITY_DESCRIPTION__"){
2410 MESSAGE("//" << periodicitySeparator << "//");
2411 throw std::exception();
2415 isOK = (load >> periodicitySeparator);
2416 MESSAGE("periodicitySeparator 2: " <<periodicitySeparator);
2417 if (periodicitySeparator == "__END_PERIODICITY_DESCRIPTION__") {
2419 periodicity_i->theFace1Entry = theFace1Entry;
2420 periodicity_i->theEdge1Entry = theEdge1Entry;
2421 periodicity_i->theFace2Entry = theFace2Entry;
2422 periodicity_i->theEdge2Entry = theEdge2Entry;
2423 periodicity_i->edge_orientation = edge_orientation;
2425 _edgesPeriodicityVector.push_back(*periodicity_i);
2427 break; // __END_PERIODICITY_DESCRIPTION__
2430 if (periodicitySeparator == "__BEGIN_FACE1__") { // __BEGIN_FACE1__
2431 isOK = (load >> theFace1Entry);
2432 MESSAGE("//" << theFace1Entry << "//");
2433 isOK = (load >> periodicitySeparator); // __END_FACE1__
2434 if (periodicitySeparator != "__END_FACE1__"){
2435 MESSAGE("//" << periodicitySeparator << "//");
2436 throw std::exception();
2438 MESSAGE("theFace1Entry: " <<theFace1Entry);
2441 if (periodicitySeparator == "__BEGIN_EDGE1__") { // __BEGIN_EDGE1__
2442 isOK = (load >> theEdge1Entry);
2443 isOK = (load >> periodicitySeparator); // __END_EDGE1__
2444 if (periodicitySeparator != "__END_EDGE1__")
2445 throw std::exception();
2446 MESSAGE("theEdge1Entry: " <<theEdge1Entry);
2449 if (periodicitySeparator == "__BEGIN_FACE2__") { // __BEGIN_FACE2__
2450 isOK = (load >> theFace2Entry);
2451 isOK = (load >> periodicitySeparator); // __END_FACE2__
2452 if (periodicitySeparator != "__END_FACE2__")
2453 throw std::exception();
2454 MESSAGE("theFace2Entry: " <<theFace2Entry);
2457 if (periodicitySeparator == "__BEGIN_EDGE2__") { // __BEGIN_EDGE2__
2458 isOK = (load >> theEdge2Entry);
2459 isOK = (load >> periodicitySeparator); // __END_EDGE2__
2460 if (periodicitySeparator != "__END_EDGE2__")
2461 throw std::exception();
2462 MESSAGE("theEdge2Entry: " <<theEdge2Entry);
2465 if (periodicitySeparator == "__BEGIN_EDGE_ORIENTATION__") { // __BEGIN_EDGE_ORIENTATION__
2466 isOK = (load >> edge_orientation);
2467 isOK = (load >> periodicitySeparator); // __END_EDGE_ORIENTATION__
2468 if (periodicitySeparator != "__END_EDGE_ORIENTATION__")
2469 throw std::exception();
2470 MESSAGE("edge_orientation: " <<edge_orientation);
2476 void BLSURFPlugin_Hypothesis::LoadVerticesPeriodicity(std::istream & load){
2480 std::string periodicitySeparator;
2481 TEntry theEdge1Entry;
2482 TEntry theVertex1Entry;
2483 TEntry theEdge2Entry;
2484 TEntry theVertex2Entry;
2486 _verticesPeriodicityVector.clear();
2489 isOK = (load >> periodicitySeparator); // __BEGIN_PERIODICITY_DESCRIPTION__
2490 MESSAGE("periodicitySeparator 1: " <<periodicitySeparator);
2491 TVertexPeriodicity *periodicity_i = new TVertexPeriodicity();
2492 if (periodicitySeparator == "__VERTICES_PERIODICITY_END__")
2493 break; // __VERTICES_PERIODICITY_END__
2494 if (periodicitySeparator != "__BEGIN_PERIODICITY_DESCRIPTION__"){
2495 MESSAGE("//" << periodicitySeparator << "//");
2496 throw std::exception();
2500 isOK = (load >> periodicitySeparator);
2501 MESSAGE("periodicitySeparator 2: " <<periodicitySeparator);
2502 if (periodicitySeparator == "__END_PERIODICITY_DESCRIPTION__") {
2504 periodicity_i->theEdge1Entry = theEdge1Entry;
2505 periodicity_i->theVertex1Entry = theVertex1Entry;
2506 periodicity_i->theEdge2Entry = theEdge2Entry;
2507 periodicity_i->theVertex2Entry = theVertex2Entry;
2509 _verticesPeriodicityVector.push_back(*periodicity_i);
2511 break; // __END_PERIODICITY_DESCRIPTION__
2514 if (periodicitySeparator == "__BEGIN_EDGE1__") { // __BEGIN_EDGE1__
2515 isOK = (load >> theEdge1Entry);
2516 isOK = (load >> periodicitySeparator); // __END_EDGE1__
2517 if (periodicitySeparator != "__END_EDGE1__")
2518 throw std::exception();
2519 MESSAGE("theEdge1Entry: " <<theEdge1Entry);
2522 if (periodicitySeparator == "__BEGIN_VERTEX1__") { // __BEGIN_VERTEX1__
2523 isOK = (load >> theVertex1Entry);
2524 isOK = (load >> periodicitySeparator); // __END_VERTEX1__
2525 if (periodicitySeparator != "__END_VERTEX1__")
2526 throw std::exception();
2527 MESSAGE("theVertex1Entry: " <<theVertex1Entry);
2530 if (periodicitySeparator == "__BEGIN_EDGE2__") { // __BEGIN_EDGE2__
2531 isOK = (load >> theEdge2Entry);
2532 isOK = (load >> periodicitySeparator); // __END_EDGE2__
2533 if (periodicitySeparator != "__END_EDGE2__")
2534 throw std::exception();
2535 MESSAGE("theEdge2Entry: " <<theEdge2Entry);
2538 if (periodicitySeparator == "__BEGIN_VERTEX2__") { // __BEGIN_VERTEX2__
2539 isOK = (load >> theVertex2Entry);
2540 isOK = (load >> periodicitySeparator); // __END_VERTEX2__
2541 if (periodicitySeparator != "__END_VERTEX2__")
2542 throw std::exception();
2543 MESSAGE("theVertex2Entry: " <<theVertex2Entry);
2549 void BLSURFPlugin_Hypothesis::LoadPreCADPeriodicity(std::istream & load, const char* shapeType) {
2553 std::string periodicitySeparator;
2556 std::vector<std::string> theSourceVerticesEntries;
2557 std::vector<std::string> theTargetVerticesEntries;
2559 bool hasSourceVertices = false;
2560 bool hasTargetVertices = false;
2562 if (shapeType == "FACES")
2563 _preCadFacesPeriodicityVector.clear();
2565 _preCadEdgesPeriodicityVector.clear();
2569 isOK = (load >> periodicitySeparator); // __BEGIN_PERIODICITY_DESCRIPTION__
2570 MESSAGE("periodicitySeparator 1: " <<periodicitySeparator);
2571 TPreCadPeriodicity *periodicity_i = new TPreCadPeriodicity();
2572 // MESSAGE("periodicitySeparator: " <<periodicitySeparator);
2573 std::string endSeparator = "__PRECAD_" + std::string(shapeType) + "_PERIODICITY_END__";
2574 if (periodicitySeparator == endSeparator)
2575 break; // __PRECAD_FACES_PERIODICITY_END__
2576 if (periodicitySeparator != "__BEGIN_PERIODICITY_DESCRIPTION__"){
2577 MESSAGE("//" << endSeparator << "//");
2578 MESSAGE("//" << periodicitySeparator << "//");
2579 throw std::exception();
2583 isOK = (load >> periodicitySeparator);
2584 MESSAGE("periodicitySeparator 2: " <<periodicitySeparator);
2585 if (periodicitySeparator == "__END_PERIODICITY_DESCRIPTION__") {
2587 periodicity_i->shape1Entry = shape1Entry;
2588 periodicity_i->shape2Entry = shape2Entry;
2590 MESSAGE("theSourceVerticesEntries.size(): " << theSourceVerticesEntries.size());
2591 MESSAGE("theTargetVerticesEntries.size(): " << theTargetVerticesEntries.size());
2593 if (hasSourceVertices)
2594 periodicity_i->theSourceVerticesEntries = theSourceVerticesEntries;
2595 if (hasTargetVertices)
2596 periodicity_i->theTargetVerticesEntries = theTargetVerticesEntries;
2598 if (shapeType == "FACES")
2599 _preCadFacesPeriodicityVector.push_back(*periodicity_i);
2601 _preCadEdgesPeriodicityVector.push_back(*periodicity_i);
2603 theSourceVerticesEntries.clear();
2604 theTargetVerticesEntries.clear();
2605 hasSourceVertices = false;
2606 hasTargetVertices = false;
2607 break; // __END_PERIODICITY_DESCRIPTION__
2610 if (periodicitySeparator == "__BEGIN_ENTRY1__") { // __BEGIN_ENTRY1__
2611 isOK = (load >> shape1Entry);
2612 isOK = (load >> periodicitySeparator); // __END_ENTRY1__
2613 if (periodicitySeparator != "__END_ENTRY1__")
2614 throw std::exception();
2615 MESSAGE("shape1Entry: " <<shape1Entry);
2618 if (periodicitySeparator == "__BEGIN_ENTRY2__") { // __BEGIN_ENTRY2__
2619 isOK = (load >> shape2Entry);
2620 isOK = (load >> periodicitySeparator); // __END_ENTRY2__
2621 if (periodicitySeparator != "__END_ENTRY2__")
2622 throw std::exception();
2623 MESSAGE("shape2Entry: " <<shape2Entry);
2626 if (periodicitySeparator == "__BEGIN_SOURCE_VERTICES_LIST__") { // __BEGIN_SOURCE_VERTICES_LIST__
2627 hasSourceVertices = true;
2628 while (isOK && (periodicitySeparator != "__END_SOURCE_VERTICES_LIST__")) {
2629 isOK = (load >> periodicitySeparator);
2630 if (periodicitySeparator != "__END_SOURCE_VERTICES_LIST__") {
2631 theSourceVerticesEntries.push_back(periodicitySeparator);
2632 MESSAGE("theSourceVerticesEntries: " <<periodicitySeparator);
2637 if (periodicitySeparator == "__BEGIN_TARGET_VERTICES_LIST__") { // __BEGIN_TARGET_VERTICES_LIST__
2638 hasTargetVertices = true;
2639 while (isOK && (periodicitySeparator != "__END_TARGET_VERTICES_LIST__")) {
2640 isOK = (load >> periodicitySeparator);
2641 if (periodicitySeparator != "__END_TARGET_VERTICES_LIST__") {
2642 theTargetVerticesEntries.push_back(periodicitySeparator);
2643 MESSAGE("theTargetVerticesEntries: " <<periodicitySeparator);
2651 //=============================================================================
2652 std::ostream & operator <<(std::ostream & save, BLSURFPlugin_Hypothesis & hyp) {
2653 return hyp.SaveTo(save);
2656 //=============================================================================
2657 std::istream & operator >>(std::istream & load, BLSURFPlugin_Hypothesis & hyp) {
2658 return hyp.LoadFrom(load);
2661 //================================================================================
2663 * \brief Does nothing
2665 //================================================================================
2667 bool BLSURFPlugin_Hypothesis::SetParametersByMesh(const SMESH_Mesh* theMesh, const TopoDS_Shape& theShape) {
2671 //================================================================================
2673 * \brief Returns default global constant physical size given a default value of element length ratio
2675 //================================================================================
2677 double BLSURFPlugin_Hypothesis::GetDefaultPhySize(double diagonal, double bbSegmentation) {
2678 if (bbSegmentation != 0 && diagonal != 0)
2679 return diagonal / bbSegmentation ;
2683 //================================================================================
2685 * \brief Returns default min size given a default value of element length ratio
2687 //================================================================================
2689 double BLSURFPlugin_Hypothesis::GetDefaultMinSize(double diagonal) {
2691 return diagonal / 1000.0 ;
2692 return undefinedDouble();
2695 //================================================================================
2697 * \brief Returns default max size given a default value of element length ratio
2699 //================================================================================
2701 double BLSURFPlugin_Hypothesis::GetDefaultMaxSize(double diagonal) {
2703 return diagonal / 5.0 ;
2704 return undefinedDouble();
2707 //================================================================================
2709 * \brief Returns default chordal error given a default value of element length ratio
2711 //================================================================================
2713 double BLSURFPlugin_Hypothesis::GetDefaultChordalError(double diagonal) {
2716 return undefinedDouble();
2719 //================================================================================
2721 * \brief Returns default tiny edge length given a default value of element length ratio
2723 //================================================================================
2725 double BLSURFPlugin_Hypothesis::GetDefaultTinyEdgeLength(double diagonal) {
2727 return diagonal * 1e-6 ;
2728 return undefinedDouble();
2731 //=============================================================================
2733 * \brief Initialize my parameter values by default parameters.
2734 * \retval bool - true if parameter values have been successfully defined
2736 //=============================================================================
2738 bool BLSURFPlugin_Hypothesis::SetParametersByDefaults(const TDefaults& dflts, const SMESH_Mesh* theMesh) {
2739 double diagonal = dflts._elemLength*_gen->GetBoundaryBoxSegmentation();
2740 _phySize = GetDefaultPhySize(diagonal, _gen->GetBoundaryBoxSegmentation());
2741 _minSize = GetDefaultMinSize(diagonal);
2742 _maxSize = GetDefaultMaxSize(diagonal);
2743 _chordalError = GetDefaultChordalError(diagonal);
2744 _tinyEdgeLength = GetDefaultTinyEdgeLength(diagonal);
2747 // return bool(_phySize = dflts._elemLength);