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

Type safety for indices #958

Closed
wants to merge 11 commits into from
Closed

Conversation

wtholliday
Copy link
Contributor

Manifold uses ints for indices which shouldn't be assigned to each other, such as vertex indices and half-edge indices. This proposal adds custom index support to VecView.

This is a WIP, and I will attempt the rest of the changes with an OK from @elalish :)

@pca006132
Copy link
Collaborator

LGTM

Copy link

codecov bot commented Sep 26, 2024

Codecov Report

Attention: Patch coverage is 54.05405% with 17 lines in your changes missing coverage. Please review.

Project coverage is 88.09%. Comparing base (d437097) to head (a3563fc).
Report is 104 commits behind head on master.

Files with missing lines Patch % Lines
src/manifold/src/shared.h 40.00% 15 Missing ⚠️
src/manifold/src/quickhull.cpp 0.00% 1 Missing ⚠️
src/utilities/include/manifold/vec_view.h 85.71% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #958      +/-   ##
==========================================
- Coverage   91.84%   88.09%   -3.75%     
==========================================
  Files          37       62      +25     
  Lines        4976     8685    +3709     
  Branches        0     1052    +1052     
==========================================
+ Hits         4570     7651    +3081     
- Misses        406     1034     +628     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Owner

@elalish elalish left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is probably a good idea, but can you show a little bit more, specifically how using these new indices looks? My main concern is code readability, so this will be okay so long as it's not adding lots of characters.

Also, should GetIndex be a member function instead of a free function?

@wtholliday
Copy link
Contributor Author

I don't think it will make code readability worse.

I think perhaps some policy template could keep GetIndex from being a free function. The issue is that VecView still needs to work for size_t indices. I'll look into it.

@elalish
Copy link
Owner

elalish commented Sep 26, 2024

We do a lot of index addition/multiplication, so I just want to make sure that's as automatic with HalfedgeIdx as it is with size_t.

@wtholliday
Copy link
Contributor Author

Gotcha. Well, we see how it looks :)

@wtholliday
Copy link
Contributor Author

I think this is just too hard a change to make, even if the result would be nice.

@wtholliday wtholliday closed this Sep 26, 2024
@elalish
Copy link
Owner

elalish commented Sep 27, 2024

Yeah, I'm not too surprised; thanks anyway.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants