
module Main where

import Control.Arrow
import System.Console.GetOpt
import System (getArgs)
import OBJParser
import Vec

data OptionFlag = Bounds deriving (Show)

options :: [OptDescr OptionFlag]
options = [
      Option "b" ["bounds"] (NoArg Bounds) "verbose output"
    ]

main = do
    args <- getArgs
    let (opts, nonOptions, errors) = getOpt Permute options args
        file = head nonOptions
    vs <- getVerticesFromFile file
    fs <- getFacesFromFile file
    let (minx,maxx) = (minimum &&& maximum) $ [getVec3 XAxis vi | vi <- vs]
        (miny,maxy) = (minimum &&& maximum) $ [getVec3 YAxis vi | vi <- vs]
        (minz,maxz) = (minimum &&& maximum) $ [getVec3 ZAxis vi | vi <- vs]
        vmin = V3 minx miny minz
        vmax = V3 maxx maxy maxz
    putStrLn $ "Number of vertices: " ++ (show $ length vs)
    putStrLn $ "Number of faces: " ++ (show $ length fs)
    putStrLn $ "Bounding Box: " ++ show vmin ++ show vmax
    putStrLn $ "BB Center: " ++ (show $ 0.5 |* (vmax - vmin) + vmin)

