-
Notifications
You must be signed in to change notification settings - Fork 34
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
Conversation
src/patchkernel/surface_skd_tree.cpp
Outdated
* 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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pass it by pointer.
src/patchkernel/surface_skd_tree.hpp
Outdated
std::vector<std::size_t> *candidateIds = nullptr; | ||
std::vector<double> *candidateMinDistances = nullptr; | ||
std::vector<std::size_t> privateCandidateIds; | ||
std::vector<double> privateCandidateMinDistances; |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
src/patchkernel/surface_skd_tree.cpp
Outdated
* 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 |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
src/patchkernel/surface_skd_tree.hpp
Outdated
std::vector<double> privateCandidateMinDistances; | ||
}; | ||
|
||
void findPointClosestCandidates(const std::array<double, 3> &point, double maxDistance, double *distance, Candidates &candidates) const; |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
04419cb
to
2f72b83
Compare
Can you confirm that the changes didn't slow-down the function? |
2f72b83
to
8f9dec6
Compare
integration levelset tests run sometimes faster and sometimes slower than the current master, therefore, I can statistically confirm no changes in performance. |
8f9dec6
to
2d5ba61
Compare
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.