class PLYParser(object): """""" def __init__(self, reader, precision=None): self.precision = precision self.reader = reader self.vertices = None self.edges = None self.faces = None self.parse() def parse(self): self.vertices = [(vertex['x'], vertex['y'], vertex['z']) for vertex in self.reader.vertices] self.faces = [face['vertex_indices'] for face in self.reader.faces] # ============================================================================== # Main # ============================================================================== if __name__ == "__main__": import compas from compas.datastructures import Mesh ply = PLY(compas.get_bunny()) mesh = Mesh.from_vertices_and_faces(ply.parser.vertices, ply.parser.faces) print(mesh.summary())
import compas from math import radians from compas.datastructures import Mesh from compas.geometry import Point, Rotation, Scale, Translation, Box from compas.geometry import trimesh_remesh from compas_view2.app import App # ============================================================================== # Get Bunny # ============================================================================== before = Mesh.from_ply(compas.get_bunny()) # ============================================================================== # Clean up # ============================================================================== before.cull_vertices() # ============================================================================== # Transform # ============================================================================== T = Translation.from_vector(Point(0, 0, 0) - Point(*before.centroid())) S = Scale.from_factors([100, 100, 100]) R = Rotation.from_axis_and_angle([1, 0, 0], radians(90)) before.transform(R * S * T) # ==============================================================================
from scipy.sparse.linalg import spsolve from compas.datastructures import Mesh from compas.plotters import MeshPlotter __author__ = ['Tom Van Mele', ] __copyright__ = 'Copyright 2016 - Block Research Group, ETH Zurich' __license__ = 'MIT' __email__ = '*****@*****.**' # make a *stanford bunny* mesh mesh = Mesh.from_ply(compas.get_bunny()) mesh.cull_vertices() # get any vertex of the mesh # and its neighbours v1 = mesh.get_any_vertex() nbrs = mesh.vertex_neighbours(v1, ordered=True) # make a quad containing: # one of the neighbours # and the CCW and CW neighbours of that neighbour, respectively # and set them as anchors