SAC: add getInliers, getModel, getModelCoefficients to avoid copying data#6304
Conversation
Adding new methods to `SampleConsensus` so getInliers, getModel and getModelCoefficients return a const reference.
mvieth
left a comment
There was a problem hiding this comment.
Thanks for implementing this! I have a few comments.
Co-authored-by: Markus Vieth <39675748+mvieth@users.noreply.github.com>
Thanks a lot, I have applied the suggestions. |
You'll need to review the other places to changed them as well - adding & and consts. |
Co-authored-by: Markus Vieth <39675748+mvieth@users.noreply.github.com>
There was a problem hiding this comment.
Pull Request Overview
This PR refactors SampleConsensus APIs to return const references for inliers, model, and coefficients, and updates all internal call sites to use these new getters.
- Introduced
const &overloads forgetInliers(),getModel(), andgetModelCoefficients()insac.h - Updated segmentation and registration modules to use return-value getters instead of out-parameter calls
- Removed redundant variable declarations and replaced
sac.get*()calls accordingly
Reviewed Changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| tools/sac_segmentation_plane.cpp | Replaced out-param calls with returned values for inliers/coeff |
| segmentation/include/pcl/segmentation/impl/sac_segmentation.hpp | Updated .segment() to assign from return‐value getters |
| segmentation/include/pcl/segmentation/impl/cpc_segmentation.hpp | Switched to return‐value getters and direct assignment |
| sample_consensus/include/pcl/sample_consensus/sac.h | Added const-reference overloads for getModel, getInliers(), getModelCoefficients() |
| registration/include/pcl/registration/impl/correspondence_rejection_sample_consensus_2d.hpp | Used const auto& and return‐value getters for inliers/coeffs |
| registration/include/pcl/registration/impl/correspondence_rejection_sample_consensus.hpp | Same updates as in 2D version |
Comments suppressed due to low confidence (1)
sample_consensus/include/pcl/sample_consensus/sac.h:310
- Add unit tests covering the new const‐reference getters (
getInliers(),getModel(),getModelCoefficients()) to validate that they return the correct data and to prevent future regressions.
inline const Indices&
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This reverts commit 83391b5.
|
Sorry for not carefully checking Copilot's suggestions; the last commit has been reverted. |
Adding new methods to
SampleConsensussogetInliers,getModelandgetModelCoefficientsreturn a const reference.Usages within PCL has been replaced.