cap.hs
#!/usr/bin/env stack
{- stack script --resolver lts-22.6
--package linear
--package waterfall-cad
--extra-dep waterfall-cad-0.3.0.0
--extra-dep opencascade-hs-0.3.0.0
-}
{--
This is a Haskell Stack script, it's executable, and needs the Haskell Stack Build Tool installed to work.
http://docs.haskellstack.org/en/stable/
On Linux, you'll need to install opencascade before running this.
On Debian based systems, this can be done with the following command:
sudo apt-get install libocct-data-exchange-7.6 libocct-data-exchange-dev libocct-draw-7.6 libocct-draw-dev libocct-foundation-7.6 libocct-foundation-dev libocct-modeling-algorithms-7.6 libocct-modeling-algorithms-dev libocct-modeling-data-7.6 libocct-modeling-data-dev libocct-ocaf-7.6 libocct-ocaf-dev libocct-visualization-7.6 libocct-visualization-dev occt-misc
On Macos, you should be able to install OpenCASCADE via homebrew:
brew install opencascade
On Macos, you'll also need to configure the path to the OpenCASCADE header files, either via extra-include-dirs, or CPATH:
export CPATH=$CPATH:/usr/local/Cellar/opencascade/7.*/include/opencascade/
--}
import qualified Waterfall
import Linear
import Data.Function ((&))
object :: Waterfall.Solid
=
object let cubeBelow =
&
Waterfall.centeredCube -0.5 *^ unit _z) &
Waterfall.translate (3
Waterfall.uScale = (`Waterfall.difference` cubeBelow)
removeBottom = removeBottom $ Waterfall.unitSphere
dome =
brim 0.05 $ Waterfall.fromPath $ Waterfall.pathFrom (V2 0 1)
Waterfall.prism V2 1 1)
[ Waterfall.lineTo (V2 1.6 1) (V2 1.75 0.4)(V2 1.75 0)
, Waterfall.bezierTo (V2 1.75 (-0.4)) (V2 1.6 (-1)) (V2 1 (-1))
, Waterfall.bezierTo (V2 0 (-1))
, Waterfall.lineTo (V2 0 1)
, Waterfall.lineTo (
]= Waterfall.uScale 0.95 Waterfall.unitSphere
headspace =
bandgap &
Waterfall.centeredCylinder V3 0.3 0.4 1) &
Waterfall.scale (pi/2) &
Waterfall.rotate (unit _y) (&
removeBottom V3 (-1) 0 0.1)
Waterfall.translate (in mconcat [dome, brim] `Waterfall.difference` mconcat [headspace, bandgap]
main :: IO ()
= Waterfall.writeSTL 0.01 "cap.stl" object
main