def slice_mesh_plane(mesh,
                     plane_normal,
                     plane_origin,
                     **kwargs):
    """
    Slice a mesh with a plane, returning a new mesh that is the
    portion of the original mesh to the positive normal side of the plane

    Parameters
    ---------
    mesh : Trimesh object
        Source mesh to slice
    plane_normal : (3,) float
        Normal vector of plane to intersect with mesh
    plane_origin:  (3,) float
        Point on plane to intersect with mesh
    cached_dots : (n, 3) float
        If an external function has stored dot
        products pass them here to avoid recomputing
    Returns
    ----------
    new_mesh : Trimesh object
        Sliced mesh
    """
    # check input for none
    if mesh is None:
        return None

    # avoid circular import
    from .base import Trimesh

    # check input plane
    plane_normal = np.asanyarray(plane_normal,
                                 dtype=np.float64)
    plane_origin = np.asanyarray(plane_origin,
                                 dtype=np.float64)

    # check to make sure origins and normals have acceptable shape
    shape_ok = ((plane_origin.shape == (3,) or
                 util.is_shape(plane_origin, (-1, 3))) and
                (plane_normal.shape == (3,) or
                 util.is_shape(plane_normal, (-1, 3))) and
                plane_origin.shape == plane_normal.shape)
    if not shape_ok:
        raise ValueError('plane origins and normals must be (n, 3)!')

    # start with original vertices and faces
    vertices = mesh.vertices.copy()
    faces = mesh.faces.copy()

    # slice away specified planes
    for origin, normal in zip(plane_origin.reshape((-1, 3)),
                              plane_normal.reshape((-1, 3))):
        # save the new vertices and faces
        vertices, faces = slice_faces_plane(vertices=vertices,
                                            faces=faces,
                                            plane_normal=normal,
                                            plane_origin=origin,
                                            **kwargs)

    # create a mesh from the sliced result
    new_mesh = Trimesh(vertices=vertices,
                       faces=faces,
                       process=False)
    return new_mesh
def slice_mesh_plane ( mesh , plane_normal , plane_origin , ** kwargs ) : if mesh is None : return None from . base import Trimesh plane_normal = np . asanyarray ( plane_normal , dtype = np . float64 ) plane_origin = np . asanyarray ( plane_origin , dtype = np . float64 ) shape_ok = ( ( plane_origin . shape == ( 3 , ) or util . is_shape ( plane_origin , ( - 1 , 3 ) ) ) and ( plane_normal . shape == ( 3 , ) or util . is_shape ( plane_normal , ( - 1 , 3 ) ) ) and plane_origin . shape == plane_normal . shape ) if not shape_ok : raise ValueError ( 'plane origins and normals must be (n, 3)!' ) vertices = mesh . vertices . copy ( ) faces = mesh . faces . copy ( ) for origin , normal in zip ( plane_origin . reshape ( ( - 1 , 3 ) ) , plane_normal . reshape ( ( - 1 , 3 ) ) ) : vertices , faces = slice_faces_plane ( vertices = vertices , faces = faces , plane_normal = normal , plane_origin = origin , ** kwargs ) new_mesh = Trimesh ( vertices = vertices , faces = faces , process = False ) return new_mesh
Slice a mesh with a plane, returning a new mesh that is the
    portion of the original mesh to the positive normal side of the plane

    Parameters
    ---------
    mesh : Trimesh object
        Source mesh to slice
    plane_normal : (3,) float
        Normal vector of plane to intersect with mesh
    plane_origin:  (3,) float
        Point on plane to intersect with mesh
    cached_dots : (n, 3) float
        If an external function has stored dot
        products pass them here to avoid recomputing
    Returns
    ----------
    new_mesh : Trimesh object
        Sliced mesh