Example #1
0
    def test_writing_empty_mesh(self):
        m = Mesh()

        local_file = os.path.join(self.tmp_dir, 'test_writing_empty_mesh.obj')
        obj.dump(m, local_file)

        self.assertEqual(os.stat(local_file).st_size, 0)
Example #2
0
 def test_writing_obj_with_mtl(self):
     local_file = os.path.join(self.tmp_dir,
                               "test_writing_obj_with_mtl.obj")
     m = obj.load(sc(self.obj_with_texure))
     obj.dump(m, local_file)
     self.assertTrue(s3.exists(os.path.splitext(local_file)[0] + '.mtl'))
     self.assertTrue(s3.exists(os.path.splitext(local_file)[0] + '.png'))
Example #3
0
 def test_writing_obj_locally_using_serializer(self):
     local_file = os.path.join(
         self.tmp_dir,
         "test_writing_ascii_obj_locally_using_serializer.obj")
     m = Mesh(filename=self.test_obj_path)
     obj.dump(m, local_file)
     self.assertFilesEqual(local_file, self.test_obj_path)
Example #4
0
 def test_writing_obj_with_no_comments_does_not_write_comments(self):
     local_file = os.path.join(
         self.tmp_dir,
         "test_writing_ply_with_no_comments_does_not_write_comments.ply")
     m = obj.load(self.test_obj_path)
     obj.dump(m, local_file)
     with open(local_file) as f:
         self.assertNotRegexpMatches(f.read(), '#')
Example #5
0
    def test_write_overlapping_groups(self):
        m = obj.load(self.test_obj_with_overlapping_groups_path)

        local_file = os.path.join(self.tmp_dir,
                                  'test_write_overlapping_groups.obj')
        obj.dump(m, local_file)

        self.assertFilesEqual(local_file,
                              self.test_obj_with_overlapping_groups_path)
Example #6
0
    def test_writing_segmented_mesh_preserves_face_order(self):
        m = obj.load(self.test_obj_path)
        self.assertTrue((m.f == self.truth['box_f']).all())

        local_file = os.path.join(
            self.tmp_dir,
            'test_writing_segmented_mesh_preserves_face_order.obj')
        obj.dump(m, local_file)
        m_reloaded = obj.load(local_file)

        self.assertTrue((m_reloaded.f == self.truth['box_f']).all())
Example #7
0
 def test_writing_obj_with_comments_does_write_comments(self):
     local_file = os.path.join(
         self.tmp_dir,
         "test_writing_ply_with_comments_does_write_comments.ply")
     m = obj.load(self.test_obj_path)
     obj.dump(m, local_file, comments=['foo bar', 'this is a comment'])
     with open(local_file) as f:
         contents = f.read()
         self.assertRegexpMatches(contents,
                                  '# foo bar\n# this is a comment\n')
         self.assertNotRegexpMatches(contents, '# Copyright')
Example #8
0
 def write_obj(self,
               filename,
               flip_faces=False,
               ungroup=False,
               comments=None,
               write_mtl=True):
     from lace.serialization import obj
     obj.dump(self,
              filename,
              flip_faces=flip_faces,
              ungroup=ungroup,
              comments=comments,
              write_mtl=write_mtl)
Example #9
0
    def test_writing_mesh_with_overlapping_segments_preserves_face_order(self):
        '''
        Covered by test above, but covered here in a less fragile way, for good measure.

        '''
        m = obj.load(self.test_obj_with_overlapping_groups_path)
        self.assertTrue((m.f == self.truth['box_f']).all())

        local_file = os.path.join(
            self.tmp_dir,
            'test_writing_mesh_with_overlapping_segments_preserves_face_order.obj'
        )
        obj.dump(m, local_file)
        m_reloaded = obj.load(local_file)

        self.assertTrue((m_reloaded.f == self.truth['box_f']).all())
Example #10
0
 def write_fuse_obj(self, filename):
     from lace.serialization import obj
     obj.dump(self, filename, split_normals=True)