From 9df875bb5e0b65ac5928c42d60a9bc2b5597d401 Mon Sep 17 00:00:00 2001 From: Jiali Duan Date: Fri, 7 Oct 2022 12:14:24 -0700 Subject: [PATCH] Fix Circleci build failure: Add != operator for Marching Cubes Vertex struct Summary: Fix Circleci error: https://app.circleci.com/pipelines/github/facebookresearch/pytorch3d/1066/workflows/94df137b-4882-4959-8fe4-738af447db23/jobs/56560. Reviewed By: kjchalup Differential Revision: D40185409 fbshipit-source-id: 7121b0cae66bd60f718df2a5d9ef5d2ac3bc658c --- .../csrc/marching_cubes/marching_cubes_cpu.cpp | 4 ++-- .../csrc/marching_cubes/marching_cubes_utils.h | 15 +++++++++------ 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/pytorch3d/csrc/marching_cubes/marching_cubes_cpu.cpp b/pytorch3d/csrc/marching_cubes/marching_cubes_cpu.cpp index 3c801001..fb846618 100644 --- a/pytorch3d/csrc/marching_cubes/marching_cubes_cpu.cpp +++ b/pytorch3d/csrc/marching_cubes/marching_cubes_cpu.cpp @@ -86,8 +86,8 @@ std::tuple MarchingCubesCpu( } tri.clear(); ps.clear(); - } - } // endif + } // endif + } // endfor edge enumeration } // endfor x } // endfor y } // endfor z diff --git a/pytorch3d/csrc/marching_cubes/marching_cubes_utils.h b/pytorch3d/csrc/marching_cubes/marching_cubes_utils.h index 7d417a3a..7a952b07 100644 --- a/pytorch3d/csrc/marching_cubes/marching_cubes_utils.h +++ b/pytorch3d/csrc/marching_cubes/marching_cubes_utils.h @@ -310,13 +310,16 @@ struct Vertex { Vertex operator+(const Vertex& xyz) const { return Vertex(x + xyz.x, y + xyz.y, z + xyz.z); } - // The == operator overrides is used for checking degenerate triangles + // The =/!= operator overrides is used for checking degenerate triangles bool operator==(const Vertex& xyz) const { - if (std::abs(x - xyz.x) < EPS && std::abs(y - xyz.y) < EPS && - std::abs(z - xyz.z) < EPS) { - return true; - } - return false; + return ( + std::abs(x - xyz.x) < EPS && std::abs(y - xyz.y) < EPS && + std::abs(z - xyz.z) < EPS); + } + bool operator!=(const Vertex& xyz) const { + return ( + std::abs(x - xyz.x) >= EPS || std::abs(y - xyz.y) >= EPS || + std::abs(z - xyz.z) >= EPS); } // vertex position float x, y, z;