Created
July 16, 2018 18:02
-
-
Save brlcad/7de8f35386c9e40075c07a708fc9aed5 to your computer and use it in GitHub Desktop.
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
import sys | |
from brlcad.primitives import union | |
argv = sys.argv | |
c_length = argv[2] | |
c_radius = argv[3] | |
rounding_radius = argv[4] | |
if rounding_radius > c_radius/2: | |
raise ValueError("Rounding Radius cannot be larger than 0.5 * Cylinder Radius") | |
exit() | |
if rounding_radius > c_length/2: | |
raise ValueError("Rounding Radius cannot be larger than 0.5 * Cylinder Height") | |
exit() | |
origin = (0, 0, 0) | |
base = (0, 0, rounding_radius) | |
filler = (0, 0, c_length) | |
top_tor = (0, 0, c_length - rounding_radius) | |
height = (0, 0, c_length - 2 * rounding_radius) | |
neg_z_dir, pos_z_dir = (0, 0, -1), (0, 0, 1) | |
db = brlcad.wdb.WDB(argv[1], "rounded cylinder!") | |
db.rcc("cylinder.rcc", base, height, c_radius) | |
db.rcc("fillend.rcc", origin, filler, c_radius - rounding_radius) | |
db.torus("bottom.tor", base, neg_z_dir, c_radius - rounding_radius, rounding_radius) | |
db.torus("top.tor", top_tor, pos_z_dir, c_radius - rounding_radius, rounding_radius) | |
db.combination("cylinder3.r", is_region=False, tree=union("cylinder.rcc", "fillend.rcc", "top.tor",\ | |
"bottom.tor")) | |
db.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment