diff --git a/CLI/Gif.hs b/CLI/Gif.hs index bed80ba..fc30601 100644 --- a/CLI/Gif.hs +++ b/CLI/Gif.hs @@ -2,6 +2,7 @@ module CLI.Gif where +import qualified Data.ByteString.Char8 as B import Diagrams.Backend.Cairo.CmdLine import Graphics.Diagram.Gif import MyPrelude @@ -9,5 +10,5 @@ import MyPrelude gifCLI :: FilePath -> IO () gifCLI _ = do - mesh <- readFile "UB1_sonderfaelle.obj" + mesh <- B.readFile "UB1_sonderfaelle.obj" gifMain (gifDiagS def mesh) diff --git a/GUI/Gtk.hs b/GUI/Gtk.hs index ad6f7e7..0262241 100644 --- a/GUI/Gtk.hs +++ b/GUI/Gtk.hs @@ -5,6 +5,7 @@ module GUI.Gtk (makeGUI) where import Control.Applicative import Control.Monad(unless) import Control.Monad.IO.Class +import qualified Data.ByteString.Char8 as B import Diagrams.Prelude import Diagrams.Backend.Cairo import Diagrams.Backend.Cairo.Internal @@ -235,7 +236,7 @@ saveAndDrawDiag :: FilePath -- ^ obj file to parse saveAndDrawDiag fp fps mygui = if (==) ".obj" . takeExtension $ fp then do - mesh <- readFile fp + mesh <- B.readFile fp mainDrawWindow <- widgetGetDrawWindow (mainDraw mygui) treeDrawWindow <- widgetGetDrawWindow (treeDraw mygui) adjustment <- rangeGetAdjustment (ptScale mygui) diff --git a/Graphics/Diagram/Gif.hs b/Graphics/Diagram/Gif.hs index 454e6f4..765bc1d 100644 --- a/Graphics/Diagram/Gif.hs +++ b/Graphics/Diagram/Gif.hs @@ -5,6 +5,7 @@ module Graphics.Diagram.Gif where import Algebra.VectorTypes import Algorithms.ConvexHull.GrahamScan import Codec.Picture.Gif +import qualified Data.ByteString.Char8 as B import Data.Monoid import Diagrams.Backend.Cairo import Diagrams.Prelude hiding ((<>)) @@ -33,5 +34,5 @@ gifDiag p xs = -- |Same as gifDiag, except that it takes a string containing the -- mesh file content instead of the the points. -gifDiagS :: DiagProp -> MeshString -> [(Diagram Cairo R2, GifDelay)] +gifDiagS :: DiagProp -> B.ByteString -> [(Diagram Cairo R2, GifDelay)] gifDiagS p = gifDiag p . filterValidPT p . meshToArr diff --git a/Graphics/Diagram/Gtk.hs b/Graphics/Diagram/Gtk.hs index 51f4114..773601f 100644 --- a/Graphics/Diagram/Gtk.hs +++ b/Graphics/Diagram/Gtk.hs @@ -2,6 +2,7 @@ module Graphics.Diagram.Gtk where +import qualified Data.ByteString.Char8 as B import Diagrams.Backend.Cairo import Diagrams.Prelude import Graphics.Diagram.Plotter @@ -36,7 +37,7 @@ diag p objs@(Objects _) -- |Create the Diagram from a String which is supposed to be the contents -- of an obj file. -diagS :: DiagProp -> MeshString -> Diagram Cairo R2 +diagS :: DiagProp -> B.ByteString -> Diagram Cairo R2 diagS p mesh | algo p == 2 || algo p == 3 = diag p @@ -49,7 +50,7 @@ diagS p mesh -- |Create the tree diagram from a String which is supposed to be the contents -- of an obj file. -diagTreeS :: DiagProp -> MeshString -> Diagram Cairo R2 +diagTreeS :: DiagProp -> B.ByteString -> Diagram Cairo R2 diagTreeS p mesh | algo p == 4 = mkDiag treePretty p (Object . filterValidPT p diff --git a/Parser/Meshparser.hs b/Parser/Meshparser.hs index 17174f9..52431c1 100644 --- a/Parser/Meshparser.hs +++ b/Parser/Meshparser.hs @@ -12,24 +12,23 @@ import Diagrams.TwoD.Types -- |Convert a text String with multiple vertices and faces into -- a list of vertices, ordered by the faces specification. -facesToArr :: String -> [[PT]] +facesToArr :: B.ByteString -> [[PT]] facesToArr str = fmap (fmap (\y -> meshs str !! (fromIntegral y - 1))) (faces str) where meshs = meshToArr - faces = rights . fmap (parseOnly parseFace) . B.lines . B.pack + faces = rights . fmap (parseOnly parseFace) . B.lines -- |Convert a text String with multiple vertices into -- an array of float tuples. -meshToArr :: String -- ^ the string to convert - -> [PT] -- ^ the resulting vertice table +meshToArr :: B.ByteString -- ^ the string to convert + -> [PT] -- ^ the resulting vertice table meshToArr = fmap p2 . rights . fmap (parseOnly parseVertice) . B.lines - . B.pack -- |Creates a Parser that accepts a single vertice, such as 'v 1.0 2.0'.