7 from salome.geom import geomBuilder
8 geompy = geomBuilder.New(salome.myStudy)
10 import SMESH, SALOMEDS
11 from salome.smesh import smeshBuilder
12 smesh = smeshBuilder.New(salome.myStudy)
15 Box_1 = geompy.MakeBoxDXDYDZ(200., 200., 200.)
16 geompy.addToStudy(Box_1, "Box_1")
18 faces = geompy.SubShapeAll(Box_1, geompy.ShapeType["FACE"])
22 geompy.addToStudyInFather(Box_1, Face_1, "Face_1")
23 geompy.addToStudyInFather(Box_1, Face_2, "Face_2")
25 # build a quadrangle mesh 3x3 on Face_1
26 Mesh_1 = smesh.Mesh(Face_1)
27 algo1D = Mesh_1.Segment()
28 algo1D.NumberOfSegments(3)
31 isDone = Mesh_1.Compute()
32 if not isDone: print 'Mesh Mesh_1 : computation failed'
34 # build a triangle mesh on Face_2
35 Mesh_2 = smesh.Mesh(Face_2)
37 algo1D = Mesh_2.Segment()
38 algo1D.NumberOfSegments(1)
39 algo2D = Mesh_2.Triangle()
40 algo2D.MaxElementArea(240)
42 isDone = Mesh_2.Compute()
43 if not isDone: print 'Mesh Mesh_2 : computation failed'
46 pattern = smesh.GetPattern()
48 isDone = pattern.LoadFromFace(Mesh_2.GetMesh(), Face_2, 0)
49 if (isDone != 1): print 'LoadFromFace :', pattern.GetErrorCode()
51 # apply the pattern to a face of the first mesh
52 facesToSplit = Mesh_1.GetElementsByType(SMESH.FACE)
53 print "Splitting %d rectangular face(s) to %d triangles..."%(len(facesToSplit), 2*len(facesToSplit))
54 pattern.ApplyToMeshFaces(Mesh_1.GetMesh(), facesToSplit, 0, 0)
55 isDone = pattern.MakeMesh(Mesh_1.GetMesh(), 0, 0)
56 if (isDone != 1): print 'MakeMesh :', pattern.GetErrorCode()
58 # create quadrangle mesh
59 Mesh_3 = smesh.Mesh(Box_1)
60 Mesh_3.Segment().NumberOfSegments(1)
63 isDone = Mesh_3.Compute()
64 if not isDone: print 'Mesh Mesh_3 : computation failed'
66 # create a 3d pattern (hexahedrons)
67 pattern_hexa = smesh.GetPattern()
69 smp_hexa = """!!! Nb of points:
86 !!! Indices of points of 4 elements:
92 pattern_hexa.LoadFromFile(smp_hexa)
94 # apply the pattern to a mesh
95 volsToSplit = Mesh_3.GetElementsByType(SMESH.VOLUME)
96 print "Splitting %d hexa volume(s) to %d hexas..."%(len(volsToSplit), 4*len(volsToSplit))
97 pattern_hexa.ApplyToHexahedrons(Mesh_3.GetMesh(), volsToSplit,0,3)
98 isDone = pattern_hexa.MakeMesh(Mesh_3.GetMesh(), True, True)
99 if (isDone != 1): print 'MakeMesh :', pattern_hexa.GetErrorCode()
101 # create one more quadrangle mesh
102 Mesh_4 = smesh.Mesh(Box_1)
103 Mesh_4.Segment().NumberOfSegments(1)
106 isDone = Mesh_4.Compute()
107 if not isDone: print 'Mesh Mesh_4 : computation failed'
109 # create another 3d pattern (pyramids)
110 pattern_pyra = smesh.GetPattern()
112 smp_pyra = """!!! Nb of points:
123 !!! Indices of points of 6 elements:
131 pattern_pyra.LoadFromFile(smp_pyra)
133 # apply the pattern to a face mesh
134 volsToSplit = Mesh_4.GetElementsByType(SMESH.VOLUME)
135 print "Splitting %d hexa volume(s) to %d hexas..."%(len(volsToSplit), 6*len(volsToSplit))
136 pattern_pyra.ApplyToHexahedrons(Mesh_4.GetMesh(), volsToSplit,1,0)
137 isDone = pattern_pyra.MakeMesh(Mesh_4.GetMesh(), True, True)
138 if (isDone != 1): print 'MakeMesh :', pattern_pyra.GetErrorCode()