예제 #1
0
파일: mesh_lut.py 프로젝트: trasse/vedo
from vedo import makeLUT, Sphere

mesh = Sphere().lineWidth(0.1)

# create some data array to be associated to points
data = mesh.points()[:, 2]
data[10:20] = float('nan')

# Build a lookup table of colors:
#               scalar  color   alpha
lut = makeLUT(
    [
        (-0.80, 'pink'),
        (-0.33, 'green', 0.8),
        (0.67, 'red'),
    ],
    vmin=-1,
    vmax=1,
    aboveColor='grey',
    belowColor='white',
    interpolate=False,
)

mesh.cmap(lut, data).addScalarBar()

mesh.show(axes=1, viewup='z')
예제 #2
0
"""Interpolate the arrays of a source Mesh (RandomHills)
onto another (ellipsoid) by averaging closest point values"""
from vedo import ParametricShape, Sphere, show

# RandomHills already contains the height as a scalar defined on vertices
h = ParametricShape('RandomHills')
h.cmap('hsv', vmin=0, vmax=6)
h.addScalarBar3D(title='RandomHills height scalar value')

# interpolate such values on a completely different Mesh.
# pick N=4 closest points and assign an ave value based on shepard kernel.
s = Sphere().scale([1, 1, 0.5]).pos(-.1, 1.5, 0.3).alpha(1).lw(0.1)
s.interpolateDataFrom(h, N=4, kernel='gaussian')
s.cmap('hsv', vmin=0, vmax=6)

show(h, s, __doc__, axes=1).close()
예제 #3
0
# create some dummy data array to be associated to points
data = mesh.points()[:,2]  # pick z-coords, use them as scalar data
data[10:70] = float('nan') # make some values invalid by setting to NaN
data[300:600] = 100        # send some values very far above-scale

# build a custom LookUp Table of colors:
#               value, color, alpha
lut = buildLUT([
                #(-2, 'pink'      ),  # up to -2 is pink
                (0.0, 'pink'      ),  # up to 0 is pink
                (0.4, 'green', 0.5),  # up to 0.4 is green with alpha=0.5
                (0.7, 'darkblue'  ),
                #( 2, 'darkblue'  ),
               ],
               vmin=-1.2, belowColor='lightblue',
               vmax= 0.7, aboveColor='grey',
               nanColor='red',
               interpolate=False,
              )
# 3D scalarbar:
mesh.cmap(lut, data).addScalarBar3D(title='My 3D scalarbar', c='white')
mesh.scalarbar.scale(1.5).rotateX(90).y(1) # make it bigger and place it

# 2D scalarbar:
# mesh.cmap(lut, data).addScalarBar()

show(mesh, __doc__,
     axes=dict(zLabelSize=.04, numberOfDivisions=10),
     elevation=-80, bg='blackboard',
)
예제 #4
0
"""Compute the (signed) distance of one mesh to another"""
from vedo import Sphere, Cube, show

s1 = Sphere().x(10)
s2 = Cube(c='grey4').scale([2, 1, 1]).x(14)

s1.distanceTo(s2, signed=False)
s1.cmap('hot').addScalarBar('Signed\nDistance')
# print(s1.pointdata["Distance"])  # numpy array

show(s1, s2, __doc__, axes=1, size=(1000, 500), zoom=1.5).close()