-
Notifications
You must be signed in to change notification settings - Fork 267
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
9 changed files
with
241 additions
and
40 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
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 |
---|---|---|
@@ -0,0 +1,55 @@ | ||
# Example of usage of the madcad library | ||
# See https://pymadcad.readthedocs.io/en/latest/index.html | ||
import vedo | ||
from madcad import * | ||
|
||
########################################################################## | ||
points = [O, X, X + Z, 2 * X + Z, 2 * (X + Z), X + 2 * Z, X + 5 * Z, 5 * Z] | ||
section = Wire(points).segmented().flip() | ||
rev = revolution(2 * pi, (O, Z), section) | ||
rev.mergeclose() | ||
vedo.show("Revolution of a wire", rev, axes=7).close() | ||
|
||
|
||
########################################################################## | ||
m = screw(10, 20) | ||
m["part"].option(color=vec3(70, 130, 180) / 255) # RGB | ||
vedo.show("A blue screw", m, axes=1).close() | ||
|
||
|
||
########################################################################## | ||
# Obtain two different shapes that has noting to to with each other | ||
m1 = brick(width=vec3(2)) | ||
m2 = m1.transform(vec3(0.5, 0.3, 0.4)).transform(quat(0.7 * vec3(1, 1, 0))) | ||
# Remove the volume of the second to the first | ||
diff = difference(m1, m2) | ||
vedo.show("Boolean difference", diff, axes=14).close() | ||
|
||
|
||
########################################################################## | ||
cube = brick(width=vec3(2)) | ||
bevel( | ||
cube, | ||
[(0, 1), (1, 2), (2, 3), (0, 3), (1, 5), (0, 4)], # Edges to smooth | ||
("width", 0.3), # Cutting description, known as 'cutter' | ||
) | ||
vedo.show("A bevel cube", cube, axes=1).close() | ||
|
||
|
||
########################################################################## | ||
square_profile = square((O, Z), 5).flip() | ||
primitives = [ | ||
ArcCentered((5 * X, Y), O, 10 * X), | ||
ArcCentered((15 * X, -Y), 10 * X, 20 * X), | ||
] | ||
# Generate a path | ||
path = web(primitives) | ||
path.mergeclose() | ||
m = tube(square_profile, path) | ||
|
||
vmesh = vedo.utils.madcad2vedo(m) # <-- convert to vedo.Mesh | ||
print(vmesh) | ||
|
||
scalar = vmesh.vertices[:, 0] | ||
vmesh.cmap("rainbow", scalar).add_scalarbar(title="x-value") | ||
vedo.show("Generating a path", vmesh, axes=7).close() |
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 |
---|---|---|
@@ -0,0 +1,20 @@ | ||
"""Use slab() to extract a "thick" 2D slice from a 3D volume""" | ||
from vedo import Axes, Volume, Box, dataurl, settings, show | ||
from vedo.pyplot import histogram | ||
|
||
settings.default_font = "Calco" | ||
|
||
vol = Volume(dataurl + "embryo.tif") | ||
vaxes = Axes(vol, xygrid=False) | ||
|
||
slab = vol.slab([45,55], axis='z', operation='mean') | ||
slab.cmap('Set1_r', vmin=10, vmax=80).add_scalarbar("intensity") | ||
# histogram(slab).show().close() # quickly inspect it | ||
|
||
bbox = slab.metadata["slab_bounding_box"] | ||
slab.z(-bbox[5] + vol.zbounds()[0]) # move slab to the bottom | ||
|
||
# create a box around the slab for reference | ||
slab_box = Box(bbox).wireframe().c("black") | ||
|
||
show(__doc__, vol, slab, slab_box, vaxes, axes=14, viewup='z') |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
_version = '2023.5.0+dev6' | ||
_version = '2023.5.0+dev7' |
Oops, something went wrong.