Skip to content

Commit c9810fd

Browse files
authored
Ensure properties maintained through Decompose operation (#794)
* Fix for #786 by setting numProps in GatherFaces method. 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. * Correct formatting of ExpectProperties * Correct more formatting * Removed ExpectProperties and instead use existing test methods * Call RelatedGL for each Decomposed Manifold
1 parent 4c57a56 commit c9810fd

File tree

3 files changed

+24
-1
lines changed

3 files changed

+24
-1
lines changed

src/manifold/src/constructors.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -509,7 +509,6 @@ std::vector<Manifold> Manifold::Decompose() const {
509509

510510
impl->GatherFaces(*pImpl_, faceNew2Old);
511511
impl->ReindexVerts(vertNew2Old, pImpl_->NumVert());
512-
513512
impl->Finish();
514513

515514
meshes.push_back(Manifold(impl));

src/manifold/src/sort.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -464,6 +464,7 @@ void Manifold::Impl::GatherFaces(const Impl& old, const Vec<int>& faceNew2Old) {
464464
gather(policy, faceNew2Old.begin(), faceNew2Old.end(),
465465
old.meshRelation_.triProperties.begin(),
466466
meshRelation_.triProperties.begin());
467+
meshRelation_.numProp = old.meshRelation_.numProp;
467468
meshRelation_.properties = old.meshRelation_.properties;
468469
}
469470

test/manifold_test.cpp

+23
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,29 @@ TEST(Manifold, Decompose) {
160160
RelatedGL(manifolds, input);
161161
}
162162

163+
TEST(Manifold, DecomposeProps) {
164+
std::vector<MeshGL> input;
165+
std::vector<Manifold> manifoldList;
166+
auto tet = WithPositionColors(Manifold::Tetrahedron());
167+
manifoldList.emplace_back(tet);
168+
input.emplace_back(tet);
169+
auto cube = WithPositionColors(Manifold::Cube());
170+
manifoldList.emplace_back(cube);
171+
input.emplace_back(cube);
172+
auto sphere = WithPositionColors(Manifold::Sphere(1, 4));
173+
manifoldList.emplace_back(sphere);
174+
input.emplace_back(sphere);
175+
Manifold manifolds = Manifold::Compose(manifoldList);
176+
177+
ExpectMeshes(manifolds, {{8, 12, 3}, {6, 8, 3}, {4, 4, 3}});
178+
179+
RelatedGL(manifolds, input);
180+
181+
for (const Manifold& manifold : manifolds.Decompose()) {
182+
RelatedGL(manifold, input);
183+
}
184+
}
185+
163186
/**
164187
* These tests check the various manifold constructors.
165188
*/

0 commit comments

Comments
 (0)