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
This commit is contained in:
Jiali Duan 2022-10-07 12:14:24 -07:00 committed by Facebook GitHub Bot
parent 73ba66e4ab
commit 9df875bb5e
2 changed files with 11 additions and 8 deletions

View File

@ -86,8 +86,8 @@ std::tuple<at::Tensor, at::Tensor> MarchingCubesCpu(
}
tri.clear();
ps.clear();
}
} // endif
} // endif
} // endfor edge enumeration
} // endfor x
} // endfor y
} // endfor z

View File

@ -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;