2019-06-06 09:58:14 +03:00
|
|
|
|
-- Example 17, pulled from our benchmarking suite.
|
2021-04-17 14:36:00 +03:00
|
|
|
|
import Control.Applicative (pure)
|
|
|
|
|
import Prelude ((<$>), ($), zipWith3, fmap, fromIntegral, (*), (/), Bool(..))
|
|
|
|
|
import Graphics.Implicit (cube, union, translate, writeSTL, V3(..))
|
2019-12-31 17:26:37 +03:00
|
|
|
|
import Graphics.Implicit.Definitions (Fastℕ, ℝ, ℝ3, SymbolicObj3)
|
2019-06-06 09:58:14 +03:00
|
|
|
|
|
|
|
|
|
default (Fastℕ, ℝ)
|
|
|
|
|
|
|
|
|
|
object2 :: SymbolicObj3
|
2021-04-17 14:36:00 +03:00
|
|
|
|
object2 = squarePipe (pure 10) 1 100
|
2019-06-06 09:58:14 +03:00
|
|
|
|
where
|
2019-12-31 17:26:37 +03:00
|
|
|
|
squarePipe :: ℝ3 -> ℝ -> ℝ -> SymbolicObj3
|
2021-04-17 14:36:00 +03:00
|
|
|
|
squarePipe (V3 x y z) diameter precision =
|
2019-06-06 09:58:14 +03:00
|
|
|
|
union
|
2020-12-05 12:25:01 +03:00
|
|
|
|
((\start -> translate start
|
2021-04-17 14:36:00 +03:00
|
|
|
|
$ cube True (pure diameter)
|
2019-12-31 20:18:25 +03:00
|
|
|
|
)
|
|
|
|
|
<$>
|
2021-04-17 14:36:00 +03:00
|
|
|
|
zipWith3
|
|
|
|
|
V3
|
|
|
|
|
(fmap (\n -> (fromIntegral n / precision) * x) [0..100])
|
|
|
|
|
(fmap (\n -> (fromIntegral n / precision) * y) [0..100])
|
|
|
|
|
(fmap (\n -> (fromIntegral n / precision) * z) [0..100]))
|
2019-06-06 09:58:14 +03:00
|
|
|
|
|
|
|
|
|
main = writeSTL 1 "example17.stl" object2
|