Exemple #1
0
    def test_cut_across_axis(self):
        original_mesh = Mesh(filename=sc(
            's3://bodylabs-assets/example_meshes/average_female.obj'))

        # Set up
        mesh = original_mesh.copy()
        # Sanity check
        np.testing.assert_almost_equal(mesh.v[:, 0].min(), -0.3668)
        np.testing.assert_almost_equal(mesh.v[:, 0].max(), 0.673871)
        # Act
        mesh.cut_across_axis(0, minval=-0.1)
        # Test
        np.testing.assert_almost_equal(mesh.v[:, 0].min(), -0.1, decimal=1)
        np.testing.assert_almost_equal(mesh.v[:, 0].max(), 0.673871)
        # Visualize
        if self.debug:
            mesh.show()

        # Set up
        mesh = original_mesh.copy()
        # Sanity check
        np.testing.assert_almost_equal(mesh.v[:, 0].min(), -0.3668)
        np.testing.assert_almost_equal(mesh.v[:, 0].max(), 0.673871)
        # Act
        mesh.cut_across_axis(0, maxval=0.1)
        # Test
        np.testing.assert_almost_equal(mesh.v[:, 0].min(), -0.3668)
        np.testing.assert_almost_equal(mesh.v[:, 0].max(), 0.1, decimal=1)
        # Visualize
        if self.debug:
            mesh.show()

        # Set up
        mesh = original_mesh.copy()
        # Sanity check
        np.testing.assert_almost_equal(mesh.v[:, 0].min(), -0.3668)
        np.testing.assert_almost_equal(mesh.v[:, 0].max(), 0.673871)
        # Act
        mesh.cut_across_axis(0, minval=-0.1, maxval=0.1)
        # Test
        np.testing.assert_almost_equal(mesh.v[:, 0].min(), -0.1, decimal=1)
        np.testing.assert_almost_equal(mesh.v[:, 0].max(), 0.1, decimal=1)
        # Visualize
        if self.debug:
            mesh.show()
Exemple #2
0
 def test_mesh_copy(self):
     m = Mesh(
         v=np.random.randn(10, 3),
         f=np.random.randn(10, 3),
         vc=np.random.randn(10, 3),
         vn=np.random.randn(10, 3),
     )
     m2 = m.copy()
     np.testing.assert_array_equal(m.v, m2.v)
     np.testing.assert_array_equal(m.f, m2.f)
     np.testing.assert_array_equal(m.vc, m2.vc)
     np.testing.assert_array_equal(m.vn, m2.vn)
     self.assertNotEqual(id(m.v), id(m2.v))
Exemple #3
0
 def test_mesh_copy_light(self):
     m = Mesh(
         v=np.random.randn(10, 3),
         f=np.random.randn(10, 3),
         vc=np.random.randn(10, 3),
         vn=np.random.randn(10, 3),
     )
     m2 = m.copy(only=['f', 'v'])
     np.testing.assert_array_equal(m.v, m2.v)
     np.testing.assert_array_equal(m.f, m2.f)
     self.assertIsNone(m2.vc)
     self.assertIsNone(m2.vn)
     self.assertNotEqual(id(m.v), id(m2.v))