Skip to content

Commit

Permalink
Adjusting tolerances for arm64
Browse files Browse the repository at this point in the history
  • Loading branch information
akenmorris committed Apr 30, 2024
1 parent d149493 commit 73fabfe
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 24 deletions.
37 changes: 23 additions & 14 deletions Libs/Mesh/Mesh.cpp
Expand Up @@ -1429,35 +1429,44 @@ bool Mesh::compareAllFaces(const Mesh& other_mesh) const {

// helper function to print out the cell indices
auto printCells = [](vtkCell* cell1, vtkCell* cell2) {
printf("[ ");
std::cout << "[ ";
for (int i = 0; i < cell1->GetNumberOfPoints(); i++) {
printf("%lld ", cell1->GetPointId(i));
std::cout << cell1->GetPointId(i) << " ";
}
printf("], [ ");
std::cout << "], [ ";
for (int i = 0; i < cell2->GetNumberOfPoints(); i++) {
printf("%lld ", cell2->GetPointId(i));
std::cout << cell2->GetPointId(i) << " ";
}
printf("]");
std::cout << "]";
};

for (int i = 0; i < this->poly_data_->GetNumberOfCells(); i++) {
vtkCell* cell1 = this->poly_data_->GetCell(i);
vtkCell* cell2 = other_mesh.poly_data_->GetCell(i);

if (cell1->GetNumberOfPoints() != cell2->GetNumberOfPoints()) {
printf("%ith face not equal (", i);
std::cout << i << "th face not equal (";
printCells(cell1, cell2);
printf(")\n");
std::cout << ")\n";
return false;
}

std::vector<vtkIdType> cell1Points(cell1->GetNumberOfPoints());
std::vector<vtkIdType> cell2Points(cell2->GetNumberOfPoints());

for (int pi = 0; pi < cell1->GetNumberOfPoints(); pi++) {
if (cell1->GetPointId(pi) != cell2->GetPointId(pi)) {
printf("%ith face not equal (", i);
printCells(cell1, cell2);
printf(")\n");
return false;
}
cell1Points[pi] = cell1->GetPointId(pi);
cell2Points[pi] = cell2->GetPointId(pi);
}

std::sort(cell1Points.begin(), cell1Points.end());
std::sort(cell2Points.begin(), cell2Points.end());

if (cell1Points != cell2Points) {
std::cout << i << "th face not equal (";
printCells(cell1, cell2);
std::cout << ")\n";
return false;
}
}

Expand Down Expand Up @@ -1521,7 +1530,7 @@ bool Mesh::compareField(const Mesh& other_mesh, const std::string& name1, const
return false;
}
} else {
if (!epsEqual(v1, v2, 1e-5)) {
if (!epsEqual(v1, v2, 1e-3)) {
printf("%ith values not equal (%0.8f != %0.8f)\n", i, v1, v2);
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion Libs/Mesh/Mesh.h
Expand Up @@ -250,7 +250,7 @@ class Mesh {
bool compareAllFaces(const Mesh& other_mesh) const;

/// compare if all fields in two meshes are (eps)equal
bool compareAllFields(const Mesh& other_mesh, const double eps = -1.0) const;
bool compareAllFields(const Mesh& other_mesh, const double eps = 1e4) const;

/// compare field of meshes to be (eps)equal (same field for both if only one specified)
bool compareField(const Mesh& other_mesh, const std::string& name1, const std::string& name2 = "",
Expand Down
19 changes: 10 additions & 9 deletions Libs/Mesh/MeshUtils.cpp
Expand Up @@ -253,7 +253,7 @@ int MeshUtils::findReferenceMesh(std::vector<Mesh>& meshes, int random_subset_si
* Given a .ply mesh, extract the boundary loop and export the boundary loop as a VTK .vtp file
*/

bool is_clockwise(const Eigen::MatrixXd& V, const Eigen::MatrixXi& F, const std::vector<int>& loop) {
static bool is_clockwise(const Eigen::MatrixXd& V, const Eigen::MatrixXi& F, const std::vector<int>& loop) {
Eigen::RowVector3d centroid{0.0, 0.0, 0.0};
for (const auto& i : loop) {
centroid += V.row(i);
Expand Down Expand Up @@ -316,7 +316,7 @@ Mesh MeshUtils::boundaryLoopExtractor(Mesh mesh) {
* defines the threshold for two surfaces to be "close"
*/

std::tuple<Eigen::MatrixXd, Eigen::MatrixXi> rem_into_eigen_mesh(const std::vector<int>& faces,
static std::tuple<Eigen::MatrixXd, Eigen::MatrixXi> rem_into_eigen_mesh(const std::vector<int>& faces,
const Eigen::MatrixXd& src_V,
const Eigen::MatrixXi& src_F) {
Eigen::MatrixXd V;
Expand All @@ -337,9 +337,9 @@ std::tuple<Eigen::MatrixXd, Eigen::MatrixXi> rem_into_eigen_mesh(const std::vect
return std::make_tuple(V, F);
}

std::tuple<Eigen::MatrixXd, Eigen::MatrixXi> shared_into_eigen_mesh(const std::vector<int>& faces,
const Eigen::MatrixXd& src_V,
const Eigen::MatrixXi& src_F) {
static std::tuple<Eigen::MatrixXd, Eigen::MatrixXi> shared_into_eigen_mesh(const std::vector<int>& faces,
const Eigen::MatrixXd& src_V,
const Eigen::MatrixXi& src_F) {
Eigen::MatrixXd V;
Eigen::MatrixXi F;
const std::unordered_set<int> faces_set(faces.begin(), faces.end());
Expand All @@ -357,9 +357,9 @@ std::tuple<Eigen::MatrixXd, Eigen::MatrixXi> shared_into_eigen_mesh(const std::v
return std::make_tuple(V, F);
}

bool is_empty(const Eigen::MatrixXd& V, const Eigen::MatrixXi& F) { return V.size() == 0 || F.size() == 0; }
static bool is_empty(const Eigen::MatrixXd& V, const Eigen::MatrixXi& F) { return V.size() == 0 || F.size() == 0; }

std::tuple<Eigen::MatrixXd, Eigen::MatrixXi, Eigen::MatrixXd, Eigen::MatrixXi> find_shared_surface(
static std::tuple<Eigen::MatrixXd, Eigen::MatrixXi, Eigen::MatrixXd, Eigen::MatrixXi> find_shared_surface(
const Eigen::MatrixXd& src_V, const Eigen::MatrixXi& src_F, const Eigen::MatrixXd& other_V,
const Eigen::MatrixXi& other_F, double tol = 1e-3) {
Eigen::MatrixXd out_V;
Expand Down Expand Up @@ -401,8 +401,9 @@ std::tuple<Eigen::MatrixXd, Eigen::MatrixXi, Eigen::MatrixXd, Eigen::MatrixXi> f
return std::make_tuple(out_V, out_F, rem_V, rem_F);
}

void move_to_boundary(const Eigen::MatrixXd& src_V, const Eigen::MatrixXi& src_F, const Eigen::MatrixXd& shared_V,
const Eigen::MatrixXi& shared_F, Eigen::MatrixXd& out_V, Eigen::MatrixXi& out_F) {
static void move_to_boundary(const Eigen::MatrixXd& src_V, const Eigen::MatrixXi& src_F,
const Eigen::MatrixXd& shared_V, const Eigen::MatrixXi& shared_F, Eigen::MatrixXd& out_V,
Eigen::MatrixXi& out_F) {
std::vector<std::vector<int>> src_loops, shared_loops;
igl::boundary_loop(src_F, src_loops);
igl::boundary_loop(shared_F, shared_loops);
Expand Down

0 comments on commit 73fabfe

Please sign in to comment.