Exemplo n.º 1
0
    if sph is None: continue

    value = sph.info['radius']*10
    color = colorMap(value, name='jet') # map value to a RGB color
    n = norm(p-sph.info['center']) # unit vector from sphere center to p
    vals.append(value)
    cols.append(color) 
    pts1.append(p)
    pts2.append(p+n/8)
    if not i%500: 
        print(i,'/',s.N())
    
vp.points(pts1, c=cols)
vp.addScalarBar()
vp.lines(pts1, pts2, c='black 0.2')
vp.histogram(vals, title='values', bins=20, vrange=[0,1])

vp.show()












Exemplo n.º 2
0
# In this example we fit a plane to regions of a surface defined by
# N points that are closest to a given point of the surface.
# For some of these point we show the fitting plane.
# Blue points are the N points used for fitting.
# Green histogram is the distribution of residuals from the fitting.
# Both plane center and normal can be accessed from the
# attribute actor.center and actor.normal (direction is arbitrary).
#
from __future__ import division, print_function
from vtkplotter import Plotter
from vtkplotter.analysis import fitPlane

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

s = vp.load('data/shapes/cow.vtk').alpha(0.3).subdivide()  # remesh

variances = []
for i, p in enumerate(s.coordinates()):
    if i % 100: continue  # skip most points
    pts = s.closestPoint(p, N=12)  # find the N closest points to p
    plane = fitPlane(pts, bc='r', alpha=0.3)  # find the fitting plane
    vp.actors.append(plane)
    vp.points(pts)  # blue points
    vp.point(p, c='red 0.2')  # mark in red the current point
    vp.arrow(plane.center, plane.center + plane.normal / 15, c='g')
    variances.append(plane.variance)

vp.histogram(variances, title='variance', c='g')
vp.show()
Exemplo n.º 3
0
# Green histogram is the distribution of residuals from the fitting.
# Red histogram is the distribution of the curvatures (1/r**2).
# Fitted radius can be accessed from attribute actor.radius

from __future__ import division, print_function
from vtkplotter import Plotter
from vtkplotter.analysis import fitSphere

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

# load mesh and increase by a lot (N=2) the nr of surface vertices
s = vp.load('data/shapes/cow.vtk').alpha(0.3).subdivide(N=2)

reds, invr = [], []
for i, p in enumerate(s.coordinates()):
    if i % 1000: continue  # skip most points
    pts = s.closestPoint(p, N=16)  # find the N closest points to p
    sph = fitSphere(pts, alpha=0.05)  # find the fitting sphere
    if sph is None:
        continue  # may fail if all points sit on a plane
    vp.actors.append(sph)
    vp.points(pts)
    vp.line(sph.info['center'], p, lw=2)
    reds.append(sph.info['residue'])
    invr.append(1 / sph.info['radius']**2)

vp.histogram(reds, title='residue', bins=12, c='g', corner=3)
vp.histogram(invr, title='1/r**2', bins=12, c='r', corner=4)

vp.show()