def trimesh_attr(vector_tag): """ Mesh with 3 vertices, 1 face, and one attribute. """ mesh = Mesh() a = mesh.add_vertex(x=0.0, y=0.0, z=0.0) b = mesh.add_vertex(x=1.0, y=0.0, z=0.0) c = mesh.add_vertex(x=1.0, y=1.0, z=0.0) fkey = mesh.add_face([a, b, c]) mesh.face_attribute(key=fkey, name=vector_tag, value=[0.0, 1.0, 0.0]) return mesh
def mesh(): """ A COMPAS mesh with two vectors stored as face attributes. """ _mesh = Mesh() # add vertices for i in range(4): _mesh.add_vertex(key=i) # right-hand side winding -- normals pointing up _mesh.add_face(fkey=0, vertices=[0, 1, 2]) _mesh.add_face(fkey=1, vertices=[0, 2, 3]) name = "my_vector_field" _mesh.face_attribute(key=0, name=name, value=[0.0, 0.0, 1.0]) _mesh.face_attribute(key=1, name=name, value=[0.0, 0.0, 2.0]) return _mesh
def mesh(vectors): """ A COMPAS mesh with three vectors stored as face attributes. """ _mesh = Mesh() # add vertices for i in range(5): _mesh.add_vertex(key=i, x=i, y=i, z=i) # right-hand side winding -- normals pointing up _mesh.add_face(fkey=0, vertices=[0, 1, 2]) _mesh.add_face(fkey=1, vertices=[0, 2, 3]) _mesh.add_face(fkey=2, vertices=[0, 3, 4]) name = "my_vector_field" _mesh.face_attribute(key=0, name=name, value=vectors[0]) _mesh.face_attribute(key=1, name=name, value=vectors[1]) _mesh.face_attribute(key=2, name=name, value=vectors[2]) return _mesh
c = mesh.add_vertex(x=1, y=1, z=0) d = mesh.add_vertex(x=0, y=1, z=0) f = mesh.add_face([a, b, c, d]) mesh = sd.mesh_subdivide_tri(mesh) mesh = sd.mesh_subdivide_quad(mesh) fkeys = list(mesh.faces()) for fk in fkeys: new_keys = msd.segment_face(mesh, fk, num=2, start_index=0) for key in new_keys: mesh.face_attribute(key, "ftype", "plot") # artist = MeshArtist(mesh, layer="level1") # artist.clear_layer() # artist.draw_faces( join_faces=True) m1 = mesh.copy() subdivide_by_ftype(m1) # artist2 = MeshArtist(m1, layer="level2") # artist2.clear_layer() m1fkeys = list(m1.faces()) #circulation = [key for key in m1fkeys if m1.face_attribute(key, 'ftype')== "circulation"] #construction = [key for key in m1fkeys if m1.face_attribute(key, 'ftype')== "construction"]