Skip to content

Commit

Permalink
Made Edge data structure public. It appears to be the only convenient…
Browse files Browse the repository at this point in the history
… way to figure out which polygon edges link which polygons. Added a function to get the dual edge (the dual of the Voronoi polygon edge is a Delaunay triangle edge).
  • Loading branch information
amitp committed Jul 6, 2010
1 parent ee066ce commit 0c2114d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
11 changes: 9 additions & 2 deletions src/com/nodename/Delaunay/Edge.as
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ package com.nodename.Delaunay
* @author ashaw
*
*/
internal final class Edge
public final class Edge
{
private static var _pool:Vector.<Edge> = new Vector.<Edge>();

Expand Down Expand Up @@ -123,7 +123,14 @@ package com.nodename.Delaunay
// draw a line connecting the input Sites for which the edge is a bisector:
return new LineSegment(leftSite.coord, rightSite.coord);
}


public function voronoiEdge():LineSegment
{
if (!visible) return new LineSegment(null, null);
return new LineSegment(_clippedVertices[LR.LEFT],
_clippedVertices[LR.RIGHT]);
}

private static var _nedges:int = 0;

internal static const DELETED:Edge = new Edge(PrivateConstructorEnforcer);
Expand Down
10 changes: 8 additions & 2 deletions src/com/nodename/Delaunay/Voronoi.as
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,12 @@ package com.nodename.Delaunay
_sites.push(site);
_sitesIndexedByLocation[p] = site;
}


public function edges():Vector.<Edge>
{
return _edges;
}

public function region(p:Point):Vector.<Point>
{
var site:Site = _sitesIndexedByLocation[p];
Expand All @@ -108,7 +113,8 @@ package com.nodename.Delaunay
}
return site.region(_plotBounds);
}


// TODO: bug: if you call this before you call region(), something goes wrong :(
public function neighborSitesForSite(coord:Point):Vector.<Point>
{
var points:Vector.<Point> = new Vector.<Point>();
Expand Down

0 comments on commit 0c2114d

Please sign in to comment.