def test_face_adjacency_halfedge(): mesh = Mesh.from_obj(compas.get('faces.obj')) assert mesh.face_adjacency_halfedge(0, 1) == (1, 7)
def cube(): return Mesh.from_polyhedron(6)
def test_clear(): mesh = Mesh.from_obj(compas.get('faces.obj')) mesh.clear() assert mesh.number_of_faces() == 0 assert mesh.number_of_vertices() == 0 assert mesh.number_of_edges() == 0
def test_from_lines(): lines = compas.json_load(compas.get('lines.json')) mesh = Mesh.from_lines(lines) assert mesh.number_of_faces() == 10 assert mesh.number_of_vertices() == 32 assert mesh.number_of_edges() == 40
def test_from_polyhedron(): mesh = Mesh.from_polyhedron(8) assert mesh.number_of_faces() == 8 assert mesh.number_of_vertices() == 6 assert mesh.number_of_edges() == 12
if callback: callback(k, callback_args) # ============================================================================== # Main # ============================================================================== if __name__ == "__main__": import compas from compas.datastructures import Mesh from compas_plotters import MeshPlotter mesh = Mesh.from_obj(compas.get('faces.obj')) fixed = list(mesh.vertices_where({'vertex_degree': 2})) lines = [] for u, v in mesh.edges(): lines.append({ 'start': mesh.vertex_coordinates(u, 'xy'), 'end': mesh.vertex_coordinates(v, 'xy'), 'color': '#cccccc', 'width': 1.0, }) mesh_smooth_area(mesh, fixed=fixed, kmax=100) plotter = MeshPlotter(mesh, figsize=(10, 7))
def test_from_ply(): mesh = Mesh.from_ply(compas.get('tubemesh.ply')) assert mesh.number_of_faces() == 342 assert mesh.number_of_vertices() == 200 assert mesh.number_of_edges() == 541
def test_vertex_neighborhood_centroid(): mesh = Mesh.from_obj(compas.get('faces.obj')) assert mesh.vertex_neighborhood_centroid(0) == [1.0, 1.0, 0.0] assert mesh.vertex_neighborhood_centroid(1) == [ 2.0, 0.6666666666666666, 0.0 ]
def test_vertex_curvature(): mesh = Mesh.from_obj(compas.get('quadmesh.obj')) assert mesh.vertex_curvature(0) == 0.0029617825994936453 assert mesh.vertex_curvature(5) == 0.036193074384009094
def test_vertex_area(): mesh = Mesh.from_obj(compas.get('faces.obj')) assert mesh.vertex_area(0) == 1 assert mesh.vertex_area(15) == 4
def test_vertex_laplacian(): mesh = Mesh.from_obj(compas.get('faces.obj')) assert mesh.vertex_laplacian(0) == [1.0, 1.0, 0.0] assert mesh.vertex_laplacian(1) == [0.0, 0.6666666666666666, 0.0]
def test_vertex_coordinates(): mesh = Mesh.from_obj(compas.get('faces.obj')) assert mesh.vertex_coordinates(15) == [6.0, 4.0, 0.0] assert mesh.vertex_coordinates(15, 'yx') == [4.0, 6.0]
def test_is_face_on_boundary(): mesh = Mesh.from_obj(compas.get('faces.obj')) assert mesh.is_face_on_boundary(0) assert not mesh.is_face_on_boundary(8)
def test_face_adjacency_vertices(): mesh = Mesh.from_obj(compas.get('faces.obj')) assert mesh.face_adjacency_vertices(0, 1) == [1, 7]
def test_face_curvature(): mesh = Mesh.from_obj(compas.get('quadmesh.obj')) assert mesh.face_curvature(0) == 0.0035753184898039566 mesh = Mesh.from_obj(compas.get('faces.obj')) assert mesh.face_curvature(0) == 0
def test_face_normal(): mesh = Mesh.from_obj(compas.get('quadmesh.obj')) assert mesh.face_normal(0) == (0.5435358481001584, -0.16248515023849733, 0.8235091728584537)
def test_edges_on_boundary(): mesh = Mesh.from_obj(compas.get('quadmesh.obj')) assert len(mesh.edges_on_boundary()) == 36
def test_face_centroid(): mesh = Mesh.from_obj(compas.get('quadmesh.obj')) assert mesh.face_centroid(0) == [ 3.94185334444046, 2.024157851934433, 1.3333333134651184 ]
def test_from_obj(): mesh = Mesh.from_obj(compas.get('faces.obj')) assert mesh.number_of_faces() == 25 assert mesh.number_of_vertices() == 36 assert mesh.number_of_edges() == 60
def test_face_center(): mesh = Mesh.from_obj(compas.get('quadmesh.obj')) assert mesh.face_center(0) == [ 3.944329439044577, 2.0258867968680776, 1.332040166602369 ]
def test_from_off(): mesh = Mesh.from_off(compas.get('cube.off')) assert mesh.number_of_faces() == 6 assert mesh.number_of_vertices() == 8 assert mesh.number_of_edges() == 12
def test_face_area(): mesh = Mesh.from_obj(compas.get('quadmesh.obj')) assert mesh.face_area(0) == 0.3374168482414756
def tet(): return Mesh.from_polyhedron(4)
def test_face_flatness(): mesh = Mesh.from_obj(compas.get('quadmesh.obj')) assert mesh.face_flatness(0) == 0.23896112582475654 mesh = Mesh.from_obj(compas.get('faces.obj')) assert mesh.face_flatness(0) == 0
def test_to_vertices_and_faces(): mesh = Mesh.from_obj(compas.get('faces.obj')) vertices, faces = mesh.to_vertices_and_faces() assert len(vertices) == 36 assert len(faces) == 25
def test_face_aspect_ratio(): mesh = Mesh.from_obj(compas.get('quadmesh.obj')) assert mesh.face_aspect_ratio(0) == 1.2813792520925738 mesh = Mesh.from_obj(compas.get('faces.obj')) assert mesh.face_aspect_ratio(0) == 1
def test_copy(): mesh1 = Mesh.from_obj(compas.get('faces.obj')) mesh2 = mesh1.copy() assert mesh1.number_of_faces() == mesh2.number_of_faces() assert mesh1.number_of_vertices() == mesh2.number_of_vertices() assert mesh1.number_of_edges() == mesh2.number_of_edges()
def test_face_skewness(): mesh = Mesh.from_obj(compas.get('quadmesh.obj')) assert mesh.face_skewness(0) == 0.2432393485343291 mesh = Mesh.from_obj(compas.get('faces.obj')) assert mesh.face_skewness(0) == 0
def test_add_vertex(): mesh = Mesh.from_stl(compas.get('cube_binary.stl')) v = mesh.number_of_vertices() key = mesh.add_vertex(x=0, y=1, z=2) assert mesh.vertex_attributes(key, 'xyz') == [0, 1, 2] assert mesh.number_of_vertices() == v + 1
def test_from_ply(): mesh = Mesh.from_ply(compas.get('bunny.ply')) assert mesh.number_of_faces() == 69451 assert mesh.number_of_vertices() == 35947 assert mesh.number_of_edges() == 104288