-// Copyright (C) 2007-2016 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
#ifndef _BLSURFPlugin_Hypothesis_HXX_
#define _BLSURFPlugin_Hypothesis_HXX_
-#include "SMESH_Hypothesis.hxx"
+#include "BLSURFPlugin_Attractor.hxx"
+
+#include <SMDS_ElemIterator.hxx>
+#include <SMESH_Hypothesis.hxx>
+#include <smIdType.hxx>
+
#include <vector>
#include <map>
#include <set>
-#include <stdexcept>
#include <string>
-#include <cstring>
-#include <sstream>
-#include <utilities.h>
-#include "BLSURFPlugin_Attractor.hxx"
+
+class SMESH_Mesh;
// Parameters for work of MG-CADSurf
+enum EnforcedMeshType { ENFORCED_MESH, ENFORCED_GROUP, ENFORCED_SUBMESH };
+
class BLSURFPlugin_Hypothesis: public SMESH_Hypothesis
{
public:
- BLSURFPlugin_Hypothesis(int hypId, int studyId, SMESH_Gen * gen);
+ BLSURFPlugin_Hypothesis(int hypId, SMESH_Gen * gen, bool hasgeom);
enum Topology {
FromCAD,
GeometricalLocalSize
};
- static const char* GetHypType() { return "MG-CADSurf Parameters"; }
-
+ enum ElementType {
+ Triangles,
+ QuadrangleDominant,
+ Quadrangles
+ };
+
+ static const char* GetHypType(bool hasgeom)
+ { return hasgeom ? "MG-CADSurf Parameters" : "MG-CADSurf Parameters_NOGEOM"; }
+
TopoDS_Shape entryToShape(std::string entry);
+ static std::string GetMeshGemsVersion();
+
void SetPhysicalMesh(PhysicalMesh thePhysicalMesh);
PhysicalMesh GetPhysicalMesh() const { return _physicalMesh; }
void SetVolumeGradation(double theGradation);
double GetVolumeGradation() const { return _volumeGradation; }
- void SetQuadAllowed(bool theVal);
- bool GetQuadAllowed() const { return _quadAllowed; }
+ void SetElementType(ElementType theElementType);
+ ElementType GetElementType() const { return _elementType; }
void SetAngleMesh(double theAngle);
double GetAngleMesh() const { return _angleMesh; }
void SetTopology(Topology theTopology);
Topology GetTopology() const { return _topology; }
+ bool GetUseSurfaceProximity() const { return _useSurfaceProximity; }
+ void SetUseSurfaceProximity( bool toUse );
+
+ int GetNbSurfaceProximityLayers() const { return _nbSurfaceProximityLayers; }
+ void SetNbSurfaceProximityLayers( int nbLayers );
+
+ double GetSurfaceProximityRatio() const { return _surfaceProximityRatio; }
+ void SetSurfaceProximityRatio( double ratio );
+
+ bool GetUseVolumeProximity() const { return _useVolumeProximity; }
+ void SetUseVolumeProximity( bool toUse );
+
+ int GetNbVolumeProximityLayers() const { return _nbVolumeProximityLayers; }
+ void SetNbVolumeProximityLayers( int nbLayers );
+
+ double GetVolumeProximityRatio() const { return _volumeProximityRatio; }
+ void SetVolumeProximityRatio( double ratio );
+
void SetVerbosity(int theVal);
int GetVerbosity() const { return _verb; }
-
+
void ClearEntry(const std::string& entry, const char * attEntry = 0);
void ClearSizeMaps();
void SetJacobianRectificationRespectGeometry( bool allowRectification );
bool GetJacobianRectificationRespectGeometry();
-
+
+ void SetUseDeprecatedPatchMesher( bool useDeprecatedPatchMesher );
+ bool GetUseDeprecatedPatchMesher();
+
void SetJacobianRectification( bool allowRectification );
bool GetJacobianRectification();
- void SetMaxNumberOfPointsPerPatch( int nb ) throw (std::invalid_argument);
+ void SetMaxNumberOfPointsPerPatch( int nb );
int GetMaxNumberOfPointsPerPatch();
+ void SetMaxNumberOfThreads( int nb );
+ int GetMaxNumberOfThreads();
+
void SetRespectGeometry( bool toRespect );
bool GetRespectGeometry();
void SetDebug( bool isDebug );
bool GetDebug();
- void SetPeriodicTolerance( double tol ) throw (std::invalid_argument);
+ void SetPeriodicTolerance( double tol );
double GetPeriodicTolerance();
- void SetRequiredEntities( const std::string& howToTreat ) throw (std::invalid_argument);
+ void SetRequiredEntities( const std::string& howToTreat );
std::string GetRequiredEntities();
- void SetSewingTolerance( double tol ) throw (std::invalid_argument);
+ void SetSewingTolerance( double tol );
double GetSewingTolerance();
- void SetTags( const std::string& howToTreat ) throw (std::invalid_argument);
+ void SetTags( const std::string& howToTreat );
std::string GetTags();
// Hyper-patches
- typedef std::set< int > THyperPatchTags;
- typedef std::vector< THyperPatchTags > THyperPatchList;
-
- void SetHyperPatches(const THyperPatchList& hpl);
- const THyperPatchList& GetHyperPatches() const { return _hyperPatchList; }
+ typedef std::set< int > THyperPatchTags;
+ typedef std::vector< THyperPatchTags > THyperPatchList;
+ typedef std::set< std::string > THyperPatchEntries;
+ typedef std::vector< THyperPatchEntries > THyperPatchEntriesList;
+
+ void SetHyperPatches(const THyperPatchList& hpl, bool notifyMesh=true);
+ void SetHyperPatches(const THyperPatchEntriesList& hpl);
+ void SetHyperPatchIDsByEntry( const TopoDS_Shape& mainShape,
+ const std::map< std::string, TopoDS_Shape >& entryToShape);
+ const THyperPatchList& GetHyperPatches() const { return _hyperPatchList; }
+ const THyperPatchEntriesList& GetHyperPatchEntries() const { return _hyperPatchEntriesList; }
static int GetHyperPatchTag( int faceTag, const BLSURFPlugin_Hypothesis* hyp, int* iPatch=0 );
+ // Enforced mesh
+ struct EnforcedMesh
+ {
+ int _meshID; // persistent mesh ID
+ int _subID; // either persistent group ID or sub-shape ID for sub-mesh
+ EnforcedMeshType _type; /* specify what _subID means:
+ - nothing for ENFORCED_MESH
+ - group ID for ENFORCED_GROUP
+ - sub-shape ID for ENFORCED_SUBMESH */
+ std::string _groupName; // name of a group to add mesh edges to
+
+ bool operator==(const EnforcedMesh& em ) const
+ {
+ return ( _meshID == em._meshID && _subID == em._subID &&
+ _type == em._type && _groupName == em._groupName );
+ }
+ };
+
+ void SetEnforcedMeshes( std::vector< EnforcedMesh > & enforcedMeshes );
+ const std::vector< EnforcedMesh > & GetEnforcedMeshes() const { return _enforcedMeshes; }
+ SMDS_ElemIteratorPtr GetEnforcedSegments( const EnforcedMesh& enfMesh,
+ SMESH_Mesh* & mesh ) const;
+
+
void SetPreCADMergeEdges(bool theVal);
bool GetPreCADMergeEdges() const { return _preCADMergeEdges; }
- void SetPreCADRemoveTinyUVEdges(bool theVal);
- bool GetPreCADRemoveTinyUVEdges() const { return _preCADRemoveTinyUVEdges; }
-
void SetPreCADRemoveDuplicateCADFaces(bool theVal);
bool GetPreCADRemoveDuplicateCADFaces() const { return _preCADRemoveDuplicateCADFaces; }
*/
typedef std::multimap< std::string, BLSURFPlugin_Attractor* > TAttractorMap;
- typedef std::map< std::string, std::vector<double> > TParamsMap; //TODO à finir
+ typedef std::map< std::string, std::vector<double> > TParamsMap; //TODO ?? finir
void SetClassAttractorEntry(const std::string& entry, const std::string& att_entry, double StartSize, double EndSize, double ActionRadius, double ConstantRadius);
std::string GetClassAttractorEntry(const std::string& entry);
// Map Vertex entry / Enforced vertex
typedef std::map< TEntry, TEnfVertex* > TEnfVertexEntryEnfVertexMap;
- typedef std::map< TEnfGroupName, std::set<int> > TGroupNameNodeIDMap;
+ typedef std::map< TEnfGroupName, std::set<smIdType> > TGroupNameNodeIDMap;
/* TODO GROUPS
// Map Group Name / List of enforced vertices
typedef std::map< TEnfGroupName , TEnfVertexList > TGroupNameEnfVertexListMap;
bool SetEnforcedVertex(TEntry theFaceEntry, TEnfName theVertexName, TEntry theVertexEntry, TEnfGroupName theGroupName,
double x = 0.0, double y = 0.0, double z = 0.0);
- TEnfVertexList GetEnfVertexList(const TEntry& theFaceEntry) throw (std::invalid_argument);
- TEnfVertexCoordsList GetEnfVertexCoordsList(const TEntry& theFaceEntry) throw (std::invalid_argument);
- TEntryList GetEnfVertexEntryList (const TEntry& theFaceEntry) throw (std::invalid_argument);
- TEnfVertex* GetEnfVertex(TEnfVertexCoords coords) throw (std::invalid_argument);
- TEnfVertex* GetEnfVertex(const TEntry& theEnfVertexEntry) throw (std::invalid_argument);
- void AddEnfVertexNodeID(TEnfGroupName theGroupName,int theNodeID);
- std::set<int> GetEnfVertexNodeIDs(TEnfGroupName theGroupName) throw (std::invalid_argument);
- void RemoveEnfVertexNodeID(TEnfGroupName theGroupName,int theNodeID) throw (std::invalid_argument);
+ TEnfVertexList GetEnfVertexList(const TEntry& theFaceEntry);
+ TEnfVertexCoordsList GetEnfVertexCoordsList(const TEntry& theFaceEntry);
+ TEntryList GetEnfVertexEntryList (const TEntry& theFaceEntry);
+ TEnfVertex* GetEnfVertex(TEnfVertexCoords coords);
+ TEnfVertex* GetEnfVertex(const TEntry& theEnfVertexEntry);
+ void AddEnfVertexNodeID(TEnfGroupName theGroupName,smIdType theNodeID);
+ std::set<smIdType> GetEnfVertexNodeIDs(TEnfGroupName theGroupName);
+ void RemoveEnfVertexNodeID(TEnfGroupName theGroupName,smIdType theNodeID);
- bool ClearEnforcedVertex(const TEntry& theFaceEntry, double x = 0.0, double y = 0.0, double z = 0.0, const TEntry& theVertexEntry="") throw (std::invalid_argument);
- bool ClearEnforcedVertices(const TEntry& theFaceEntry) throw (std::invalid_argument);
+ bool ClearEnforcedVertex(const TEntry& theFaceEntry, double x = 0.0, double y = 0.0, double z = 0.0, const TEntry& theVertexEntry="");
+ bool ClearEnforcedVertices(const TEntry& theFaceEntry);
void ClearAllEnforcedVertices();
+ void AddEnforcedVertex( const TEntry& theFaceEntry, TEnfVertex * theEnfVertex );
- const TFaceEntryEnfVertexListMap _GetAllEnforcedVerticesByFace() const { return _faceEntryEnfVertexListMap; }
- const TEnfVertexList _GetAllEnforcedVertices() const { return _enfVertexList; }
+ const TFaceEntryEnfVertexListMap& _GetAllEnforcedVerticesByFace() const { return _faceEntryEnfVertexListMap; }
+ const TEnfVertexList& _GetAllEnforcedVertices() const { return _enfVertexList; }
- const TFaceEntryCoordsListMap _GetAllCoordsByFace() const { return _faceEntryCoordsListMap; }
- const TCoordsEnfVertexMap _GetAllEnforcedVerticesByCoords() const { return _coordsEnfVertexMap; }
+ const TFaceEntryCoordsListMap& _GetAllCoordsByFace() const { return _faceEntryCoordsListMap; }
+ const TCoordsEnfVertexMap& _GetAllEnforcedVerticesByCoords() const { return _coordsEnfVertexMap; }
- const TFaceEntryEnfVertexEntryListMap _GetAllEnfVertexEntriesByFace() const { return _faceEntryEnfVertexEntryListMap; }
- const TEnfVertexEntryEnfVertexMap _GetAllEnforcedVerticesByEnfVertexEntry() const { return _enfVertexEntryEnfVertexMap; }
+ const TFaceEntryEnfVertexEntryListMap& _GetAllEnfVertexEntriesByFace() const { return _faceEntryEnfVertexEntryListMap; }
+ const TEnfVertexEntryEnfVertexMap& _GetAllEnforcedVerticesByEnfVertexEntry() const { return _enfVertexEntryEnfVertexMap; }
// TODO GROUPS
// const TEnfVertexGroupNameMap _GetEnforcedVertexGroupNameMap() const { return _enfVertexGroupNameMap; }
* \brief Internal enforced vertices
*/
void SetInternalEnforcedVertexAllFaces(bool toEnforceInternalVertices);
- const bool _GetInternalEnforcedVertexAllFaces() const { return _enforcedInternalVerticesAllFaces; }
+ bool _GetInternalEnforcedVertexAllFaces() const { return _enforcedInternalVerticesAllFaces; }
static bool GetInternalEnforcedVertexAllFaces( const BLSURFPlugin_Hypothesis* hyp );
void SetInternalEnforcedVertexAllFacesGroup(TEnfGroupName theGroupName);
const TEnfGroupName _GetInternalEnforcedVertexAllFacesGroup() const { return _enforcedInternalVerticesAllFacesGroup; }
static double GetDefaultGradation() { return 1.3; }
static bool GetDefaultUseVolumeGradation() { return false; }
static double GetDefaultVolumeGradation() { return 2; }
- static bool GetDefaultQuadAllowed() { return false; }
+ static ElementType GetDefaultElementType() { return Triangles; }
static double GetDefaultAngleMesh() { return 8.0; }
-
+ static bool GetDefaultUseSurfaceProximity() { return false; }
+ static int GetDefaultNbSurfaceProximityLayers() { return 1; }
+ static double GetDefaultSurfaceProximityRatio() { return 1.; }
+ static bool GetDefaultUseVolumeProximity() { return false; }
+ static int GetDefaultNbVolumeProximityLayers() { return 1; }
+ static double GetDefaultVolumeProximityRatio() { return 1.; }
+
static double GetDefaultChordalError(double diagonal);
static double GetDefaultChordalError() { return undefinedDouble(); }
static bool GetDefaultAnisotropic() { return false; }
static bool GetDefaultCorrectSurfaceIntersection() { return true; }
static double GetDefaultCorrectSurfaceIntersectionMaxCost() { return 15.; }
static bool GetDefaultBadElementRemoval() { return false; }
- static double GetDefaultBadElementAspectRatio() {return 1000.0; }
+ static double GetDefaultBadElementAspectRatio() {return 1000.0; }
static bool GetDefaultOptimizeMesh() { return true; }
static bool GetDefaultQuadraticMesh() { return false; }
-
+
static int GetDefaultVerbosity() { return 3; }
static Topology GetDefaultTopology() { return FromCAD; }
// PreCAD
static bool GetDefaultPreCADMergeEdges() { return false; }
- static bool GetDefaultPreCADRemoveTinyUVEdges() { return false; }
static bool GetDefaultPreCADRemoveDuplicateCADFaces() { return false; }
static bool GetDefaultPreCADProcess3DTopology() { return false; }
static bool GetDefaultPreCADDiscardInput() { return false; }
-
+
static TSizeMap GetDefaultSizeMap() { return TSizeMap();}
static TAttractorMap GetDefaultAttractorMap() { return TAttractorMap(); }
// const TPreCadPeriodicityEntriesVector _GetPreCadFacesPeriodicityEntries() const { return _preCadFacesPeriodicityEntriesVector; }
static TPreCadPeriodicityVector GetDefaultPreCadFacesPeriodicityVector() { return TPreCadPeriodicityVector(); }
- const TPreCadPeriodicityVector _GetPreCadFacesPeriodicityVector() const { return _preCadFacesPeriodicityVector; }
+ const TPreCadPeriodicityVector& _GetPreCadFacesPeriodicityVector() const { return _preCadFacesPeriodicityVector; }
static TPreCadPeriodicityVector GetPreCadFacesPeriodicityVector(const BLSURFPlugin_Hypothesis* hyp);
static TPreCadPeriodicityVector GetDefaultPreCadEdgesPeriodicityVector() { return TPreCadPeriodicityVector(); }
- const TPreCadPeriodicityVector _GetPreCadEdgesPeriodicityVector() const { return _preCadEdgesPeriodicityVector; }
+ const TPreCadPeriodicityVector& _GetPreCadEdgesPeriodicityVector() const { return _preCadEdgesPeriodicityVector; }
static TPreCadPeriodicityVector GetPreCadEdgesPeriodicityVector(const BLSURFPlugin_Hypothesis* hyp);
static TFacesPeriodicityVector GetDefaultFacesPeriodicityVector() { return TFacesPeriodicityVector(); }
- const TFacesPeriodicityVector _GetFacesPeriodicityVector() const { return _facesPeriodicityVector; }
+ const TFacesPeriodicityVector& _GetFacesPeriodicityVector() const { return _facesPeriodicityVector; }
static TFacesPeriodicityVector GetFacesPeriodicityVector(const BLSURFPlugin_Hypothesis* hyp);
static TEdgesPeriodicityVector GetDefaultEdgesPeriodicityVector() { return TEdgesPeriodicityVector(); }
- const TEdgesPeriodicityVector _GetEdgesPeriodicityVector() const { return _edgesPeriodicityVector; }
+ const TEdgesPeriodicityVector& _GetEdgesPeriodicityVector() const { return _edgesPeriodicityVector; }
static TEdgesPeriodicityVector GetEdgesPeriodicityVector(const BLSURFPlugin_Hypothesis* hyp);
static TVerticesPeriodicityVector GetDefaultVerticesPeriodicityVector() { return TVerticesPeriodicityVector(); }
- const TVerticesPeriodicityVector _GetVerticesPeriodicityVector() const { return _verticesPeriodicityVector; }
+ const TVerticesPeriodicityVector& _GetVerticesPeriodicityVector() const { return _verticesPeriodicityVector; }
static TVerticesPeriodicityVector GetVerticesPeriodicityVector(const BLSURFPlugin_Hypothesis* hyp);
void ClearPreCadPeriodicityVectors();
typedef std::set< std::string > TOptionNames;
void SetOptionValue(const std::string& optionName,
- const std::string& optionValue) throw (std::invalid_argument);
+ const std::string& optionValue);
void SetPreCADOptionValue(const std::string& optionName,
- const std::string& optionValue) throw (std::invalid_argument);
- std::string GetOptionValue(const std::string& optionName, bool* isDefault=0) const throw (std::invalid_argument);
- std::string GetPreCADOptionValue(const std::string& optionName, bool* isDefault=0) const throw (std::invalid_argument);
+ const std::string& optionValue);
+ std::string GetOptionValue(const std::string& optionName, bool* isDefault=0) const;
+ std::string GetPreCADOptionValue(const std::string& optionName, bool* isDefault=0) const;
void ClearOption(const std::string& optionName);
void ClearPreCADOption(const std::string& optionName);
TOptionValues GetOptionValues() const;
std::string GetOption(const std::string& optionName) const;
std::string GetPreCADOption(const std::string& optionName) const;
- static bool ToBool(const std::string& str, bool* isOk=0) throw (std::invalid_argument);
- static double ToDbl(const std::string& str, bool* isOk=0) throw (std::invalid_argument);
- static int ToInt(const std::string& str, bool* isOk=0) throw (std::invalid_argument);
+ static bool ToBool(const std::string& str, bool* isOk=0);
+ static double ToDbl(const std::string& str, bool* isOk=0);
+ static int ToInt(const std::string& str, bool* isOk=0);
/*!
* Sets the file for export resulting mesh in GMF format
double _gradation;
bool _useVolumeGradation;
double _volumeGradation;
- bool _quadAllowed;
+ ElementType _elementType;
double _angleMesh;
double _chordalError;
bool _anisotropic;
bool _quadraticMesh;
int _verb;
Topology _topology;
-
+ bool _useSurfaceProximity;
+ int _nbSurfaceProximityLayers;
+ double _surfaceProximityRatio;
+ bool _useVolumeProximity;
+ int _nbVolumeProximityLayers;
+ double _volumeProximityRatio;
+
bool _preCADMergeEdges;
- bool _preCADRemoveTinyUVEdges;
bool _preCADRemoveDuplicateCADFaces;
bool _preCADProcess3DTopology;
bool _preCADDiscardInput;
double _preCADEpsNano;
-
+
TOptionValues _option2value, _preCADoption2value, _customOption2value; // user defined values
TOptionValues _defaultOptionValues; // default values
TOptionNames _doubleOptions, _charOptions, _boolOptions; // to find a type of option
TSizeMap _sizeMap;
TSizeMap _attractors;
TAttractorMap _classAttractors;
- TSizeMap _attEntry;
- TParamsMap _attParams;
- TFaceEntryEnfVertexListMap _faceEntryEnfVertexListMap;
- TEnfVertexList _enfVertexList;
+ TFaceEntryEnfVertexListMap _faceEntryEnfVertexListMap;
+ TEnfVertexList _enfVertexList;
// maps to get "manual" enf vertex (through their coordinates)
- TFaceEntryCoordsListMap _faceEntryCoordsListMap;
- TCoordsEnfVertexMap _coordsEnfVertexMap;
+ TFaceEntryCoordsListMap _faceEntryCoordsListMap;
+ TCoordsEnfVertexMap _coordsEnfVertexMap;
// maps to get "geom" enf vertex (through their geom entries)
- TFaceEntryEnfVertexEntryListMap _faceEntryEnfVertexEntryListMap;
- TEnfVertexEntryEnfVertexMap _enfVertexEntryEnfVertexMap;
- TGroupNameNodeIDMap _groupNameNodeIDMap;
+ TFaceEntryEnfVertexEntryListMap _faceEntryEnfVertexEntryListMap;
+ TEnfVertexEntryEnfVertexMap _enfVertexEntryEnfVertexMap;
+ TGroupNameNodeIDMap _groupNameNodeIDMap;
// Enable internal enforced vertices on specific face if requested by user
// TFaceEntryInternalVerticesList _faceEntryInternalVerticesList;
- bool _enforcedInternalVerticesAllFaces;
- TEnfGroupName _enforcedInternalVerticesAllFacesGroup;
+ bool _enforcedInternalVerticesAllFaces;
+ TEnfGroupName _enforcedInternalVerticesAllFacesGroup;
- TPreCadPeriodicityVector _preCadFacesPeriodicityVector;
- TPreCadPeriodicityVector _preCadEdgesPeriodicityVector;
+ TPreCadPeriodicityVector _preCadFacesPeriodicityVector;
+ TPreCadPeriodicityVector _preCadEdgesPeriodicityVector;
+
+ TFacesPeriodicityVector _facesPeriodicityVector;
+ TEdgesPeriodicityVector _edgesPeriodicityVector;
+ TVerticesPeriodicityVector _verticesPeriodicityVector;
- TFacesPeriodicityVector _facesPeriodicityVector;
- TEdgesPeriodicityVector _edgesPeriodicityVector;
- TVerticesPeriodicityVector _verticesPeriodicityVector;
+ THyperPatchList _hyperPatchList;
+ THyperPatchEntriesList _hyperPatchEntriesList;
- THyperPatchList _hyperPatchList;
+ std::vector< EnforcedMesh > _enforcedMeshes; // enforced 1D meshes
// Called by SaveTo to store content of _preCadFacesPeriodicityVector and _preCadEdgesPeriodicityVector
void SavePreCADPeriodicity(std::ostream & save, const char* shapeType);