Copyright | (C) Frank Staals |
---|---|
License | see the LICENSE file |
Maintainer | Frank Staals |
Safe Haskell | None |
Language | Haskell2010 |
Synopsis
- type VertexId' (s :: k) = VertexId s 'Primal
- type FaceId' (s :: k) = FaceId s 'Primal
- data VertexData r v = VertexData !(Point 2 r) !v
- vData :: forall r v v. Lens (VertexData r v) (VertexData r v) v v
- location :: forall r v r. Lens (VertexData r v) (VertexData r v) (Point 2 r) (Point 2 r)
- data FaceData h f = FaceData (Seq h) !f
- holes :: forall h f h. Lens (FaceData h f) (FaceData h f) (Seq h) (Seq h)
- fData :: forall h f f. Lens (FaceData h f) (FaceData h f) f f
- data PlanarSubdivision s v e f r = PlanarSubdivision (Vector (Component s r)) (Vector (Raw s (VertexId' (Wrap s)) v)) (Vector (Raw s (Dart (Wrap s)) e)) (Vector (RawFace s f))
- type family Wrap (s :: k) :: k where ...
- type Component s r = PlaneGraph (Wrap s) (VertexId' s) (Dart s) (FaceId' s) r
- data ComponentId s
- data PolygonFaceData
- data PlanarGraph (s :: k) (w :: World) v e f
- data PlaneGraph s v e f r
- fromSimplePolygon :: (Ord r, Fractional r) => proxy s -> SimplePolygon p r -> f -> f -> PlanarSubdivision s p () f r
- fromConnectedSegments :: (Foldable f, Ord r, Fractional r) => proxy s -> f (LineSegment 2 p r :+ e) -> PlanarSubdivision s (NonEmpty p) e () r
- fromPlaneGraph :: forall s v e f r. (Ord r, Fractional r) => PlaneGraph s v e f r -> PlanarSubdivision s v e f r
- fromPlaneGraph' :: forall s v e f r. PlaneGraph s v e f r -> Dart s -> PlanarSubdivision s v e f r
- numComponents :: PlanarSubdivision s v e f r -> Int
- numVertices :: PlanarSubdivision s v e f r -> Int
- numEdges :: PlanarSubdivision s v e f r -> Int
- numFaces :: PlanarSubdivision s v e f r -> Int
- numDarts :: PlanarSubdivision s v e f r -> Int
- dual :: forall k (s :: k) (w :: World) v e f. Getter (PlanarGraph s w v e f) (PlanarGraph s (DualOf w) f e v)
- components :: forall k (s :: k) v e f r r. Lens (PlanarSubdivision (s :: k) v e f r) (PlanarSubdivision (s :: k) v e f r) (Vector (Component s r)) (Vector (Component s r))
- component :: ComponentId s -> Lens' (PlanarSubdivision s v e f r) (Component s r)
- vertices' :: PlanarSubdivision s v e f r -> Vector (VertexId' s)
- vertices :: PlanarSubdivision s v e f r -> Vector (VertexId' s, VertexData r v)
- edges' :: PlanarSubdivision s v e f r -> Vector (Dart s)
- edges :: PlanarSubdivision s v e f r -> Vector (Dart s, e)
- faces' :: PlanarSubdivision s v e f r -> Vector (FaceId' s)
- faces :: PlanarSubdivision s v e f r -> Vector (FaceId' s, FaceData (Dart s) f)
- internalFaces :: PlanarSubdivision s v e f r -> Vector (FaceId' s, FaceData (Dart s) f)
- darts' :: PlanarSubdivision s v e f r -> Vector (Dart s)
- headOf :: Dart s -> PlanarSubdivision s v e f r -> VertexId' s
- tailOf :: Dart s -> PlanarSubdivision s v e f r -> VertexId' s
- twin :: forall k (s :: k). Dart s -> Dart s
- endPoints :: Dart s -> PlanarSubdivision s v e f r -> (VertexId' s, VertexId' s)
- incidentEdges :: VertexId' s -> PlanarSubdivision s v e f r -> Vector (Dart s)
- incomingEdges :: VertexId' s -> PlanarSubdivision s v e f r -> Vector (Dart s)
- outgoingEdges :: VertexId' s -> PlanarSubdivision s v e f r -> Vector (Dart s)
- nextIncidentEdge :: Dart s -> PlanarSubdivision s v e f r -> Dart s
- neighboursOf :: VertexId' s -> PlanarSubdivision s v e f r -> Vector (VertexId' s)
- leftFace :: Dart s -> PlanarSubdivision s v e f r -> FaceId' s
- rightFace :: Dart s -> PlanarSubdivision s v e f r -> FaceId' s
- outerBoundaryDarts :: FaceId' s -> PlanarSubdivision s v e f r -> Vector (Dart s)
- boundaryVertices :: FaceId' s -> PlanarSubdivision s v e f r -> Vector (VertexId' s)
- holesOf :: FaceId' s -> PlanarSubdivision s v e f r -> Seq (Dart s)
- outerFaceId :: PlanarSubdivision s v e f r -> FaceId' s
- boundary' :: Dart s -> PlanarSubdivision s v e f r -> Vector (Dart s)
- locationOf :: VertexId' s -> Lens' (PlanarSubdivision s v e f r) (Point 2 r)
- class HasDataOf g i where
- endPointsOf :: Dart s -> Getter (PlanarSubdivision s v e f r) (VertexData r v, VertexData r v)
- endPointData :: Dart s -> PlanarSubdivision s v e f r -> (VertexData r v, VertexData r v)
- faceDataOf :: FaceId' s -> Lens' (PlanarSubdivision s v e f r) (FaceData (Dart s) f)
- edgeSegment :: Dart s -> PlanarSubdivision s v e f r -> LineSegment 2 v r :+ e
- edgeSegments :: PlanarSubdivision s v e f r -> Vector (Dart s, LineSegment 2 v r :+ e)
- rawFacePolygon :: FaceId' s -> PlanarSubdivision s v e f r -> SomePolygon v r :+ f
- rawFaceBoundary :: FaceId' s -> PlanarSubdivision s v e f r -> SimplePolygon v r :+ f
- rawFacePolygons :: PlanarSubdivision s v e f r -> Vector (FaceId' s, SomePolygon v r :+ f)
- newtype VertexId (s :: k) (w :: World) = VertexId {
- _unVertexId :: Int
- newtype FaceId (s :: k) (w :: World) = FaceId {}
- data Dart (s :: k)
- data World
- rawVertexData :: forall k (s :: k) v e f r v. Lens (PlanarSubdivision (s :: k) v e f r) (PlanarSubdivision (s :: k) v e f r) (Vector (Raw s (VertexId' (Wrap s)) v)) (Vector (Raw s (VertexId' (Wrap s)) v))
- rawDartData :: forall k (s :: k) v e f r e. Lens (PlanarSubdivision (s :: k) v e f r) (PlanarSubdivision (s :: k) v e f r) (Vector (Raw s (Dart (Wrap s)) e)) (Vector (Raw s (Dart (Wrap s)) e))
- rawFaceData :: forall k (s :: k) v e f r f. Lens (PlanarSubdivision (s :: k) v e f r) (PlanarSubdivision (s :: k) v e f r) (Vector (RawFace s f)) (Vector (RawFace s f))
- vertexData :: Lens (PlanarSubdivision s v e f r) (PlanarSubdivision s v' e f r) (Vector v) (Vector v')
- dartData :: Lens (PlanarSubdivision s v e f r) (PlanarSubdivision s v e' f r) (Vector (Dart s, e)) (Vector (Dart s, e'))
- faceData :: Lens (PlanarSubdivision s v e f r) (PlanarSubdivision s v e f' r) (Vector f) (Vector f')
- dataVal :: Lens (Raw s ia a) (Raw s ia b) a b
- dartMapping :: PlanarSubdivision s v e f r -> Vector (Dart (Wrap s), Dart s)
- data Raw s ia a = Raw {
- _compId :: !(ComponentId s)
- _idxVal :: !ia
- _dataVal :: !a
Documentation
data VertexData r v Source #
Note that the functor instance is in v
VertexData !(Point 2 r) !v |
Instances
vData :: forall r v v. Lens (VertexData r v) (VertexData r v) v v Source #
location :: forall r v r. Lens (VertexData r v) (VertexData r v) (Point 2 r) (Point 2 r) Source #
The Face data consists of the data itself and a list of holes
Instances
data PlanarSubdivision s v e f r Source #
A planarsubdivision is essentially a bunch of plane-graphs; one for every connected component. These graphs store the global ID's (darts, vertexId's, faceId's) in their data values. This essentially gives us a mapping between the two.
note that a face may actually occur in multiple graphs, hence when we store
the edges to the the holes, we store the global edgeId's rather than the
local
edgeId (dart)'s.
invariant: the outerface has faceId 0
PlanarSubdivision (Vector (Component s r)) (Vector (Raw s (VertexId' (Wrap s)) v)) (Vector (Raw s (Dart (Wrap s)) e)) (Vector (RawFace s f)) |
Instances
type Component s r = PlaneGraph (Wrap s) (VertexId' s) (Dart s) (FaceId' s) r Source #
A connected component.
For every face f, and every hole in this face, the facedata points to a dart d on the hole s.t. this dart has the face f on its left. i.e. leftFace d = f
data ComponentId s Source #
ComponentId type
Instances
data PolygonFaceData Source #
Data type that expresses whether or not we are inside or outside the polygon.
Instances
Eq PolygonFaceData Source # | |
Defined in Data.Geometry.PlanarSubdivision.Basic (==) :: PolygonFaceData -> PolygonFaceData -> Bool # (/=) :: PolygonFaceData -> PolygonFaceData -> Bool # | |
Read PolygonFaceData Source # | |
Defined in Data.Geometry.PlanarSubdivision.Basic | |
Show PolygonFaceData Source # | |
Defined in Data.Geometry.PlanarSubdivision.Basic showsPrec :: Int -> PolygonFaceData -> ShowS # show :: PolygonFaceData -> String # showList :: [PolygonFaceData] -> ShowS # |
data PlanarGraph (s :: k) (w :: World) v e f #
A *connected* Planar graph with bidirected edges. I.e. the edges (darts) are directed, however, for every directed edge, the edge in the oposite direction is also in the graph.
The types v, e, and f are the are the types of the data associated with the vertices, edges, and faces, respectively.
The orbits in the embedding are assumed to be in counterclockwise order. Therefore, every dart directly bounds the face to its right.
Instances
data PlaneGraph s v e f r Source #
Embedded, *connected*, planar graph
Instances
:: (Ord r, Fractional r) | |
=> proxy s | |
-> SimplePolygon p r | |
-> f | data inside |
-> f | data outside the polygon |
-> PlanarSubdivision s p () f r |
Construct a plane graph from a simple polygon. It is assumed that the polygon is given in counterclockwise order.
the interior of the polygon will have faceId 0
pre: the input polygon is given in counterclockwise order running time: \(O(n)\).
fromConnectedSegments :: (Foldable f, Ord r, Fractional r) => proxy s -> f (LineSegment 2 p r :+ e) -> PlanarSubdivision s (NonEmpty p) e () r Source #
Constructs a connected planar subdivision.
pre: the segments form a single connected component running time: \(O(n\log n)\)
fromPlaneGraph :: forall s v e f r. (Ord r, Fractional r) => PlaneGraph s v e f r -> PlanarSubdivision s v e f r Source #
Constructs a planarsubdivision from a PlaneGraph
runningTime: \(O(n)\)
fromPlaneGraph' :: forall s v e f r. PlaneGraph s v e f r -> Dart s -> PlanarSubdivision s v e f r Source #
Given a (connected) PlaneGraph and a dart that has the outerface on its left | Constructs a planarsubdivision
runningTime: \(O(n)\)
numComponents :: PlanarSubdivision s v e f r -> Int Source #
Get the number of vertices
>>>
numVertices myGraph
1
numVertices :: PlanarSubdivision s v e f r -> Int Source #
Get the number of vertices
>>>
numVertices myGraph
4
numEdges :: PlanarSubdivision s v e f r -> Int Source #
Get the number of Edges
>>>
numEdges myGraph
6
numFaces :: PlanarSubdivision s v e f r -> Int Source #
\( O(1) \). Get the number of faces
>>>
numFaces myGraph
4
numDarts :: PlanarSubdivision s v e f r -> Int Source #
Get the number of Darts
>>>
numDarts myGraph
12
dual :: forall k (s :: k) (w :: World) v e f. Getter (PlanarGraph s w v e f) (PlanarGraph s (DualOf w) f e v) #
Get the dual graph of this graph.
components :: forall k (s :: k) v e f r r. Lens (PlanarSubdivision (s :: k) v e f r) (PlanarSubdivision (s :: k) v e f r) (Vector (Component s r)) (Vector (Component s r)) Source #
component :: ComponentId s -> Lens' (PlanarSubdivision s v e f r) (Component s r) Source #
vertices' :: PlanarSubdivision s v e f r -> Vector (VertexId' s) Source #
Enumerate all vertices
>>>
vertices' myGraph
[VertexId 0,VertexId 1,VertexId 2,VertexId 3]
vertices :: PlanarSubdivision s v e f r -> Vector (VertexId' s, VertexData r v) Source #
Enumerate all vertices, together with their vertex data
edges' :: PlanarSubdivision s v e f r -> Vector (Dart s) Source #
Enumerate all edges. We report only the Positive darts
edges :: PlanarSubdivision s v e f r -> Vector (Dart s, e) Source #
Enumerate all edges with their edge data. We report only the Positive darts.
>>>
mapM_ print $ edges myGraph
(Dart (Arc 2) +1,"c+") (Dart (Arc 1) +1,"b+") (Dart (Arc 0) +1,"a+") (Dart (Arc 5) +1,"g+") (Dart (Arc 4) +1,"e+") (Dart (Arc 3) +1,"d+")
faces' :: PlanarSubdivision s v e f r -> Vector (FaceId' s) Source #
\( O(n) \). Vector of all primal faces.
faces :: PlanarSubdivision s v e f r -> Vector (FaceId' s, FaceData (Dart s) f) Source #
\( O(n) \). Vector of all primal faces with associated data.
internalFaces :: PlanarSubdivision s v e f r -> Vector (FaceId' s, FaceData (Dart s) f) Source #
Enumerates all faces with their face data exlcluding the outer face
headOf :: Dart s -> PlanarSubdivision s v e f r -> VertexId' s Source #
The vertex this dart is heading in to
running time: \(O(1)\)
tailOf :: Dart s -> PlanarSubdivision s v e f r -> VertexId' s Source #
The tail of a dart, i.e. the vertex this dart is leaving from
running time: \(O(1)\)
twin :: forall k (s :: k). Dart s -> Dart s #
Get the twin of this dart (edge)
>>>
twin (dart 0 "+1")
Dart (Arc 0) -1>>>
twin (dart 0 "-1")
Dart (Arc 0) +1
endPoints :: Dart s -> PlanarSubdivision s v e f r -> (VertexId' s, VertexId' s) Source #
endPoints d g = (tailOf d g, headOf d g)
running time: \(O(1)\)
incidentEdges :: VertexId' s -> PlanarSubdivision s v e f r -> Vector (Dart s) Source #
All edges incident to vertex v, in counterclockwise order around v.
running time: \(O(k)\), where \(k\) is the number of edges reported.
incomingEdges :: VertexId' s -> PlanarSubdivision s v e f r -> Vector (Dart s) Source #
All edges incident to vertex v in incoming direction (i.e. pointing into v) in counterclockwise order around v.
running time: \(O(k)\), where (k) is the total number of incident edges of v
outgoingEdges :: VertexId' s -> PlanarSubdivision s v e f r -> Vector (Dart s) Source #
All edges incident to vertex v in outgoing direction (i.e. pointing away from v) in counterclockwise order around v.
running time: \(O(k)\), where (k) is the total number of incident edges of v
nextIncidentEdge :: Dart s -> PlanarSubdivision s v e f r -> Dart s Source #
Given a dart d that points into some vertex v, report the next dart e in the cyclic order around v.
running time: \(O(1)\)
neighboursOf :: VertexId' s -> PlanarSubdivision s v e f r -> Vector (VertexId' s) Source #
Gets the neighbours of a particular vertex, in counterclockwise order around the vertex.
running time: \(O(k)\), where \(k\) is the output size
leftFace :: Dart s -> PlanarSubdivision s v e f r -> FaceId' s Source #
The face to the left of the dart
running time: \(O(1)\).
rightFace :: Dart s -> PlanarSubdivision s v e f r -> FaceId' s Source #
The face to the right of the dart
running time: \(O(1)\).
outerBoundaryDarts :: FaceId' s -> PlanarSubdivision s v e f r -> Vector (Dart s) Source #
The darts on the outer boundary of the face, for internal faces the darts are in clockwise order. For the outer face the darts are in counterclockwise order, and the darts from various components are in no particular order.
running time: \(O(k)\), where \(k\) is the output size.
boundaryVertices :: FaceId' s -> PlanarSubdivision s v e f r -> Vector (VertexId' s) Source #
The vertices of the outer boundary of the face, for internal faces in clockwise order, for the outer face in counter clockwise order.
running time: \(O(k)\), where \(k\) is the output size.
holesOf :: FaceId' s -> PlanarSubdivision s v e f r -> Seq (Dart s) Source #
Lists the holes in this face, given as a list of darts to arbitrary darts on those faces. The returned darts are on the outside of the hole, i.e. they are incident to the given input face:
all (\d -> leftFace d ps == fi) $ holesOf fi ps
running time: \(O(k)\), where \(k\) is the number of darts returned.
outerFaceId :: PlanarSubdivision s v e f r -> FaceId' s Source #
gets the id of the outer face
running time: \(O(1)\)
boundary' :: Dart s -> PlanarSubdivision s v e f r -> Vector (Dart s) Source #
Generates the darts incident to a face, starting with the given dart.
\(O(k)\), where \(k\) is the number of darts reported
locationOf :: VertexId' s -> Lens' (PlanarSubdivision s v e f r) (Point 2 r) Source #
General interface to accessing vertex data, dart data, and face data.
dataOf :: i -> Lens' g (DataOf g i) #
get the data associated with the value i.
running time: \(O(1)\) to read the data, \(O(n)\) to write it.
Instances
endPointsOf :: Dart s -> Getter (PlanarSubdivision s v e f r) (VertexData r v, VertexData r v) Source #
Getter for the data at the endpoints of a dart
running time: \(O(1)\)
endPointData :: Dart s -> PlanarSubdivision s v e f r -> (VertexData r v, VertexData r v) Source #
data corresponding to the endpoints of the dart
running time: \(O(1)\)
faceDataOf :: FaceId' s -> Lens' (PlanarSubdivision s v e f r) (FaceData (Dart s) f) Source #
edgeSegment :: Dart s -> PlanarSubdivision s v e f r -> LineSegment 2 v r :+ e Source #
Given a dart and the subdivision constructs the line segment representing it
\(O(1)\)
edgeSegments :: PlanarSubdivision s v e f r -> Vector (Dart s, LineSegment 2 v r :+ e) Source #
Reports all edges as line segments
rawFacePolygon :: FaceId' s -> PlanarSubdivision s v e f r -> SomePolygon v r :+ f Source #
Constructs the boundary of the given face
\(O(k)\), where \(k\) is the complexity of the face
rawFaceBoundary :: FaceId' s -> PlanarSubdivision s v e f r -> SimplePolygon v r :+ f Source #
Constructs the outer boundary of the face
\(O(k)\), where \(k\) is the complexity of the outer boundary of the face
rawFacePolygons :: PlanarSubdivision s v e f r -> Vector (FaceId' s, SomePolygon v r :+ f) Source #
Lists all *internal* faces of the planar subdivision.
newtype VertexId (s :: k) (w :: World) #
A vertex in a planar graph. A vertex is tied to a particular planar graph by the phantom type s, and to a particular world w.
Instances
newtype FaceId (s :: k) (w :: World) #
The type to represent FaceId's
Instances
A dart represents a bi-directed edge. I.e. a dart has a direction, however the dart of the oposite direction is always present in the planar graph as well.
Instances
The world in which the graph lives
rawVertexData :: forall k (s :: k) v e f r v. Lens (PlanarSubdivision (s :: k) v e f r) (PlanarSubdivision (s :: k) v e f r) (Vector (Raw s (VertexId' (Wrap s)) v)) (Vector (Raw s (VertexId' (Wrap s)) v)) Source #
rawDartData :: forall k (s :: k) v e f r e. Lens (PlanarSubdivision (s :: k) v e f r) (PlanarSubdivision (s :: k) v e f r) (Vector (Raw s (Dart (Wrap s)) e)) (Vector (Raw s (Dart (Wrap s)) e)) Source #
rawFaceData :: forall k (s :: k) v e f r f. Lens (PlanarSubdivision (s :: k) v e f r) (PlanarSubdivision (s :: k) v e f r) (Vector (RawFace s f)) (Vector (RawFace s f)) Source #
vertexData :: Lens (PlanarSubdivision s v e f r) (PlanarSubdivision s v' e f r) (Vector v) (Vector v') Source #
Lens to the facedata of the vertexdata themselves. The indices correspond to the vertexId's
dartData :: Lens (PlanarSubdivision s v e f r) (PlanarSubdivision s v e' f r) (Vector (Dart s, e)) (Vector (Dart s, e')) Source #
lens to access the Dart Data
faceData :: Lens (PlanarSubdivision s v e f r) (PlanarSubdivision s v e f' r) (Vector f) (Vector f') Source #
Lens to the facedata of the faces themselves. The indices correspond to the faceIds
dartMapping :: PlanarSubdivision s v e f r -> Vector (Dart (Wrap s), Dart s) Source #
Helper type for the data that we store in a planar subdivision
Raw | |
|
Instances
Functor (Raw s ia) Source # | |
Foldable (Raw s ia) Source # | |
Defined in Data.Geometry.PlanarSubdivision.Raw fold :: Monoid m => Raw s ia m -> m # foldMap :: Monoid m => (a -> m) -> Raw s ia a -> m # foldMap' :: Monoid m => (a -> m) -> Raw s ia a -> m # foldr :: (a -> b -> b) -> b -> Raw s ia a -> b # foldr' :: (a -> b -> b) -> b -> Raw s ia a -> b # foldl :: (b -> a -> b) -> b -> Raw s ia a -> b # foldl' :: (b -> a -> b) -> b -> Raw s ia a -> b # foldr1 :: (a -> a -> a) -> Raw s ia a -> a # foldl1 :: (a -> a -> a) -> Raw s ia a -> a # elem :: Eq a => a -> Raw s ia a -> Bool # maximum :: Ord a => Raw s ia a -> a # minimum :: Ord a => Raw s ia a -> a # | |
Traversable (Raw s ia) Source # | |
Defined in Data.Geometry.PlanarSubdivision.Raw | |
(Eq ia, Eq a) => Eq (Raw s ia a) Source # | |
(Show ia, Show a) => Show (Raw s ia a) Source # | |
Generic (Raw s ia a) Source # | |
(ToJSON ia, ToJSON a) => ToJSON (Raw s ia a) Source # | |
Defined in Data.Geometry.PlanarSubdivision.Raw | |
(FromJSON ia, FromJSON a) => FromJSON (Raw s ia a) Source # | |
type Rep (Raw s ia a) Source # | |
Defined in Data.Geometry.PlanarSubdivision.Raw type Rep (Raw s ia a) = D1 ('MetaData "Raw" "Data.Geometry.PlanarSubdivision.Raw" "hgeometry-0.12.0.2-IMXeR0PuShPEjPCARytEWE" 'False) (C1 ('MetaCons "Raw" 'PrefixI 'True) (S1 ('MetaSel ('Just "_compId") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (ComponentId s)) :*: (S1 ('MetaSel ('Just "_idxVal") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 ia) :*: S1 ('MetaSel ('Just "_dataVal") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 a)))) |