Ejemplo n.º 1
0
    def test_face_corner_touch_off_center(self):
        mesh_1 = generate_box_mesh(np.array([0, 0, 0]), np.array([1, 1, 1]))

        rot = Quaternion.fromData(np.array([1, 1, 1], dtype=float),
                                  np.array([0, 0, 1], dtype=float))
        mesh_2 = form_mesh(
            np.dot(rot.to_matrix(), mesh_1.vertices.T).T +
            np.array([0.6, 0.6, 1.0]), mesh_1.faces)

        mesh = merge_meshes((mesh_1, mesh_2))
        output_mesh = resolve_self_intersection(mesh)

        self.assert_self_intersect(mesh)
        self.assert_no_self_intersect(output_mesh)
        self.assert_even_adj_faces(output_mesh)
Ejemplo n.º 2
0
    def test_face_edge_touch(self):
        mesh_1 = generate_box_mesh(np.array([0, 0, 0]), np.array([1, 1, 1]))

        rot = Quaternion.fromData(np.array([1, 0, 1], dtype=float),
                                  np.array([0, 0, 1], dtype=float))
        mesh_2 = form_mesh(
            np.dot(rot.to_matrix(), mesh_1.vertices.T).T +
            np.array([0.5, 0.5, 1.0]), mesh_1.faces)

        mesh = boolean(mesh_1, mesh_2, "union", "igl")

        self.assertEqual(17, mesh.num_vertices)
        self.assertEqual(30, mesh.num_faces)
        self.assertFalse(mesh.is_manifold())
        self.assertTrue(mesh.is_closed())
        self.assertEqual(1, mesh.num_components)
Ejemplo n.º 3
0
    def test_face_corner_touch_off_center(self):
        mesh_1 = generate_box_mesh(
                np.array([0, 0, 0]), np.array([1, 1, 1]));

        rot = Quaternion.fromData(
                np.array([1, 1, 1], dtype=float),
                np.array([0, 0, 1], dtype=float));
        mesh_2 = form_mesh(
                np.dot(rot.to_matrix(), mesh_1.vertices.T).T +
                np.array([0.6, 0.6, 1.0]),
                mesh_1.faces);

        mesh = merge_meshes((mesh_1, mesh_2));
        output_mesh = resolve_self_intersection(mesh);

        self.assert_self_intersect(mesh);
        self.assert_no_self_intersect(output_mesh);
        self.assert_even_adj_faces(output_mesh);
Ejemplo n.º 4
0
    def test_face_edge_touch(self):
        mesh_1 = generate_box_mesh(
                np.array([0, 0, 0]), np.array([1, 1, 1]));

        rot = Quaternion.fromData(
                np.array([1, 0, 1], dtype=float),
                np.array([0, 0, 1], dtype=float));
        mesh_2 = form_mesh(
                np.dot(rot.to_matrix(), mesh_1.vertices.T).T +
                np.array([0.5, 0.5, 1.0]),
                mesh_1.faces);

        mesh = boolean(mesh_1, mesh_2, "union", "igl");

        self.assertEqual(17, mesh.num_vertices);
        self.assertEqual(30, mesh.num_faces);
        self.assertFalse(mesh.is_manifold());
        self.assertTrue(mesh.is_closed());
        self.assertEqual(1, mesh.num_components);
Ejemplo n.º 5
0
    def test_face_corner_touch_off_center(self):
        mesh_1 = generate_box_mesh(
                np.array([0, 0, 0]), np.array([1, 1, 1]));

        rot = Quaternion.fromData(
                np.array([1, 1, 1], dtype=float),
                np.array([0, 0, 1], dtype=float));
        mesh_2 = form_mesh(
                np.dot(rot.to_matrix(), mesh_1.vertices.T).T +
                np.array([0.6, 0.6, 1.0]),
                mesh_1.faces);

        mesh = boolean(mesh_1, mesh_2, "union", "igl");

        self.assertEqual(16, mesh.num_vertices);
        self.assertEqual(26, mesh.num_faces);
        self.assertFalse(mesh.is_manifold());
        self.assertTrue(mesh.is_closed());
        self.assertEqual(1, mesh.num_components);
Ejemplo n.º 6
0
def add_base(support_mesh, print_dir, support_length):
    Z_dir = np.array([0.0, 0.0, 1.0]);
    vertices = support_mesh.vertices.reshape((-1, 3), order="C");
    faces = support_mesh.faces.reshape((-1, 3), order="C");

    height = np.dot(print_dir, vertices.T).ravel();
    projection = vertices - np.outer(height, print_dir);

    if np.all(print_dir == Z_dir):
        rot = Quaternion().to_matrix();
    else:
        rot = Quaternion.fromData(print_dir, Z_dir).to_matrix();
    projection = np.dot(rot, projection.T);
    bbox_min = np.amin(projection, axis=1) - Z_dir * 0.15;
    bbox_max = np.amax(projection, axis=1) + Z_dir * 0.15;
    base = generate_box_mesh(bbox_min, bbox_max);
    base_vertices = np.dot(rot.T, base.vertices.T).T\
            + print_dir * np.amin(height);

    num_support_vertices = support_mesh.num_vertices;
    vertices = np.vstack([vertices, base_vertices]);
    faces = np.vstack([faces, base.faces + num_support_vertices]);

    return form_mesh(vertices, faces);