def test_selfintersects(self):
        tree_handle_no = aabb_normals.aabbtree_n_compute(self.simple_m.v,
                                                         self.simple_m.f.astype(np.uint32).copy(),
                                                         0.5)

        self.assertTrue(aabb_normals.aabbtree_n_selfintersects(tree_handle_no) == 0)

        tree_handle_yes = aabb_normals.aabbtree_n_compute(self.self_int_cyl_m.v,
                                                          self.self_int_cyl_m.f.astype(np.uint32).copy(),
                                                          0.5)

        self.assertTrue(aabb_normals.aabbtree_n_selfintersects(tree_handle_yes) == (2 * 8))
Exemple #2
0
    def test_cylinders(self):
        create_tree = lambda eps: aabb_normals.aabbtree_n_compute(
            self.cylinder_m.v,
            self.cylinder_m.f.astype(np.uint32).copy(), eps)
        tree_handle_no_normals = create_tree(0)
        tree_handle_normals = create_tree(10)

        query_v = self.cylinder_trans_m.v

        tri_n = NormalizeRows(
            TriToScaledNormal(self.cylinder_trans_m.v,
                              self.cylinder_trans_m.f))

        query_n = np.zeros(self.cylinder_trans_m.v.shape)
        for i_f in range(self.cylinder_trans_m.f.shape[0]):
            query_n[self.cylinder_trans_m.f[i_f, :], :] += tri_n[i_f, :]
        query_n = NormalizeRows(query_n)

        closest_tri, _ = aabb_normals.aabbtree_n_nearest(
            tree_handle_no_normals, query_v, query_n)
        # all closest triangles are the two extremes
        self.assertTrue(np.unique(closest_tri).shape[0] <= 4)

        closest_tri_n, _ = aabb_normals.aabbtree_n_nearest(
            tree_handle_normals, query_v, query_n)
        # there are four triangles that do not need to be reached, in the center and in the extremes
        self.assertTrue(
            np.unique(closest_tri_n).shape[0] >= (self.cylinder_m.f.shape[0] -
                                                  4))
Exemple #3
0
 def test_dist_classic(self):
     tree_handle = aabb_normals.aabbtree_n_compute(
         self.simple_m.v,
         self.simple_m.f.astype(np.uint32).copy(), 0.0)
     query_v = np.array([[0.5, 0.1, 0.25], [0.5, 0.1, 0.25]])
     query_n = np.array([[0.0, 1.0, 0.0], [1.0, 0.0, 0.0]])
     closest_tri, closest_p = aabb_normals.aabbtree_n_nearest(
         tree_handle, query_v, query_n)
     self.assertTrue((closest_tri == np.array([[0, 0]])).all())
     self.assertTrue((closest_p == query_v).all())