Skip to content

Commit a376418

Browse files
committed
Wrap static member variables in a getter method.
1 parent b38baee commit a376418

File tree

7 files changed

+26
-17
lines changed

7 files changed

+26
-17
lines changed

octree/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ if(NOT build)
1212
endif()
1313

1414
set(srcs
15-
src/octree_key.cpp
1615
src/octree_inst.cpp
1716
)
1817

octree/include/pcl/octree/impl/octree2buf_base.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ Octree2BufBase<LeafContainerT, BranchContainerT>::setMaxVoxelIndex(
7373

7474
// tree depth == amount of bits of maxVoxels
7575
treeDepth =
76-
std::max<uindex_t>(std::min<uindex_t>(OctreeKey::maxDepth,
76+
std::max<uindex_t>(std::min<uindex_t>(OctreeKey::getMaxDepth(),
7777
std::ceil(std::log2(max_voxel_index_arg))),
7878
0);
7979

octree/include/pcl/octree/impl/octree_base.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ OctreeBase<LeafContainerT, BranchContainerT>::setMaxVoxelIndex(
7878

7979
// tree depth == bitlength of maxVoxels
8080
tree_depth =
81-
std::min(static_cast<uindex_t>(OctreeKey::maxDepth),
81+
std::min(static_cast<uindex_t>(OctreeKey::getMaxDepth()),
8282
static_cast<uindex_t>(std::ceil(std::log2(max_voxel_index_arg))));
8383

8484
setTreeDepth(tree_depth);
@@ -94,11 +94,11 @@ OctreeBase<LeafContainerT, BranchContainerT>::setTreeDepth(uindex_t depth_arg)
9494
depth_arg);
9595
return;
9696
}
97-
if (depth_arg > OctreeKey::maxDepth) {
97+
if (depth_arg > OctreeKey::getMaxDepth()) {
9898
PCL_ERROR("[pcl::octree::OctreeBase::setTreeDepth] Tree depth (%lu) must be <= max "
9999
"depth(%lu)!\n",
100100
depth_arg,
101-
OctreeKey::maxDepth);
101+
OctreeKey::getMaxDepth());
102102
return;
103103
}
104104

octree/include/pcl/octree/impl/octree_pointcloud.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -713,7 +713,7 @@ pcl::octree::OctreePointCloud<PointT, LeafContainerT, BranchContainerT, OctreeT>
713713

714714
// tree depth == amount of bits of max_voxels
715715
this->octree_depth_ = std::max<uindex_t>(
716-
std::min<uindex_t>(OctreeKey::maxDepth,
716+
std::min<uindex_t>(OctreeKey::getMaxDepth(),
717717
std::ceil(std::log2(max_voxels) - minValue)),
718718
0);
719719

octree/include/pcl/octree/octree_key.h

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,14 @@ class OctreeKey {
138138
(!!(this->z & depthMask)));
139139
}
140140

141-
/* \brief maximum depth that can be addressed */
142-
static const unsigned char maxDepth;
141+
static unsigned char
142+
getMaxDepth()
143+
{
144+
/* \brief maximum depth that can be addressed */
145+
static const unsigned char maxDepth{
146+
static_cast<unsigned char>(sizeof(uindex_t) * 8)};
147+
return maxDepth;
148+
}
143149

144150
// Indices addressing a voxel at (X, Y, Z)
145151
// NOLINTBEGIN(modernize-use-default-member-init)

octree/src/octree_key.cpp

Lines changed: 0 additions & 4 deletions
This file was deleted.

sample_consensus/include/pcl/sample_consensus/sac_model.h

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ namespace pcl
186186

187187
// Get a second point which is different than the first
188188
samples.resize (getSampleSize ());
189-
for (unsigned int iter = 0; iter < max_sample_checks_; ++iter)
189+
for (unsigned int iter = 0; iter < getMaxSampleSize(); ++iter)
190190
{
191191
// Choose the random indices
192192
if (samples_radius_ < std::numeric_limits<double>::epsilon ())
@@ -201,7 +201,10 @@ namespace pcl
201201
return;
202202
}
203203
}
204-
PCL_DEBUG ("[pcl::SampleConsensusModel::getSamples] WARNING: Could not select %d sample points in %d iterations!\n", getSampleSize (), max_sample_checks_);
204+
PCL_DEBUG("[pcl::SampleConsensusModel::getSamples] WARNING: Could not select "
205+
"%d sample points in %d iterations!\n",
206+
getSampleSize(),
207+
getMaxSampleSize());
205208
samples.clear ();
206209
}
207210

@@ -359,6 +362,14 @@ namespace pcl
359362
return sample_size_;
360363
}
361364

365+
static unsigned int
366+
getMaxSampleSize()
367+
{
368+
/** The maximum number of samples to try until we get a good one */
369+
static const unsigned int max_sample_checks_ = 1000;
370+
return max_sample_checks_;
371+
}
372+
362373
/** \brief Return the number of coefficients in the model. */
363374
inline unsigned int
364375
getModelSize () const
@@ -556,9 +567,6 @@ namespace pcl
556567
/** \brief A pointer to the vector of point indices to use. */
557568
IndicesPtr indices_;
558569

559-
/** The maximum number of samples to try until we get a good one */
560-
static const unsigned int max_sample_checks_ = 1000;
561-
562570
/** \brief The minimum and maximum radius limits for the model.
563571
* Applicable to all models that estimate a radius.
564572
*/

0 commit comments

Comments
 (0)