import static uk.co.nickthecoder.foocad.layout.v1.Layout2d.* import static uk.co.nickthecoder.foocad.layout.v1.Layout3d.* class Path : Model { val brick = Cube( 96, 196, 50 ).translate(2,2,0).label( "brick" ); val offset = 50//200/3 fun across() = brick + brick.translate( 100, offset, 0 ) + brick.translate( 200, offset*2, 0 ) + brick.translate( 300, offset*3, 0 ) + brick.translate( 400, offset*2, 0 ) + brick.translate( 500, offset, 0 ) + brick.translate( 600, 0, 0 ) fun path( length : int ) : Shape3d { return across().translate( 0, -200, 0 ).repeatY( length+1, 200 ) } fun croppedPath( length : int ) : Shape3d { return path( length ).intersection( Cube( 700, 200 * length, 2 + 50 ).translate(0,0,-1) ) } override fun build() : Shape3d { val foo = 0.41 val crop1 = PolygonBuilder() .moveTo( 0, 0 ) .lineTo( 700, 0 ) .lineTo( 700, 200 * 4 - 700 * foo - 40) .lineTo( 0, 200 * 4 - 40) .build().extrude(51).translate(0,0,-1) val crop2 = PolygonBuilder() .moveTo( 0, 0 ) .lineTo( 700, 700 * foo ) .lineTo( 700, 200 * 10) .lineTo( 0, 200 * 10 - 700 * foo ) .build().extrude(51).translate(0,0,-1) val crop3 = PolygonBuilder() .moveTo( 0, 700 * foo ) .lineTo( 700, 0 ) .lineTo( 700, 200 * 4) .lineTo( 0, 200 * 4 ) .build().extrude(51).translate(0,0,-1) return path( 4 ).intersection( crop1 ) + path( 11 ).translate(0,-50,0).intersection( crop2 ).rotate( 0,0,-45 ).translate( 0, 770, 0) + path( 4 ).translate(0,-50,0).intersection( crop3 ).translate( 1210, 1700, 0 ) } }