Skip to content

Commit cb71fde

Browse files
committed
Fix MSVC warning C26814: "The const variable 'variable' can be computed at compile time. Consider using constexpr."
1 parent 58f9cfb commit cb71fde

File tree

99 files changed

+275
-276
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

99 files changed

+275
-276
lines changed

apps/in_hand_scanner/src/icp.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ pcl::ihs::ICP::findTransformation(const MeshConstPtr& mesh_model,
161161
{
162162
// Check the input
163163
// TODO: Double check the minimum number of points necessary for icp
164-
const std::size_t n_min = 4;
164+
constexpr std::size_t n_min = 4;
165165

166166
if (mesh_model->sizeVertices() < n_min || cloud_data->size() < n_min) {
167167
std::cerr << "ERROR in icp.cpp: Not enough input points!\n";

apps/in_hand_scanner/src/integration.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ pcl::ihs::Integration::reconstructMesh(const CloudXYZRGBNormalConstPtr& cloud_da
124124
// * 3 - 0 //
125125
const int offset_1 = -width;
126126
const int offset_2 = -width - 1;
127-
const int offset_3 = -1;
127+
constexpr int offset_3 = -1;
128128
const int offset_4 = -width - 2;
129129

130130
for (int r = 1; r < height; ++r) {
@@ -262,7 +262,7 @@ pcl::ihs::Integration::merge(const CloudXYZRGBNormalConstPtr& cloud_data,
262262
// * 3 - 0 //
263263
const int offset_1 = -width;
264264
const int offset_2 = -width - 1;
265-
const int offset_3 = -1;
265+
constexpr int offset_3 = -1;
266266
const int offset_4 = -width - 2;
267267

268268
const float dot_min = std::cos(max_angle_ * 17.45329252e-3); // deg to rad

apps/in_hand_scanner/src/main_window.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ pcl::ihs::MainWindow::MainWindow(QWidget* parent)
7070
spacer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
7171
ui_->toolBar->insertWidget(ui_->actionHelp, spacer);
7272

73-
const double max = std::numeric_limits<double>::max();
73+
constexpr double max = std::numeric_limits<double>::max();
7474

7575
// In hand scanner
7676
QHBoxLayout* layout = new QHBoxLayout(ui_->placeholder_in_hand_scanner);

apps/in_hand_scanner/src/opengl_viewer.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -484,7 +484,7 @@ pcl::ihs::OpenGLViewer::addMesh(const CloudXYZRGBNormalConstPtr& cloud,
484484
const int h = cloud->height;
485485
const int offset_1 = -w;
486486
const int offset_2 = -w - 1;
487-
const int offset_3 = -1;
487+
constexpr int offset_3 = -1;
488488

489489
FaceVertexMeshPtr mesh(new FaceVertexMesh());
490490
mesh->transformation = T;
@@ -1083,7 +1083,7 @@ pcl::ihs::OpenGLViewer::initializeGL()
10831083
void
10841084
pcl::ihs::OpenGLViewer::setupViewport(const int w, const int h)
10851085
{
1086-
const float aspect_ratio = 4. / 3.;
1086+
constexpr float aspect_ratio = 4. / 3.;
10871087

10881088
// Use the biggest possible area of the window to draw to
10891089
// case 1 (w < w_scaled): case 2 (w >= w_scaled):

apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/localTypes.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -167,25 +167,25 @@ struct IncIndex
167167
/// A helpful const representing the number of elements in our vectors.
168168
/// This is used for all operations that require the copying of the vector.
169169
/// Although this is used in a fairly generic way, the display requires 3D.
170-
const unsigned int XYZ_SIZE = 3;
170+
constexpr unsigned int XYZ_SIZE = 3;
171171

172172
/// A helpful const representing the number of elements in each row/col in
173173
/// our matrices. This is used for all operations that require the copying of
174174
/// the matrix.
175-
const unsigned int MATRIX_SIZE_DIM = 4;
175+
constexpr unsigned int MATRIX_SIZE_DIM = 4;
176176

177177
/// A helpful const representing the number of elements in our matrices.
178178
/// This is used for all operations that require the copying of the matrix.
179-
const unsigned int MATRIX_SIZE = MATRIX_SIZE_DIM * MATRIX_SIZE_DIM;
179+
constexpr unsigned int MATRIX_SIZE = MATRIX_SIZE_DIM * MATRIX_SIZE_DIM;
180180

181181
/// The default window width
182-
const unsigned int WINDOW_WIDTH = 1200;
182+
constexpr unsigned int WINDOW_WIDTH = 1200;
183183
/// The default window height
184-
const unsigned int WINDOW_HEIGHT = 1000;
184+
constexpr unsigned int WINDOW_HEIGHT = 1000;
185185

186186
/// The default z translation used to push the world origin in front of the
187187
/// display
188-
const float DISPLAY_Z_TRANSLATION = -2.0f;
188+
constexpr float DISPLAY_Z_TRANSLATION = -2.0f;
189189

190190
/// The radius of the trackball given as a percentage of the screen width
191-
const float TRACKBALL_RADIUS_SCALE = 0.4f;
191+
constexpr float TRACKBALL_RADIUS_SCALE = 0.4f;

apps/src/feature_matching.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ ICCVTutorial<FeatureType>::findCorrespondences(
324324

325325
// Find the index of the best match for each keypoint, and store it in
326326
// "correspondences_out"
327-
const int k = 1;
327+
constexpr int k = 1;
328328
pcl::Indices k_indices(k);
329329
std::vector<float> k_squared_distances(k);
330330
for (int i = 0; i < static_cast<int>(source->size()); ++i) {

apps/src/multiscale_feature_persistence_example.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
using namespace pcl;
4848

4949
const Eigen::Vector4f subsampling_leaf_size(0.01f, 0.01f, 0.01f, 0.0f);
50-
const float normal_estimation_search_radius = 0.05f;
50+
constexpr float normal_estimation_search_radius = 0.05f;
5151

5252
void
5353
subsampleAndCalculateNormals(PointCloud<PointXYZ>::Ptr& cloud,

apps/src/openni_feature_persistence.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,11 @@ using namespace std::chrono_literals;
6969
} while (false)
7070
// clang-format on
7171

72-
const float default_subsampling_leaf_size = 0.02f;
73-
const float default_normal_search_radius = 0.041f;
72+
constexpr float default_subsampling_leaf_size = 0.02f;
73+
constexpr float default_normal_search_radius = 0.041f;
7474
const double aux[] = {0.21, 0.32};
7575
const std::vector<double> default_scales_vector(aux, aux + 2);
76-
const float default_alpha = 1.2f;
76+
constexpr float default_alpha = 1.2f;
7777

7878
template <typename PointType>
7979
class OpenNIFeaturePersistence {

apps/src/openni_mobile_server.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ CopyPointCloudToBuffers(const pcl::PointCloud<pcl::PointXYZRGBA>::ConstPtr& clou
7979
point.x > bounds_max.x || point.y > bounds_max.y || point.z > bounds_max.z)
8080
continue;
8181

82-
const int conversion_factor = 500;
82+
constexpr int conversion_factor = 500;
8383

8484
cloud_buffers.points[j * 3 + 0] = static_cast<short>(point.x * conversion_factor);
8585
cloud_buffers.points[j * 3 + 1] = static_cast<short>(point.y * conversion_factor);

apps/src/openni_organized_edge_detection.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ class OpenNIOrganizedEdgeDetection {
6868
*this);
6969
viewer->resetCameraViewpoint("cloud");
7070

71-
const int point_size = 2;
71+
constexpr int point_size = 2;
7272
viewer->addPointCloud<PointT>(cloud, "nan boundary edges");
7373
viewer->setPointCloudRenderingProperties(
7474
pcl::visualization::PCL_VISUALIZER_POINT_SIZE,

0 commit comments

Comments
 (0)