Fix build and freeze

This commit is contained in:
Julian Ospald
2019-12-05 12:19:55 +08:00
parent cfb428a70e
commit 8643826810
8 changed files with 202 additions and 118 deletions

View File

@@ -1,6 +1,6 @@
{-# OPTIONS_HADDOCK ignore-exports #-}
module Parser.Meshparser (meshToArr, facesToArr) where
module Parser.Meshparser (meshToArr, facesToArr, parseObj) where
import Control.Applicative
import Data.Attoparsec.ByteString.Char8
@@ -9,13 +9,8 @@ import qualified Data.ByteString.Char8 as B
import Diagrams.TwoD.Types
-- |Convert a text String with multiple vertices and faces into
-- a list of vertices, ordered by the faces specification.
facesToArr :: B.ByteString -> [[P2 Double]]
facesToArr str = fmap (fmap (\y -> meshToArr str !! (fromIntegral y - 1)))
(faces str)
where
faces = rights . fmap (parseOnly parseFace) . B.lines
facesToArr :: B.ByteString -> [[Int]]
facesToArr = rights . fmap (parseOnly parseFace) . B.lines
-- |Convert a text String with multiple vertices into
@@ -37,5 +32,14 @@ parseVertice =
<*> (many' space *> double)
parseFace :: Parser [Integer]
parseFace :: Parser [Int]
parseFace = char 'f' *> many1' (many' space *> decimal)
-- |Convert a text String with multiple vertices and faces into
-- a list of vertices, ordered by the faces specification.
parseObj :: B.ByteString -> [[P2 Double]]
parseObj str = fmap (fmap (\y -> meshToArr str !! (fromIntegral y - 1)))
(faces str)
where
faces = rights . fmap (parseOnly parseFace) . B.lines