Skip to content
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

Review casts in PCL, Part B #5508

Prev Previous commit
Next Next commit
Addressed clang-format violations flagged by CI
  • Loading branch information
gnawme committed Jan 12, 2023
commit e7d62f413ab59b8c0d6501a20f93684ac348feb3
7 changes: 4 additions & 3 deletions 2d/include/pcl/2d/impl/kernel.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,8 @@ kernel<PointT>::gaussianKernel(pcl::PointCloud<PointT>& kernel)
for (int j = 0; j < kernel_size_; j++) {
int iks = (i - kernel_size_ / 2);
int jks = (j - kernel_size_ / 2);
kernel(j, i).intensity =
std::exp(static_cast<float>(-static_cast<double>(iks * iks + jks * jks) / sigma_sqr));
kernel(j, i).intensity = std::exp(
static_cast<float>(-static_cast<double>(iks * iks + jks * jks) / sigma_sqr));
sum += (kernel(j, i).intensity);
}
}
Expand All @@ -132,7 +132,8 @@ kernel<PointT>::loGKernel(pcl::PointCloud<PointT>& kernel)
for (int j = 0; j < kernel_size_; j++) {
int iks = (i - kernel_size_ / 2);
int jks = (j - kernel_size_ / 2);
float temp = static_cast<float>(static_cast<double>(iks * iks + jks * jks) / sigma_sqr);
float temp =
static_cast<float>(static_cast<double>(iks * iks + jks * jks) / sigma_sqr);
kernel(j, i).intensity = (1.0f - temp) * std::exp(-temp);
sum += kernel(j, i).intensity;
}
Expand Down
3 changes: 2 additions & 1 deletion ml/src/svm_wrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,8 @@ pcl::SVM::loadProblem(const char* filename, svm_problem& prob)
return false;
}

if (static_cast<int>(prob.x[i][0].value) <= 0 || static_cast<int>(prob.x[i][0].value) > max_index) {
if (static_cast<int>(prob.x[i][0].value) <= 0 ||
static_cast<int>(prob.x[i][0].value) > max_index) {
PCL_ERROR("[pcl::%s] Wrong input format: sample_serial_number out of range.\n",
getClassName().c_str());
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -385,8 +385,9 @@ class DataContainer : public DataContainerInterface {
"Normals are not set for the input and target point clouds");
const NormalT& src = (*input_normals_)[corr.index_query];
const NormalT& tgt = (*target_normals_)[corr.index_match];
return (static_cast<double>((src.normal[0] * tgt.normal[0]) + (src.normal[1] * tgt.normal[1]) +
(src.normal[2] * tgt.normal[2])));
return (static_cast<double>((src.normal[0] * tgt.normal[0]) +
(src.normal[1] * tgt.normal[1]) +
(src.normal[2] * tgt.normal[2])));
}

private:
Expand Down
3 changes: 2 additions & 1 deletion registration/include/pcl/registration/impl/gicp.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,8 @@ GeneralizedIterativeClosestPoint<PointSource, PointTarget, Scalar>::
for (std::size_t i = 0; i < 4; i++)
for (std::size_t j = 0; j < 4; j++)
for (std::size_t k = 0; k < 4; k++)
transform_R(i, j) += static_cast<double>(transformation_(i, k)) * static_cast<double>(guess(k, j));
transform_R(i, j) += static_cast<double>(transformation_(i, k)) *
static_cast<double>(guess(k, j));

Eigen::Matrix3d R = transform_R.topLeftCorner<3, 3>();

Expand Down
6 changes: 3 additions & 3 deletions registration/include/pcl/registration/impl/ia_fpcs.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -312,9 +312,9 @@ pcl::registration::FPCSInitialAlignment<PointSource, PointTarget, NormalT, Scala
// heuristic determination of number of trials to have high probability of finding a
// good solution
if (max_iterations_ == 0) {
float first_est =
std::log(small_error_) /
std::log(1.0 - std::pow(static_cast<double>(approx_overlap_), static_cast<double>(min_iterations)));
float first_est = std::log(small_error_) /
std::log(1.0 - std::pow(static_cast<double>(approx_overlap_),
static_cast<double>(min_iterations)));
max_iterations_ =
static_cast<int>(first_est / (diameter_fraction * approx_overlap_ * 2.f));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,8 @@ TransformationEstimationDualQuaternion<PointSource, PointTarget, Scalar>::
ptrdiff_t i;
es.eigenvalues().real().maxCoeff(&i);
const Eigen::Matrix<double, 4, 1> qmat = es.eigenvectors().col(i).real();
const Eigen::Matrix<double, 4, 1> smat = -(0.5 / static_cast<double>(npts)) * C2 * qmat;
const Eigen::Matrix<double, 4, 1> smat =
-(0.5 / static_cast<double>(npts)) * C2 * qmat;

const Eigen::Quaternion<double> q(qmat(3), qmat(0), qmat(1), qmat(2));
const Eigen::Quaternion<double> s(smat(3), smat(0), smat(1), smat(2));
Expand Down
12 changes: 8 additions & 4 deletions registration/src/correspondence_rejection_var_trimmed.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,12 @@ pcl::registration::CorrespondenceRejectorVarTrimmed::getRemainingCorrespondences
}
}
factor_ = optimizeInlierRatio(dists);
nth_element(
dists.begin(), dists.begin() + static_cast<int>(static_cast<double>(dists.size()) * factor_), dists.end());
trimmed_distance_ = dists[static_cast<int>(static_cast<double>(dists.size()) * factor_)];
nth_element(dists.begin(),
dists.begin() +
static_cast<int>(static_cast<double>(dists.size()) * factor_),
dists.end());
trimmed_distance_ =
dists[static_cast<int>(static_cast<double>(dists.size()) * factor_)];

unsigned int number_valid_correspondences = 0;
remaining_correspondences.resize(original_correspondences.size());
Expand Down Expand Up @@ -99,6 +102,7 @@ pcl::registration::CorrespondenceRejectorVarTrimmed::optimizeInlierRatio(
int min_index(0);
FRMS.minCoeff(&min_index);

const float opt_ratio = static_cast<float>(min_index + min_el) / static_cast<float>(points_nbr);
const float opt_ratio =
static_cast<float>(min_index + min_el) / static_cast<float>(points_nbr);
return (opt_ratio);
}
3 changes: 2 additions & 1 deletion registration/src/gicp6d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,8 @@ GeneralizedIterativeClosestPoint6D::computeTransformation(PointCloudSource& outp
for (std::size_t i = 0; i < 4; i++)
for (std::size_t j = 0; j < 4; j++)
for (std::size_t k = 0; k < 4; k++)
transform_R(i, j) += static_cast<double>(transformation_(i, k)) * static_cast<double>(guess(k, j));
transform_R(i, j) += static_cast<double>(transformation_(i, k)) *
static_cast<double>(guess(k, j));

Eigen::Matrix3d R = transform_R.topLeftCorner<3, 3>();

Expand Down
3 changes: 2 additions & 1 deletion simulation/tools/sim_terminal_demo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,8 @@ generate_halo(
int n_poses)
{

for (double t = 0; t < (2 * M_PI); t = t + (2 * M_PI) / (static_cast<double>(n_poses))) {
for (double t = 0; t < (2 * M_PI);
t = t + (2 * M_PI) / (static_cast<double>(n_poses))) {
double x = halo_r * std::cos(t);
double y = halo_r * sin(t);
double z = halo_dz;
Expand Down