mirror of
https://github.com/facebookresearch/pytorch3d.git
synced 2025-08-02 03:42:50 +08:00
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:
parent
a0f79318c5
commit
780e231536
@ -6,7 +6,7 @@ import torch.nn as nn
|
||||
from pytorch3d.structures import Meshes
|
||||
|
||||
|
||||
class SubdivideMeshes(nn.Module): # pragma: no cover
|
||||
class SubdivideMeshes(nn.Module):
|
||||
"""
|
||||
Subdivide a triangle mesh by adding a new vertex at the center of each edge
|
||||
and dividing each face into four new faces. Vectors of vertex
|
||||
@ -396,7 +396,7 @@ def create_verts_index(verts_per_mesh, edges_per_mesh, device=None):
|
||||
return verts_idx
|
||||
|
||||
|
||||
def create_faces_index(faces_per_mesh, device=None): # pragma: no cover
|
||||
def create_faces_index(faces_per_mesh, device=None):
|
||||
"""
|
||||
Helper function to group the faces indices for each mesh. New faces are
|
||||
stacked at the end of the original faces tensor, so in order to have
|
||||
|
@ -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(
|
||||
|
Loading…
x
Reference in New Issue
Block a user