paintAlongHullTest.frink

Download or view paintAlongHullTest.frink in plain text format


/** This program tests the VoxelArray.paintAlong hull method for 3D printing.
    This expands or contracts an object by moving a tool around its hull.  This
    is sometimes called the Minkowski sum operation in some modeling packages.
*/


sides = 7
angle = 90 deg  // Point at top
outerRadius = .5 in

res = 254/in

polygon = callJava["frink.graphics.Point2DFloatList", "makeRegularPolygon", [sides, outerRadius res, angle]]

v = callJava["frink.graphics.VoxelArray", "extrudeZTapered", [polygon, 0 in res, 1 in res, 1, .5]]


// Double-cone tool
th = .1 in
tr = .1 in
t1 = callJava["frink.graphics.VoxelArray", "makeTaperedCylinder", [0,0,0,0,0,th res, tr res, 0]]
t2 = callJava["frink.graphics.VoxelArray", "makeTaperedCylinder", [0,0,0,0,0,-th res, tr res, 0]]
doubleConeTool = t1.union[t2]

// Spherical tool
sphereTool = callJava["frink.graphics.VoxelArray", "makeSphere", [.1 in res]]

// Double-cone with flat sides tool
th = .1 in
tr = .1 in
flatHeight = .1 in
t1 = callJava["frink.graphics.VoxelArray", "makeTaperedCylinder", [0,0,flatHeight/2 res,0,0,(th+flatHeight/2) res, tr res, 0]]
t2 = callJava["frink.graphics.VoxelArray", "makeTaperedCylinder", [0,0,-flatHeight/2 res,0,0,-(th + flatHeight/2) res, tr res, 0]]
flat = callJava["frink.graphics.VoxelArray", "makeCylinder", [0,0,flatHeight/2 res,0,0,-flatHeight/2 res, tr res]]
doubleConeWithFlatSidesTool = t1.union[t2].union[flat]


v = v.paintAlongHull[sphereTool, 0,0,0, true]

v.projectX[undef].show["X"]
v.projectY[undef].show["Y"]
v.projectZ[undef].show["Z"]

filename = "paintAlongHullTest.obj"
print["Writing $filename..."]
w = new Writer[filename]
w.println[v.toObjFormat["hull", 1/(res mm)]]
w.close[]
println["done."]


Download or view paintAlongHullTest.frink in plain text format


This is a program written in the programming language Frink.
For more information, view the Frink Documentation or see More Sample Frink Programs.

Alan Eliasen was born 20218 days, 0 hours, 14 minutes ago.