1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
import Graphics.OpenSCAD
data Shelf = Shelf {
width :: Double,
depth :: Double,
boardThickness :: Double,
shelfHeights :: [Double]
} deriving (Show)
myShelf :: Shelf
myShelf = Shelf { width = 36, depth = 8, boardThickness = 1,
shelfHeights = [12, 12, 10, 10, 6, 6, 6] }
modelShelf :: Shelf -> [Model3d]
modelShelf s =
let sidesPos = [(0,0,0), (boardThickness s + width s, 0, 0)]
shelvesPos = let ys = scanl (+) 0 [h + boardThickness s|h <- shelfHeights s]
in [ (boardThickness s, 0, y) | y <- ys ]
place board places = map (\p -> translate p board) places
in place sideBoard sidesPos ++ place shelfBoard shelvesPos
where shelfHeight = sum (shelfHeights s) + (boardThickness s) *
(fromIntegral (length $ shelfHeights s) + 1)
sideBoard = box (boardThickness s) (depth s) shelfHeight
shelfBoard = box (width s) (depth s) (boardThickness s)
main :: IO ()
main = drawL $ modelShelf myShelf
|