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