packages feed

delaunayNd 0.1.0.1 → 0.1.0.2

raw patch · 3 files changed

+33/−22 lines, 3 filesdep −splitdep ~Uniquedep ~containersdep ~extraPVP: minor bump suggested

API additions: PVP suggests at least a minor version bump

Dependencies removed: split

Dependency ranges changed: Unique, containers, extra, hashable, ilist, insert-ordered-containers

API changes (from Hackage documentation)

+ Geometry.Delaunay: getDelaunayTiles :: Tessellation -> [IntMap [Double]]

Files

CHANGELOG.md view
@@ -1,5 +1,10 @@ # Changelog for `delaunayNd`
 
+## 0.1.0.2 - 2023-11-18
+
+New function `getDelaunayTiles`, to extract the vertices of the tiles.
+
+
 ## 0.1.0.1 - 2023-11-15
 
 Built of v0.1.0.0 has failed because of a non-declarated header file.
delaunayNd.cabal view
@@ -1,6 +1,6 @@ cabal-version:       2.2
 name:                delaunayNd
-version:             0.1.0.1
+version:             0.1.0.2
 synopsis:            Delaunay tessellation
 description:         
     This library performs the Delaunay tessellation in arbitrary dimension.
@@ -28,15 +28,13 @@                      , Geometry.Qhull.Types
                      , Geometry.Qhull.Shared
   build-depends:       base >= 4.9 && < 5
-                     , split >= 0.2.3.5
-                     , containers >= 0.6.4.1
-                     , extra >= 1.7.7
-                     , ilist >= 0.4.0.1
-                     , hashable >= 1.3.5.0
-                     , insert-ordered-containers >= 0.2.5.3
-                     , Unique >= 0.4.7.9
+                     , containers >= 0.6.4.1 && < 0.8
+                     , extra >= 1.7.7 && < 1.8
+                     , ilist >= 0.4.0.1 && < 0.5
+                     , hashable >= 1.3.5.0 && < 1.5
+                     , insert-ordered-containers >= 0.2.5.3 && < 0.3
+                     , Unique >= 0.4.7.9 && < 0.5
   other-extensions:    ForeignFunctionInterface
-                     , TypeFamilies
   default-language:    Haskell2010
   include-dirs:        C
   C-sources:           C/libqhull_r.c
src/Geometry/Delaunay/Delaunay.hs view
@@ -8,7 +8,8 @@   , facetOf'
   , facetFamilies'
   , facetCenters'
-    ) 
+  , getDelaunayTiles
+  ) 
   where
 import           Control.Monad               ( unless, when )
 import           Data.IntMap.Strict          ( IntMap )
@@ -19,23 +20,26 @@ import           Geometry.Delaunay.CDelaunay ( c_tessellation
                                              , cTessellationToTessellation 
                                              )
-import           Geometry.Delaunay.Types     ( Tessellation(_tilefacets, _sites, _tiles),
-                                               Tile,
-                                               TileFacet(_facetOf),
-                                               Site(_neighfacetsIds) )
+import           Geometry.Delaunay.Types     ( Tessellation(_tilefacets, _sites, _tiles)
+                                             , Tile (..)
+                                             , Simplex(_vertices')
+                                             , TileFacet(_facetOf)
+                                             , Site(_neighfacetsIds) 
+                                             )
 import           Foreign.C.Types             ( CDouble, CUInt )
 import           Foreign.Marshal.Alloc       ( free, mallocBytes )
 import           Foreign.Marshal.Array       ( pokeArray )
 import           Foreign.Storable            ( peek, sizeOf )
-import           Geometry.Qhull.Types        ( HasCenter(_center), 
-                                               HasFamily(_family), 
-                                               Family, 
-                                               Index )
+import           Geometry.Qhull.Types        ( HasCenter(_center) 
+                                             , HasFamily(_family)
+                                             , Family
+                                             , Index 
+                                             )
 
-delaunay :: [[Double]]     -- ^ sites (vertex coordinates)
-         -> Bool           -- ^ whether to add a point at infinity
-         -> Bool           -- ^ whether to include degenerate tiles
-         -> Maybe Double   -- ^ volume threshold
+delaunay :: [[Double]]      -- ^ sites (vertex coordinates)
+         -> Bool            -- ^ whether to add a point at infinity
+         -> Bool            -- ^ whether to include degenerate tiles
+         -> Maybe Double    -- ^ volume threshold
          -> IO Tessellation -- ^ Delaunay tessellation
 delaunay sites atinfinity degenerate vthreshold = do
   let n     = length sites
@@ -110,3 +114,7 @@ -- | the circumcenters of the tiles a facet belongs to, facet given by its id
 facetCenters' :: Tessellation -> Int -> IntMap [Double]
 facetCenters' = funofFacetToFunofInt facetCenters
+
+-- | list of the maps of vertices for all tiles
+getDelaunayTiles :: Tessellation -> [IntMap [Double]]
+getDelaunayTiles tess = IM.elems $ IM.map (_vertices' . _simplex) (_tiles tess)