import static uk.co.nickthecoder.foocad.layout.v1.Layout2d.* import static uk.co.nickthecoder.foocad.layout.v1.Layout3d.* import static uk.co.nickthecoder.foocad.chamferedextrude.v1.ChamferedExtrude.* class TowelRail : Model { var thickness = 10 var depth = 5 var capSize = 20 var chamfer = 1 var poleD = 37 var stickerDepth = 5 fun thicken( shape : Shape2d ) = thicken( shape, depth ) fun thicken( shape : Shape2d, depth : double ) : Shape3d { return shape.firstPath.thickness( thickness ).chamferedExtrude( depth, chamfer ) } @Piece fun mirror() = build().mirrorX() @Piece fun stickers() = (Circle( poleD/2 ).chamferedExtrude( stickerDepth, stickerDepth/2, 0) - Cylinder( stickerDepth, 5 ).translateZ( 1 )).tileX(2,2) override fun build() : Shape3d { val shapes = SVGParser().parseFile( "towelRail.svg" ).shapes val a = thicken( shapes["a"], depth*2 ) val b = thicken( shapes["b"] ) val c = thicken( shapes["c"] ) val d = thicken( shapes["d"] ) val cap = shapes["cap"].chamferedExtrude( capSize, chamfer ) val pos = shapes["cap"].middle val recess = Circle(poleD/2).translate( pos ) .extrude(capSize*2) .translateZ(depth/2) val hole = Circle( 2 ).translate( pos ).extrude( depth * 2 ).centerZ() val end = Circle( thickness/2 ).translate( shapes["a"].firstPath.reverse().points[0] ).chamferedExtrude( depth*2, chamfer ) val all = (a+b+c+d + cap + end - recess - hole).centerXY() return all } }