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

Cleaning Hull Algorithm Code #904

Merged
merged 5 commits into from
Aug 25, 2024
Merged

Conversation

Kushal-Shah-03
Copy link
Contributor

I've removed some redundant functions and structs, I also removed some comments. I had made some changes in the previous PR, which also removed some redundancy in the code. Should I make the same changes here? (like modifying the for_each loop to merge two for loops)

I was thinking I can pass the vertPos_ and halfedge_ to the function as arguments and then modify them inside the quickhull implementation to reduce the size of the impl Hull function and also reduce the ConvexHull class. What do you think?

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.

You should make your changes in one PR or the other - you don't want to generate a bunch of merge conflicts for yourself. Do whatever feels easiest to keep track of.


ConvexHull getConvexHullAsMesh(const Vec<glm::dvec3>& pointCloud, bool CCW,
double epsilon) {
Vec<glm::dvec3> pointCloudVec(pointCloud);
Copy link
Owner

Choose a reason for hiding this comment

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

Unnecessary?

double epsilon) {
Vec<glm::dvec3> pointCloudVec(pointCloud);
QuickHull qh(pointCloudVec);
return qh.buildMesh(CCW, epsilon);
Copy link
Owner

Choose a reason for hiding this comment

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

Let's get rid of CCW too - CCW is always positive in Manifold.

@@ -488,8 +488,7 @@ void Manifold::Impl::Hull(const std::vector<glm::vec3>& vertPos) {
Vec<glm::dvec3> pointCloudVec(numVert);
manifold::transform(vertPos.begin(), vertPos.end(), pointCloudVec.begin(),
[](const glm::vec3& v) { return glm::dvec3(v); });
QuickHull qh(pointCloudVec);
ConvexHull hull = qh.getConvexHullAsMesh(pointCloudVec, false);
ConvexHull hull = getConvexHullAsMesh(pointCloudVec, false);
Copy link
Owner

Choose a reason for hiding this comment

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

You might just merge getConvexHullAsMesh into Impl::Hull and put this combined implementation in quickhull.cpp. Then you can remove ConvexHull and directly construct halfedge_ and vertPos_.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have merged getConvexHullAsMesh into Impl::Hull and removed ConvexHull. I think it's better to keep the Hull function inside Impl, since it follows a similar flow to the other functions inside Impl. Although if you think it's better to put it into quickhull.cpp, I can make that change.

Copy link
Owner

Choose a reason for hiding this comment

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

I mean both - notice how our Impl functions are implemented across many files? You can implement Impl::Hull in quickhull.cpp if you want, so long as it imports impl.h.

@Kushal-Shah-03
Copy link
Contributor Author

I was going through the Face struct to see how we could break it into struct of vectors, I noticed that
isVisibleFaceOnCurrentIteration, visibilityCheckedOnIteration and horizonEdgesOnCurrentIteration are accessed close to each other.
and
inFaceStack, mostDistantPoint, mostDistantPointDist and pointsOnPositiveSide are also accessed close to each other.
he and P are accessed close to all the variables.

So maybe we can break the Face struct into these three parts?

Copy link

codecov bot commented Aug 22, 2024

Codecov Report

Attention: Patch coverage is 76.47059% with 8 lines in your changes missing coverage. Please review.

Project coverage is 89.68%. Comparing base (d437097) to head (6a7582b).
Report is 80 commits behind head on master.

Files Patch % Lines
src/manifold/src/quickhull.cpp 76.47% 8 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #904      +/-   ##
==========================================
- Coverage   91.84%   89.68%   -2.16%     
==========================================
  Files          37       66      +29     
  Lines        4976     9696    +4720     
  Branches        0     1042    +1042     
==========================================
+ Hits         4570     8696    +4126     
- Misses        406     1000     +594     

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

@pca006132
Copy link
Collaborator

I was going through the Face struct to see how we could break it into struct of vectors, I noticed that isVisibleFaceOnCurrentIteration, visibilityCheckedOnIteration and horizonEdgesOnCurrentIteration are accessed close to each other. and inFaceStack, mostDistantPoint, mostDistantPointDist and pointsOnPositiveSide are also accessed close to each other. he and P are accessed close to all the variables.

So maybe we can break the Face struct into these three parts?

I think you probably want to do this in the optimization PR.

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.

This is looking like great progress to me - @pca006132 any changes you want to see before we merge?

@pca006132
Copy link
Collaborator

LGTM

@elalish elalish merged commit a0e4d1b into elalish:master Aug 25, 2024
22 checks passed
@elalish elalish mentioned this pull request Nov 5, 2024
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