Skip to content

Commit

Permalink
Undo test changes made by Windows compat patch.
Browse files Browse the repository at this point in the history
  • Loading branch information
fire committed Apr 19, 2022
1 parent 0cf5739 commit 9153bce
Show file tree
Hide file tree
Showing 2 changed files with 118 additions and 120 deletions.
233 changes: 116 additions & 117 deletions test/mesh_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,13 +125,12 @@ Polygons SquareHole(float xOffset = 0.0) {

} // namespace

//TEST(MeshIO, ReadWrite) {
// Mesh mesh = ImportMesh("c:/users/baidhir/desktop/gyroidpuzzle.ply");
// ExportMesh("c:/repos/manifold/test/data/gyroidpuzzle1.ply", mesh, {});
// Mesh mesh_out = ImportMesh("c:/repos/manifold/test/data/gyroidpuzzle1.ply");
// Identical(mesh, mesh_out);
//}
//
TEST(MeshIO, ReadWrite) {
Mesh mesh = ImportMesh("data/gyroidpuzzle.ply");
ExportMesh("data/gyroidpuzzle1.ply", mesh, {});
Mesh mesh_out = ImportMesh("data/gyroidpuzzle1.ply");
Identical(mesh, mesh_out);
}

/**
* This tests that turning a mesh into a manifold and returning it to a mesh
Expand All @@ -145,20 +144,20 @@ TEST(Manifold, GetMesh) {
Identical(mesh_out, mesh_out2);
}

//TEST(Manifold, Regression) {
// Manifold manifold(ImportMesh("c:/repos/manifold/test/data/gyroidpuzzle.ply"));
// EXPECT_TRUE(manifold.IsManifold());
//
// Manifold manifold1 = manifold;
// manifold1.Translate(glm::vec3(5.0f));
// int num_overlaps = manifold.NumOverlaps(manifold1);
// ASSERT_EQ(num_overlaps, 228677);
//
// Mesh mesh_out = manifold.GetMesh();
// Manifold manifold2(mesh_out);
// Mesh mesh_out2 = manifold2.GetMesh();
// // Identical(mesh_out, mesh_out2);
//}
TEST(Manifold, Regression) {
Manifold manifold(ImportMesh("data/gyroidpuzzle.ply"));
EXPECT_TRUE(manifold.IsManifold());

Manifold manifold1 = manifold;
manifold1.Translate(glm::vec3(5.0f));
int num_overlaps = manifold.NumOverlaps(manifold1);
ASSERT_EQ(num_overlaps, 228677);

Mesh mesh_out = manifold.GetMesh();
Manifold manifold2(mesh_out);
Mesh mesh_out2 = manifold2.GetMesh();
// Identical(mesh_out, mesh_out2);
}

/**
* ExpectMeshes performs a decomposition, so this test ensures that compose and
Expand Down Expand Up @@ -314,33 +313,33 @@ TEST(Manifold, ManualSmooth) {
// ExportMesh("sharpenedSphere.gltf", out, options);
}

//TEST(Manifold, Csaszar) {
// Manifold csaszar = Manifold::Smooth(ImportMesh("c:/repos/manifold/test/data/Csaszar.ply"));
// csaszar.Refine(100);
// ExpectMeshes(csaszar, {{70000, 140000}});
// auto prop = csaszar.GetProperties();
// EXPECT_NEAR(prop.volume, 84699, 10);
// EXPECT_NEAR(prop.surfaceArea, 14796, 10);
//
// // const Mesh out = csaszar.GetMesh();
// // ExportOptions options;
// // options.faceted = false;
// // options.mat.roughness = 0.1;
//
// // options.mat.vertColor.resize(csaszar.NumVert());
// // MeshRelation rel = csaszar.GetMeshRelation();
// // const glm::vec4 blue(0, 0, 1, 1);
// // const glm::vec4 yellow(1, 1, 0, 1);
// // for (int tri = 0; tri < csaszar.NumTri(); ++tri) {
// // for (int i : {0, 1, 2}) {
// // const glm::vec3& uvw = rel.barycentric[rel.triBary[tri].vertBary[i]];
// // const float alpha = glm::min(uvw[0], glm::min(uvw[1], uvw[2]));
// // options.mat.vertColor[out.triVerts[tri][i]] =
// // glm::mix(yellow, blue, glm::smoothstep(0.0f, 0.2f, alpha));
// // }
// // }
// // ExportMesh("smoothCsaszar.gltf", out, options);
//}
TEST(Manifold, Csaszar) {
Manifold csaszar = Manifold::Smooth(ImportMesh("data/Csaszar.ply"));
csaszar.Refine(100);
ExpectMeshes(csaszar, {{70000, 140000}});
auto prop = csaszar.GetProperties();
EXPECT_NEAR(prop.volume, 84699, 10);
EXPECT_NEAR(prop.surfaceArea, 14796, 10);

// const Mesh out = csaszar.GetMesh();
// ExportOptions options;
// options.faceted = false;
// options.mat.roughness = 0.1;

// options.mat.vertColor.resize(csaszar.NumVert());
// MeshRelation rel = csaszar.GetMeshRelation();
// const glm::vec4 blue(0, 0, 1, 1);
// const glm::vec4 yellow(1, 1, 0, 1);
// for (int tri = 0; tri < csaszar.NumTri(); ++tri) {
// for (int i : {0, 1, 2}) {
// const glm::vec3& uvw = rel.barycentric[rel.triBary[tri].vertBary[i]];
// const float alpha = glm::min(uvw[0], glm::min(uvw[1], uvw[2]));
// options.mat.vertColor[out.triVerts[tri][i]] =
// glm::mix(yellow, blue, glm::smoothstep(0.0f, 0.2f, alpha));
// }
// }
// ExportMesh("smoothCsaszar.gltf", out, options);
}

/**
* These tests verify the calculation of a manifold's geometric properties.
Expand Down Expand Up @@ -423,36 +422,36 @@ TEST(Manifold, Transform) {

Identical(cube.GetMesh(), cube2.GetMesh());
}
//
//TEST(Manifold, MeshRelation) {
// std::vector<Mesh> input;
// std::map<int, int> meshID2idx;
//
// input.push_back(ImportMesh("c:/repos/manifold/test/data/gyroidpuzzle.ply"));
// Manifold gyroid(input[0]);
//
// std::vector<int> meshIDs = gyroid.GetMeshIDs();
// EXPECT_EQ(meshIDs.size(), 1);
// meshID2idx[meshIDs[0]] = input.size() - 1;
//
// Related(gyroid, input, meshID2idx);
//}

//TEST(Manifold, MeshRelationRefine) {
// std::vector<Mesh> input;
// std::map<int, int> meshID2idx;
//
// input.push_back(ImportMesh("c:/repos/manifold/test/data/Csaszar.ply"));
// Manifold csaszar(input[0]);
//
// std::vector<int> meshIDs = csaszar.GetMeshIDs();
// EXPECT_EQ(meshIDs.size(), 1);
// meshID2idx[meshIDs[0]] = input.size() - 1;
//
// Related(csaszar, input, meshID2idx);
// csaszar.Refine(4);
// Related(csaszar, input, meshID2idx);
//}
TEST(Manifold, MeshRelation) {
std::vector<Mesh> input;
std::map<int, int> meshID2idx;

input.push_back(ImportMesh("data/gyroidpuzzle.ply"));
Manifold gyroid(input[0]);

std::vector<int> meshIDs = gyroid.GetMeshIDs();
EXPECT_EQ(meshIDs.size(), 1);
meshID2idx[meshIDs[0]] = input.size() - 1;

Related(gyroid, input, meshID2idx);
}

TEST(Manifold, MeshRelationRefine) {
std::vector<Mesh> input;
std::map<int, int> meshID2idx;

input.push_back(ImportMesh("data/Csaszar.ply"));
Manifold csaszar(input[0]);

std::vector<int> meshIDs = csaszar.GetMeshIDs();
EXPECT_EQ(meshIDs.size(), 1);
meshID2idx[meshIDs[0]] = input.size() - 1;

Related(csaszar, input, meshID2idx);
csaszar.Refine(4);
Related(csaszar, input, meshID2idx);
}

/**
* The very simplest Boolean operation test.
Expand Down Expand Up @@ -709,43 +708,43 @@ TEST(Boolean, Sphere) {
RelatedOp(sphere, sphere2, result);
}

//TEST(Boolean, Gyroid) {
// Mesh gyroidpuzzle = ImportMesh("c:/repos/manifold/test/data/gyroidpuzzle.ply");
// Manifold gyroid(gyroidpuzzle);
//
// Mesh gyroidpuzzle2 = gyroidpuzzle;
// std::transform(gyroidpuzzle.vertPos.begin(), gyroidpuzzle.vertPos.end(),
// gyroidpuzzle2.vertPos.begin(),
// [](const glm::vec3& v) { return v + glm::vec3(5.0f); });
// Manifold gyroid2(gyroidpuzzle2);
//
// EXPECT_TRUE(gyroid.IsManifold());
// EXPECT_TRUE(gyroid.MatchesTriNormals());
// EXPECT_LE(gyroid.NumDegenerateTris(), 12);
// // ExportMesh("gyroidpuzzle1.gltf", gyroid.Extract(), {});
// Manifold result = gyroid + gyroid2;
// ExportMesh("gyroidUnion.gltf", result.GetMesh(), {});
//
// EXPECT_TRUE(result.IsManifold());
// EXPECT_TRUE(result.MatchesTriNormals());
// EXPECT_LE(result.NumDegenerateTris(), 33);
// EXPECT_EQ(result.Decompose().size(), 1);
// auto prop = result.GetProperties();
// EXPECT_NEAR(prop.volume, 7692, 1);
// EXPECT_NEAR(prop.surfaceArea, 9642, 1);
//
// std::vector<Mesh> input;
// std::map<int, int> meshID2idx;
//
// std::vector<int> meshIDs = gyroid.GetMeshIDs();
// EXPECT_EQ(meshIDs.size(), 1);
// meshID2idx[meshIDs[0]] = input.size();
// input.push_back(gyroidpuzzle);
//
// meshIDs = gyroid2.GetMeshIDs();
// EXPECT_EQ(meshIDs.size(), 1);
// meshID2idx[meshIDs[0]] = input.size();
// input.push_back(gyroidpuzzle2);
//
// Related(result, input, meshID2idx);
//}
TEST(Boolean, Gyroid) {
Mesh gyroidpuzzle = ImportMesh("data/gyroidpuzzle.ply");
Manifold gyroid(gyroidpuzzle);

Mesh gyroidpuzzle2 = gyroidpuzzle;
std::transform(gyroidpuzzle.vertPos.begin(), gyroidpuzzle.vertPos.end(),
gyroidpuzzle2.vertPos.begin(),
[](const glm::vec3& v) { return v + glm::vec3(5.0f); });
Manifold gyroid2(gyroidpuzzle2);

EXPECT_TRUE(gyroid.IsManifold());
EXPECT_TRUE(gyroid.MatchesTriNormals());
EXPECT_LE(gyroid.NumDegenerateTris(), 12);
// ExportMesh("gyroidpuzzle1.gltf", gyroid.Extract(), {});
Manifold result = gyroid + gyroid2;
ExportMesh("gyroidUnion.gltf", result.GetMesh(), {});

EXPECT_TRUE(result.IsManifold());
EXPECT_TRUE(result.MatchesTriNormals());
EXPECT_LE(result.NumDegenerateTris(), 33);
EXPECT_EQ(result.Decompose().size(), 1);
auto prop = result.GetProperties();
EXPECT_NEAR(prop.volume, 7692, 1);
EXPECT_NEAR(prop.surfaceArea, 9642, 1);

std::vector<Mesh> input;
std::map<int, int> meshID2idx;

std::vector<int> meshIDs = gyroid.GetMeshIDs();
EXPECT_EQ(meshIDs.size(), 1);
meshID2idx[meshIDs[0]] = input.size();
input.push_back(gyroidpuzzle);

meshIDs = gyroid2.GetMeshIDs();
EXPECT_EQ(meshIDs.size(), 1);
meshID2idx[meshIDs[0]] = input.size();
input.push_back(gyroidpuzzle2);

Related(result, input, meshID2idx);
}
5 changes: 2 additions & 3 deletions test/polygon_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

#include <algorithm>
#include <random>
#include <limits>

#include "test.h"

Expand Down Expand Up @@ -61,8 +60,8 @@ Polygons Turn180(Polygons polys) {
}

Polygons Duplicate(Polygons polys) {
float xMin = std::numeric_limits<float>::infinity();
float xMax = -std::numeric_limits<float>::infinity();
float xMin = 1.0 / 0.0;
float xMax = -1.0 / 0.0;
int indexMax = 0;
for (SimplePolygon &poly : polys) {
for (PolyVert &vert : poly) {
Expand Down

0 comments on commit 9153bce

Please sign in to comment.