-import qualified Data.Array.Repa as R (map, force, reshape)
-import qualified Data.Array.Repa.IO.BMP as R (writeComponentsToBMP)
-import System.Environment (getArgs)
+import Control.Monad ( when )
+import qualified Data.Array.Repa as R
+import Data.Maybe ( fromJust )
+import GHC.Conc ( getNumProcessors, setNumCapabilities )
+import System.IO ( hPutStrLn, stderr )
+import System.Exit ( exitSuccess, exitWith, ExitCode(..) )
+
+import CommandLine ( Args(..), apply_args )
+import ExitCodes
+import Grid ( zoom )
+import Volumetric (
+ bracket_array,
+ flip_x,
+ flip_y,
+ read_word16s,
+ round_array,
+ swap_bytes,
+ write_values_to_bmp,
+ write_word16s,
+ z_slice )
+
+
+validate_args :: Args -> IO ()
+validate_args Args{..} = do
+ when (scale <= 0) $ do
+ hPutStrLn stderr "ERROR: scale must be greater than zero."
+ exitWith (ExitFailure exit_arg_not_positive)
+
+ when (width <= 0) $ do
+ hPutStrLn stderr "ERROR: width must be greater than zero."
+ exitWith (ExitFailure exit_arg_not_positive)
+
+ when (height <= 0) $ do
+ hPutStrLn stderr "ERROR: height must be greater than zero."
+ exitWith (ExitFailure exit_arg_not_positive)
+
+ when (depth <= 0) $ do
+ hPutStrLn stderr "ERROR: depth must be greater than zero."
+ exitWith (ExitFailure exit_arg_not_positive)
+
+ case slice of
+ Just s ->
+ when (s < 0 || s > depth) $ do
+ hPutStrLn stderr "ERROR: slice must be between zero and depth."
+ exitWith (ExitFailure exit_arg_out_of_bounds)
+ Nothing -> return ()