Salome HOME
Merge from BR_plugins_pbyacs 03/04/2013
[plugins/hexoticplugin.git] / src / HexoticPlugin / HexoticPLUGINBuilder.py
1 # Copyright (C) 2007-2013  CEA/DEN, EDF R&D
2 #
3 # This library is free software; you can redistribute it and/or
4 # modify it under the terms of the GNU Lesser General Public
5 # License as published by the Free Software Foundation; either
6 # version 2.1 of the License.
7 #
8 # This library is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 # Lesser General Public License for more details.
12 #
13 # You should have received a copy of the GNU Lesser General Public
14 # License along with this library; if not, write to the Free Software
15 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 #
17 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 #
19
20 ##
21 # @package HexoticPLUGINBuilder
22 # Python API for the Hexotic meshing plug-in module.
23
24 from salome.smesh.smesh_algorithm import Mesh_Algorithm
25 from salome.smesh.smeshBuilder import AssureGeomPublished
26
27 # import HexoticPlugin module if possible
28 noHexoticPlugin = 0
29 try:
30     import HexoticPlugin
31 except ImportError:
32     noHexoticPlugin = 1
33     pass
34
35 #----------------------------
36 # Mesh algo type identifiers
37 #----------------------------
38
39 ## Algorithm type: Hexotic hexahedron 3D algorithm, see Hexotic_Algorithm
40 Hexotic = "Hexotic_3D"
41
42 #----------------------------
43 # Algorithms
44 #----------------------------
45
46 ## Defines a hexahedron 3D algorithm
47 #
48 #  It is created by calling smesh.Mesh.Hexahedron( smesh.Hexotic, geom=0 )
49 class Hexotic_Algorithm(Mesh_Algorithm):
50
51     ## name of the dynamic method in smesh.Mesh class
52     #  @internal
53     meshMethod = "Hexahedron"
54     ## type of algorithm used with helper function in smesh.Mesh class
55     #  @internal
56     algoType   = Hexotic
57     ## doc string of the method in smesh.Mesh class
58     #  @internal
59     docHelper  = "Creates hexahedron 3D algorithm for volumes"
60
61     ## Private constructor.
62     #  @param mesh parent mesh object algorithm is assigned to
63     #  @param geom geometry (shape/sub-shape) algorithm is assigned to;
64     #              if it is @c 0 (default), the algorithm is assigned to the main shape
65     def __init__(self, mesh, geom=0):
66         Mesh_Algorithm.__init__(self)
67         if noHexoticPlugin: print "Warning: HexoticPlugin module unavailable"
68         self.Create(mesh, geom, Hexotic, "libHexoticEngine.so")
69         self.params = None
70         pass
71
72     ## Defines "SetMinMaxHexes" hypothesis to give two hexotic parameters
73     #  @param min minimal level of recursive partitioning on the initial octree cube
74     #  @param max maximal level of recursive partitioning on the initial octree cube
75     #  @return hypothesis object
76     def SetMinMaxHexes(self, min=3, max=8):
77         self.Parameters().SetHexesMinLevel(min)
78         self.Parameters().SetHexesMaxLevel(max)
79         return self.Parameters()
80
81     ## Defines "SetMinMaxSize" hypothesis to give two hexotic parameters
82     #  @param min minimal element's size
83     #  @param max maximal element's size
84     #  @return hypothesis object
85     def SetMinMaxSize(self, min, max):
86         self.Parameters().SetMinSize(min)
87         self.Parameters().SetMaxSize(max)
88         return self.Parameters()
89
90     ## (OBSOLETE) Defines "MinMaxQuad" hypothesis to give three hexotic parameters
91     #  @param min minimal level of recursive partitioning on the initial octree cube
92     #  @param max maximal level of recursive partitioning on the initial octree cube
93     #  @param quad not documented
94     #  @return hypothesis object
95     def MinMaxQuad(self, min=3, max=8, quad=True):
96         print "WARNING: Function MinMaxQuad is deprecated, use SetMinMaxHexes instead"
97         return self.SetMinMaxHexes(min, max)
98
99     ## Defines hypothesis having several parameters
100     #  @return hypothesis object
101     def Parameters(self):
102         if not self.params:
103             self.params = self.Hypothesis("Hexotic_Parameters", [],
104                                           "libHexoticEngine.so", UseExisting=0)
105             pass
106         return self.params
107
108
109     pass # end of Hexotic_Algorithm class