Building by Blocks

Quadrangle Face

import geompy

import salome

gg = salome.ImportComponentGUI("GEOM")

 

# create vertices

p1 = geompy.MakeVertex(  0.,   0.,   0.)

p2 = geompy.MakeVertex(150.,  30.,   0.)

p3 = geompy.MakeVertex(  0., 120.,  50.)

p4 = geompy.MakeVertex(  0.,  40.,  70.)

 

# create edges

edge1 = geompy.MakeEdge(p1, p2)

edge2 = geompy.MakeEdge(p2, p3)

edge3 = geompy.MakeEdge(p3, p4)

edge4 = geompy.MakeEdge(p4, p1)

 

# create a quadrangle face from four edges

qface1 = geompy.MakeQuad(edge1, edge2, edge3, edge4)

 

# create a quadrangle face from two edges

qface2 = geompy.MakeQuad2Edges(edge1, edge3)

 

# create a quadrangle from four points in its corners

qface3 = geompy.MakeQuad4Vertices(p1, p2, p3, p4)

 

# add objects in the study

id_p1 = geompy.addToStudy(p1,"Point1")

id_p2 = geompy.addToStudy(p2,"Point2")

id_p3 = geompy.addToStudy(p3,"Point3")

id_p4 = geompy.addToStudy(p4,"Point4")

id_edge1 = geompy.addToStudy(edge1,"Edge1")

id_edge2 = geompy.addToStudy(edge2,"Edge2")

id_edge3 = geompy.addToStudy(edge3,"Edge3")

id_edge4 = geompy.addToStudy(edge4,"Edge4")

id_qface1 = geompy.addToStudy(qface1,"Qface1")

id_qface2 = geompy.addToStudy(qface2,"Qface2")

id_qface3 = geompy.addToStudy(qface3,"Qface3")

 

# display the vertices, the edges and the quadrangle faces

gg.createAndDisplayGO(id_p1)

gg.createAndDisplayGO(id_p2)

gg.createAndDisplayGO(id_p3)

gg.createAndDisplayGO(id_p4)

gg.createAndDisplayGO(id_edge1)

gg.createAndDisplayGO(id_edge2)

gg.createAndDisplayGO(id_edge3)

gg.createAndDisplayGO(id_edge4)

gg.createAndDisplayGO(id_qface1)

gg.setDisplayMode(id_qface1,1)

gg.createAndDisplayGO(id_qface2)

gg.setDisplayMode(id_qface2,1)

gg.createAndDisplayGO(id_qface3)

gg.setDisplayMode(id_qface3,1)

Hexagonal Solid

import geompy

import salome

gg = salome.ImportComponentGUI("GEOM")

 

# create vertices

p0  = geompy.MakeVertex(  0.,   0.,   0.)

p1  = geompy.MakeVertex(  0.,   0.,  40.)

p2  = geompy.MakeVertex( 70., -15.,   0.)

p3  = geompy.MakeVertex( 70., -15.,  70.)

 

p4  = geompy.MakeVertex(  0.,  70.,   0.)

p5  = geompy.MakeVertex(  0.,  70.,  40.)

p6  = geompy.MakeVertex( 70.,  70.,   0.)

p7  = geompy.MakeVertex( 70.,  70.,  70.)

 

p8  = geompy.MakeVertex(  0., -50.,   0.)

p9  = geompy.MakeVertex(  0., -50.,  40.)

p10 = geompy.MakeVertex( 70., -35.,   0.)

p11 = geompy.MakeVertex( 70., -35.,  70.)

 

# create faces

qface1 = geompy.MakeQuad4Vertices(p0, p1, p2, p3)

qface2 = geompy.MakeQuad4Vertices(p4, p5, p6, p7)

qface3 = geompy.MakeQuad4Vertices(p0, p1, p4, p5)

qface4 = geompy.MakeQuad4Vertices(p2, p3, p6, p7)

qface5 = geompy.MakeQuad4Vertices(p0, p2, p4, p6)

qface6 = geompy.MakeQuad4Vertices(p1, p3, p5, p7)

 

qface7 = geompy.MakeQuad4Vertices(p8, p9, p10, p11)

 

# create a hexahedral solid between two given faces

solid1 = geompy.MakeHexa2Faces(qface1, qface7)

 

# create a hexahedral solid, bounded by six given faces

solid2 = geompy.MakeHexa(qface1, qface2, qface3, qface4, qface5, qface6)

 

# add objects in the study

geompy.addToStudy(qface1,"qface1")

geompy.addToStudy(qface2,"qface2")

geompy.addToStudy(qface3,"qface3")

geompy.addToStudy(qface4,"qface4")

geompy.addToStudy(qface5,"qface5")

geompy.addToStudy(qface6,"qface6")

geompy.addToStudy(qface7,"qface7")

 

id_solid1 = geompy.addToStudy(solid1,"Solid1")

id_solid2 = geompy.addToStudy(solid2,"Solid2")

 

# display solids

gg.createAndDisplayGO(id_solid1)

gg.setDisplayMode(id_solid1, 1)

gg.createAndDisplayGO(id_solid2)

gg.setDisplayMode(id_solid2, 1)