FooCAD Source Codeimport static uk.co.nickthecoder.foocad.layout.Debug.*
class SheetEdge : Model {
val name = "Sheet Edge"
var sheetThickness = 4 // Including any slack
val slotDepth = 5
val thickness = 2
val radius = 8
val roundedSides = 8
fun profile2() : Shape2d {
val width = slotDepth + thickness*2 + sheetThickness
val shape = PolygonBuilder().apply {
moveTo(0,0)
lineTo(width,0)
lineTo(width, width)
lineTo(width-thickness, width)
lineTo(width-thickness, width-slotDepth)
lineTo(width-thickness-sheetThickness, width-slotDepth)
lineTo(width-thickness-sheetThickness, width)
lineTo(slotDepth, width)
lineTo(slotDepth, width-slotDepth)
lineTo(0, width-slotDepth)
lineTo(0, thickness + sheetThickness )
lineTo(slotDepth, thickness + sheetThickness )
lineTo(slotDepth, thickness)
lineTo(0,thickness)
}.build()
return if (roundedSides > 0) {
shape.roundCorner(1, radius, roundedSides)
} else {
shape
}
}
fun plainProfile() : Shape2d {
val width = slotDepth + thickness*2 + sheetThickness
val shape = PolygonBuilder().apply {
moveTo(0,0)
lineTo(width,0)
lineTo(width, width)
lineTo(slotDepth,width)
//lineTo(slotDepth,width-slotDepth)
lineTo(0,width-slotDepth)
}.build()
return if (roundedSides > 0) {
shape.roundCorner(1, radius, roundedSides)
} else {
shape
}
}
fun lumber() = Lumber( name, plainProfile() )
fun plain(length : double) : Shape3d {
return lumber().cut(length)
}
fun mitred(length : double) : Shape3d {
val lumber = lumber()
val result = lumber.cut( length )
.cutZRatio( MitreJoint( lumber, 1 ), 0 )
.cutZRatio( MitreJoint( lumber, 1 ).otherEnd(), 1 )
return result
}
fun corner() : Shape3d {
return plainProfile().revolve(90).sides(roundedSides*8)
}
override fun build() : Shape3d {
val plain = plain(104).rotateZ(-90).toOrigin().center()
//val corner = corner(30,20)
val end = plain.translateX(-60).mirrorX().also() +
plain.rotateY(90).translateZ(60).mirrorZ().also()
val edges = plain.rotateX(90).translate(-60,0,-60).mirrorX().also()
.mirrorZ().also()
val square = PolygonBuilder().apply {
moveTo(140,0)
lineTo(0,0)
lineTo(0,140)
}.build().roundAllCorners(3) // Square(100).roundAllCorners(3)
val side = plainProfile().mirrorY().extrude( square ).toOrigin()
val cube = corner().translate(60-9,60-9,-60-9).color("Green") +
edges + end.translateY(-60).mirrorY().also()
val all = side + side.rotateY(90).mirrorZ() + side.rotateX(90).mirrorY()
val foo = thickness*2 + sheetThickness //slotDepth
val glass = Cube( 50,50, sheetThickness ).color("Red")
.translate(foo, foo,thickness)
val glasses = glass + glass.rotateX(90).mirrorY() + glass.rotateY(90).mirrorZ()
val cut = all - glasses
return cut.intersection( Cube(30) )
}
}