Increase code coverage of subdivide_meshes

Summary: Increase code coverage of subdivide_meshes and re-include it in code coverage test

Reviewed By: bottler

Differential Revision: D29097476

fbshipit-source-id: 3403ae38a90c4b53f24188eed11faae202a235b5
This commit is contained in:
Patrick Labatut
2021-06-14 04:02:14 -07:00
committed by Facebook GitHub Bot
parent a0f79318c5
commit 780e231536
2 changed files with 11 additions and 4 deletions

View File

@@ -11,7 +11,7 @@ from pytorch3d.utils.ico_sphere import ico_sphere
class TestSubdivideMeshes(TestCaseMixin, unittest.TestCase):
def test_simple_subdivide(self):
def simple_subdivide(self, with_init=False):
# Create a mesh with one face and check the subdivided mesh has
# 4 faces with the correct vertex coordinates.
device = torch.device("cuda:0")
@@ -23,7 +23,8 @@ class TestSubdivideMeshes(TestCaseMixin, unittest.TestCase):
)
faces = torch.tensor([[0, 1, 2]], dtype=torch.int64, device=device)
mesh = Meshes(verts=[verts], faces=[faces])
subdivide = SubdivideMeshes()
mesh_init = mesh.clone() if with_init else None
subdivide = SubdivideMeshes(meshes=mesh_init)
new_mesh = subdivide(mesh)
# Subdivided face:
@@ -61,6 +62,12 @@ class TestSubdivideMeshes(TestCaseMixin, unittest.TestCase):
self.assertClose(new_faces, gt_subdivide_faces)
self.assertTrue(new_verts.requires_grad == verts.requires_grad)
def test_simple_subdivide(self):
self.simple_subdivide()
def test_simple_subdivide_with_init(self):
self.simple_subdivide(with_init=True)
def test_heterogeneous_meshes(self):
device = torch.device("cuda:0")
verts1 = torch.tensor(