{-# LANGUAGE UndecidableInstances #-}
--------------------------------------------------------------------------------
-- |
-- Module      :  HGeometry.PolyLine
-- Copyright   :  (C) Frank Staals
-- License     :  see the LICENSE file
-- Maintainer  :  Frank Staals
--
-- A Polyline and some basic functions to interact with them.
--
--------------------------------------------------------------------------------
module HGeometry.PolyLine
  ( PolyLineF(..), PolyLine
  , _PolyLineF
  , module HGeometry.PolyLine.Class
  , HasVertices(..)
  , HasEdges(..)
  ) where


import Control.DeepSeq (NFData)
import Control.Lens
import Data.Coerce (coerce)
import Data.Functor.Classes
import Data.Semigroup.Foldable
import Data.Vector.NonEmpty.Internal (NonEmptyVector(..))
import GHC.Generics
import HGeometry.Box
import HGeometry.Foldable.Util
import HGeometry.Interval.Class
import HGeometry.Point
import HGeometry.PolyLine.Class
import HGeometry.Properties
import HGeometry.Transformation
import HGeometry.Vector.NonEmpty.Util ()
import Hiraffe.Graph

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

-- | Simple polygons just store their vertices in CCCW order
newtype PolyLineF f point = PolyLine (f point)
  deriving stock ((forall x. PolyLineF f point -> Rep (PolyLineF f point) x)
-> (forall x. Rep (PolyLineF f point) x -> PolyLineF f point)
-> Generic (PolyLineF f point)
forall x. Rep (PolyLineF f point) x -> PolyLineF f point
forall x. PolyLineF f point -> Rep (PolyLineF f point) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall k (f :: k -> *) (point :: k) x.
Rep (PolyLineF f point) x -> PolyLineF f point
forall k (f :: k -> *) (point :: k) x.
PolyLineF f point -> Rep (PolyLineF f point) x
$cfrom :: forall k (f :: k -> *) (point :: k) x.
PolyLineF f point -> Rep (PolyLineF f point) x
from :: forall x. PolyLineF f point -> Rep (PolyLineF f point) x
$cto :: forall k (f :: k -> *) (point :: k) x.
Rep (PolyLineF f point) x -> PolyLineF f point
to :: forall x. Rep (PolyLineF f point) x -> PolyLineF f point
Generic,Int -> PolyLineF f point -> ShowS
[PolyLineF f point] -> ShowS
PolyLineF f point -> String
(Int -> PolyLineF f point -> ShowS)
-> (PolyLineF f point -> String)
-> ([PolyLineF f point] -> ShowS)
-> Show (PolyLineF f point)
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
forall k (f :: k -> *) (point :: k).
Show (f point) =>
Int -> PolyLineF f point -> ShowS
forall k (f :: k -> *) (point :: k).
Show (f point) =>
[PolyLineF f point] -> ShowS
forall k (f :: k -> *) (point :: k).
Show (f point) =>
PolyLineF f point -> String
$cshowsPrec :: forall k (f :: k -> *) (point :: k).
Show (f point) =>
Int -> PolyLineF f point -> ShowS
showsPrec :: Int -> PolyLineF f point -> ShowS
$cshow :: forall k (f :: k -> *) (point :: k).
Show (f point) =>
PolyLineF f point -> String
show :: PolyLineF f point -> String
$cshowList :: forall k (f :: k -> *) (point :: k).
Show (f point) =>
[PolyLineF f point] -> ShowS
showList :: [PolyLineF f point] -> ShowS
Show, ReadPrec [PolyLineF f point]
ReadPrec (PolyLineF f point)
Int -> ReadS (PolyLineF f point)
ReadS [PolyLineF f point]
(Int -> ReadS (PolyLineF f point))
-> ReadS [PolyLineF f point]
-> ReadPrec (PolyLineF f point)
-> ReadPrec [PolyLineF f point]
-> Read (PolyLineF f point)
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
forall k (f :: k -> *) (point :: k).
Read (f point) =>
ReadPrec [PolyLineF f point]
forall k (f :: k -> *) (point :: k).
Read (f point) =>
ReadPrec (PolyLineF f point)
forall k (f :: k -> *) (point :: k).
Read (f point) =>
Int -> ReadS (PolyLineF f point)
forall k (f :: k -> *) (point :: k).
Read (f point) =>
ReadS [PolyLineF f point]
$creadsPrec :: forall k (f :: k -> *) (point :: k).
Read (f point) =>
Int -> ReadS (PolyLineF f point)
readsPrec :: Int -> ReadS (PolyLineF f point)
$creadList :: forall k (f :: k -> *) (point :: k).
Read (f point) =>
ReadS [PolyLineF f point]
readList :: ReadS [PolyLineF f point]
$creadPrec :: forall k (f :: k -> *) (point :: k).
Read (f point) =>
ReadPrec (PolyLineF f point)
readPrec :: ReadPrec (PolyLineF f point)
$creadListPrec :: forall k (f :: k -> *) (point :: k).
Read (f point) =>
ReadPrec [PolyLineF f point]
readListPrec :: ReadPrec [PolyLineF f point]
Read)
  deriving newtype (PolyLineF f point -> ()
(PolyLineF f point -> ()) -> NFData (PolyLineF f point)
forall a. (a -> ()) -> NFData a
forall k (f :: k -> *) (point :: k).
NFData (f point) =>
PolyLineF f point -> ()
$crnf :: forall k (f :: k -> *) (point :: k).
NFData (f point) =>
PolyLineF f point -> ()
rnf :: PolyLineF f point -> ()
NFData,(forall a b. (a -> b) -> PolyLineF f a -> PolyLineF f b)
-> (forall a b. a -> PolyLineF f b -> PolyLineF f a)
-> Functor (PolyLineF f)
forall a b. a -> PolyLineF f b -> PolyLineF f a
forall a b. (a -> b) -> PolyLineF f a -> PolyLineF f b
forall (f :: * -> *) a b.
Functor f =>
a -> PolyLineF f b -> PolyLineF f a
forall (f :: * -> *) a b.
Functor f =>
(a -> b) -> PolyLineF f a -> PolyLineF f b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
$cfmap :: forall (f :: * -> *) a b.
Functor f =>
(a -> b) -> PolyLineF f a -> PolyLineF f b
fmap :: forall a b. (a -> b) -> PolyLineF f a -> PolyLineF f b
$c<$ :: forall (f :: * -> *) a b.
Functor f =>
a -> PolyLineF f b -> PolyLineF f a
<$ :: forall a b. a -> PolyLineF f b -> PolyLineF f a
Functor,(forall m. Monoid m => PolyLineF f m -> m)
-> (forall m a. Monoid m => (a -> m) -> PolyLineF f a -> m)
-> (forall m a. Monoid m => (a -> m) -> PolyLineF f a -> m)
-> (forall a b. (a -> b -> b) -> b -> PolyLineF f a -> b)
-> (forall a b. (a -> b -> b) -> b -> PolyLineF f a -> b)
-> (forall b a. (b -> a -> b) -> b -> PolyLineF f a -> b)
-> (forall b a. (b -> a -> b) -> b -> PolyLineF f a -> b)
-> (forall a. (a -> a -> a) -> PolyLineF f a -> a)
-> (forall a. (a -> a -> a) -> PolyLineF f a -> a)
-> (forall a. PolyLineF f a -> [a])
-> (forall a. PolyLineF f a -> Bool)
-> (forall a. PolyLineF f a -> Int)
-> (forall a. Eq a => a -> PolyLineF f a -> Bool)
-> (forall a. Ord a => PolyLineF f a -> a)
-> (forall a. Ord a => PolyLineF f a -> a)
-> (forall a. Num a => PolyLineF f a -> a)
-> (forall a. Num a => PolyLineF f a -> a)
-> Foldable (PolyLineF f)
forall a. Eq a => a -> PolyLineF f a -> Bool
forall a. Num a => PolyLineF f a -> a
forall a. Ord a => PolyLineF f a -> a
forall m. Monoid m => PolyLineF f m -> m
forall a. PolyLineF f a -> Bool
forall a. PolyLineF f a -> Int
forall a. PolyLineF f a -> [a]
forall a. (a -> a -> a) -> PolyLineF f a -> a
forall m a. Monoid m => (a -> m) -> PolyLineF f a -> m
forall b a. (b -> a -> b) -> b -> PolyLineF f a -> b
forall a b. (a -> b -> b) -> b -> PolyLineF f a -> b
forall (f :: * -> *) a.
(Foldable f, Eq a) =>
a -> PolyLineF f a -> Bool
forall (f :: * -> *) a. (Foldable f, Num a) => PolyLineF f a -> a
forall (f :: * -> *) a. (Foldable f, Ord a) => PolyLineF f a -> a
forall (f :: * -> *) m.
(Foldable f, Monoid m) =>
PolyLineF f m -> m
forall (f :: * -> *) a. Foldable f => PolyLineF f a -> Bool
forall (f :: * -> *) a. Foldable f => PolyLineF f a -> Int
forall (f :: * -> *) a. Foldable f => PolyLineF f a -> [a]
forall (f :: * -> *) a.
Foldable f =>
(a -> a -> a) -> PolyLineF f a -> a
forall (f :: * -> *) m a.
(Foldable f, Monoid m) =>
(a -> m) -> PolyLineF f a -> m
forall (f :: * -> *) b a.
Foldable f =>
(b -> a -> b) -> b -> PolyLineF f a -> b
forall (f :: * -> *) a b.
Foldable f =>
(a -> b -> b) -> b -> PolyLineF f a -> b
forall (t :: * -> *).
(forall m. Monoid m => t m -> m)
-> (forall m a. Monoid m => (a -> m) -> t a -> m)
-> (forall m a. Monoid m => (a -> m) -> t a -> m)
-> (forall a b. (a -> b -> b) -> b -> t a -> b)
-> (forall a b. (a -> b -> b) -> b -> t a -> b)
-> (forall b a. (b -> a -> b) -> b -> t a -> b)
-> (forall b a. (b -> a -> b) -> b -> t a -> b)
-> (forall a. (a -> a -> a) -> t a -> a)
-> (forall a. (a -> a -> a) -> t a -> a)
-> (forall a. t a -> [a])
-> (forall a. t a -> Bool)
-> (forall a. t a -> Int)
-> (forall a. Eq a => a -> t a -> Bool)
-> (forall a. Ord a => t a -> a)
-> (forall a. Ord a => t a -> a)
-> (forall a. Num a => t a -> a)
-> (forall a. Num a => t a -> a)
-> Foldable t
$cfold :: forall (f :: * -> *) m.
(Foldable f, Monoid m) =>
PolyLineF f m -> m
fold :: forall m. Monoid m => PolyLineF f m -> m
$cfoldMap :: forall (f :: * -> *) m a.
(Foldable f, Monoid m) =>
(a -> m) -> PolyLineF f a -> m
foldMap :: forall m a. Monoid m => (a -> m) -> PolyLineF f a -> m
$cfoldMap' :: forall (f :: * -> *) m a.
(Foldable f, Monoid m) =>
(a -> m) -> PolyLineF f a -> m
foldMap' :: forall m a. Monoid m => (a -> m) -> PolyLineF f a -> m
$cfoldr :: forall (f :: * -> *) a b.
Foldable f =>
(a -> b -> b) -> b -> PolyLineF f a -> b
foldr :: forall a b. (a -> b -> b) -> b -> PolyLineF f a -> b
$cfoldr' :: forall (f :: * -> *) a b.
Foldable f =>
(a -> b -> b) -> b -> PolyLineF f a -> b
foldr' :: forall a b. (a -> b -> b) -> b -> PolyLineF f a -> b
$cfoldl :: forall (f :: * -> *) b a.
Foldable f =>
(b -> a -> b) -> b -> PolyLineF f a -> b
foldl :: forall b a. (b -> a -> b) -> b -> PolyLineF f a -> b
$cfoldl' :: forall (f :: * -> *) b a.
Foldable f =>
(b -> a -> b) -> b -> PolyLineF f a -> b
foldl' :: forall b a. (b -> a -> b) -> b -> PolyLineF f a -> b
$cfoldr1 :: forall (f :: * -> *) a.
Foldable f =>
(a -> a -> a) -> PolyLineF f a -> a
foldr1 :: forall a. (a -> a -> a) -> PolyLineF f a -> a
$cfoldl1 :: forall (f :: * -> *) a.
Foldable f =>
(a -> a -> a) -> PolyLineF f a -> a
foldl1 :: forall a. (a -> a -> a) -> PolyLineF f a -> a
$ctoList :: forall (f :: * -> *) a. Foldable f => PolyLineF f a -> [a]
toList :: forall a. PolyLineF f a -> [a]
$cnull :: forall (f :: * -> *) a. Foldable f => PolyLineF f a -> Bool
null :: forall a. PolyLineF f a -> Bool
$clength :: forall (f :: * -> *) a. Foldable f => PolyLineF f a -> Int
length :: forall a. PolyLineF f a -> Int
$celem :: forall (f :: * -> *) a.
(Foldable f, Eq a) =>
a -> PolyLineF f a -> Bool
elem :: forall a. Eq a => a -> PolyLineF f a -> Bool
$cmaximum :: forall (f :: * -> *) a. (Foldable f, Ord a) => PolyLineF f a -> a
maximum :: forall a. Ord a => PolyLineF f a -> a
$cminimum :: forall (f :: * -> *) a. (Foldable f, Ord a) => PolyLineF f a -> a
minimum :: forall a. Ord a => PolyLineF f a -> a
$csum :: forall (f :: * -> *) a. (Foldable f, Num a) => PolyLineF f a -> a
sum :: forall a. Num a => PolyLineF f a -> a
$cproduct :: forall (f :: * -> *) a. (Foldable f, Num a) => PolyLineF f a -> a
product :: forall a. Num a => PolyLineF f a -> a
Foldable,Foldable (PolyLineF f)
Foldable (PolyLineF f) =>
(forall m. Semigroup m => PolyLineF f m -> m)
-> (forall m a. Semigroup m => (a -> m) -> PolyLineF f a -> m)
-> (forall m a. Semigroup m => (a -> m) -> PolyLineF f a -> m)
-> (forall a. PolyLineF f a -> NonEmpty a)
-> (forall a. Ord a => PolyLineF f a -> a)
-> (forall a. Ord a => PolyLineF f a -> a)
-> (forall a. PolyLineF f a -> a)
-> (forall a. PolyLineF f a -> a)
-> (forall a b. (a -> b) -> (a -> b -> b) -> PolyLineF f a -> b)
-> (forall a b. (a -> b) -> (b -> a -> b) -> PolyLineF f a -> b)
-> (forall a b. (a -> b) -> (b -> a -> b) -> PolyLineF f a -> b)
-> (forall a b. (a -> b) -> (a -> b -> b) -> PolyLineF f a -> b)
-> Foldable1 (PolyLineF f)
forall a. Ord a => PolyLineF f a -> a
forall m. Semigroup m => PolyLineF f m -> m
forall a. PolyLineF f a -> a
forall a. PolyLineF f a -> NonEmpty a
forall m a. Semigroup m => (a -> m) -> PolyLineF f a -> m
forall a b. (a -> b) -> (a -> b -> b) -> PolyLineF f a -> b
forall a b. (a -> b) -> (b -> a -> b) -> PolyLineF f a -> b
forall (t :: * -> *).
Foldable t =>
(forall m. Semigroup m => t m -> m)
-> (forall m a. Semigroup m => (a -> m) -> t a -> m)
-> (forall m a. Semigroup m => (a -> m) -> t a -> m)
-> (forall a. t a -> NonEmpty a)
-> (forall a. Ord a => t a -> a)
-> (forall a. Ord a => t a -> a)
-> (forall a. t a -> a)
-> (forall a. t a -> a)
-> (forall a b. (a -> b) -> (a -> b -> b) -> t a -> b)
-> (forall a b. (a -> b) -> (b -> a -> b) -> t a -> b)
-> (forall a b. (a -> b) -> (b -> a -> b) -> t a -> b)
-> (forall a b. (a -> b) -> (a -> b -> b) -> t a -> b)
-> Foldable1 t
forall (f :: * -> *). Foldable1 f => Foldable (PolyLineF f)
forall (f :: * -> *) a. (Foldable1 f, Ord a) => PolyLineF f a -> a
forall (f :: * -> *) m.
(Foldable1 f, Semigroup m) =>
PolyLineF f m -> m
forall (f :: * -> *) a. Foldable1 f => PolyLineF f a -> a
forall (f :: * -> *) a. Foldable1 f => PolyLineF f a -> NonEmpty a
forall (f :: * -> *) m a.
(Foldable1 f, Semigroup m) =>
(a -> m) -> PolyLineF f a -> m
forall (f :: * -> *) a b.
Foldable1 f =>
(a -> b) -> (a -> b -> b) -> PolyLineF f a -> b
forall (f :: * -> *) a b.
Foldable1 f =>
(a -> b) -> (b -> a -> b) -> PolyLineF f a -> b
$cfold1 :: forall (f :: * -> *) m.
(Foldable1 f, Semigroup m) =>
PolyLineF f m -> m
fold1 :: forall m. Semigroup m => PolyLineF f m -> m
$cfoldMap1 :: forall (f :: * -> *) m a.
(Foldable1 f, Semigroup m) =>
(a -> m) -> PolyLineF f a -> m
foldMap1 :: forall m a. Semigroup m => (a -> m) -> PolyLineF f a -> m
$cfoldMap1' :: forall (f :: * -> *) m a.
(Foldable1 f, Semigroup m) =>
(a -> m) -> PolyLineF f a -> m
foldMap1' :: forall m a. Semigroup m => (a -> m) -> PolyLineF f a -> m
$ctoNonEmpty :: forall (f :: * -> *) a. Foldable1 f => PolyLineF f a -> NonEmpty a
toNonEmpty :: forall a. PolyLineF f a -> NonEmpty a
$cmaximum :: forall (f :: * -> *) a. (Foldable1 f, Ord a) => PolyLineF f a -> a
maximum :: forall a. Ord a => PolyLineF f a -> a
$cminimum :: forall (f :: * -> *) a. (Foldable1 f, Ord a) => PolyLineF f a -> a
minimum :: forall a. Ord a => PolyLineF f a -> a
$chead :: forall (f :: * -> *) a. Foldable1 f => PolyLineF f a -> a
head :: forall a. PolyLineF f a -> a
$clast :: forall (f :: * -> *) a. Foldable1 f => PolyLineF f a -> a
last :: forall a. PolyLineF f a -> a
$cfoldrMap1 :: forall (f :: * -> *) a b.
Foldable1 f =>
(a -> b) -> (a -> b -> b) -> PolyLineF f a -> b
foldrMap1 :: forall a b. (a -> b) -> (a -> b -> b) -> PolyLineF f a -> b
$cfoldlMap1' :: forall (f :: * -> *) a b.
Foldable1 f =>
(a -> b) -> (b -> a -> b) -> PolyLineF f a -> b
foldlMap1' :: forall a b. (a -> b) -> (b -> a -> b) -> PolyLineF f a -> b
$cfoldlMap1 :: forall (f :: * -> *) a b.
Foldable1 f =>
(a -> b) -> (b -> a -> b) -> PolyLineF f a -> b
foldlMap1 :: forall a b. (a -> b) -> (b -> a -> b) -> PolyLineF f a -> b
$cfoldrMap1' :: forall (f :: * -> *) a b.
Foldable1 f =>
(a -> b) -> (a -> b -> b) -> PolyLineF f a -> b
foldrMap1' :: forall a b. (a -> b) -> (a -> b -> b) -> PolyLineF f a -> b
Foldable1,PolyLineF f point -> PolyLineF f point -> Bool
(PolyLineF f point -> PolyLineF f point -> Bool)
-> (PolyLineF f point -> PolyLineF f point -> Bool)
-> Eq (PolyLineF f point)
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
forall k (f :: k -> *) (point :: k).
Eq (f point) =>
PolyLineF f point -> PolyLineF f point -> Bool
$c== :: forall k (f :: k -> *) (point :: k).
Eq (f point) =>
PolyLineF f point -> PolyLineF f point -> Bool
== :: PolyLineF f point -> PolyLineF f point -> Bool
$c/= :: forall k (f :: k -> *) (point :: k).
Eq (f point) =>
PolyLineF f point -> PolyLineF f point -> Bool
/= :: PolyLineF f point -> PolyLineF f point -> Bool
Eq,Eq (PolyLineF f point)
Eq (PolyLineF f point) =>
(PolyLineF f point -> PolyLineF f point -> Ordering)
-> (PolyLineF f point -> PolyLineF f point -> Bool)
-> (PolyLineF f point -> PolyLineF f point -> Bool)
-> (PolyLineF f point -> PolyLineF f point -> Bool)
-> (PolyLineF f point -> PolyLineF f point -> Bool)
-> (PolyLineF f point -> PolyLineF f point -> PolyLineF f point)
-> (PolyLineF f point -> PolyLineF f point -> PolyLineF f point)
-> Ord (PolyLineF f point)
PolyLineF f point -> PolyLineF f point -> Bool
PolyLineF f point -> PolyLineF f point -> Ordering
PolyLineF f point -> PolyLineF f point -> PolyLineF f point
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
forall k (f :: k -> *) (point :: k).
Ord (f point) =>
Eq (PolyLineF f point)
forall k (f :: k -> *) (point :: k).
Ord (f point) =>
PolyLineF f point -> PolyLineF f point -> Bool
forall k (f :: k -> *) (point :: k).
Ord (f point) =>
PolyLineF f point -> PolyLineF f point -> Ordering
forall k (f :: k -> *) (point :: k).
Ord (f point) =>
PolyLineF f point -> PolyLineF f point -> PolyLineF f point
$ccompare :: forall k (f :: k -> *) (point :: k).
Ord (f point) =>
PolyLineF f point -> PolyLineF f point -> Ordering
compare :: PolyLineF f point -> PolyLineF f point -> Ordering
$c< :: forall k (f :: k -> *) (point :: k).
Ord (f point) =>
PolyLineF f point -> PolyLineF f point -> Bool
< :: PolyLineF f point -> PolyLineF f point -> Bool
$c<= :: forall k (f :: k -> *) (point :: k).
Ord (f point) =>
PolyLineF f point -> PolyLineF f point -> Bool
<= :: PolyLineF f point -> PolyLineF f point -> Bool
$c> :: forall k (f :: k -> *) (point :: k).
Ord (f point) =>
PolyLineF f point -> PolyLineF f point -> Bool
> :: PolyLineF f point -> PolyLineF f point -> Bool
$c>= :: forall k (f :: k -> *) (point :: k).
Ord (f point) =>
PolyLineF f point -> PolyLineF f point -> Bool
>= :: PolyLineF f point -> PolyLineF f point -> Bool
$cmax :: forall k (f :: k -> *) (point :: k).
Ord (f point) =>
PolyLineF f point -> PolyLineF f point -> PolyLineF f point
max :: PolyLineF f point -> PolyLineF f point -> PolyLineF f point
$cmin :: forall k (f :: k -> *) (point :: k).
Ord (f point) =>
PolyLineF f point -> PolyLineF f point -> PolyLineF f point
min :: PolyLineF f point -> PolyLineF f point -> PolyLineF f point
Ord,(forall a. Eq a => Eq (PolyLineF f a)) =>
(forall a b.
 (a -> b -> Bool) -> PolyLineF f a -> PolyLineF f b -> Bool)
-> Eq1 (PolyLineF f)
forall a. Eq a => Eq (PolyLineF f a)
forall a b.
(a -> b -> Bool) -> PolyLineF f a -> PolyLineF f b -> Bool
forall (f :: * -> *) a. (Eq1 f, Eq a) => Eq (PolyLineF f a)
forall (f :: * -> *) a b.
Eq1 f =>
(a -> b -> Bool) -> PolyLineF f a -> PolyLineF f b -> Bool
forall (f :: * -> *).
(forall a. Eq a => Eq (f a)) =>
(forall a b. (a -> b -> Bool) -> f a -> f b -> Bool) -> Eq1 f
$cliftEq :: forall (f :: * -> *) a b.
Eq1 f =>
(a -> b -> Bool) -> PolyLineF f a -> PolyLineF f b -> Bool
liftEq :: forall a b.
(a -> b -> Bool) -> PolyLineF f a -> PolyLineF f b -> Bool
Eq1,Eq1 (PolyLineF f)
(Eq1 (PolyLineF f), forall a. Ord a => Ord (PolyLineF f a)) =>
(forall a b.
 (a -> b -> Ordering) -> PolyLineF f a -> PolyLineF f b -> Ordering)
-> Ord1 (PolyLineF f)
forall a. Ord a => Ord (PolyLineF f a)
forall a b.
(a -> b -> Ordering) -> PolyLineF f a -> PolyLineF f b -> Ordering
forall (f :: * -> *). Ord1 f => Eq1 (PolyLineF f)
forall (f :: * -> *) a. (Ord1 f, Ord a) => Ord (PolyLineF f a)
forall (f :: * -> *) a b.
Ord1 f =>
(a -> b -> Ordering) -> PolyLineF f a -> PolyLineF f b -> Ordering
forall (f :: * -> *).
(Eq1 f, forall a. Ord a => Ord (f a)) =>
(forall a b. (a -> b -> Ordering) -> f a -> f b -> Ordering)
-> Ord1 f
$cliftCompare :: forall (f :: * -> *) a b.
Ord1 f =>
(a -> b -> Ordering) -> PolyLineF f a -> PolyLineF f b -> Ordering
liftCompare :: forall a b.
(a -> b -> Ordering) -> PolyLineF f a -> PolyLineF f b -> Ordering
Ord1)

-- | By default we store simple poylline as non-empty vectors.
type PolyLine = PolyLineF NonEmptyVector

type instance Dimension (PolyLineF f point) = Dimension point
type instance NumType   (PolyLineF f point) = NumType point


-- | Access the container
_PolyLineF :: Iso (PolyLineF f point) (PolyLineF f' point')
                  (f point)                (f' point' )
_PolyLineF :: forall {k} {k} (f :: k -> *) (point :: k) (f' :: k -> *)
       (point' :: k) (p :: * -> * -> *) (f :: * -> *).
(Profunctor p, Functor f) =>
p (f point) (f (f' point'))
-> p (PolyLineF f point) (f (PolyLineF f' point'))
_PolyLineF = (PolyLineF f point -> f point)
-> (f' point' -> PolyLineF f' point')
-> Iso
     (PolyLineF f point) (PolyLineF f' point') (f point) (f' point')
forall s a b t. (s -> a) -> (b -> t) -> Iso s t a b
iso (\(PolyLine f point
vs) -> f point
vs) f' point' -> PolyLineF f' point'
forall {k} (f :: k -> *) (point :: k). f point -> PolyLineF f point
PolyLine

instance Traversable f => Traversable (PolyLineF f) where
  traverse :: forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> PolyLineF f a -> f (PolyLineF f b)
traverse a -> f b
f (PolyLine f a
vs) = f b -> PolyLineF f b
forall {k} (f :: k -> *) (point :: k). f point -> PolyLineF f point
PolyLine (f b -> PolyLineF f b) -> f (f b) -> f (PolyLineF f b)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (a -> f b) -> f a -> f (f b)
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> f a -> f (f b)
traverse a -> f b
f f a
vs
instance Traversable1 f => Traversable1 (PolyLineF f) where
  traverse1 :: forall (f :: * -> *) a b.
Apply f =>
(a -> f b) -> PolyLineF f a -> f (PolyLineF f b)
traverse1 a -> f b
f (PolyLine f a
vs) = f b -> PolyLineF f b
forall {k} (f :: k -> *) (point :: k). f point -> PolyLineF f point
PolyLine (f b -> PolyLineF f b) -> f (f b) -> f (PolyLineF f b)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (a -> f b) -> f a -> f (f b)
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable1 t, Apply f) =>
(a -> f b) -> t a -> f (t b)
forall (f :: * -> *) a b. Apply f => (a -> f b) -> f a -> f (f b)
traverse1 a -> f b
f f a
vs

instance ( TraversableWithIndex Int f
         , Traversable1 f
         , IxValue (f point) ~ point
         , Index   (f point) ~ Int
         , Ixed    (f point)
         ) => HasVertices (PolyLineF f point) (PolyLineF f point') where
  vertices :: IndexedTraversal1
  (VertexIx (PolyLineF f point))
  (PolyLineF f point)
  (PolyLineF f point')
  (Vertex (PolyLineF f point))
  (Vertex (PolyLineF f point'))
vertices = (f point -> f (f point'))
-> PolyLineF f point -> f (PolyLineF f point')
forall {k} {k} (f :: k -> *) (point :: k) (f' :: k -> *)
       (point' :: k) (p :: * -> * -> *) (f :: * -> *).
(Profunctor p, Functor f) =>
p (f point) (f (f' point'))
-> p (PolyLineF f point) (f (PolyLineF f' point'))
_PolyLineF ((f point -> f (f point'))
 -> PolyLineF f point -> f (PolyLineF f point'))
-> (p point (f point') -> f point -> f (f point'))
-> p point (f point')
-> PolyLineF f point
-> f (PolyLineF f point')
forall b c a. (b -> c) -> (a -> b) -> a -> c
. p point (f point') -> f point -> f (f point')
forall (f :: * -> *) a b.
Traversable1 f =>
IndexedTraversal1 Int (f a) (f b) a b
IndexedTraversal1 Int (f point) (f point') point point'
traversed1

instance ( Traversable1 f
         , IxValue (f point) ~ point
         , Index   (f point) ~ Int
         , Ixed    (f point)
         ) => HasPoints (PolyLineF f point) (PolyLineF f point') point point' where
  allPoints :: forall (d :: Nat) r r'.
(Point_ point d r, Point_ point' d r',
 NumType (PolyLineF f point) ~ r, NumType (PolyLineF f point') ~ r',
 Dimension (PolyLineF f point) ~ d,
 Dimension (PolyLineF f point') ~ d) =>
Traversal1 (PolyLineF f point) (PolyLineF f point') point point'
allPoints = (f point -> f (f point'))
-> PolyLineF f point -> f (PolyLineF f point')
forall {k} {k} (f :: k -> *) (point :: k) (f' :: k -> *)
       (point' :: k) (p :: * -> * -> *) (f :: * -> *).
(Profunctor p, Functor f) =>
p (f point) (f (f' point'))
-> p (PolyLineF f point) (f (PolyLineF f' point'))
_PolyLineF ((f point -> f (f point'))
 -> PolyLineF f point -> f (PolyLineF f point'))
-> ((point -> f point') -> f point -> f (f point'))
-> (point -> f point')
-> PolyLineF f point
-> f (PolyLineF f point')
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (point -> f point') -> f point -> f (f point')
forall (f :: * -> *) a b.
Traversable1 f =>
IndexedTraversal1 Int (f a) (f b) a b
IndexedTraversal1 Int (f point) (f point') point point'
traversed1

instance ( Traversable1 f
         , IxValue (f point) ~ point
         , Index   (f point) ~ Int
         , Ixed    (f point)
         , DefaultTransformByConstraints (PolyLineF f point) 2 r
         , Point_ point 2 r
         ) => IsTransformable (PolyLineF f point)

instance ( Traversable1 f
         , IxValue (f point) ~ point
         , Index   (f point) ~ Int
         , Ixed    (f point)
         , Point_ point 2 r
         -- , OptVector_ 2 r, OptMetric_ 2 r
         ) => IsBoxable (PolyLineF f point)

instance ( TraversableWithIndex Int f
         , Traversable1 f
         , Ixed (f point)
         , IxValue (f point) ~ point
         , Index (f point) ~ Int
         ) => HasVertices' (PolyLineF f point) where
  type Vertex   (PolyLineF f point) = point
  type VertexIx (PolyLineF f point) = Int
  vertexAt :: VertexIx (PolyLineF f point)
-> IndexedTraversal'
     (VertexIx (PolyLineF f point))
     (PolyLineF f point)
     (Vertex (PolyLineF f point))
vertexAt VertexIx (PolyLineF f point)
i = (f point -> f (f point))
-> PolyLineF f point -> f (PolyLineF f point)
forall {k} {k} (f :: k -> *) (point :: k) (f' :: k -> *)
       (point' :: k) (p :: * -> * -> *) (f :: * -> *).
(Profunctor p, Functor f) =>
p (f point) (f (f' point'))
-> p (PolyLineF f point) (f (PolyLineF f' point'))
_PolyLineF ((f point -> f (f point))
 -> PolyLineF f point -> f (PolyLineF f point))
-> (p point (f point) -> f point -> f (f point))
-> p point (f point)
-> PolyLineF f point
-> f (PolyLineF f point)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Index (f point)
-> IndexedTraversal'
     (Index (f point)) (f point) (IxValue (f point))
forall m.
Ixed m =>
Index m -> IndexedTraversal' (Index m) m (IxValue m)
iix VertexIx (PolyLineF f point)
Index (f point)
i

instance ( Traversable1 f
         -- , Ixed (f point)
         -- , IxValue (f point) ~ point
         -- , Index (f point) ~ Int
         ) => HasStart (PolyLineF f point) point where
  start :: Lens' (PolyLineF f point) point
start = (point -> f point) -> PolyLineF f point -> f (PolyLineF f point)
Lens' (PolyLineF f point) point
forall (t :: * -> *) a. Traversable1 t => Lens' (t a) a
head1

instance ( Traversable1 f
         -- , Ixed (f point)
         -- , IxValue (f point) ~ point
         -- , Index (f point) ~ Int
         ) => HasEnd (PolyLineF f point) point where
  end :: Lens' (PolyLineF f point) point
end = (point -> f point) -> PolyLineF f point -> f (PolyLineF f point)
Lens' (PolyLineF f point) point
forall (t :: * -> *) a. Traversable1 t => Lens' (t a) a
last1

instance ( Traversable1 f
         , IxValue (f point) ~ point, Index (f point) ~ Int
         , Ixed (f point)
         , HasFromFoldable1 f
         , Point_ point d r
         , TraversableWithIndex Int f
         ) => PolyLine_ (PolyLineF f point) point where

instance ( Traversable1 f
         , IxValue (f point) ~ point, Index (f point) ~ Int
         , Ixed (f point)
         , HasFromFoldable1 f
         , Point_ point d r
         , TraversableWithIndex Int f
         ) => ConstructablePolyLine_ (PolyLineF f point) point where
  polyLineFromPoints :: forall (f :: * -> *). Foldable1 f => f point -> PolyLineF f point
polyLineFromPoints = f point -> PolyLineF f point
forall {k} (f :: k -> *) (point :: k). f point -> PolyLineF f point
PolyLine (f point -> PolyLineF f point)
-> (f point -> f point) -> f point -> PolyLineF f point
forall b c a. (b -> c) -> (a -> b) -> a -> c
. f point -> f point
forall (f :: * -> *) (g :: * -> *) a.
(HasFromFoldable1 f, Foldable1 g) =>
g a -> f a
forall (g :: * -> *) a. Foldable1 g => g a -> f a
fromFoldable1

instance Reversing (f point) => Reversing (PolyLineF f point) where
  reversing :: PolyLineF f point -> PolyLineF f point
reversing = f point -> PolyLineF f point
forall {k} (f :: k -> *) (point :: k). f point -> PolyLineF f point
PolyLine (f point -> PolyLineF f point)
-> (PolyLineF f point -> f point)
-> PolyLineF f point
-> PolyLineF f point
forall b c a. (b -> c) -> (a -> b) -> a -> c
. f point -> f point
forall t. Reversing t => t -> t
reversing (f point -> f point)
-> (PolyLineF f point -> f point) -> PolyLineF f point -> f point
forall b c a. (b -> c) -> (a -> b) -> a -> c
. PolyLineF f point -> f point
forall a b. Coercible a b => a -> b
coerce