Skip to content

Commit

Permalink
Revert "Fix for elalish#786 by setting numProps in GatherFaces method…
Browse files Browse the repository at this point in the history
…. Added test for Decompose with properties, and ExpectProperties function in test_main in order to check properties in a mesh match those set by SetProperties."

This reverts commit 03848fa.
  • Loading branch information
harmanpa committed Apr 26, 2024
1 parent e8c0bc2 commit 86e6d42
Show file tree
Hide file tree
Showing 5 changed files with 1 addition and 52 deletions.
1 change: 1 addition & 0 deletions src/manifold/src/constructors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -509,6 +509,7 @@ std::vector<Manifold> Manifold::Decompose() const {

impl->GatherFaces(*pImpl_, faceNew2Old);
impl->ReindexVerts(vertNew2Old, pImpl_->NumVert());

impl->Finish();

meshes.push_back(Manifold(impl));
Expand Down
1 change: 0 additions & 1 deletion src/manifold/src/sort.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,6 @@ void Manifold::Impl::GatherFaces(const Impl& old, const Vec<int>& faceNew2Old) {
gather(policy, faceNew2Old.begin(), faceNew2Old.end(),
old.meshRelation_.triProperties.begin(),
meshRelation_.triProperties.begin());
meshRelation_.numProp = old.meshRelation_.numProp;
meshRelation_.properties = old.meshRelation_.properties;
}

Expand Down
26 changes: 0 additions & 26 deletions test/manifold_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,32 +160,6 @@ TEST(Manifold, Decompose) {
RelatedGL(manifolds, input);
}

TEST(Manifold, DecomposeProps) {
auto posNorm = [](float* newProp, glm::vec3 pos,
const float* oldProp) {
newProp[0] = hypotf(hypotf(pos.x, pos.y), pos.z);
};
std::vector<Manifold> manifoldList;
manifoldList.emplace_back(Manifold::Tetrahedron().SetProperties(1, posNorm));
manifoldList.emplace_back(Manifold::Cube().SetProperties(1, posNorm));
manifoldList.emplace_back(Manifold::Sphere(1, 4).SetProperties(1, posNorm));
Manifold manifolds = Manifold::Compose(manifoldList);

ExpectMeshes(manifolds, {{8, 12, 1}, {6, 8, 1}, {4, 4, 1}});
ExpectProperties(manifolds.GetMeshGL(), 1, posNorm);

std::vector<MeshGL> input;

for (const Manifold& manifold : manifoldList) {
EXPECT_GE(manifold.OriginalID(), 0);
auto mesh = manifold.GetMeshGL();
input.emplace_back(mesh);
ExpectProperties(mesh, 1, posNorm);
}

RelatedGL(manifolds, input);
}

/**
* These tests check the various manifold constructors.
*/
Expand Down
3 changes: 0 additions & 3 deletions test/test.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,6 @@ float GetMinProperty(const MeshGL& mesh, int channel);
void Identical(const Mesh& mesh1, const Mesh& mesh2);
void RelatedGL(const Manifold& out, const std::vector<MeshGL>& originals,
bool checkNormals = false, bool updateNormals = false);
void ExpectProperties(const MeshGL& mesh, int numProp, std::function<void(float* newProp, glm::vec3 position,
const float* oldProp)>
propFunc);
void ExpectMeshes(const Manifold& manifold,
const std::vector<MeshSize>& meshSize);
void CheckNormals(const Manifold& manifold);
Expand Down
22 changes: 0 additions & 22 deletions test/test_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -404,28 +404,6 @@ void RelatedGL(const Manifold& out, const std::vector<MeshGL>& originals,
}
}

void ExpectProperties(const MeshGL& mesh, int numProp, std::function<void(float* newProp, glm::vec3 position,
const float* oldProp)>
propFunc) {
EXPECT_EQ(mesh.numProp, 3+numProp);
auto* prop = new float[numProp];
auto* propTarget = new float[numProp];
glm::vec3 pos;
for(int i=0;i<mesh.NumVert();i++) {
pos.x = mesh.vertProperties[i*(numProp+3)+0];
pos.y = mesh.vertProperties[i*(numProp+3)+1];
pos.z = mesh.vertProperties[i*(numProp+3)+2];
for(int j=0;j<numProp;j++) {
propTarget[j] = 0.0;
prop[j] = mesh.vertProperties[i*(numProp+3)+3+j];
}
propFunc(propTarget, pos, propTarget);
for(int j=0;j<numProp;j++) {
EXPECT_FLOAT_EQ(prop[j], propTarget[j]);
}
}
}

void ExpectMeshes(const Manifold& manifold,
const std::vector<MeshSize>& meshSize) {
EXPECT_FALSE(manifold.IsEmpty());
Expand Down

0 comments on commit 86e6d42

Please sign in to comment.