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

patchkernel: find all the closest cells to a given point #446

Merged
merged 1 commit into from
Mar 19, 2024

Conversation

marcocisternino
Copy link
Member

This pull request adds methods to SurfaceSkdTree to find all the closest cells to a given point. The aim is to provide external applications with the the chance to select the the closest cell using its criteria. Existing methods select the closest cell using a specific criterium: the cell more "aligned" with the line that connect the specified point and its projection onto the cell will be chosen.

* argument will be set to the maximum representable distance
*/
void SurfaceSkdTree::findPointClosestCandidates(const std::array<double, 3> &point, double maxDistance,
double *distanceEstimate, Candidates &candidates) const
Copy link
Member

Choose a reason for hiding this comment

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

Pass it by pointer.

std::vector<std::size_t> *candidateIds = nullptr;
std::vector<double> *candidateMinDistances = nullptr;
std::vector<std::size_t> privateCandidateIds;
std::vector<double> privateCandidateMinDistances;
Copy link
Member

Choose a reason for hiding this comment

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

These should be a unique_ptr of a vector to avoid the allocation. Also, rename it to candidateTdsStorage, candidateMinDistancesStorage.

Copy link
Member

Choose a reason for hiding this comment

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

The structure already contains the name candidates, we can remove it from its memebers.

Copy link
Member

Choose a reason for hiding this comment

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

Can we come up with a more descriptive name? Like ClosestCellCandidates? Or ClosestCandidates?

Copy link
Member

Choose a reason for hiding this comment

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

Move the declaration before the members.

* argument will be set to the maximum representable distance
*/
void SurfaceSkdTree::findPointClosestCandidates(const std::array<double, 3> &point, double maxDistance,
double *distanceEstimate, Candidates &candidates) const
Copy link
Member

Choose a reason for hiding this comment

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

Since the Candidates already contain information about the distance of the candidates, we can move the distance estimate into the structure. We can call it maximumDistance.

Copy link
Member

Choose a reason for hiding this comment

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

Or maxDistance to be coherent with the other member of the distance.

std::vector<double> privateCandidateMinDistances;
};

void findPointClosestCandidates(const std::array<double, 3> &point, double maxDistance, double *distance, Candidates &candidates) const;
Copy link
Member

Choose a reason for hiding this comment

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

This should be private or protected.

Copy link
Member

Choose a reason for hiding this comment

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

It's already private, sorry for the noise.

@marcocisternino marcocisternino force-pushed the skdtree.find.closest.cells branch from 04419cb to 2f72b83 Compare February 14, 2024 11:06
@edoardolombardi edoardolombardi self-requested a review February 14, 2024 11:36
@andrea-iob
Copy link
Member

Can you confirm that the changes didn't slow-down the function?

@marcocisternino marcocisternino marked this pull request as ready for review February 14, 2024 14:24
@marcocisternino marcocisternino force-pushed the skdtree.find.closest.cells branch from 2f72b83 to 8f9dec6 Compare February 14, 2024 17:28
@marcocisternino
Copy link
Member Author

Can you confirm that the changes didn't slow-down the function?

integration levelset tests run sometimes faster and sometimes slower than the current master, therefore, I can statistically confirm no changes in performance.

@marcocisternino marcocisternino force-pushed the skdtree.find.closest.cells branch from 8f9dec6 to 2d5ba61 Compare February 20, 2024 15:03
@marcocisternino marcocisternino merged commit 3ae33ab into master Mar 19, 2024
6 checks passed
@marcocisternino marcocisternino deleted the skdtree.find.closest.cells branch March 19, 2024 16:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants