#### /src/examples/Level1/SMESH/test_smesh.py

Python | 74 lines | 42 code | 19 blank | 13 comment | 0 complexity | 160aa3e85efcdbbda303cb745c1a5102 MD5 | raw file
1# This is a simple port of Fotis'code to python
3
4from OCC.BRepPrimAPI import *
5from OCC.TopAbs import *
6from OCC.TopExp import *
7from OCC.TopoDS import *
8from OCC.SMESH import *
9from OCC.StdMeshers import *
10from OCC.MeshVS import *
11
12from OCC.Display.SimpleGui import *
14#Create the shape to mesh
15#aShape = BRepPrimAPI_MakeSphere(40).Shape()
16aShape = BRepPrimAPI_MakeBox(10,20,30).Shape()
17#aShape = BRepPrimAPI_MakeTorus(400,40).Shape()
18
19aMeshGen = SMESH_Gen()
20aMesh = aMeshGen.CreateMesh(0,True)
21
22an1DHypothesis = StdMeshers_Arithmetic1D(0,0,aMeshGen)
23an1DHypothesis.SetLength(1.,False)
24an1DHypothesis.SetLength(5.,True)
25an1DAlgo = StdMeshers_Regular_1D(1,0,aMeshGen)
26
29
30#Calculate mesh
31aMesh.ShapeToMesh(aShape)
32
33#Assign hyptothesis to mesh
38
39#Compute the data
40aMeshGen.Compute(aMesh,aMesh.GetShapeToMesh())
41
42# Export the data
43print "Export to DAT"
44aMesh.ExportDAT("_TEST.DAT")
45
46print "Export to STL"
47aMesh.ExportSTL("_TEST.STL",True) #True if ascii
48
49print "Export to UNV"
50aMesh.ExportUNV("_TEST.UNV") #True if ascii
51
52# Export to MED fails
53#print "Export to MED"
54#aMesh.ExportMED("_TEST.MED")
55
56# Display the data
58aMeshVS = MeshVS_Mesh(True)
59DMF = 1 # to wrap!
60MeshVS_BP_Mesh       =  5 # To wrap!
61