D5. Concrete

Objectives

We will generate a thickened mesh representing the concrete, starting from our input meshes. The output mesh could be used e.g. for solids finite element analysis.

Thicken the mesh

mesh_up = mesh.copy()
thickness = 0.05

for vkey in mesh.vertices():
    xyz = mesh.vertex_coordinates(vkey)
    v_normal = mesh.vertex_normal(vkey)

    up = scale_vector(v_normal, thickness)
    mesh_up.vertex_attributes(vkey, 'xyz', add_vectors(xyz, up))

mesh_flip_cycles(mesh_up)

concrete = mesh.copy()
max_int_key = len(list(mesh.vertices()))
max_int_fkey = len(list(mesh.faces()))

for key, attr in mesh_up.vertices(True):
    concrete.add_vertex(key=key + max_int_key, **attr)

for fkey in mesh_up.faces():
    vertices = mesh_up.face_vertices(fkey)
    vertices = [key + max_int_key for key in vertices]
    concrete.add_face(vertices)

boundary = mesh_up.vertices_on_boundary()
boundary.append(boundary[0])

for a, b in pairwise(boundary):
    concrete.add_face([b, a, a + max_int_key, b + max_int_key])

artist = MeshArtist(concrete, layer="DF2021:: Concrete")
# artist.clear_layer()
artist.draw_faces(join_faces=True)
artist.draw_edges()

Alternatively, you can use mesh_offsetor mesh_thicken

Last updated