示例#1
0
    def test_positive_oriented_3D(self):
        p1 = np.array([0, 0, 0])
        p2 = np.array([1, 0, 0])
        p3 = np.array([0, 1, 0])
        p4 = np.array([0, 0, 1])

        self.assertGreater(0.0, orient_3D(p1, p2, p3, p4))
示例#2
0
    def test_degenerated_to_a_point_3D(self):
        p1 = np.array([1, 0, 0])
        p2 = np.array([1, 0, 0])
        p3 = np.array([1, 0, 0])
        p4 = np.array([1, 0, 0])

        self.assertEqual(0.0, orient_3D(p1, p2, p3, p4))
示例#3
0
    def test_list_input_3D(self):
        p1 = [0.0, 0.0, 0.0]
        p2 = [1.0, 0.0, 0.0]
        p3 = [0.0, 1.0, 0.0]
        p4 = [0.0, 0.0, 1.0]

        self.assertGreater(0.0, orient_3D(p1, p2, p3, p4))
示例#4
0
    def test_negative_oriented_3D(self):
        p1 = np.array([0, 0, 0])
        p2 = np.array([1, 0, 0])
        p3 = np.array([0, 1, 0])
        p4 = np.array([0, 0, -1])

        self.assertLess(0.0, orient_3D(p1, p2, p3, p4))
示例#5
0
    def test_collinear_3D(self):
        p1 = np.array([1, 0, 0])
        p2 = np.array([1, 0, 0])
        p3 = np.array([0, 1, 0])
        p4 = np.array([0, 1, 0])

        self.assertEqual(0.0, orient_3D(p1, p2, p3, p4))
示例#6
0
    def test_positive_oriented_3D(self):
        p1 = np.array([0, 0, 0]);
        p2 = np.array([1, 0, 0]);
        p3 = np.array([0, 1, 0]);
        p4 = np.array([0, 0, 1]);

        self.assertGreater(0.0, orient_3D(p1, p2, p3, p4));
示例#7
0
def main():
    args = parse_args();
    mesh = pymesh.load_mesh(args.input_mesh);

    vertices = mesh.vertices;
    voxels = mesh.voxels;
    num_voxels = mesh.num_voxels;
    orientation = np.zeros(num_voxels);

    for i in range(num_voxels):
        tet = voxels[i];
        orientation[i] = pymesh.orient_3D(
                vertices[tet[1]],
                vertices[tet[0]],
                vertices[tet[2]],
                vertices[tet[3]]);
        if orientation[i] < 0:
            orientation[i] = -1;
        elif orientation[i] > 0:
            orientation[i] = 1;

    mesh.add_attribute("orientation");
    mesh.set_attribute("orientation", orientation);

    pymesh.save_mesh(args.output_mesh, mesh, "orientation");
示例#8
0
    def test_list_input_3D(self):
        p1 = [0.0, 0.0, 0.0];
        p2 = [1.0, 0.0, 0.0];
        p3 = [0.0, 1.0, 0.0];
        p4 = [0.0, 0.0, 1.0];

        self.assertGreater(0.0, orient_3D(p1, p2, p3, p4));
示例#9
0
    def test_degenerated_to_a_point_3D(self):
        p1 = np.array([1, 0, 0]);
        p2 = np.array([1, 0, 0]);
        p3 = np.array([1, 0, 0]);
        p4 = np.array([1, 0, 0]);

        self.assertEqual(0.0, orient_3D(p1, p2, p3, p4));
示例#10
0
    def test_collinear_3D(self):
        p1 = np.array([1, 0, 0]);
        p2 = np.array([1, 0, 0]);
        p3 = np.array([0, 1, 0]);
        p4 = np.array([0, 1, 0]);

        self.assertEqual(0.0, orient_3D(p1, p2, p3, p4));
示例#11
0
    def test_negative_oriented_3D(self):
        p1 = np.array([0, 0, 0]);
        p2 = np.array([1, 0, 0]);
        p3 = np.array([0, 1, 0]);
        p4 = np.array([0, 0,-1]);

        self.assertLess(0.0, orient_3D(p1, p2, p3, p4));
示例#12
0
def coplanar_analysis(mesh, intersecting_faces):
    intersect_and_coplanar = set()
    vertices = mesh.vertices
    faces = mesh.faces
    for fi, fj in intersecting_faces:
        p0 = vertices[faces[fi, 0]]
        p1 = vertices[faces[fi, 1]]
        p2 = vertices[faces[fi, 2]]
        q0 = vertices[faces[fj, 0]]
        q1 = vertices[faces[fj, 1]]
        q2 = vertices[faces[fj, 2]]
        if pymesh.orient_3D(p0, p1, p2, q0) == 0 and \
           pymesh.orient_3D(p0, p1, p2, q1) == 0 and \
           pymesh.orient_3D(p0, p1, p2, q2) == 0:
            intersect_and_coplanar.add(fi)
            intersect_and_coplanar.add(fj)
    return intersect_and_coplanar
示例#13
0
def coplanar_analysis(mesh, intersecting_faces):
    intersect_and_coplanar = set();
    vertices = mesh.vertices;
    faces = mesh.faces;
    for fi, fj in intersecting_faces:
        p0 = vertices[faces[fi, 0]];
        p1 = vertices[faces[fi, 1]];
        p2 = vertices[faces[fi, 2]];
        q0 = vertices[faces[fj, 0]];
        q1 = vertices[faces[fj, 1]];
        q2 = vertices[faces[fj, 2]];
        if pymesh.orient_3D(p0, p1, p2, q0) == 0 and \
           pymesh.orient_3D(p0, p1, p2, q1) == 0 and \
           pymesh.orient_3D(p0, p1, p2, q2) == 0:
               intersect_and_coplanar.add(fi);
               intersect_and_coplanar.add(fj);
    return intersect_and_coplanar;
示例#14
0
def main():
    args = parse_args()
    mesh = pymesh.load_mesh(args.input_mesh)

    vertices = mesh.vertices
    voxels = mesh.voxels
    num_voxels = mesh.num_voxels
    orientation = np.zeros(num_voxels)

    for i in range(num_voxels):
        tet = voxels[i]
        orientation[i] = pymesh.orient_3D(vertices[tet[1]], vertices[tet[0]],
                                          vertices[tet[2]], vertices[tet[3]])
        if orientation[i] < 0:
            orientation[i] = -1
        elif orientation[i] > 0:
            orientation[i] = 1

    mesh.add_attribute("orientation")
    mesh.set_attribute("orientation", orientation)

    pymesh.save_mesh(args.output_mesh, mesh, "orientation")