Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added alwaysAsOriginal option #671

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 11 additions & 18 deletions src/manifold/src/boolean_result.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -779,38 +779,31 @@

#ifdef MANIFOLD_DEBUG
triangulate.Stop();
Timer simplify;
simplify.Start();
Timer finish;
finish.Start();
#endif

if (ManifoldParams().intermediateChecks)
ASSERT(outR.IsManifold(), logicErr, "triangulated mesh is not manifold!");

CreateProperties(outR, inP_, inQ_);

UpdateReference(outR, inP_, inQ_, invertQ);

outR.SimplifyTopology();

if (ManifoldParams().intermediateChecks)
ASSERT(outR.Is2Manifold(), logicErr, "simplified mesh is not 2-manifold!");

#ifdef MANIFOLD_DEBUG
simplify.Stop();
Timer sort;
sort.Start();
#endif
if (ManifoldParams().alwaysAsOriginal) {
outR.AsOriginal();

Check warning on line 792 in src/manifold/src/boolean_result.cpp

View check run for this annotation

Codecov / codecov/patch

src/manifold/src/boolean_result.cpp#L792

Added line #L792 was not covered by tests
} else {
UpdateReference(outR, inP_, inQ_, invertQ);
outR.SimplifyTopology();
outR.Finish();
}

outR.Finish();
outR.IncrementMeshIDs();

#ifdef MANIFOLD_DEBUG
sort.Stop();
finish.Stop();
if (ManifoldParams().verbose) {
assemble.Print("Assembly");
triangulate.Print("Triangulation");
simplify.Print("Simplification");
sort.Print("Sorting");
finish.Print("Finishing");
std::cout << outR.NumVert() << " verts and " << outR.NumTri() << " tris"
<< std::endl;
}
Expand Down
4 changes: 4 additions & 0 deletions src/manifold/src/edge_op.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
// limitations under the License.

#include "impl.h"
#include "optional_assert.h"
#include "par.h"

namespace {
Expand Down Expand Up @@ -256,6 +257,9 @@ void Manifold::Impl::SimplifyTopology() {
std::cout << "found " << numFlagged << " edges to swap" << std::endl;
}
#endif

if (ManifoldParams().intermediateChecks)
ASSERT(Is2Manifold(), logicErr, "simplified mesh is not 2-manifold!");
}

// Deduplicate the given 4-manifold edge by duplicating endVert, thus making the
Expand Down
8 changes: 8 additions & 0 deletions src/manifold/src/impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -661,6 +661,14 @@ void Manifold::Impl::CreateFaces(const std::vector<float>& propertyTolerance) {
}
}

void Manifold::Impl::AsOriginal() {
meshRelation_.originalID = ReserveIDs(1);
InitializeOriginal();
CreateFaces();
SimplifyTopology();
Finish();
}

/**
* Create the halfedge_ data structure from an input triVerts array like Mesh.
*/
Expand Down
1 change: 1 addition & 0 deletions src/manifold/src/impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ struct Manifold::Impl {
void CreateFaces(const std::vector<float>& propertyTolerance = {});
void RemoveUnreferencedVerts(Vec<glm::ivec3>& triVerts);
void InitializeOriginal();
void AsOriginal();
void CreateHalfedges(const Vec<glm::ivec3>& triVerts);
void CalculateNormals();
void IncrementMeshIDs();
Expand Down
6 changes: 1 addition & 5 deletions src/manifold/src/manifold.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -438,11 +438,7 @@ int Manifold::OriginalID() const {
*/
Manifold Manifold::AsOriginal() const {
auto newImpl = std::make_shared<Impl>(*GetCsgLeafNode().GetImpl());
newImpl->meshRelation_.originalID = ReserveIDs(1);
newImpl->InitializeOriginal();
newImpl->CreateFaces();
newImpl->SimplifyTopology();
newImpl->Finish();
newImpl->AsOriginal();
return Manifold(std::make_shared<CsgLeafNode>(newImpl));
}

Expand Down
4 changes: 4 additions & 0 deletions src/utilities/include/public.h
Original file line number Diff line number Diff line change
Expand Up @@ -615,6 +615,10 @@ struct ExecutionParams {
bool deterministic = false;
/// Perform optional but recommended triangle cleanups in SimplifyTopology()
bool cleanupTriangles = true;
/// Speed up Boolean operations by resetting each result to an original,
/// allowing more simplification to happen, but losing the relationships to
/// input meshes.
bool alwaysAsOriginal = false;
};

#ifdef MANIFOLD_DEBUG
Expand Down
Loading