How to use the ply.load_ply function in ply

To help you get started, we’ve selected a few ply examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github julienr / meshcut / tests / test_cross_section.py View on Github external
def load_human():
    # TODO: This is ugly, make ply a submodule of meshcut (requires
    # some refactoring)
    print('examples :', EXAMPLES_DIR)
    sys.path.append(EXAMPLES_DIR)
    import ply

    fname = os.path.join(DATA_DIR, 'mesh.ply')
    with open(fname) as f:
        verts, faces, _ = ply.load_ply(f)

    return meshcut.TriangleMesh(verts, faces)
github vlachoudis / bCNC / bCNC / plugins / slicemesh.py View on Github external
def loadMesh(self, file):
		#Decide on filetype
		fn, fext = os.path.splitext(file)
		fext = fext.upper()

		if fext=='.STL':
			verts, faces = self.load_stl(file)
		elif fext=='.PLY':
			with open(file) as f:
				verts, faces, _ = ply.load_ply(f)
		else:
			print("unknown file extension",fext)
			return None

		return verts, faces
github julienr / meshcut / examples / 0_cross_section.py View on Github external
import os
import numpy as np
import mayavi.mlab as mlab
import itertools
import utils
import ply

import meshcut

##
if __name__ == '__main__':
    ##
    example_dir = os.path.join(os.path.dirname(meshcut.__file__), 'examples')
    example_fname = os.path.join(example_dir, 'data', 'mesh.ply')
    with open(example_fname) as f:
        verts, faces, _ = ply.load_ply(f)

    mesh = meshcut.TriangleMesh(verts, faces)
    ##

    def show(plane, expected_n_contours):
        P = meshcut.cross_section_mesh(mesh, plane)
        colors = [
            (0, 1, 1),
            (1, 0, 1),
            (0, 0, 1)
        ]
        print("num contours : ", len(P), ' expected : ', expected_n_contours)

        if True:
            utils.trimesh3d(mesh.verts, mesh.tris, color=(1, 1, 1),
                            opacity=0.5)
github vlachoudis / bCNC / bCNC / plugins / slicemesh.py View on Github external
def loadMesh(self, file):
		#Decide on filetype
		fn, fext = os.path.splitext(file)
		fext = fext.upper()

		if fext=='.STL':
			verts, faces = self.load_stl(file)
		elif fext=='.PLY':
			with open(file) as f:
				verts, faces, _ = ply.load_ply(f)
		else:
			print("unknown file extension",fext)
			return None

		return verts, faces
github julienr / meshcut / misc / experiments.py View on Github external
"""Experimental stuff. Run this in ipython from the 'examples' directory"""
##
import numpy as np
import ply
import mayavi.mlab as mlab  # noqa
from utils import points3d, trimesh3d, show_plane
# %matplotlib qt
##
with open('data/mesh.ply') as f:
    verts, faces, _ = ply.load_ply(f)

##
# plane defined by origin and normal
plane_orig = (1.0, 0.0, 0.0)
plane_norm = (1.0, 0.0, 0.0)

trimesh3d(verts, faces, color=(1, 1, 1))
show_plane(plane_orig, plane_norm, scale=0.5, color=(1, 0, 0), opacity=0.5)
##


def point_to_plane_dist(p, plane_orig, plane_norm):
    return np.dot((p - plane_orig), plane_norm)


def classify_faces(verts, faces, plane_orig, plane_norm):