Skip to content

Commit

Permalink
Fix triangle area and non-manifold edge tests for CUDA (#6859)
Browse files Browse the repository at this point in the history
Fix python test, fix mkl download URL typo, restrict numpy to v1.x
  • Loading branch information
ssheorey authored Jul 9, 2024
1 parent 02c26d9 commit 8b25949
Show file tree
Hide file tree
Showing 4 changed files with 819 additions and 212 deletions.
3 changes: 2 additions & 1 deletion 3rdparty/mkl/mkl.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@
#
# The name "STATIC" is used to avoid naming collisions for other 3rdparty CMake
# files (e.g. PyTorch) that also depends on MKL.
# FIXME: anaconda.org URLs don't work anymore.

include(ExternalProject)

if(WIN32)
set(MKL_INCLUDE_URL
https://github.com/isl-org/Open3D/releases/download/v0.12.0/mkl-include-2020.1-intel_216-win-64.tar.bz2W
https://github.com/isl-org/Open3D/releases/download/v0.12.0/mkl-include-2020.1-intel_216-win-64.tar.bz2
https://anaconda.org/intel/mkl-include/2020.1/download/win-64/mkl-include-2020.1-intel_216.tar.bz2
)
set(MKL_INCLUDE_SHA256 65cedb770358721fd834224cd8be1fe1cc10b37ef2a1efcc899fc2fefbeb5b31)
Expand Down
33 changes: 20 additions & 13 deletions cpp/tests/t/geometry/TriangleMesh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1348,21 +1348,26 @@ TEST_P(TriangleMeshPermuteDevices, ComputeTriangleAreas) {
t::geometry::TriangleMesh mesh_empty;
EXPECT_NO_THROW(mesh_empty.ComputeTriangleAreas());

std::shared_ptr<open3d::geometry::TriangleMesh> mesh =
open3d::geometry::TriangleMesh::CreateSphere(1.0, 3);
t::geometry::TriangleMesh t_mesh = t::geometry::TriangleMesh::FromLegacy(
*mesh, core::Float64, core::Int64, device);
std::vector<double> areas;
mesh->GetSurfaceArea(areas);
t::geometry::TriangleMesh t_mesh =
t::geometry::TriangleMesh::CreateSphere(1.0, 3).To(device);
core::Tensor ref_areas = core::Tensor::Init<float>(
{0.39031237489989984, 0.39031237489989995, 0.39031237489989973,
0.39031237489989995, 0.39031237489989984, 0.3903123748999,
0.3903123748998997, 0.3903123748998999, 0.39031237489989973,
0.39031237489989995, 0.3903123748999, 0.3903123748999002,
0.4330127018922192, 0.43301270189221924, 0.43301270189221924,
0.43301270189221924, 0.43301270189221924, 0.4330127018922193,
0.4330127018922191, 0.43301270189221913, 0.4330127018922192,
0.43301270189221924, 0.4330127018922195, 0.43301270189221963},
device);
t_mesh.ComputeTriangleAreas();
EXPECT_TRUE(t_mesh.GetTriangleAttr("areas").AllClose(
core::Tensor(areas, {(int)areas.size()}, core::Float64)));
EXPECT_TRUE(t_mesh.GetTriangleAttr("areas").AllClose(ref_areas));
}

TEST_P(TriangleMeshPermuteDevices, RemoveNonManifoldEdges) {
using ::testing::UnorderedElementsAreArray;
core::Device device = GetParam();
t::geometry::TriangleMesh mesh_empty;
t::geometry::TriangleMesh mesh_empty(device);
EXPECT_TRUE(mesh_empty.RemoveNonManifoldEdges().IsEmpty());

core::Tensor verts = core::Tensor::Init<float>(
Expand Down Expand Up @@ -1419,17 +1424,19 @@ TEST_P(TriangleMeshPermuteDevices, RemoveNonManifoldEdges) {
mesh.RemoveNonManifoldEdges();

EXPECT_TRUE(mesh.GetNonManifoldEdges(true).AllClose(
core::Tensor({0, 2}, core::Int64)));
core::Tensor({0, 2}, core::Int64, device)));

EXPECT_TRUE(mesh.GetNonManifoldEdges(false).AllClose(
core::Tensor({0, 2}, core::Int64)));
core::Tensor({0, 2}, core::Int64, device)));

t::geometry::TriangleMesh box = t::geometry::TriangleMesh::CreateBox();
t::geometry::TriangleMesh box =
t::geometry::TriangleMesh::CreateBox().To(device);
EXPECT_TRUE(mesh.GetVertexPositions().AllClose(verts));
EXPECT_TRUE(mesh.GetTriangleIndices().AllClose(box.GetTriangleIndices()));
core::Tensor expected_labels = tri_labels.IndexGet(
{core::Tensor::Init<bool>({1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0,
0, 0, 1, 1, 1, 0, 0, 1, 0, 1})});
0, 0, 1, 1, 1, 0, 0, 1, 0, 1},
device)});
EXPECT_TRUE(mesh.GetTriangleAttr("labels").AllClose(expected_labels));
}
} // namespace tests
Expand Down
2 changes: 1 addition & 1 deletion python/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
numpy>=1.18.0
numpy>=1.18.0,<2.0.0
dash>=2.6.0
werkzeug>=2.2.3
nbformat>=5.7.0
Expand Down
Loading

0 comments on commit 8b25949

Please sign in to comment.