Skip to content

Commit

Permalink
Optimise SortEntry memory footprint (elalish#493)
Browse files Browse the repository at this point in the history
  • Loading branch information
stephomi authored Jul 15, 2023
1 parent c167a48 commit 2aef6e4
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/manifold/src/edge_op.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,11 @@ struct SwappableEdge {
};

struct SortEntry {
Halfedge hedge;
int start;
int end;
int index;
inline bool operator<(const SortEntry& entry) const {
return hedge < entry.hedge;
inline bool operator<(const SortEntry& other) const {
return start == other.start ? end < other.end : start < other.start;
}
};
} // namespace
Expand Down Expand Up @@ -154,14 +155,15 @@ void Manifold::Impl::SimplifyTopology() {

auto policy = autoPolicy(halfedge_.size());
for_each_n(policy, countAt(0), nbEdges, [=] __host__ __device__(int i) {
entriesPtr[i].hedge = halfedge_[i];
entriesPtr[i].start = halfedge_[i].startVert;
entriesPtr[i].end = halfedge_[i].endVert;
entriesPtr[i].index = i;
});

sort(policy, entries.begin(), entries.end());
for (int i = 0; i < nbEdges - 1; ++i) {
if (entries[i].hedge.startVert == entries[i + 1].hedge.startVert &&
entries[i].hedge.endVert == entries[i + 1].hedge.endVert) {
if (entries[i].start == entries[i + 1].start &&
entries[i].end == entries[i + 1].end) {
DedupeEdge(entries[i].index);
numFlagged++;
}
Expand Down

0 comments on commit 2aef6e4

Please sign in to comment.