From b008cb7eb63b2df765103152166a7a30bb8718d4 Mon Sep 17 00:00:00 2001 From: Sameer Sheorey Date: Fri, 14 Jun 2024 12:15:42 -0700 Subject: [PATCH] Add special case for MSVC output for GetNonManifoldEdges(), return empty areas property if there are no triangles. --- cpp/open3d/t/geometry/TriangleMesh.cpp | 3 +++ cpp/tests/t/geometry/TriangleMesh.cpp | 14 +++++++++----- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/cpp/open3d/t/geometry/TriangleMesh.cpp b/cpp/open3d/t/geometry/TriangleMesh.cpp index 34b960b7390..4342c0a2d9e 100644 --- a/cpp/open3d/t/geometry/TriangleMesh.cpp +++ b/cpp/open3d/t/geometry/TriangleMesh.cpp @@ -309,6 +309,9 @@ TriangleMesh &TriangleMesh::ComputeTriangleAreas() { } if (!HasTriangleIndices()) { + SetTriangleAttr("areas", core::Tensor::Empty( + {0}, GetVertexPositions().GetDtype(), + GetDevice())); utility::LogWarning("TriangleMesh has no triangle indices."); return *this; } diff --git a/cpp/tests/t/geometry/TriangleMesh.cpp b/cpp/tests/t/geometry/TriangleMesh.cpp index b6d625d5a62..baab268a9b2 100644 --- a/cpp/tests/t/geometry/TriangleMesh.cpp +++ b/cpp/tests/t/geometry/TriangleMesh.cpp @@ -1402,11 +1402,15 @@ TEST_P(TriangleMeshPermuteDevices, RemoveNonManifoldEdges) { expected_edges = core::eigen_converter::EigenVector2iVectorToTensor( legacy_mesh.GetNonManifoldEdges(true), core::Int64, device); EXPECT_TRUE(mesh.GetNonManifoldEdges(true).AllClose(expected_edges)); - expected_edges = core::eigen_converter::EigenVector2iVectorToTensor( - legacy_mesh.GetNonManifoldEdges(false), core::Int64, device); - std::cout << mesh.GetNonManifoldEdges(false).ToString() << std::endl; - std::cout << expected_edges.ToString() << std::endl; - +#ifdef _MSC_VER + expected_edges = core::Tensor::Init( + {{0 8}, {1 8}, {0 1}, {6 7}, {0 2}, {0 4}, {2, 8}, {6 6}, {4 8}}, + device); +#else + expected_edges = core::Tensor::Init( + {{0 8}, {1 8}, {0 1}, {6 7}, {0 2}, {0 4}, {6 6}, {4 8}, {2 8}}, + device); +#endif EXPECT_TRUE(mesh.GetNonManifoldEdges(false).AllClose(expected_edges)); mesh.RemoveNonManifoldEdges();