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

        if True:
            utils.trimesh3d(mesh.verts,
                            mesh.tris,
                            color=(1, 1, 1),
                            opacity=0.5,
                            representation='wireframe')
            utils.show_plane(plane.orig,
                             plane.n,
                             scale=1,
                             color=(1, 0, 0),
                             opacity=0.5)

            for p, color in zip(P, itertools.cycle(colors)):
                p = np.array(p)
                mlab.plot3d(p[:, 0],
                            p[:, 1],
                            p[:, 2],
                            tube_radius=None,
                            line_width=3.0,
                            color=color)
        return P
    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)
            utils.show_plane(plane.orig,
                             plane.n,
                             scale=1,
                             color=(1, 0, 0),
                             opacity=0.5)

            for p, color in zip(P, itertools.cycle(colors)):
                p = np.array(p)
                #utils.points3d(np.array(p), point_size=3, color=(1,1,1))
                mlab.plot3d(p[:, 0],
                            p[:, 1],
                            p[:, 2],
                            tube_radius=None,
                            line_width=3.0,
                            color=color)
        return P
Exemple #3
0
    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)
            utils.show_plane(plane.orig, plane.n, scale=1, color=(1, 0, 0),
                             opacity=0.5)

            for p, color in zip(P, itertools.cycle(colors)):
                p = np.array(p)
                mlab.plot3d(p[:, 0], p[:, 1], p[:, 2], tube_radius=None,
                            line_width=3.0, color=color)
        return P
Exemple #4
0
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):
    faces_pos = []
    faces_mid = []
    faces_neg = []

    for f in faces:
        sides = [
            point_to_plane_dist(p, plane_orig, plane_norm) for p in verts[f]
Exemple #5
0
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):
    faces_pos = []
    faces_mid = []
    faces_neg = []

    for f in faces:
        sides = [point_to_plane_dist(p, plane_orig, plane_norm)
                 for p in verts[f]]