D3.3 3D Visualization

Translate mesh copy

We can create two copy of the 2d mesh, translate them to the left and to the right along the local z-axis.

# copy the mesh
beam_side1 = beam_2d.copy()
beam_side2 = beam_2d.copy()

thickness = 0.05

for vkey in beam_2d.vertices():
    xyz = beam_2d.vertex_coordinates(vkey)

    left = scale_vector(zaxis_local, -0.5 * thickness)
    right = scale_vector(zaxis_local, 0.5 * thickness)

    beam_side1.vertex_attributes(vkey, 'xyz', add_vectors(xyz, left))
    beam_side2.vertex_attributes(vkey, 'xyz', add_vectors(xyz, right))

mesh_flip_cycles(beam_side2)

meshartist = MeshArtist(beam_side1, layer="DF2021:: Beam:: Seam:: local_mesh")
#meshartist.clear_layer()
meshartist.draw_faces(join_faces=True)
meshartist.draw_edges()

Add side faces

Side faces need to be added between the meshes.

beam_3d = beam_side1.copy()
max_int_key = len(list(beam_3d.vertices()))
max_int_fkey = len(list(beam_3d.faces()))

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

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

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

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

meshartist = MeshArtist(beam_3d, layer="DF2021:: Beam:: Seam:: local_mesh")
meshartist.clear_layer()
meshartist.draw_faces(join_faces=True)
meshartist.draw_edges()

Last updated