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_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_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)