]> SALOME platform Git repositories - plugins/gmshplugin.git/blob - src/GMSHPlugin/GMSHPluginBuilder.py
Salome HOME
49802b6757b769ee9a04be00afdf6b004b9934fe
[plugins/gmshplugin.git] / src / GMSHPlugin / GMSHPluginBuilder.py
1 # Copyright (C) 2012-2015  ALNEOS
2 # Copyright (C) 2016-2024  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 ##
23 # @package GMSHPluginBuilder
24 # Python API for the GMSH meshing plug-in module.
25
26 from salome.smesh.smesh_algorithm import Mesh_Algorithm
27
28 # import GMSHPlugin module if possible
29 noGMSHPlugin = 0
30 try:
31     import GMSHPlugin
32 except ImportError:
33     noGMSHPlugin = 1
34     pass
35
36 # Types of algorithms
37 GMSH = "GMSH"
38 GMSH_3D       = "GMSH_3D"
39 GMSH_2D       = "GMSH_2D"
40 GMSH_3D_Remote = "GMSH_3D_Remote"
41
42 ## Base of all GMSH algorithms.
43 #
44 class GMSH_Algorithm(Mesh_Algorithm):
45     
46     meshMethod = "Tetrahedron"
47     algoType   = GMSH
48     
49     def __init__(self, mesh, geom=0):
50         Mesh_Algorithm.__init__(self)
51         if noGMSHPlugin: print("Warning: GMSHPlugin module unavailable")
52         self.Create(mesh, geom, self.algoType, "libGMSHEngine.so")
53         self.params = None
54
55     ## Defines hypothesis having several parameters
56     #
57     def Parameters(self):
58         if self.algoType == GMSH_2D:
59             hypType = "GMSH_Parameters_2D"
60         elif self.algoType == GMSH:
61             hypType = "GMSH_Parameters"
62         elif self.algoType == GMSH_3D:
63             hypType = "GMSH_Parameters_3D"
64         elif self.algoType == GMSH_3D_Remote:
65             hypType = "GMSH_Parameters_3D"
66
67         if self.params and self.params.GetName() != hypType:
68             self.mesh.RemoveHypothesis( self.params, self.geom )
69             self.params = None
70         if not self.params:
71             self.params = self.Hypothesis(hypType, [],"libGMSHEngine.so",UseExisting=0)
72         return self.params
73
74 class GMSH_2D_Algorithm(GMSH_Algorithm):
75     
76     meshMethod = "Triangle"
77     algoType   = GMSH_2D
78     
79     ## Private constructor.
80     def __init__(self, mesh, geom=0):
81         GMSH_Algorithm.__init__(self, mesh, geom)
82
83 class GMSH_3D_Algorithm(GMSH_Algorithm):
84     
85     meshMethod = "Tetrahedron"
86     algoType   = GMSH_3D
87
88     ## Private constructor.
89     def __init__(self, mesh, geom=0):
90         GMSH_Algorithm.__init__(self, mesh, geom)
91
92
93 class GMSH_3D_Remote_Algorithm(GMSH_Algorithm):
94     meshMethod = "Tetrahedron"
95     algoType   = GMSH_3D_Remote
96
97     ## Private constructor.
98     def __init__(self, mesh, geom=0):
99         GMSH_Algorithm.__init__(self, mesh, geom)