| 1 | {-# LANGUAGE PatternGuards #-} |
|---|
| 2 | |
|---|
| 3 | import System.Environment |
|---|
| 4 | import Data.Function |
|---|
| 5 | import qualified Data.Vector.Unboxed as V |
|---|
| 6 | import Data.Vector.Unboxed (Vector) |
|---|
| 7 | import Control.Monad |
|---|
| 8 | import System.IO |
|---|
| 9 | |
|---|
| 10 | import QuickHull |
|---|
| 11 | import TestData |
|---|
| 12 | |
|---|
| 13 | |
|---|
| 14 | main :: IO () |
|---|
| 15 | main |
|---|
| 16 | = do [strPoints] <- getArgs |
|---|
| 17 | let numPoints = read strPoints |
|---|
| 18 | |
|---|
| 19 | putStr "Generating test data.\n" |
|---|
| 20 | let vPoints = genPointsDisc numPoints (400, 400) 350 |
|---|
| 21 | |
|---|
| 22 | -- Force points to create the input vector. |
|---|
| 23 | V.force vPoints `seq` return () |
|---|
| 24 | |
|---|
| 25 | -- Compute the convex hull. |
|---|
| 26 | putStr "Computing hull.\n" |
|---|
| 27 | hFlush stdout |
|---|
| 28 | vHull <- quickHull vPoints |
|---|
| 29 | V.force vHull `seq` return () |
|---|
| 30 | putStr "Done\n" |
|---|
| 31 | |
|---|
| 32 | |
|---|
| 33 | |
|---|
| 34 | |
|---|