Esempio n. 1
0
    def test_validate_edge_mapping(self):
        """Verify the edge mapping is correct after triangulation."""
        n = 25
        d = Delaunay(n=n, seed=50)
        d.compute_triangulation()
        tri_edge_count = np.zeros((n, n), dtype=np.int32)
        edge_mapping_count = tri_edge_count.copy()
        for edge, emap in d.edge_mapping.items():
            i = edge[0]
            j = edge[1]
            self.assertTrue(i < j)
            edge_mapping_count[i, j] += len(d.edge_mapping[edge])

        for triangle in d.triangles.values():
            for edge in itertools.combinations(triangle, 2):
                i = edge[0]
                j = edge[1]
                self.assertTrue(i < j)
                tri_edge_count[i, j] += 1

        self.assertTrue(np.all(tri_edge_count == edge_mapping_count))
        self.assertEquals(np.max(tri_edge_count), 2)
Esempio n. 2
0
    def test_validation_bad_triangulation(self):
        """Test the validation method by taking a correct triangulation,
        flip a pair of triangles, verify the new triangulation is bad,
        restore the triangulation, and move to a new pair of triangles.

        Only triangle pairs that have a convex hull containing their four
        unique points are included in the flipping."""
        n = 25
        d = Delaunay(n=n, seed=50)
        d.compute_triangulation()

        self.assertTrue(d.validate_triangulation())
        self.assertTrue(self.validate_through_flip_check(d))

        # Now break the triangulation.
        for emap in d.edge_mapping.values():
            if len(emap) == 2 and self.shared_edge_angles_not_oblique(d, emap):
                id1, id2 = emap
                d.flip(id1, id2)
                self.assertFalse(d.validate_triangulation())
                self.assertFalse(self.validate_through_flip_check(d))
                d.flip(id1, id2)
                self.assertTrue(d.validate_triangulation())
                self.assertTrue(self.validate_through_flip_check(d))
Esempio n. 3
0
 def correctness_tests(self, n, reps):
     for i in range(reps):
         d = Delaunay(n=n, seed=i)
         d.compute_triangulation()
         self.assertTrue(d.validate_triangulation())
         self.assertTrue(self.validate_through_flip_check(d))
Esempio n. 4
0
 def test_validate(self):
     for i in range(100):
         d = Delaunay(n=15, seed=i)
         d.compute_triangulation()
         self.assertTrue(d.validate_triangulation())
         self.assertTrue(self.validate_through_flip_check(d))