]> SALOME platform Git repositories - plugins/gmshplugin.git/blob - src/GMSHPlugin/GMSHPlugin_Mesher.hxx
Salome HOME
updated copyright message
[plugins/gmshplugin.git] / src / GMSHPlugin / GMSHPlugin_Mesher.hxx
1 // Copyright (C) 2012-2015  ALNEOS
2 // Copyright (C) 2016-2023  EDF
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, bool is3D);
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   void FillGMSHMesh();
82
83  private:
84   SMESH_Mesh*          _mesh;
85   const TopoDS_Shape&  _shape;
86   int                  _algo2d;
87   int                  _algo3d;
88   int                  _recomb2DAlgo;
89   bool                 _recombineAll;
90   int                  _subdivAlgo;
91   int                  _remeshAlgo;
92   int                  _remeshPara;
93   double               _smouthSteps;
94   double               _sizeFactor;
95   double               _minSize, _maxSize;
96   bool                 _secondOrder, _useIncomplElem;
97   bool                 _is2d;
98   bool                 _is3d;
99   GModel*              _gModel;
100 #if GMSH_MAJOR_VERSION >=4 && GMSH_MINOR_VERSION >=3
101   double               _maxThreads;
102 #endif
103 #if GMSH_MAJOR_VERSION >=4 && GMSH_MINOR_VERSION >=10
104   double               _meshCurvatureSize;
105 #endif
106
107   std::set<std::string> _compounds;
108
109   std::map< const MVertex *, const SMDS_MeshNode* > _nodeMap;
110
111   const SMDS_MeshNode* Node( const MVertex* v );
112   SMESHDS_SubMesh* HasSubMesh( const TopoDS_Shape& s );
113
114   void SetGmshOptions();
115   void CreateGmshCompounds();
116   void FillSMesh();
117   void HideComputedEntities( GModel* gModel );
118   void RestoreVisibility( GModel* gModel );
119   void Set1DSubMeshes( GModel* );
120   void Set2DSubMeshes( GModel* );
121   void toPython( GModel* );
122 #if GMSH_MAJOR_VERSION >=4 && GMSH_MINOR_VERSION >=3
123   void SetMaxThreadsGmsh();
124   void SetCompoundMeshVisibility();
125 #endif
126   class mymsg : public GmshMessage
127   {
128   private:
129     GModel* _gModel;
130   public:
131     mymsg(GModel* _gModel) :  GmshMessage(), _gModel(_gModel) {}
132     void operator()(std::string level, std::string msg);
133   };
134 };
135
136 #endif