-// Copyright (C) 2007-2019 CEA/DEN, EDF R&D
+// Copyright (C) 2007-2024 CEA, EDF
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
//
#include "BLSURFPlugin_Hypothesis.hxx"
#include "BLSURFPlugin_Attractor.hxx"
-#include "SMESH_Gen_i.hxx"
+
+#include <SMESHDS_Group.hxx>
+#include <SMESHDS_Mesh.hxx>
+#include <SMESH_BoostTxtArchive.hxx>
+#include <SMESH_Gen_i.hxx>
+#include <SMESH_Group.hxx>
+#include <SMESH_TryCatch.hxx>
+
+#include <Basics_Utils.hxx>
#include <utilities.h>
-#include <cstring>
-#include <iostream>
-#include <sstream>
// cascade include
-#include "ShapeAnalysis.hxx"
+#include <ShapeAnalysis.hxx>
// CORBA includes
#include CORBA_CLIENT_HEADER(SALOMEDS)
#include CORBA_CLIENT_HEADER(GEOM_Gen)
+#include <meshgems/meshgems.h>
+#define MESHGEMS_VERSION_HEX (MESHGEMS_VERSION_MAJOR << 16 | MESHGEMS_VERSION_MINOR << 8 | MESHGEMS_VERSION_PATCH)
+
+#include <boost/archive/text_oarchive.hpp>
+#include <boost/serialization/set.hpp>
+#include <boost/serialization/vector.hpp>
+#include <boost/serialization/string.hpp>
+
namespace
{
struct GET_DEFAULT // struct used to get default value from GetOptionValue()
//=============================================================================
BLSURFPlugin_Hypothesis::BLSURFPlugin_Hypothesis(int hypId, SMESH_Gen * gen, bool hasgeom) :
- SMESH_Hypothesis(hypId, gen),
+ SMESH_Hypothesis(hypId, gen),
_physicalMesh(GetDefaultPhysicalMesh()),
_geometricMesh(GetDefaultGeometricMesh()),
_phySize(GetDefaultPhySize()),
_volumeGradation(GetDefaultVolumeGradation()),
_elementType(GetDefaultElementType()),
_angleMesh(GetDefaultAngleMesh()),
- _chordalError(GetDefaultChordalError()),
+ _chordalError(GetDefaultChordalError()),
_anisotropic(GetDefaultAnisotropic()),
_anisotropicRatio(GetDefaultAnisotropicRatio()),
_removeTinyEdges(GetDefaultRemoveTinyEdges()),
_quadraticMesh(GetDefaultQuadraticMesh()),
_verb(GetDefaultVerbosity()),
_topology(GetDefaultTopology()),
+ _useSurfaceProximity(GetDefaultUseSurfaceProximity()),
+ _nbSurfaceProximityLayers(GetDefaultNbSurfaceProximityLayers()),
+ _surfaceProximityRatio(GetDefaultSurfaceProximityRatio()),
+ _useVolumeProximity(GetDefaultUseVolumeProximity()),
+ _nbVolumeProximityLayers(GetDefaultNbVolumeProximityLayers()),
+ _volumeProximityRatio(GetDefaultVolumeProximityRatio()),
_preCADMergeEdges(GetDefaultPreCADMergeEdges()),
_preCADRemoveDuplicateCADFaces(GetDefaultPreCADRemoveDuplicateCADFaces()),
_preCADProcess3DTopology(GetDefaultPreCADProcess3DTopology()),
{
_name = GetHypType(hasgeom);
_param_algo_dim = 2;
-
-// _GMFFileMode = false; // GMF ascii mode
// Advanced options with their defaults according to MG User Manual
- const char* boolOptionNames[] = { "enforce_cad_edge_sizes", // default = 0
- // "correct_surface_intersections", // default = 1
- // "create_tag_on_collision", // default = 1
- "jacobian_rectification_respect_geometry", // default = 1
- "rectify_jacobian", // default = 1
- "respect_geometry", // default = 1
- // "optimise_tiny_edges", // default = 0
- // "remove_duplicate_cad_faces", // default = 1
- "tiny_edge_avoid_surface_intersections", // default = 1
- "debug", // default = 0
- "use_deprecated_patch_mesher", // default 0
- // "tiny_edge_respect_geometry", // default = 0
- "" // mark of end
- };
+ const char* boolOptionNames[] = {
+#if MESHGEMS_VERSION_HEX < 0x020A00
+ "enforce_cad_edge_sizes", // default = 0 // Deprecated since MeshGems 2.10
+#endif
+ "jacobian_rectification_respect_geometry", // default = 1
+ "rectify_jacobian", // default = 1
+ "respect_geometry", // default = 1
+ "tiny_edge_avoid_surface_intersections", // default = 1
+ "debug", // default = 0
+ "allow_patch_independent", // false
+ "" // mark of end
+ };
- const char* intOptionNames[] = { "max_number_of_points_per_patch", // default = 100000
- "max_number_of_threads", // default = 4
- "" // mark of end
- };
+ const char* intOptionNames[] = {
+#if MESHGEMS_VERSION_HEX < 0x020A00
+ "max_number_of_points_per_patch", // default = 100000 // Deprecated since MeshGems 2.10
+#endif
+ "max_number_of_threads", // default = 4
+ "" // mark of end
+ };
const char* doubleOptionNames[] = { // "surface_intersections_processing_max_cost",// default = 15
// "periodic_tolerance", // default = diag/100
// "volume_gradation",
// "tiny_edge_optimisation_length", // default = diag * 1e-6
- "" // mark of end
- };
+ "" // mark of end
+ };
const char* charOptionNames[] = { // "required_entities", // default = "respect"
// "tags", // default = "respect"
- "" // mark of end
- };
+ "" // mark of end
+ };
// PreCAD advanced options
const char* preCADboolOptionNames[] = { "closed_geometry", // default = 0
// remove_tiny_uv_edges option is not documented
// but it is useful that the user can change it to disable all preprocessing options
"remove_tiny_uv_edges", // default = 1
+ "compute_ridges", // true
"" // mark of end
};
const char* preCADintOptionNames[] = { // "manifold_geometry", // default = 0
// default values to be used while MG meshing
- _defaultOptionValues["enforce_cad_edge_sizes" ] = "no";
+#if MESHGEMS_VERSION_HEX < 0x020A00
+ _defaultOptionValues["enforce_cad_edge_sizes" ] = "no"; // Deprecated since MeshGems 2.10
+#endif
_defaultOptionValues["jacobian_rectification_respect_geometry"] = "yes";
- _defaultOptionValues["max_number_of_points_per_patch" ] = "0";
+#if MESHGEMS_VERSION_HEX < 0x020A00
+ _defaultOptionValues["max_number_of_points_per_patch" ] = "0"; // Deprecated since MeshGems 2.10
+#endif
_defaultOptionValues["max_number_of_threads" ] = "4";
_defaultOptionValues["rectify_jacobian" ] = "yes";
- _defaultOptionValues["use_deprecated_patch_mesher" ] = "yes";
_defaultOptionValues["respect_geometry" ] = "yes";
_defaultOptionValues["tiny_edge_avoid_surface_intersections" ] = "yes";
- _defaultOptionValues["use_deprecated_patch_mesher" ] = "no";
+ //_defaultOptionValues["use_deprecated_patch_mesher" ] = "no";
_defaultOptionValues["debug" ] = "no";
+ _defaultOptionValues["allow_patch_independent" ] = "no";
if ( hasgeom )
{
_defaultOptionValues["closed_geometry" ] = "no";
_defaultOptionValues["required_entities" ] = "respect";
_defaultOptionValues["sewing_tolerance" ] = "5e-4*D";
_defaultOptionValues["tags" ] = "respect";
+ _defaultOptionValues["compute_ridges" ] = "yes";
+ }
+
+ if ( MESHGEMS_VERSION_HEX < 0x020906 )
+ {
+ std::string missingOption = "allow_patch_independent";
+ _defaultOptionValues.erase( missingOption );
+ _boolOptions.erase( missingOption );
+ _option2value.erase( missingOption );
}
#ifdef _DEBUG_
ASSERT( _option2value.size() + _preCADoption2value.size() == _defaultOptionValues.size() );
#endif
- _sizeMap.clear();
- _attractors.clear();
- _faceEntryEnfVertexListMap.clear();
- _enfVertexList.clear();
- _faceEntryCoordsListMap.clear();
- _coordsEnfVertexMap.clear();
- _faceEntryEnfVertexEntryListMap.clear();
- _enfVertexEntryEnfVertexMap.clear();
- _groupNameNodeIDMap.clear();
-
- /* TODO GROUPS
- _groupNameEnfVertexListMap.clear();
- _enfVertexGroupNameMap.clear();
- */
}
TopoDS_Shape BLSURFPlugin_Hypothesis::entryToShape(std::string entry)
GEOM::GEOM_Object_var aGeomObj;
TopoDS_Shape S = TopoDS_Shape();
- SALOMEDS::SObject_var aSObj = SMESH_Gen_i::getStudyServant()->FindObjectID( entry.c_str() );
+ SALOMEDS::SObject_var aSObj = SMESH_Gen_i::GetSMESHGen()->getStudyServant()->FindObjectID( entry.c_str() );
if (!aSObj->_is_nil() ) {
CORBA::Object_var obj = aSObj->GetObject();
aGeomObj = GEOM::GEOM_Object::_narrow(obj);
}
//=============================================================================
-void BLSURFPlugin_Hypothesis::SetPhysicalMesh(PhysicalMesh thePhysicalMesh) {
+std::string BLSURFPlugin_Hypothesis::GetMeshGemsVersion()
+{
+ return MESHGEMS_VERSION_LONG;
+}
+
+//=============================================================================
+void BLSURFPlugin_Hypothesis::SetPhysicalMesh(PhysicalMesh thePhysicalMesh)
+{
if (thePhysicalMesh != _physicalMesh) {
_physicalMesh = thePhysicalMesh;
NotifySubMeshesHypothesisModification();
}
//=============================================================================
-void BLSURFPlugin_Hypothesis::SetGeometricMesh(GeometricMesh theGeometricMesh) {
+void BLSURFPlugin_Hypothesis::SetGeometricMesh(GeometricMesh theGeometricMesh)
+{
if (theGeometricMesh != _geometricMesh) {
_geometricMesh = theGeometricMesh;
// switch (_geometricMesh) {
}
//=============================================================================
-void BLSURFPlugin_Hypothesis::SetPhySize(double theVal, bool isRelative) {
+void BLSURFPlugin_Hypothesis::SetPhySize(double theVal, bool isRelative)
+{
if ((theVal != _phySize) || (isRelative != _phySizeRel)) {
_phySizeRel = isRelative;
if (theVal == 0) {
}
//=============================================================================
-void BLSURFPlugin_Hypothesis::SetMinSize(double theMinSize, bool isRelative) {
+void BLSURFPlugin_Hypothesis::SetMinSize(double theMinSize, bool isRelative)
+{
if ((theMinSize != _minSize) || (isRelative != _minSizeRel)) {
_minSizeRel = isRelative;
_minSize = theMinSize;
}
//=============================================================================
-void BLSURFPlugin_Hypothesis::SetMaxSize(double theMaxSize, bool isRelative) {
+void BLSURFPlugin_Hypothesis::SetMaxSize(double theMaxSize, bool isRelative)
+{
if ((theMaxSize != _maxSize) || (isRelative != _maxSizeRel)) {
_maxSizeRel = isRelative;
_maxSize = theMaxSize;
}
//=============================================================================
-void BLSURFPlugin_Hypothesis::SetUseGradation(bool theVal) {
+void BLSURFPlugin_Hypothesis::SetUseGradation(bool theVal)
+{
if (theVal != _useGradation) {
_useGradation = theVal;
NotifySubMeshesHypothesisModification();
}
//=============================================================================
-void BLSURFPlugin_Hypothesis::SetGradation(double theVal) {
+void BLSURFPlugin_Hypothesis::SetGradation(double theVal)
+{
_useGradation = ( theVal > 0 );
if (theVal != _gradation) {
_gradation = theVal;
}
//=============================================================================
-void BLSURFPlugin_Hypothesis::SetUseVolumeGradation(bool theVal) {
+void BLSURFPlugin_Hypothesis::SetUseVolumeGradation(bool theVal)
+{
if (theVal != _useVolumeGradation) {
_useVolumeGradation = theVal;
NotifySubMeshesHypothesisModification();
}
//=============================================================================
-void BLSURFPlugin_Hypothesis::SetVolumeGradation(double theVal) {
+void BLSURFPlugin_Hypothesis::SetVolumeGradation(double theVal)
+{
_useVolumeGradation = ( theVal > 0 );
if (theVal != _volumeGradation) {
_volumeGradation = theVal;
}
//=============================================================================
-void BLSURFPlugin_Hypothesis::SetElementType(ElementType theElementType) {
+void BLSURFPlugin_Hypothesis::SetElementType(ElementType theElementType)
+{
if (theElementType != _elementType) {
_elementType = theElementType;
NotifySubMeshesHypothesisModification();
}
//=============================================================================
-void BLSURFPlugin_Hypothesis::SetAngleMesh(double theVal) {
+void BLSURFPlugin_Hypothesis::SetAngleMesh(double theVal)
+{
if (theVal != _angleMesh) {
_angleMesh = theVal;
NotifySubMeshesHypothesisModification();
}
//=============================================================================
-void BLSURFPlugin_Hypothesis::SetChordalError(double theDistance) {
+void BLSURFPlugin_Hypothesis::SetChordalError(double theDistance)
+{
if (theDistance != _chordalError) {
_chordalError = theDistance;
NotifySubMeshesHypothesisModification();
}
//=============================================================================
-void BLSURFPlugin_Hypothesis::SetAnisotropic(bool theVal) {
+void BLSURFPlugin_Hypothesis::SetAnisotropic(bool theVal)
+{
if (theVal != _anisotropic) {
_anisotropic = theVal;
NotifySubMeshesHypothesisModification();
}
//=============================================================================
-void BLSURFPlugin_Hypothesis::SetAnisotropicRatio(double theVal) {
+void BLSURFPlugin_Hypothesis::SetAnisotropicRatio(double theVal)
+{
if (theVal != _anisotropicRatio) {
_anisotropicRatio = theVal;
NotifySubMeshesHypothesisModification();
}
//=============================================================================
-void BLSURFPlugin_Hypothesis::SetRemoveTinyEdges(bool theVal) {
+void BLSURFPlugin_Hypothesis::SetRemoveTinyEdges(bool theVal)
+{
if (theVal != _removeTinyEdges) {
_removeTinyEdges = theVal;
NotifySubMeshesHypothesisModification();
}
//=============================================================================
-void BLSURFPlugin_Hypothesis::SetTinyEdgeLength(double theVal) {
+void BLSURFPlugin_Hypothesis::SetTinyEdgeLength(double theVal)
+{
if (theVal != _tinyEdgeLength) {
_tinyEdgeLength = theVal;
NotifySubMeshesHypothesisModification();
}
//=============================================================================
-void BLSURFPlugin_Hypothesis::SetOptimiseTinyEdges(bool theVal) {
+void BLSURFPlugin_Hypothesis::SetOptimiseTinyEdges(bool theVal)
+{
if (theVal != _optimiseTinyEdges) {
_optimiseTinyEdges = theVal;
NotifySubMeshesHypothesisModification();
}
//=============================================================================
-void BLSURFPlugin_Hypothesis::SetTinyEdgeOptimisationLength(double theVal) {
+void BLSURFPlugin_Hypothesis::SetTinyEdgeOptimisationLength(double theVal)
+{
if (theVal != _tinyEdgeOptimisationLength) {
_tinyEdgeOptimisationLength = theVal;
NotifySubMeshesHypothesisModification();
}
//=============================================================================
-void BLSURFPlugin_Hypothesis::SetCorrectSurfaceIntersection(bool theVal) {
+void BLSURFPlugin_Hypothesis::SetCorrectSurfaceIntersection(bool theVal)
+{
if (theVal != _correctSurfaceIntersec) {
_correctSurfaceIntersec = theVal;
NotifySubMeshesHypothesisModification();
}
//=============================================================================
-void BLSURFPlugin_Hypothesis::SetCorrectSurfaceIntersectionMaxCost(double theVal) {
+void BLSURFPlugin_Hypothesis::SetCorrectSurfaceIntersectionMaxCost(double theVal)
+{
if (theVal != _corrSurfaceIntersCost) {
_corrSurfaceIntersCost = theVal;
NotifySubMeshesHypothesisModification();
}
//=============================================================================
-void BLSURFPlugin_Hypothesis::SetBadElementRemoval(bool theVal) {
+void BLSURFPlugin_Hypothesis::SetBadElementRemoval(bool theVal)
+{
if (theVal != _badElementRemoval) {
_badElementRemoval = theVal;
NotifySubMeshesHypothesisModification();
}
//=============================================================================
-void BLSURFPlugin_Hypothesis::SetBadElementAspectRatio(double theVal) {
+void BLSURFPlugin_Hypothesis::SetBadElementAspectRatio(double theVal)
+{
if (theVal != _badElementAspectRatio) {
_badElementAspectRatio = theVal;
NotifySubMeshesHypothesisModification();
}
//=============================================================================
-void BLSURFPlugin_Hypothesis::SetOptimizeMesh(bool theVal) {
+void BLSURFPlugin_Hypothesis::SetOptimizeMesh(bool theVal)
+{
if (theVal != _optimizeMesh) {
_optimizeMesh = theVal;
NotifySubMeshesHypothesisModification();
}
//=============================================================================
-void BLSURFPlugin_Hypothesis::SetQuadraticMesh(bool theVal) {
+void BLSURFPlugin_Hypothesis::SetQuadraticMesh(bool theVal)
+{
if (theVal != _quadraticMesh) {
_quadraticMesh = theVal;
NotifySubMeshesHypothesisModification();
}
//=============================================================================
-void BLSURFPlugin_Hypothesis::SetTopology(Topology theTopology) {
+void BLSURFPlugin_Hypothesis::SetTopology(Topology theTopology)
+{
if (theTopology != _topology) {
_topology = theTopology;
NotifySubMeshesHypothesisModification();
}
}
+//=============================================================================
+void BLSURFPlugin_Hypothesis::SetUseSurfaceProximity( bool toUse )
+{
+ if ( _useSurfaceProximity != toUse )
+ {
+ _useSurfaceProximity = toUse;
+ NotifySubMeshesHypothesisModification();
+ }
+}
+
+//=============================================================================
+void BLSURFPlugin_Hypothesis::SetNbSurfaceProximityLayers( int nbLayers )
+{
+ if ( _nbSurfaceProximityLayers != nbLayers )
+ {
+ _nbSurfaceProximityLayers = nbLayers;
+ NotifySubMeshesHypothesisModification();
+ }
+}
+
+//=============================================================================
+void BLSURFPlugin_Hypothesis::SetSurfaceProximityRatio( double ratio )
+{
+ if ( _surfaceProximityRatio != ratio )
+ {
+ _surfaceProximityRatio = ratio;
+ NotifySubMeshesHypothesisModification();
+ }
+}
+
+//=============================================================================
+void BLSURFPlugin_Hypothesis::SetUseVolumeProximity( bool toUse )
+{
+ if ( _useVolumeProximity != toUse )
+ {
+ _useVolumeProximity = toUse;
+ NotifySubMeshesHypothesisModification();
+ }
+}
+
+//=============================================================================
+void BLSURFPlugin_Hypothesis::SetNbVolumeProximityLayers( int nbLayers )
+{
+ if ( _nbVolumeProximityLayers != nbLayers )
+ {
+ _nbVolumeProximityLayers = nbLayers;
+ NotifySubMeshesHypothesisModification();
+ }
+}
+
+//=============================================================================
+void BLSURFPlugin_Hypothesis::SetVolumeProximityRatio( double ratio )
+{
+ if ( _volumeProximityRatio != ratio )
+ {
+ _volumeProximityRatio = ratio;
+ NotifySubMeshesHypothesisModification();
+ }
+}
+
//=============================================================================
void BLSURFPlugin_Hypothesis::SetVerbosity(int theVal) {
if (theVal != _verb) {
//=============================================================================
void BLSURFPlugin_Hypothesis::SetEnforceCadEdgesSize( bool toEnforce )
{
+#if MESHGEMS_VERSION_HEX < 0x020A00
+ // Deprecated since MeshGems 2.10
if ( GetEnforceCadEdgesSize() != toEnforce )
{
SetOptionValue( "enforce_cad_edge_sizes", toEnforce ? "yes" : "no" );
NotifySubMeshesHypothesisModification();
}
+#else
+ (void)toEnforce; // maybe unused
+#endif
}
//=============================================================================
bool BLSURFPlugin_Hypothesis::GetEnforceCadEdgesSize()
{
+#if MESHGEMS_VERSION_HEX < 0x020A00
+ // Deprecated since MeshGems 2.10
return ToBool( GetOptionValue( "enforce_cad_edge_sizes" ), GET_DEFAULT() );
+#else
+ return false;
+#endif
}
//=============================================================================
}
//=============================================================================
-void BLSURFPlugin_Hypothesis::SetUseDeprecatedPatchMesher( bool useDeprecatedPatchMesher )
+void BLSURFPlugin_Hypothesis::SetUseDeprecatedPatchMesher( bool /*useDeprecatedPatchMesher*/ )
{
- if ( GetUseDeprecatedPatchMesher() != useDeprecatedPatchMesher )
- {
- SetOptionValue( "use_deprecated_patch_mesher", useDeprecatedPatchMesher ? "yes" : "no" );
- NotifySubMeshesHypothesisModification();
- }
+ // if ( GetUseDeprecatedPatchMesher() != useDeprecatedPatchMesher )
+ // {
+ // SetOptionValue( "use_deprecated_patch_mesher", useDeprecatedPatchMesher ? "yes" : "no" );
+ // NotifySubMeshesHypothesisModification();
+ // }
}
//=============================================================================
bool BLSURFPlugin_Hypothesis::GetUseDeprecatedPatchMesher()
{
- return ToBool( GetOptionValue("use_deprecated_patch_mesher", GET_DEFAULT()));
+ return false;//ToBool( GetOptionValue("use_deprecated_patch_mesher", GET_DEFAULT()));
}
//=============================================================================
void BLSURFPlugin_Hypothesis::SetMaxNumberOfPointsPerPatch( int nb )
- throw (std::invalid_argument)
{
+#if MESHGEMS_VERSION_HEX < 0x020A00
+ // Deprecated since MeshGems 2.10
if ( nb < 0 )
throw std::invalid_argument( SMESH_Comment("Invalid number of points: ") << nb );
SetOptionValue("max_number_of_points_per_patch", SMESH_Comment( nb ));
NotifySubMeshesHypothesisModification();
}
+#else
+ (void)nb; // maybe unused
+#endif
}
//=============================================================================
int BLSURFPlugin_Hypothesis::GetMaxNumberOfPointsPerPatch()
{
+#if MESHGEMS_VERSION_HEX < 0x020A00
+ // Deprecated since MeshGems 2.10
return ToInt( GetOptionValue("max_number_of_points_per_patch", GET_DEFAULT()));
+#else
+ return 0;
+#endif
}
//=============================================================================
void BLSURFPlugin_Hypothesis::SetMaxNumberOfThreads( int nb )
- throw (std::invalid_argument)
{
if ( nb < 0 )
throw std::invalid_argument( SMESH_Comment("Invalid number of threads: ") << nb );
//=============================================================================
void BLSURFPlugin_Hypothesis::SetPeriodicTolerance( CORBA::Double tol )
- throw (std::invalid_argument)
{
if ( tol <= 0 )
throw std::invalid_argument( SMESH_Comment("Invalid tolerance: ") << tol );
//=============================================================================
void BLSURFPlugin_Hypothesis::SetRequiredEntities( const std::string& howToTreat )
- throw (std::invalid_argument)
{
if ( howToTreat != "respect" && howToTreat != "ignore" && howToTreat != "clear" )
throw std::invalid_argument
//=============================================================================
void BLSURFPlugin_Hypothesis::SetSewingTolerance( CORBA::Double tol )
- throw (std::invalid_argument)
{
if ( tol <= 0 )
throw std::invalid_argument( SMESH_Comment("Invalid tolerance: ") << tol );
//=============================================================================
void BLSURFPlugin_Hypothesis::SetTags( const std::string& howToTreat )
- throw (std::invalid_argument)
{
if ( howToTreat != "respect" && howToTreat != "ignore" && howToTreat != "clear" )
throw std::invalid_argument
{
return GetPreCADOptionValue("tags", GET_DEFAULT());
}
+
//=============================================================================
-void BLSURFPlugin_Hypothesis::SetHyperPatches(const THyperPatchList& hpl)
+void BLSURFPlugin_Hypothesis::SetHyperPatches(const THyperPatchList& hpl, bool notifyMesh)
{
if ( hpl != _hyperPatchList )
{
_hyperPatchList[ *iPatch ].clear();
}
if ( iPatches.size() > 1 )
- for ( int j = _hyperPatchList.size()-1; j > 0; --j )
+ for ( int j = (int) _hyperPatchList.size()-1; j > 0; --j )
if ( _hyperPatchList[j].empty() )
_hyperPatchList.erase( _hyperPatchList.begin() + j );
}
}
+ if ( notifyMesh )
+ NotifySubMeshesHypothesisModification();
+ }
+}
+//=============================================================================
+void BLSURFPlugin_Hypothesis::SetHyperPatches(const THyperPatchEntriesList& hpel)
+{
+ if ( hpel != _hyperPatchEntriesList )
+ {
+ _hyperPatchEntriesList = hpel;
+ _hyperPatchList.clear();
+
NotifySubMeshesHypothesisModification();
}
}
+//================================================================================
+/*!
+ * \brief Set _hyperPatchList by _hyperPatchEntriesList
+ */
+//================================================================================
+
+void BLSURFPlugin_Hypothesis::
+SetHyperPatchIDsByEntry( const TopoDS_Shape& mainShape,
+ const std::map< std::string, TopoDS_Shape >& entryToShape)
+{
+ _hyperPatchList.clear();
+ if ( _hyperPatchEntriesList.empty() || mainShape.IsNull() )
+ return;
+
+ _hyperPatchList.resize( _hyperPatchEntriesList.size() );
+
+ TopTools_IndexedMapOfShape shapeMap;
+ TopExp::MapShapes( mainShape, shapeMap );
+
+ for ( size_t i = 0; i < _hyperPatchEntriesList.size(); ++i )
+ {
+ THyperPatchTags & idsList = _hyperPatchList [ i ];
+ const THyperPatchEntries & entryList = _hyperPatchEntriesList[ i ];
+ for ( const std::string & entry : entryList )
+ {
+ auto e2sIt = entryToShape.find( entry );
+ if ( e2sIt != entryToShape.end() )
+ {
+ for ( TopExp_Explorer fExp( e2sIt->second, TopAbs_FACE ); fExp.More(); fExp.Next() )
+ {
+ int id = shapeMap.FindIndex( fExp.Current() );
+ if ( id > 0 )
+ idsList.insert( id );
+ }
+ }
+ }
+ }
+ THyperPatchList hpl;
+ hpl.swap( _hyperPatchList );
+ SetHyperPatches( hpl, /*notifyMesh=*/false );
+}
+
//=============================================================================
/*!
* \brief Return a tag of a face taking into account the hyper-patches. Optionally
for ( size_t i = 0; i < hpl.size(); ++i )
if ( hpl[i].count( faceTag ))
{
- if ( iPatch ) *iPatch = i;
+ if ( iPatch ) *iPatch = (int) i;
return *( hpl[i].begin() );
}
}
return faceTag;
}
+
+//=============================================================================
+void BLSURFPlugin_Hypothesis::SetEnforcedMeshes( std::vector< EnforcedMesh > & enforcedMeshes )
+{
+ if ( _enforcedMeshes != enforcedMeshes )
+ {
+ _enforcedMeshes.swap( enforcedMeshes );
+ NotifySubMeshesHypothesisModification();
+ }
+}
+
+//================================================================================
+/*!
+ * \brief Return elements of 1D enforced mesh. Result can be NULL
+ */
+//================================================================================
+
+SMDS_ElemIteratorPtr
+BLSURFPlugin_Hypothesis::GetEnforcedSegments( const EnforcedMesh& enfMesh,
+ SMESH_Mesh* & mesh ) const
+{
+ SMDS_ElemIteratorPtr it;
+ if (( mesh = SMESH_Hypothesis::GetMeshByPersistentID( enfMesh._meshID )))
+ {
+ mesh->Load();
+ if ( mesh->NbEdges() == 0 )
+ GetGen()->Compute( *mesh, mesh->GetShapeToMesh(), /*flags=*/0 );
+
+ switch( enfMesh._type )
+ {
+ case ENFORCED_MESH:
+ it = mesh->GetMeshDS()->elementsIterator( SMDSAbs_Edge );
+ break;
+
+ case ENFORCED_GROUP:
+ if ( SMESH_Group* grp = mesh->GetGroup( enfMesh._subID ))
+ {
+ if ( grp->GetGroupDS()->GetType() == SMDSAbs_Edge )
+ it = grp->GetGroupDS()->GetElements();
+ }
+ break;
+
+ case ENFORCED_SUBMESH:
+ if ( SMESH_subMesh* sm = mesh->GetSubMeshContaining( enfMesh._subID ))
+ if ( SMESHDS_SubMesh * smDS = sm->GetSubMeshDS() )
+ {
+ it = smDS->GetElements();
+ if ( it->more() && it->next()->GetType() != SMDSAbs_Edge )
+ it = SMDS_ElemIteratorPtr();
+ else
+ it = smDS->GetElements();
+ }
+ break;
+ }
+ }
+ return it;
+}
+
+
//=============================================================================
void BLSURFPlugin_Hypothesis::SetPreCADMergeEdges(bool theVal)
{
//=============================================================================
void BLSURFPlugin_Hypothesis::SetOptionValue(const std::string& optionName, const std::string& optionValue)
- throw (std::invalid_argument) {
-
+{
TOptionValues::iterator op_val = _option2value.find(optionName);
if (op_val == _option2value.end())
{
// strip white spaces
while (ptr[0] == ' ')
ptr++;
- int i = strlen(ptr);
+ size_t i = strlen(ptr);
while (i != 0 && ptr[i - 1] == ' ')
i--;
// check value type
//=============================================================================
void BLSURFPlugin_Hypothesis::SetPreCADOptionValue(const std::string& optionName, const std::string& optionValue)
- throw (std::invalid_argument) {
-
+{
TOptionValues::iterator op_val = _preCADoption2value.find(optionName);
if (op_val == _preCADoption2value.end()) {
op_val = _option2value.find(optionName);
// strip white spaces
while (ptr[0] == ' ')
ptr++;
- int i = strlen(ptr);
+ size_t i = strlen(ptr);
while (i != 0 && ptr[i - 1] == ' ')
i--;
// check value type
//=============================================================================
std::string BLSURFPlugin_Hypothesis::GetOptionValue(const std::string& optionName,
bool* isDefault) const
- throw (std::invalid_argument)
{
TOptionValues::const_iterator op_val = _option2value.find(optionName);
if (op_val == _option2value.end())
//=============================================================================
std::string BLSURFPlugin_Hypothesis::GetPreCADOptionValue(const std::string& optionName,
bool* isDefault) const
- throw (std::invalid_argument)
{
TOptionValues::const_iterator op_val = _preCADoption2value.find(optionName);
if (op_val == _preCADoption2value.end())
if ( val.empty() && isDefault )
{
op_val = _defaultOptionValues.find( optionName );
- if (op_val != _option2value.end())
+ if (op_val != _defaultOptionValues.end())
val = op_val->second;
}
return val;
//=======================================================================
BLSURFPlugin_Hypothesis::TEnfVertexList BLSURFPlugin_Hypothesis::GetEnfVertexList(const TEntry& theFaceEntry)
- throw (std::invalid_argument) {
-
+{
if (_faceEntryEnfVertexListMap.count(theFaceEntry) > 0)
return _faceEntryEnfVertexListMap[theFaceEntry];
else
//function : GetEnfVertexCoordsList
//=======================================================================
-BLSURFPlugin_Hypothesis::TEnfVertexCoordsList BLSURFPlugin_Hypothesis::GetEnfVertexCoordsList(
- const TEntry& theFaceEntry) throw (std::invalid_argument) {
-
+BLSURFPlugin_Hypothesis::TEnfVertexCoordsList BLSURFPlugin_Hypothesis::GetEnfVertexCoordsList(const TEntry& theFaceEntry)
+{
if (_faceEntryCoordsListMap.count(theFaceEntry) > 0)
return _faceEntryCoordsListMap[theFaceEntry];
//=======================================================================
BLSURFPlugin_Hypothesis::TEntryList BLSURFPlugin_Hypothesis::GetEnfVertexEntryList(const TEntry& theFaceEntry)
- throw (std::invalid_argument) {
-
+{
if (_faceEntryEnfVertexEntryListMap.count(theFaceEntry) > 0)
return _faceEntryEnfVertexEntryListMap[theFaceEntry];
//=======================================================================
BLSURFPlugin_Hypothesis::TEnfVertex* BLSURFPlugin_Hypothesis::GetEnfVertex(TEnfVertexCoords coords)
- throw (std::invalid_argument) {
-
+{
if (_coordsEnfVertexMap.count(coords) > 0)
return _coordsEnfVertexMap[coords];
//=======================================================================
BLSURFPlugin_Hypothesis::TEnfVertex* BLSURFPlugin_Hypothesis::GetEnfVertex(const TEntry& theEnfVertexEntry)
- throw (std::invalid_argument) {
-
+{
if (_enfVertexEntryEnfVertexMap.count(theEnfVertexEntry) > 0)
return _enfVertexEntryEnfVertexMap[theEnfVertexEntry];
//function : ClearEnforcedVertex
//=======================================================================
-bool BLSURFPlugin_Hypothesis::ClearEnforcedVertex(const TEntry& theFaceEntry, double x, double y, double z,
- const TEntry& theVertexEntry) throw (std::invalid_argument) {
-
+bool BLSURFPlugin_Hypothesis::ClearEnforcedVertex(const TEntry& theFaceEntry,
+ double x, double y, double z,
+ const TEntry& theVertexEntry)
+{
bool toNotify = false;
std::ostringstream msg;
TEnfVertex *oldEnfVertex;
//function : ClearEnforcedVertices
//=======================================================================
-bool BLSURFPlugin_Hypothesis::ClearEnforcedVertices(const TEntry& theFaceEntry) throw (std::invalid_argument) {
-
+bool BLSURFPlugin_Hypothesis::ClearEnforcedVertices(const TEntry& theFaceEntry)
+{
bool toNotify = false;
TEnfVertex *oldEnfVertex;
BLSURFPlugin_Hypothesis::TFaceEntryEnfVertexListMap BLSURFPlugin_Hypothesis::GetAllEnforcedVerticesByFace(
- const BLSURFPlugin_Hypothesis* hyp) {
+ const BLSURFPlugin_Hypothesis* hyp)
+{
return hyp ? hyp->_GetAllEnforcedVerticesByFace() : GetDefaultFaceEntryEnfVertexListMap();
}
}
BLSURFPlugin_Hypothesis::TEnfVertexList BLSURFPlugin_Hypothesis::GetAllEnforcedVertices(
- const BLSURFPlugin_Hypothesis* hyp) {
+ const BLSURFPlugin_Hypothesis* hyp)
+{
return hyp ? hyp->_GetAllEnforcedVertices() : GetDefaultEnfVertexList();
}
BLSURFPlugin_Hypothesis::TFaceEntryCoordsListMap BLSURFPlugin_Hypothesis::GetAllCoordsByFace(
- const BLSURFPlugin_Hypothesis* hyp) {
+ const BLSURFPlugin_Hypothesis* hyp)
+{
return hyp ? hyp->_GetAllCoordsByFace() : GetDefaultFaceEntryCoordsListMap();
}
BLSURFPlugin_Hypothesis::TCoordsEnfVertexMap BLSURFPlugin_Hypothesis::GetAllEnforcedVerticesByCoords(
- const BLSURFPlugin_Hypothesis* hyp) {
+ const BLSURFPlugin_Hypothesis* hyp)
+{
return hyp ? hyp->_GetAllEnforcedVerticesByCoords() : GetDefaultCoordsEnfVertexMap();
}
BLSURFPlugin_Hypothesis::TFaceEntryEnfVertexEntryListMap BLSURFPlugin_Hypothesis::GetAllEnfVertexEntriesByFace(
- const BLSURFPlugin_Hypothesis* hyp) {
+ const BLSURFPlugin_Hypothesis* hyp)
+{
return hyp ? hyp->_GetAllEnfVertexEntriesByFace() : GetDefaultFaceEntryEnfVertexEntryListMap();
}
BLSURFPlugin_Hypothesis::TEnfVertexEntryEnfVertexMap BLSURFPlugin_Hypothesis::GetAllEnforcedVerticesByEnfVertexEntry(
- const BLSURFPlugin_Hypothesis* hyp) {
+ const BLSURFPlugin_Hypothesis* hyp)
+{
return hyp ? hyp->_GetAllEnforcedVerticesByEnfVertexEntry() : GetDefaultEnfVertexEntryEnfVertexMap();
}
-std::set<int> BLSURFPlugin_Hypothesis::GetEnfVertexNodeIDs(TEnfGroupName theGroupName) throw (std::invalid_argument)
+std::set<smIdType> BLSURFPlugin_Hypothesis::GetEnfVertexNodeIDs(TEnfGroupName theGroupName)
{
TGroupNameNodeIDMap::const_iterator it = _groupNameNodeIDMap.find(theGroupName);
if (it != _groupNameNodeIDMap.end()) {
throw std::invalid_argument(msg.str());
}
-void BLSURFPlugin_Hypothesis::AddEnfVertexNodeID(TEnfGroupName theGroupName,int theNodeID)
+void BLSURFPlugin_Hypothesis::AddEnfVertexNodeID(TEnfGroupName theGroupName,smIdType theNodeID)
{
_groupNameNodeIDMap[theGroupName].insert(theNodeID);
}
-void BLSURFPlugin_Hypothesis::RemoveEnfVertexNodeID(TEnfGroupName theGroupName,int theNodeID) throw (std::invalid_argument)
+void BLSURFPlugin_Hypothesis::RemoveEnfVertexNodeID(TEnfGroupName theGroupName,smIdType theNodeID)
{
TGroupNameNodeIDMap::iterator it = _groupNameNodeIDMap.find(theGroupName);
if (it != _groupNameNodeIDMap.end()) {
- std::set<int>::iterator IDit = it->second.find(theNodeID);
+ std::set<smIdType>::iterator IDit = it->second.find(theNodeID);
if (IDit != it->second.end())
it->second.erase(IDit);
std::ostringstream msg;
//=============================================================================
-void BLSURFPlugin_Hypothesis::SetInternalEnforcedVertexAllFaces(bool toEnforceInternalVertices) {
+void BLSURFPlugin_Hypothesis::SetInternalEnforcedVertexAllFaces(bool toEnforceInternalVertices)
+{
if (toEnforceInternalVertices != _enforcedInternalVerticesAllFaces) {
_enforcedInternalVerticesAllFaces = toEnforceInternalVertices;
if (toEnforceInternalVertices)
//=============================================================================
-void BLSURFPlugin_Hypothesis::SetInternalEnforcedVertexAllFacesGroup(BLSURFPlugin_Hypothesis::TEnfGroupName theGroupName) {
+void BLSURFPlugin_Hypothesis::SetInternalEnforcedVertexAllFacesGroup(BLSURFPlugin_Hypothesis::TEnfGroupName theGroupName)
+{
if (std::string(theGroupName) != std::string(_enforcedInternalVerticesAllFacesGroup)) {
_enforcedInternalVerticesAllFacesGroup = theGroupName;
NotifySubMeshesHypothesisModification();
//=============================================================================
BLSURFPlugin_Hypothesis::TPreCadPeriodicityVector BLSURFPlugin_Hypothesis::GetPreCadFacesPeriodicityVector(
- const BLSURFPlugin_Hypothesis* hyp) {
+ const BLSURFPlugin_Hypothesis* hyp)
+{
return hyp ? hyp->_GetPreCadFacesPeriodicityVector() : GetDefaultPreCadFacesPeriodicityVector();
}
//=============================================================================
BLSURFPlugin_Hypothesis::TPreCadPeriodicityVector BLSURFPlugin_Hypothesis::GetPreCadEdgesPeriodicityVector(
- const BLSURFPlugin_Hypothesis* hyp) {
+ const BLSURFPlugin_Hypothesis* hyp)
+{
return hyp ? hyp->_GetPreCadEdgesPeriodicityVector() : GetDefaultPreCadEdgesPeriodicityVector();
}
//=============================================================================
BLSURFPlugin_Hypothesis::TFacesPeriodicityVector BLSURFPlugin_Hypothesis::GetFacesPeriodicityVector(
- const BLSURFPlugin_Hypothesis* hyp) {
+ const BLSURFPlugin_Hypothesis* hyp)
+{
return hyp ? hyp->_GetFacesPeriodicityVector() : GetDefaultFacesPeriodicityVector();
}
//=============================================================================
BLSURFPlugin_Hypothesis::TEdgesPeriodicityVector BLSURFPlugin_Hypothesis::GetEdgesPeriodicityVector(
- const BLSURFPlugin_Hypothesis* hyp){
+ const BLSURFPlugin_Hypothesis* hyp)
+{
return hyp ? hyp->_GetEdgesPeriodicityVector() : GetDefaultEdgesPeriodicityVector();
}
//=============================================================================
BLSURFPlugin_Hypothesis::TVerticesPeriodicityVector BLSURFPlugin_Hypothesis::GetVerticesPeriodicityVector(
- const BLSURFPlugin_Hypothesis* hyp){
+ const BLSURFPlugin_Hypothesis* hyp)
+{
return hyp ? hyp->_GetVerticesPeriodicityVector() : GetDefaultVerticesPeriodicityVector();
}
//=======================================================================
//function : ClearAllEnforcedVertices
//=======================================================================
-void BLSURFPlugin_Hypothesis::ClearPreCadPeriodicityVectors() {
+void BLSURFPlugin_Hypothesis::ClearPreCadPeriodicityVectors()
+{
_preCadFacesPeriodicityVector.clear();
_preCadEdgesPeriodicityVector.clear();
NotifySubMeshesHypothesisModification();
//function : AddPreCadFacesPeriodicity
//=======================================================================
void BLSURFPlugin_Hypothesis::AddPreCadFacesPeriodicity(TEntry theFace1Entry, TEntry theFace2Entry,
- std::vector<std::string> &theSourceVerticesEntries, std::vector<std::string> &theTargetVerticesEntries) {
+ std::vector<std::string> &theSourceVerticesEntries, std::vector<std::string> &theTargetVerticesEntries)
+{
TPreCadPeriodicity preCadFacesPeriodicity;
preCadFacesPeriodicity.shape1Entry = theFace1Entry;
//function : AddPreCadEdgesPeriodicity
//=======================================================================
void BLSURFPlugin_Hypothesis::AddPreCadEdgesPeriodicity(TEntry theEdge1Entry, TEntry theEdge2Entry,
- std::vector<std::string> &theSourceVerticesEntries, std::vector<std::string> &theTargetVerticesEntries) {
-
+ std::vector<std::string> &theSourceVerticesEntries, std::vector<std::string> &theTargetVerticesEntries)
+{
TPreCadPeriodicity preCadEdgesPeriodicity;
preCadEdgesPeriodicity.shape1Entry = theEdge1Entry;
preCadEdgesPeriodicity.shape2Entry = theEdge2Entry;
save << *tag << " ";
}
+ // New options in 2.9.6 (issue #17784)
+ save << " " << _useSurfaceProximity;
+ save << " " << _nbSurfaceProximityLayers;
+ save << " " << _surfaceProximityRatio;
+ save << " " << _useVolumeProximity;
+ save << " " << _nbVolumeProximityLayers;
+ save << " " << _volumeProximityRatio;
+
+ // hyper-patches as entries
+ std::ostringstream hpStream;
+ boost::archive::text_oarchive( hpStream ) << _hyperPatchEntriesList;
+ std::string hpString = hpStream.str();
+ SMESHDS_Hypothesis::SaveStringToStream( save, hpString );
+
+ // Enforced meshes
+ std::ostringstream enfMStream;
+ boost::archive::text_oarchive( enfMStream ) << _enforcedMeshes;
+ std::string enfMString = enfMStream.str();
+ SMESHDS_Hypothesis::SaveStringToStream( save, enfMString );
+
return save;
}
-void BLSURFPlugin_Hypothesis::SaveFacesPeriodicity(std::ostream & save){
-
+void BLSURFPlugin_Hypothesis::SaveFacesPeriodicity(std::ostream & save)
+{
TFacesPeriodicityVector::const_iterator it_faces_periodicity = _facesPeriodicityVector.begin();
if (it_faces_periodicity != _facesPeriodicityVector.end()) {
save << " " << "__FACES_PERIODICITY_BEGIN__";
}
}
-void BLSURFPlugin_Hypothesis::SaveEdgesPeriodicity(std::ostream & save){
-
+void BLSURFPlugin_Hypothesis::SaveEdgesPeriodicity(std::ostream & save)
+{
TEdgesPeriodicityVector::const_iterator it_edges_periodicity = _edgesPeriodicityVector.begin();
if (it_edges_periodicity != _edgesPeriodicityVector.end()) {
save << " " << "__EDGES_PERIODICITY_BEGIN__";
}
}
-void BLSURFPlugin_Hypothesis::SaveVerticesPeriodicity(std::ostream & save){
-
+void BLSURFPlugin_Hypothesis::SaveVerticesPeriodicity(std::ostream & save)
+{
TVerticesPeriodicityVector::const_iterator it_vertices_periodicity = _verticesPeriodicityVector.begin();
if (it_vertices_periodicity != _verticesPeriodicityVector.end()) {
save << " " << "__VERTICES_PERIODICITY_BEGIN__";
}
}
-void BLSURFPlugin_Hypothesis::SavePreCADPeriodicity(std::ostream & save, const char* shapeType) {
+void BLSURFPlugin_Hypothesis::SavePreCADPeriodicity(std::ostream & save, const char* shapeType)
+{
TPreCadPeriodicityVector precad_periodicity;
if ( shapeType && strcmp( shapeType, "FACES" ) == 0 )
precad_periodicity = _preCadFacesPeriodicityVector;
bool hasVerticesPeriodicity = false;
isOK = static_cast<bool>(load >> option_or_sm);
- if (isOK)
- if ( (option_or_sm == "1")||(option_or_sm == "0") ) {
+ if (isOK) {
+ if (( option_or_sm == "1" ) || ( option_or_sm == "0" )) {
i = atoi(option_or_sm.c_str());
hasCADSurfOptions = true;
_phySizeRel = (bool) i;
}
- if (option_or_sm == "__OPTIONS_BEGIN__")
+ else if (option_or_sm == "__OPTIONS_BEGIN__")
hasOptions = true;
else if (option_or_sm == "__CUSTOM_OPTIONS_BEGIN__")
hasCustomOptions = true;
hasEdgesPeriodicity = true;
else if (option_or_sm == "__VERTICES_PERIODICITY_BEGIN__")
hasVerticesPeriodicity = true;
+ }
if (isOK && hasCADSurfOptions) {
isOK = static_cast<bool>(load >> i);
break;
isOK = static_cast<bool>(load >> optValue);
}
- if (isOK) {
+ // read the value of the advanced option
+ // unless this option is no more used
+ if (isOK
+#if MESHGEMS_VERSION_HEX >= 0x020A00
+ && optName != "enforce_cad_edge_sizes" && optName != "max_number_of_points_per_patch"
+#endif
+ ) {
std::string & value = _option2value[optName];
value = optValue;
- int len = value.size();
+ int len = (int) value.size();
// continue reading until "%#" encountered
while (value[len - 1] != '#' || value[len - 2] != '%') {
isOK = static_cast<bool>(load >> optValue);
if (isOK) {
value += " ";
value += optValue;
- len = value.size();
+ len = (int) value.size();
} else {
break;
}
}
if (isOK) {
std::string& value = optValue;
- int len = value.size();
+ int len = (int) value.size();
// continue reading until "%#" encountered
while (value[len - 1] != '#' || value[len - 2] != '%') {
isOK = static_cast<bool>(load >> optValue);
if (isOK) {
value += " ";
value += optValue;
- len = value.size();
+ len = (int) value.size();
} else {
break;
}
if (isOK) {
std::string & value = _preCADoption2value[optName];
value = optValue;
- int len = value.size();
+ int len = (int) value.size();
// continue reading until "%#" encountered
while (value[len - 1] != '#' || value[len - 2] != '%') {
isOK = static_cast<bool>(load >> optValue);
if (isOK) {
value += " ";
value += optValue;
- len = value.size();
+ len = (int) value.size();
} else {
break;
}
if (isOK) {
std::string & value2 = _sizeMap[smEntry];
value2 = smValue;
- int len2 = value2.size();
+ int len2 = (int) value2.size();
// continue reading until "%#" encountered
while (value2[len2 - 1] != '#' || value2[len2 - 2] != '%') {
isOK = static_cast<bool>(load >> smValue);
if (isOK) {
value2 += " ";
value2 += smValue;
- len2 = value2.size();
+ len2 = (int) value2.size();
} else {
break;
}
if (hasSizeMap) {
isOK = static_cast<bool>(load >> option_or_sm);
- if (isOK)
+ if (isOK) {
if (option_or_sm == "__ATTRACTORS_BEGIN__")
hasAttractor = true;
- if (option_or_sm == "__NEW_ATTRACTORS_BEGIN__")
+ else if (option_or_sm == "__NEW_ATTRACTORS_BEGIN__")
hasNewAttractor = true;
else if (option_or_sm == "__ENFORCED_VERTICES_BEGIN__")
hasEnforcedVertex = true;
hasEdgesPeriodicity = true;
else if (option_or_sm == "__VERTICES_PERIODICITY_BEGIN__")
hasVerticesPeriodicity = true;
+ }
}
std::string atEntry, atValue;
if (isOK) {
std::string & value3 = _attractors[atEntry];
value3 = atValue;
- int len3 = value3.size();
+ int len3 = (int) value3.size();
// continue reading until "%#" encountered
while (value3[len3 - 1] != '#' || value3[len3 - 2] != '%') {
isOK = static_cast<bool>(load >> atValue);
if (isOK) {
value3 += " ";
value3 += atValue;
- len3 = value3.size();
+ len3 = (int) value3.size();
} else {
break;
}
}
}
+ // New options in 2.9.6 (issue #17784)
+ if ( static_cast<bool>( load >> _useSurfaceProximity ))
+ {
+ load >> _nbSurfaceProximityLayers;
+ load >> _surfaceProximityRatio;
+ load >> _useVolumeProximity;
+ load >> _nbVolumeProximityLayers;
+ isOK = static_cast<bool>( load >> _volumeProximityRatio );
+ }
+
+ // hyper-patches as entries (issue bos #20543)
+ std::string buffer;
+ if ( SMESHDS_Hypothesis::LoadStringFromStream( load, buffer ))
+ {
+ SMESH_TRY;
+ SMESHUtils::BoostTxtArchive( buffer ) >> _hyperPatchEntriesList;
+ SMESH_CATCH( SMESH::printErrorInDebugMode );
+ }
+
+ // Enforced meshes (issue bos $16292)
+ buffer.clear();
+ if ( SMESHDS_Hypothesis::LoadStringFromStream( load, buffer ))
+ {
+ SMESH_TRY;
+ SMESHUtils::BoostTxtArchive( buffer ) >> _enforcedMeshes;
+ SMESH_CATCH( SMESH::printErrorInDebugMode );
+ }
+
return load;
}
-void BLSURFPlugin_Hypothesis::LoadFacesPeriodicity(std::istream & load){
+namespace boost {
+ namespace serialization {
+ //=======================================================================
+ //function : serialize
+ //purpose : serialize EnforcedMesh
+ //=======================================================================
+
+ template<class Archive>
+ void serialize(Archive & ar, BLSURFPlugin_Hypothesis::EnforcedMesh & enfM,
+ const unsigned int /*version*/)
+ {
+ ar & enfM._meshID;
+ ar & enfM._subID;
+ ar & enfM._type;
+ ar & enfM._groupName;
+ }
+
+ } // namespace serialization
+} // namespace boost
+
+
+void BLSURFPlugin_Hypothesis::LoadFacesPeriodicity(std::istream & load)
+{
bool isOK = true;
std::string periodicitySeparator;
}
-void BLSURFPlugin_Hypothesis::LoadEdgesPeriodicity(std::istream & load){
-
+void BLSURFPlugin_Hypothesis::LoadEdgesPeriodicity(std::istream & load)
+{
bool isOK = true;
std::string periodicitySeparator;
}
}
-void BLSURFPlugin_Hypothesis::LoadPreCADPeriodicity(std::istream & load, const char* shapeType) {
-
+void BLSURFPlugin_Hypothesis::LoadPreCADPeriodicity(std::istream & load, const char* shapeType)
+{
bool isOK = true;
std::string periodicitySeparator;
*/
//================================================================================
-bool BLSURFPlugin_Hypothesis::SetParametersByMesh(const SMESH_Mesh* theMesh, const TopoDS_Shape& theShape) {
+bool BLSURFPlugin_Hypothesis::SetParametersByMesh(const SMESH_Mesh* /*theMesh*/, const TopoDS_Shape& /*theShape*/)
+{
return false;
}
*/
//================================================================================
-double BLSURFPlugin_Hypothesis::GetDefaultPhySize(double diagonal, double bbSegmentation) {
+double BLSURFPlugin_Hypothesis::GetDefaultPhySize(double diagonal, double bbSegmentation)
+{
if (bbSegmentation != 0 && diagonal != 0)
return diagonal / bbSegmentation ;
return 10;
*/
//================================================================================
-double BLSURFPlugin_Hypothesis::GetDefaultMinSize(double diagonal) {
+double BLSURFPlugin_Hypothesis::GetDefaultMinSize(double diagonal)
+{
if (diagonal != 0)
return diagonal / 1000.0 ;
return undefinedDouble();
*/
//================================================================================
-double BLSURFPlugin_Hypothesis::GetDefaultMaxSize(double diagonal) {
+double BLSURFPlugin_Hypothesis::GetDefaultMaxSize(double diagonal)
+{
if (diagonal != 0)
return diagonal / 5.0 ;
return undefinedDouble();
*/
//================================================================================
-double BLSURFPlugin_Hypothesis::GetDefaultChordalError(double diagonal) {
+double BLSURFPlugin_Hypothesis::GetDefaultChordalError(double diagonal)
+{
if (diagonal != 0)
return diagonal;
return undefinedDouble();
*/
//================================================================================
-double BLSURFPlugin_Hypothesis::GetDefaultTinyEdgeLength(double diagonal) {
+double BLSURFPlugin_Hypothesis::GetDefaultTinyEdgeLength(double diagonal)
+{
if (diagonal != 0)
return diagonal * 1e-6 ;
return undefinedDouble();
*/
//================================================================================
-double BLSURFPlugin_Hypothesis::GetDefaultTinyEdgeOptimisationLength(double diagonal) {
+double BLSURFPlugin_Hypothesis::GetDefaultTinyEdgeOptimisationLength(double diagonal)
+{
if (diagonal != 0)
return diagonal * 1e-6 ;
return undefinedDouble();
*/
//=============================================================================
-bool BLSURFPlugin_Hypothesis::SetParametersByDefaults(const TDefaults& dflts, const SMESH_Mesh* theMesh) {
- double diagonal = dflts._elemLength*_gen->GetBoundaryBoxSegmentation();
- _phySize = GetDefaultPhySize(diagonal, _gen->GetBoundaryBoxSegmentation());
- _minSize = GetDefaultMinSize(diagonal);
- _maxSize = GetDefaultMaxSize(diagonal);
+bool BLSURFPlugin_Hypothesis::SetParametersByDefaults(const TDefaults& dflts,
+ const SMESH_Mesh* /*theMesh*/)
+{
+ _phySize = GetDefaultPhySize(dflts._diagonal, _gen->GetBoundaryBoxSegmentation());
+ _minSize = GetDefaultMinSize(dflts._diagonal);
+ _maxSize = GetDefaultMaxSize(dflts._diagonal);
_chordalError = 0.5 * _phySize; //GetDefaultChordalError(diagonal); IMP 0023307
- _tinyEdgeLength = GetDefaultTinyEdgeLength(diagonal);
- _tinyEdgeOptimisationLength = GetDefaultTinyEdgeOptimisationLength(diagonal);
+
+ if ( dflts._way == SMESH_Hypothesis::BY_AVERAGE_LENGTH )
+ {
+ _phySize = dflts._elemLength;
+ _minSize = dflts._elemLength / 100.;
+ _maxSize = dflts._elemLength * 2.;
+ _chordalError = dflts._elemLength / 2.;
+ _elementType = dflts._quadDominated ? QuadrangleDominant : Triangles;
+ _physicalMesh = PhysicalLocalSize; // to activate _enforcedInternalVerticesAllFaces
+ _enforcedInternalVerticesAllFaces = true;
+ }
+ else
+ {
+ _tinyEdgeLength = GetDefaultTinyEdgeLength(dflts._diagonal);
+ _tinyEdgeOptimisationLength = GetDefaultTinyEdgeOptimisationLength(dflts._diagonal);
+ }
return true;
}
//================================================================================
bool BLSURFPlugin_Hypothesis::ToBool(const std::string& str, bool* isOk )
- throw (std::invalid_argument)
{
std::string s = str;
if ( isOk ) *isOk = true;
for ( size_t i = 0; i <= s.size(); ++i )
- s[i] = tolower( s[i] );
+ s[i] = (char) tolower( s[i] );
if ( s == "1" || s == "true" || s == "active" || s == "yes" )
return true;
//================================================================================
double BLSURFPlugin_Hypothesis::ToDbl(const std::string& str, bool* isOk )
- throw (std::invalid_argument)
{
if ( str.empty() ) throw std::invalid_argument("Empty value provided");
+ // Forces "C" locale to be set as LC_NUMERIC
+ Kernel_Utils::Localizer loc;
+
char * endPtr;
double val = strtod(&str[0], &endPtr);
bool ok = (&str[0] != endPtr);
//================================================================================
int BLSURFPlugin_Hypothesis::ToInt(const std::string& str, bool* isOk )
- throw (std::invalid_argument)
{
if ( str.empty() ) throw std::invalid_argument("Empty value provided");