module Data.Geometry.Triangulation.Draw where

import           Algorithms.Geometry.DelaunayTriangulation.Types
import           Data.Geometry.LineSegment
import           Ipe

--------------------------------------------------------------------------------

-- | Draws a triangulation
drawTriangulation :: IpeOut (Triangulation p r) Group r
drawTriangulation :: IpeOut (Triangulation p r) Group r
drawTriangulation Triangulation p r
tr =
  IpeOut [IpeObject r] Group r
forall (f :: * -> *) r.
Foldable f =>
IpeOut (f (IpeObject r)) Group r
ipeGroup [ IpeObject' Path r -> IpeObject r
forall (i :: * -> *) r. ToObject i => IpeObject' i r -> IpeObject r
iO (IpeObject' Path r -> IpeObject r)
-> IpeObject' Path r -> IpeObject r
forall a b. (a -> b) -> a -> b
$ IpeOut (LineSegment 2 p r) Path r
forall p r. IpeOut (LineSegment 2 p r) Path r
ipeLineSegment LineSegment 2 p r
e
           | LineSegment 2 p r
e <- ((Point 2 r :+ p, Point 2 r :+ p) -> LineSegment 2 p r)
-> [(Point 2 r :+ p, Point 2 r :+ p)] -> [LineSegment 2 p r]
forall a b. (a -> b) -> [a] -> [b]
map (((Point 2 r :+ p) -> (Point 2 r :+ p) -> LineSegment 2 p r)
-> (Point 2 r :+ p, Point 2 r :+ p) -> LineSegment 2 p r
forall a b c. (a -> b -> c) -> (a, b) -> c
uncurry (Point 2 r :+ p) -> (Point 2 r :+ p) -> LineSegment 2 p r
forall (d :: Nat) r p.
(Point d r :+ p) -> (Point d r :+ p) -> LineSegment d p r
ClosedLineSegment) ([(Point 2 r :+ p, Point 2 r :+ p)] -> [LineSegment 2 p r])
-> (Triangulation p r -> [(Point 2 r :+ p, Point 2 r :+ p)])
-> Triangulation p r
-> [LineSegment 2 p r]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Triangulation p r -> [(Point 2 r :+ p, Point 2 r :+ p)]
forall p r. Triangulation p r -> [(Point 2 r :+ p, Point 2 r :+ p)]
edgesAsPoints (Triangulation p r -> [LineSegment 2 p r])
-> Triangulation p r -> [LineSegment 2 p r]
forall a b. (a -> b) -> a -> b
$ Triangulation p r
tr
           ]