Skip to content

Commit

Permalink
fixup! Add canonicalization pass
Browse files Browse the repository at this point in the history
  • Loading branch information
sorki committed Nov 6, 2023
1 parent b6694ee commit ec6482e
Showing 1 changed file with 40 additions and 29 deletions.
69 changes: 40 additions & 29 deletions Graphics/Implicit/Canon.hs
Original file line number Diff line number Diff line change
Expand Up @@ -28,58 +28,66 @@ module Graphics.Implicit.Canon
, rewriteUntilIrreducible
) where

import Linear
( V2(V2)
, V3(V3)
, V4(V4)
)

import Prelude
( Bool(True)
, Eq((==))
, Maybe(Just)
, Num((*), (+))
, Num
( (*)
, (+)
)
, Ord((<))
, length
, ($)
, (<$>)
, length
)
import Linear (V2(V2), V3(V3), V4(V4))

import Graphics.Implicit.Definitions
( SharedObj
( Empty
, Full
, Complement
, UnionR
( ExtrudeMScale
( C1
, C2
, Fn
)
, SharedObj
( Complement
, DifferenceR
, EmbedBoxedObj
, Empty
, Full
, IntersectR
, Translate
, Scale
, Mirror
, Outset
, Scale
, Shell
, EmbedBoxedObj
, Translate
, UnionR
, WithRounding
)
, SymbolicObj2
( Square
, Circle
( Circle
, Polygon
, Rotate2
, Transform2
, Shared2
, Square
, Transform2
)
, SymbolicObj3
( Cube
, Sphere
, Cylinder
, Rotate3
, Transform3
, Extrude
, ExtrudeM
, RotateExtrude
, ExtrudeOnEdgeOf
, Rotate3
, RotateExtrude
, Shared3
)
, ExtrudeMScale
( C1
, C2
, Fn
, Sphere
, Transform3
)
, hasZeroComponent
)
Expand All @@ -89,7 +97,10 @@ import {-# SOURCE #-} Graphics.Implicit.Primitives
, fullSpace
)

import Control.Lens (preview, (#))
import Control.Lens
( preview
, (#)
)

-- $setup
-- >>> import Prelude (id, pure)
Expand Down Expand Up @@ -166,12 +177,12 @@ fmapObj2
-> (forall obj f a . (Object obj f a) => obj -> obj) -- ^ Shared2|3 transformation
-> SymbolicObj2
-> SymbolicObj2
fmapObj2 f _ _ (Square v) = f $ Square v
fmapObj2 f _ _ (Circle r) = f $ Circle r
fmapObj2 f _ _ (Polygon ps) = f $ Polygon ps
fmapObj2 f g s (Rotate2 r o) = f $ Rotate2 r (fmapObj2 f g s o)
fmapObj2 f _ _ (Square v) = f $ Square v
fmapObj2 f _ _ (Circle r) = f $ Circle r
fmapObj2 f _ _ (Polygon ps) = f $ Polygon ps
fmapObj2 f g s (Rotate2 r o) = f $ Rotate2 r (fmapObj2 f g s o)
fmapObj2 f g s (Transform2 m o) = f $ Transform2 m (fmapObj2 f g s o)
fmapObj2 f g s (Shared2 o) = fmapSharedObj (fmapObj2 f g s) s (Shared2 o)
fmapObj2 f g s (Shared2 o) = fmapSharedObj (fmapObj2 f g s) s (Shared2 o)

-- | Map over @SymbolicObj3@ and its underlying shared objects
--
Expand Down

0 comments on commit ec6482e

Please sign in to comment.