{-# OPTIONS_GHC -Wno-missing-signatures #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE DerivingStrategies #-}
{-# LANGUAGE GeneralisedNewtypeDeriving #-}
module Shape.Data
    where
import Geometry.Data

--import Data.Vector.Fusion.Util
import Control.Lens
import Streaming
type Shape = Stream (Of ShapeObj) IO ()

--_shVertices :: Shape -> [ShapeV]
--{-# INLINE _shVertices #-}
--_shVertices = concatMap _shVs

--shVList :: Shape -> [ShapeV]
--{-# INLINE shVList #-}
--shVList = _shVertices
--shVList = DL.toList . _shVertices

{-# INLINE shVfromList #-}
shVfromList = id
--shVfromList = DL.fromList
{-# INLINE shEfromList #-}
shEfromList = id
--shEfromList = DL.fromList

data ShapeObj = ShapeObj 
    { _shType :: ShapeType 
    , _shVs :: Stream (Of ShapeV) IO ()
    }
  deriving ()

newtype ShapeType = TopPrism Int
  deriving (Eq,Ord,Show)

-- edges are given by four consecutive points
data ShapeV = ShapeV
    {_svPos :: Point3
    ,_svCol :: Point4
    }
  deriving (Eq,Ord,Show)
pairToSV :: (Point3,Point4) -> ShapeV
{-# INLINE pairToSV #-}
pairToSV = uncurry ShapeV
makeLenses ''ShapeV
