Repository: fabanc/pyvoronoi (language: python)

Issue:
fix #11
Copied from GetCell which works OK
fix #11
Copied from GetCell which works OK


Discussion / hints:

Fix patch:
diff --git a/pyvoronoi/voronoi.cpp b/pyvoronoi/voronoi.cpp
index f11d971..2ece707 100644
--- a/pyvoronoi/voronoi.cpp
+++ b/pyvoronoi/voronoi.cpp
@@ -1,7 +1,6 @@
 #pragma warning(disable : 4503)
 #include "voronoi.hpp"
 #include "map"
-#include "iostream"
 
 VoronoiDiagram::VoronoiDiagram() {
 
@@ -82,13 +81,13 @@ c_Edge VoronoiDiagram::GetEdge(long long index)
 
 	//Find vertex references
 	long long edge_start = -1;
-    	long long edge_end = -1;
+    long long edge_end = -1;
 
-    	if (edge->vertex0() != NULL){
+    if (edge->vertex0() != NULL){
         	edge_start = map_vertices_to_indexes[edge->vertex0()];
-    	}
+    }
 
-    	if (edge->vertex1() != NULL){
+    if (edge->vertex1() != NULL){
         	edge_end = map_vertices_to_indexes[edge->vertex1()];
 	}
 
@@ -173,7 +172,6 @@ c_Cell VoronoiDiagram::GetCell(long long index)
 
 			long vertices_count = vertex_identifiers.size();
 			if (vertices_count == 0){
-				//std::cout << "Pushing start vertex index: " << edge_start << '\n';
 				vertex_identifiers.push_back(edge_start);
 			}
 			else{
@@ -182,7 +180,6 @@ c_Cell VoronoiDiagram::GetCell(long long index)
 				}
 			}
 
-			//std::cout << "Pushing end vertex index: " << edge_end << '\n';
 			vertex_identifiers.push_back(edge_end);
 			//Move to the next edge
 			edge = edge->next();
diff --git a/setup.py b/setup.py
index dbe6293..5fd2a08 100644
--- a/setup.py
+++ b/setup.py
@@ -5,7 +5,7 @@
 from setuptools.extension import Extension
 from setuptools.command.test import test as TestCommand
 
-version = '1.0.3'
+version = '1.0.5'
 
 """
 Note on using the setup.py:


Test patch:
diff --git a/tests/test_pyvoronoi.py b/tests/test_pyvoronoi.py
index f9c9c89..3c8344a 100644
--- a/tests/test_pyvoronoi.py
+++ b/tests/test_pyvoronoi.py
@@ -116,9 +116,35 @@ def test_vertex_reference_for_edges(self):
         pv.AddSegment([[10,0],[10,10]])
         pv.Construct()
         edges = pv.GetEdges()
+        cells = pv.GetCells()
+        for i in range(len(edges)):
+            edge = edges[i]
+            if cells[edge.cell].is_open == False:
+                self.assertTrue(edge.start != -1 and edge.end != -1)
+
+    def test_edge_vertices_indexes(self):
+        """
+        Test the node edge have both ends not referencing a vertex.
+        :return: 
+        """
+        pv = pyvoronoi.Pyvoronoi(1)
+        pv.AddSegment([[0,0],[0,10]])
+        pv.AddSegment([[0,0],[10,0]])
+        pv.AddSegment([[0,10],[10,10]])
+        pv.AddSegment([[10,0],[10,10]])
+        pv.Construct()
+        edges = pv.GetEdges()
+
+        vertices_count = 0
+
         for i in range(len(edges)):
             edge = edges[i]
-            self.assertTrue(edge.start != -1 and edge.end != -1)
+            vertices = [edge.start, edge.end]
+            for v in vertices:
+                if v == -1:
+                    vertices_count += 1
+
+        self.assertTrue(vertices_count == 16)
 
     def test_vertex_reference_for_cells(self):
         """