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

Remove fancy iterators #852

Merged
merged 24 commits into from
Jul 7, 2024
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
refactored shared
  • Loading branch information
elalish committed Jun 28, 2024
commit 47df38fa5ee4d860a3fbc3edb2d6cb0ae383f7e6
27 changes: 9 additions & 18 deletions src/manifold/src/shared.h
Original file line number Diff line number Diff line change
Expand Up @@ -173,28 +173,19 @@ struct TmpEdge {
};
/** @} */

struct Halfedge2Tmp {
void operator()(thrust::tuple<TmpEdge&, const Halfedge&, int> inout) {
const Halfedge& halfedge = thrust::get<1>(inout);
int idx = thrust::get<2>(inout);
if (!halfedge.IsForward()) idx = -1;

thrust::get<0>(inout) = TmpEdge(halfedge.startVert, halfedge.endVert, idx);
}
};

struct TmpInvalid {
bool operator()(const TmpEdge& edge) { return edge.halfedgeIdx < 0; }
};

Vec<TmpEdge> inline CreateTmpEdges(const Vec<Halfedge>& halfedge) {
Vec<TmpEdge> edges(halfedge.size());
for_each_n(autoPolicy(edges.size()),
zip(edges.begin(), halfedge.begin(), countAt(0)), edges.size(),
Halfedge2Tmp());
for_each_n(autoPolicy(edges.size()), countAt(0), edges.size(),
[&edges, &halfedge](const int idx) {
const Halfedge& half = halfedge[idx];
edges[idx] = TmpEdge(half.startVert, half.endVert,
half.IsForward() ? idx : -1);
});

size_t numEdge =
remove_if<decltype(edges.begin())>(
autoPolicy(edges.size()), edges.begin(), edges.end(), TmpInvalid()) -
autoPolicy(edges.size()), edges.begin(), edges.end(),
[](const TmpEdge& edge) { return edge.halfedgeIdx < 0; }) -
edges.begin();
DEBUG_ASSERT(numEdge == halfedge.size() / 2, topologyErr, "Not oriented!");
edges.resize(numEdge);
Expand Down