Skip to content

Commit cb2e644

Browse files
committed
just changed some variable names
1 parent 269d06f commit cb2e644

File tree

4 files changed

+173
-8
lines changed

4 files changed

+173
-8
lines changed

bin/DelaunayLib.swc

-25.3 KB
Binary file not shown.

src/com/nodename/Delaunay/EdgeList.as

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -64,17 +64,17 @@ package com.nodename.Delaunay
6464
}
6565

6666
/**
67-
* Insert newhe to the right of lb
67+
* Insert newHalfedge to the right of lb
6868
* @param lb
69-
* @param newhe
69+
* @param newHalfedge
7070
*
7171
*/
72-
public function insert(lb:Halfedge, newhe:Halfedge):void
72+
public function insert(lb:Halfedge, newHalfedge:Halfedge):void
7373
{
74-
newhe.edgeListLeftNeighbor = lb;
75-
newhe.edgeListRightNeighbor = lb.edgeListRightNeighbor;
76-
lb.edgeListRightNeighbor.edgeListLeftNeighbor = newhe;
77-
lb.edgeListRightNeighbor = newhe;
74+
newHalfedge.edgeListLeftNeighbor = lb;
75+
newHalfedge.edgeListRightNeighbor = lb.edgeListRightNeighbor;
76+
lb.edgeListRightNeighbor.edgeListLeftNeighbor = newHalfedge;
77+
lb.edgeListRightNeighbor = newHalfedge;
7878
}
7979

8080
/**
Lines changed: 165 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,165 @@
1+
package com.nodename.Delaunay
2+
{
3+
import com.nodename.geom.Circle;
4+
import com.nodename.utils.IDisposable;
5+
6+
import flash.display.BitmapData;
7+
import flash.geom.Point;
8+
import flash.geom.Rectangle;
9+
10+
internal final class SiteList implements IDisposable
11+
{
12+
private var _sites:Vector.<Site>;
13+
private var _currentIndex:uint;
14+
15+
private var _sorted:Boolean;
16+
17+
public function SiteList()
18+
{
19+
_sites = new Vector.<Site>();
20+
_sorted = false;
21+
}
22+
23+
public function dispose():void
24+
{
25+
if (_sites)
26+
{
27+
for each (var site:Site in _sites)
28+
{
29+
site.dispose();
30+
}
31+
_sites.length = 0;
32+
_sites = null;
33+
}
34+
}
35+
36+
public function push(site:Site):uint
37+
{
38+
_sorted = false;
39+
return _sites.push(site);
40+
}
41+
42+
public function get length():uint
43+
{
44+
return _sites.length;
45+
}
46+
47+
public function next():Site
48+
{
49+
if (_sorted == false)
50+
{
51+
throw new Error("SiteList::next(): sites have not been sorted");
52+
}
53+
if (_currentIndex < _sites.length)
54+
{
55+
return _sites[_currentIndex++];
56+
}
57+
else
58+
{
59+
return null;
60+
}
61+
}
62+
63+
internal function getSitesBounds():Rectangle
64+
{
65+
if (_sorted == false)
66+
{
67+
Site.sortSites(_sites);
68+
_currentIndex = 0;
69+
_sorted = true;
70+
}
71+
var xmin:Number, xmax:Number, ymin:Number, ymax:Number;
72+
if (_sites.length == 0)
73+
{
74+
return new Rectangle(0, 0, 0, 0);
75+
}
76+
xmin = Number.MAX_VALUE;
77+
xmax = Number.MIN_VALUE;
78+
for each (var site:Site in _sites)
79+
{
80+
if (site.x < xmin)
81+
{
82+
xmin = site.x;
83+
}
84+
if (site.x > xmax)
85+
{
86+
xmax = site.x;
87+
}
88+
}
89+
// here's where we assume that the sites have been sorted on y:
90+
ymin = _sites[0].y;
91+
ymax = _sites[_sites.length - 1].y;
92+
93+
return new Rectangle(xmin, ymin, xmax - xmin, ymax - ymin);
94+
}
95+
96+
public function siteColors(referenceImage:BitmapData = null):Vector.<uint>
97+
{
98+
var colors:Vector.<uint> = new Vector.<uint>();
99+
for each (var site:Site in _sites)
100+
{
101+
colors.push(referenceImage ? referenceImage.getPixel(site.x, site.y) : site.color);
102+
}
103+
return colors;
104+
}
105+
106+
public function siteCoords():Vector.<Point>
107+
{
108+
var coords:Vector.<Point> = new Vector.<Point>();
109+
for each (var site:Site in _sites)
110+
{
111+
coords.push(site.coord);
112+
}
113+
return coords;
114+
}
115+
116+
/**
117+
*
118+
* @return the largest circle centered at each site that fits in its region;
119+
* if the region is infinite, return a circle of radius 0.
120+
*
121+
*/
122+
public function circles():Vector.<Circle>
123+
{
124+
var circles:Vector.<Circle> = new Vector.<Circle>();
125+
for each (var site:Site in _sites)
126+
{
127+
var radius:Number = 0;
128+
var nearestEdge:Edge = site.nearestEdge();
129+
130+
!nearestEdge.isPartOfConvexHull() && (radius = nearestEdge.sitesDistance() * 0.5);
131+
circles.push(new Circle(site.x, site.y, radius));
132+
}
133+
return circles;
134+
}
135+
136+
public function regions(plotBounds:Rectangle):Vector.<Vector.<Point>>
137+
{
138+
var regions:Vector.<Vector.<Point>> = new Vector.<Vector.<Point>>();
139+
for each (var site:Site in _sites)
140+
{
141+
regions.push(site.region(plotBounds));
142+
}
143+
return regions;
144+
}
145+
146+
/**
147+
*
148+
* @param proximityMap a BitmapData whose regions are filled with the site index values; see PlanePointsCanvas::fillRegions()
149+
* @param x
150+
* @param y
151+
* @return coordinates of nearest Site to (x, y)
152+
*
153+
*/
154+
public function nearestSitePoint(proximityMap:BitmapData, x:Number, y:Number):Point
155+
{
156+
var index:uint = proximityMap.getPixel(x, y);
157+
if (index > _sites.length - 1)
158+
{
159+
return null;
160+
}
161+
return _sites[index].coord;
162+
}
163+
164+
}
165+
}

src/com/nodename/Delaunay/kruskal.as

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ package com.nodename.Delaunay
2929

3030
for (var i:int = lineSegments.length; --i > -1;)
3131
{
32-
var lineSegment:LineSegment = lineSegments[i] as LineSegment;
32+
var lineSegment:LineSegment = lineSegments[i];
3333

3434
var node0:Node = nodes[lineSegment.p0];
3535
var rootOfSet0:Node;

0 commit comments

Comments
 (0)