Exemplo n.º 1
0
    def get_plane_at_point(self,
                           pos,
                           norm,
                           sx,
                           sy,
                           color='lightgray',
                           alpha=.25,
                           **kwargs):
        """ 
            Returns a plane going through a point at pos, oriented 
            orthogonally to the vector norm and of width and height
            sx, sy. 

            :param pos: 3-tuple or list with x,y,z, coords of point the plane goes through
            :param sx, sy: int, width and height of the plane
            :param norm: 3-tuple or list with 3d vector the plane is orthogonal to
            :param color, alpha: plane color and transparency
        """
        plane = Plane(pos=pos, normal=norm, sx=sx, sy=sy, c=color, alpha=alpha)
        return plane
Exemplo n.º 2
0
"""
Make a textured floor, a lamp post, and load a mesh of a car
make copies of the car, rotate and move them in a loop.
rate=10 limits the speed of the loop to maximum 10 fps
"""
from __future__ import division, print_function
from vtkplotter import Plotter, Plane, Text, datadir

vp = Plotter(interactive=0, axes=0)

vp.add(Plane(pos=(4, 0, -0.45), sx=12, texture="metalfloor1"))

# load and set its position (methods can be concatenated)
vp.load(datadir + "lamp.vtk").pos([1.7, -0.4, 2])

a = vp.load(datadir + "porsche.ply", c="r").rotateX(90)
a.normalize()  # set actor at origin and scale size to 1

for i in range(1, 10):
    b = a.clone().color("aqua").alpha(0.04 * i)
    b.rotateX(-20 * i).rotateY(-10 * i).pos([i, i / 2, i / 2])
    vp.add(b)  # add actor b
    vp.show(rate=10)  # maximum frame rate in hertz
    print(i, "time:", vp.clock, "s")

vp.add(Text(__doc__))

vp.show(interactive=1)
Exemplo n.º 3
0
import trimesh
import numpy as np
from vtkplotter import show, Plane, printc, download

# load the mesh from filename, file objects are also supported
f = download(
    'https://github.com/mikedh/trimesh/raw/master/models/featuretype.STL')
mesh = trimesh.load_mesh(f)

# get a single cross section of the mesh
txt = 'cross section of the mesh'
mslice = mesh.section(plane_origin=mesh.centroid, plane_normal=[0, 0, 1])

pl = Plane(mesh.centroid, normal=[0, 0, 1], sx=6, sy=4, alpha=0.3)

slice_2D, to_3D = mslice.to_planar()

# show objects on N=2 non-synced renderers:
show([(mesh, pl), (slice_2D, txt)], N=2, sharecam=False, axes=True)

# if we wanted to take a bunch of parallel slices, like for a 3D printer
# we can do that easily with the section_multiplane method
# we're going to slice the mesh into evenly spaced chunks along z
# this takes the (2,3) bounding box and slices it into [minz, maxz]
z_extents = mesh.bounds[:, 2]
# slice every .125 model units (eg, inches)
z_levels = np.arange(*z_extents, step=0.125)

# find a bunch of parallel cross sections
sections = mesh.section_multiplane(plane_origin=mesh.bounds[0],
                                   plane_normal=[0, 0, 1],
Exemplo n.º 4
0
from vtkplotter import Plotter, Plane, datadir

vp = Plotter()

cow = vp.load(datadir + "cow.byu", c="grey", alpha=0.7)
vp += Plane(pos=[0, -3.6, 0], normal=[0, 1, 0], sx=20).texture("grass")
vp.show(viewup='y', interactive=0)

# vp.light() returns a vtkLight object with focal Point, fp, to mesh cow
# fp can also be explicitly set as fp=[x,y,z]
l = vp.addLight(pos=[-6, 6, 6], focalPoint=cow, deg=12, showsource=1)

# can be switched on/off this way
#l.SwitchOff()

vp.show(interactive=1)
Exemplo n.º 5
0
from vtkplotter import Plotter, load, Plane, datadir

vp = Plotter()

cow = vp.load(datadir + "cow.byu", c="grey", alpha=0.7)
vp += Plane(pos=[0, -3.6, 0], normal=[0, 1, 0], sx=20, texture="grass")
vp.show(viewup='y')

# vp.light() returns a vtkLight object with focal Point, fp, to actor cow
# fp can also be explicitly set as fp=[x,y,z]
l = vp.addLight(pos=[-6, 6, 6], focalPoint=cow, deg=12, showsource=1)

# can be switched on/off this way
#l.SwitchOff()

vp.show()
Exemplo n.º 6
0
'''
Make a textured floor, a lamp post, and load a mesh of a car
make copies of the car, rotate and move them in a loop.
rate=10 limits the speed of the loop to maximum 10 fps
'''
from __future__ import division, print_function
from vtkplotter import Plotter, Plane, Text

vp = Plotter(interactive=0, axes=0)

vp.add(Plane(pos=(4, 0, -.45), sx=12, texture='metalfloor1'))

# load and set its position (methods can be concatenated)
vp.load('data/shapes/lamp.vtk').pos([1.7, -0.4, 2])

a = vp.load('data/shapes/porsche.ply', c='r').rotateX(90)
a.normalize()  # set actor at origin and scale size to 1

for i in range(1, 10):
    b = a.clone().color('aqua').alpha(.04 * i)
    b.rotateX(-20 * i).rotateY(-10 * i).pos([i, i / 2, i / 2])
    vp.add(b)  # add actor b
    vp.show(rate=10)  # maximum frame rate in hertz
    print(i, 'time:', vp.clock, 's')

vp.add(Text(__doc__))

vp.show(interactive=1)
Exemplo n.º 7
0
"""
Make a textured floor, a lamp post, and load a mesh of a car
make copies of the car, rotate and move them in a loop.
"""
from __future__ import division, print_function
from vtkplotter import Plotter, Plane, Text, datadir

vp = Plotter(interactive=0, axes=0)

vp += Plane(pos=(4, 0, -0.45), sx=12).texture("metalfloor1")

# load and set its position (methods can be concatenated)
vp.load(datadir + "lamp.vtk").pos([1.7, -0.4, 2])
vp += Text(__doc__)

a = vp.load(datadir + "porsche.ply", c="r").rotateX(90)
a.normalize()  # set actor at origin and scale size to 1

for i in range(1, 10):
    b = a.clone().color("aqua").alpha(0.04 * i)
    b.rotateX(-20 * i).rotateY(-10 * i).pos([i, i / 2, i / 2])
    vp += b  # add actor b to Plotter
    vp.show(rate=10)  # maximum frame rate in hertz
    print(i, "time:", vp.clock, "s")

vp.show(interactive=1)
Exemplo n.º 8
0
from vtkplotter import Plotter, load, Plane

vp = Plotter()

cow = vp.load('data/cow.g', c='grey', alpha=.7)

vp.add(Plane(pos=[0,-3.6,0], normal=[0,1,0], sx=20, texture='grass'))

# vp.light() returns a vtkLight object with focal Point, fp, to actor cow
# fp can also be explicitly set as fp=[x,y,z]
l = vp.light(pos=[-6,6,6], fp=cow, deg=12, showsource=1)

# can be switched on/off this way
#l.SwitchOff()

vp.show()