Beispiel #1
0
 def test_with_27_voxels(self):
     voxels = [i for i in Octree.get_all_voxels([0, 0, 0], 1, 3)]
     tree = Octree(voxels, 1, [[0, 3], [0, 3], [0, 3]], True)
     tree.fill_tree()
     self.assertEqual(self.get_count_voxels_on_upper_node(1, 3), len(tree.Start.Objects))
     for i in range(8):
         self.assertEqual(1, len(tree.Start.Children[i]), str(i))
Beispiel #2
0
 def test_with_125_voxels(self):
     voxels =[i for i in Octree.get_all_voxels([0, 0, 0], 1, 5)]
     tree = Octree(voxels, 1, [[0, 5], [0, 5], [0, 5]], True)
     tree.fill_tree()
     #tree.Start.distribute(True, 1)
     self.assertEqual(self.get_count_voxels_on_upper_node(1, 5), len(tree.Start.Objects))
     for child in range(8):
         self.assertEqual(7, len(tree.Start.Children[child]), str(child))
         for i in range(8):
             ch = tree.Start.Children[child]
             self.assertTrue(len(ch.Children[i]) == 1 or len(ch.Children[i]) == 0)
Beispiel #3
0
def get_voxel_model(model, size_mod, size_voxel):
    """

    :param model:
    :param size_mod: [[min_x, max_x], [min_y, max_y], [min_z, max_z]]
    :param size_voxel:
    :return:
    """
    max_size_model = max(*[i[1] - i[0] for i in size_mod])
    start_pos = [i[0] for i in size_mod]
    voxels = Octree.get_all_voxels(start_pos, size_voxel, max_size_model)
    tree = Octree(voxels, size_voxel, size_mod, True)
    tree.fill_tree()
    for mesh in model:
        temp = tree.get_all_crossing(mesh, tree.Start)
        for i in temp:
            yield i