Download or view floodFillTest.frink in plain text format
/** This tests the "flood fill" routines in VoxelArray which can be used to
calculate volumes of tricky shapes. */
res = 254/in
thickness = 1.2 mm
innerDiam = 2 inch
outer = callJava["frink.graphics.VoxelArray", "makeSphere", [(innerDiam/2 + thickness) res]]
inner = callJava["frink.graphics.VoxelArray", "makeSphere", [innerDiam/2 res]]
outer.remove[inner]
start = now[]
inside = outer.floodFill[outer.getMinX[], outer.getMaxX[],
outer.getMinY[], outer.getMaxY[],
outer.getMinZ[], outer.getMaxZ[],
0,0,0]
end = now[]
println["Time in flood fill was " + format[end-start, "ms", 0]]
vol = inside.countSetBits[]
println["Volume is $vol voxels"]
physvol = vol / res^3
calcvol = 4/3 pi (innerDiam/2)^3
println["Physical Volume is " + format[physvol, "in^3", 7]]
println["Calculated Volume is " + format[calcvol, "in^3", 7]]
error = abs[physvol-calcvol]/calcvol
print["Error is " + format[error, "percent", 5]]
println[" (1 part in " + round[1/error] + ")"]
inside.projectX[undef].show["X"]
inside.projectY[undef].show["Y"]
inside.projectZ[undef].show["Z"]
filename = "floodFillTest.obj"
print["Writing $filename..."]
w = new Writer[filename]
w.println[inside.toObjFormat["inside", 1/(res mm)]]
w.close[]
println["done."]
Download or view floodFillTest.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 20143 days, 11 hours, 38 minutes ago.