1 // Copyright (C) 2012-2015 ALNEOS
2 // Copyright (C) 2016-2024 EDF
4 // This library is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU Lesser General Public
6 // License as published by the Free Software Foundation; either
7 // version 2.1 of the License, or (at your option) any later version.
9 // This library is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 // Lesser General Public License for more details.
14 // You should have received a copy of the GNU Lesser General Public
15 // License along with this library; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 // See http://www.alneos.com/ or email : contact@alneos.fr
19 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 #ifndef _GMSHPlugin_Mesher_HXX_
23 #define _GMSHPlugin_Mesher_HXX_
26 #include "GmshVersion.h"
27 #if GMSH_MAJOR_VERSION >=4
32 #include "GmshConfig.h"
33 #include "GModelIO_OCC.h"
34 #include "GModelIO_GEO.h"
36 #if GMSH_MAJOR_VERSION >=4
40 #include "GEdgeCompound.h"
41 #include "GFaceCompound.h"
45 #include <SMDS_MeshElement.hxx>
46 #include "GMSHPlugin_Defs.hxx"
47 #include "SMESH_Algo.hxx"
56 //class TopTools_DataMapOfShapeShape;
57 //class TopTools_IndexedMapOfShape;
58 class GMSHPlugin_Hypothesis;
61 //=============================================================================
63 * \brief This class calls the GMSH mesher of OCC geometry
65 //=============================================================================
67 class GMSHPLUGIN_EXPORT GMSHPlugin_Mesher
70 // ---------- PUBLIC METHODS ----------
72 GMSHPlugin_Mesher (SMESH_Mesh* mesh, const TopoDS_Shape& aShape, bool is2D, bool is3D);
74 void SetParameters(const GMSHPlugin_Hypothesis* hyp);
76 bool Compute3D( std::vector< const SMDS_MeshNode* >& nodeVec,
77 std::map<const SMDS_MeshElement*, bool, TIDCompare>& listElements,
81 bool Evaluate(MapShapeNbElems& aResMap);
83 static float DistBoundingBox(const SBoundingBox3d& bounds, const SPoint3& point);
86 void FillGeomMapMeshUsing2DMeshIterator( std::map<const SMDS_MeshElement*, bool, TIDCompare>& listElements );
87 GModel* GetGModel(){ return _gModel;};
88 void finalizeGModel();
89 const SMDS_MeshNode* Node( const MVertex* v );
90 const SMDS_MeshNode* PremeshedNode( const MVertex* v );
94 const TopoDS_Shape& _shape;
104 double _minSize, _maxSize;
105 bool _secondOrder, _useIncomplElem;
110 #if GMSH_MAJOR_VERSION >=4 && GMSH_MINOR_VERSION >=3
113 #if GMSH_MAJOR_VERSION >=4 && GMSH_MINOR_VERSION >=10
114 double _meshCurvatureSize;
117 std::set<std::string> _compounds;
119 std::map< const MVertex *, const SMDS_MeshNode* > _nodeMap;
120 std::map< const MVertex *, const SMDS_MeshNode* > _premeshednodeMap; // used for the SA version
121 SMESHDS_SubMesh* HasSubMesh( const TopoDS_Shape& s );
123 void SetGmshOptions();
124 void CreateGmshCompounds();
126 void HideComputedEntities( GModel* gModel, bool hideAnyway = false );
127 void RestoreVisibility( GModel* gModel );
128 void Set1DSubMeshes( GModel* );
129 void Set2DSubMeshes( GModel* );
130 void toPython( GModel* );
131 bool IsAllNodesInSameFace( const SMDS_MeshElement* triangle, const TopoDS_Face& F, std::vector<gp_XY>& uvValues );
132 std::map<int,std::vector<std::tuple<smIdType,bool,std::vector<gp_XY>>>> AssociateElementsToFaces( std::map<const SMDS_MeshElement*, bool, TIDCompare>& listElements );
133 void Set2DMeshes( std::vector< const SMDS_MeshNode* >& nodeVec, std::map<const SMDS_MeshElement*, bool, TIDCompare>& listElements );
135 #if GMSH_MAJOR_VERSION >=4 && GMSH_MINOR_VERSION >=3
136 void SetMaxThreadsGmsh();
137 void SetCompoundMeshVisibility();
139 class mymsg : public GmshMessage
144 mymsg(GModel* _gModel) : GmshMessage(), _gModel(_gModel) {}
145 void operator()(std::string level, std::string msg);