/Bathroom/LooRollBin.foocad

A bin for toilet rolls.
The final size includes a margin, so rollSize can be exact.
This matches Bin.foocad.
import static uk.co.nickthecoder.foocad.layout.v1.Layout2d.*
import static uk.co.nickthecoder.foocad.layout.v1.Layout3d.*
include Bin.foocad
class LooRollBin : Model {
// The rolls I buy are 100x100
@Custom( about="Diameter and height of a loo roll" )
var rollSize = Vector2( 100, 100 )
@Custom( about="Number of rolls high" )
var rollsZ = 2
@Custom
var margin = Vector2( 10, 10 )
fun bin() = CustomBin( rollSize, margin ).apply {
size = Vector3(
rollSize.x,
rollSize.x,
rollSize.y * rollsZ + margin.y + lidHeight + lipSize.y + thickness
)
}
@Piece
fun knob() = bin().knob()
@Piece
fun main() = bin().main()
@Piece
fun lid() = bin().lid()
@Piece
fun foot() = bin().foot()
override fun build() : Shape3d {
val bin = bin()
val rolls = Cylinder( rollSize.y, rollSize.x / 2 )
.tileX(2, 5)
.tileZ(rollsZ)
.bottomTo( bin.baseThickness )
.centerX()
.previewOnly()
return bin.build() + rolls
}
}
/**
* Changes the cross-section of the bin from a circle to
* something appropriate to hold 2 loo rolls next to each other.
*/
class CustomBin( val rollSize : Vector2, val margin : Vector2 ) : Bin() {
override fun profile() : Shape2d {
val one = Circle( rollSize.x / 2 + margin.x + thickness ).leftTo(0)
return one hull one.mirrorX()
}
}

