Files
loop/src/Shape/Data.hs
T

50 lines
1.3 KiB
Haskell

{-# LANGUAGE DeriveGeneric #-}
{-# OPTIONS_GHC -Wno-missing-signatures #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE DerivingStrategies #-}
{-# LANGUAGE GeneralisedNewtypeDeriving #-}
module Shape.Data
where
import Geometry.Data
import GHC.Generics
import Data.Aeson
import Control.Lens
import Streaming
type Shape' = Stream (Of ShapeObj) IO ()
type Shape = [ShapeObj]
{-# INLINE shVfromList #-}
shVfromList = id
{-# INLINE shEfromList #-}
shEfromList = id
data ShapeObj = ShapeObj
{ _shType :: ShapeType
, _shVs :: [ShapeV]
}
deriving (Eq,Ord,Show,Read,Generic)
instance ToJSON ShapeObj where
toEncoding = genericToEncoding defaultOptions
instance FromJSON ShapeObj
newtype ShapeType = TopPrism Int
deriving (Eq,Ord,Show,Read,Generic)
instance ToJSON ShapeType where
toEncoding = genericToEncoding defaultOptions
instance FromJSON ShapeType
-- edges are given by four consecutive points
data ShapeV = ShapeV
{_svPos :: Point3
,_svCol :: Point4
}
deriving (Eq,Ord,Show,Read,Generic)
instance ToJSON ShapeV where
toEncoding = genericToEncoding defaultOptions
instance FromJSON ShapeV
pairToSV :: (Point3,Point4) -> ShapeV
{-# INLINE pairToSV #-}
pairToSV = uncurry ShapeV
makeLenses ''ShapeV
makeLenses ''ShapeObj