Move from store to flat

This commit is contained in:
2022-08-20 17:54:35 +01:00
parent 8571ab9254
commit ff9dbdf068
95 changed files with 793 additions and 748 deletions
+40 -28
View File
@@ -1,20 +1,25 @@
{-# LANGUAGE DeriveAnyClass #-}
{-# LANGUAGE DeriveGeneric #-}
{-# OPTIONS_GHC -Wno-missing-signatures #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE DerivingStrategies #-}
{-# LANGUAGE GeneralisedNewtypeDeriving #-}
module Shape.Data
where
import LinearHelp
import Geometry.Data
import GHC.Generics
import Data.Aeson
{-# LANGUAGE StrictData #-}
{-# LANGUAGE TemplateHaskell #-}
{-# OPTIONS_GHC -Wno-missing-signatures #-}
module Shape.Data where
import Control.Lens
import Data.Aeson
import Data.Store
import Flat
import GHC.Generics
import Geometry.Data
import LinearHelp
import Streaming
import TH.Derive
import Data.Store
type Shape' = Stream (Of ShapeObj) IO ()
type Shape = [ShapeObj]
{-# INLINE shVfromList #-}
@@ -23,33 +28,40 @@ shVfromList = id
{-# INLINE shEfromList #-}
shEfromList = id
data ShapeObj = ShapeObj
{ _shType :: ShapeType
, _shVs :: [ShapeV]
data ShapeObj = ShapeObj
{ _shType :: ShapeType
, _shVs :: [ShapeV]
}
deriving (Eq,Ord,Show,Read,Generic)
instance ToJSON ShapeObj where
deriving (Eq, Ord, Show, Read, Generic, Flat)
instance ToJSON ShapeObj where
toEncoding = genericToEncoding defaultOptions
instance FromJSON ShapeObj
instance FromJSON ShapeObj
newtype ShapeType = TopPrism Int
deriving (Eq,Ord,Show,Read,Generic)
instance ToJSON ShapeType where
deriving (Eq, Ord, Show, Read, Generic, Flat)
instance ToJSON ShapeType where
toEncoding = genericToEncoding defaultOptions
instance FromJSON ShapeType
instance FromJSON ShapeType
-- edges are given by four consecutive points
data ShapeV = ShapeV
{_svPos :: Point3
,_svCol :: Point4
{ _svPos :: Point3
, _svCol :: Point4
}
deriving (Eq,Ord,Show,Read,Generic)
instance ToJSON ShapeV where
deriving (Eq, Ord, Show, Read, Generic, Flat)
instance ToJSON ShapeV where
toEncoding = genericToEncoding defaultOptions
instance FromJSON ShapeV
pairToSV :: (Point3,Point4) -> ShapeV
instance FromJSON ShapeV
pairToSV :: (Point3, Point4) -> ShapeV
{-# INLINE pairToSV #-}
pairToSV = uncurry ShapeV
makeLenses ''ShapeV
makeLenses ''ShapeObj
$($(derive [d| instance Deriving (Store ShapeV) |]))
$($(derive [d| instance Deriving (Store ShapeObj) |]))
$($(derive [d| instance Deriving (Store ShapeType) |]))