Example #1
0
File: test.py Project: sjmvm/pymca
    def _test(self, dtype):
        # Set of points for test
        tests = (
            # 2D square
            ((0, 0), (0, 1), (1, 1), (2, 0)),
            # 3D
            ((0, 0, 0), (1, 0, 0), (1, 1, 0), (0, 2, 0), (0, 0, 3)),
        )

        for points in tests:
            points = numpy.array(points, dtype=dtype)
            indices = qhull.delaunay(points, dtype=dtype)
            self.assertEqual(len(indices), 2)
            for simplex in indices:
                self.assertEqual(len(simplex), len(points[0]) + 1)
Example #2
0
    def _test(self, dtype):
        # Set of points for test
        tests = (
            # 2D square
            ((0, 0), (0, 1), (1, 1), (2, 0)),
            # 3D
            ((0, 0, 0), (1, 0, 0), (1, 1, 0), (0, 2, 0), (0, 0, 3)),
        )

        for points in tests:
            points = numpy.array(points, dtype=dtype)
            indices = qhull.delaunay(points, dtype=dtype)
            self.assertEqual(len(indices), 2)
            for simplex in indices:
                self.assertEqual(len(simplex), len(points[0]) + 1)
Example #3
0
 def _getFacets(self):
     if self.vertices is None:
         self.facets = None
     #if self.vertices.dtype == numpy.float32:
     #    self.facets = Object3DQhullf.delaunay(self.vertices[:,0:2],
     #                         "qhull d Qbb QJ Qc Po")
     #else:
     if DEBUG:
         e0 = time.time()
     self.facets = Object3DQhull.delaunay(self.vertices[:, 0:2],
                                          "qhull d Qbb QJ Qc")
     if DEBUG:
         print("delaunay elapsed = ", time.time() - e0)
         print("facets 1st= ", self.facets[0, :])
         print("vertices 1st =", self.vertices[self.facets[0,0]],\
                             self.vertices[self.facets[0,1]],\
                             self.vertices[self.facets[0,2]])
         print("COLORS = ", self.vertexColors[self.facets[0,0]],\
                        self.vertexColors[self.facets[0,1]],\
                        self.vertexColors[self.facets[0,2]])
         print("COLORS = ", self.vertexColors[self.facets[1,0]],\
                        self.vertexColors[self.facets[1,1]],\
                        self.vertexColors[self.facets[1,2]])
Example #4
0
 def _getFacets(self):
     if self.vertices is None:
         self.facets = None
     #if self.vertices.dtype == numpy.float32:
     #    self.facets = Object3DQhullf.delaunay(self.vertices[:,0:2],
     #                         "qhull d Qbb QJ Qc Po")
     #else:
     if DEBUG:
         e0 = time.time()
     self.facets = Object3DQhull.delaunay(self.vertices[:,0:2],
                              "qhull d Qbb QJ Qc")
     if DEBUG:
         print("delaunay elapsed = ", time.time() -e0)
         print("facets 1st= ",self.facets[0,:])
         print("vertices 1st =", self.vertices[self.facets[0,0]],\
                             self.vertices[self.facets[0,1]],\
                             self.vertices[self.facets[0,2]])
         print("COLORS = ", self.vertexColors[self.facets[0,0]],\
                        self.vertexColors[self.facets[0,1]],\
                        self.vertexColors[self.facets[0,2]])
         print("COLORS = ", self.vertexColors[self.facets[1,0]],\
                        self.vertexColors[self.facets[1,1]],\
                        self.vertexColors[self.facets[1,2]])