def test_dont_add_man_size(self): node = get_empty_node_with_empty_children(4) meshes = [[[0.5, 0.5, 0.5], [1, 0.5, 1], [1, 1, 1]], [[0.6, 0.6, 0.6], [0.6, 0.7, 0.7], [0.5, 0.5, 0.5]]] node.Meshes = meshes Cot._fill_tree(node, 2) self.assertEqual(2, len(node.Children[7].Meshes))
def test_add_first_lvl_mesh(self): node = get_empty_node_with_empty_children(4) mesh = [[[1, 1, 1], [1, 2, 1], [2, 2, 2]]] node.Meshes = mesh Cot._fill_tree(node, 0.5) self.assertEqual(1, len(node.Meshes)) self.assertEqual(mesh, node.Meshes)
def test_add_mesh_on_first_lvl(self): node = get_empty_node_with_empty_children(4) mesh = [[[0, 0, 0], [2, 2, 2], [2, 3, 3]]] node.Meshes = mesh Cot._distribution(node) self.assertEqual(1, len(node.Meshes)) self.assertEqual(mesh, node.Meshes)
def test_add_third_lvl(self): node = get_empty_node_with_empty_children(4) meshes = [[[0.5, 0.5, 0.5], [1, 0.5, 1], [1, 1, 1]], [[0.6, 0.6, 0.6], [0.6, 0.7, 0.7], [0.5, 0.5, 0.5]]] node.Meshes = meshes Cot._fill_tree(node, 1) self.assertEqual(1, len(node.Children[7].Children[7].Meshes)) self.assertEqual(1, len(node.Children[7].Meshes))
def test_add_mesh_on_second_lvl(self): node = get_empty_node_with_empty_children(4) mesh = [[[3, 3, 3], [3, 3.5, 3], [3.5, 3, 3]]] node.Meshes = mesh Cot._distribution(node) self.assertEqual(0, len(node.Meshes)) self.assertEqual(1, len(node.Children[0].Meshes)) self.assertEqual(mesh, node.Children[0].Meshes)
def test_create_node_with_one_mesh(self): meshes = [[[1, 1, 1], [1, 1.5, 1], [1, 1, 1.5]]] node = Cot.get_octree(meshes, [[0, 4], [0, 4], [0, 4]], 1) self.assertEqual(1, len(node.Meshes)) self.assertEqual(4, node.Size) self.assertEqual([0, 0, 0], node.Coordinate) self.assertEqual([2.0, 2.0, 2.0], node.BoundingBox)
def test_4_points_mesh_on_boundeng_boxes(self): node = get_empty_node_with_empty_children(4) mesh = [[0, 0, 0], [2, 0, 0], [2, 2, 2], [0, 2, 2]] res = Cot._get_bounding_box_for_mesh(mesh, node) self.assertEqual([[-1, -1, -1], [0, -1, -1], [0, 0, 0], [-1, 0, 0]], res)
def test_4_points_mesh(self): node = get_empty_node_with_empty_children(4) mesh = [[0.5, 0.5, 0.5], [0.7, 0.7, 0.7], [1, 1, 1], [1.5, 1.5, 1.5]] res = Cot._get_bounding_box_for_mesh(mesh, node) self.assertEqual([[-1, -1, -1] for i in range(4)], res)
def test_3_point_with_extreme_point(self): node = get_empty_node_with_empty_children(4) mesh = [[0, 0, 0], [1, 1, 1], [1.5, 1.5, 1.5]] res = Cot._get_bounding_box_for_mesh(mesh, node) self.assertEqual([[-1, -1, -1] for i in range(3)], res)
def test_create_3_lvl_tree(self): meshes = [[[0.5, 0.5, 0.5], [1, 0.5, 1], [1, 1, 1]], [[0.6, 0.6, 0.6], [0.6, 0.7, 0.7], [0.5, 0.5, 0.5]]] node = Cot.get_octree(meshes, [[0, 4], [0, 4], [0, 4]], 0.5) self.assertEqual(1, len(node.Children[7].Meshes)) self.assertEqual(1, len(node.Children[7].Children[7].Meshes))
def test_size(self): meshes = [[[1, 1, 1], [1, 1.5, 1], [1, 1, 1.5]]] node = Cot.get_octree(meshes, [[-1, 0], [-2, -1], [1, 4]], 1) self.assertEqual(3, node.Size)
def test_coordinates(self): meshes = [[[1, 1, 1], [1, 1.5, 1], [1, 1, 1.5]]] node = Cot.get_octree(meshes, [[-1, 4], [-1, 4], [1, 4]], 1) self.assertEqual([-1, -1, 1], node.Coordinate)
def test_dont_add_one_mesh(self): node = get_empty_node_with_empty_children(4) meshes = [[[0.6, 0.6, 0.6], [0.6, 0.7, 0.7], [0.5, 0.5, 0.5]]] node.Meshes = meshes Cot._fill_tree(node, 1) self.assertEqual(1, len(node.Meshes))
def test_crossing_on_third_lvl_false(self): meshes = [[[0.5, 0.5, 0.5], [1, 0.5, 1], [1, 1, 1]], [[0.6, 0.6, 0.6], [0.6, 0.7, 0.7], [0.5, 0.5, 0.5]]] node = Cot.get_octree(meshes, [[0, 4], [0, 4], [0, 4]], 1) res = node.check_crossing([2, 2, 2], 1) self.assertFalse(res)
def test_crossing_on_second_lvl_true(self): meshes = [[[0.5, 0.5, 0.5], [1, 0.5, 1], [1, 1, 1]], [[0.6, 0.6, 0.6], [0.6, 0.7, 0.7], [1, 1, 1]]] node = Cot.get_octree(meshes, [[0, 4], [0, 4], [0, 4]], 1) res = node.check_crossing([1, 1, 1], 1) self.assertTrue(res)