Salome HOME
First publish of HEXABLOCKcomponant
[modules/hexablock.git] / src / HEXABLOCK_I / hexablock.py
1 # -*- coding: latin-1 -*-
2
3 # Francis KLOSS - 2009-2010 - CEA-Saclay, DEN, DM2S, SFME, LGLS, F-91191 Gif-sur-Yvette, France
4 # =============================================================================================
5
6 import salome
7 from HEXABLOCK_ORB import *
8 import smesh
9 import HEXABLOCKPlugin
10
11 component = salome.lcc.FindOrLoadComponent("FactoryServer", "HEXABLOCK")
12
13 component = component._narrow(HEXABLOCK_Gen)
14
15 for k in dir(component):
16     if k[0] == '_':
17         continue
18     globals()[k] = getattr(component, k)
19
20 del k
21
22 def mesh(name, doc, dim=3):
23     geom = smesh.geompy.MakeBox(0, 0, 0,  1, 1, 1)
24     smesh.geompy.addToStudy(geom, name)
25     mesh = smesh.Mesh(geom)
26
27     so = "libHexaBlockEngine.so"
28
29     algo = smesh.SMESH._objref_SMESH_Gen.CreateHypothesis(smesh.smesh, "HEXABLOCK_3D", so)
30     mesh.mesh.AddHypothesis(geom, algo)
31
32     hypo = smesh.SMESH._objref_SMESH_Gen.CreateHypothesis(smesh.smesh, "HEXABLOCK_Parameters", so)
33     mesh.mesh.AddHypothesis(geom, hypo)
34
35     hypo.SetDocument(doc)
36     hypo.SetDimension(dim)
37
38     mesh.Compute()
39
40     return mesh