-
Notifications
You must be signed in to change notification settings - Fork 268
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
28 changed files
with
434 additions
and
444 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,12 @@ | ||
"""Use 2 lines to define a flat arrow""" | ||
from vedo import * | ||
|
||
arrs = [] | ||
for i in range(10): | ||
s, c = sin(i), cos(i) | ||
l1 = [[sin(x)+c, -cos(x)+s, x] for x in arange(0,3, 0.1)] | ||
l2 = [[sin(x)+c+0.1, -cos(x)+s + x/15, x] for x in arange(0,3, 0.1)] | ||
|
||
FlatArrow(l1, l2, c=i, tipSize=1, tipWidth=1) | ||
arrs.append(FlatArrow(l1, l2, c=i, tipSize=1, tipWidth=1)) | ||
|
||
# three points, aka ellipsis, retrieves the list of all created actors | ||
show(..., __doc__, viewup="z", axes=1) | ||
show(arrs, __doc__, viewup="z", axes=1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,39 @@ | ||
from vedo import makeLUT, Sphere | ||
"""Build a custom colormap, including | ||
out-of-range and NaN colors and labels""" | ||
from vedo import buildLUT, Sphere, show, settings | ||
|
||
mesh = Sphere().lineWidth(0.1) | ||
# settings.useDepthPeeling = True # might help with transparencies | ||
|
||
# create some data array to be associated to points | ||
data = mesh.points()[:,2] | ||
data[10:20] = float('nan') | ||
# generate a sphere and stretch it, so it sits between z=-2 and z=+2 | ||
mesh = Sphere(quads=True).scale([1,1,2]).lineWidth(0.1) | ||
|
||
# Build a lookup table of colors: | ||
# scalar color alpha | ||
lut = makeLUT( [(-0.80, 'pink' ), | ||
(-0.33, 'green', 0.8), | ||
( 0.67, 'red' ), | ||
# 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, vmax=1, | ||
aboveColor='grey', | ||
belowColor='white', | ||
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 | ||
|
||
mesh.cmap(lut, data).addScalarBar() | ||
# 2D scalarbar: | ||
# mesh.cmap(lut, data).addScalarBar() | ||
|
||
mesh.show(axes=1, viewup='z') | ||
show(mesh, __doc__, | ||
axes=dict(zLabelSize=.04, numberOfDivisions=10), | ||
elevation=-80, bg='blackboard', | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,36 @@ | ||
''' | ||
Mesh objects can be combined with | ||
(1) `mesh.merge` - creates a new mesh object; this new mesh inherits properties (color, etc.) of the first mesh. | ||
(2) `assembly.Assembly` - combines meshes (or other actors); preserves properties | ||
(2) `assembly.Assembly` - groups meshes (or other actors); preserves properties | ||
(3) `+` - equivalent to `Assembly` | ||
''' | ||
|
||
# credits: https://github.com/icemtel | ||
import vedo | ||
import numpy as np | ||
|
||
# Define vertices and faces | ||
verts = np.array([(0, 0, 0), (10, 0, 0), (0, 10, 0), (0, 0, 10)]) | ||
faces = np.array([(0, 1, 2), (2, 1, 3), (1, 0, 3), (0, 2, 3)]) | ||
verts = [(0, 0, 0), (10, 0, 0), (0, 10, 0), (0, 0, 10)] | ||
faces = [(0, 1, 2), (2, 1, 3), (1, 0, 3), (0, 2, 3)] | ||
# Create a tetrahedron and a copy | ||
mesh = vedo.Mesh([verts, faces], c='red') | ||
mesh2 = mesh.clone().x(15).y(15).c('blue') # Create a copy, shift it; change color | ||
mesh1 = vedo.Mesh([verts, faces], c='red') | ||
mesh2 = mesh1.clone().pos(15,15,0).c('blue') # Create a copy, position it; change color | ||
|
||
# Merge: creates a new mesh, color of the second mesh is lost | ||
mesh_all = vedo.merge(mesh, mesh2) | ||
# Merge: creates a new mesh, fusion of the 2 inputs. Color of the second mesh is lost. | ||
mesh_all = vedo.merge(mesh1, mesh2) | ||
print('1. Type:', type(mesh_all)) | ||
# Show | ||
plotter = vedo.show(mesh_all, viewup='z', axes=1) # -> all red | ||
plotter = vedo.show("mesh.merge(mesh1, mesh2) creates a single new Mesh object", | ||
mesh_all, viewup='z', axes=1) # -> all red | ||
plotter.close() | ||
|
||
# Assembly: groups meshes | ||
mesh_all = vedo.assembly.Assembly(mesh, mesh2) | ||
# Assembly: groups meshes. Objects keep their individuality (can be later unpacked). | ||
mesh_all = vedo.Assembly(mesh1, mesh2) | ||
print('2. Type:', type(mesh_all)) | ||
# Show | ||
plotter = vedo.show(mesh_all, viewup='z', axes=1) # -> red and blue | ||
plotter = vedo.show("Assembly(mesh1, mesh2) groups meshes preserving their properties", | ||
mesh_all, viewup='z', axes=1) # -> red and blue | ||
plotter.close() | ||
|
||
# Equivalently, "+" also creates an Assembly | ||
mesh_all = mesh + mesh2 | ||
mesh_all = mesh1 + mesh2 | ||
print('3. Type:', type(mesh_all)) | ||
# Show | ||
plotter = vedo.show(mesh_all, viewup='z', axes=1) # -> red and blue | ||
plotter = vedo.show("mesh1+mesh2 operator is equivalent to Assembly()", | ||
mesh_all, viewup='z', axes=1) # -> red and blue | ||
plotter.close() |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.