packages feed

delaunay 0.1.0.1 → 0.1.0.2

raw patch · 3 files changed

+66/−4 lines, 3 filesdep +HUnitdep +QuickCheckdep +delaunayPVP ok

version bump matches the API change (PVP)

Dependencies added: HUnit, QuickCheck, delaunay

API changes (from Hackage documentation)

Files

Graphics/Triangulation/Delaunay.hs view
@@ -21,7 +21,10 @@ -- | Generate the Delaunay triangulation of a set of points triangulate :: [Vector2] -> [(Vector2,Vector2,Vector2)] triangulate [] = []-triangulate pts' = map (\(Pt a,Pt b,Pt c) -> (a,b,c)) $ triangulationToTris $ removeHelperPoints pts trig+triangulate pts' = +  case pts of+    (_:_:_:_) -> map (\(Pt a,Pt b,Pt c) -> (a,b,c)) $ triangulationToTris $ removeHelperPoints pts trig+    _tooFew   -> []   where trig = addPoints (baseTriangulation pts) pts         pts  = map Pt $ nub pts'         @@ -105,7 +108,9 @@         p3 = Pt $ Vector2 xMax yMin         p4 = Pt $ Vector2 xMax yMax         -- note: p1 <= p2 <= p3 <= p4.-        (BBox2 xMin yMin xMax yMax) = bound_points $ map (\(Pt x) -> x) pts+        (BBox2 xMin' yMin' xMax' yMax') = bound_points $ map (\(Pt x) -> x) pts+        [xMin,yMin] = map (\x -> x - 1) [xMin',yMin']+        [xMax,yMax] = map (\x -> x + 1) [xMax',yMax']           triangulationToTris :: Triangulation -> [Triangle]
delaunay.cabal view
@@ -2,9 +2,10 @@ -- documentation, see http://haskell.org/cabal/users-guide/  name:                delaunay-version:             0.1.0.1+version:             0.1.0.2 synopsis:            Build a Delaunay triangulation of a set of points-description:         Use '--ghc-options=-fllvm' for improved performance.+description:         This package provides a single function that builds a Delaunay triangulation of a set of points.+		     Use '--ghc-options=-fllvm' for improved performance. homepage:            http://github.com/mruegenberg/Delaunay license:             BSD3 license-file:        LICENSE@@ -24,3 +25,18 @@                      , AC-Vector >= 2.2.0                      , unordered-containers >= 0.2.1.0                      , hashable >= 1.0.1.1++Test-Suite           delaunay-testsuite+  Type:              exitcode-stdio-1.0+  hs-source-dirs:    tests+  Main-is:           Tests.hs++  Build-depends:       base >= 4 && <5+                     , AC-Vector >= 2.2.0+                     , delaunay+                     , QuickCheck >= 2.4.0.0+                     , HUnit >= 1.2.0.0++source-repository head+  type:         git+  location:     git://github.com/mruegenberg/Delaunay.git
+ tests/Tests.hs view
@@ -0,0 +1,41 @@+module Main where+import Test.HUnit(Counts(..),Test(..),runTestTT,(~?=),(~:))+import Control.Monad (unless)+import Data.Vector.V2+import System.Exit (exitFailure)++-- modules under test+import Graphics.Triangulation.Delaunay (triangulate)++-- TODO: use test-framework+success :: Counts -> Bool+success cs = errors cs == 0 && failures cs == 0++tests ::  IO Counts+tests = runTestTT $ TestList +  [ fewPointsTests+  , triPointsAreDistinctTests+  ]++fewPointsTests = TestList +  [ "triangulate no points"  ~: triangulate []                     ~?= []+  , "triangulate one point"  ~: triangulate [v2 1 1]               ~?= []+  , "triangulate two points" ~: triangulate [v2 1 1, v2 2 2]       ~?= []+  , "triangulate many dups"  ~: triangulate (replicate 5 (v2 1 1)) ~?= []+  ]+  where+    v2 = Vector2 ++triPointsAreDistinctTests = TestList +  [ "each tri has distinct pts" ~: filter (not . hasDistinctPoints) (triangulate pts) ~?= []+  ]+  where +    pts = [v 0 7, v 24 33, v 10 13, v 20 0, v 22 11] where v = Vector2++hasDistinctPoints :: (Vector2, Vector2, Vector2) -> Bool+hasDistinctPoints (p1,p2,p3) = p1/=p2 && p1/=p3 && p2/=p3++main = do+  result <- tests+  unless (success result) exitFailure+