1 // Copyright (C) 2007-2020 CEA/DEN, EDF R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 // File : BLSURFPlugin_Hypothesis.cxx
22 // Authors : Francis KLOSS (OCC) & Patrick LAUG (INRIA) & Lioka RAZAFINDRAZAKA (CEA)
23 // & Aurelien ALLEAUME (DISTENE)
24 // Size maps development: Nicolas GEIMER (OCC) & Gilles DAVID (EURIWARE)
27 #include "BLSURFPlugin_Hypothesis.hxx"
28 #include "BLSURFPlugin_Attractor.hxx"
29 #include "SMESH_Gen_i.hxx"
30 #include <utilities.h>
35 #include <Basics_Utils.hxx>
38 #include "ShapeAnalysis.hxx"
41 #include CORBA_CLIENT_HEADER(SALOMEDS)
42 #include CORBA_CLIENT_HEADER(GEOM_Gen)
44 #include <meshgems/meshgems.h>
45 #define MESHGEMS_VERSION_HEX (MESHGEMS_VERSION_MAJOR << 16 | MESHGEMS_VERSION_MINOR << 8 | MESHGEMS_VERSION_PATCH)
49 struct GET_DEFAULT // struct used to get default value from GetOptionValue()
52 operator bool* () { return &isDefault; }
56 //=============================================================================
57 BLSURFPlugin_Hypothesis::BLSURFPlugin_Hypothesis(int hypId, SMESH_Gen * gen, bool hasgeom) :
58 SMESH_Hypothesis(hypId, gen),
59 _physicalMesh(GetDefaultPhysicalMesh()),
60 _geometricMesh(GetDefaultGeometricMesh()),
61 _phySize(GetDefaultPhySize()),
62 _phySizeRel(GetDefaultPhySizeRel()),
63 _minSize(GetDefaultMinSize()),
64 _maxSize(GetDefaultMaxSize()),
65 _minSizeRel(GetDefaultMinSizeRel()),
66 _maxSizeRel(GetDefaultMaxSizeRel()),
67 _useGradation(GetDefaultUseGradation()),
68 _gradation(GetDefaultGradation()),
69 _useVolumeGradation(GetDefaultUseVolumeGradation()),
70 _volumeGradation(GetDefaultVolumeGradation()),
71 _elementType(GetDefaultElementType()),
72 _angleMesh(GetDefaultAngleMesh()),
73 _chordalError(GetDefaultChordalError()),
74 _anisotropic(GetDefaultAnisotropic()),
75 _anisotropicRatio(GetDefaultAnisotropicRatio()),
76 _removeTinyEdges(GetDefaultRemoveTinyEdges()),
77 _tinyEdgeLength(GetDefaultTinyEdgeLength()),
78 _optimiseTinyEdges(GetDefaultOptimiseTinyEdges()),
79 _tinyEdgeOptimisationLength(GetDefaultTinyEdgeOptimisationLength()),
80 _correctSurfaceIntersec(GetDefaultCorrectSurfaceIntersection()),
81 _corrSurfaceIntersCost(GetDefaultCorrectSurfaceIntersectionMaxCost()),
82 _badElementRemoval(GetDefaultBadElementRemoval()),
83 _badElementAspectRatio(GetDefaultBadElementAspectRatio()),
84 _optimizeMesh(GetDefaultOptimizeMesh()),
85 _quadraticMesh(GetDefaultQuadraticMesh()),
86 _verb(GetDefaultVerbosity()),
87 _topology(GetDefaultTopology()),
88 _useSurfaceProximity(GetDefaultUseSurfaceProximity()),
89 _nbSurfaceProximityLayers(GetDefaultNbSurfaceProximityLayers()),
90 _surfaceProximityRatio(GetDefaultSurfaceProximityRatio()),
91 _useVolumeProximity(GetDefaultUseVolumeProximity()),
92 _nbVolumeProximityLayers(GetDefaultNbVolumeProximityLayers()),
93 _volumeProximityRatio(GetDefaultVolumeProximityRatio()),
94 _preCADMergeEdges(GetDefaultPreCADMergeEdges()),
95 _preCADRemoveDuplicateCADFaces(GetDefaultPreCADRemoveDuplicateCADFaces()),
96 _preCADProcess3DTopology(GetDefaultPreCADProcess3DTopology()),
97 _preCADDiscardInput(GetDefaultPreCADDiscardInput()),
98 _sizeMap(GetDefaultSizeMap()),
99 _attractors(GetDefaultSizeMap()),
100 _classAttractors(GetDefaultAttractorMap()),
101 _faceEntryEnfVertexListMap(GetDefaultFaceEntryEnfVertexListMap()),
102 _enfVertexList(GetDefaultEnfVertexList()),
103 _faceEntryCoordsListMap(GetDefaultFaceEntryCoordsListMap()),
104 _coordsEnfVertexMap(GetDefaultCoordsEnfVertexMap()),
105 _faceEntryEnfVertexEntryListMap(GetDefaultFaceEntryEnfVertexEntryListMap()),
106 _enfVertexEntryEnfVertexMap(GetDefaultEnfVertexEntryEnfVertexMap()),
107 _groupNameNodeIDMap(GetDefaultGroupNameNodeIDMap()),
108 _enforcedInternalVerticesAllFaces(GetDefaultInternalEnforcedVertex()),
109 _preCadFacesPeriodicityVector(GetDefaultPreCadFacesPeriodicityVector()),
110 _preCadEdgesPeriodicityVector(GetDefaultPreCadEdgesPeriodicityVector()),
111 _GMFFileName(GetDefaultGMFFile())
113 _name = GetHypType(hasgeom);
116 // Advanced options with their defaults according to MG User Manual
118 const char* boolOptionNames[] = {
119 #if MESHGEMS_VERSION_HEX < 0x020A00
120 "enforce_cad_edge_sizes", // default = 0 // Deprecated since MeshGems 2.10
122 "jacobian_rectification_respect_geometry", // default = 1
123 "rectify_jacobian", // default = 1
124 "respect_geometry", // default = 1
125 "tiny_edge_avoid_surface_intersections", // default = 1
126 "debug", // default = 0
127 "allow_patch_independent", // false
131 const char* intOptionNames[] = {
132 #if MESHGEMS_VERSION_HEX < 0x020A00
133 "max_number_of_points_per_patch", // default = 100000 // Deprecated since MeshGems 2.10
135 "max_number_of_threads", // default = 4
138 const char* doubleOptionNames[] = { // "surface_intersections_processing_max_cost",// default = 15
139 // "periodic_tolerance", // default = diag/100
140 // "volume_gradation",
141 // "tiny_edge_optimisation_length", // default = diag * 1e-6
144 const char* charOptionNames[] = { // "required_entities", // default = "respect"
145 // "tags", // default = "respect"
149 // PreCAD advanced options
150 const char* preCADboolOptionNames[] = { "closed_geometry", // default = 0
151 "discard_input_topology", // default = 0
152 "merge_edges", // default = = 1
153 "remove_duplicate_cad_faces", // default = 1
154 // "create_tag_on_collision", // default = 1
155 "process_3d_topology", // default = 1
156 // "remove_tiny_edges", // default = 0
157 // remove_tiny_uv_edges option is not documented
158 // but it is useful that the user can change it to disable all preprocessing options
159 "remove_tiny_uv_edges", // default = 1
160 "compute_ridges", // true
163 const char* preCADintOptionNames[] = { // "manifold_geometry", // default = 0
166 const char* preCADdoubleOptionNames[] = { "periodic_tolerance", // default = diag * 1e-5
167 "sewing_tolerance", // default = diag * 5e-4
168 // "tiny_edge_length", // default = diag * 1e-5
171 const char* preCADcharOptionNames[] = { "required_entities", // default = "respect"
172 "tags", // default = "respect"
177 while (boolOptionNames[i][0])
179 _boolOptions.insert( boolOptionNames[i] );
180 _option2value[boolOptionNames[i++]].clear();
183 while (preCADboolOptionNames[i][0] && hasgeom)
185 _boolOptions.insert( preCADboolOptionNames[i] );
186 _preCADoption2value[preCADboolOptionNames[i++]].clear();
189 while (intOptionNames[i][0])
190 _option2value[intOptionNames[i++]].clear();
193 while (preCADintOptionNames[i][0] && hasgeom)
194 _preCADoption2value[preCADintOptionNames[i++]].clear();
197 while (doubleOptionNames[i][0]) {
198 _doubleOptions.insert(doubleOptionNames[i]);
199 _option2value[doubleOptionNames[i++]].clear();
202 while (preCADdoubleOptionNames[i][0] && hasgeom) {
203 _preCADdoubleOptions.insert(preCADdoubleOptionNames[i]);
204 _preCADoption2value[preCADdoubleOptionNames[i++]].clear();
207 while (charOptionNames[i][0]) {
208 _charOptions.insert(charOptionNames[i]);
209 _option2value[charOptionNames[i++]].clear();
212 while (preCADcharOptionNames[i][0] && hasgeom) {
213 _preCADcharOptions.insert(preCADcharOptionNames[i]);
214 _preCADoption2value[preCADcharOptionNames[i++]].clear();
217 // default values to be used while MG meshing
219 #if MESHGEMS_VERSION_HEX < 0x020A00
220 _defaultOptionValues["enforce_cad_edge_sizes" ] = "no"; // Deprecated since MeshGems 2.10
222 _defaultOptionValues["jacobian_rectification_respect_geometry"] = "yes";
223 #if MESHGEMS_VERSION_HEX < 0x020A00
224 _defaultOptionValues["max_number_of_points_per_patch" ] = "0"; // Deprecated since MeshGems 2.10
226 _defaultOptionValues["max_number_of_threads" ] = "4";
227 _defaultOptionValues["rectify_jacobian" ] = "yes";
228 _defaultOptionValues["respect_geometry" ] = "yes";
229 _defaultOptionValues["tiny_edge_avoid_surface_intersections" ] = "yes";
230 //_defaultOptionValues["use_deprecated_patch_mesher" ] = "no";
231 _defaultOptionValues["debug" ] = "no";
232 _defaultOptionValues["allow_patch_independent" ] = "no";
235 _defaultOptionValues["closed_geometry" ] = "no";
236 _defaultOptionValues["discard_input_topology" ] = "no";
237 _defaultOptionValues["merge_edges" ] = "no";
238 _defaultOptionValues["periodic_tolerance" ] = "1e-5*D";
239 _defaultOptionValues["process_3d_topology" ] = "no";
240 _defaultOptionValues["remove_duplicate_cad_faces" ] = "no";
241 _defaultOptionValues["remove_tiny_uv_edges" ] = "no";
242 _defaultOptionValues["required_entities" ] = "respect";
243 _defaultOptionValues["sewing_tolerance" ] = "5e-4*D";
244 _defaultOptionValues["tags" ] = "respect";
245 _defaultOptionValues["compute_ridges" ] = "yes";
248 if ( MESHGEMS_VERSION_HEX < 0x020906 )
250 std::string missingOption = "allow_patch_independent";
251 _defaultOptionValues.erase( missingOption );
252 _boolOptions.erase( missingOption );
253 _option2value.erase( missingOption );
257 // check validity of option names of _defaultOptionValues
258 TOptionValues::iterator n2v = _defaultOptionValues.begin();
259 for ( ; n2v != _defaultOptionValues.end(); ++n2v )
260 ASSERT( _option2value.count( n2v->first ) || _preCADoption2value.count( n2v->first ));
261 ASSERT( _option2value.size() + _preCADoption2value.size() == _defaultOptionValues.size() );
266 TopoDS_Shape BLSURFPlugin_Hypothesis::entryToShape(std::string entry)
268 GEOM::GEOM_Object_var aGeomObj;
270 TopoDS_Shape S = TopoDS_Shape();
271 SALOMEDS::SObject_var aSObj = SMESH_Gen_i::getStudyServant()->FindObjectID( entry.c_str() );
272 if (!aSObj->_is_nil() ) {
273 CORBA::Object_var obj = aSObj->GetObject();
274 aGeomObj = GEOM::GEOM_Object::_narrow(obj);
277 if ( !aGeomObj->_is_nil() )
278 S = SMESH_Gen_i::GetSMESHGen()->GeomObjectToShape( aGeomObj.in() );
282 //=============================================================================
283 std::string BLSURFPlugin_Hypothesis::GetMeshGemsVersion()
285 return MESHGEMS_VERSION_LONG;
288 //=============================================================================
289 void BLSURFPlugin_Hypothesis::SetPhysicalMesh(PhysicalMesh thePhysicalMesh) {
290 if (thePhysicalMesh != _physicalMesh) {
291 _physicalMesh = thePhysicalMesh;
292 NotifySubMeshesHypothesisModification();
296 //=============================================================================
297 void BLSURFPlugin_Hypothesis::SetGeometricMesh(GeometricMesh theGeometricMesh) {
298 if (theGeometricMesh != _geometricMesh) {
299 _geometricMesh = theGeometricMesh;
300 // switch (_geometricMesh) {
303 // _angleMesh = GetDefaultAngleMesh();
304 // _gradation = GetDefaultGradation();
307 NotifySubMeshesHypothesisModification();
311 //=============================================================================
312 void BLSURFPlugin_Hypothesis::SetPhySize(double theVal, bool isRelative) {
313 if ((theVal != _phySize) || (isRelative != _phySizeRel)) {
314 _phySizeRel = isRelative;
316 _phySize = GetMaxSize();
320 NotifySubMeshesHypothesisModification();
324 //=============================================================================
325 void BLSURFPlugin_Hypothesis::SetMinSize(double theMinSize, bool isRelative) {
326 if ((theMinSize != _minSize) || (isRelative != _minSizeRel)) {
327 _minSizeRel = isRelative;
328 _minSize = theMinSize;
329 NotifySubMeshesHypothesisModification();
333 //=============================================================================
334 void BLSURFPlugin_Hypothesis::SetMaxSize(double theMaxSize, bool isRelative) {
335 if ((theMaxSize != _maxSize) || (isRelative != _maxSizeRel)) {
336 _maxSizeRel = isRelative;
337 _maxSize = theMaxSize;
338 NotifySubMeshesHypothesisModification();
342 //=============================================================================
343 void BLSURFPlugin_Hypothesis::SetUseGradation(bool theVal) {
344 if (theVal != _useGradation) {
345 _useGradation = theVal;
346 NotifySubMeshesHypothesisModification();
350 //=============================================================================
351 void BLSURFPlugin_Hypothesis::SetGradation(double theVal) {
352 _useGradation = ( theVal > 0 );
353 if (theVal != _gradation) {
355 NotifySubMeshesHypothesisModification();
359 //=============================================================================
360 void BLSURFPlugin_Hypothesis::SetUseVolumeGradation(bool theVal) {
361 if (theVal != _useVolumeGradation) {
362 _useVolumeGradation = theVal;
363 NotifySubMeshesHypothesisModification();
367 //=============================================================================
368 void BLSURFPlugin_Hypothesis::SetVolumeGradation(double theVal) {
369 _useVolumeGradation = ( theVal > 0 );
370 if (theVal != _volumeGradation) {
371 _volumeGradation = theVal;
372 NotifySubMeshesHypothesisModification();
376 //=============================================================================
377 void BLSURFPlugin_Hypothesis::SetElementType(ElementType theElementType) {
378 if (theElementType != _elementType) {
379 _elementType = theElementType;
380 NotifySubMeshesHypothesisModification();
384 //=============================================================================
385 void BLSURFPlugin_Hypothesis::SetAngleMesh(double theVal) {
386 if (theVal != _angleMesh) {
388 NotifySubMeshesHypothesisModification();
392 //=============================================================================
393 void BLSURFPlugin_Hypothesis::SetChordalError(double theDistance) {
394 if (theDistance != _chordalError) {
395 _chordalError = theDistance;
396 NotifySubMeshesHypothesisModification();
400 //=============================================================================
401 void BLSURFPlugin_Hypothesis::SetAnisotropic(bool theVal) {
402 if (theVal != _anisotropic) {
403 _anisotropic = theVal;
404 NotifySubMeshesHypothesisModification();
408 //=============================================================================
409 void BLSURFPlugin_Hypothesis::SetAnisotropicRatio(double theVal) {
410 if (theVal != _anisotropicRatio) {
411 _anisotropicRatio = theVal;
412 NotifySubMeshesHypothesisModification();
416 //=============================================================================
417 void BLSURFPlugin_Hypothesis::SetRemoveTinyEdges(bool theVal) {
418 if (theVal != _removeTinyEdges) {
419 _removeTinyEdges = theVal;
420 NotifySubMeshesHypothesisModification();
424 //=============================================================================
425 void BLSURFPlugin_Hypothesis::SetTinyEdgeLength(double theVal) {
426 if (theVal != _tinyEdgeLength) {
427 _tinyEdgeLength = theVal;
428 NotifySubMeshesHypothesisModification();
432 //=============================================================================
433 void BLSURFPlugin_Hypothesis::SetOptimiseTinyEdges(bool theVal) {
434 if (theVal != _optimiseTinyEdges) {
435 _optimiseTinyEdges = theVal;
436 NotifySubMeshesHypothesisModification();
440 //=============================================================================
441 void BLSURFPlugin_Hypothesis::SetTinyEdgeOptimisationLength(double theVal) {
442 if (theVal != _tinyEdgeOptimisationLength) {
443 _tinyEdgeOptimisationLength = theVal;
444 NotifySubMeshesHypothesisModification();
448 //=============================================================================
449 void BLSURFPlugin_Hypothesis::SetCorrectSurfaceIntersection(bool theVal) {
450 if (theVal != _correctSurfaceIntersec) {
451 _correctSurfaceIntersec = theVal;
452 NotifySubMeshesHypothesisModification();
456 //=============================================================================
457 void BLSURFPlugin_Hypothesis::SetCorrectSurfaceIntersectionMaxCost(double theVal) {
458 if (theVal != _corrSurfaceIntersCost) {
459 _corrSurfaceIntersCost = theVal;
460 NotifySubMeshesHypothesisModification();
464 //=============================================================================
465 void BLSURFPlugin_Hypothesis::SetBadElementRemoval(bool theVal) {
466 if (theVal != _badElementRemoval) {
467 _badElementRemoval = theVal;
468 NotifySubMeshesHypothesisModification();
472 //=============================================================================
473 void BLSURFPlugin_Hypothesis::SetBadElementAspectRatio(double theVal) {
474 if (theVal != _badElementAspectRatio) {
475 _badElementAspectRatio = theVal;
476 NotifySubMeshesHypothesisModification();
480 //=============================================================================
481 void BLSURFPlugin_Hypothesis::SetOptimizeMesh(bool theVal) {
482 if (theVal != _optimizeMesh) {
483 _optimizeMesh = theVal;
484 NotifySubMeshesHypothesisModification();
488 //=============================================================================
489 void BLSURFPlugin_Hypothesis::SetQuadraticMesh(bool theVal) {
490 if (theVal != _quadraticMesh) {
491 _quadraticMesh = theVal;
492 NotifySubMeshesHypothesisModification();
496 //=============================================================================
497 void BLSURFPlugin_Hypothesis::SetTopology(Topology theTopology) {
498 if (theTopology != _topology) {
499 _topology = theTopology;
500 NotifySubMeshesHypothesisModification();
504 //=============================================================================
505 void BLSURFPlugin_Hypothesis::SetUseSurfaceProximity( bool toUse )
507 if ( _useSurfaceProximity != toUse )
509 _useSurfaceProximity = toUse;
510 NotifySubMeshesHypothesisModification();
514 //=============================================================================
515 void BLSURFPlugin_Hypothesis::SetNbSurfaceProximityLayers( int nbLayers )
517 if ( _nbSurfaceProximityLayers != nbLayers )
519 _nbSurfaceProximityLayers = nbLayers;
520 NotifySubMeshesHypothesisModification();
524 //=============================================================================
525 void BLSURFPlugin_Hypothesis::SetSurfaceProximityRatio( double ratio )
527 if ( _surfaceProximityRatio != ratio )
529 _surfaceProximityRatio = ratio;
530 NotifySubMeshesHypothesisModification();
534 //=============================================================================
535 void BLSURFPlugin_Hypothesis::SetUseVolumeProximity( bool toUse )
537 if ( _useVolumeProximity != toUse )
539 _useVolumeProximity = toUse;
540 NotifySubMeshesHypothesisModification();
544 //=============================================================================
545 void BLSURFPlugin_Hypothesis::SetNbVolumeProximityLayers( int nbLayers )
547 if ( _nbVolumeProximityLayers != nbLayers )
549 _nbVolumeProximityLayers = nbLayers;
550 NotifySubMeshesHypothesisModification();
554 //=============================================================================
555 void BLSURFPlugin_Hypothesis::SetVolumeProximityRatio( double ratio )
557 if ( _volumeProximityRatio != ratio )
559 _volumeProximityRatio = ratio;
560 NotifySubMeshesHypothesisModification();
564 //=============================================================================
565 void BLSURFPlugin_Hypothesis::SetVerbosity(int theVal) {
566 if (theVal != _verb) {
568 NotifySubMeshesHypothesisModification();
572 //=============================================================================
573 void BLSURFPlugin_Hypothesis::SetEnforceCadEdgesSize( bool toEnforce )
575 #if MESHGEMS_VERSION_HEX < 0x020A00
576 // Deprecated since MeshGems 2.10
577 if ( GetEnforceCadEdgesSize() != toEnforce )
579 SetOptionValue( "enforce_cad_edge_sizes", toEnforce ? "yes" : "no" );
580 NotifySubMeshesHypothesisModification();
583 (void)toEnforce; // maybe unused
586 //=============================================================================
587 bool BLSURFPlugin_Hypothesis::GetEnforceCadEdgesSize()
589 #if MESHGEMS_VERSION_HEX < 0x020A00
590 // Deprecated since MeshGems 2.10
591 return ToBool( GetOptionValue( "enforce_cad_edge_sizes" ), GET_DEFAULT() );
596 //=============================================================================
598 void BLSURFPlugin_Hypothesis::SetJacobianRectificationRespectGeometry( bool allowRectification )
600 if ( GetJacobianRectificationRespectGeometry() != allowRectification )
602 SetOptionValue("jacobian_rectification_respect_geometry", allowRectification ? "yes" : "no" );
603 NotifySubMeshesHypothesisModification();
606 //=============================================================================
607 bool BLSURFPlugin_Hypothesis::GetJacobianRectificationRespectGeometry()
609 return ToBool( GetOptionValue("jacobian_rectification_respect_geometry", GET_DEFAULT()));
611 //=============================================================================
613 void BLSURFPlugin_Hypothesis::SetJacobianRectification( bool allowRectification )
615 if ( GetJacobianRectification() != allowRectification )
617 SetOptionValue( "rectify_jacobian", allowRectification ? "yes" : "no" );
618 NotifySubMeshesHypothesisModification();
621 //=============================================================================
622 bool BLSURFPlugin_Hypothesis::GetJacobianRectification()
624 return ToBool( GetOptionValue("rectify_jacobian", GET_DEFAULT()));
626 //=============================================================================
628 void BLSURFPlugin_Hypothesis::SetUseDeprecatedPatchMesher( bool /*useDeprecatedPatchMesher*/ )
630 // if ( GetUseDeprecatedPatchMesher() != useDeprecatedPatchMesher )
632 // SetOptionValue( "use_deprecated_patch_mesher", useDeprecatedPatchMesher ? "yes" : "no" );
633 // NotifySubMeshesHypothesisModification();
636 //=============================================================================
637 bool BLSURFPlugin_Hypothesis::GetUseDeprecatedPatchMesher()
639 return false;//ToBool( GetOptionValue("use_deprecated_patch_mesher", GET_DEFAULT()));
641 //=============================================================================
643 void BLSURFPlugin_Hypothesis::SetMaxNumberOfPointsPerPatch( int nb )
645 #if MESHGEMS_VERSION_HEX < 0x020A00
646 // Deprecated since MeshGems 2.10
648 throw std::invalid_argument( SMESH_Comment("Invalid number of points: ") << nb );
650 if ( GetMaxNumberOfPointsPerPatch() != nb )
652 SetOptionValue("max_number_of_points_per_patch", SMESH_Comment( nb ));
653 NotifySubMeshesHypothesisModification();
656 (void)nb; // maybe unused
659 //=============================================================================
660 int BLSURFPlugin_Hypothesis::GetMaxNumberOfPointsPerPatch()
662 #if MESHGEMS_VERSION_HEX < 0x020A00
663 // Deprecated since MeshGems 2.10
664 return ToInt( GetOptionValue("max_number_of_points_per_patch", GET_DEFAULT()));
669 //=============================================================================
671 void BLSURFPlugin_Hypothesis::SetMaxNumberOfThreads( int nb )
674 throw std::invalid_argument( SMESH_Comment("Invalid number of threads: ") << nb );
676 if ( GetMaxNumberOfThreads() != nb )
678 SetOptionValue("max_number_of_threads", SMESH_Comment( nb ));
679 NotifySubMeshesHypothesisModification();
682 //=============================================================================
683 int BLSURFPlugin_Hypothesis::GetMaxNumberOfThreads()
685 return ToInt( GetOptionValue("max_number_of_threads", GET_DEFAULT()));
687 //=============================================================================
689 void BLSURFPlugin_Hypothesis::SetRespectGeometry( bool toRespect )
691 if ( GetRespectGeometry() != toRespect )
693 SetOptionValue("respect_geometry", toRespect ? "yes" : "no" );
694 NotifySubMeshesHypothesisModification();
697 //=============================================================================
698 bool BLSURFPlugin_Hypothesis::GetRespectGeometry()
700 return ToBool( GetOptionValue( "respect_geometry", GET_DEFAULT()));
702 //=============================================================================
704 void BLSURFPlugin_Hypothesis::SetTinyEdgesAvoidSurfaceIntersections( bool toAvoidIntersection )
706 if ( GetTinyEdgesAvoidSurfaceIntersections() != toAvoidIntersection )
708 SetOptionValue("tiny_edge_avoid_surface_intersections", toAvoidIntersection ? "yes" : "no" );
709 NotifySubMeshesHypothesisModification();
712 //=============================================================================
713 bool BLSURFPlugin_Hypothesis::GetTinyEdgesAvoidSurfaceIntersections()
715 return ToBool( GetOptionValue("tiny_edge_avoid_surface_intersections", GET_DEFAULT()));
717 //=============================================================================
719 void BLSURFPlugin_Hypothesis::SetClosedGeometry( bool isClosed )
721 if ( GetClosedGeometry() != isClosed )
723 SetPreCADOptionValue("closed_geometry", isClosed ? "yes" : "no" );
724 NotifySubMeshesHypothesisModification();
727 //=============================================================================
728 bool BLSURFPlugin_Hypothesis::GetClosedGeometry()
730 return ToBool( GetPreCADOptionValue( "closed_geometry", GET_DEFAULT()));
732 //=============================================================================
734 void BLSURFPlugin_Hypothesis::SetDebug( bool isDebug )
736 if ( GetDebug() != isDebug )
738 SetPreCADOptionValue("debug", isDebug ? "yes" : "no" );
739 NotifySubMeshesHypothesisModification();
742 //=============================================================================
743 bool BLSURFPlugin_Hypothesis::GetDebug()
745 return ToBool( GetPreCADOptionValue("debug", GET_DEFAULT()));
747 //=============================================================================
749 void BLSURFPlugin_Hypothesis::SetPeriodicTolerance( CORBA::Double tol )
752 throw std::invalid_argument( SMESH_Comment("Invalid tolerance: ") << tol );
753 if ( GetPeriodicTolerance() != tol )
755 SetPreCADOptionValue("periodic_tolerance", SMESH_Comment( tol ) );
756 NotifySubMeshesHypothesisModification();
759 //=============================================================================
760 double BLSURFPlugin_Hypothesis::GetPeriodicTolerance()
762 return ToDbl( GetPreCADOptionValue( "periodic_tolerance", GET_DEFAULT()));
764 //=============================================================================
766 void BLSURFPlugin_Hypothesis::SetRequiredEntities( const std::string& howToTreat )
768 if ( howToTreat != "respect" && howToTreat != "ignore" && howToTreat != "clear" )
769 throw std::invalid_argument
770 ( SMESH_Comment("required_entities must be in ['respect','ignore','clear'] "));
772 if ( GetRequiredEntities() != howToTreat )
774 SetPreCADOptionValue("required_entities", howToTreat );
775 NotifySubMeshesHypothesisModification();
778 //=============================================================================
779 std::string BLSURFPlugin_Hypothesis::GetRequiredEntities()
781 return GetPreCADOptionValue("required_entities", GET_DEFAULT());
783 //=============================================================================
785 void BLSURFPlugin_Hypothesis::SetSewingTolerance( CORBA::Double tol )
788 throw std::invalid_argument( SMESH_Comment("Invalid tolerance: ") << tol );
789 if ( GetSewingTolerance() != tol )
791 SetPreCADOptionValue("sewing_tolerance", SMESH_Comment( tol ) );
792 NotifySubMeshesHypothesisModification();
795 //=============================================================================
796 CORBA::Double BLSURFPlugin_Hypothesis::GetSewingTolerance()
798 return ToDbl( GetPreCADOptionValue("sewing_tolerance", GET_DEFAULT()));
800 //=============================================================================
802 void BLSURFPlugin_Hypothesis::SetTags( const std::string& howToTreat )
804 if ( howToTreat != "respect" && howToTreat != "ignore" && howToTreat != "clear" )
805 throw std::invalid_argument
806 ( SMESH_Comment("'tags' must be in ['respect','ignore','clear'] "));
808 if ( GetTags() != howToTreat )
810 SetPreCADOptionValue("tags", howToTreat );
811 NotifySubMeshesHypothesisModification();
814 //=============================================================================
815 std::string BLSURFPlugin_Hypothesis::GetTags()
817 return GetPreCADOptionValue("tags", GET_DEFAULT());
819 //=============================================================================
820 void BLSURFPlugin_Hypothesis::SetHyperPatches(const THyperPatchList& hpl)
822 if ( hpl != _hyperPatchList )
824 // join patches sharing tags
825 _hyperPatchList.clear();
826 for ( size_t i = 0; i < hpl.size(); ++i )
828 const THyperPatchTags& tags = hpl[i];
829 if ( tags.size() < 2 ) continue;
831 std::set<int> iPatches;
832 if ( !_hyperPatchList.empty() )
834 THyperPatchTags::iterator t = tags.begin();
835 for ( ; t != tags.end(); ++t )
838 GetHyperPatchTag( *t, this, &iPatch );
840 iPatches.insert( iPatch );
844 if ( iPatches.empty() )
846 _hyperPatchList.push_back( tags );
850 std::set<int>::iterator iPatch = iPatches.begin();
851 THyperPatchTags& mainPatch = _hyperPatchList[ *iPatch ];
852 mainPatch.insert( tags.begin(), tags.end() );
854 for ( ++iPatch; iPatch != iPatches.end(); ++iPatch )
856 mainPatch.insert( _hyperPatchList[ *iPatch ].begin(), _hyperPatchList[ *iPatch ].end() );
857 _hyperPatchList[ *iPatch ].clear();
859 if ( iPatches.size() > 1 )
860 for ( int j = _hyperPatchList.size()-1; j > 0; --j )
861 if ( _hyperPatchList[j].empty() )
862 _hyperPatchList.erase( _hyperPatchList.begin() + j );
865 NotifySubMeshesHypothesisModification();
868 //=============================================================================
870 * \brief Return a tag of a face taking into account the hyper-patches. Optionally
871 * return an index of a patch including the face
873 //================================================================================
875 int BLSURFPlugin_Hypothesis::GetHyperPatchTag( const int faceTag,
876 const BLSURFPlugin_Hypothesis* hyp,
881 const THyperPatchList& hpl = hyp->_hyperPatchList;
882 for ( size_t i = 0; i < hpl.size(); ++i )
883 if ( hpl[i].count( faceTag ))
885 if ( iPatch ) *iPatch = i;
886 return *( hpl[i].begin() );
891 //=============================================================================
892 void BLSURFPlugin_Hypothesis::SetPreCADMergeEdges(bool theVal)
894 if (theVal != ToBool( GetPreCADOptionValue("merge_edges", GET_DEFAULT()))) {
895 _preCADMergeEdges = theVal;
896 SetPreCADOptionValue("merge_edges", theVal ? "yes" : "no" );
897 NotifySubMeshesHypothesisModification();
901 //=============================================================================
902 void BLSURFPlugin_Hypothesis::SetPreCADRemoveDuplicateCADFaces(bool theVal)
904 if (theVal != ToBool( GetPreCADOptionValue("remove_duplicate_cad_faces", GET_DEFAULT()))) {
905 _preCADRemoveDuplicateCADFaces = theVal;
906 SetPreCADOptionValue("remove_duplicate_cad_faces", theVal ? "yes" : "no" );
907 NotifySubMeshesHypothesisModification();
911 //=============================================================================
912 void BLSURFPlugin_Hypothesis::SetPreCADProcess3DTopology(bool theVal)
914 if (theVal != ToBool( GetPreCADOptionValue("process_3d_topology", GET_DEFAULT()))) {
915 _preCADProcess3DTopology = theVal;
916 SetPreCADOptionValue("process_3d_topology", theVal ? "yes" : "no" );
917 NotifySubMeshesHypothesisModification();
921 //=============================================================================
922 void BLSURFPlugin_Hypothesis::SetPreCADDiscardInput(bool theVal)
924 if (theVal != ToBool( GetPreCADOptionValue("discard_input_topology", GET_DEFAULT()))) {
925 _preCADDiscardInput = theVal;
926 SetPreCADOptionValue("discard_input_topology", theVal ? "yes" : "no" );
927 NotifySubMeshesHypothesisModification();
931 //=============================================================================
932 // Return true if any PreCAD option is activated
933 bool BLSURFPlugin_Hypothesis::HasPreCADOptions(const BLSURFPlugin_Hypothesis* hyp)
935 if ( !hyp || hyp->_name == GetHypType(/*hasgeom=*/false))
939 bool orDefault, isOk;
940 return ( ToBool( hyp->GetPreCADOptionValue("closed_geometry" , &orDefault )) ||
941 ToBool( hyp->GetPreCADOptionValue("discard_input_topology" , &orDefault )) ||
942 ToBool( hyp->GetPreCADOptionValue("merge_edges" , &orDefault )) ||
943 ToBool( hyp->GetPreCADOptionValue("remove_duplicate_cad_faces", &orDefault )) ||
944 ToBool( hyp->GetPreCADOptionValue("process_3d_topology" , &orDefault )) ||
945 ToBool( hyp->GetPreCADOption ("manifold_geometry") , &isOk ) ||
946 hyp->GetPreCADOptionValue("sewing_tolerance", &orDefault ) != "5e-4*D" ||
947 !hyp->_preCadFacesPeriodicityVector.empty() ||
948 !hyp->_preCadEdgesPeriodicityVector.empty() ||
949 !hyp->_facesPeriodicityVector.empty() ||
950 !hyp->_edgesPeriodicityVector.empty() ||
951 !hyp->_verticesPeriodicityVector.empty() ||
952 !hyp->GetHyperPatches().empty() ||
953 hyp->GetTopology() != FromCAD );
956 //=============================================================================
957 // void BLSURFPlugin_Hypothesis::SetGMFFile(const std::string& theFileName, bool isBinary)
958 void BLSURFPlugin_Hypothesis::SetGMFFile(const std::string& theFileName)
960 _GMFFileName = theFileName;
961 // _GMFFileMode = isBinary;
962 NotifySubMeshesHypothesisModification();
965 //=============================================================================
966 void BLSURFPlugin_Hypothesis::SetOptionValue(const std::string& optionName, const std::string& optionValue)
968 TOptionValues::iterator op_val = _option2value.find(optionName);
969 if (op_val == _option2value.end())
971 op_val = _preCADoption2value.find(optionName);
972 if (op_val == _preCADoption2value.end())
974 std::string msg = "Unknown MG-CADSurf option: '" + optionName + "'. Try SetAdvancedOption()";
975 throw std::invalid_argument(msg);
978 if (op_val->second != optionValue)
980 const char* ptr = optionValue.c_str();
981 // strip white spaces
982 while (ptr[0] == ' ')
985 while (i != 0 && ptr[i - 1] == ' ')
989 std::string typeName;
992 } else if (_charOptions.count(optionName)) {
993 // do not check strings
994 } else if (_doubleOptions.count(optionName)) {
995 // check if value is double
998 } else if (_boolOptions.count(optionName)) {
999 // check if value is bool
1000 ToBool(ptr, &typeOk);
1003 // check if value is int
1004 ToInt(ptr, &typeOk);
1005 typeName = "integer";
1008 std::string msg = "Advanced option '" + optionName + "' = '" + optionValue + "' but must be " + typeName;
1009 throw std::invalid_argument(msg);
1011 std::string value( ptr, i );
1012 if ( _defaultOptionValues[ optionName ] == value )
1015 op_val->second = value;
1017 NotifySubMeshesHypothesisModification();
1021 //=============================================================================
1022 void BLSURFPlugin_Hypothesis::SetPreCADOptionValue(const std::string& optionName, const std::string& optionValue)
1024 TOptionValues::iterator op_val = _preCADoption2value.find(optionName);
1025 if (op_val == _preCADoption2value.end()) {
1026 op_val = _option2value.find(optionName);
1027 if (op_val == _option2value.end()) {
1028 std::string msg = "Unknown MG-PreCAD option: '" + optionName + "'. Try SetAdvancedOption()";
1029 throw std::invalid_argument(msg);
1032 if (op_val->second != optionValue)
1034 const char* ptr = optionValue.c_str();
1035 // strip white spaces
1036 while (ptr[0] == ' ')
1038 int i = strlen(ptr);
1039 while (i != 0 && ptr[i - 1] == ' ')
1043 std::string typeName;
1046 } else if (_preCADcharOptions.find(optionName) != _preCADcharOptions.end()) {
1047 // do not check strings
1048 } else if (_preCADdoubleOptions.find(optionName) != _preCADdoubleOptions.end()) {
1049 // check if value is double
1051 strtod(ptr, &endPtr);
1052 typeOk = (ptr != endPtr);
1054 } else if (_boolOptions.count(optionName)) {
1055 // check if value is bool
1056 ToBool(ptr, &typeOk);
1059 // check if value is int
1061 strtol(ptr, &endPtr, 10);
1062 typeOk = (ptr != endPtr);
1063 typeName = "integer";
1066 std::string msg = "PreCAD advanced option '" + optionName + "' = '" + optionValue + "' but must be " + typeName;
1067 throw std::invalid_argument(msg);
1069 std::string value( ptr, i );
1070 if ( _defaultOptionValues[ optionName ] == value )
1073 op_val->second = value;
1075 NotifySubMeshesHypothesisModification();
1079 //=============================================================================
1080 std::string BLSURFPlugin_Hypothesis::GetOptionValue(const std::string& optionName,
1081 bool* isDefault) const
1083 TOptionValues::const_iterator op_val = _option2value.find(optionName);
1084 if (op_val == _option2value.end())
1086 op_val = _preCADoption2value.find(optionName);
1087 if (op_val == _preCADoption2value.end())
1089 op_val = _customOption2value.find(optionName);
1090 if (op_val == _customOption2value.end())
1092 std::string msg = "Unknown MG-CADSurf option: <" + optionName + ">";
1093 throw std::invalid_argument(msg);
1097 std::string val = op_val->second;
1098 if ( isDefault ) *isDefault = ( val.empty() );
1100 if ( val.empty() && isDefault )
1102 op_val = _defaultOptionValues.find( optionName );
1103 if (op_val != _defaultOptionValues.end())
1104 val = op_val->second;
1109 //=============================================================================
1110 std::string BLSURFPlugin_Hypothesis::GetPreCADOptionValue(const std::string& optionName,
1111 bool* isDefault) const
1113 TOptionValues::const_iterator op_val = _preCADoption2value.find(optionName);
1114 if (op_val == _preCADoption2value.end())
1116 op_val = _option2value.find(optionName);
1117 if (op_val == _option2value.end())
1119 op_val = _customOption2value.find(optionName);
1120 if (op_val == _customOption2value.end())
1122 std::string msg = "Unknown MG-CADSurf option: <" + optionName + ">";
1123 throw std::invalid_argument(msg);
1127 std::string val = op_val->second;
1128 if ( isDefault ) *isDefault = ( val.empty() );
1130 if ( val.empty() && isDefault )
1132 op_val = _defaultOptionValues.find( optionName );
1133 if (op_val != _option2value.end())
1134 val = op_val->second;
1139 //=============================================================================
1140 void BLSURFPlugin_Hypothesis::ClearOption(const std::string& optionName)
1142 TOptionValues::iterator op_val = _customOption2value.find(optionName);
1143 if (op_val != _customOption2value.end())
1144 _customOption2value.erase(op_val);
1146 op_val = _option2value.find(optionName);
1147 if (op_val != _option2value.end())
1148 op_val->second.clear();
1150 op_val = _preCADoption2value.find(optionName);
1151 if (op_val != _preCADoption2value.end())
1152 op_val->second.clear();
1157 //=============================================================================
1158 void BLSURFPlugin_Hypothesis::ClearPreCADOption(const std::string& optionName)
1160 TOptionValues::iterator op_val = _preCADoption2value.find(optionName);
1161 if (op_val != _preCADoption2value.end())
1162 op_val->second.clear();
1165 //=============================================================================
1166 void BLSURFPlugin_Hypothesis::AddOption(const std::string& optionName, const std::string& optionValue)
1169 TOptionValues::iterator op_val = _option2value.find(optionName);
1170 if (op_val != _option2value.end())
1172 if (op_val->second != optionValue)
1173 op_val->second = optionValue;
1179 op_val = _preCADoption2value.find(optionName);
1180 if (op_val != _preCADoption2value.end())
1182 if (op_val->second != optionValue)
1183 op_val->second = optionValue;
1187 else if ( optionValue.empty() )
1189 _customOption2value.erase( optionName );
1193 op_val = _customOption2value.find(optionName);
1194 if (op_val == _customOption2value.end())
1195 _customOption2value[optionName] = optionValue;
1196 else if (op_val->second != optionValue)
1197 op_val->second = optionValue;
1203 NotifySubMeshesHypothesisModification();
1206 //=============================================================================
1207 void BLSURFPlugin_Hypothesis::AddPreCADOption(const std::string& optionName, const std::string& optionValue)
1209 AddOption( optionName, optionValue );
1212 //=============================================================================
1213 std::string BLSURFPlugin_Hypothesis::GetOption(const std::string& optionName) const
1215 TOptionValues::const_iterator op_val = _customOption2value.find(optionName);
1216 if (op_val != _customOption2value.end())
1217 return op_val->second;
1222 //=============================================================================
1223 std::string BLSURFPlugin_Hypothesis::GetPreCADOption(const std::string& optionName) const
1225 TOptionValues::const_iterator op_val = _customOption2value.find(optionName);
1226 if (op_val != _customOption2value.end())
1227 return op_val->second;
1232 //=============================================================================
1233 BLSURFPlugin_Hypothesis::TOptionValues BLSURFPlugin_Hypothesis::GetOptionValues() const
1236 TOptionValues::const_iterator op_val = _option2value.begin();
1237 for ( ; op_val != _option2value.end(); ++op_val )
1238 vals.insert( make_pair( op_val->first, GetOptionValue( op_val->first, GET_DEFAULT() )));
1243 //=============================================================================
1244 BLSURFPlugin_Hypothesis::TOptionValues BLSURFPlugin_Hypothesis::GetPreCADOptionValues() const
1247 TOptionValues::const_iterator op_val = _preCADoption2value.begin();
1248 for ( ; op_val != _preCADoption2value.end(); ++op_val )
1249 vals.insert( make_pair( op_val->first, GetPreCADOptionValue( op_val->first, GET_DEFAULT() )));
1254 //=======================================================================
1255 //function : SetSizeMapEntry
1256 //=======================================================================
1257 void BLSURFPlugin_Hypothesis::SetSizeMapEntry(const std::string& entry, const std::string& sizeMap) {
1258 if (_sizeMap[entry].compare(sizeMap) != 0) {
1259 SetPhysicalMesh(PhysicalLocalSize);
1260 _sizeMap[entry] = sizeMap;
1261 NotifySubMeshesHypothesisModification();
1265 //=======================================================================
1266 //function : GetSizeMapEntry
1267 //=======================================================================
1268 std::string BLSURFPlugin_Hypothesis::GetSizeMapEntry(const std::string& entry) {
1269 TSizeMap::iterator it = _sizeMap.find(entry);
1270 if (it != _sizeMap.end())
1273 return "No_Such_Entry";
1277 * \brief Return the size maps
1279 BLSURFPlugin_Hypothesis::TSizeMap BLSURFPlugin_Hypothesis::GetSizeMapEntries(const BLSURFPlugin_Hypothesis* hyp) {
1280 return hyp ? hyp->_GetSizeMapEntries() : GetDefaultSizeMap();
1283 //=======================================================================
1284 //function : SetAttractorEntry
1285 //=======================================================================
1286 void BLSURFPlugin_Hypothesis::SetAttractorEntry(const std::string& entry, const std::string& attractor) {
1287 if (_attractors[entry].compare(attractor) != 0) {
1288 SetPhysicalMesh(PhysicalLocalSize);
1289 _attractors[entry] = attractor;
1290 NotifySubMeshesHypothesisModification();
1294 //=======================================================================
1295 //function : GetAttractorEntry
1296 //=======================================================================
1297 std::string BLSURFPlugin_Hypothesis::GetAttractorEntry(const std::string& entry) {
1298 TSizeMap::iterator it = _attractors.find(entry);
1299 if (it != _attractors.end())
1302 return "No_Such_Entry";
1306 * \brief Return the attractors
1308 BLSURFPlugin_Hypothesis::TSizeMap BLSURFPlugin_Hypothesis::GetAttractorEntries(const BLSURFPlugin_Hypothesis* hyp) {
1309 return hyp ? hyp->_GetAttractorEntries() : GetDefaultSizeMap();
1312 //=======================================================================
1313 //function : SetClassAttractorEntry
1314 //=======================================================================
1315 void BLSURFPlugin_Hypothesis::SetClassAttractorEntry(const std::string& entry, const std::string& attEntry, double StartSize, double EndSize, double ActionRadius, double ConstantRadius)
1317 SetPhysicalMesh(PhysicalLocalSize);
1319 // The new attractor can't be defined on the same face as another sizemap
1320 TSizeMap::iterator it = _sizeMap.find( entry );
1321 if ( it != _sizeMap.end() ) {
1323 NotifySubMeshesHypothesisModification();
1326 TSizeMap::iterator itAt = _attractors.find( entry );
1327 if ( itAt != _attractors.end() ) {
1328 _attractors.erase(itAt);
1329 NotifySubMeshesHypothesisModification();
1333 const TopoDS_Shape AttractorShape = BLSURFPlugin_Hypothesis::entryToShape(attEntry);
1334 const TopoDS_Face FaceShape = TopoDS::Face(BLSURFPlugin_Hypothesis::entryToShape(entry));
1335 TAttractorMap::iterator attIt = _classAttractors.find(entry);
1336 for ( ; attIt != _classAttractors.end(); ++attIt )
1337 if ( attIt->first == entry &&
1338 attIt->second->GetAttractorEntry() == attEntry )
1340 bool attExists = (attIt != _classAttractors.end());
1342 BLSURFPlugin_Attractor* myAttractor;
1344 myAttractor = new BLSURFPlugin_Attractor(FaceShape, AttractorShape, attEntry);//, 0.1 );
1345 _classAttractors.insert( make_pair( entry, myAttractor ));
1348 myAttractor = attIt->second;
1350 // if (!myAttractor->IsMapBuilt())
1351 // myAttractor->BuildMap();
1352 myAttractor->SetParameters(StartSize, EndSize, ActionRadius, ConstantRadius);
1354 NotifySubMeshesHypothesisModification();
1357 //=======================================================================
1358 //function : SetConstantSizeOnAdjacentFaces
1359 //=======================================================================
1360 // TODO uncomment and test (include the needed .hxx)
1361 // SetConstantSizeOnAdjacentFaces(myShape, att_entry, startSize, endSize = user_size, const_dist ) {
1362 // TopTools_IndexedMapOfShapListOdShape anEdge2FaceMap;
1363 // TopExp::MapShapesAnAncestors(myShape,TopAbs_EDGE, TopAbs_FACE, anEdge2FaceMap);
1364 // TopTools_IndexedMapOfShapListOdShape::iterator it;
1365 // for (it = anEdge2FaceMap.begin();it != anEdge2FaceMap.end();it++){
1366 // SetClassAttractorEntry((*it).first, att_entry, startSize, endSize, 0, const_dist)
1374 //=======================================================================
1375 //function : GetClassAttractorEntry
1376 //=======================================================================
1377 // BLSURFPlugin_Attractor& BLSURFPlugin_Hypothesis::GetClassAttractorEntry(const std::string& entry)
1379 // TAttractorMap::iterator it = _classAttractors.find( entry );
1380 // if ( it != _classAttractors.end() )
1381 // return it->second;
1383 // return "No_Such_Entry";
1387 * \brief Return the map of attractor instances
1389 BLSURFPlugin_Hypothesis::TAttractorMap BLSURFPlugin_Hypothesis::GetClassAttractorEntries(const BLSURFPlugin_Hypothesis* hyp)
1391 return hyp ? hyp->_GetClassAttractorEntries():GetDefaultAttractorMap();
1394 //=======================================================================
1395 //function : ClearEntry
1396 //=======================================================================
1397 void BLSURFPlugin_Hypothesis::ClearEntry(const std::string& entry,
1398 const char * attEntry/*=0*/)
1400 TSizeMap::iterator it = _sizeMap.find( entry );
1402 if ( it != _sizeMap.end() ) {
1404 NotifySubMeshesHypothesisModification();
1407 TSizeMap::iterator itAt = _attractors.find( entry );
1408 if ( itAt != _attractors.end() ) {
1409 _attractors.erase(itAt);
1410 NotifySubMeshesHypothesisModification();
1413 TAttractorMap::iterator it_clAt = _classAttractors.find( entry );
1414 if ( it_clAt != _classAttractors.end() ) {
1416 if ( !attEntry || it_clAt->second->GetAttractorEntry() == attEntry )
1417 _classAttractors.erase( it_clAt++ );
1421 while ( it_clAt != _classAttractors.end() );
1422 NotifySubMeshesHypothesisModification();
1425 std::cout<<"No_Such_Entry"<<std::endl;
1430 //=======================================================================
1431 //function : ClearSizeMaps
1432 //=======================================================================
1433 void BLSURFPlugin_Hypothesis::ClearSizeMaps() {
1435 _attractors.clear();
1436 _classAttractors.clear();
1439 // Enable internal enforced vertices on specific face if requested by user
1441 ////=======================================================================
1442 ////function : SetInternalEnforcedVertex
1443 ////=======================================================================
1444 //void BLSURFPlugin_Hypothesis::SetInternalEnforcedVertex(TEntry theFaceEntry,
1445 // bool toEnforceInternalVertices,
1446 // TEnfGroupName theGroupName) {
1448 // << toEnforceInternalVertices << ", " << theGroupName << ")");
1450 // TFaceEntryInternalVerticesList::iterator it = _faceEntryInternalVerticesList.find(theFaceEntry);
1451 // if (it != _faceEntryInternalVerticesList.end()) {
1452 // if (!toEnforceInternalVertices) {
1453 // _faceEntryInternalVerticesList.erase(it);
1457 // if (toEnforceInternalVertices) {
1458 // _faceEntryInternalVerticesList.insert(theFaceEntry);
1463 // // Take care of groups
1467 //=======================================================================
1468 //function : SetEnforcedVertex
1469 //=======================================================================
1470 bool BLSURFPlugin_Hypothesis::SetEnforcedVertex(TEntry theFaceEntry,
1471 TEnfName theVertexName,
1472 TEntry theVertexEntry,
1473 TEnfGroupName theGroupName,
1474 double x, double y, double z)
1476 SetPhysicalMesh(PhysicalLocalSize);
1478 bool toNotify = false;
1479 bool toCreate = true;
1481 TEnfVertex *oldEnVertex;
1482 TEnfVertex *newEnfVertex = new TEnfVertex();
1483 newEnfVertex->name = theVertexName;
1484 newEnfVertex->geomEntry = theVertexEntry;
1485 newEnfVertex->coords.clear();
1486 if (theVertexEntry == "") {
1487 newEnfVertex->coords.push_back(x);
1488 newEnfVertex->coords.push_back(y);
1489 newEnfVertex->coords.push_back(z);
1491 newEnfVertex->grpName = theGroupName;
1492 newEnfVertex->faceEntries.clear();
1493 newEnfVertex->faceEntries.insert(theFaceEntry);
1496 // update _enfVertexList
1497 TEnfVertexList::iterator it = _enfVertexList.find(newEnfVertex);
1498 if (it != _enfVertexList.end()) {
1500 oldEnVertex = (*it);
1501 if (oldEnVertex->name != theVertexName) {
1502 oldEnVertex->name = theVertexName;
1505 if (oldEnVertex->grpName != theGroupName) {
1506 oldEnVertex->grpName = theGroupName;
1509 TEntryList::iterator it_faceEntries = oldEnVertex->faceEntries.find(theFaceEntry);
1510 if (it_faceEntries == oldEnVertex->faceEntries.end()) {
1511 oldEnVertex->faceEntries.insert(theFaceEntry);
1512 _faceEntryEnfVertexListMap[theFaceEntry].insert(oldEnVertex);
1516 // update map coords / enf vertex if needed
1517 if (oldEnVertex->coords.size()) {
1518 _coordsEnfVertexMap[oldEnVertex->coords] = oldEnVertex;
1519 _faceEntryCoordsListMap[theFaceEntry].insert(oldEnVertex->coords);
1522 // update map geom entry / enf vertex if needed
1523 if (oldEnVertex->geomEntry != "") {
1524 _enfVertexEntryEnfVertexMap[oldEnVertex->geomEntry] = oldEnVertex;
1525 _faceEntryEnfVertexEntryListMap[theFaceEntry].insert(oldEnVertex->geomEntry);
1530 // //////// CREATE ////////////
1533 AddEnforcedVertex( theFaceEntry, newEnfVertex );
1536 delete newEnfVertex;
1540 NotifySubMeshesHypothesisModification();
1545 //=======================================================================
1546 //function : AddEnforcedVertex
1547 //=======================================================================
1549 void BLSURFPlugin_Hypothesis::AddEnforcedVertex( const TEntry& faceEntry,
1550 TEnfVertex * newEnfVertex )
1554 _faceEntryEnfVertexListMap[faceEntry].insert(newEnfVertex);
1555 _enfVertexList.insert(newEnfVertex);
1556 if ( newEnfVertex->geomEntry.empty() ) {
1557 _faceEntryCoordsListMap[faceEntry].insert(newEnfVertex->coords);
1558 _coordsEnfVertexMap[newEnfVertex->coords] = newEnfVertex;
1561 _faceEntryEnfVertexEntryListMap[faceEntry].insert(newEnfVertex->geomEntry);
1562 _enfVertexEntryEnfVertexMap[newEnfVertex->geomEntry] = newEnfVertex;
1567 //=======================================================================
1568 //function : GetEnforcedVertices
1569 //=======================================================================
1571 BLSURFPlugin_Hypothesis::TEnfVertexList BLSURFPlugin_Hypothesis::GetEnfVertexList(const TEntry& theFaceEntry)
1573 if (_faceEntryEnfVertexListMap.count(theFaceEntry) > 0)
1574 return _faceEntryEnfVertexListMap[theFaceEntry];
1576 return GetDefaultEnfVertexList();
1578 std::ostringstream msg;
1579 msg << "No enforced vertex for face entry " << theFaceEntry;
1580 throw std::invalid_argument(msg.str());
1583 //=======================================================================
1584 //function : GetEnfVertexCoordsList
1585 //=======================================================================
1587 BLSURFPlugin_Hypothesis::TEnfVertexCoordsList BLSURFPlugin_Hypothesis::GetEnfVertexCoordsList(const TEntry& theFaceEntry)
1589 if (_faceEntryCoordsListMap.count(theFaceEntry) > 0)
1590 return _faceEntryCoordsListMap[theFaceEntry];
1592 std::ostringstream msg;
1593 msg << "No enforced vertex coords for face entry " << theFaceEntry;
1594 throw std::invalid_argument(msg.str());
1597 //=======================================================================
1598 //function : GetEnfVertexEntryList
1599 //=======================================================================
1601 BLSURFPlugin_Hypothesis::TEntryList BLSURFPlugin_Hypothesis::GetEnfVertexEntryList(const TEntry& theFaceEntry)
1603 if (_faceEntryEnfVertexEntryListMap.count(theFaceEntry) > 0)
1604 return _faceEntryEnfVertexEntryListMap[theFaceEntry];
1606 std::ostringstream msg;
1607 msg << "No enforced vertex entry for face entry " << theFaceEntry;
1608 throw std::invalid_argument(msg.str());
1611 //=======================================================================
1612 //function : GetEnfVertex(TEnfVertexCoords coords)
1613 //=======================================================================
1615 BLSURFPlugin_Hypothesis::TEnfVertex* BLSURFPlugin_Hypothesis::GetEnfVertex(TEnfVertexCoords coords)
1617 if (_coordsEnfVertexMap.count(coords) > 0)
1618 return _coordsEnfVertexMap[coords];
1620 std::ostringstream msg;
1621 msg << "No enforced vertex with coords (" << coords[0] << ", " << coords[1] << ", " << coords[2] << ")";
1622 throw std::invalid_argument(msg.str());
1625 //=======================================================================
1626 //function : GetEnfVertex(const TEntry& theEnfVertexEntry)
1627 //=======================================================================
1629 BLSURFPlugin_Hypothesis::TEnfVertex* BLSURFPlugin_Hypothesis::GetEnfVertex(const TEntry& theEnfVertexEntry)
1631 if (_enfVertexEntryEnfVertexMap.count(theEnfVertexEntry) > 0)
1632 return _enfVertexEntryEnfVertexMap[theEnfVertexEntry];
1634 std::ostringstream msg;
1635 msg << "No enforced vertex with entry " << theEnfVertexEntry;
1636 throw std::invalid_argument(msg.str());
1639 //Enable internal enforced vertices on specific face if requested by user
1640 ////=======================================================================
1641 ////function : GetInternalEnforcedVertex
1642 ////=======================================================================
1644 //bool BLSURFPlugin_Hypothesis::GetInternalEnforcedVertex(const TEntry& theFaceEntry)
1646 // if (_faceEntryInternalVerticesList.count(theFaceEntry) > 0)
1651 //=======================================================================
1652 //function : ClearEnforcedVertex
1653 //=======================================================================
1655 bool BLSURFPlugin_Hypothesis::ClearEnforcedVertex(const TEntry& theFaceEntry,
1656 double x, double y, double z,
1657 const TEntry& theVertexEntry)
1659 bool toNotify = false;
1660 std::ostringstream msg;
1661 TEnfVertex *oldEnfVertex;
1662 TEnfVertexCoords coords;
1664 coords.push_back(x);
1665 coords.push_back(y);
1666 coords.push_back(z);
1668 // check that enf vertex with given enf vertex entry exists
1669 TEnfVertexEntryEnfVertexMap::iterator it_enfVertexEntry = _enfVertexEntryEnfVertexMap.find(theVertexEntry);
1670 if (it_enfVertexEntry != _enfVertexEntryEnfVertexMap.end()) {
1672 oldEnfVertex = it_enfVertexEntry->second;
1674 _enfVertexEntryEnfVertexMap.erase(it_enfVertexEntry);
1676 TEntryList& enfVertexEntryList = _faceEntryEnfVertexEntryListMap[theFaceEntry];
1677 enfVertexEntryList.erase(theVertexEntry);
1678 if (enfVertexEntryList.size() == 0)
1679 _faceEntryEnfVertexEntryListMap.erase(theFaceEntry);
1680 // TFaceEntryEnfVertexEntryListMap::iterator it_entry_entry = _faceEntryEnfVertexEntryListMap.find(theFaceEntry);
1681 // TEntryList::iterator it_entryList = it_entry_entry->second.find(theVertexEntry);
1682 // it_entry_entry->second.erase(it_entryList);
1683 // if (it_entry_entry->second.size() == 0)
1684 // _faceEntryEnfVertexEntryListMap.erase(it_entry_entry);
1687 MESSAGE("Enforced vertex with geom entry " << theVertexEntry << " not found");
1688 msg << "No enforced vertex with geom entry " << theVertexEntry;
1689 // check that enf vertex with given coords exists
1690 TCoordsEnfVertexMap::iterator it_coords_enf = _coordsEnfVertexMap.find(coords);
1691 if (it_coords_enf != _coordsEnfVertexMap.end()) {
1693 oldEnfVertex = it_coords_enf->second;
1695 _coordsEnfVertexMap.erase(it_coords_enf);
1697 TEnfVertexCoordsList& enfVertexCoordsList = _faceEntryCoordsListMap[theFaceEntry];
1698 enfVertexCoordsList.erase(coords);
1699 if (enfVertexCoordsList.size() == 0)
1700 _faceEntryCoordsListMap.erase(theFaceEntry);
1701 // TFaceEntryCoordsListMap::iterator it_entry_coords = _faceEntryCoordsListMap.find(theFaceEntry);
1702 // TEnfVertexCoordsList::iterator it_coordsList = it_entry_coords->second.find(coords);
1703 // it_entry_coords->second.erase(it_coordsList);
1704 // if (it_entry_coords->second.size() == 0)
1705 // _faceEntryCoordsListMap.erase(it_entry_coords);
1708 MESSAGE("Enforced vertex with coords " << x << ", " << y << ", " << z << " not found");
1710 msg << "No enforced vertex at " << x << ", " << y << ", " << z;
1711 throw std::invalid_argument(msg.str());
1715 // update _enfVertexList
1716 TEnfVertexList::iterator it = _enfVertexList.find(oldEnfVertex);
1717 if (it != _enfVertexList.end()) {
1718 (*it)->faceEntries.erase(theFaceEntry);
1719 if ((*it)->faceEntries.size() == 0){
1720 _enfVertexList.erase(it);
1725 // update _faceEntryEnfVertexListMap
1726 TEnfVertexList& currentEnfVertexList = _faceEntryEnfVertexListMap[theFaceEntry];
1727 currentEnfVertexList.erase(oldEnfVertex);
1729 if (currentEnfVertexList.size() == 0) {
1730 _faceEntryEnfVertexListMap.erase(theFaceEntry);
1734 NotifySubMeshesHypothesisModification();
1739 //=======================================================================
1740 //function : ClearEnforcedVertices
1741 //=======================================================================
1743 bool BLSURFPlugin_Hypothesis::ClearEnforcedVertices(const TEntry& theFaceEntry)
1745 bool toNotify = false;
1746 TEnfVertex *oldEnfVertex;
1748 TFaceEntryCoordsListMap::iterator it_entry_coords = _faceEntryCoordsListMap.find(theFaceEntry);
1749 if (it_entry_coords != _faceEntryCoordsListMap.end()) {
1751 TEnfVertexCoordsList coordsList = it_entry_coords->second;
1752 TEnfVertexCoordsList::iterator it_coordsList = coordsList.begin();
1753 for (; it_coordsList != coordsList.end(); ++it_coordsList) {
1754 TEnfVertexCoords coords = (*it_coordsList);
1755 oldEnfVertex = _coordsEnfVertexMap[coords];
1756 _coordsEnfVertexMap.erase(coords);
1757 // update _enfVertexList
1758 TEnfVertexList::iterator it = _enfVertexList.find(oldEnfVertex);
1759 if (it != _enfVertexList.end()) {
1760 (*it)->faceEntries.erase(theFaceEntry);
1761 if ((*it)->faceEntries.size() == 0){
1762 _enfVertexList.erase(it);
1767 _faceEntryCoordsListMap.erase(it_entry_coords);
1768 _faceEntryEnfVertexListMap.erase(theFaceEntry);
1771 TFaceEntryEnfVertexEntryListMap::iterator it_entry_entry = _faceEntryEnfVertexEntryListMap.find(theFaceEntry);
1772 if (it_entry_entry != _faceEntryEnfVertexEntryListMap.end()) {
1774 TEntryList enfVertexEntryList = it_entry_entry->second;
1775 TEntryList::iterator it_enfVertexEntryList = enfVertexEntryList.begin();
1776 for (; it_enfVertexEntryList != enfVertexEntryList.end(); ++it_enfVertexEntryList) {
1777 TEntry enfVertexEntry = (*it_enfVertexEntryList);
1778 oldEnfVertex = _enfVertexEntryEnfVertexMap[enfVertexEntry];
1779 _enfVertexEntryEnfVertexMap.erase(enfVertexEntry);
1780 // update _enfVertexList
1781 TEnfVertexList::iterator it = _enfVertexList.find(oldEnfVertex);
1782 if (it != _enfVertexList.end()) {
1783 (*it)->faceEntries.erase(theFaceEntry);
1784 if ((*it)->faceEntries.size() == 0){
1785 _enfVertexList.erase(it);
1790 _faceEntryEnfVertexEntryListMap.erase(it_entry_entry);
1791 _faceEntryEnfVertexListMap.erase(theFaceEntry);
1795 NotifySubMeshesHypothesisModification();
1798 // std::ostringstream msg;
1799 // msg << "No enforced vertex for " << theFaceEntry;
1800 // throw std::invalid_argument(msg.str());
1803 //=======================================================================
1804 //function : ClearAllEnforcedVertices
1805 //=======================================================================
1806 void BLSURFPlugin_Hypothesis::ClearAllEnforcedVertices()
1808 _faceEntryEnfVertexListMap.clear();
1809 _faceEntryCoordsListMap.clear();
1810 _coordsEnfVertexMap.clear();
1811 _faceEntryEnfVertexEntryListMap.clear();
1812 _enfVertexEntryEnfVertexMap.clear();
1814 TEnfVertexList::iterator it_enfVertex = _enfVertexList.begin();
1815 for ( ; it_enfVertex != _enfVertexList.end(); ++it_enfVertex )
1816 delete *it_enfVertex;
1817 _enfVertexList.clear();
1819 // Enable internal enforced vertices on specific face if requested by user
1820 // _faceEntryInternalVerticesList.clear();
1821 NotifySubMeshesHypothesisModification();
1825 //================================================================================
1827 * \brief Return the enforced vertices
1829 //================================================================================
1832 BLSURFPlugin_Hypothesis::TFaceEntryEnfVertexListMap BLSURFPlugin_Hypothesis::GetAllEnforcedVerticesByFace(
1833 const BLSURFPlugin_Hypothesis* hyp) {
1834 return hyp ? hyp->_GetAllEnforcedVerticesByFace() : GetDefaultFaceEntryEnfVertexListMap();
1837 //Enable internal enforced vertices on specific face if requested by user
1838 //BLSURFPlugin_Hypothesis::TFaceEntryInternalVerticesList BLSURFPlugin_Hypothesis::GetAllInternalEnforcedVerticesByFace(
1839 // const BLSURFPlugin_Hypothesis* hyp) {
1840 // return hyp ? hyp->_GetAllInternalEnforcedVerticesByFace() : GetDefaultFaceEntryInternalVerticesMap();
1843 bool BLSURFPlugin_Hypothesis::GetInternalEnforcedVertexAllFaces(const BLSURFPlugin_Hypothesis* hyp)
1845 return hyp ? hyp->_GetInternalEnforcedVertexAllFaces() : GetDefaultInternalEnforcedVertex();
1848 BLSURFPlugin_Hypothesis::TEnfGroupName BLSURFPlugin_Hypothesis::GetInternalEnforcedVertexAllFacesGroup(const BLSURFPlugin_Hypothesis* hyp)
1850 return hyp ? hyp->_GetInternalEnforcedVertexAllFacesGroup() : BLSURFPlugin_Hypothesis::TEnfGroupName();
1853 BLSURFPlugin_Hypothesis::TEnfVertexList BLSURFPlugin_Hypothesis::GetAllEnforcedVertices(
1854 const BLSURFPlugin_Hypothesis* hyp) {
1855 return hyp ? hyp->_GetAllEnforcedVertices() : GetDefaultEnfVertexList();
1858 BLSURFPlugin_Hypothesis::TFaceEntryCoordsListMap BLSURFPlugin_Hypothesis::GetAllCoordsByFace(
1859 const BLSURFPlugin_Hypothesis* hyp) {
1860 return hyp ? hyp->_GetAllCoordsByFace() : GetDefaultFaceEntryCoordsListMap();
1863 BLSURFPlugin_Hypothesis::TCoordsEnfVertexMap BLSURFPlugin_Hypothesis::GetAllEnforcedVerticesByCoords(
1864 const BLSURFPlugin_Hypothesis* hyp) {
1865 return hyp ? hyp->_GetAllEnforcedVerticesByCoords() : GetDefaultCoordsEnfVertexMap();
1868 BLSURFPlugin_Hypothesis::TFaceEntryEnfVertexEntryListMap BLSURFPlugin_Hypothesis::GetAllEnfVertexEntriesByFace(
1869 const BLSURFPlugin_Hypothesis* hyp) {
1870 return hyp ? hyp->_GetAllEnfVertexEntriesByFace() : GetDefaultFaceEntryEnfVertexEntryListMap();
1873 BLSURFPlugin_Hypothesis::TEnfVertexEntryEnfVertexMap BLSURFPlugin_Hypothesis::GetAllEnforcedVerticesByEnfVertexEntry(
1874 const BLSURFPlugin_Hypothesis* hyp) {
1875 return hyp ? hyp->_GetAllEnforcedVerticesByEnfVertexEntry() : GetDefaultEnfVertexEntryEnfVertexMap();
1878 std::set<int> BLSURFPlugin_Hypothesis::GetEnfVertexNodeIDs(TEnfGroupName theGroupName)
1880 TGroupNameNodeIDMap::const_iterator it = _groupNameNodeIDMap.find(theGroupName);
1881 if (it != _groupNameNodeIDMap.end()) {
1884 std::ostringstream msg;
1885 msg << "No group " << theGroupName;
1886 throw std::invalid_argument(msg.str());
1889 void BLSURFPlugin_Hypothesis::AddEnfVertexNodeID(TEnfGroupName theGroupName,int theNodeID)
1891 _groupNameNodeIDMap[theGroupName].insert(theNodeID);
1894 void BLSURFPlugin_Hypothesis::RemoveEnfVertexNodeID(TEnfGroupName theGroupName,int theNodeID)
1896 TGroupNameNodeIDMap::iterator it = _groupNameNodeIDMap.find(theGroupName);
1897 if (it != _groupNameNodeIDMap.end()) {
1898 std::set<int>::iterator IDit = it->second.find(theNodeID);
1899 if (IDit != it->second.end())
1900 it->second.erase(IDit);
1901 std::ostringstream msg;
1902 msg << "No node IDs " << theNodeID << " for group " << theGroupName;
1903 throw std::invalid_argument(msg.str());
1905 std::ostringstream msg;
1906 msg << "No group " << theGroupName;
1907 throw std::invalid_argument(msg.str());
1911 //=============================================================================
1912 void BLSURFPlugin_Hypothesis::SetInternalEnforcedVertexAllFaces(bool toEnforceInternalVertices) {
1913 if (toEnforceInternalVertices != _enforcedInternalVerticesAllFaces) {
1914 _enforcedInternalVerticesAllFaces = toEnforceInternalVertices;
1915 if (toEnforceInternalVertices)
1916 SetPhysicalMesh(PhysicalLocalSize);
1917 NotifySubMeshesHypothesisModification();
1922 //=============================================================================
1923 void BLSURFPlugin_Hypothesis::SetInternalEnforcedVertexAllFacesGroup(BLSURFPlugin_Hypothesis::TEnfGroupName theGroupName) {
1924 if (std::string(theGroupName) != std::string(_enforcedInternalVerticesAllFacesGroup)) {
1925 _enforcedInternalVerticesAllFacesGroup = theGroupName;
1926 NotifySubMeshesHypothesisModification();
1930 //=============================================================================
1931 BLSURFPlugin_Hypothesis::TPreCadPeriodicityVector BLSURFPlugin_Hypothesis::GetPreCadFacesPeriodicityVector(
1932 const BLSURFPlugin_Hypothesis* hyp) {
1933 return hyp ? hyp->_GetPreCadFacesPeriodicityVector() : GetDefaultPreCadFacesPeriodicityVector();
1936 //=============================================================================
1937 BLSURFPlugin_Hypothesis::TPreCadPeriodicityVector BLSURFPlugin_Hypothesis::GetPreCadEdgesPeriodicityVector(
1938 const BLSURFPlugin_Hypothesis* hyp) {
1939 return hyp ? hyp->_GetPreCadEdgesPeriodicityVector() : GetDefaultPreCadEdgesPeriodicityVector();
1942 //=============================================================================
1943 BLSURFPlugin_Hypothesis::TFacesPeriodicityVector BLSURFPlugin_Hypothesis::GetFacesPeriodicityVector(
1944 const BLSURFPlugin_Hypothesis* hyp) {
1945 return hyp ? hyp->_GetFacesPeriodicityVector() : GetDefaultFacesPeriodicityVector();
1948 //=============================================================================
1949 BLSURFPlugin_Hypothesis::TEdgesPeriodicityVector BLSURFPlugin_Hypothesis::GetEdgesPeriodicityVector(
1950 const BLSURFPlugin_Hypothesis* hyp){
1951 return hyp ? hyp->_GetEdgesPeriodicityVector() : GetDefaultEdgesPeriodicityVector();
1954 //=============================================================================
1955 BLSURFPlugin_Hypothesis::TVerticesPeriodicityVector BLSURFPlugin_Hypothesis::GetVerticesPeriodicityVector(
1956 const BLSURFPlugin_Hypothesis* hyp){
1957 return hyp ? hyp->_GetVerticesPeriodicityVector() : GetDefaultVerticesPeriodicityVector();
1960 //=======================================================================
1961 //function : ClearAllEnforcedVertices
1962 //=======================================================================
1963 void BLSURFPlugin_Hypothesis::ClearPreCadPeriodicityVectors() {
1964 _preCadFacesPeriodicityVector.clear();
1965 _preCadEdgesPeriodicityVector.clear();
1966 NotifySubMeshesHypothesisModification();
1969 //=======================================================================
1970 //function : AddPreCadFacesPeriodicity
1971 //=======================================================================
1972 void BLSURFPlugin_Hypothesis::AddPreCadFacesPeriodicity(TEntry theFace1Entry, TEntry theFace2Entry,
1973 std::vector<std::string> &theSourceVerticesEntries, std::vector<std::string> &theTargetVerticesEntries) {
1975 TPreCadPeriodicity preCadFacesPeriodicity;
1976 preCadFacesPeriodicity.shape1Entry = theFace1Entry;
1977 preCadFacesPeriodicity.shape2Entry = theFace2Entry;
1978 preCadFacesPeriodicity.theSourceVerticesEntries = theSourceVerticesEntries;
1979 preCadFacesPeriodicity.theTargetVerticesEntries = theTargetVerticesEntries;
1981 _preCadFacesPeriodicityVector.push_back(preCadFacesPeriodicity);
1983 NotifySubMeshesHypothesisModification();
1986 //=======================================================================
1987 //function : AddPreCadEdgesPeriodicity
1988 //=======================================================================
1989 void BLSURFPlugin_Hypothesis::AddPreCadEdgesPeriodicity(TEntry theEdge1Entry, TEntry theEdge2Entry,
1990 std::vector<std::string> &theSourceVerticesEntries, std::vector<std::string> &theTargetVerticesEntries) {
1992 TPreCadPeriodicity preCadEdgesPeriodicity;
1993 preCadEdgesPeriodicity.shape1Entry = theEdge1Entry;
1994 preCadEdgesPeriodicity.shape2Entry = theEdge2Entry;
1995 preCadEdgesPeriodicity.theSourceVerticesEntries = theSourceVerticesEntries;
1996 preCadEdgesPeriodicity.theTargetVerticesEntries = theTargetVerticesEntries;
1998 _preCadEdgesPeriodicityVector.push_back(preCadEdgesPeriodicity);
2000 NotifySubMeshesHypothesisModification();
2003 //=============================================================================
2004 std::ostream & BLSURFPlugin_Hypothesis::SaveTo(std::ostream & save)
2006 // We must keep at least the same number of arguments when increasing the SALOME version
2007 // When MG-CADSurf becomes CADMESH, some parameters were fused into a single one. Thus the same
2008 // parameter can be written several times to keep the old global number of parameters.
2010 // Treat old options which are now in the advanced options
2011 TOptionValues::iterator op_val;
2013 int _preCADRemoveNanoEdges = -1;
2014 double _preCADEpsNano = -1.0;
2015 op_val = _option2value.find("respect_geometry");
2016 if (op_val != _option2value.end()) {
2017 std::string value = op_val->second;
2019 _decimesh = value.compare("1") == 0 ? 1 : 0;
2021 op_val = _preCADoption2value.find("remove_tiny_edges");
2022 if (op_val != _preCADoption2value.end()) {
2023 std::string value = op_val->second;
2025 _preCADRemoveNanoEdges = value.compare("1") == 0 ? 1 : 0;
2027 op_val = _preCADoption2value.find("tiny_edge_length");
2028 if (op_val != _preCADoption2value.end()) {
2029 std::string value = op_val->second;
2031 _preCADEpsNano = strtod(value.c_str(), NULL);
2034 save << " " << (int) _topology << " " << (int) _physicalMesh << " " << (int) _geometricMesh << " " << _phySize << " "
2035 << _angleMesh << " " << _gradation << " " << (int) _elementType << " " << _decimesh;
2036 save << " " << _minSize << " " << _maxSize << " " << _angleMesh << " " << _minSize << " " << _maxSize << " " << _verb;
2037 save << " " << (int) _preCADMergeEdges << " " << _preCADRemoveNanoEdges << " " << (int) _preCADDiscardInput << " " << _preCADEpsNano ;
2038 save << " " << (int) _enforcedInternalVerticesAllFaces;
2039 save << " " << (int) _phySizeRel << " " << (int) _minSizeRel << " " << (int) _maxSizeRel << " " << _chordalError ;
2040 save << " " << (int) _anisotropic << " " << _anisotropicRatio << " " << (int) _removeTinyEdges << " " << _tinyEdgeLength ;
2041 save << " " << (int) _badElementRemoval << " " << _badElementAspectRatio << " " << (int) _optimizeMesh << " " << (int) _quadraticMesh ;
2042 save << " " << (int) _preCADProcess3DTopology << " " << (int) _preCADRemoveDuplicateCADFaces;
2043 save << " " << (int)_optimiseTinyEdges << " " << _tinyEdgeOptimisationLength;
2044 save << " " << (int)_correctSurfaceIntersec << " " << _corrSurfaceIntersCost;
2045 save << " " << (int)_useGradation << " " << (int)_useVolumeGradation << " " << _volumeGradation;
2047 op_val = _option2value.begin();
2048 if (op_val != _option2value.end()) {
2049 save << " " << "__OPTIONS_BEGIN__";
2050 for (; op_val != _option2value.end(); ++op_val) {
2051 if (!op_val->second.empty())
2052 save << " " << op_val->first << " " << op_val->second << "%#"; // "%#" is a mark of value end
2054 save << " " << "__OPTIONS_END__";
2057 op_val = _customOption2value.begin();
2058 if (op_val != _customOption2value.end()) {
2059 save << " " << "__CUSTOM_OPTIONS_BEGIN__";
2060 for (; op_val != _customOption2value.end(); ++op_val) {
2061 if (!op_val->second.empty())
2062 save << " " << op_val->first << " " << op_val->second << "%#"; // "%#" is a mark of value end
2064 save << " " << "__CUSTOM_OPTIONS_END__";
2067 op_val = _preCADoption2value.begin();
2068 if (op_val != _preCADoption2value.end()) {
2069 save << " " << "__PRECAD_OPTIONS_BEGIN__";
2070 for (; op_val != _preCADoption2value.end(); ++op_val) {
2071 if (!op_val->second.empty())
2072 save << " " << op_val->first << " " << op_val->second << "%#"; // "%#" is a mark of value end
2074 save << " " << "__PRECAD_OPTIONS_END__";
2077 TSizeMap::iterator it_sm = _sizeMap.begin();
2078 if (it_sm != _sizeMap.end()) {
2079 save << " " << "__SIZEMAP_BEGIN__";
2080 for (; it_sm != _sizeMap.end(); ++it_sm) {
2081 save << " " << it_sm->first << " " << it_sm->second << "%#"; // "%#" is a mark of value end
2083 save << " " << "__SIZEMAP_END__";
2086 TSizeMap::iterator it_at = _attractors.begin();
2087 if (it_at != _attractors.end()) {
2088 save << " " << "__ATTRACTORS_BEGIN__";
2089 for (; it_at != _attractors.end(); ++it_at) {
2090 save << " " << it_at->first << " " << it_at->second << "%#"; // "%#" is a mark of value end
2092 save << " " << "__ATTRACTORS_END__";
2095 TAttractorMap::iterator it_At = _classAttractors.begin();
2096 if (it_At != _classAttractors.end()) {
2097 std::ostringstream test;
2098 save << " " << "__NEW_ATTRACTORS_BEGIN__";
2099 test << " " << "__NEW_ATTRACTORS_BEGIN__";
2100 for (; it_At != _classAttractors.end(); ++it_At) {
2101 std::vector<double> attParams;
2102 attParams = it_At->second->GetParameters();
2103 // double step = it_At->second->GetStep();
2104 save << " " << it_At->first;
2105 save << " " << it_At->second->GetAttractorEntry();
2106 save << " " << attParams[0] << " " << attParams[1] << " " << attParams[2] << " " << attParams[3];
2107 // save << " " << step;
2108 test << " " << it_At->first;
2109 test << " " << it_At->second->GetAttractorEntry();
2110 test << " " << attParams[0] << " " << attParams[1] << " " << attParams[2] << " " << attParams[3];
2111 // test << " " << step;
2113 save << " " << "__NEW_ATTRACTORS_END__";
2114 test << " " << "__NEW_ATTRACTORS_END__";
2117 TEnfVertexList::const_iterator it_enf = _enfVertexList.begin();
2118 if (it_enf != _enfVertexList.end()) {
2119 save << " " << "__ENFORCED_VERTICES_BEGIN__";
2120 for (; it_enf != _enfVertexList.end(); ++it_enf) {
2121 TEnfVertex *enfVertex = (*it_enf);
2122 save << " " << "__BEGIN_VERTEX__";
2123 if (!enfVertex->name.empty()) {
2124 save << " " << "__BEGIN_NAME__";
2125 save << " " << enfVertex->name;
2126 save << " " << "__END_NAME__";
2128 if (!enfVertex->geomEntry.empty()) {
2129 save << " " << "__BEGIN_ENTRY__";
2130 save << " " << enfVertex->geomEntry;
2131 save << " " << "__END_ENTRY__";
2133 if (!enfVertex->grpName.empty()) {
2134 save << " " << "__BEGIN_GROUP__";
2135 save << " " << enfVertex->grpName;
2136 save << " " << "__END_GROUP__";
2138 if (enfVertex->coords.size()) {
2139 save << " " << "__BEGIN_COORDS__";
2140 for ( size_t i = 0; i < enfVertex->coords.size(); i++ )
2141 save << " " << enfVertex->coords[i];
2142 save << " " << "__END_COORDS__";
2144 TEntryList::const_iterator faceEntriesIt = enfVertex->faceEntries.begin();
2145 bool hasFaces = false;
2146 if (faceEntriesIt != enfVertex->faceEntries.end()) {
2148 save << " " << "__BEGIN_FACELIST__";
2150 for (; faceEntriesIt != enfVertex->faceEntries.end(); ++faceEntriesIt)
2151 if ( faceEntriesIt->empty() )
2152 save << " _no_face_";
2154 save << " " << (*faceEntriesIt);
2156 save << " " << "__END_FACELIST__";
2157 save << " " << "__END_VERTEX__";
2159 save << " " << "__ENFORCED_VERTICES_END__";
2164 SavePreCADPeriodicity(save, "FACES");
2165 SavePreCADPeriodicity(save, "EDGES");
2167 SaveFacesPeriodicity(save);
2168 SaveEdgesPeriodicity(save);
2169 SaveVerticesPeriodicity(save);
2172 save << " " << _hyperPatchList.size() << " ";
2173 for ( size_t i = 0; i < _hyperPatchList.size(); ++i )
2175 THyperPatchTags& patch = _hyperPatchList[i];
2176 save << patch.size() << " ";
2177 THyperPatchTags::iterator tag = patch.begin();
2178 for ( ; tag != patch.end(); ++tag )
2179 save << *tag << " ";
2182 // New options in 2.9.6 (issue #17784)
2183 save << " " << _useSurfaceProximity;
2184 save << " " << _nbSurfaceProximityLayers;
2185 save << " " << _surfaceProximityRatio;
2186 save << " " << _useVolumeProximity;
2187 save << " " << _nbVolumeProximityLayers;
2188 save << " " << _volumeProximityRatio;
2193 void BLSURFPlugin_Hypothesis::SaveFacesPeriodicity(std::ostream & save){
2195 TFacesPeriodicityVector::const_iterator it_faces_periodicity = _facesPeriodicityVector.begin();
2196 if (it_faces_periodicity != _facesPeriodicityVector.end()) {
2197 save << " " << "__FACES_PERIODICITY_BEGIN__";
2198 for (; it_faces_periodicity != _facesPeriodicityVector.end(); ++it_faces_periodicity) {
2199 TFacesPeriodicity periodicity_i = (*it_faces_periodicity);
2200 save << " " << "__BEGIN_PERIODICITY_DESCRIPTION__";
2201 save << " " << "__BEGIN_ENTRY1__";
2202 save << " " << periodicity_i.first;
2203 save << " " << "__END_ENTRY1__";
2204 save << " " << "__BEGIN_ENTRY2__";
2205 save << " " << periodicity_i.second;
2206 save << " " << "__END_ENTRY2__";
2207 save << " " << "__END_PERIODICITY_DESCRIPTION__";
2209 save << " " << "__FACES_PERIODICITY_END__";
2213 void BLSURFPlugin_Hypothesis::SaveEdgesPeriodicity(std::ostream & save){
2215 TEdgesPeriodicityVector::const_iterator it_edges_periodicity = _edgesPeriodicityVector.begin();
2216 if (it_edges_periodicity != _edgesPeriodicityVector.end()) {
2217 save << " " << "__EDGES_PERIODICITY_BEGIN__";
2218 for (; it_edges_periodicity != _edgesPeriodicityVector.end(); ++it_edges_periodicity) {
2219 TEdgePeriodicity periodicity_i = (*it_edges_periodicity);
2220 save << " " << "__BEGIN_PERIODICITY_DESCRIPTION__";
2221 if (! periodicity_i.theFace1Entry.empty()){
2222 save << " " << "__BEGIN_FACE1__";
2223 save << " " << periodicity_i.theFace1Entry;
2224 save << " " << "__END_FACE1__";
2226 save << " " << "__BEGIN_EDGE1__";
2227 save << " " << periodicity_i.theEdge1Entry;
2228 save << " " << "__END_EDGE1__";
2229 if (! periodicity_i.theFace2Entry.empty()){
2230 save << " " << "__BEGIN_FACE2__";
2231 save << " " << periodicity_i.theFace2Entry;
2232 save << " " << "__END_FACE2__";
2234 save << " " << "__BEGIN_EDGE2__";
2235 save << " " << periodicity_i.theEdge2Entry;
2236 save << " " << "__END_EDGE2__";
2237 save << " " << "__BEGIN_EDGE_ORIENTATION__";
2238 save << " " << periodicity_i.edge_orientation;
2239 save << " " << "__END_EDGE_ORIENTATION__";
2240 save << " " << "__END_PERIODICITY_DESCRIPTION__";
2242 save << " " << "__EDGES_PERIODICITY_END__";
2246 void BLSURFPlugin_Hypothesis::SaveVerticesPeriodicity(std::ostream & save){
2248 TVerticesPeriodicityVector::const_iterator it_vertices_periodicity = _verticesPeriodicityVector.begin();
2249 if (it_vertices_periodicity != _verticesPeriodicityVector.end()) {
2250 save << " " << "__VERTICES_PERIODICITY_BEGIN__";
2251 for (; it_vertices_periodicity != _verticesPeriodicityVector.end(); ++it_vertices_periodicity) {
2252 TVertexPeriodicity periodicity_i = (*it_vertices_periodicity);
2253 save << " " << "__BEGIN_PERIODICITY_DESCRIPTION__";
2254 save << " " << "__BEGIN_EDGE1__";
2255 save << " " << periodicity_i.theEdge1Entry;
2256 save << " " << "__END_EDGE1__";
2257 save << " " << "__BEGIN_VERTEX1__";
2258 save << " " << periodicity_i.theVertex1Entry;
2259 save << " " << "__END_VERTEX1__";
2260 save << " " << "__BEGIN_EDGE2__";
2261 save << " " << periodicity_i.theEdge2Entry;
2262 save << " " << "__END_EDGE2__";
2263 save << " " << "__BEGIN_VERTEX2__";
2264 save << " " << periodicity_i.theVertex2Entry;
2265 save << " " << "__END_VERTEX2__";
2266 save << " " << "__END_PERIODICITY_DESCRIPTION__";
2268 save << " " << "__VERTICES_PERIODICITY_END__";
2272 void BLSURFPlugin_Hypothesis::SavePreCADPeriodicity(std::ostream & save, const char* shapeType) {
2273 TPreCadPeriodicityVector precad_periodicity;
2274 if ( shapeType && strcmp( shapeType, "FACES" ) == 0 )
2275 precad_periodicity = _preCadFacesPeriodicityVector;
2277 precad_periodicity = _preCadEdgesPeriodicityVector;
2278 TPreCadPeriodicityVector::const_iterator it_precad_periodicity = precad_periodicity.begin();
2279 if (it_precad_periodicity != precad_periodicity.end()) {
2280 save << " " << "__PRECAD_" << shapeType << "_PERIODICITY_BEGIN__";
2281 for (; it_precad_periodicity != precad_periodicity.end(); ++it_precad_periodicity) {
2282 TPreCadPeriodicity periodicity_i = (*it_precad_periodicity);
2283 save << " " << "__BEGIN_PERIODICITY_DESCRIPTION__";
2284 if (!periodicity_i.shape1Entry.empty()) {
2285 save << " " << "__BEGIN_ENTRY1__";
2286 save << " " << periodicity_i.shape1Entry;
2287 save << " " << "__END_ENTRY1__";
2289 if (!periodicity_i.shape2Entry.empty()) {
2290 save << " " << "__BEGIN_ENTRY2__";
2291 save << " " << periodicity_i.shape2Entry;
2292 save << " " << "__END_ENTRY2__";
2295 std::vector<std::string>::const_iterator sourceVerticesEntriesIt = periodicity_i.theSourceVerticesEntries.begin();
2296 bool hasSourceVertices = false;
2297 if (sourceVerticesEntriesIt != periodicity_i.theSourceVerticesEntries.end()) {
2298 hasSourceVertices = true;
2299 save << " " << "__BEGIN_SOURCE_VERTICES_LIST__";
2301 for (; sourceVerticesEntriesIt != periodicity_i.theSourceVerticesEntries.end(); ++sourceVerticesEntriesIt)
2302 save << " " << (*sourceVerticesEntriesIt);
2303 if (hasSourceVertices)
2304 save << " " << "__END_SOURCE_VERTICES_LIST__";
2306 std::vector<std::string>::const_iterator targetVerticesEntriesIt = periodicity_i.theTargetVerticesEntries.begin();
2307 bool hasTargetVertices = false;
2308 if (targetVerticesEntriesIt != periodicity_i.theTargetVerticesEntries.end()) {
2309 hasTargetVertices = true;
2310 save << " " << "__BEGIN_TARGET_VERTICES_LIST__";
2312 for (; targetVerticesEntriesIt != periodicity_i.theTargetVerticesEntries.end(); ++targetVerticesEntriesIt)
2313 save << " " << (*targetVerticesEntriesIt);
2314 if (hasTargetVertices)
2315 save << " " << "__END_TARGET_VERTICES_LIST__";
2317 save << " " << "__END_PERIODICITY_DESCRIPTION__";
2319 save << " " << "__PRECAD_" << shapeType << "_PERIODICITY_END__";
2324 //=============================================================================
2325 std::istream & BLSURFPlugin_Hypothesis::LoadFrom(std::istream & load)
2330 std::string option_or_sm;
2332 isOK = static_cast<bool>(load >> i);
2334 _topology = (Topology) i;
2336 load.clear(std::ios::badbit | load.rdstate());
2338 isOK = static_cast<bool>(load >> i);
2340 _physicalMesh = (PhysicalMesh) i;
2342 load.clear(std::ios::badbit | load.rdstate());
2344 isOK = static_cast<bool>(load >> i);
2346 _geometricMesh = (GeometricMesh) i;
2348 load.clear(std::ios::badbit | load.rdstate());
2350 isOK = static_cast<bool>(load >> val);
2354 load.clear(std::ios::badbit | load.rdstate());
2356 isOK = static_cast<bool>(load >> val);
2360 load.clear(std::ios::badbit | load.rdstate());
2362 isOK = static_cast<bool>(load >> val);
2366 load.clear(std::ios::badbit | load.rdstate());
2368 isOK = static_cast<bool>(load >> i);
2370 _elementType = (ElementType) i;
2372 load.clear(std::ios::badbit | load.rdstate());
2374 isOK = static_cast<bool>(load >> i);
2376 if ( i != -1) { // if value is -1, then this is no longer a standard option
2377 std::string & value = _option2value["respect_geometry"];
2378 bool _decimesh = (bool) i;
2379 value = _decimesh ? "1" : "0";
2383 load.clear(std::ios::badbit | load.rdstate());
2385 isOK = static_cast<bool>(load >> val);
2389 load.clear(std::ios::badbit | load.rdstate());
2391 isOK = static_cast<bool>(load >> val);
2395 load.clear(std::ios::badbit | load.rdstate());
2397 isOK = static_cast<bool>(load >> val);
2399 // former parameter: get min value
2400 _angleMesh = std::min(val,_angleMesh);
2402 load.clear(std::ios::badbit | load.rdstate());
2404 isOK = static_cast<bool>(load >> val);
2406 // former parameter: get min value
2407 _minSize = std::min(val,_minSize);
2409 load.clear(std::ios::badbit | load.rdstate());
2411 isOK = static_cast<bool>(load >> val);
2413 // former parameter: get max value
2414 _maxSize = std::max(val,_maxSize);
2416 load.clear(std::ios::badbit | load.rdstate());
2418 isOK = static_cast<bool>(load >> i);
2422 load.clear(std::ios::badbit | load.rdstate());
2424 isOK = static_cast<bool>(load >> i);
2426 _preCADMergeEdges = (bool) i;
2428 load.clear(std::ios::badbit | load.rdstate());
2430 isOK = static_cast<bool>(load >> i);
2432 if ( i != -1) { // if value is -1, then this is no longer a standard option
2433 std::string & value = _preCADoption2value["remove_tiny_edges"];
2434 bool _preCADRemoveNanoEdges = (bool) i;
2435 value = _preCADRemoveNanoEdges ? "1" : "0";
2439 load.clear(std::ios::badbit | load.rdstate());
2441 isOK = static_cast<bool>(load >> i);
2443 _preCADDiscardInput = (bool) i;
2445 load.clear(std::ios::badbit | load.rdstate());
2447 isOK = static_cast<bool>(load >> val);
2448 if (isOK) { // _preCADEpsNano
2449 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
2450 std::string & value = _preCADoption2value["tiny_edge_length"];
2451 std::ostringstream oss;
2457 load.clear(std::ios::badbit | load.rdstate());
2459 isOK = static_cast<bool>(load >> i);
2461 _enforcedInternalVerticesAllFaces = (bool) i;
2463 load.clear(std::ios::badbit | load.rdstate());
2465 // New options with MeshGems-CADSurf
2467 bool hasCADSurfOptions = false;
2468 bool hasOptions = false;
2469 bool hasCustomOptions = false;
2470 bool hasPreCADOptions = false;
2471 bool hasSizeMap = false;
2472 bool hasAttractor = false;
2473 bool hasNewAttractor = false;
2474 bool hasEnforcedVertex = false;
2475 bool hasPreCADFacesPeriodicity = false;
2476 bool hasPreCADEdgesPeriodicity = false;
2477 bool hasFacesPeriodicity = false;
2478 bool hasEdgesPeriodicity = false;
2479 bool hasVerticesPeriodicity = false;
2481 isOK = static_cast<bool>(load >> option_or_sm);
2483 if (( option_or_sm == "1" ) || ( option_or_sm == "0" )) {
2484 i = atoi(option_or_sm.c_str());
2485 hasCADSurfOptions = true;
2486 _phySizeRel = (bool) i;
2488 else if (option_or_sm == "__OPTIONS_BEGIN__")
2490 else if (option_or_sm == "__CUSTOM_OPTIONS_BEGIN__")
2491 hasCustomOptions = true;
2492 else if (option_or_sm == "__PRECAD_OPTIONS_BEGIN__")
2493 hasPreCADOptions = true;
2494 else if (option_or_sm == "__SIZEMAP_BEGIN__")
2496 else if (option_or_sm == "__ATTRACTORS_BEGIN__")
2497 hasAttractor = true;
2498 else if (option_or_sm == "__NEW_ATTRACTORS_BEGIN__")
2499 hasNewAttractor = true;
2500 else if (option_or_sm == "__ENFORCED_VERTICES_BEGIN__")
2501 hasEnforcedVertex = true;
2502 else if (option_or_sm == "__PRECAD_FACES_PERIODICITY_BEGIN__")
2503 hasPreCADFacesPeriodicity = true;
2504 else if (option_or_sm == "__PRECAD_EDGES_PERIODICITY_BEGIN__")
2505 hasPreCADEdgesPeriodicity = true;
2506 else if (option_or_sm == "__FACES_PERIODICITY_BEGIN__")
2507 hasFacesPeriodicity = true;
2508 else if (option_or_sm == "__EDGES_PERIODICITY_BEGIN__")
2509 hasEdgesPeriodicity = true;
2510 else if (option_or_sm == "__VERTICES_PERIODICITY_BEGIN__")
2511 hasVerticesPeriodicity = true;
2514 if (isOK && hasCADSurfOptions) {
2515 isOK = static_cast<bool>(load >> i);
2517 _minSizeRel = (bool) i;
2519 load.clear(std::ios::badbit | load.rdstate());
2521 isOK = static_cast<bool>(load >> i);
2523 _maxSizeRel = (bool) i;
2525 load.clear(std::ios::badbit | load.rdstate());
2527 isOK = static_cast<bool>(load >> val);
2529 _chordalError = val;
2531 load.clear(std::ios::badbit | load.rdstate());
2533 isOK = static_cast<bool>(load >> i);
2535 _anisotropic = (bool) i;
2537 load.clear(std::ios::badbit | load.rdstate());
2539 isOK = static_cast<bool>(load >> val);
2541 _anisotropicRatio = val;
2543 load.clear(std::ios::badbit | load.rdstate());
2545 isOK = static_cast<bool>(load >> i);
2547 _removeTinyEdges = (bool) i;
2549 load.clear(std::ios::badbit | load.rdstate());
2551 isOK = static_cast<bool>(load >> val);
2553 _tinyEdgeLength = val;
2555 load.clear(std::ios::badbit | load.rdstate());
2557 isOK = static_cast<bool>(load >> i);
2559 _badElementRemoval = (bool) i;
2561 load.clear(std::ios::badbit | load.rdstate());
2563 isOK = static_cast<bool>(load >> val);
2565 _badElementAspectRatio = val;
2567 load.clear(std::ios::badbit | load.rdstate());
2569 isOK = static_cast<bool>(load >> i);
2571 _optimizeMesh = (bool) i;
2573 load.clear(std::ios::badbit | load.rdstate());
2575 isOK = static_cast<bool>(load >> i);
2577 _quadraticMesh = (bool) i;
2579 load.clear(std::ios::badbit | load.rdstate());
2581 isOK = static_cast<bool>(load >> i);
2583 _preCADProcess3DTopology = (bool) i;
2585 load.clear(std::ios::badbit | load.rdstate());
2587 if (( load >> std::ws).peek() != '_' )
2589 isOK = static_cast<bool>(load >> i);
2591 _preCADRemoveDuplicateCADFaces = (bool) i;
2593 load.clear(std::ios::badbit | load.rdstate());
2595 isOK = static_cast<bool>(load >> i);
2597 _optimiseTinyEdges = (bool) i;
2599 load.clear(std::ios::badbit | load.rdstate());
2601 isOK = static_cast<bool>(load >> val);
2603 _tinyEdgeOptimisationLength = val;
2605 load.clear(std::ios::badbit | load.rdstate());
2607 isOK = static_cast<bool>(load >> i);
2609 _correctSurfaceIntersec = (bool) i;
2611 load.clear(std::ios::badbit | load.rdstate());
2613 isOK = static_cast<bool>(load >> val);
2615 _corrSurfaceIntersCost = val;
2617 load.clear(std::ios::badbit | load.rdstate());
2619 isOK = static_cast<bool>(load >> i);
2621 _useGradation = (bool) i;
2623 load.clear(std::ios::badbit | load.rdstate());
2625 isOK = static_cast<bool>(load >> i);
2627 _useVolumeGradation = (bool) i;
2629 load.clear(std::ios::badbit | load.rdstate());
2631 isOK = static_cast<bool>(load >> val);
2633 _volumeGradation = val;
2635 load.clear(std::ios::badbit | load.rdstate());
2640 if (hasCADSurfOptions) {
2641 isOK = static_cast<bool>(load >> option_or_sm);
2643 if (option_or_sm == "__OPTIONS_BEGIN__")
2645 else if (option_or_sm == "__CUSTOM_OPTIONS_BEGIN__")
2646 hasCustomOptions = true;
2647 else if (option_or_sm == "__PRECAD_OPTIONS_BEGIN__")
2648 hasPreCADOptions = true;
2649 else if (option_or_sm == "__SIZEMAP_BEGIN__")
2651 else if (option_or_sm == "__ATTRACTORS_BEGIN__")
2652 hasAttractor = true;
2653 else if (option_or_sm == "__NEW_ATTRACTORS_BEGIN__")
2654 hasNewAttractor = true;
2655 else if (option_or_sm == "__ENFORCED_VERTICES_BEGIN__")
2656 hasEnforcedVertex = true;
2657 else if (option_or_sm == "__PRECAD_FACES_PERIODICITY_BEGIN__")
2658 hasPreCADFacesPeriodicity = true;
2659 else if (option_or_sm == "__PRECAD_EDGES_PERIODICITY_BEGIN__")
2660 hasPreCADEdgesPeriodicity = true;
2661 else if (option_or_sm == "__FACES_PERIODICITY_BEGIN__")
2662 hasFacesPeriodicity = true;
2663 else if (option_or_sm == "__EDGES_PERIODICITY_BEGIN__")
2664 hasEdgesPeriodicity = true;
2665 else if (option_or_sm == "__VERTICES_PERIODICITY_BEGIN__")
2666 hasVerticesPeriodicity = true;
2670 std::string optName, optValue;
2671 while (isOK && hasOptions) {
2672 isOK = static_cast<bool>(load >> optName);
2674 if (optName == "__OPTIONS_END__")
2676 isOK = static_cast<bool>(load >> optValue);
2678 // read the value of the advanced option
2679 // unless this option is no more used
2681 #if MESHGEMS_VERSION_HEX >= 0x020A00
2682 && optName != "enforce_cad_edge_sizes" && optName != "max_number_of_points_per_patch"
2685 std::string & value = _option2value[optName];
2687 int len = value.size();
2688 // continue reading until "%#" encountered
2689 while (value[len - 1] != '#' || value[len - 2] != '%') {
2690 isOK = static_cast<bool>(load >> optValue);
2699 if ( value[ len - 1] == '#' )
2700 value.resize(len - 2); //cut off "%#"
2705 isOK = static_cast<bool>(load >> option_or_sm);
2707 if (option_or_sm == "__CUSTOM_OPTIONS_BEGIN__")
2708 hasCustomOptions = true;
2709 else if (option_or_sm == "__PRECAD_OPTIONS_BEGIN__")
2710 hasPreCADOptions = true;
2711 else if (option_or_sm == "__SIZEMAP_BEGIN__")
2713 else if (option_or_sm == "__ATTRACTORS_BEGIN__")
2714 hasAttractor = true;
2715 else if (option_or_sm == "__NEW_ATTRACTORS_BEGIN__")
2716 hasNewAttractor = true;
2717 else if (option_or_sm == "__ENFORCED_VERTICES_BEGIN__")
2718 hasEnforcedVertex = true;
2719 else if (option_or_sm == "__PRECAD_FACES_PERIODICITY_BEGIN__")
2720 hasPreCADFacesPeriodicity = true;
2721 else if (option_or_sm == "__PRECAD_EDGES_PERIODICITY_BEGIN__")
2722 hasPreCADEdgesPeriodicity = true;
2723 else if (option_or_sm == "__FACES_PERIODICITY_BEGIN__")
2724 hasFacesPeriodicity = true;
2725 else if (option_or_sm == "__EDGES_PERIODICITY_BEGIN__")
2726 hasEdgesPeriodicity = true;
2727 else if (option_or_sm == "__VERTICES_PERIODICITY_BEGIN__")
2728 hasVerticesPeriodicity = true;
2732 while (isOK && hasCustomOptions) {
2733 isOK = static_cast<bool>(load >> optName);
2735 if (optName == "__CUSTOM_OPTIONS_END__")
2737 isOK = static_cast<bool>(load >> optValue);
2740 std::string& value = optValue;
2741 int len = value.size();
2742 // continue reading until "%#" encountered
2743 while (value[len - 1] != '#' || value[len - 2] != '%') {
2744 isOK = static_cast<bool>(load >> optValue);
2753 if ( value[ len - 1] == '#' )
2754 value.resize(len - 2); //cut off "%#"
2755 _customOption2value[optName] = value;
2759 if (hasCustomOptions) {
2760 isOK = static_cast<bool>(load >> option_or_sm);
2762 if (option_or_sm == "__PRECAD_OPTIONS_BEGIN__")
2763 hasPreCADOptions = true;
2764 else if (option_or_sm == "__SIZEMAP_BEGIN__")
2766 else if (option_or_sm == "__ATTRACTORS_BEGIN__")
2767 hasAttractor = true;
2768 else if (option_or_sm == "__NEW_ATTRACTORS_BEGIN__")
2769 hasNewAttractor = true;
2770 else if (option_or_sm == "__ENFORCED_VERTICES_BEGIN__")
2771 hasEnforcedVertex = true;
2772 else if (option_or_sm == "__PRECAD_FACES_PERIODICITY_BEGIN__")
2773 hasPreCADFacesPeriodicity = true;
2774 else if (option_or_sm == "__PRECAD_EDGES_PERIODICITY_BEGIN__")
2775 hasPreCADEdgesPeriodicity = true;
2776 else if (option_or_sm == "__FACES_PERIODICITY_BEGIN__")
2777 hasFacesPeriodicity = true;
2778 else if (option_or_sm == "__EDGES_PERIODICITY_BEGIN__")
2779 hasEdgesPeriodicity = true;
2780 else if (option_or_sm == "__VERTICES_PERIODICITY_BEGIN__")
2781 hasVerticesPeriodicity = true;
2785 while (isOK && hasPreCADOptions) {
2786 isOK = static_cast<bool>(load >> optName);
2788 if (optName == "__PRECAD_OPTIONS_END__")
2790 isOK = static_cast<bool>(load >> optValue);
2793 std::string & value = _preCADoption2value[optName];
2795 int len = value.size();
2796 // continue reading until "%#" encountered
2797 while (value[len - 1] != '#' || value[len - 2] != '%') {
2798 isOK = static_cast<bool>(load >> optValue);
2807 if ( value[ len - 1] == '#' )
2808 value.resize(len - 2); //cut off "%#"
2812 if (hasPreCADOptions) {
2813 isOK = static_cast<bool>(load >> option_or_sm);
2815 if (option_or_sm == "__SIZEMAP_BEGIN__")
2817 else if (option_or_sm == "__ATTRACTORS_BEGIN__")
2818 hasAttractor = true;
2819 else if (option_or_sm == "__NEW_ATTRACTORS_BEGIN__")
2820 hasNewAttractor = true;
2821 else if (option_or_sm == "__ENFORCED_VERTICES_BEGIN__")
2822 hasEnforcedVertex = true;
2823 else if (option_or_sm == "__PRECAD_FACES_PERIODICITY_BEGIN__")
2824 hasPreCADFacesPeriodicity = true;
2825 else if (option_or_sm == "__PRECAD_EDGES_PERIODICITY_BEGIN__")
2826 hasPreCADEdgesPeriodicity = true;
2827 else if (option_or_sm == "__FACES_PERIODICITY_BEGIN__")
2828 hasFacesPeriodicity = true;
2829 else if (option_or_sm == "__EDGES_PERIODICITY_BEGIN__")
2830 hasEdgesPeriodicity = true;
2831 else if (option_or_sm == "__VERTICES_PERIODICITY_BEGIN__")
2832 hasVerticesPeriodicity = true;
2836 std::string smEntry, smValue;
2837 while (isOK && hasSizeMap) {
2838 isOK = static_cast<bool>(load >> smEntry);
2840 if (smEntry == "__SIZEMAP_END__")
2842 isOK = static_cast<bool>(load >> smValue);
2845 std::string & value2 = _sizeMap[smEntry];
2847 int len2 = value2.size();
2848 // continue reading until "%#" encountered
2849 while (value2[len2 - 1] != '#' || value2[len2 - 2] != '%') {
2850 isOK = static_cast<bool>(load >> smValue);
2854 len2 = value2.size();
2859 value2.resize(len2 - 2); //cut off "%#"
2864 isOK = static_cast<bool>(load >> option_or_sm);
2866 if (option_or_sm == "__ATTRACTORS_BEGIN__")
2867 hasAttractor = true;
2868 else if (option_or_sm == "__NEW_ATTRACTORS_BEGIN__")
2869 hasNewAttractor = true;
2870 else if (option_or_sm == "__ENFORCED_VERTICES_BEGIN__")
2871 hasEnforcedVertex = true;
2872 else if (option_or_sm == "__PRECAD_FACES_PERIODICITY_BEGIN__")
2873 hasPreCADFacesPeriodicity = true;
2874 else if (option_or_sm == "__PRECAD_EDGES_PERIODICITY_BEGIN__")
2875 hasPreCADEdgesPeriodicity = true;
2876 else if (option_or_sm == "__FACES_PERIODICITY_BEGIN__")
2877 hasFacesPeriodicity = true;
2878 else if (option_or_sm == "__EDGES_PERIODICITY_BEGIN__")
2879 hasEdgesPeriodicity = true;
2880 else if (option_or_sm == "__VERTICES_PERIODICITY_BEGIN__")
2881 hasVerticesPeriodicity = true;
2885 std::string atEntry, atValue;
2886 while (isOK && hasAttractor) {
2887 isOK = static_cast<bool>(load >> atEntry);
2889 if (atEntry == "__ATTRACTORS_END__")
2891 isOK = static_cast<bool>(load >> atValue);
2894 std::string & value3 = _attractors[atEntry];
2896 int len3 = value3.size();
2897 // continue reading until "%#" encountered
2898 while (value3[len3 - 1] != '#' || value3[len3 - 2] != '%') {
2899 isOK = static_cast<bool>(load >> atValue);
2903 len3 = value3.size();
2908 value3.resize(len3 - 2); //cut off "%#"
2913 isOK = static_cast<bool>(load >> option_or_sm);
2915 if (option_or_sm == "__NEW_ATTRACTORS_BEGIN__")
2916 hasNewAttractor = true;
2917 else if (option_or_sm == "__ENFORCED_VERTICES_BEGIN__")
2918 hasEnforcedVertex = true;
2919 else if (option_or_sm == "__PRECAD_FACES_PERIODICITY_BEGIN__")
2920 hasPreCADFacesPeriodicity = true;
2921 else if (option_or_sm == "__PRECAD_EDGES_PERIODICITY_BEGIN__")
2922 hasPreCADEdgesPeriodicity = true;
2923 else if (option_or_sm == "__FACES_PERIODICITY_BEGIN__")
2924 hasFacesPeriodicity = true;
2925 else if (option_or_sm == "__EDGES_PERIODICITY_BEGIN__")
2926 hasEdgesPeriodicity = true;
2927 else if (option_or_sm == "__VERTICES_PERIODICITY_BEGIN__")
2928 hasVerticesPeriodicity = true;
2932 std::string newAtFaceEntry, atTestString;
2933 std::string newAtShapeEntry;
2934 double attParams[4];
2936 while (isOK && hasNewAttractor) {
2937 //std::cout<<"Load new attractor"<<std::endl;
2938 isOK = static_cast<bool>(load >> newAtFaceEntry);
2940 if (newAtFaceEntry == "__NEW_ATTRACTORS_END__")
2942 isOK = static_cast<bool>(load >> newAtShapeEntry);
2945 isOK = static_cast<bool>(load >> attParams[0]>>attParams[1]>>attParams[2]>>attParams[3]); //>>step);
2948 const TopoDS_Shape attractorShape = BLSURFPlugin_Hypothesis::entryToShape(newAtShapeEntry);
2949 const TopoDS_Face faceShape = TopoDS::Face(BLSURFPlugin_Hypothesis::entryToShape(newAtFaceEntry));
2950 BLSURFPlugin_Attractor* attractor = new BLSURFPlugin_Attractor(faceShape, attractorShape, newAtShapeEntry);//, step);
2951 attractor->SetParameters(attParams[0], attParams[1], attParams[2], attParams[3]);
2952 //attractor->BuildMap();
2953 _classAttractors.insert( make_pair( newAtFaceEntry, attractor ));
2958 if (hasNewAttractor) {
2959 isOK = static_cast<bool>(load >> option_or_sm);
2961 if (option_or_sm == "__ENFORCED_VERTICES_BEGIN__")
2962 hasEnforcedVertex = true;
2963 else if (option_or_sm == "__PRECAD_FACES_PERIODICITY_BEGIN__")
2964 hasPreCADFacesPeriodicity = true;
2965 else if (option_or_sm == "__PRECAD_EDGES_PERIODICITY_BEGIN__")
2966 hasPreCADEdgesPeriodicity = true;
2967 else if (option_or_sm == "__FACES_PERIODICITY_BEGIN__")
2968 hasFacesPeriodicity = true;
2969 else if (option_or_sm == "__EDGES_PERIODICITY_BEGIN__")
2970 hasEdgesPeriodicity = true;
2971 else if (option_or_sm == "__VERTICES_PERIODICITY_BEGIN__")
2972 hasVerticesPeriodicity = true;
2978 // Here is a example of the saved stream:
2979 // __ENFORCED_VERTICES_BEGIN__
2980 // __BEGIN_VERTEX__ => no name, no entry
2981 // __BEGIN_GROUP__ mon groupe __END_GROUP__
2982 // __BEGIN_COORDS__ 10 10 10 __END_COORDS__
2983 // __BEGIN_FACELIST__ 0:1:1:1:1 __END_FACELIST__
2985 // __BEGIN_VERTEX__ => no coords
2986 // __BEGIN_NAME__ mes points __END_NAME__
2987 // __BEGIN_ENTRY__ 0:1:1:4 __END_ENTRY__
2988 // __BEGIN_GROUP__ mon groupe __END_GROUP__
2989 // __BEGIN_FACELIST__ 0:1:1:1:3 __END_FACELIST__
2991 // __ENFORCED_VERTICES_END__
2994 std::string enfSeparator;
2995 std::string enfName;
2996 std::string enfGeomEntry;
2997 std::string enfGroup;
2998 TEntryList enfFaceEntryList;
2999 double enfCoords[3];
3000 bool hasCoords = false;
3002 _faceEntryEnfVertexListMap.clear();
3003 _enfVertexList.clear();
3004 _faceEntryCoordsListMap.clear();
3005 _coordsEnfVertexMap.clear();
3006 _faceEntryEnfVertexEntryListMap.clear();
3007 _enfVertexEntryEnfVertexMap.clear();
3010 while (isOK && hasEnforcedVertex)
3012 isOK = static_cast<bool>(load >> enfSeparator); // __BEGIN_VERTEX__
3013 TEnfVertex *enfVertex = new TEnfVertex();
3014 if (enfSeparator == "__ENFORCED_VERTICES_END__")
3015 break; // __ENFORCED_VERTICES_END__
3016 if (enfSeparator != "__BEGIN_VERTEX__")
3017 throw std::exception();
3020 isOK = static_cast<bool>(load >> enfSeparator);
3021 if (enfSeparator == "__END_VERTEX__") {
3023 enfVertex->name = enfName;
3024 enfVertex->geomEntry = enfGeomEntry;
3025 enfVertex->grpName = enfGroup;
3026 enfVertex->coords.clear();
3028 enfVertex->coords.assign(enfCoords,enfCoords+3);
3029 enfVertex->faceEntries = enfFaceEntryList;
3031 _enfVertexList.insert(enfVertex);
3033 if (enfVertex->coords.size()) {
3034 _coordsEnfVertexMap[enfVertex->coords] = enfVertex;
3035 for (TEntryList::const_iterator it = enfVertex->faceEntries.begin() ; it != enfVertex->faceEntries.end(); ++it) {
3036 _faceEntryCoordsListMap[(*it)].insert(enfVertex->coords);
3037 _faceEntryEnfVertexListMap[(*it)].insert(enfVertex);
3040 if (!enfVertex->geomEntry.empty()) {
3041 _enfVertexEntryEnfVertexMap[enfVertex->geomEntry] = enfVertex;
3042 for (TEntryList::const_iterator it = enfVertex->faceEntries.begin() ; it != enfVertex->faceEntries.end(); ++it) {
3043 _faceEntryEnfVertexEntryListMap[(*it)].insert(enfVertex->geomEntry);
3044 _faceEntryEnfVertexListMap[(*it)].insert(enfVertex);
3049 enfGeomEntry.clear();
3051 enfFaceEntryList.clear();
3053 break; // __END_VERTEX__
3056 if (enfSeparator == "__BEGIN_NAME__") { // __BEGIN_NAME__
3057 while (isOK && (enfSeparator != "__END_NAME__")) {
3058 isOK = static_cast<bool>(load >> enfSeparator);
3059 if (enfSeparator != "__END_NAME__") {
3060 if (!enfName.empty())
3062 enfName += enfSeparator;
3067 if (enfSeparator == "__BEGIN_ENTRY__") { // __BEGIN_ENTRY__
3068 isOK = static_cast<bool>(load >> enfGeomEntry);
3069 isOK = static_cast<bool>(load >> enfSeparator); // __END_ENTRY__
3070 if (enfSeparator != "__END_ENTRY__")
3071 throw std::exception();
3074 if (enfSeparator == "__BEGIN_GROUP__") { // __BEGIN_GROUP__
3075 while (isOK && (enfSeparator != "__END_GROUP__")) {
3076 isOK = static_cast<bool>(load >> enfSeparator);
3077 if (enfSeparator != "__END_GROUP__") {
3078 if (!enfGroup.empty())
3080 enfGroup += enfSeparator;
3085 if (enfSeparator == "__BEGIN_COORDS__") { // __BEGIN_COORDS__
3087 isOK = static_cast<bool>(load >> enfCoords[0] >> enfCoords[1] >> enfCoords[2]);
3088 isOK = static_cast<bool>(load >> enfSeparator); // __END_COORDS__
3089 if (enfSeparator != "__END_COORDS__")
3090 throw std::exception();
3093 if (enfSeparator == "__BEGIN_FACELIST__") { // __BEGIN_FACELIST__
3094 while (isOK && (enfSeparator != "__END_FACELIST__")) {
3095 isOK = static_cast<bool>(load >> enfSeparator);
3096 if (enfSeparator != "__END_FACELIST__") {
3097 enfFaceEntryList.insert(enfSeparator);
3104 if ( hasEnforcedVertex ) {
3105 isOK = static_cast<bool>(load >> option_or_sm);
3107 if (option_or_sm == "__PRECAD_FACES_PERIODICITY_BEGIN__")
3108 hasPreCADFacesPeriodicity = true;
3109 else if (option_or_sm == "__PRECAD_EDGES_PERIODICITY_BEGIN__")
3110 hasPreCADEdgesPeriodicity = true;
3111 else if (option_or_sm == "__FACES_PERIODICITY_BEGIN__")
3112 hasFacesPeriodicity = true;
3113 else if (option_or_sm == "__EDGES_PERIODICITY_BEGIN__")
3114 hasEdgesPeriodicity = true;
3115 else if (option_or_sm == "__VERTICES_PERIODICITY_BEGIN__")
3116 hasVerticesPeriodicity = true;
3122 if (hasPreCADFacesPeriodicity)
3124 LoadPreCADPeriodicity(load, "FACES");
3126 isOK = static_cast<bool>(load >> option_or_sm);
3128 if (option_or_sm == "__PRECAD_EDGES_PERIODICITY_BEGIN__")
3129 hasPreCADEdgesPeriodicity = true;
3130 else if (option_or_sm == "__FACES_PERIODICITY_BEGIN__")
3131 hasFacesPeriodicity = true;
3132 else if (option_or_sm == "__EDGES_PERIODICITY_BEGIN__")
3133 hasEdgesPeriodicity = true;
3134 else if (option_or_sm == "__VERTICES_PERIODICITY_BEGIN__")
3135 hasVerticesPeriodicity = true;
3139 if (hasPreCADEdgesPeriodicity)
3141 LoadPreCADPeriodicity(load, "EDGES");
3143 isOK = static_cast<bool>(load >> option_or_sm);
3145 if (option_or_sm == "__FACES_PERIODICITY_BEGIN__")
3146 hasFacesPeriodicity = true;
3147 else if (option_or_sm == "__EDGES_PERIODICITY_BEGIN__")
3148 hasEdgesPeriodicity = true;
3149 else if (option_or_sm == "__VERTICES_PERIODICITY_BEGIN__")
3150 hasVerticesPeriodicity = true;
3154 if (hasFacesPeriodicity)
3156 LoadFacesPeriodicity(load);
3158 isOK = static_cast<bool>(load >> option_or_sm);
3160 if (option_or_sm == "__EDGES_PERIODICITY_BEGIN__")
3161 hasEdgesPeriodicity = true;
3162 else if (option_or_sm == "__VERTICES_PERIODICITY_BEGIN__")
3163 hasVerticesPeriodicity = true;
3167 if (hasEdgesPeriodicity)
3169 LoadEdgesPeriodicity(load);
3171 isOK = static_cast<bool>(load >> option_or_sm);
3173 if (option_or_sm == "__VERTICES_PERIODICITY_BEGIN__")
3174 hasVerticesPeriodicity = true;
3177 if (hasVerticesPeriodicity)
3178 LoadVerticesPeriodicity(load);
3181 if ( !option_or_sm.empty() && option_or_sm[0] == '_' )
3182 isOK = static_cast<bool>(load >> option_or_sm);
3183 if ( isOK && !option_or_sm.empty() )
3185 int nbPatches = atoi( option_or_sm.c_str() );
3186 if ( nbPatches >= 0 )
3188 _hyperPatchList.resize( nbPatches );
3189 for ( int iP = 0; iP < nbPatches && isOK; ++iP )
3191 isOK = static_cast<bool>(load >> i) && i >= 2;
3194 for ( int iT = 0; iT < nbTags; ++iT )
3196 if (( isOK = static_cast<bool>(load >> i)))
3197 _hyperPatchList[ iP ].insert( i );
3202 if ( !isOK ) // remove invalid patches
3204 for ( i = nbPatches - 1; i >= 0; i-- )
3205 if ( _hyperPatchList[i].size() < 2 )
3206 _hyperPatchList.resize( i );
3211 // New options in 2.9.6 (issue #17784)
3212 if ( static_cast<bool>( load >> _useSurfaceProximity ))
3214 load >> _nbSurfaceProximityLayers;
3215 load >> _surfaceProximityRatio;
3216 load >> _useVolumeProximity;
3217 load >> _nbVolumeProximityLayers;
3218 isOK = static_cast<bool>( load >> _volumeProximityRatio );
3224 void BLSURFPlugin_Hypothesis::LoadFacesPeriodicity(std::istream & load){
3228 std::string periodicitySeparator;
3232 _facesPeriodicityVector.clear();
3235 isOK = static_cast<bool>(load >> periodicitySeparator); // __BEGIN_PERIODICITY_DESCRIPTION__
3236 TFacesPeriodicity *periodicity_i = new TFacesPeriodicity();
3237 if (periodicitySeparator == "__FACES_PERIODICITY_END__")
3238 break; // __FACES_PERIODICITY_END__
3239 if (periodicitySeparator != "__BEGIN_PERIODICITY_DESCRIPTION__"){
3240 throw std::exception();
3244 isOK = static_cast<bool>(load >> periodicitySeparator);
3245 if (periodicitySeparator == "__END_PERIODICITY_DESCRIPTION__") {
3247 periodicity_i->first = shape1Entry;
3248 periodicity_i->second = shape2Entry;
3250 _facesPeriodicityVector.push_back(*periodicity_i);
3252 break; // __END_PERIODICITY_DESCRIPTION__
3255 if (periodicitySeparator == "__BEGIN_ENTRY1__") { // __BEGIN_ENTRY1__
3256 isOK = static_cast<bool>(load >> shape1Entry);
3257 isOK = static_cast<bool>(load >> periodicitySeparator); // __END_ENTRY1__
3258 if (periodicitySeparator != "__END_ENTRY1__")
3259 throw std::exception();
3262 if (periodicitySeparator == "__BEGIN_ENTRY2__") { // __BEGIN_ENTRY2__
3263 isOK = static_cast<bool>(load >> shape2Entry);
3264 isOK = static_cast<bool>(load >> periodicitySeparator); // __END_ENTRY2__
3265 if (periodicitySeparator != "__END_ENTRY2__")
3266 throw std::exception();
3273 void BLSURFPlugin_Hypothesis::LoadEdgesPeriodicity(std::istream & load){
3277 std::string periodicitySeparator;
3278 TEntry theFace1Entry;
3279 TEntry theEdge1Entry;
3280 TEntry theFace2Entry;
3281 TEntry theEdge2Entry;
3282 int edge_orientation = 0;
3284 _edgesPeriodicityVector.clear();
3287 isOK = static_cast<bool>(load >> periodicitySeparator); // __BEGIN_PERIODICITY_DESCRIPTION__
3288 TEdgePeriodicity *periodicity_i = new TEdgePeriodicity();
3289 if (periodicitySeparator == "__EDGES_PERIODICITY_END__")
3290 break; // __EDGES_PERIODICITY_END__
3291 if (periodicitySeparator != "__BEGIN_PERIODICITY_DESCRIPTION__"){
3292 throw std::exception();
3296 isOK = static_cast<bool>(load >> periodicitySeparator);
3297 if (periodicitySeparator == "__END_PERIODICITY_DESCRIPTION__") {
3299 periodicity_i->theFace1Entry = theFace1Entry;
3300 periodicity_i->theEdge1Entry = theEdge1Entry;
3301 periodicity_i->theFace2Entry = theFace2Entry;
3302 periodicity_i->theEdge2Entry = theEdge2Entry;
3303 periodicity_i->edge_orientation = edge_orientation;
3305 _edgesPeriodicityVector.push_back(*periodicity_i);
3307 break; // __END_PERIODICITY_DESCRIPTION__
3310 if (periodicitySeparator == "__BEGIN_FACE1__") { // __BEGIN_FACE1__
3311 isOK = static_cast<bool>(load >> theFace1Entry);
3312 isOK = static_cast<bool>(load >> periodicitySeparator); // __END_FACE1__
3313 if (periodicitySeparator != "__END_FACE1__"){
3314 throw std::exception();
3318 if (periodicitySeparator == "__BEGIN_EDGE1__") { // __BEGIN_EDGE1__
3319 isOK = static_cast<bool>(load >> theEdge1Entry);
3320 isOK = static_cast<bool>(load >> periodicitySeparator); // __END_EDGE1__
3321 if (periodicitySeparator != "__END_EDGE1__")
3322 throw std::exception();
3325 if (periodicitySeparator == "__BEGIN_FACE2__") { // __BEGIN_FACE2__
3326 isOK = static_cast<bool>(load >> theFace2Entry);
3327 isOK = static_cast<bool>(load >> periodicitySeparator); // __END_FACE2__
3328 if (periodicitySeparator != "__END_FACE2__")
3329 throw std::exception();
3332 if (periodicitySeparator == "__BEGIN_EDGE2__") { // __BEGIN_EDGE2__
3333 isOK = static_cast<bool>(load >> theEdge2Entry);
3334 isOK = static_cast<bool>(load >> periodicitySeparator); // __END_EDGE2__
3335 if (periodicitySeparator != "__END_EDGE2__")
3336 throw std::exception();
3339 if (periodicitySeparator == "__BEGIN_EDGE_ORIENTATION__") { // __BEGIN_EDGE_ORIENTATION__
3340 isOK = static_cast<bool>(load >> edge_orientation);
3341 isOK = static_cast<bool>(load >> periodicitySeparator); // __END_EDGE_ORIENTATION__
3342 if (periodicitySeparator != "__END_EDGE_ORIENTATION__")
3343 throw std::exception();
3349 void BLSURFPlugin_Hypothesis::LoadVerticesPeriodicity(std::istream & load)
3353 std::string periodicitySeparator;
3354 TEntry theEdge1Entry;
3355 TEntry theVertex1Entry;
3356 TEntry theEdge2Entry;
3357 TEntry theVertex2Entry;
3359 _verticesPeriodicityVector.clear();
3362 isOK = static_cast<bool>(load >> periodicitySeparator); // __BEGIN_PERIODICITY_DESCRIPTION__
3363 TVertexPeriodicity *periodicity_i = new TVertexPeriodicity();
3364 if (periodicitySeparator == "__VERTICES_PERIODICITY_END__")
3365 break; // __VERTICES_PERIODICITY_END__
3366 if (periodicitySeparator != "__BEGIN_PERIODICITY_DESCRIPTION__"){
3367 throw std::exception();
3371 isOK = static_cast<bool>(load >> periodicitySeparator);
3372 if (periodicitySeparator == "__END_PERIODICITY_DESCRIPTION__") {
3374 periodicity_i->theEdge1Entry = theEdge1Entry;
3375 periodicity_i->theVertex1Entry = theVertex1Entry;
3376 periodicity_i->theEdge2Entry = theEdge2Entry;
3377 periodicity_i->theVertex2Entry = theVertex2Entry;
3379 _verticesPeriodicityVector.push_back(*periodicity_i);
3381 break; // __END_PERIODICITY_DESCRIPTION__
3384 if (periodicitySeparator == "__BEGIN_EDGE1__") { // __BEGIN_EDGE1__
3385 isOK = static_cast<bool>(load >> theEdge1Entry);
3386 isOK = static_cast<bool>(load >> periodicitySeparator); // __END_EDGE1__
3387 if (periodicitySeparator != "__END_EDGE1__")
3388 throw std::exception();
3391 if (periodicitySeparator == "__BEGIN_VERTEX1__") { // __BEGIN_VERTEX1__
3392 isOK = static_cast<bool>(load >> theVertex1Entry);
3393 isOK = static_cast<bool>(load >> periodicitySeparator); // __END_VERTEX1__
3394 if (periodicitySeparator != "__END_VERTEX1__")
3395 throw std::exception();
3398 if (periodicitySeparator == "__BEGIN_EDGE2__") { // __BEGIN_EDGE2__
3399 isOK = static_cast<bool>(load >> theEdge2Entry);
3400 isOK = static_cast<bool>(load >> periodicitySeparator); // __END_EDGE2__
3401 if (periodicitySeparator != "__END_EDGE2__")
3402 throw std::exception();
3405 if (periodicitySeparator == "__BEGIN_VERTEX2__") { // __BEGIN_VERTEX2__
3406 isOK = static_cast<bool>(load >> theVertex2Entry);
3407 isOK = static_cast<bool>(load >> periodicitySeparator); // __END_VERTEX2__
3408 if (periodicitySeparator != "__END_VERTEX2__")
3409 throw std::exception();
3415 void BLSURFPlugin_Hypothesis::LoadPreCADPeriodicity(std::istream & load, const char* shapeType) {
3419 std::string periodicitySeparator;
3422 std::vector<std::string> theSourceVerticesEntries;
3423 std::vector<std::string> theTargetVerticesEntries;
3425 bool hasSourceVertices = false;
3426 bool hasTargetVertices = false;
3428 if ( shapeType && strcmp( shapeType, "FACES") == 0 )
3429 _preCadFacesPeriodicityVector.clear();
3431 _preCadEdgesPeriodicityVector.clear();
3435 isOK = static_cast<bool>(load >> periodicitySeparator); // __BEGIN_PERIODICITY_DESCRIPTION__
3436 TPreCadPeriodicity *periodicity_i = new TPreCadPeriodicity();
3437 std::string endSeparator = "__PRECAD_" + std::string(shapeType) + "_PERIODICITY_END__";
3438 if (periodicitySeparator == endSeparator)
3439 break; // __PRECAD_FACES_PERIODICITY_END__
3440 if (periodicitySeparator != "__BEGIN_PERIODICITY_DESCRIPTION__"){
3441 throw std::exception();
3445 isOK = static_cast<bool>(load >> periodicitySeparator);
3446 if (periodicitySeparator == "__END_PERIODICITY_DESCRIPTION__") {
3448 periodicity_i->shape1Entry = shape1Entry;
3449 periodicity_i->shape2Entry = shape2Entry;
3451 if (hasSourceVertices)
3452 periodicity_i->theSourceVerticesEntries = theSourceVerticesEntries;
3453 if (hasTargetVertices)
3454 periodicity_i->theTargetVerticesEntries = theTargetVerticesEntries;
3456 if ( shapeType && strcmp( shapeType, "FACES" ) == 0 )
3457 _preCadFacesPeriodicityVector.push_back(*periodicity_i);
3459 _preCadEdgesPeriodicityVector.push_back(*periodicity_i);
3461 theSourceVerticesEntries.clear();
3462 theTargetVerticesEntries.clear();
3463 hasSourceVertices = false;
3464 hasTargetVertices = false;
3465 break; // __END_PERIODICITY_DESCRIPTION__
3468 if (periodicitySeparator == "__BEGIN_ENTRY1__") { // __BEGIN_ENTRY1__
3469 isOK = static_cast<bool>(load >> shape1Entry);
3470 isOK = static_cast<bool>(load >> periodicitySeparator); // __END_ENTRY1__
3471 if (periodicitySeparator != "__END_ENTRY1__")
3472 throw std::exception();
3475 if (periodicitySeparator == "__BEGIN_ENTRY2__") { // __BEGIN_ENTRY2__
3476 isOK = static_cast<bool>(load >> shape2Entry);
3477 isOK = static_cast<bool>(load >> periodicitySeparator); // __END_ENTRY2__
3478 if (periodicitySeparator != "__END_ENTRY2__")
3479 throw std::exception();
3482 if (periodicitySeparator == "__BEGIN_SOURCE_VERTICES_LIST__") { // __BEGIN_SOURCE_VERTICES_LIST__
3483 hasSourceVertices = true;
3484 while (isOK && (periodicitySeparator != "__END_SOURCE_VERTICES_LIST__")) {
3485 isOK = static_cast<bool>(load >> periodicitySeparator);
3486 if (periodicitySeparator != "__END_SOURCE_VERTICES_LIST__") {
3487 theSourceVerticesEntries.push_back(periodicitySeparator);
3492 if (periodicitySeparator == "__BEGIN_TARGET_VERTICES_LIST__") { // __BEGIN_TARGET_VERTICES_LIST__
3493 hasTargetVertices = true;
3494 while (isOK && (periodicitySeparator != "__END_TARGET_VERTICES_LIST__")) {
3495 isOK = static_cast<bool>(load >> periodicitySeparator);
3496 if (periodicitySeparator != "__END_TARGET_VERTICES_LIST__") {
3497 theTargetVerticesEntries.push_back(periodicitySeparator);
3505 //=============================================================================
3506 std::ostream & operator <<(std::ostream & save, BLSURFPlugin_Hypothesis & hyp) {
3507 return hyp.SaveTo(save);
3510 //=============================================================================
3511 std::istream & operator >>(std::istream & load, BLSURFPlugin_Hypothesis & hyp) {
3512 return hyp.LoadFrom(load);
3515 //================================================================================
3517 * \brief Does nothing
3519 //================================================================================
3521 bool BLSURFPlugin_Hypothesis::SetParametersByMesh(const SMESH_Mesh* /*theMesh*/, const TopoDS_Shape& /*theShape*/) {
3525 //================================================================================
3527 * \brief Returns default global constant physical size given a default value of element length ratio
3529 //================================================================================
3531 double BLSURFPlugin_Hypothesis::GetDefaultPhySize(double diagonal, double bbSegmentation) {
3532 if (bbSegmentation != 0 && diagonal != 0)
3533 return diagonal / bbSegmentation ;
3537 //================================================================================
3539 * \brief Returns default min size given a default value of element length ratio
3541 //================================================================================
3543 double BLSURFPlugin_Hypothesis::GetDefaultMinSize(double diagonal) {
3545 return diagonal / 1000.0 ;
3546 return undefinedDouble();
3549 //================================================================================
3551 * \brief Returns default max size given a default value of element length ratio
3553 //================================================================================
3555 double BLSURFPlugin_Hypothesis::GetDefaultMaxSize(double diagonal) {
3557 return diagonal / 5.0 ;
3558 return undefinedDouble();
3561 //================================================================================
3563 * \brief Returns default chordal error given a default value of element length ratio
3565 //================================================================================
3567 double BLSURFPlugin_Hypothesis::GetDefaultChordalError(double diagonal) {
3570 return undefinedDouble();
3573 //================================================================================
3575 * \brief Returns default tiny edge length given a default value of element length ratio
3577 //================================================================================
3579 double BLSURFPlugin_Hypothesis::GetDefaultTinyEdgeLength(double diagonal) {
3581 return diagonal * 1e-6 ;
3582 return undefinedDouble();
3585 //================================================================================
3587 * \brief Returns default tiny edge optimisation length given a default value of element length ratio
3589 //================================================================================
3591 double BLSURFPlugin_Hypothesis::GetDefaultTinyEdgeOptimisationLength(double diagonal) {
3593 return diagonal * 1e-6 ;
3594 return undefinedDouble();
3597 //=============================================================================
3599 * \brief Initialize my parameter values by default parameters.
3600 * \retval bool - true if parameter values have been successfully defined
3602 //=============================================================================
3604 bool BLSURFPlugin_Hypothesis::SetParametersByDefaults(const TDefaults& dflts,
3605 const SMESH_Mesh* /*theMesh*/)
3607 _phySize = GetDefaultPhySize(dflts._diagonal, _gen->GetBoundaryBoxSegmentation());
3608 _minSize = GetDefaultMinSize(dflts._diagonal);
3609 _maxSize = GetDefaultMaxSize(dflts._diagonal);
3610 _chordalError = 0.5 * _phySize; //GetDefaultChordalError(diagonal); IMP 0023307
3612 if ( dflts._way == SMESH_Hypothesis::BY_AVERAGE_LENGTH )
3614 _phySize = dflts._elemLength;
3615 _minSize = dflts._elemLength / 100.;
3616 _maxSize = dflts._elemLength * 2.;
3617 _chordalError = dflts._elemLength / 2.;
3618 _elementType = dflts._quadDominated ? QuadrangleDominant : Triangles;
3619 _physicalMesh = PhysicalLocalSize; // to activate _enforcedInternalVerticesAllFaces
3620 _enforcedInternalVerticesAllFaces = true;
3624 _tinyEdgeLength = GetDefaultTinyEdgeLength(dflts._diagonal);
3625 _tinyEdgeOptimisationLength = GetDefaultTinyEdgeOptimisationLength(dflts._diagonal);
3631 //================================================================================
3633 * \brief Converts a string to a bool
3635 //================================================================================
3637 bool BLSURFPlugin_Hypothesis::ToBool(const std::string& str, bool* isOk )
3639 std::string s = str;
3640 if ( isOk ) *isOk = true;
3642 for ( size_t i = 0; i <= s.size(); ++i )
3643 s[i] = tolower( s[i] );
3645 if ( s == "1" || s == "true" || s == "active" || s == "yes" )
3648 if ( s == "0" || s == "false" || s == "inactive" || s == "no" )
3654 std::string msg = "Not a Boolean value:'" + str + "'";
3655 throw std::invalid_argument(msg);
3660 //================================================================================
3662 * \brief Converts a string to a real value
3664 //================================================================================
3666 double BLSURFPlugin_Hypothesis::ToDbl(const std::string& str, bool* isOk )
3668 if ( str.empty() ) throw std::invalid_argument("Empty value provided");
3670 // Forces "C" locale to be set as LC_NUMERIC
3671 Kernel_Utils::Localizer loc;
3674 double val = strtod(&str[0], &endPtr);
3675 bool ok = (&str[0] != endPtr);
3677 if ( isOk ) *isOk = ok;
3681 std::string msg = "Not a real value:'" + str + "'";
3682 throw std::invalid_argument(msg);
3687 //================================================================================
3689 * \brief Converts a string to a integer value
3691 //================================================================================
3693 int BLSURFPlugin_Hypothesis::ToInt(const std::string& str, bool* isOk )
3695 if ( str.empty() ) throw std::invalid_argument("Empty value provided");
3698 int val = (int)strtol( &str[0], &endPtr, 10);
3699 bool ok = (&str[0] != endPtr);
3701 if ( isOk ) *isOk = ok;
3705 std::string msg = "Not an integer value:'" + str + "'";
3706 throw std::invalid_argument(msg);