{-# LANGUAGE InstanceSigs #-}
module Geometry.ConvexHull.Types
  where
import           Data.IntMap.Strict   ( IntMap )
import qualified Data.IntMap.Strict   as IM
import           Data.IntSet          ( IntSet )
import           Geometry.Qhull.Types ( HasCenter(..)
                                      , HasVolume(..)
                                      , HasEdges(..)
                                      , HasVertices(..)
                                      , HasNormal(..)
                                      , HasFamily(..)
                                      , Family
                                      , EdgeMap
                                      , IndexSet
                                      , IndexMap )

data Vertex = Vertex {
    Vertex -> [Double]
_point         :: [Double]
  , Vertex -> IntSet
_neighfacets   :: IntSet
  , Vertex -> IntSet
_neighvertices :: IndexSet
  , Vertex -> IntSet
_neighridges   :: IntSet
} deriving Int -> Vertex -> ShowS
[Vertex] -> ShowS
Vertex -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Vertex] -> ShowS
$cshowList :: [Vertex] -> ShowS
show :: Vertex -> String
$cshow :: Vertex -> String
showsPrec :: Int -> Vertex -> ShowS
$cshowsPrec :: Int -> Vertex -> ShowS
Show

data Ridge = Ridge {
    Ridge -> IndexMap [Double]
_rvertices :: IndexMap [Double]
  , Ridge -> IntSet
_ridgeOf   :: IntSet
  , Ridge -> EdgeMap
_redges    :: EdgeMap
} deriving Int -> Ridge -> ShowS
[Ridge] -> ShowS
Ridge -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Ridge] -> ShowS
$cshowList :: [Ridge] -> ShowS
show :: Ridge -> String
$cshow :: Ridge -> String
showsPrec :: Int -> Ridge -> ShowS
$cshowsPrec :: Int -> Ridge -> ShowS
Show

instance HasVertices Ridge where
  _vertices :: Ridge -> IndexMap [Double]
  _vertices :: Ridge -> IndexMap [Double]
_vertices = Ridge -> IndexMap [Double]
_rvertices

instance HasEdges Ridge where
  _edges :: Ridge -> EdgeMap
  _edges :: Ridge -> EdgeMap
_edges = Ridge -> EdgeMap
_redges

data Facet = Facet {
    Facet -> IndexMap [Double]
_fvertices    :: IndexMap [Double]
  , Facet -> IntSet
_fridges      :: IntSet
  , Facet -> [Double]
_centroid     :: [Double]
  , Facet -> [Double]
_normal'      :: [Double]
  , Facet -> Double
_offset'      :: Double
  , Facet -> Int
_orientation' :: Int
  , Facet -> Double
_area         :: Double
  , Facet -> IntSet
_neighbors    :: IntSet
  , Facet -> Family
_family'      :: Family
  , Facet -> EdgeMap
_fedges       :: EdgeMap
} deriving Int -> Facet -> ShowS
[Facet] -> ShowS
Facet -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Facet] -> ShowS
$cshowList :: [Facet] -> ShowS
show :: Facet -> String
$cshow :: Facet -> String
showsPrec :: Int -> Facet -> ShowS
$cshowsPrec :: Int -> Facet -> ShowS
Show

instance HasCenter Facet where
  _center :: Facet -> [Double]
  _center :: Facet -> [Double]
_center = Facet -> [Double]
_centroid

instance HasEdges Facet where
  _edges :: Facet -> EdgeMap
  _edges :: Facet -> EdgeMap
_edges = Facet -> EdgeMap
_fedges

instance HasVertices Facet where
  _vertices :: Facet -> IndexMap [Double]
  _vertices :: Facet -> IndexMap [Double]
_vertices = Facet -> IndexMap [Double]
_fvertices

instance HasNormal Facet where
  _normal :: Facet -> [Double]
  _normal :: Facet -> [Double]
_normal = Facet -> [Double]
_normal'
  _offset :: Facet -> Double
  _offset :: Facet -> Double
_offset = Facet -> Double
_offset'

instance HasVolume Facet where
  _volume :: Facet -> Double
  _volume :: Facet -> Double
_volume = Facet -> Double
_area

instance HasFamily Facet where
  _family :: Facet -> Family
  _family :: Facet -> Family
_family = Facet -> Family
_family'

data ConvexHull = ConvexHull {
    ConvexHull -> IndexMap Vertex
_hvertices  :: IndexMap Vertex
  , ConvexHull -> IntMap Facet
_hfacets    :: IntMap Facet
  , ConvexHull -> IntMap Ridge
_hridges    :: IntMap Ridge
  , ConvexHull -> EdgeMap
_hedges     :: EdgeMap
  , ConvexHull -> Bool
_simplicial :: Bool
  , ConvexHull -> Int
_dimension  :: Int
} deriving Int -> ConvexHull -> ShowS
[ConvexHull] -> ShowS
ConvexHull -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ConvexHull] -> ShowS
$cshowList :: [ConvexHull] -> ShowS
show :: ConvexHull -> String
$cshow :: ConvexHull -> String
showsPrec :: Int -> ConvexHull -> ShowS
$cshowsPrec :: Int -> ConvexHull -> ShowS
Show

instance HasEdges ConvexHull where
  _edges :: ConvexHull -> EdgeMap
  _edges :: ConvexHull -> EdgeMap
_edges = ConvexHull -> EdgeMap
_hedges

instance HasVertices ConvexHull where
  _vertices :: ConvexHull -> IndexMap [Double]
  _vertices :: ConvexHull -> IndexMap [Double]
_vertices ConvexHull
hull = forall a b. (a -> b) -> IntMap a -> IntMap b
IM.map Vertex -> [Double]
_point (ConvexHull -> IndexMap Vertex
_hvertices ConvexHull
hull)