Пример #1
0
def test_byureader():
    filename = examples.download_teapot(load=False)
    reader = pyvista.get_reader(filename)
    assert isinstance(reader, pyvista.BYUReader)
    assert reader.filename == filename

    mesh = reader.read()
    assert all([mesh.n_points, mesh.n_cells])
Пример #2
0
def generate_points(dataset=examples.download_teapot(), subset=1):
    """A helper to make a 3D NumPy array of points (n_points by 3)"""
    ids = np.random.randint(low=0,
                            high=dataset.n_points - 1,
                            size=int(dataset.n_points * subset))

    bounds = dataset.bounds  # x, y, z
    center = dataset.center

    points = dataset.points[ids]

    # Center Align
    center = np.array(center).reshape(-1, 3)
    points = points - center

    # Bounds Align
    bounds[0] = bounds[0] - center[0][0]
    bounds[1] = bounds[1] - center[0][0]
    bounds[2] = bounds[2] - center[0][1]
    bounds[3] = bounds[3] - center[0][1]
    bounds[4] = bounds[4] - center[0][2]
    bounds[5] = bounds[5] - center[0][2]
    return points, bounds
Пример #3
0
 def test_download_teapot():
     data = examples.download_teapot()
     assert data.n_cells
Пример #4
0
mesh.faces.reshape(-1, 4)[:, 1:]  # triangular faces

###############################################################################
# Loading other files types is just as easy! Simply pass your file path to the
# :func:`pyvista.read` function and that's it!
#
# Here are a few other examples - simply replace ``examples.download_*`` in the
# examples below with ``pyvista.read('path/to/you/file.ext')``

###############################################################################
# Example STL file:
mesh = examples.download_cad_model()
cpos = [(107.0, 68.5, 204.0), (128.0, 86.5, 223.5), (0.45, 0.36, -0.8)]
mesh.plot(cpos=cpos)

###############################################################################
# Example OBJ file
mesh = examples.download_doorman()
mesh.plot(cpos="xy")

###############################################################################
# Example BYU file
mesh = examples.download_teapot()
mesh.plot(cpos=[-1, 2, -5], show_edges=True)

###############################################################################
# Example VTK file
mesh = examples.download_bunny_coarse()
cpos = [(0.2, 0.3, 0.9), (0, 0, 0), (0, 1, 0)]
mesh.plot(cpos=cpos, show_edges=True, color=True)
Пример #5
0
import numpy as np
import math
import pyvista as pv
import tree as T
import assignment as AS
import time
import pickle
from tqdm import tqdm_notebook
from pathlib import Path

from scipy.optimize import linear_sum_assignment

from pyvista import examples
from operator import itemgetter

dataset_teapot = examples.download_teapot()
dataset_bunny = examples.download_bunny_coarse()

teapot_points, temp = T.generate_points(dataset_teapot)
bunny_points, temp = T.generate_points(dataset_bunny)

source = teapot_points
destination = bunny_points * 10

source_points, destination_points = [], []
src_pts_path = Path("source_pts.pkl")
dst_pts_path = Path("dst_pts.pkl")

if src_pts_path.exists():
    with open(src_pts_path, "rb") as fp:
        source_points = pickle.load(fp)