]> SALOME platform Git repositories - plugins/gmshplugin.git/blob - src/GMSHPlugin/GMSHPlugin_Mesher.hxx
Salome HOME
Merge branch 'mab/gmsh_4.10_squashed'
[plugins/gmshplugin.git] / src / GMSHPlugin / GMSHPlugin_Mesher.hxx
1 // Copyright (C) 2012-2015  ALNEOS
2 // Copyright (C) 2016-2022  EDF R&D
3 //
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.
8 //
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.
13 //
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
17 //
18 // See http://www.alneos.com/ or email : contact@alneos.fr
19 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 //
21
22 #ifndef _GMSHPlugin_Mesher_HXX_
23 #define _GMSHPlugin_Mesher_HXX_
24
25 #include <stdio.h>
26 #include "GmshVersion.h"
27 #if GMSH_MAJOR_VERSION >=4
28 #include "gmsh.h"
29 #else
30 #include "Gmsh.h"
31 #endif
32 #include "GmshConfig.h"
33 #include "GModelIO_OCC.h"
34 #include "GModelIO_GEO.h"
35 #include "Geo.h"
36 #if GMSH_MAJOR_VERSION >=4
37 #include "GEdge.h"
38 #include "GFace.h"
39 #else
40 #include "GEdgeCompound.h"
41 #include "GFaceCompound.h"
42 #endif
43 #include "MElement.h"
44
45 #include "GMSHPlugin_Defs.hxx"
46 #include "SMESH_Algo.hxx"
47
48 #include <map>
49 #include <set>
50
51 class SMESH_Mesh;
52 class SMESH_Comment;
53 class SMESHDS_Mesh;
54 class TopoDS_Shape;
55 //class TopTools_DataMapOfShapeShape;
56 //class TopTools_IndexedMapOfShape;
57 class GMSHPlugin_Hypothesis;
58
59
60 //=============================================================================
61 /*!
62  * \brief This class calls the GMSH mesher of OCC geometry
63  */
64 //=============================================================================
65
66 class GMSHPLUGIN_EXPORT GMSHPlugin_Mesher
67 {
68  public:
69   // ---------- PUBLIC METHODS ----------
70
71   GMSHPlugin_Mesher (SMESH_Mesh* mesh, const TopoDS_Shape& aShape, bool is2D);
72
73   void SetParameters(const GMSHPlugin_Hypothesis*          hyp);
74
75   bool Compute();
76
77   bool Evaluate(MapShapeNbElems& aResMap);
78
79   static float DistBoundingBox(const SBoundingBox3d& bounds, const SPoint3& point);
80
81  private:
82   SMESH_Mesh*          _mesh;
83   const TopoDS_Shape&  _shape;
84   int                  _algo2d;
85   int                  _algo3d;
86   int                  _recomb2DAlgo;
87   bool                 _recombineAll;
88   int                  _subdivAlgo;
89   int                  _remeshAlgo;
90   int                  _remeshPara;
91   double               _smouthSteps;
92   double               _sizeFactor;
93   double               _minSize, _maxSize;
94   bool                 _secondOrder, _useIncomplElem;
95   bool                 _is2d;
96   GModel*              _gModel;
97 #if GMSH_MAJOR_VERSION >=4 && GMSH_MINOR_VERSION >=3
98   double               _maxThreads;
99 #endif
100 #if GMSH_MAJOR_VERSION >=4 && GMSH_MINOR_VERSION >=10
101   double               _meshCurvatureSize;
102 #endif
103
104   std::set<std::string> _compounds;
105
106   std::map< const MVertex *, const SMDS_MeshNode* > _nodeMap;
107
108   const SMDS_MeshNode* Node( const MVertex* v );
109   SMESHDS_SubMesh* HasSubMesh( const TopoDS_Shape& s );
110
111   void SetGmshOptions();
112   void CreateGmshCompounds();
113   void FillSMesh();
114   void HideComputedEntities( GModel* gModel );
115   void RestoreVisibility( GModel* gModel );
116   void Set1DSubMeshes( GModel* );
117   void Set2DSubMeshes( GModel* );
118   void toPython( GModel* );
119 #if GMSH_MAJOR_VERSION >=4 && GMSH_MINOR_VERSION >=3
120   void SetMaxThreadsGmsh();
121   void SetCompoundMeshVisibility();
122 #endif
123   class mymsg : public GmshMessage
124   {
125   private:
126     GModel* _gModel;
127   public:
128     mymsg(GModel* _gModel) :  GmshMessage(), _gModel(_gModel) {}
129     void operator()(std::string level, std::string msg);
130   };
131 };
132
133 #endif