Salome HOME
39e7c39cb181a7d3928906b53de49d6a5dbb8bf6
[plugins/hexoticplugin.git] / src / HexoticPlugin / HexoticPLUGINBuilder.py
1 # Copyright (C) 2007-2014  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, or (at your option) any later version.
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 smeshBuilder.Mesh.Hexahedron( smeshBuilder.Hexotic, geom=0 )
49 class Hexotic_Algorithm(Mesh_Algorithm):
50
51     ## name of the dynamic method in smeshBuilder.Mesh class
52     #  @internal
53     meshMethod = "Hexahedron"
54     ## type of algorithm used with helper function in smeshBuilder.Mesh class
55     #  @internal
56     algoType   = Hexotic
57     ## doc string of the method in smeshBuilder.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     ## Sets a size map
91     #  @param theObject geometrical object to assign local size to
92     #  @param theSize local size on the given object
93     #  @return hypothesis object
94     def SetSizeMap(self, theObject, theSize):
95         AssureGeomPublished( self.mesh, theObject )
96         if theSize <= 0:
97           raise ValueError, "The size must be > 0"
98         self.Parameters().SetSizeMap(theObject, theSize)
99         return self.Parameters()
100       
101     ## Unsets a size map : this is meant to be used only by the dump
102     #  @param theObject geometrical object to unassign local size
103     #  @return hypothesis object
104     def UnsetSizeMap(self, theObject):
105         AssureGeomPublished( self.mesh, theObject )
106         self.Parameters().UnsetSizeMap(theObject)
107         return self.Parameters()
108
109     ## (OBSOLETE) Defines "MinMaxQuad" hypothesis to give three hexotic parameters
110     #  @param min minimal level of recursive partitioning on the initial octree cube
111     #  @param max maximal level of recursive partitioning on the initial octree cube
112     #  @param quad not documented
113     #  @return hypothesis object
114     def MinMaxQuad(self, min=3, max=8, quad=True):
115         print "WARNING: Function MinMaxQuad is deprecated, use SetMinMaxHexes instead"
116         return self.SetMinMaxHexes(min, max)
117
118     ## Defines hypothesis having several parameters
119     #  @return hypothesis object
120     def Parameters(self):
121         if not self.params:
122             self.params = self.Hypothesis("Hexotic_Parameters", [],
123                                           "libHexoticEngine.so", UseExisting=0)
124             pass
125         return self.params
126
127
128     pass # end of Hexotic_Algorithm class