Jelajahi Sumber

Merge pull request #141 from motion-twin/master

Voronoi : GetNeighborIds
Nicolas Cannasse 9 tahun lalu
induk
melakukan
daad72a472
1 mengubah file dengan 21 tambahan dan 3 penghapusan
  1. 21 3
      h2d/col/Voronoi.hx

+ 21 - 3
h2d/col/Voronoi.hx

@@ -375,9 +375,9 @@ class Cell {
 	static function sortByAngle(a:Halfedge, b:Halfedge) {
 		return b.angle > a.angle ? 1 : (b.angle < a.angle ? -1 : 0);
 	}
-
-	// Return a list of the neighbor Ids
-	public function getNeighborIds() {
+	
+	// Return a list of the neighbors
+	public function getNeighbors() {
 		var neighbors = [],
 			iHalfedge = this.halfedges.length,
 			edge;
@@ -394,6 +394,24 @@ class Cell {
 		return neighbors;
     }
 
+	// Return a list of the neighbor Indexes
+	public function getNeighborIndexes() {
+		var neighbors = [],
+			iHalfedge = this.halfedges.length,
+			edge;
+		while (iHalfedge-- != 0){
+			edge = this.halfedges[iHalfedge].edge;
+			// NC : changes pointId check to object == check
+			if (edge.lPoint != null && edge.lPoint != this.point) {
+				neighbors.push(edge.lCell.id);
+				}
+			else if (edge.rPoint != null && edge.rPoint != this.point){
+				neighbors.push(edge.rCell.id);
+				}
+			}
+		return neighbors;
+    }
+
 	public function getBbox() {
 		var halfedges = this.halfedges,
 			iHalfedge = halfedges.length,