7 Box_1 = geompy.MakeBoxDXDYDZ(200., 200., 200.)
8 geompy.addToStudy(Box_1, "Box_1")
10 faces = geompy.SubShapeAll(Box_1, geompy.ShapeType["FACE"])
14 geompy.addToStudyInFather(Box_1, Face_1, "Face_1")
15 geompy.addToStudyInFather(Box_1, Face_2, "Face_2")
17 # build a quadrangle mesh 3x3 on Face_1
18 Mesh_1 = smesh.Mesh(Face_1)
19 algo1D = Mesh_1.Segment()
20 algo1D.NumberOfSegments(3)
23 isDone = Mesh_1.Compute()
24 if not isDone: print 'Mesh Mesh_1 : computation failed'
26 # build a triangle mesh on Face_2
27 Mesh_2 = smesh.Mesh(Face_2)
29 algo1D = Mesh_2.Segment()
30 algo1D.NumberOfSegments(1)
31 algo2D = Mesh_2.Triangle()
32 algo2D.MaxElementArea(240)
34 isDone = Mesh_2.Compute()
35 if not isDone: print 'Mesh Mesh_2 : computation failed'
38 pattern = smesh.GetPattern()
40 isDone = pattern.LoadFromFace(Mesh_2.GetMesh(), Face_2, 0)
41 if (isDone != 1): print 'LoadFromFace :', pattern.GetErrorCode()
43 # apply the pattern to a face of the first mesh
44 facesToSplit = Mesh_1.GetElementsByType(smesh.SMESH.FACE)
45 print "Splitting %d rectangular face(s) to %d triangles..."%(len(facesToSplit), 2*len(facesToSplit))
46 pattern.ApplyToMeshFaces(Mesh_1.GetMesh(), facesToSplit, 0, 0)
47 isDone = pattern.MakeMesh(Mesh_1.GetMesh(), 0, 0)
48 if (isDone != 1): print 'MakeMesh :', pattern.GetErrorCode()
50 # create quadrangle mesh
51 Mesh_3 = smesh.Mesh(Box_1)
52 Mesh_3.Segment().NumberOfSegments(1)
55 isDone = Mesh_3.Compute()
56 if not isDone: print 'Mesh Mesh_3 : computation failed'
58 # create a 3d pattern (hexahedrons)
59 pattern_hexa = smesh.GetPattern()
61 smp_hexa = """!!! Nb of points:
78 !!! Indices of points of 4 elements:
84 pattern_hexa.LoadFromFile(smp_hexa)
86 # apply the pattern to a mesh
87 volsToSplit = Mesh_3.GetElementsByType(smesh.SMESH.VOLUME)
88 print "Splitting %d hexa volume(s) to %d hexas..."%(len(volsToSplit), 4*len(volsToSplit))
89 pattern_hexa.ApplyToHexahedrons(Mesh_3.GetMesh(), volsToSplit,0,3)
90 isDone = pattern_hexa.MakeMesh(Mesh_3.GetMesh(), True, True)
91 if (isDone != 1): print 'MakeMesh :', pattern_hexa.GetErrorCode()
93 # create one more quadrangle mesh
94 Mesh_4 = smesh.Mesh(Box_1)
95 Mesh_4.Segment().NumberOfSegments(1)
98 isDone = Mesh_4.Compute()
99 if not isDone: print 'Mesh Mesh_4 : computation failed'
101 # create another 3d pattern (pyramids)
102 pattern_pyra = smesh.GetPattern()
104 smp_pyra = """!!! Nb of points:
115 !!! Indices of points of 6 elements:
123 pattern_pyra.LoadFromFile(smp_pyra)
125 # apply the pattern to a face mesh
126 volsToSplit = Mesh_4.GetElementsByType(smesh.SMESH.VOLUME)
127 print "Splitting %d hexa volume(s) to %d hexas..."%(len(volsToSplit), 6*len(volsToSplit))
128 pattern_pyra.ApplyToHexahedrons(Mesh_4.GetMesh(), volsToSplit,1,0)
129 isDone = pattern_pyra.MakeMesh(Mesh_4.GetMesh(), True, True)
130 if (isDone != 1): print 'MakeMesh :', pattern_pyra.GetErrorCode()