Skip to content

Commit 97cb436

Browse files
authored
Merge pull request PointCloudLibrary#4665 from mvieth/indices_5
Use more pcl::Indices
2 parents 0b39c0e + 476ebff commit 97cb436

39 files changed

+175
-177
lines changed

.ci/azure-pipelines/build/ubuntu_indices.yaml

-6
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,6 @@ steps:
1010
-DPCL_ONLY_CORE_POINT_TYPES=ON \
1111
-DPCL_INDEX_SIGNED=$INDEX_SIGNED \
1212
-DPCL_INDEX_SIZE=$INDEX_SIZE \
13-
-DBUILD_geometry=OFF \
14-
-DBUILD_io=OFF \
15-
-DBUILD_tools=OFF \
16-
-DBUILD_kdtree=OFF \
17-
-DBUILD_ml=OFF \
18-
-DBUILD_stereo=OFF \
1913
-DBUILD_global_tests=ON
2014
# Temporary fix to ensure no tests are skipped
2115
cmake $(Build.SourcesDirectory)

apps/3d_rec_framework/include/pcl/apps/3d_rec_framework/feature_wrapper/local/local_estimator.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ class UniformSamplingExtractor : public KeypointExtractor<PointInT> {
7777
using KeypointExtractor<PointInT>::input_;
7878
using KeypointExtractor<PointInT>::radius_;
7979
float sampling_density_;
80-
std::shared_ptr<std::vector<std::vector<int>>> neighborhood_indices_;
80+
std::shared_ptr<std::vector<pcl::Indices>> neighborhood_indices_;
8181
std::shared_ptr<std::vector<std::vector<float>>> neighborhood_dist_;
8282

8383
void
@@ -92,7 +92,7 @@ class UniformSamplingExtractor : public KeypointExtractor<PointInT> {
9292
tree.reset(new pcl::search::KdTree<PointInT>(false));
9393
tree->setInputCloud(input);
9494

95-
neighborhood_indices_.reset(new std::vector<std::vector<int>>);
95+
neighborhood_indices_.reset(new std::vector<pcl::Indices>);
9696
neighborhood_indices_->resize(keypoints_cloud->size());
9797
neighborhood_dist_.reset(new std::vector<std::vector<float>>);
9898
neighborhood_dist_->resize(keypoints_cloud->size());

apps/src/ni_linemod.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ class NILinemod {
208208
* \param[out] object the segmented resultant object
209209
*/
210210
void
211-
segmentObject(int picked_idx,
211+
segmentObject(pcl::index_t picked_idx,
212212
const CloudConstPtr& cloud,
213213
const PointIndices::Ptr& plane_indices,
214214
const PointIndices::Ptr& plane_boundary_indices,
@@ -293,7 +293,7 @@ class NILinemod {
293293
/////////////////////////////////////////////////////////////////////////
294294
void
295295
segment(const PointT& picked_point,
296-
int picked_idx,
296+
pcl::index_t picked_idx,
297297
PlanarRegion<PointT>& region,
298298
PointIndices&,
299299
CloudPtr& object)

filters/src/passthrough.cpp

+11-8
Original file line numberDiff line numberDiff line change
@@ -297,8 +297,11 @@ pcl::PassThrough<pcl::PCLPointCloud2>::applyFilter (Indices &indices)
297297
indices.resize (indices_->size ());
298298
removed_indices_->resize (indices_->size ());
299299
int oii = 0, rii = 0; // oii = output indices iterator, rii = removed indices iterator
300-
const std::uint32_t xyz_offset[3] = {input_->fields[x_idx_].offset, input_->fields[y_idx_].offset, input_->fields[z_idx_].offset};
301-
PCL_DEBUG ("[pcl::%s<pcl::PCLPointCloud2>::applyFilter] Field offsets: x: %u, y: %u, z: %u.\n", filter_name_.c_str (), xyz_offset[0], xyz_offset[1], xyz_offset[2]);
300+
const auto x_offset = input_->fields[x_idx_].offset,
301+
y_offset = input_->fields[y_idx_].offset,
302+
z_offset = input_->fields[z_idx_].offset;
303+
PCL_DEBUG ("[pcl::%s<pcl::PCLPointCloud2>::applyFilter] Field offsets: x: %zu, y: %zu, z: %zu.\n", filter_name_.c_str (),
304+
static_cast<std::size_t>(x_offset), static_cast<std::size_t>(y_offset), static_cast<std::size_t>(z_offset));
302305

303306
// Has a field name been specified?
304307
if (filter_field_name_.empty ())
@@ -307,9 +310,9 @@ pcl::PassThrough<pcl::PCLPointCloud2>::applyFilter (Indices &indices)
307310
for (const auto ii : indices) // ii = input index
308311
{
309312
float pt[3];
310-
memcpy (&pt[0], &input_->data[ii * input_->point_step + xyz_offset[0]], sizeof(float));
311-
memcpy (&pt[1], &input_->data[ii * input_->point_step + xyz_offset[1]], sizeof(float));
312-
memcpy (&pt[2], &input_->data[ii * input_->point_step + xyz_offset[2]], sizeof(float));
313+
memcpy (&pt[0], &input_->data[ii * input_->point_step + x_offset], sizeof(float));
314+
memcpy (&pt[1], &input_->data[ii * input_->point_step + y_offset], sizeof(float));
315+
memcpy (&pt[2], &input_->data[ii * input_->point_step + z_offset], sizeof(float));
313316
// Non-finite entries are always passed to removed indices
314317
if (!std::isfinite (pt[0]) ||
315318
!std::isfinite (pt[1]) ||
@@ -338,9 +341,9 @@ pcl::PassThrough<pcl::PCLPointCloud2>::applyFilter (Indices &indices)
338341
for (const auto ii : indices) // ii = input index
339342
{
340343
float pt[3];
341-
memcpy (&pt[0], &input_->data[ii * input_->point_step + xyz_offset[0]], sizeof(float));
342-
memcpy (&pt[1], &input_->data[ii * input_->point_step + xyz_offset[1]], sizeof(float));
343-
memcpy (&pt[2], &input_->data[ii * input_->point_step + xyz_offset[2]], sizeof(float));
344+
memcpy (&pt[0], &input_->data[ii * input_->point_step + x_offset], sizeof(float));
345+
memcpy (&pt[1], &input_->data[ii * input_->point_step + y_offset], sizeof(float));
346+
memcpy (&pt[2], &input_->data[ii * input_->point_step + z_offset], sizeof(float));
344347
// Non-finite entries are always passed to removed indices
345348
if (!std::isfinite (pt[0]) ||
346349
!std::isfinite (pt[1]) ||

recognition/include/pcl/recognition/impl/hv/hv_go.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ inline void extractEuclideanClustersSmooth(const typename pcl::PointCloud<PointT
6565
// Create a bool vector of processed point indices, and initialize it to false
6666
std::vector<bool> processed (cloud.size (), false);
6767

68-
std::vector<int> nn_indices;
68+
pcl::Indices nn_indices;
6969
std::vector<float> nn_distances;
7070
// Process all points in the indices vector
7171
int size = static_cast<int> (cloud.size ());

registration/include/pcl/registration/correspondence_rejection_poly.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -240,8 +240,8 @@ class PCL_EXPORTS CorrespondenceRejectorPoly : public CorrespondenceRejector {
240240
* all edge length ratios are larger than or equal to \ref similarity_threshold_
241241
*/
242242
inline bool
243-
thresholdPolygon(const std::vector<int>& source_indices,
244-
const std::vector<int>& target_indices)
243+
thresholdPolygon(const pcl::Indices& source_indices,
244+
const pcl::Indices& target_indices)
245245
{
246246
// Convert indices to correspondences and an index vector pointing to each element
247247
pcl::Correspondences corr(cardinality_);

registration/include/pcl/registration/correspondence_types.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -61,15 +61,15 @@ getCorDistMeanStd(const pcl::Correspondences& correspondences,
6161
* \note order of indices corresponds to input list of descriptor correspondences
6262
*/
6363
inline void
64-
getQueryIndices(const pcl::Correspondences& correspondences, std::vector<int>& indices);
64+
getQueryIndices(const pcl::Correspondences& correspondences, pcl::Indices& indices);
6565

6666
/** \brief extracts the match indices
6767
* \param[in] correspondences list of correspondences
6868
* \param[out] indices array of extracted indices.
6969
* \note order of indices corresponds to input list of descriptor correspondences
7070
*/
7171
inline void
72-
getMatchIndices(const pcl::Correspondences& correspondences, std::vector<int>& indices);
72+
getMatchIndices(const pcl::Correspondences& correspondences, pcl::Indices& indices);
7373

7474
} // namespace registration
7575
} // namespace pcl

registration/include/pcl/registration/ia_fpcs.h

+14-14
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ getMeanPointDensity(const typename pcl::PointCloud<PointT>::ConstPtr& cloud,
6464
template <typename PointT>
6565
inline float
6666
getMeanPointDensity(const typename pcl::PointCloud<PointT>::ConstPtr& cloud,
67-
const std::vector<int>& indices,
67+
const pcl::Indices& indices,
6868
float max_dist,
6969
int nr_threads = 1);
7070

@@ -318,7 +318,7 @@ class FPCSInitialAlignment : public Registration<PointSource, PointTarget, Scala
318318
* * = 0 a set of four congruent points was selected
319319
*/
320320
int
321-
selectBase(std::vector<int>& base_indices, float (&ratio)[2]);
321+
selectBase(pcl::Indices& base_indices, float (&ratio)[2]);
322322

323323
/** \brief Select randomly a triplet of points with large point-to-point distances.
324324
* The minimum point sampling distance is calculated based on the estimated point
@@ -330,7 +330,7 @@ class FPCSInitialAlignment : public Registration<PointSource, PointTarget, Scala
330330
* * = 0 base triangle succesully selected
331331
*/
332332
int
333-
selectBaseTriangle(std::vector<int>& base_indices);
333+
selectBaseTriangle(pcl::Indices& base_indices);
334334

335335
/** \brief Setup the base (four coplanar points) by ordering the points and computing
336336
* intersection ratios and segment to segment distances of base diagonal.
@@ -339,14 +339,14 @@ class FPCSInitialAlignment : public Registration<PointSource, PointTarget, Scala
339339
* \param[out] ratio diagonal intersection ratios of base points
340340
*/
341341
void
342-
setupBase(std::vector<int>& base_indices, float (&ratio)[2]);
342+
setupBase(pcl::Indices& base_indices, float (&ratio)[2]);
343343

344344
/** \brief Calculate intersection ratios and segment to segment distances of base
345345
* diagonals. \param[in] base_indices indices of base B \param[out] ratio diagonal
346346
* intersection ratios of base points \return quality value of diagonal intersection
347347
*/
348348
float
349-
segmentToSegmentDist(const std::vector<int>& base_indices, float (&ratio)[2]);
349+
segmentToSegmentDist(const pcl::Indices& base_indices, float (&ratio)[2]);
350350

351351
/** \brief Search for corresponding point pairs given the distance between two base
352352
* points.
@@ -375,8 +375,8 @@ class FPCSInitialAlignment : public Registration<PointSource, PointTarget, Scala
375375
* * = 0 at least one base match was found
376376
*/
377377
virtual int
378-
determineBaseMatches(const std::vector<int>& base_indices,
379-
std::vector<std::vector<int>>& matches,
378+
determineBaseMatches(const pcl::Indices& base_indices,
379+
std::vector<pcl::Indices>& matches,
380380
const pcl::Correspondences& pairs_a,
381381
const pcl::Correspondences& pairs_b,
382382
const float (&ratio)[2]);
@@ -391,7 +391,7 @@ class FPCSInitialAlignment : public Registration<PointSource, PointTarget, Scala
391391
* * = 0 edges of match M fits to the ones of base B
392392
*/
393393
int
394-
checkBaseMatch(const std::vector<int>& match_indices, const float (&ds)[4]);
394+
checkBaseMatch(const pcl::Indices& match_indices, const float (&ds)[4]);
395395

396396
/** \brief Method to handle current candidate matches. Here we validate and evaluate
397397
* the matches w.r.t the base and store the best fitting match (together with its
@@ -404,8 +404,8 @@ class FPCSInitialAlignment : public Registration<PointSource, PointTarget, Scala
404404
* contains the candidates matches M
405405
*/
406406
virtual void
407-
handleMatches(const std::vector<int>& base_indices,
408-
std::vector<std::vector<int>>& matches,
407+
handleMatches(const pcl::Indices& base_indices,
408+
std::vector<pcl::Indices>& matches,
409409
MatchingCandidates& candidates);
410410

411411
/** \brief Sets the correspondences between the base B and the match M by using the
@@ -416,8 +416,8 @@ class FPCSInitialAlignment : public Registration<PointSource, PointTarget, Scala
416416
* \param[out] correspondences resulting correspondences
417417
*/
418418
virtual void
419-
linkMatchWithBase(const std::vector<int>& base_indices,
420-
std::vector<int>& match_indices,
419+
linkMatchWithBase(const pcl::Indices& base_indices,
420+
pcl::Indices& match_indices,
421421
pcl::Correspondences& correspondences);
422422

423423
/** \brief Validate the matching by computing the transformation between the source
@@ -434,8 +434,8 @@ class FPCSInitialAlignment : public Registration<PointSource, PointTarget, Scala
434434
* * = 0 MSE smaller than max_mse_
435435
*/
436436
virtual int
437-
validateMatch(const std::vector<int>& base_indices,
438-
const std::vector<int>& match_indices,
437+
validateMatch(const pcl::Indices& base_indices,
438+
const pcl::Indices& match_indices,
439439
const pcl::Correspondences& correspondences,
440440
Eigen::Matrix4f& transformation);
441441

registration/include/pcl/registration/ia_kfpcs.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -205,8 +205,8 @@ class KFPCSInitialAlignment
205205
* contains the candidates matches M
206206
*/
207207
void
208-
handleMatches(const std::vector<int>& base_indices,
209-
std::vector<std::vector<int>>& matches,
208+
handleMatches(const pcl::Indices& base_indices,
209+
std::vector<pcl::Indices>& matches,
210210
MatchingCandidates& candidates) override;
211211

212212
/** \brief Validate the transformation by calculating the score value after

registration/include/pcl/registration/ia_ransac.h

+6-6
Original file line numberDiff line numberDiff line change
@@ -261,10 +261,10 @@ class SampleConsensusInitialAlignment : public Registration<PointSource, PointTa
261261
/** \brief Choose a random index between 0 and n-1
262262
* \param n the number of possible indices to choose from
263263
*/
264-
inline int
264+
inline pcl::index_t
265265
getRandomIndex(int n)
266266
{
267-
return (static_cast<int>(n * (rand() / (RAND_MAX + 1.0))));
267+
return (static_cast<pcl::index_t>(n * (rand() / (RAND_MAX + 1.0))));
268268
};
269269

270270
/** \brief Select \a nr_samples sample points from cloud while making sure that their
@@ -275,9 +275,9 @@ class SampleConsensusInitialAlignment : public Registration<PointSource, PointTa
275275
*/
276276
void
277277
selectSamples(const PointCloudSource& cloud,
278-
int nr_samples,
278+
unsigned int nr_samples,
279279
float min_sample_distance,
280-
std::vector<int>& sample_indices);
280+
pcl::Indices& sample_indices);
281281

282282
/** \brief For each of the sample points, find a list of points in the target cloud
283283
* whose features are similar to the sample points' features. From these, select one
@@ -288,8 +288,8 @@ class SampleConsensusInitialAlignment : public Registration<PointSource, PointTa
288288
*/
289289
void
290290
findSimilarFeatures(const FeatureCloud& input_features,
291-
const std::vector<int>& sample_indices,
292-
std::vector<int>& corresponding_indices);
291+
const pcl::Indices& sample_indices,
292+
pcl::Indices& corresponding_indices);
293293

294294
/** \brief An error metric for that computes the quality of the alignment between the
295295
* given cloud and the target. \param cloud the input cloud \param threshold distances

registration/include/pcl/registration/impl/correspondence_estimation_normal_shooting.hpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ CorrespondenceEstimationNormalShooting<PointSource, PointTarget, NormalT, Scalar
7373

7474
correspondences.resize(indices_->size());
7575

76-
std::vector<int> nn_indices(k_);
76+
pcl::Indices nn_indices(k_);
7777
std::vector<float> nn_dists(k_);
7878

7979
int min_index = 0;
@@ -188,9 +188,9 @@ CorrespondenceEstimationNormalShooting<PointSource, PointTarget, NormalT, Scalar
188188

189189
correspondences.resize(indices_->size());
190190

191-
std::vector<int> nn_indices(k_);
191+
pcl::Indices nn_indices(k_);
192192
std::vector<float> nn_dists(k_);
193-
std::vector<int> index_reciprocal(1);
193+
pcl::Indices index_reciprocal(1);
194194
std::vector<float> distance_reciprocal(1);
195195

196196
int min_index = 0;

registration/include/pcl/registration/impl/correspondence_types.hpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -68,15 +68,15 @@ getCorDistMeanStd(const pcl::Correspondences& correspondences,
6868
}
6969

7070
inline void
71-
getQueryIndices(const pcl::Correspondences& correspondences, std::vector<int>& indices)
71+
getQueryIndices(const pcl::Correspondences& correspondences, pcl::Indices& indices)
7272
{
7373
indices.resize(correspondences.size());
7474
for (std::size_t i = 0; i < correspondences.size(); ++i)
7575
indices[i] = correspondences[i].index_query;
7676
}
7777

7878
inline void
79-
getMatchIndices(const pcl::Correspondences& correspondences, std::vector<int>& indices)
79+
getMatchIndices(const pcl::Correspondences& correspondences, pcl::Indices& indices)
8080
{
8181
indices.resize(correspondences.size());
8282
for (std::size_t i = 0; i < correspondences.size(); ++i)

0 commit comments

Comments
 (0)