def test_rotation_180(self): mesh_1 = generate_box_mesh(np.array([-2, -1, -1]), np.array([2, 1, 1])) rot = Quaternion.fromAxisAngle(np.array([1.0, 1.0, 0.0]), math.pi / 2.0) mesh_2 = form_mesh( np.dot(rot.to_matrix(), mesh_1.vertices.T).T, mesh_1.faces) mesh = boolean(mesh_1, mesh_2, "union", "cgal") self.assertTrue(mesh.is_closed()) self.assertTrue(mesh.is_manifold()) self.assertEqual(1, mesh.num_components)
def test_intersection_with_slighly_rotated_self(self): mesh_1 = generate_box_mesh(np.array([0, 0, 0]), np.array([1, 1, 1])) rot = Quaternion.fromAxisAngle(np.array([1.0, 1.0, 1.0]), 0.0001) mesh_2 = form_mesh( np.dot(rot.to_matrix(), mesh_1.vertices.T).T, mesh_1.faces) mesh = boolean(mesh_1, mesh_2, "intersection", "igl") self.assertTrue(mesh.is_closed()) self.assertTrue(mesh.is_manifold()) self.assertTrue(1, mesh.num_components)
def test_rotate_union_120_degrees(self): # TODO: Bug mesh_1 = generate_box_mesh(np.array([-2, -1, -1]), np.array([2, 1, 1])) rot = Quaternion.fromAxisAngle(np.array([1.0, 0.0, 0.0]), float(2 * math.pi) / 3) mesh_2 = form_mesh( np.dot(rot.to_matrix(), mesh_1.vertices.T).T, mesh_1.faces) mesh = boolean(mesh_1, mesh_2, "union", "igl") self.assertTrue(mesh.is_closed()) self.assertTrue(mesh.is_manifold()) self.assertEqual(1, mesh.num_components)
def test_rotation_180(self): mesh_1 = generate_box_mesh( np.array([-2, -1, -1]), np.array([2, 1, 1])); rot = Quaternion.fromAxisAngle( np.array([1.0, 1.0, 0.0]), math.pi / 2.0); mesh_2 = form_mesh( np.dot(rot.to_matrix(), mesh_1.vertices.T).T, mesh_1.faces); mesh = boolean(mesh_1, mesh_2, "union", "cgal"); self.assertTrue(mesh.is_closed()); self.assertTrue(mesh.is_manifold()); self.assertEqual(1, mesh.num_components);
def test_union_with_45_rotated_self(self): mesh_1 = generate_box_mesh( np.array([0, 0, 0]), np.array([1, 1, 1])); rot = Quaternion.fromAxisAngle(np.array([1.0, 1.0, 1.0]), math.pi/4.0); mesh_2 = form_mesh( np.dot(rot.to_matrix(), mesh_1.vertices.T).T, mesh_1.faces); mesh = boolean(mesh_1, mesh_2, "union", "igl"); self.assertTrue(mesh.is_closed()); self.assertTrue(mesh.is_manifold()); self.assertTrue(1, mesh.num_components);
def test_rotate_union_120_degrees(self): # TODO: Bug mesh_1 = generate_box_mesh( np.array([-2, -1, -1]), np.array([2, 1, 1])); rot = Quaternion.fromAxisAngle( np.array([1.0, 0.0, 0.0]), float(2*math.pi) / 3); mesh_2 = form_mesh( np.dot(rot.to_matrix(), mesh_1.vertices.T).T, mesh_1.faces); mesh = boolean(mesh_1, mesh_2, "union", "igl"); self.assertTrue(mesh.is_closed()); self.assertTrue(mesh.is_manifold()); self.assertEqual(1, mesh.num_components);
def test_rotate_120(self): mesh_1 = generate_box_mesh(np.array([-2, -1, -1]), np.array([2, 1, 1])) rot = Quaternion.fromAxisAngle(np.array([1.0, 0.0, 0.0]), float(2 * math.pi) / 3) mesh_2 = form_mesh( np.dot(rot.to_matrix(), mesh_1.vertices.T).T, mesh_1.faces) mesh = merge_meshes((mesh_1, mesh_2)) output_mesh = resolve_self_intersection(mesh) self.assert_self_intersect(mesh) # The output mesh contains degenerated face. #self.assert_no_self_intersect(output_mesh); self.assert_even_adj_faces(output_mesh)
def test_union_with_rotated_self(self): #TODO: bug mesh_1 = generate_box_mesh(np.array([0, 0, 0]), np.array([1, 1, 1])) rot = Quaternion.fromAxisAngle(np.array([1, 1, 0], dtype=float), math.pi * 0.5) mesh_2 = form_mesh( np.dot(rot.to_matrix(), mesh_1.vertices.T).T + np.array([0.5, 0.5, 0.5]), mesh_1.faces) mesh = boolean(mesh_1, mesh_2, "union", "igl") self.assertTrue(mesh.is_closed()) self.assertTrue(mesh.is_manifold()) self.assertEqual(1, mesh.num_components)
def test_rotation_union_stress_2(self): # TODO: Bug N = 3 mesh_1 = generate_box_mesh(np.array([-2, -1, -1]), np.array([2, 1, 1])) mesh = mesh_1 for i in range(N): rot = Quaternion.fromAxisAngle(np.array([1.0, 1.0, 0.0]), float(i * 2 * math.pi) / N) mesh_2 = form_mesh( np.dot(rot.to_matrix(), mesh_1.vertices.T).T, mesh_1.faces) mesh = boolean(mesh, mesh_2, "union", "igl") self.assertTrue(mesh.is_closed()) self.assertTrue(mesh.is_manifold()) self.assertEqual(1, mesh.num_components)
def test_intersect_with_rotated_self(self): mesh_1 = generate_box_mesh(np.array([0, 0, 0]), np.array([1, 1, 1])) rot = Quaternion.fromAxisAngle(np.array([1, 1, 0], dtype=float), math.pi * 0.5) mesh_2 = form_mesh( np.dot(rot.to_matrix(), mesh_1.vertices.T).T + np.array([0.5, 0.5, 0.5]), mesh_1.faces) mesh = merge_meshes((mesh_1, mesh_2)) output_mesh = resolve_self_intersection(mesh) self.assert_self_intersect(mesh) # The output mesh contains degenerated triangles, which cause CGAL # assertion failure. #self.assert_no_self_intersect(output_mesh); self.assert_even_adj_faces(output_mesh)
def test_union_with_rotated_self(self): #TODO: bug mesh_1 = generate_box_mesh( np.array([0, 0, 0]), np.array([1, 1, 1])); rot = Quaternion.fromAxisAngle(np.array([1, 1, 0], dtype=float), math.pi * 0.5); mesh_2 = form_mesh( np.dot(rot.to_matrix(), mesh_1.vertices.T).T + np.array([0.5, 0.5, 0.5]), mesh_1.faces); mesh = boolean(mesh_1, mesh_2, "union", "igl"); self.assertTrue(mesh.is_closed()); self.assertTrue(mesh.is_manifold()); self.assertEqual(1, mesh.num_components);
def test_rotate_120(self): mesh_1 = generate_box_mesh( np.array([-2, -1, -1]), np.array([2, 1, 1])); rot = Quaternion.fromAxisAngle( np.array([1.0, 0.0, 0.0]), float(2*math.pi) / 3); mesh_2 = form_mesh( np.dot(rot.to_matrix(), mesh_1.vertices.T).T, mesh_1.faces); mesh = merge_meshes((mesh_1, mesh_2)); output_mesh = resolve_self_intersection(mesh); self.assert_self_intersect(mesh); # The output mesh contains degenerated face. #self.assert_no_self_intersect(output_mesh); self.assert_even_adj_faces(output_mesh);
def test_edge_edge_orthogonal_touch(self): eps = np.finfo(float).eps mesh_1 = generate_box_mesh(np.array([0, 0, 0]), np.array([1, 1, 1])) rot = Quaternion.fromAxisAngle(np.array([1, 1, 0], dtype=float), math.pi * 0.5) mesh_2 = form_mesh( np.dot(rot.to_matrix(), mesh_1.vertices.T).T + np.array([-1, -1, 0.5], dtype=float) + np.array( [-math.sqrt(2) / 4.0 + eps, math.sqrt(2) / 4.0 + eps, 0.0], dtype=float), mesh_1.faces) mesh = boolean(mesh_1, mesh_2, "union", "igl") self.assertTrue(mesh.is_closed()) self.assertTrue(mesh.is_manifold()) self.assertEqual(1, mesh.num_components)
def test_rotation_union_stress_2(self): # TODO: Bug N = 3; mesh_1 = generate_box_mesh( np.array([-2, -1, -1]), np.array([2, 1, 1])); mesh = mesh_1; for i in range(N): rot = Quaternion.fromAxisAngle( np.array([1.0, 1.0, 0.0]), float(i*2*math.pi) / N); mesh_2 = form_mesh( np.dot(rot.to_matrix(), mesh_1.vertices.T).T, mesh_1.faces); mesh = boolean(mesh, mesh_2, "union", "igl"); self.assertTrue(mesh.is_closed()); self.assertTrue(mesh.is_manifold()); self.assertEqual(1, mesh.num_components);
def test_edge_edge_orthogonal_touch(self): eps = np.finfo(float).eps; mesh_1 = generate_box_mesh( np.array([0, 0, 0]), np.array([1, 1, 1])); rot = Quaternion.fromAxisAngle(np.array([1, 1, 0], dtype=float), math.pi * 0.5); mesh_2 = form_mesh( np.dot(rot.to_matrix(), mesh_1.vertices.T).T + np.array([-1, -1, 0.5], dtype=float)+ np.array([-math.sqrt(2)/4.0 + eps, math.sqrt(2)/4.0+eps, 0.0], dtype=float), mesh_1.faces); mesh = boolean(mesh_1, mesh_2, "union", "igl"); self.assertTrue(mesh.is_closed()); self.assertTrue(mesh.is_manifold()); self.assertEqual(1, mesh.num_components);
def test_intersect_with_rotated_self(self): mesh_1 = generate_box_mesh( np.array([0, 0, 0]), np.array([1, 1, 1])); rot = Quaternion.fromAxisAngle(np.array([1, 1, 0], dtype=float), math.pi * 0.5); mesh_2 = form_mesh( np.dot(rot.to_matrix(), mesh_1.vertices.T).T + np.array([0.5, 0.5, 0.5]), mesh_1.faces); mesh = merge_meshes((mesh_1, mesh_2)); output_mesh = resolve_self_intersection(mesh); self.assert_self_intersect(mesh); # The output mesh contains degenerated triangles, which cause CGAL # assertion failure. #self.assert_no_self_intersect(output_mesh); self.assert_even_adj_faces(output_mesh);