From 5b8b06f2fa36a04f8bc5d427c6a936f57ba831fc Mon Sep 17 00:00:00 2001 From: Norm Evangelista Date: Mon, 17 Nov 2025 14:32:21 -0800 Subject: [PATCH 1/8] Added more bugprone-* clang-tidy checks --- .clang-tidy | 4 ++ .../example_nurbs_fitting_closed_curve.cpp | 6 +-- .../example_nurbs_fitting_closed_curve3d.cpp | 6 +-- .../surface/example_nurbs_fitting_curve2d.cpp | 6 +-- .../surface/example_nurbs_fitting_surface.cpp | 6 +-- .../surface/example_nurbs_viewer_surface.cpp | 4 +- .../surface/test_nurbs_fitting_surface.cpp | 12 ++--- surface/src/on_nurbs/closing_boundary.cpp | 16 +++--- surface/src/on_nurbs/fitting_curve_2d.cpp | 12 ++--- .../src/on_nurbs/fitting_curve_2d_apdm.cpp | 26 +++++----- .../src/on_nurbs/fitting_curve_2d_asdm.cpp | 12 ++--- .../src/on_nurbs/fitting_curve_2d_atdm.cpp | 16 +++--- surface/src/on_nurbs/fitting_curve_2d_pdm.cpp | 20 +++---- surface/src/on_nurbs/fitting_curve_2d_sdm.cpp | 4 +- surface/src/on_nurbs/fitting_curve_2d_tdm.cpp | 8 +-- surface/src/on_nurbs/fitting_curve_pdm.cpp | 12 ++--- surface/src/on_nurbs/fitting_cylinder_pdm.cpp | 8 +-- surface/src/on_nurbs/fitting_sphere_pdm.cpp | 4 +- surface/src/on_nurbs/fitting_surface_im.cpp | 34 ++++++------ surface/src/on_nurbs/fitting_surface_pdm.cpp | 10 ++-- surface/src/on_nurbs/fitting_surface_tdm.cpp | 4 +- .../src/on_nurbs/global_optimization_pdm.cpp | 4 +- .../src/on_nurbs/global_optimization_tdm.cpp | 10 ++-- surface/src/on_nurbs/nurbs_tools.cpp | 20 +++---- surface/src/on_nurbs/sequential_fitter.cpp | 20 +++---- surface/src/on_nurbs/sparse_mat.cpp | 2 +- surface/src/on_nurbs/triangulation.cpp | 52 +++++++++---------- 27 files changed, 171 insertions(+), 167 deletions(-) diff --git a/.clang-tidy b/.clang-tidy index 5b0383fadf9..d475e97d587 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -1,7 +1,11 @@ --- Checks: > -*, + bugprone-assert-side-effect, bugprone-copy-constructor-init, + bugprone-dangling-handle, + bugprone-forward-declaration-namespace, + bugprone-inaccurate-erase, bugprone-macro-parentheses, bugprone-unhandled-self-assignment, bugprone-unused-raii, diff --git a/examples/surface/example_nurbs_fitting_closed_curve.cpp b/examples/surface/example_nurbs_fitting_closed_curve.cpp index 65342497a35..9c6ffda9bdb 100644 --- a/examples/surface/example_nurbs_fitting_closed_curve.cpp +++ b/examples/surface/example_nurbs_fitting_closed_curve.cpp @@ -43,9 +43,9 @@ VisualizeCurve (ON_NurbsCurve &curve, double r, double g, double b, bool show_cp curve.GetCV (i, cp); pcl::PointXYZ p; - p.x = float (cp.x); - p.y = float (cp.y); - p.z = float (cp.z); + p.x = static_cast(cp.x); + p.y = static_cast(cp.y); + p.z = static_cast(cp.z); cps->push_back (p); } pcl::visualization::PointCloudColorHandlerCustom handler (cps, 255 * r, 255 * g, 255 * b); diff --git a/examples/surface/example_nurbs_fitting_closed_curve3d.cpp b/examples/surface/example_nurbs_fitting_closed_curve3d.cpp index c6da7235fac..4595e520b47 100644 --- a/examples/surface/example_nurbs_fitting_closed_curve3d.cpp +++ b/examples/surface/example_nurbs_fitting_closed_curve3d.cpp @@ -41,9 +41,9 @@ VisualizeCurve (ON_NurbsCurve &curve, double r, double g, double b, bool show_cp curve.GetCV (i, cp); pcl::PointXYZ p; - p.x = float (cp.x); - p.y = float (cp.y); - p.z = float (cp.z); + p.x = static_cast(cp.x); + p.y = static_cast(cp.y); + p.z = static_cast(cp.z); cps->push_back (p); } pcl::visualization::PointCloudColorHandlerCustom handler (cps, 255 * r, 255 * g, 255 * b); diff --git a/examples/surface/example_nurbs_fitting_curve2d.cpp b/examples/surface/example_nurbs_fitting_curve2d.cpp index f66b050cfdd..e43ee38fe3f 100644 --- a/examples/surface/example_nurbs_fitting_curve2d.cpp +++ b/examples/surface/example_nurbs_fitting_curve2d.cpp @@ -41,9 +41,9 @@ VisualizeCurve (ON_NurbsCurve &curve, double r, double g, double b, bool show_cp curve.GetCV (i, cp); pcl::PointXYZ p; - p.x = float (cp.x); - p.y = float (cp.y); - p.z = float (cp.z); + p.x = static_cast(cp.x); + p.y = static_cast(cp.y); + p.z = static_cast(cp.z); cps->push_back (p); } pcl::visualization::PointCloudColorHandlerCustom handler (cps, 255 * r, 255 * g, 255 * b); diff --git a/examples/surface/example_nurbs_fitting_surface.cpp b/examples/surface/example_nurbs_fitting_surface.cpp index 0cbda86ac80..ee52a8dea05 100644 --- a/examples/surface/example_nurbs_fitting_surface.cpp +++ b/examples/surface/example_nurbs_fitting_surface.cpp @@ -202,9 +202,9 @@ visualizeCurve (ON_NurbsCurve &curve, ON_NurbsSurface &surface, pcl::visualizati double pnt[3]; surface.Evaluate (p1.x, p1.y, 0, 3, pnt); pcl::PointXYZRGB p2; - p2.x = float (pnt[0]); - p2.y = float (pnt[1]); - p2.z = float (pnt[2]); + p2.x = static_cast(pnt[0]); + p2.y = static_cast(pnt[1]); + p2.z = static_cast(pnt[2]); p2.r = 255; p2.g = 0; diff --git a/examples/surface/example_nurbs_viewer_surface.cpp b/examples/surface/example_nurbs_viewer_surface.cpp index d77d7f02075..27ff9319469 100644 --- a/examples/surface/example_nurbs_viewer_surface.cpp +++ b/examples/surface/example_nurbs_viewer_surface.cpp @@ -48,7 +48,7 @@ main (int argc, char *argv[]) return -1; } - const ON_NurbsSurface& on_surf = *(ON_NurbsSurface*)on_object; + const ON_NurbsSurface& on_surf = *dynamic_cast(on_object); pcl::PolygonMesh mesh; std::string mesh_id = "mesh_nurbs"; @@ -68,7 +68,7 @@ main (int argc, char *argv[]) return -1; } - const ON_NurbsCurve& on_curv = *(ON_NurbsCurve*)on_object; + const ON_NurbsCurve& on_curv = *dynamic_cast(on_object); pcl::on_nurbs::Triangulation::convertTrimmedSurface2PolygonMesh (on_surf, on_curv, mesh, mesh_resolution); diff --git a/examples/surface/test_nurbs_fitting_surface.cpp b/examples/surface/test_nurbs_fitting_surface.cpp index 74a52083587..60832ea8bf4 100644 --- a/examples/surface/test_nurbs_fitting_surface.cpp +++ b/examples/surface/test_nurbs_fitting_surface.cpp @@ -12,15 +12,15 @@ CreateCylinderPoints (pcl::PointCloud::Ptr cloud, pcl::on_nurbs::vector_v { for (unsigned i = 0; i < npoints; i++) { - double da = alpha * double (rand ()) / RAND_MAX; - double dh = h * (double (rand ()) / RAND_MAX - 0.5); + double da = alpha * static_cast(rand ()) / RAND_MAX; + double dh = h * (static_cast(rand ()) / RAND_MAX - 0.5); Point p; - p.x = float (r * std::cos (da)); - p.y = float (r * sin (da)); - p.z = float (dh); + p.x = static_cast(r * std::cos (da)); + p.y = static_cast(r * sin (da)); + p.z = static_cast(dh); - data.push_back (Eigen::Vector3d (p.x, p.y, p.z)); + data.emplace_back(p.x, p.y, p.z); cloud->push_back (p); } } diff --git a/surface/src/on_nurbs/closing_boundary.cpp b/surface/src/on_nurbs/closing_boundary.cpp index 4bb1637e36b..2b1c4ba65bd 100644 --- a/surface/src/on_nurbs/closing_boundary.cpp +++ b/surface/src/on_nurbs/closing_boundary.cpp @@ -243,7 +243,7 @@ ClosingBoundary::sampleUniform (ON_NurbsSurface *nurbs, vector_vec3d &point_list { params (0) = minU + (maxU - minU) * ds * i; nurbs->Evaluate (params (0), params (1), 0, 3, points); - point_list.push_back (Eigen::Vector3d (points[0], points[1], points[2])); + point_list.emplace_back(points[0], points[1], points[2]); } } } @@ -262,10 +262,10 @@ ClosingBoundary::sampleRandom (ON_NurbsSurface *nurbs, vector_vec3d &point_list, for (unsigned i = 0; i < samples; i++) { - params (0) = minU + (maxU - minU) * (double (rand ()) / RAND_MAX); - params (1) = minV + (maxV - minV) * (double (rand ()) / RAND_MAX); + params (0) = minU + (maxU - minU) * (static_cast(rand ()) / RAND_MAX); + params (1) = minV + (maxV - minV) * (static_cast(rand ()) / RAND_MAX); nurbs->Evaluate (params (0), params (1), 0, 3, points); - point_list.push_back (Eigen::Vector3d (points[0], points[1], points[2])); + point_list.emplace_back(points[0], points[1], points[2]); } } @@ -290,7 +290,7 @@ ClosingBoundary::sampleFromBoundary (ON_NurbsSurface *nurbs, vector_vec3d &point { params (1) = minV + (maxV - minV) * ds * i; nurbs->Evaluate (params (0), params (1), 0, 3, points); - point_list.push_back (Eigen::Vector3d (points[0], points[1], points[2])); + point_list.emplace_back(points[0], points[1], points[2]); param_list.push_back (params); } @@ -300,7 +300,7 @@ ClosingBoundary::sampleFromBoundary (ON_NurbsSurface *nurbs, vector_vec3d &point { params (1) = minV + (maxV - minV) * ds * i; nurbs->Evaluate (params (0), params (1), 0, 3, points); - point_list.push_back (Eigen::Vector3d (points[0], points[1], points[2])); + point_list.emplace_back(points[0], points[1], points[2]); param_list.push_back (params); } @@ -310,7 +310,7 @@ ClosingBoundary::sampleFromBoundary (ON_NurbsSurface *nurbs, vector_vec3d &point { params (0) = minU + (maxU - minU) * ds * i; nurbs->Evaluate (params (0), params (1), 0, 3, points); - point_list.push_back (Eigen::Vector3d (points[0], points[1], points[2])); + point_list.emplace_back(points[0], points[1], points[2]); param_list.push_back (params); } @@ -320,7 +320,7 @@ ClosingBoundary::sampleFromBoundary (ON_NurbsSurface *nurbs, vector_vec3d &point { params (0) = minU + (maxU - minU) * ds * i; nurbs->Evaluate (params (0), params (1), 0, 3, points); - point_list.push_back (Eigen::Vector3d (points[0], points[1], points[2])); + point_list.emplace_back(points[0], points[1], points[2]); param_list.push_back (params); } } diff --git a/surface/src/on_nurbs/fitting_curve_2d.cpp b/surface/src/on_nurbs/fitting_curve_2d.cpp index fbafd5a8fa5..0aceacb41e7 100644 --- a/surface/src/on_nurbs/fitting_curve_2d.cpp +++ b/surface/src/on_nurbs/fitting_curve_2d.cpp @@ -74,7 +74,7 @@ int FittingCurve2d::findElement (double xi, const std::vector &elements) { if (xi >= elements.back ()) - return (int (elements.size ()) - 2); + return (static_cast(elements.size ()) - 2); for (std::size_t i = 0; i < elements.size () - 1; i++) { @@ -120,7 +120,7 @@ FittingCurve2d::assemble (const Parameter ¶meter) { int ncp = m_nurbs.m_cv_count; int nCageReg = m_nurbs.m_cv_count - 2; - int nInt = int (m_data->interior.size ()); + int nInt = static_cast(m_data->interior.size ()); double wInt = 1.0; if (!m_data->interior_weight.empty ()) @@ -290,7 +290,7 @@ FittingCurve2d::initNurbsPCA (int order, NurbsDataCurve2d *data, int ncps) if (ncps < order) ncps = order; - unsigned s = static_cast (data->interior.size ()); + auto s = static_cast (data->interior.size ()); data->interior_param.clear (); NurbsTools::pca (data->interior, mean, eigenvectors, eigenvalues); @@ -399,7 +399,7 @@ FittingCurve2d::getElementVector (const ON_NurbsCurve &nurbs) void FittingCurve2d::assembleInterior (double wInt, double rScale, unsigned &row) { - int nInt = int (m_data->interior.size ()); + int nInt = static_cast(m_data->interior.size ()); m_data->interior_error.clear (); m_data->interior_normals.clear (); m_data->interior_line_start.clear (); @@ -413,7 +413,7 @@ FittingCurve2d::assembleInterior (double wInt, double rScale, unsigned &row) double param; Eigen::Vector2d pt, t; double error; - if (p < int (m_data->interior_param.size ())) + if (p < static_cast(m_data->interior_param.size ())) { param = findClosestElementMidPoint (m_nurbs, pcp, m_data->interior_param[p]); param = inverseMapping (m_nurbs, pcp, param, error, pt, t, rScale, in_max_steps, in_accuracy, m_quiet); @@ -428,7 +428,7 @@ FittingCurve2d::assembleInterior (double wInt, double rScale, unsigned &row) m_data->interior_error.push_back (error); - if (p < int (m_data->interior_weight.size ())) + if (p < static_cast(m_data->interior_weight.size ())) wInt = m_data->interior_weight[p]; m_data->interior_line_start.push_back (pcp); diff --git a/surface/src/on_nurbs/fitting_curve_2d_apdm.cpp b/surface/src/on_nurbs/fitting_curve_2d_apdm.cpp index b30bc04f74b..0693b70dbfe 100644 --- a/surface/src/on_nurbs/fitting_curve_2d_apdm.cpp +++ b/surface/src/on_nurbs/fitting_curve_2d_apdm.cpp @@ -75,7 +75,7 @@ int FittingCurve2dAPDM::findElement (double xi, const std::vector &elements) { if (xi >= elements.back ()) - return (int (elements.size ()) - 2); + return (static_cast(elements.size ()) - 2); for (std::size_t i = 0; i < elements.size () - 1; i++) { @@ -148,8 +148,8 @@ FittingCurve2dAPDM::assemble (const Parameter ¶meter) int cp_red = m_nurbs.m_order - 2; int ncp = m_nurbs.m_cv_count - 2 * cp_red; int nCageReg = m_nurbs.m_cv_count - 2 * cp_red; - int nInt = int (m_data->interior.size ()); - int nClosestP = int (elements.size ()) * cp_res; + int nInt = static_cast(m_data->interior.size ()); + int nClosestP = static_cast(elements.size ()) * cp_res; double wInt = 1.0; if (!m_data->interior_weight.empty ()) @@ -330,8 +330,8 @@ FittingCurve2dAPDM::removeCPsOnLine (const ON_NurbsCurve &nurbs, double min_curv } int order = nurbs.Order (); - ON_NurbsCurve nurbs_opt = ON_NurbsCurve (2, false, order, int (cps.size ()) + 2 * cp_red); - nurbs_opt.MakePeriodicUniformKnotVector (1.0 / (double (cps.size ()))); + ON_NurbsCurve nurbs_opt = ON_NurbsCurve (2, false, order, static_cast(cps.size ()) + 2 * cp_red); + nurbs_opt.MakePeriodicUniformKnotVector (1.0 / (static_cast(cps.size ()))); nurbs_opt.m_knot[cp_red] = 0.0; nurbs_opt.m_knot[nurbs_opt.m_knot_capacity - cp_red - 1] = 1.0; @@ -428,7 +428,7 @@ FittingCurve2dAPDM::addCageRegularisation (double weight, unsigned &row, const s { int i = j % ncp; - if (i >= int (m_data->closest_points_error.size () - 1)) + if (i >= static_cast(m_data->closest_points_error.size () - 1)) { printf ("[FittingCurve2dAPDM::addCageRegularisation] Warning, index for closest_points_error out of bounds\n"); m_solver.f (row, 0, 0.0); @@ -512,7 +512,7 @@ FittingCurve2dAPDM::initCPsNurbsCurve2D (int order, const vector_vec2d &cps) return nurbs; } - int ncps = int (cps.size ()) + 2 * cp_red; // +2*cp_red for smoothness and +1 for closing + int ncps = static_cast(cps.size ()) + 2 * cp_red; // +2*cp_red for smoothness and +1 for closing nurbs = ON_NurbsCurve (2, false, order, ncps); nurbs.MakePeriodicUniformKnotVector (1.0 / (ncps - order + 1)); @@ -520,7 +520,7 @@ FittingCurve2dAPDM::initCPsNurbsCurve2D (int order, const vector_vec2d &cps) nurbs.SetCV (cp_red + j, ON_3dPoint (cps[j] (0), cps[j] (1), 0.0)); // close nurbs - nurbs.SetCV (cp_red + int (cps.size ()), ON_3dPoint (cps[0] (0), cps[0] (1), 0.0)); + nurbs.SetCV (cp_red + static_cast(cps.size ()), ON_3dPoint (cps[0] (0), cps[0] (1), 0.0)); // make smooth at closing point for (int j = 0; j < cp_red; j++) @@ -544,7 +544,7 @@ FittingCurve2dAPDM::initNurbsCurve2D (int order, const vector_vec2d &data, int n Eigen::Vector2d mean = NurbsTools::computeMean (data); - unsigned s = unsigned (data.size ()); + auto s = static_cast(data.size ()); double r (0.0); for (unsigned i = 0; i < s; i++) @@ -641,7 +641,7 @@ FittingCurve2dAPDM::getElementVector (const ON_NurbsCurve &nurbs) void FittingCurve2dAPDM::assembleInterior (double wInt, double sigma2, double rScale, unsigned &row) { - int nInt = int (m_data->interior.size ()); + int nInt = static_cast(m_data->interior.size ()); bool wFunction (true); double ds = 1.0 / (2.0 * sigma2); m_data->interior_error.clear (); @@ -657,7 +657,7 @@ FittingCurve2dAPDM::assembleInterior (double wInt, double sigma2, double rScale, double param; Eigen::Vector2d pt, t; double error; - if (p < int (m_data->interior_param.size ())) + if (p < static_cast(m_data->interior_param.size ())) { param = findClosestElementMidPoint (m_nurbs, pcp, m_data->interior_param[p]); param = inverseMapping (m_nurbs, pcp, param, error, pt, t, rScale, in_max_steps, in_accuracy, m_quiet); @@ -677,10 +677,10 @@ FittingCurve2dAPDM::assembleInterior (double wInt, double sigma2, double rScale, Eigen::Vector3d b (t (0), t (1), 0.0); Eigen::Vector3d z = a.cross (b); - if (p < int (m_data->interior_weight.size ())) + if (p < static_cast(m_data->interior_weight.size ())) wInt = m_data->interior_weight[p]; - if (p < int (m_data->interior_weight_function.size ())) + if (p < static_cast(m_data->interior_weight_function.size ())) wFunction = m_data->interior_weight_function[p]; double w (wInt); diff --git a/surface/src/on_nurbs/fitting_curve_2d_asdm.cpp b/surface/src/on_nurbs/fitting_curve_2d_asdm.cpp index dbdc041942c..1cf4d3f333d 100644 --- a/surface/src/on_nurbs/fitting_curve_2d_asdm.cpp +++ b/surface/src/on_nurbs/fitting_curve_2d_asdm.cpp @@ -59,12 +59,12 @@ FittingCurve2dASDM::assemble (const FittingCurve2dAPDM::Parameter ¶meter) int cp_red = m_nurbs.m_order - 2; int ncp = m_nurbs.m_cv_count - 2 * cp_red; int nCageReg = m_nurbs.m_cv_count - 2 * cp_red; - int nInt = int (m_data->interior.size ()); + int nInt = static_cast(m_data->interior.size ()); // int nCommon = m_data->common.size(); // int nClosestP = parameter.closest_point_resolution; std::vector elements = getElementVector (m_nurbs); - int nClosestP = int (elements.size ()); + int nClosestP = static_cast(elements.size ()); double wInt = 1.0; if (!m_data->interior_weight.empty ()) @@ -213,7 +213,7 @@ FittingCurve2dASDM::addCageRegularisation (double weight, unsigned &row, const s { int i = j % ncp; - if (i >= int (m_data->closest_points_error.size () - 1)) + if (i >= static_cast(m_data->closest_points_error.size () - 1)) { printf ("[FittingCurve2dASDM::addCageRegularisation] Warning, index for closest_points_error out of bounds\n"); } @@ -259,7 +259,7 @@ FittingCurve2dASDM::addCageRegularisation (double weight, unsigned &row, const s void FittingCurve2dASDM::assembleInterior (double wInt, double sigma2, double rScale, unsigned &row) { - unsigned nInt = unsigned (m_data->interior.size ()); + auto nInt = static_cast(m_data->interior.size ()); bool wFunction (true); double ds = 1.0 / (2.0 * sigma2); m_data->interior_line_start.clear (); @@ -410,7 +410,7 @@ FittingCurve2dASDM::assembleClosestPoints (const std::vector &elements, for (std::size_t i = 0; i < elements.size (); i++) { - int j = (i + 1) % int (elements.size ()); + int j = (i + 1) % static_cast(elements.size ()); double dxi = elements[j] - elements[i]; double xi = elements[i] + 0.5 * dxi; @@ -444,7 +444,7 @@ FittingCurve2dASDM::assembleClosestPoints (const std::vector &elements, if (m_data->closest_rho.size () != elements.size ()) { printf ("[FittingCurve2dASDM::assembleClosestPoints] ERROR: size does not match %d %d\n", - int (m_data->closest_rho.size ()), int (elements.size ())); + static_cast(m_data->closest_rho.size ()), static_cast(elements.size ())); } else { diff --git a/surface/src/on_nurbs/fitting_curve_2d_atdm.cpp b/surface/src/on_nurbs/fitting_curve_2d_atdm.cpp index 8c66856a47e..10fe12c2c2e 100644 --- a/surface/src/on_nurbs/fitting_curve_2d_atdm.cpp +++ b/surface/src/on_nurbs/fitting_curve_2d_atdm.cpp @@ -58,12 +58,12 @@ FittingCurve2dATDM::assemble (const FittingCurve2dAPDM::Parameter ¶meter) int cp_red = m_nurbs.m_order - 2; int ncp = m_nurbs.m_cv_count - 2 * cp_red; int nCageReg = m_nurbs.m_cv_count - 2 * cp_red; - int nInt = int (m_data->interior.size ()); + int nInt = static_cast(m_data->interior.size ()); // int nCommon = m_data->common.size(); // int nClosestP = parameter.closest_point_resolution; std::vector elements = getElementVector (m_nurbs); - int nClosestP = int (elements.size ()); + int nClosestP = static_cast(elements.size ()); double wInt = 1.0; if (!m_data->interior_weight.empty ()) @@ -189,7 +189,7 @@ FittingCurve2dATDM::addCageRegularisation (double weight, unsigned &row, const s { int i = j % ncp; - if (i >= int (m_data->closest_points_error.size () - 1)) + if (i >= static_cast(m_data->closest_points_error.size () - 1)) { printf ("[FittingCurve2dATDM::addCageRegularisation] Warning, index for closest_points_error out of bounds\n"); } @@ -235,7 +235,7 @@ FittingCurve2dATDM::addCageRegularisation (double weight, unsigned &row, const s void FittingCurve2dATDM::assembleInterior (double wInt, double sigma2, double rScale, unsigned &row) { - int nInt = int (m_data->interior.size ()); + int nInt = static_cast(m_data->interior.size ()); bool wFunction (true); double ds = 1.0 / (2.0 * sigma2); m_data->interior_line_start.clear (); @@ -250,7 +250,7 @@ FittingCurve2dATDM::assembleInterior (double wInt, double sigma2, double rScale, double param; Eigen::Vector2d pt, t, n; double error; - if (p < int (m_data->interior_param.size ())) + if (p < static_cast(m_data->interior_param.size ())) { param = findClosestElementMidPoint (m_nurbs, pcp, m_data->interior_param[p]); param = inverseMapping (m_nurbs, pcp, param, error, pt, t, rScale, in_max_steps, in_accuracy, m_quiet); @@ -279,10 +279,10 @@ FittingCurve2dATDM::assembleInterior (double wInt, double sigma2, double rScale, Eigen::Vector3d b (t (0), t (1), 0.0); Eigen::Vector3d z = a.cross (b); - if (p < int (m_data->interior_weight.size ())) + if (p < static_cast(m_data->interior_weight.size ())) wInt = m_data->interior_weight[p]; - if (p < int (m_data->interior_weight_function.size ())) + if (p < static_cast(m_data->interior_weight_function.size ())) wFunction = m_data->interior_weight_function[p]; double w (wInt); @@ -325,7 +325,7 @@ FittingCurve2dATDM::assembleClosestPoints (const std::vector &elements, for (std::size_t i = 0; i < elements.size (); i++) { - int j = i % int (elements.size ()); + int j = i % static_cast(elements.size ()); double dxi = elements[j] - elements[i]; double xi = elements[i] + 0.5 * dxi; diff --git a/surface/src/on_nurbs/fitting_curve_2d_pdm.cpp b/surface/src/on_nurbs/fitting_curve_2d_pdm.cpp index 4310a8d4b34..0bc30e45ca6 100644 --- a/surface/src/on_nurbs/fitting_curve_2d_pdm.cpp +++ b/surface/src/on_nurbs/fitting_curve_2d_pdm.cpp @@ -74,7 +74,7 @@ int FittingCurve2dPDM::findElement (double xi, const std::vector &elements) { if (xi >= elements.back ()) - return (int (elements.size ()) - 2); + return (static_cast(elements.size ()) - 2); for (std::size_t i = 0; i < elements.size () - 1; i++) { @@ -121,7 +121,7 @@ FittingCurve2dPDM::assemble (const Parameter ¶meter) int cp_red = m_nurbs.m_order - 2; int ncp = m_nurbs.m_cv_count - 2 * cp_red; int nCageReg = m_nurbs.m_cv_count - 2 * cp_red; - int nInt = int (m_data->interior.size ()); + int nInt = static_cast(m_data->interior.size ()); double wInt = 1.0; if (!m_data->interior_weight.empty ()) @@ -296,8 +296,8 @@ FittingCurve2dPDM::removeCPsOnLine (const ON_NurbsCurve &nurbs, double min_curve } int order = nurbs.Order (); - ON_NurbsCurve nurbs_opt = ON_NurbsCurve (2, false, order, int (cps.size ()) + 2 * cp_red); - nurbs_opt.MakePeriodicUniformKnotVector (1.0 / double (cps.size ())); + ON_NurbsCurve nurbs_opt = ON_NurbsCurve (2, false, order, static_cast(cps.size ()) + 2 * cp_red); + nurbs_opt.MakePeriodicUniformKnotVector (1.0 / static_cast(cps.size ())); nurbs_opt.m_knot[cp_red] = 0.0; nurbs_opt.m_knot[nurbs_opt.m_knot_capacity - cp_red - 1] = 1.0; @@ -372,7 +372,7 @@ FittingCurve2dPDM::initCPsNurbsCurve2D (int order, const vector_vec2d &cps) return nurbs; } - int ncps = int (cps.size ()) + 2 * cp_red; // +2*cp_red for smoothness and +1 for closing + int ncps = static_cast(cps.size ()) + 2 * cp_red; // +2*cp_red for smoothness and +1 for closing nurbs = ON_NurbsCurve (2, false, order, ncps); nurbs.MakePeriodicUniformKnotVector (1.0 / (ncps - order + 1)); @@ -380,7 +380,7 @@ FittingCurve2dPDM::initCPsNurbsCurve2D (int order, const vector_vec2d &cps) nurbs.SetCV (cp_red + j, ON_3dPoint (cps[j] (0), cps[j] (1), 0.0)); // close nurbs - nurbs.SetCV (cp_red + int (cps.size ()), ON_3dPoint (cps[0] (0), cps[0] (1), 0.0)); + nurbs.SetCV (cp_red + static_cast(cps.size ()), ON_3dPoint (cps[0] (0), cps[0] (1), 0.0)); // make smooth at closing point for (int j = 0; j < cp_red; j++) @@ -404,7 +404,7 @@ FittingCurve2dPDM::initNurbsCurve2D (int order, const vector_vec2d &data, int nc Eigen::Vector2d mean = NurbsTools::computeMean (data); - unsigned s = unsigned (data.size ()); + auto s = static_cast(data.size ()); double r (0.0); for (unsigned i = 0; i < s; i++) @@ -516,7 +516,7 @@ FittingCurve2dPDM::getElementVector (const ON_NurbsCurve &nurbs) void FittingCurve2dPDM::assembleInterior (double wInt, double rScale, unsigned &row) { - int nInt = int (m_data->interior.size ()); + int nInt = static_cast(m_data->interior.size ()); m_data->interior_error.clear (); m_data->interior_normals.clear (); m_data->interior_line_start.clear (); @@ -530,7 +530,7 @@ FittingCurve2dPDM::assembleInterior (double wInt, double rScale, unsigned &row) double param; Eigen::Vector2d pt, t; double error; - if (p < int (m_data->interior_param.size ())) + if (p < static_cast(m_data->interior_param.size ())) { param = findClosestElementMidPoint (m_nurbs, pcp, m_data->interior_param[p]); param = inverseMapping (m_nurbs, pcp, param, error, pt, t, rScale, in_max_steps, in_accuracy, m_quiet); @@ -545,7 +545,7 @@ FittingCurve2dPDM::assembleInterior (double wInt, double rScale, unsigned &row) m_data->interior_error.push_back (error); - if (p < int (m_data->interior_weight.size ())) + if (p < static_cast(m_data->interior_weight.size ())) wInt = m_data->interior_weight[p]; m_data->interior_line_start.push_back (pcp); diff --git a/surface/src/on_nurbs/fitting_curve_2d_sdm.cpp b/surface/src/on_nurbs/fitting_curve_2d_sdm.cpp index a08b6faece8..60e109f549b 100644 --- a/surface/src/on_nurbs/fitting_curve_2d_sdm.cpp +++ b/surface/src/on_nurbs/fitting_curve_2d_sdm.cpp @@ -59,7 +59,7 @@ FittingCurve2dSDM::assemble (const FittingCurve2dPDM::Parameter ¶meter) int cp_red = m_nurbs.m_order - 2; int ncp = m_nurbs.m_cv_count - 2 * cp_red; int nCageReg = m_nurbs.m_cv_count - 2 * cp_red; - int nInt = int (m_data->interior.size ()); + int nInt = static_cast(m_data->interior.size ()); double wInt = 1.0; if (!m_data->interior_weight.empty ()) @@ -211,7 +211,7 @@ FittingCurve2dSDM::addCageRegularisation (double weight, unsigned &row) void FittingCurve2dSDM::assembleInterior (double wInt, double rScale, unsigned &row) { - unsigned nInt = int (m_data->interior.size ()); + unsigned nInt = static_cast(m_data->interior.size ()); m_data->interior_line_start.clear (); m_data->interior_line_end.clear (); m_data->interior_error.clear (); diff --git a/surface/src/on_nurbs/fitting_curve_2d_tdm.cpp b/surface/src/on_nurbs/fitting_curve_2d_tdm.cpp index e7b04cf3c11..88478b19fc0 100644 --- a/surface/src/on_nurbs/fitting_curve_2d_tdm.cpp +++ b/surface/src/on_nurbs/fitting_curve_2d_tdm.cpp @@ -57,7 +57,7 @@ FittingCurve2dTDM::assemble (const FittingCurve2dPDM::Parameter ¶meter) int cp_red = m_nurbs.m_order - 2; int ncp = m_nurbs.m_cv_count - 2 * cp_red; int nCageReg = m_nurbs.m_cv_count - 2 * cp_red; - int nInt = int (m_data->interior.size ()); + int nInt = static_cast(m_data->interior.size ()); double wInt = 1.0; if (!m_data->interior_weight.empty ()) @@ -189,7 +189,7 @@ FittingCurve2dTDM::addCageRegularisation (double weight, unsigned &row) void FittingCurve2dTDM::assembleInterior (double wInt, double rScale, unsigned &row) { - int nInt = int (m_data->interior.size ()); + int nInt = static_cast(m_data->interior.size ()); m_data->interior_line_start.clear (); m_data->interior_line_end.clear (); m_data->interior_error.clear (); @@ -202,7 +202,7 @@ FittingCurve2dTDM::assembleInterior (double wInt, double rScale, unsigned &row) double param; Eigen::Vector2d pt, t, n; double error; - if (p < int (m_data->interior_param.size ())) + if (p < static_cast(m_data->interior_param.size ())) { param = findClosestElementMidPoint (m_nurbs, pcp, m_data->interior_param[p]); param = inverseMapping (m_nurbs, pcp, param, error, pt, t, rScale, in_max_steps, in_accuracy, m_quiet); @@ -227,7 +227,7 @@ FittingCurve2dTDM::assembleInterior (double wInt, double rScale, unsigned &row) n (1) = pointAndTangents[5]; n.normalize (); - if (p < int (m_data->interior_weight.size ())) + if (p < static_cast(m_data->interior_weight.size ())) wInt = m_data->interior_weight[p]; addPointConstraint (m_data->interior_param[p], m_data->interior[p], n, wInt, row); diff --git a/surface/src/on_nurbs/fitting_curve_pdm.cpp b/surface/src/on_nurbs/fitting_curve_pdm.cpp index 95ec19b1538..67e993ada8e 100644 --- a/surface/src/on_nurbs/fitting_curve_pdm.cpp +++ b/surface/src/on_nurbs/fitting_curve_pdm.cpp @@ -74,7 +74,7 @@ int FittingCurve::findElement (double xi, const std::vector &elements) { if (xi >= elements.back ()) - return (int (elements.size ()) - 2); + return (static_cast(elements.size ()) - 2); for (std::size_t i = 0; i < elements.size () - 1; i++) { @@ -109,7 +109,7 @@ FittingCurve::assemble (const Parameter ¶meter) int cp_red = m_nurbs.m_order - 2; int ncp = m_nurbs.m_cv_count - 2 * cp_red; int nCageReg = m_nurbs.m_cv_count - 2 * cp_red; - int nInt = int (m_data->interior.size ()); + int nInt = static_cast(m_data->interior.size ()); int nrows = nInt + nCageReg; @@ -213,7 +213,7 @@ FittingCurve::initNurbsCurve2D (int order, const vector_vec2d &data) Eigen::Vector2d mean = NurbsTools::computeMean (data); - unsigned s = unsigned (data.size ()); + auto s = static_cast(data.size ()); double r (0.0); for (unsigned i = 0; i < s; i++) @@ -252,7 +252,7 @@ FittingCurve::initNurbsCurvePCA (int order, const vector_vec3d &data, int ncps, Eigen::Matrix3d eigenvectors; Eigen::Vector3d eigenvalues; - unsigned s = unsigned (data.size ()); + auto s = static_cast(data.size ()); NurbsTools::pca (data, mean, eigenvectors, eigenvalues); @@ -312,7 +312,7 @@ FittingCurve::getElementVector (const ON_NurbsCurve &nurbs) void FittingCurve::assembleInterior (double wInt, unsigned &row) { - int nInt = int (m_data->interior.size ()); + int nInt = static_cast(m_data->interior.size ()); m_data->interior_line_start.clear (); m_data->interior_line_end.clear (); m_data->interior_error.clear (); @@ -325,7 +325,7 @@ FittingCurve::assembleInterior (double wInt, unsigned &row) double param; Eigen::Vector3d pt, t; double error; - if (p < int (m_data->interior_param.size ())) + if (p < static_cast(m_data->interior_param.size ())) { param = inverseMapping (m_nurbs, pcp, m_data->interior_param[p], error, pt, t, in_max_steps, in_accuracy); m_data->interior_param[p] = param; diff --git a/surface/src/on_nurbs/fitting_cylinder_pdm.cpp b/surface/src/on_nurbs/fitting_cylinder_pdm.cpp index 5f3b970df9a..bebcc2dcedc 100644 --- a/surface/src/on_nurbs/fitting_cylinder_pdm.cpp +++ b/surface/src/on_nurbs/fitting_cylinder_pdm.cpp @@ -136,7 +136,7 @@ FittingCylinder::assemble (double smoothness) { int cp_red = (m_nurbs.m_order[1] - 2); int ncp = m_nurbs.m_cv_count[0] * (m_nurbs.m_cv_count[1] - 2 * cp_red); - int nInt = int (m_data->interior.size ()); + int nInt = static_cast(m_data->interior.size ()); int nCageRegInt = (m_nurbs.m_cv_count[0] - 2) * (m_nurbs.m_cv_count[1] - 2 * cp_red); int nCageRegBnd = 2 * (m_nurbs.m_cv_count[1] - 2 * cp_red); @@ -224,7 +224,7 @@ FittingCylinder::initNurbsPCACylinder (int order, NurbsDataSurface *data) Eigen::Matrix3d eigenvectors; Eigen::Vector3d eigenvalues; - unsigned s = unsigned (data->interior.size ()); + auto s = static_cast(data->interior.size ()); NurbsTools::pca (data->interior, mean, eigenvectors, eigenvalues); @@ -289,7 +289,7 @@ FittingCylinder::initNurbsCylinderWithAxes (int order, NurbsDataSurface *data, E { Eigen::Vector3d mean; - unsigned s = unsigned (data->interior.size ()); + auto s = static_cast(data->interior.size ()); mean = NurbsTools::computeMean (data->interior); data->mean = mean; @@ -410,7 +410,7 @@ FittingCylinder::assembleInterior (double wInt, unsigned &row) m_data->interior_line_end.clear (); m_data->interior_error.clear (); m_data->interior_normals.clear (); - unsigned nInt = unsigned (m_data->interior.size ()); + auto nInt = static_cast(m_data->interior.size ()); for (unsigned p = 0; p < nInt; p++) { Vector3d pcp; diff --git a/surface/src/on_nurbs/fitting_sphere_pdm.cpp b/surface/src/on_nurbs/fitting_sphere_pdm.cpp index 296df348d4c..23ddcf9214e 100644 --- a/surface/src/on_nurbs/fitting_sphere_pdm.cpp +++ b/surface/src/on_nurbs/fitting_sphere_pdm.cpp @@ -83,7 +83,7 @@ FittingSphere::assemble (double smoothness) { int cp_red = (m_nurbs.m_order[1] - 2); int ncp = m_nurbs.m_cv_count[0] * (m_nurbs.m_cv_count[1] - 2 * cp_red); - int nInt = int (m_data->interior.size ()); + int nInt = static_cast(m_data->interior.size ()); int nCageRegInt = (m_nurbs.m_cv_count[0] - 2) * (m_nurbs.m_cv_count[1] - 2 * cp_red); int nCageRegBnd = 2 * (m_nurbs.m_cv_count[1] - 2 * cp_red); @@ -311,7 +311,7 @@ FittingSphere::assembleInterior (double wInt, unsigned &row) m_data->interior_line_end.clear (); m_data->interior_error.clear (); m_data->interior_normals.clear (); - unsigned nInt = unsigned (m_data->interior.size ()); + auto nInt = static_cast(m_data->interior.size ()); for (unsigned p = 0; p < nInt; p++) { Vector3d pcp; diff --git a/surface/src/on_nurbs/fitting_surface_im.cpp b/surface/src/on_nurbs/fitting_surface_im.cpp index f86d0d653f1..a2d0b2537c3 100644 --- a/surface/src/on_nurbs/fitting_surface_im.cpp +++ b/surface/src/on_nurbs/fitting_surface_im.cpp @@ -53,7 +53,7 @@ FittingSurfaceIM::computeMean () const u.y = 0.0; u.z = 0.0; - double ds = 1.0 / double (m_indices.size ()); + double ds = 1.0 / static_cast(m_indices.size ()); const pcl::PointCloud &cloud_ref = *m_cloud; for (const auto &index : m_indices) @@ -65,9 +65,9 @@ FittingSurfaceIM::computeMean () const if (std::isnan (point.x) || std::isnan (point.y) || std::isnan (point.z)) continue; - u.x += point.x * float (ds); - u.y += point.y * float (ds); - u.z += point.z * float (ds); + u.x += point.x * static_cast(ds); + u.y += point.y * static_cast(ds); + u.z += point.z * static_cast(ds); } return u; @@ -181,19 +181,19 @@ FittingSurfaceIM::refine () Eigen::Vector2d bbx (m_nurbs.Knot (0, 0), m_nurbs.Knot (0, m_nurbs.KnotCount (0) - 1)); Eigen::Vector2d bby (m_nurbs.Knot (1, 0), m_nurbs.Knot (1, m_nurbs.KnotCount (1) - 1)); - int dx = int (bbx (1) - bbx (0)); - int dy = int (bby (1) - bby (0)); - double ddx = double (dx) / (m_nurbs.CVCount (0) - 1); - double ddy = double (dy) / (m_nurbs.CVCount (1) - 1); + int dx = static_cast(bbx (1) - bbx (0)); + int dy = static_cast(bby (1) - bby (0)); + double ddx = static_cast(dx) / (m_nurbs.CVCount (0) - 1); + double ddy = static_cast(dy) / (m_nurbs.CVCount (1) - 1); m_cps_px.clear (); for (int i = 0; i < m_nurbs.CVCount (0); i++) { for (int j = 0; j < m_nurbs.CVCount (1); j++) { - int px = int (bbx (0) + ddx * i); - int py = int (bby (0) + ddy * j); - m_cps_px.push_back (Eigen::Vector2i (px, py)); + int px = static_cast(bbx (0) + ddx * i); + int py = static_cast(bby (0) + ddy * j); + m_cps_px.emplace_back(px, py); } } } @@ -244,10 +244,10 @@ FittingSurfaceIM::initSurface (int order, const Eigen::Vector4d &bb) { for (int j = 0; j < m_nurbs.Order (1); j++) { - int px = int (m_bb (0) + ddx * i + 0.5); - int py = int (m_bb (2) + ddy * j + 0.5); + int px = static_cast(m_bb (0) + ddx * i + 0.5); + int py = static_cast(m_bb (2) + ddy * j + 0.5); - m_cps_px.push_back (Eigen::Vector2i (px, py)); + m_cps_px.emplace_back(px, py); ON_3dPoint p; p.x = pt.z * (px - m_intrinsic (0, 2)) / m_intrinsic (0, 0); @@ -265,7 +265,7 @@ FittingSurfaceIM::initSurface (int order, const Eigen::Vector4d &bb) void FittingSurfaceIM::assemble (bool inverse_mapping) { - int nInt = int (m_indices.size ()); + int nInt = static_cast(m_indices.size ()); int nCageReg = (m_nurbs.m_cv_count[0] - 2) * (m_nurbs.m_cv_count[1] - 2); int nCageRegBnd = 2 * (m_nurbs.m_cv_count[0] - 1) + 2 * (m_nurbs.m_cv_count[1] - 1); @@ -296,8 +296,8 @@ FittingSurfaceIM::assemble (bool inverse_mapping) Eigen::Vector3d p, tu, tv; Eigen::Vector2d params1 (params (0), params (1)); params1 = inverseMapping (m_nurbs, point, params1, error, p, tu, tv, 200, 1e-6, true); - params (0) = int (params1 (0)); - params (1) = int (params1 (1)); + params (0) = static_cast(params1 (0)); + params (1) = static_cast(params1 (1)); } addPointConstraint (params, pt.z, 1.0, row); diff --git a/surface/src/on_nurbs/fitting_surface_pdm.cpp b/surface/src/on_nurbs/fitting_surface_pdm.cpp index 0fd07201d25..c57a20f22c6 100644 --- a/surface/src/on_nurbs/fitting_surface_pdm.cpp +++ b/surface/src/on_nurbs/fitting_surface_pdm.cpp @@ -282,7 +282,7 @@ FittingSurface::assembleInterior (double wInt, unsigned &row) m_data->interior_line_end.clear (); m_data->interior_error.clear (); m_data->interior_normals.clear (); - unsigned nInt = static_cast (m_data->interior.size ()); + auto nInt = static_cast (m_data->interior.size ()); for (unsigned p = 0; p < nInt; p++) { Vector3d &pcp = m_data->interior[p]; @@ -326,7 +326,7 @@ FittingSurface::assembleBoundary (double wBnd, unsigned &row) m_data->boundary_line_end.clear (); m_data->boundary_error.clear (); m_data->boundary_normals.clear (); - unsigned nBnd = static_cast (m_data->boundary.size ()); + auto nBnd = static_cast (m_data->boundary.size ()); for (unsigned p = 0; p < nBnd; p++) { Vector3d &pcp = m_data->boundary[p]; @@ -407,7 +407,7 @@ FittingSurface::initNurbsPCA (int order, NurbsDataSurface *m_data, Eigen::Vector Eigen::Matrix3d eigenvectors; Eigen::Vector3d eigenvalues; - unsigned s = static_cast (m_data->interior.size ()); + auto s = static_cast (m_data->interior.size ()); NurbsTools::pca (m_data->interior, mean, eigenvectors, eigenvalues); @@ -455,7 +455,7 @@ FittingSurface::initNurbsPCABoundingBox (int order, NurbsDataSurface *m_data, Ei Eigen::Matrix3d eigenvectors; Eigen::Vector3d eigenvalues; - unsigned s = static_cast (m_data->interior.size ()); + auto s = static_cast (m_data->interior.size ()); m_data->interior_param.clear (); NurbsTools::pca (m_data->interior, mean, eigenvectors, eigenvalues); @@ -479,7 +479,7 @@ FittingSurface::initNurbsPCABoundingBox (int order, NurbsDataSurface *m_data, Ei for (unsigned i = 0; i < s; i++) { Eigen::Vector3d p (eigenvectors_inv * (m_data->interior[i] - mean)); - m_data->interior_param.push_back (Eigen::Vector2d (p (0), p (1))); + m_data->interior_param.emplace_back(p (0), p (1)); if (p (0) > v_max (0)) v_max (0) = p (0); diff --git a/surface/src/on_nurbs/fitting_surface_tdm.cpp b/surface/src/on_nurbs/fitting_surface_tdm.cpp index fd71feb60de..fe2df537472 100644 --- a/surface/src/on_nurbs/fitting_surface_tdm.cpp +++ b/surface/src/on_nurbs/fitting_surface_tdm.cpp @@ -145,7 +145,7 @@ FittingSurfaceTDM::assembleInterior (double wInt, double wTangent, unsigned &row m_data->interior_line_end.clear (); m_data->interior_error.clear (); m_data->interior_normals.clear (); - unsigned nInt = static_cast (m_data->interior.size ()); + auto nInt = static_cast (m_data->interior.size ()); for (unsigned p = 0; p < nInt; p++) { Vector3d &pcp = m_data->interior[p]; @@ -190,7 +190,7 @@ FittingSurfaceTDM::assembleBoundary (double wBnd, double wTangent, unsigned &row m_data->boundary_line_end.clear (); m_data->boundary_error.clear (); m_data->boundary_normals.clear (); - unsigned nBnd = static_cast (m_data->boundary.size ()); + auto nBnd = static_cast (m_data->boundary.size ()); for (unsigned p = 0; p < nBnd; p++) { Vector3d &pcp = m_data->boundary[p]; diff --git a/surface/src/on_nurbs/global_optimization_pdm.cpp b/surface/src/on_nurbs/global_optimization_pdm.cpp index 079dc0726a1..d3875524ab8 100644 --- a/surface/src/on_nurbs/global_optimization_pdm.cpp +++ b/surface/src/on_nurbs/global_optimization_pdm.cpp @@ -78,7 +78,7 @@ GlobalOptimization::assemble (Parameter params) { // determine number of rows of matrix m_ncols = 0; - unsigned nnurbs = static_cast (m_nurbs.size ()); + auto nnurbs = static_cast (m_nurbs.size ()); unsigned nInt (0), nBnd (0), nCageRegInt (0), nCageRegBnd (0), nCommonBnd (0), nCommonPar (0); for (unsigned i = 0; i < nnurbs; i++) { @@ -413,7 +413,7 @@ GlobalOptimization::assembleBoundaryPoints (unsigned id, int ncps, double weight ON_NurbsSurface *nurbs = m_nurbs[id]; NurbsDataSurface *data = m_data[id]; - unsigned nBnd = static_cast (m_data[id]->boundary.size ()); + auto nBnd = static_cast (m_data[id]->boundary.size ()); // interior points should lie on surface data->boundary_line_start.clear (); diff --git a/surface/src/on_nurbs/global_optimization_tdm.cpp b/surface/src/on_nurbs/global_optimization_tdm.cpp index fa9bd21606d..a0ae969fbae 100644 --- a/surface/src/on_nurbs/global_optimization_tdm.cpp +++ b/surface/src/on_nurbs/global_optimization_tdm.cpp @@ -57,7 +57,7 @@ GlobalOptimizationTDM::assemble (Parameter params) { // determine number of rows of matrix m_ncols = 0; - unsigned nnurbs = static_cast (m_nurbs.size ()); + auto nnurbs = static_cast (m_nurbs.size ()); unsigned nInt (0), nBnd (0), nCageRegInt (0), nCageRegBnd (0), nCommonBnd (0); for (unsigned i = 0; i < nnurbs; i++) { @@ -127,7 +127,7 @@ GlobalOptimizationTDM::assemble (ParameterTDM params) { // determine number of rows of matrix m_ncols = 0; - unsigned nnurbs = static_cast (m_nurbs.size ()); + auto nnurbs = static_cast (m_nurbs.size ()); unsigned nInt (0), nBnd (0), nCageRegInt (0), nCageRegBnd (0), nCommonBnd (0), nCommonPar (0); for (unsigned i = 0; i < nnurbs; i++) { @@ -453,7 +453,7 @@ GlobalOptimizationTDM::assembleInteriorPoints (unsigned id, int ncps, double wei ON_NurbsSurface *nurbs = m_nurbs[id]; NurbsDataSurface *data = m_data[id]; - unsigned nInt = static_cast (m_data[id]->interior.size ()); + auto nInt = static_cast (m_data[id]->interior.size ()); // interior points should lie on surface data->interior_line_start.clear (); @@ -506,7 +506,7 @@ GlobalOptimizationTDM::assembleInteriorPointsTD (unsigned id, int ncps, double w ON_NurbsSurface *nurbs = m_nurbs[id]; NurbsDataSurface *data = m_data[id]; - unsigned nInt = static_cast (m_data[id]->interior.size ()); + auto nInt = static_cast (m_data[id]->interior.size ()); // interior points should lie on surface data->interior_line_start.clear (); @@ -560,7 +560,7 @@ GlobalOptimizationTDM::assembleBoundaryPoints (unsigned id, int ncps, double wei ON_NurbsSurface *nurbs = m_nurbs[id]; NurbsDataSurface *data = m_data[id]; - unsigned nBnd = static_cast (m_data[id]->boundary.size ()); + auto nBnd = static_cast (m_data[id]->boundary.size ()); // interior points should lie on surface data->boundary_line_start.clear (); diff --git a/surface/src/on_nurbs/nurbs_tools.cpp b/surface/src/on_nurbs/nurbs_tools.cpp index b429883ba4a..1da9b42d75b 100644 --- a/surface/src/on_nurbs/nurbs_tools.cpp +++ b/surface/src/on_nurbs/nurbs_tools.cpp @@ -57,12 +57,12 @@ NurbsTools::downsample_random (const vector_vec3d &data1, vector_vec3d &data2, u return; } - unsigned s = unsigned (data1.size ()); + auto s = static_cast(data1.size ()); data2.clear (); for (unsigned i = 0; i < size; i++) { - unsigned rnd = unsigned (s * (double (rand ()) / RAND_MAX)); + auto rnd = static_cast(s * (static_cast(rand ()) / RAND_MAX)); data2.push_back (data1[rnd]); } } @@ -73,13 +73,13 @@ NurbsTools::downsample_random (vector_vec3d &data, unsigned size) if (data.size () <= size && size > 0) return; - unsigned s = unsigned (data.size ()); + auto s = static_cast(data.size ()); vector_vec3d data_tmp; for (unsigned i = 0; i < size; i++) { - unsigned rnd = unsigned ((s - 1) * (double (rand ()) / RAND_MAX)); + auto rnd = static_cast((s - 1) * (static_cast(rand ()) / RAND_MAX)); data_tmp.push_back (data[rnd]); } @@ -168,7 +168,7 @@ NurbsTools::computeMean (const vector_vec3d &data) { Eigen::Vector3d u (0.0, 0.0, 0.0); - unsigned s = unsigned (data.size ()); + auto s = static_cast(data.size ()); double ds = 1.0 / s; for (unsigned i = 0; i < s; i++) @@ -183,7 +183,7 @@ NurbsTools::computeMean (const vector_vec2d &data) Eigen::Vector2d u (0.0, 0.0); std::size_t s = data.size (); - double ds = 1.0 / double (s); + double ds = 1.0 / static_cast(s); for (std::size_t i = 0; i < s; i++) u += (data[i] * ds); @@ -197,7 +197,7 @@ NurbsTools::computeVariance (const Eigen::Vector3d &mean, const vector_vec3d &da Eigen::Vector3d var (0.0, 0.0, 0.0); std::size_t s = data.size (); - double ds = 1.0 / double (s); + double ds = 1.0 / static_cast(s); for (std::size_t i = 0; i < s; i++) { @@ -214,7 +214,7 @@ NurbsTools::computeVariance (const Eigen::Vector2d &mean, const vector_vec2d &da Eigen::Vector2d var (0.0, 0.0); std::size_t s = data.size (); - double ds = 1.0 / double (s); + double ds = 1.0 / static_cast(s); for (std::size_t i = 0; i < s; i++) { @@ -306,7 +306,7 @@ NurbsTools::pca (const vector_vec3d &data, Eigen::Vector3d &mean, Eigen::Matrix3 mean = computeMean (data); - unsigned s = unsigned (data.size ()); + auto s = static_cast(data.size ()); Eigen::MatrixXd Q (3, s); @@ -344,7 +344,7 @@ NurbsTools::pca (const vector_vec2d &data, Eigen::Vector2d &mean, Eigen::Matrix2 mean = computeMean (data); - unsigned s = unsigned (data.size ()); + auto s = static_cast(data.size ()); Eigen::MatrixXd Q (2, s); diff --git a/surface/src/on_nurbs/sequential_fitter.cpp b/surface/src/on_nurbs/sequential_fitter.cpp index 9cdb6bf2521..e9eeeb5d6f2 100644 --- a/surface/src/on_nurbs/sequential_fitter.cpp +++ b/surface/src/on_nurbs/sequential_fitter.cpp @@ -385,7 +385,7 @@ SequentialFitter::compute_boundary (const ON_NurbsSurface &nurbs) return nurbs; } - FittingSurface *fitting = new FittingSurface (&m_data, nurbs); + auto *fitting = new FittingSurface (&m_data, nurbs); this->compute_boundary (fitting); @@ -407,7 +407,7 @@ SequentialFitter::compute_interior (const ON_NurbsSurface &nurbs) printf ("[SequentialFitter::compute_interior] Warning, no interior points given: setInterior()\n"); return nurbs; } - FittingSurface *fitting = new FittingSurface (&m_data, nurbs); + auto *fitting = new FittingSurface (&m_data, nurbs); this->compute_interior (fitting); @@ -475,12 +475,12 @@ SequentialFitter::getClosestPointOnNurbs ( ON_NurbsSurface SequentialFitter::grow (float max_dist, float max_angle, unsigned min_length, unsigned max_length) { - unsigned num_bnd = unsigned (this->m_data.boundary_param.size ()); + auto num_bnd = static_cast(this->m_data.boundary_param.size ()); if (num_bnd == 0) throw std::runtime_error ("[SequentialFitter::grow] No boundary given."); - if (unsigned (this->m_data.boundary.size ()) != num_bnd) + if (static_cast(this->m_data.boundary.size ()) != num_bnd) { printf ("[SequentialFitter::grow] %zu %u\n", this->m_data.boundary.size (), num_bnd); throw std::runtime_error ("[SequentialFitter::grow] size of boundary and boundary parameters do not match."); @@ -544,14 +544,14 @@ SequentialFitter::grow (float max_dist, float max_angle, unsigned min_length, un pcl::PointXYZRGB point = m_cloud->at (this->m_boundary_indices->indices[i]); for (unsigned j = min_length; j < max_length; j++) { - int col = int (ri (0) + bni (0) * j); - int row = int (ri (1) + bni (1) * j); + int col = static_cast(ri (0) + bni (0) * j); + int row = static_cast(ri (1) + bni (1) * j); - if (row >= int (m_cloud->height) || row < 0) + if (row >= static_cast(m_cloud->height) || row < 0) { break; } - if (col >= int (m_cloud->width) || col < 0) + if (col >= static_cast(m_cloud->width) || col < 0) { break; } @@ -590,7 +590,7 @@ SequentialFitter::grow (float max_dist, float max_angle, unsigned min_length, un compute_interior (m_nurbs); double int_err (0.0); - double div_err = 1.0 / double (m_data.interior_error.size ()); + double div_err = 1.0 / static_cast(m_data.interior_error.size ()); for (const double &i : m_data.interior_error) { int_err += (i * div_err); @@ -615,7 +615,7 @@ SequentialFitter::PCL2ON (pcl::PointCloud::Ptr &pcl_cloud, con if (!std::isnan (pt.x) && !std::isnan (pt.y) && !std::isnan (pt.z)) { - on_cloud.push_back (Eigen::Vector3d (pt.x, pt.y, pt.z)); + on_cloud.emplace_back(pt.x, pt.y, pt.z); numPoints++; } diff --git a/surface/src/on_nurbs/sparse_mat.cpp b/surface/src/on_nurbs/sparse_mat.cpp index 3c429b04cea..6bf796dcd60 100644 --- a/surface/src/on_nurbs/sparse_mat.cpp +++ b/surface/src/on_nurbs/sparse_mat.cpp @@ -196,7 +196,7 @@ SparseMat::nonzeros () it_row = m_mat.begin (); while (it_row != m_mat.end ()) { - s += int (it_row->second.size ()); + s += static_cast(it_row->second.size ()); ++it_row; } diff --git a/surface/src/on_nurbs/triangulation.cpp b/surface/src/on_nurbs/triangulation.cpp index 86e31e8ddb8..609ef7a62f0 100644 --- a/surface/src/on_nurbs/triangulation.cpp +++ b/surface/src/on_nurbs/triangulation.cpp @@ -77,15 +77,15 @@ Triangulation::createVertices (pcl::PointCloud::Ptr &cloud, float float height, unsigned segX, unsigned segY) { pcl::PointXYZ v; - float dx = width / float (segX); - float dy = height / float (segY); + float dx = width / static_cast(segX); + float dy = height / static_cast(segY); for (unsigned j = 0; j <= segY; j++) { for (unsigned i = 0; i <= segX; i++) { - v.x = x0 + float (i) * dx; - v.y = y0 + float (j) * dy; + v.x = x0 + static_cast(i) * dx; + v.y = y0 + static_cast(j) * dy; v.z = z0; cloud->push_back (v); } @@ -181,7 +181,7 @@ Triangulation::convertSurface2PolygonMesh (const ON_NurbsSurface &nurbs, Polygon pcl::PointCloud::Ptr cloud (new pcl::PointCloud); mesh.polygons.clear (); - createVertices (cloud, float (x0), float (y0), 0.0f, float (w), float (h), resolution, resolution); + createVertices (cloud, static_cast(x0), static_cast(y0), 0.0f, static_cast(w), static_cast(h), resolution, resolution); createIndices (mesh.polygons, 0, resolution, resolution); for (auto &v : *cloud) @@ -189,9 +189,9 @@ Triangulation::convertSurface2PolygonMesh (const ON_NurbsSurface &nurbs, Polygon double point[9]; nurbs.Evaluate (v.x, v.y, 1, 3, point); - v.x = float (point[0]); - v.y = float (point[1]); - v.z = float (point[2]); + v.x = static_cast(point[0]); + v.y = static_cast(point[1]); + v.z = static_cast(point[2]); } toPCLPointCloud2 (*cloud, mesh.cloud); @@ -219,7 +219,7 @@ Triangulation::convertTrimmedSurface2PolygonMesh (const ON_NurbsSurface &nurbs, pcl::PointCloud::Ptr cloud (new pcl::PointCloud); std::vector polygons; - createVertices (cloud, float (x0), float (y0), 0.0f, float (w), float (h), resolution, resolution); + createVertices (cloud, static_cast(x0), static_cast(y0), 0.0f, static_cast(w), static_cast(h), resolution, resolution); createIndices (polygons, 0, resolution, resolution); vector_vec2d points (cloud->size (), Eigen::Vector2d ()); @@ -290,8 +290,8 @@ Triangulation::convertTrimmedSurface2PolygonMesh (const ON_NurbsSurface &nurbs, { pcl::PointXYZ &v = cloud->at (out_idx[i]); Eigen::Vector2d &pc = out_pc[i]; - v.x = float (pc (0)); - v.y = float (pc (1)); + v.x = static_cast(pc (0)); + v.y = static_cast(pc (1)); } for (auto &v : *cloud) @@ -299,9 +299,9 @@ Triangulation::convertTrimmedSurface2PolygonMesh (const ON_NurbsSurface &nurbs, double point[3]; nurbs.Evaluate (v.x, v.y, 0, 3, point); - v.x = float (point[0]); - v.y = float (point[1]); - v.z = float (point[2]); + v.x = static_cast(point[0]); + v.y = static_cast(point[1]); + v.z = static_cast(point[2]); // tu[0] = point[3]; // tu[1] = point[4]; // tu[2] = point[5]; @@ -338,7 +338,7 @@ Triangulation::convertTrimmedSurface2PolygonMesh (const ON_NurbsSurface &nurbs, pcl::PointCloud::Ptr cloud (new pcl::PointCloud); std::vector polygons; - createVertices (cloud, float (x0), float (y0), 0.0f, float (w), float (h), resolution, resolution); + createVertices (cloud, static_cast(x0), static_cast(y0), 0.0f, static_cast(w), static_cast(h), resolution, resolution); createIndices (polygons, 0, resolution, resolution); vector_vec2d points (cloud->size (), Eigen::Vector2d ()); @@ -375,8 +375,8 @@ Triangulation::convertTrimmedSurface2PolygonMesh (const ON_NurbsSurface &nurbs, params[i] = param; pt_is_in[i] = (z (2) >= 0.0); - end.push_back (Eigen::Vector3d (pc (0), pc (1), 0.0)); - start.push_back (Eigen::Vector3d (vp (0), vp (1), 0.0)); + end.emplace_back(pc (0), pc (1), 0.0); + start.emplace_back(vp (0), vp (1), 0.0); } for (const auto &poly : polygons) @@ -414,8 +414,8 @@ Triangulation::convertTrimmedSurface2PolygonMesh (const ON_NurbsSurface &nurbs, { pcl::PointXYZ &v = cloud->at (out_idx[i]); Eigen::Vector2d &pc = out_pc[i]; - v.x = float (pc (0)); - v.y = float (pc (1)); + v.x = static_cast(pc (0)); + v.y = static_cast(pc (1)); } for (auto &v : *cloud) @@ -423,9 +423,9 @@ Triangulation::convertTrimmedSurface2PolygonMesh (const ON_NurbsSurface &nurbs, double point[3]; nurbs.Evaluate (v.x, v.y, 0, 3, point); - v.x = float (point[0]); - v.y = float (point[1]); - v.z = float (point[2]); + v.x = static_cast(point[0]); + v.y = static_cast(point[1]); + v.z = static_cast(point[2]); } for (std::size_t i = 0; i < start.size (); i++) @@ -469,7 +469,7 @@ Triangulation::convertSurface2Vertices (const ON_NurbsSurface &nurbs, pcl::Point double y1 = nurbs.Knot (1, nurbs.KnotCount (1) - 1); double h = y1 - y0; - createVertices (cloud, float (x0), float (y0), 0.0f, float (w), float (h), resolution, resolution); + createVertices (cloud, static_cast(x0), static_cast(y0), 0.0f, static_cast(w), static_cast(h), resolution, resolution); createIndices (vertices, 0, resolution, resolution); for (auto &v : *cloud) @@ -564,9 +564,9 @@ Triangulation::convertCurve2PointCloud (const ON_NurbsCurve &curve, const ON_Nur double pp[3]; curve.Evaluate (xi, 0, 2, pp); surf.Evaluate (pp[0], pp[1], 0, 3, p); - pt.x = float (p[0]); - pt.y = float (p[1]); - pt.z = float (p[2]); + pt.x = static_cast(p[0]); + pt.y = static_cast(p[1]); + pt.z = static_cast(p[2]); pt.r = 255; pt.g = 0; pt.b = 0; From 771fe4af9e057f453ef2ca87d4ffc1588023288d Mon Sep 17 00:00:00 2001 From: Norm Evangelista Date: Mon, 17 Nov 2025 16:51:26 -0800 Subject: [PATCH 2/8] Relocated forward decls to proper namespaces --- .../pcl/visualization/vtk/vtkFixedXRenderWindowInteractor.h | 3 ++- visualization/include/pcl/visualization/window.h | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/visualization/include/pcl/visualization/vtk/vtkFixedXRenderWindowInteractor.h b/visualization/include/pcl/visualization/vtk/vtkFixedXRenderWindowInteractor.h index 54bac8e7396..1065991b8af 100644 --- a/visualization/include/pcl/visualization/vtk/vtkFixedXRenderWindowInteractor.h +++ b/visualization/include/pcl/visualization/vtk/vtkFixedXRenderWindowInteractor.h @@ -36,8 +36,9 @@ #include "vtkRenderingUIModule.h" // For export macro #include // Needed for X types in the public interface -namespace pcl { class vtkCallbackCommand; + +namespace pcl { class vtkXRenderWindowInteractorInternals; class VTKRENDERINGUI_EXPORT vtkXRenderWindowInteractor : public vtkRenderWindowInteractor diff --git a/visualization/include/pcl/visualization/window.h b/visualization/include/pcl/visualization/window.h index 7db1e4331ed..65f82178905 100644 --- a/visualization/include/pcl/visualization/window.h +++ b/visualization/include/pcl/visualization/window.h @@ -47,9 +47,8 @@ template class vtkSmartPointer; class vtkObject; class vtkRenderWindow; class vtkRenderWindowInteractor; -class vtkCallbackCommand; class vtkRendererCollection; -class PCLVisualizerInteractorStyle; +class vtkCallbackCommand; namespace pcl { @@ -57,6 +56,7 @@ namespace pcl { class MouseEvent; class KeyboardEvent; + class PCLVisualizerInteractorStyle; class PCL_EXPORTS Window { From ad6a0a4415897a7dbe2a8242ddbc3e48b7de6668 Mon Sep 17 00:00:00 2001 From: Norm Evangelista Date: Wed, 19 Nov 2025 15:47:33 -0800 Subject: [PATCH 3/8] Enabled -DBUILD_surface_on_nurbs=ON in clang-tidy GitHub action --- .github/workflows/clang-tidy.yml | 1 + .../apps/3d_rec_framework/pc_source/source.h | 2 +- .../impl/global_nn_recognizer_crh.hpp | 6 +-- .../impl/global_nn_recognizer_cvfh.hpp | 6 +-- .../pipeline/impl/local_recognizer.hpp | 8 +-- .../pipeline/local_recognizer.h | 2 +- .../tools/openni_frame_source.h | 4 +- .../utils/persistence_utils.h | 2 +- .../tools/local_recognition_mian_dataset.cpp | 2 +- .../src/tools/openni_frame_source.cpp | 2 +- .../pcl/apps/cloud_composer/commands.h | 6 +-- .../apps/cloud_composer/impl/cloud_item.hpp | 2 +- .../cloud_composer/impl/merge_selection.hpp | 4 +- .../cloud_composer/impl/transform_clouds.hpp | 2 +- .../items/cloud_composer_item.h | 2 +- .../apps/cloud_composer/items/cloud_item.h | 6 +-- .../point_selectors/manipulation_event.h | 2 +- .../pcl/apps/cloud_composer/project_model.h | 2 +- .../tool_interface/abstract_tool.h | 2 +- .../pcl/apps/cloud_composer/toolbox_model.h | 2 +- .../tools/euclidean_clustering.h | 2 +- .../tools/impl/organized_segmentation.hpp | 12 ++--- .../cloud_composer/tools/impl/supervoxels.hpp | 4 +- .../cloud_composer/tools/normal_estimation.h | 2 +- .../cloud_composer/tools/sanitize_cloud.h | 2 +- .../tools/statistical_outlier_removal.h | 2 +- .../tools/voxel_grid_downsample.h | 2 +- apps/cloud_composer/src/cloud_view.cpp | 6 +-- apps/cloud_composer/src/cloud_viewer.cpp | 2 +- apps/cloud_composer/src/commands.cpp | 8 +-- .../src/items/cloud_composer_item.cpp | 4 +- apps/cloud_composer/src/items/cloud_item.cpp | 9 ++-- apps/cloud_composer/src/items/fpfh_item.cpp | 2 +- .../cloud_composer/src/items/normals_item.cpp | 6 +-- apps/cloud_composer/src/merge_selection.cpp | 10 ++-- .../click_trackball_interactor_style.cpp | 12 ++--- .../rectangular_frustum_selector.cpp | 4 +- .../selected_trackball_interactor_style.cpp | 6 +-- apps/cloud_composer/src/project_model.cpp | 20 +++---- apps/cloud_composer/src/properties_model.cpp | 8 +-- .../cloud_composer/src/signal_multiplexer.cpp | 2 +- .../src/tool_interface/abstract_tool.cpp | 2 +- apps/cloud_composer/src/toolbox_model.cpp | 12 ++--- apps/cloud_composer/src/transform_clouds.cpp | 2 +- apps/cloud_composer/src/work_queue.cpp | 2 +- .../tools/euclidean_clustering.cpp | 14 ++--- apps/cloud_composer/tools/fpfh_estimation.cpp | 2 +- .../tools/normal_estimation.cpp | 6 +-- .../tools/organized_segmentation.cpp | 4 +- apps/cloud_composer/tools/sanitize_cloud.cpp | 10 ++-- .../tools/statistical_outlier_removal.cpp | 10 ++-- apps/cloud_composer/tools/supervoxels.cpp | 4 +- .../tools/voxel_grid_downsample.cpp | 12 ++--- .../include/pcl/apps/in_hand_scanner/icp.h | 12 ++--- .../in_hand_scanner/impl/common_types.hpp | 2 +- .../apps/in_hand_scanner/in_hand_scanner.h | 10 ++-- .../in_hand_scanner/input_data_processing.h | 32 +++++------ .../pcl/apps/in_hand_scanner/integration.h | 10 ++-- .../in_hand_scanner/offline_integration.h | 2 +- .../pcl/apps/in_hand_scanner/opengl_viewer.h | 22 ++++---- apps/in_hand_scanner/src/icp.cpp | 24 ++++----- apps/in_hand_scanner/src/in_hand_scanner.cpp | 10 ++-- .../src/input_data_processing.cpp | 22 ++------ apps/in_hand_scanner/src/integration.cpp | 10 ++-- apps/in_hand_scanner/src/main_window.cpp | 4 +- .../src/offline_integration.cpp | 2 +- apps/in_hand_scanner/src/opengl_viewer.cpp | 28 ++++------ .../apps/face_detection/openni_frame_source.h | 4 +- .../apps/impl/dominant_plane_segmentation.hpp | 10 ++-- apps/include/pcl/apps/nn_classification.h | 4 +- apps/include/pcl/apps/openni_passthrough.h | 2 +- .../pcl/apps/organized_segmentation_demo.h | 2 +- apps/include/pcl/apps/pcd_video_player.h | 2 +- apps/include/pcl/apps/pcl_viewer_dialog.h | 2 +- apps/include/pcl/apps/timer.h | 2 +- .../pcl/apps/modeler/abstract_worker.h | 2 +- .../pcl/apps/modeler/channel_actor_item.h | 2 +- .../apps/modeler/icp_registration_worker.h | 8 +-- .../apps/modeler/normal_estimation_worker.h | 4 +- .../pcl/apps/modeler/normals_actor_item.h | 4 +- .../pcl/apps/modeler/parameter_dialog.h | 2 +- .../include/pcl/apps/modeler/poisson_worker.h | 14 ++--- .../pcl/apps/modeler/render_window_item.h | 2 +- .../statistical_outlier_removal_worker.h | 6 +-- .../pcl/apps/modeler/thread_controller.h | 2 +- .../modeler/voxel_grid_downsample_worker.h | 8 +-- apps/modeler/src/abstract_item.cpp | 2 +- apps/modeler/src/cloud_mesh.cpp | 4 +- apps/modeler/src/cloud_mesh_item.cpp | 12 ++--- apps/modeler/src/icp_registration_worker.cpp | 18 +++---- apps/modeler/src/main_window.cpp | 2 +- apps/modeler/src/normal_estimation_worker.cpp | 14 ++--- apps/modeler/src/normals_actor_item.cpp | 22 ++++---- apps/modeler/src/parameter.cpp | 24 ++++----- apps/modeler/src/parameter_dialog.cpp | 20 +++---- apps/modeler/src/points_actor_item.cpp | 2 +- apps/modeler/src/poisson_worker.cpp | 8 +-- apps/modeler/src/render_window.cpp | 6 +-- apps/modeler/src/render_window_item.cpp | 4 +- apps/modeler/src/scene_tree.cpp | 16 +++--- .../statistical_outlier_removal_worker.cpp | 4 +- apps/modeler/src/surface_actor_item.cpp | 2 +- apps/modeler/src/thread_controller.cpp | 4 +- .../src/voxel_grid_downsample_worker.cpp | 17 +++--- .../point_cloud_editor/cloudEditorWidget.h | 16 +++--- .../point_cloud_editor/cloudTransformTool.h | 2 +- .../pcl/apps/point_cloud_editor/command.h | 4 +- .../point_cloud_editor/denoiseParameterForm.h | 2 +- .../pcl/apps/point_cloud_editor/trackball.h | 2 +- apps/point_cloud_editor/src/cloud.cpp | 2 +- .../src/cloudEditorWidget.cpp | 41 +++++++------- .../src/cloudTransformTool.cpp | 8 +-- .../src/denoiseParameterForm.cpp | 2 +- apps/point_cloud_editor/src/select1DTool.cpp | 2 +- apps/point_cloud_editor/src/selection.cpp | 2 +- .../src/selectionTransformTool.cpp | 14 ++--- .../src/statisticsDialog.cpp | 2 +- apps/point_cloud_editor/src/trackball.cpp | 2 +- apps/src/convolve.cpp | 4 +- apps/src/dinast_grabber_example.cpp | 2 +- .../face_detection/openni_frame_source.cpp | 2 +- apps/src/feature_matching.cpp | 21 ++++---- apps/src/grabcut_2d.cpp | 12 ++--- .../manual_registration.cpp | 2 +- apps/src/ni_agast.cpp | 17 +++--- apps/src/ni_brisk.cpp | 10 ++-- apps/src/ni_linemod.cpp | 4 +- apps/src/ni_susan.cpp | 4 +- apps/src/openni_3d_concave_hull.cpp | 4 +- apps/src/openni_3d_convex_hull.cpp | 4 +- apps/src/openni_boundary_estimation.cpp | 4 +- apps/src/openni_fast_mesh.cpp | 4 +- apps/src/openni_feature_persistence.cpp | 6 +-- apps/src/openni_ii_normal_estimation.cpp | 4 +- apps/src/openni_klt.cpp | 10 ++-- apps/src/openni_mls_smoothing.cpp | 4 +- apps/src/openni_mobile_server.cpp | 2 +- apps/src/openni_octree_compression.cpp | 4 +- apps/src/openni_organized_compression.cpp | 6 +-- apps/src/openni_organized_edge_detection.cpp | 10 ++-- ...nni_organized_multi_plane_segmentation.cpp | 6 +-- apps/src/openni_planar_convex_hull.cpp | 2 +- apps/src/openni_planar_segmentation.cpp | 2 +- apps/src/openni_shift_to_depth_conversion.cpp | 6 +-- apps/src/openni_tracking.cpp | 22 ++++---- apps/src/openni_uniform_sampling.cpp | 4 +- apps/src/openni_voxel_grid.cpp | 4 +- apps/src/organized_segmentation_demo.cpp | 16 +++--- apps/src/pcd_organized_edge_detection.cpp | 2 +- ...pcd_organized_multi_plane_segmentation.cpp | 17 +++--- apps/src/pcd_select_object_plane.cpp | 4 +- .../src/pcd_video_player/pcd_video_player.cpp | 4 +- apps/src/ppf_object_recognition.cpp | 4 +- apps/src/pyramid_surface_matching.cpp | 4 +- apps/src/render_views_tesselated_sphere.cpp | 16 +++--- apps/src/stereo_ground_segmentation.cpp | 54 +++++++++---------- common/include/pcl/common/fft/.clang-tidy | 3 ++ common/src/fft/.clang-tidy | 3 ++ features/include/pcl/features/ppfrgb.h | 2 +- .../pcl/geometry/impl/polygon_operations.hpp | 6 +-- keypoints/include/pcl/keypoints/harris_2d.h | 21 ++++---- .../include/pcl/keypoints/impl/harris_2d.hpp | 4 +- .../include/pcl/outofcore/impl/lru_cache.hpp | 8 +-- .../pcl/recognition/3rdparty/.clang-tidy | 3 ++ .../include/pcl/recognition/crh_alignment.h | 6 +-- .../euclidean_cluster_comparator.h | 4 +- .../include/pcl/surface/3rdparty/.clang-tidy | 3 ++ .../pcl/surface/on_nurbs/fitting_curve_2d.h | 9 ++-- .../surface/on_nurbs/fitting_curve_2d_apdm.h | 20 +++---- .../surface/on_nurbs/fitting_curve_2d_pdm.h | 9 ++-- .../pcl/surface/on_nurbs/fitting_surface_im.h | 7 +-- .../include/pcl/surface/on_nurbs/nurbs_data.h | 6 +-- .../pcl/surface/on_nurbs/nurbs_solve.h | 7 +-- surface/src/3rdparty/.clang-tidy | 3 ++ .../pcl/tracking/hsv_color_coherence.h | 12 ++--- .../pcl/tracking/impl/pyramidal_klt.hpp | 22 ++++---- tracking/include/pcl/tracking/pyramidal_klt.h | 8 +-- 177 files changed, 618 insertions(+), 679 deletions(-) create mode 100644 common/include/pcl/common/fft/.clang-tidy create mode 100644 common/src/fft/.clang-tidy create mode 100644 recognition/include/pcl/recognition/3rdparty/.clang-tidy create mode 100644 surface/include/pcl/surface/3rdparty/.clang-tidy create mode 100644 surface/src/3rdparty/.clang-tidy diff --git a/.github/workflows/clang-tidy.yml b/.github/workflows/clang-tidy.yml index 59fc4071c26..1b49eecb99f 100755 --- a/.github/workflows/clang-tidy.yml +++ b/.github/workflows/clang-tidy.yml @@ -17,6 +17,7 @@ jobs: cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_CXX_COMPILER=/usr/bin/clang-18 -DCMAKE_C_COMPILER=/usr/bin/clang-18 . \ -DBUILD_benchmarks=ON \ -DBUILD_examples=ON \ + -DBUILD_surface_on_nurbs=ON \ -DBUILD_simulation=ON \ -DBUILD_global_tests=ON diff --git a/apps/3d_rec_framework/include/pcl/apps/3d_rec_framework/pc_source/source.h b/apps/3d_rec_framework/include/pcl/apps/3d_rec_framework/pc_source/source.h index e2a14ac7e48..e51afd192ab 100644 --- a/apps/3d_rec_framework/include/pcl/apps/3d_rec_framework/pc_source/source.h +++ b/apps/3d_rec_framework/include/pcl/apps/3d_rec_framework/pc_source/source.h @@ -51,7 +51,7 @@ class Model { if (resolution <= 0) return assembled_; - typename std::map::iterator it = + auto it = voxelized_assembled_.find(resolution); if (it == voxelized_assembled_.end()) { PointTPtr voxelized(new pcl::PointCloud); diff --git a/apps/3d_rec_framework/include/pcl/apps/3d_rec_framework/pipeline/impl/global_nn_recognizer_crh.hpp b/apps/3d_rec_framework/include/pcl/apps/3d_rec_framework/pipeline/impl/global_nn_recognizer_crh.hpp index af7ab87d642..4dad194506e 100644 --- a/apps/3d_rec_framework/include/pcl/apps/3d_rec_framework/pipeline/impl/global_nn_recognizer_crh.hpp +++ b/apps/3d_rec_framework/include/pcl/apps/3d_rec_framework/pipeline/impl/global_nn_recognizer_crh.hpp @@ -22,11 +22,7 @@ pcl::rec_3d_framework::GlobalNNCRHRecognizer::getP using mv_pair = std::pair; mv_pair pair_model_view = std::make_pair(model.id_, view_id); - std::map, - Eigen::aligned_allocator>>:: - iterator it = poses_cache_.find(pair_model_view); + auto it = poses_cache_.find(pair_model_view); if (it != poses_cache_.end()) { pose_matrix = it->second; diff --git a/apps/3d_rec_framework/include/pcl/apps/3d_rec_framework/pipeline/impl/global_nn_recognizer_cvfh.hpp b/apps/3d_rec_framework/include/pcl/apps/3d_rec_framework/pipeline/impl/global_nn_recognizer_cvfh.hpp index 6a583006cd7..08d17d7caaf 100644 --- a/apps/3d_rec_framework/include/pcl/apps/3d_rec_framework/pipeline/impl/global_nn_recognizer_cvfh.hpp +++ b/apps/3d_rec_framework/include/pcl/apps/3d_rec_framework/pipeline/impl/global_nn_recognizer_cvfh.hpp @@ -22,11 +22,7 @@ pcl::rec_3d_framework::GlobalNNCVFHRecognizer::get using mv_pair = std::pair; mv_pair pair_model_view = std::make_pair(model.id_, view_id); - std::map, - Eigen::aligned_allocator>>:: - iterator it = poses_cache_.find(pair_model_view); + auto it = poses_cache_.find(pair_model_view); if (it != poses_cache_.end()) { pose_matrix = it->second; diff --git a/apps/3d_rec_framework/include/pcl/apps/3d_rec_framework/pipeline/impl/local_recognizer.hpp b/apps/3d_rec_framework/include/pcl/apps/3d_rec_framework/pipeline/impl/local_recognizer.hpp index 1bf8388f7fe..73fee8ec022 100644 --- a/apps/3d_rec_framework/include/pcl/apps/3d_rec_framework/pipeline/impl/local_recognizer.hpp +++ b/apps/3d_rec_framework/include/pcl/apps/3d_rec_framework/pipeline/impl/local_recognizer.hpp @@ -460,11 +460,7 @@ pcl::rec_3d_framework::LocalRecognitionPipeline::g using mv_pair = std::pair; mv_pair pair_model_view = std::make_pair(model.id_, view_id); - std::map, - Eigen::aligned_allocator>>:: - iterator it = poses_cache_.find(pair_model_view); + auto it = poses_cache_.find(pair_model_view); if (it != poses_cache_.end()) { pose_matrix = it->second; @@ -489,7 +485,7 @@ pcl::rec_3d_framework::LocalRecognitionPipeline:: if (use_cache_) { std::pair pair_model_view = std::make_pair(model.id_, view_id); - typename std::map, PointInTPtr>::iterator it = + auto it = keypoints_cache_.find(pair_model_view); if (it != keypoints_cache_.end()) { diff --git a/apps/3d_rec_framework/include/pcl/apps/3d_rec_framework/pipeline/local_recognizer.h b/apps/3d_rec_framework/include/pcl/apps/3d_rec_framework/pipeline/local_recognizer.h index 8aece90423d..20f50ad52c4 100644 --- a/apps/3d_rec_framework/include/pcl/apps/3d_rec_framework/pipeline/local_recognizer.h +++ b/apps/3d_rec_framework/include/pcl/apps/3d_rec_framework/pipeline/local_recognizer.h @@ -195,7 +195,7 @@ class PCL_EXPORTS LocalRecognitionPipeline { } public: - LocalRecognitionPipeline() : search_model_("") + LocalRecognitionPipeline() : { use_cache_ = false; threshold_accept_model_hypothesis_ = 0.2f; diff --git a/apps/3d_rec_framework/include/pcl/apps/3d_rec_framework/tools/openni_frame_source.h b/apps/3d_rec_framework/include/pcl/apps/3d_rec_framework/tools/openni_frame_source.h index 1fe6f4aacfb..b78cbea047b 100644 --- a/apps/3d_rec_framework/include/pcl/apps/3d_rec_framework/tools/openni_frame_source.h +++ b/apps/3d_rec_framework/include/pcl/apps/3d_rec_framework/tools/openni_frame_source.h @@ -31,9 +31,9 @@ class PCL_EXPORTS OpenNIFrameSource { pcl::OpenNIGrabber grabber_; PointCloudPtr most_recent_frame_; - int frame_counter_; + int frame_counter_{0}; std::mutex mutex_; - bool active_; + bool active_{true}; }; } // namespace OpenNIFrameSource diff --git a/apps/3d_rec_framework/include/pcl/apps/3d_rec_framework/utils/persistence_utils.h b/apps/3d_rec_framework/include/pcl/apps/3d_rec_framework/utils/persistence_utils.h index 528a7daf4a8..fcaba10419f 100644 --- a/apps/3d_rec_framework/include/pcl/apps/3d_rec_framework/utils/persistence_utils.h +++ b/apps/3d_rec_framework/include/pcl/apps/3d_rec_framework/utils/persistence_utils.h @@ -54,7 +54,7 @@ writeMatrixToFile(const std::string& file, Eigen::Matrix4f& matrix) for (std::size_t i = 0; i < 4; i++) { for (std::size_t j = 0; j < 4; j++) { out << matrix(i, j); - if (!(i == 3 && j == 3)) + if (i != 3 || j != 3) out << " "; } } diff --git a/apps/3d_rec_framework/src/tools/local_recognition_mian_dataset.cpp b/apps/3d_rec_framework/src/tools/local_recognition_mian_dataset.cpp index 220952347f4..f6ab05df515 100644 --- a/apps/3d_rec_framework/src/tools/local_recognition_mian_dataset.cpp +++ b/apps/3d_rec_framework/src/tools/local_recognition_mian_dataset.cpp @@ -102,7 +102,7 @@ recognizeAndVisualize( for (std::size_t i = 0; i < files.size(); i++) { std::cout << files[i] << std::endl; if (scene != -1) - if ((std::size_t)scene != i) + if (static_cast(scene) != i) continue; const std::string file = ply_files_dir.string() + files[i]; diff --git a/apps/3d_rec_framework/src/tools/openni_frame_source.cpp b/apps/3d_rec_framework/src/tools/openni_frame_source.cpp index 1d0645dd3a5..a6eb42bdc39 100644 --- a/apps/3d_rec_framework/src/tools/openni_frame_source.cpp +++ b/apps/3d_rec_framework/src/tools/openni_frame_source.cpp @@ -5,7 +5,7 @@ namespace OpenNIFrameSource { OpenNIFrameSource::OpenNIFrameSource(const std::string& device_id) -: grabber_(device_id), frame_counter_(0), active_(true) +: grabber_(device_id), { std::function frame_cb = [this](const PointCloudConstPtr& cloud) { onNewFrame(cloud); }; diff --git a/apps/cloud_composer/include/pcl/apps/cloud_composer/commands.h b/apps/cloud_composer/include/pcl/apps/cloud_composer/commands.h index e47c399b2e2..9ef05cde3e8 100644 --- a/apps/cloud_composer/include/pcl/apps/cloud_composer/commands.h +++ b/apps/cloud_composer/include/pcl/apps/cloud_composer/commands.h @@ -54,7 +54,7 @@ class CloudCommand : public QUndoCommand { public: CloudCommand(ConstItemList input_data, QUndoCommand* parent = nullptr); - ~CloudCommand(); + ~CloudCommand() override; virtual bool runCommand(AbstractTool* tool) = 0; @@ -112,8 +112,8 @@ class CloudCommand : public QUndoCommand { bool canUseTemplates(ConstItemList& input_data); - bool can_use_templates_; - int template_type_; + bool can_use_templates_{false}; + int template_type_{-1}; }; class ModifyItemCommand : public CloudCommand { diff --git a/apps/cloud_composer/include/pcl/apps/cloud_composer/impl/cloud_item.hpp b/apps/cloud_composer/include/pcl/apps/cloud_composer/impl/cloud_item.hpp index 6c78b82d46f..8ee74eaf3c0 100644 --- a/apps/cloud_composer/include/pcl/apps/cloud_composer/impl/cloud_item.hpp +++ b/apps/cloud_composer/include/pcl/apps/cloud_composer/impl/cloud_item.hpp @@ -68,7 +68,7 @@ pcl::cloud_composer::CloudItem::createCloudItemFromTemplate( { pcl::PCLPointCloud2::Ptr cloud_blob = pcl::make_shared(); toPCLPointCloud2(*cloud_ptr, *cloud_blob); - CloudItem* cloud_item = + auto* cloud_item = new CloudItem(name, cloud_blob, Eigen::Vector4f(), Eigen::Quaternionf(), false); cloud_item->setData(QVariant::fromValue(cloud_ptr), ItemDataRole::CLOUD_TEMPLATED); cloud_item->setPointType(); diff --git a/apps/cloud_composer/include/pcl/apps/cloud_composer/impl/merge_selection.hpp b/apps/cloud_composer/include/pcl/apps/cloud_composer/impl/merge_selection.hpp index bb913d2581e..e7917878cc8 100644 --- a/apps/cloud_composer/include/pcl/apps/cloud_composer/impl/merge_selection.hpp +++ b/apps/cloud_composer/include/pcl/apps/cloud_composer/impl/merge_selection.hpp @@ -74,7 +74,7 @@ pcl::cloud_composer::MergeSelection::performTemplatedAction( input_cloud_item->printNumPoints(); // If this cloud hasn't been completely selected if (!input_data.contains(input_cloud_item)) { - typename PointCloud::Ptr input_cloud = + auto input_cloud = input_cloud_item->data(ItemDataRole::CLOUD_TEMPLATED) .value::Ptr>(); qDebug() << "Extracting " @@ -102,7 +102,7 @@ pcl::cloud_composer::MergeSelection::performTemplatedAction( } // Just concatenate for all fully selected clouds foreach (const CloudComposerItem* input_item, input_data) { - typename PointCloud::Ptr input_cloud = + auto input_cloud = input_item->data(ItemDataRole::CLOUD_TEMPLATED) .value::Ptr>(); *merged_cloud += *input_cloud; diff --git a/apps/cloud_composer/include/pcl/apps/cloud_composer/impl/transform_clouds.hpp b/apps/cloud_composer/include/pcl/apps/cloud_composer/impl/transform_clouds.hpp index 5fce284b5ab..77d63739861 100644 --- a/apps/cloud_composer/include/pcl/apps/cloud_composer/impl/transform_clouds.hpp +++ b/apps/cloud_composer/include/pcl/apps/cloud_composer/impl/transform_clouds.hpp @@ -68,7 +68,7 @@ pcl::cloud_composer::TransformClouds::performTemplatedAction( foreach (const CloudComposerItem* input_item, input_data) { qDebug() << "Transforming cloud " << input_item->getId(); QVariant variant = input_item->data(ItemDataRole::CLOUD_TEMPLATED); - typename PointCloud::Ptr input_cloud = + auto input_cloud = variant.value::Ptr>(); Eigen::Matrix4f transform; diff --git a/apps/cloud_composer/include/pcl/apps/cloud_composer/items/cloud_composer_item.h b/apps/cloud_composer/include/pcl/apps/cloud_composer/items/cloud_composer_item.h index 422f8e3d512..3a60dcc1d8b 100644 --- a/apps/cloud_composer/include/pcl/apps/cloud_composer/items/cloud_composer_item.h +++ b/apps/cloud_composer/include/pcl/apps/cloud_composer/items/cloud_composer_item.h @@ -73,7 +73,7 @@ class CloudComposerItem : public QStandardItem { CloudComposerItem(const QString& name = "default item"); CloudComposerItem(const CloudComposerItem& to_copy); - ~CloudComposerItem(); + ~CloudComposerItem() override; inline int type() const override diff --git a/apps/cloud_composer/include/pcl/apps/cloud_composer/items/cloud_item.h b/apps/cloud_composer/include/pcl/apps/cloud_composer/items/cloud_item.h index 8e4a6a4b2f5..126e8ff2faa 100644 --- a/apps/cloud_composer/include/pcl/apps/cloud_composer/items/cloud_item.h +++ b/apps/cloud_composer/include/pcl/apps/cloud_composer/items/cloud_item.h @@ -149,15 +149,15 @@ class CloudItem : public CloudComposerItem { Eigen::Vector4f origin_; Eigen::Quaternionf orientation_; - bool template_cloud_set_; + bool template_cloud_set_{false}; // Internal Storage of the templated type of this cloud - int point_type_; + int point_type_{PointTypeFlags::NONE}; bool checkIfFinite(); - bool is_sanitized_; + bool is_sanitized_{false}; // Helper functions which set the point_type_ based on the current point type template diff --git a/apps/cloud_composer/include/pcl/apps/cloud_composer/point_selectors/manipulation_event.h b/apps/cloud_composer/include/pcl/apps/cloud_composer/point_selectors/manipulation_event.h index af1f09e875a..883222cdfe6 100644 --- a/apps/cloud_composer/include/pcl/apps/cloud_composer/point_selectors/manipulation_event.h +++ b/apps/cloud_composer/include/pcl/apps/cloud_composer/point_selectors/manipulation_event.h @@ -45,7 +45,7 @@ namespace cloud_composer { class ManipulationEvent { public: - ManipulationEvent() {} + ManipulationEvent() = default; void addManipulation(const QString& id, diff --git a/apps/cloud_composer/include/pcl/apps/cloud_composer/project_model.h b/apps/cloud_composer/include/pcl/apps/cloud_composer/project_model.h index 5394e2f1ec5..dd6c7094563 100644 --- a/apps/cloud_composer/include/pcl/apps/cloud_composer/project_model.h +++ b/apps/cloud_composer/include/pcl/apps/cloud_composer/project_model.h @@ -66,7 +66,7 @@ class ProjectModel : public QStandardItemModel { public: ProjectModel(QObject* parent = nullptr); ProjectModel(const ProjectModel& to_copy); - ~ProjectModel(); + ~ProjectModel() override; ProjectModel(QString project_name, QObject* parent = nullptr); diff --git a/apps/cloud_composer/include/pcl/apps/cloud_composer/tool_interface/abstract_tool.h b/apps/cloud_composer/include/pcl/apps/cloud_composer/tool_interface/abstract_tool.h index 30bd06080c9..aac5565ef4c 100644 --- a/apps/cloud_composer/include/pcl/apps/cloud_composer/tool_interface/abstract_tool.h +++ b/apps/cloud_composer/include/pcl/apps/cloud_composer/tool_interface/abstract_tool.h @@ -51,7 +51,7 @@ class AbstractTool : public QObject { public: AbstractTool(PropertiesModel* parameter_model, QObject* parent); - ~AbstractTool() { qDebug() << "Tool Destructed"; } + ~AbstractTool() override { qDebug() << "Tool Destructed"; } /** \brief Function called which does work in plugin * \param data input_data from the model - const for good reason diff --git a/apps/cloud_composer/include/pcl/apps/cloud_composer/toolbox_model.h b/apps/cloud_composer/include/pcl/apps/cloud_composer/toolbox_model.h index f109c8d93a9..377bf94ce7c 100644 --- a/apps/cloud_composer/include/pcl/apps/cloud_composer/toolbox_model.h +++ b/apps/cloud_composer/include/pcl/apps/cloud_composer/toolbox_model.h @@ -114,7 +114,7 @@ public Q_SLOTS: QItemSelectionModel* selection_model_; QSet tool_items; - ProjectModel* project_model_; + ProjectModel* project_model_{nullptr}; }; } // namespace cloud_composer } // namespace pcl diff --git a/apps/cloud_composer/include/pcl/apps/cloud_composer/tools/euclidean_clustering.h b/apps/cloud_composer/include/pcl/apps/cloud_composer/tools/euclidean_clustering.h index c97be097638..cc886e279ca 100644 --- a/apps/cloud_composer/include/pcl/apps/cloud_composer/tools/euclidean_clustering.h +++ b/apps/cloud_composer/include/pcl/apps/cloud_composer/tools/euclidean_clustering.h @@ -99,7 +99,7 @@ class EuclideanClusteringToolFactory : public QObject, public ToolFactory { inline QList getRequiredInputChildrenTypes() const override { - return QList(); + return {}; } }; diff --git a/apps/cloud_composer/include/pcl/apps/cloud_composer/tools/impl/organized_segmentation.hpp b/apps/cloud_composer/include/pcl/apps/cloud_composer/tools/impl/organized_segmentation.hpp index a200e83c857..3f776e3572f 100644 --- a/apps/cloud_composer/include/pcl/apps/cloud_composer/tools/impl/organized_segmentation.hpp +++ b/apps/cloud_composer/include/pcl/apps/cloud_composer/tools/impl/organized_segmentation.hpp @@ -66,7 +66,7 @@ pcl::cloud_composer::OrganizedSegmentationTool::performTemplatedAction( "item! (input list)"; return output; } - typename PointCloud::Ptr input_cloud = + auto input_cloud = variant.value::Ptr>(); if (!input_cloud->isOrganized()) { qCritical() << "Organized Segmentation requires an organized cloud!"; @@ -89,13 +89,13 @@ pcl::cloud_composer::OrganizedSegmentationTool::performTemplatedAction( input_item->getChildren(CloudComposerItem::NORMALS_ITEM); // Get the normals cloud, we just use the first normals that were found if there are // more than one - pcl::PointCloud::ConstPtr input_normals = + auto input_normals = normals_list.value(0) ->data(ItemDataRole::CLOUD_TEMPLATED) .value::ConstPtr>(); QVariant variant = input_item->data(ItemDataRole::CLOUD_TEMPLATED); - typename PointCloud::Ptr input_cloud = + auto input_cloud = variant.value::Ptr>(); pcl::OrganizedMultiPlaneSegmentation mps; @@ -121,7 +121,7 @@ pcl::cloud_composer::OrganizedSegmentationTool::performTemplatedAction( auto plane_labels = pcl::make_shared>(); for (std::size_t i = 0; i < label_indices.size(); ++i) - if (label_indices[i].indices.size() > (std::size_t)min_plane_size) + if (label_indices[i].indices.size() > static_cast(min_plane_size)) plane_labels->insert(i); typename PointCloud::CloudVectorType clusters; @@ -143,7 +143,7 @@ pcl::cloud_composer::OrganizedSegmentationTool::performTemplatedAction( pcl::IndicesPtr extracted_indices(new pcl::Indices()); for (std::size_t i = 0; i < euclidean_label_indices.size(); i++) { - if (euclidean_label_indices[i].indices.size() >= (std::size_t)min_cluster_size) { + if (euclidean_label_indices[i].indices.size() >= static_cast(min_cluster_size)) { typename PointCloud::Ptr cluster(new PointCloud); pcl::copyPointCloud(*input_cloud, euclidean_label_indices[i].indices, *cluster); qDebug() << "Found cluster with size " << cluster->width; @@ -158,7 +158,7 @@ pcl::cloud_composer::OrganizedSegmentationTool::performTemplatedAction( } for (std::size_t i = 0; i < label_indices.size(); i++) { - if (label_indices[i].indices.size() >= (std::size_t)min_plane_size) { + if (label_indices[i].indices.size() >= static_cast(min_plane_size)) { typename PointCloud::Ptr plane(new PointCloud); pcl::copyPointCloud(*input_cloud, label_indices[i].indices, *plane); qDebug() << "Found plane with size " << plane->width; diff --git a/apps/cloud_composer/include/pcl/apps/cloud_composer/tools/impl/supervoxels.hpp b/apps/cloud_composer/include/pcl/apps/cloud_composer/tools/impl/supervoxels.hpp index 4222f215ec2..9c717a6c70b 100644 --- a/apps/cloud_composer/include/pcl/apps/cloud_composer/tools/impl/supervoxels.hpp +++ b/apps/cloud_composer/include/pcl/apps/cloud_composer/tools/impl/supervoxels.hpp @@ -64,14 +64,14 @@ pcl::cloud_composer::SupervoxelsTool::performTemplatedAction( "item! (input list)"; return output; } - typename PointCloud::Ptr input_cloud = + auto input_cloud = variant.value::Ptr>(); // TODO: Check if Voxelized } foreach (const CloudComposerItem* input_item, input_data) { QVariant variant = input_item->data(ItemDataRole::CLOUD_TEMPLATED); - typename PointCloud::Ptr input_cloud = + auto input_cloud = variant.value::Ptr>(); float resolution = parameter_model_->getProperty("Resolution").toFloat(); diff --git a/apps/cloud_composer/include/pcl/apps/cloud_composer/tools/normal_estimation.h b/apps/cloud_composer/include/pcl/apps/cloud_composer/tools/normal_estimation.h index cd27fbee0cc..003095341b4 100644 --- a/apps/cloud_composer/include/pcl/apps/cloud_composer/tools/normal_estimation.h +++ b/apps/cloud_composer/include/pcl/apps/cloud_composer/tools/normal_estimation.h @@ -99,7 +99,7 @@ class NormalEstimationToolFactory : public QObject, public ToolFactory { inline QList getRequiredInputChildrenTypes() const override { - return QList(); + return {}; } }; diff --git a/apps/cloud_composer/include/pcl/apps/cloud_composer/tools/sanitize_cloud.h b/apps/cloud_composer/include/pcl/apps/cloud_composer/tools/sanitize_cloud.h index 2a8e33ccc94..bb031c6c19d 100644 --- a/apps/cloud_composer/include/pcl/apps/cloud_composer/tools/sanitize_cloud.h +++ b/apps/cloud_composer/include/pcl/apps/cloud_composer/tools/sanitize_cloud.h @@ -99,7 +99,7 @@ class SanitizeCloudToolFactory : public QObject, public ToolFactory { inline QList getRequiredInputChildrenTypes() const override { - return QList(); + return {}; } }; diff --git a/apps/cloud_composer/include/pcl/apps/cloud_composer/tools/statistical_outlier_removal.h b/apps/cloud_composer/include/pcl/apps/cloud_composer/tools/statistical_outlier_removal.h index 092edb0634f..a27a79dc986 100644 --- a/apps/cloud_composer/include/pcl/apps/cloud_composer/tools/statistical_outlier_removal.h +++ b/apps/cloud_composer/include/pcl/apps/cloud_composer/tools/statistical_outlier_removal.h @@ -99,7 +99,7 @@ class StatisticalOutlierRemovalToolFactory : public QObject, public ToolFactory inline QList getRequiredInputChildrenTypes() const override { - return QList(); + return {}; } }; diff --git a/apps/cloud_composer/include/pcl/apps/cloud_composer/tools/voxel_grid_downsample.h b/apps/cloud_composer/include/pcl/apps/cloud_composer/tools/voxel_grid_downsample.h index 8672be64672..868b532a9d0 100644 --- a/apps/cloud_composer/include/pcl/apps/cloud_composer/tools/voxel_grid_downsample.h +++ b/apps/cloud_composer/include/pcl/apps/cloud_composer/tools/voxel_grid_downsample.h @@ -99,7 +99,7 @@ class VoxelGridDownsampleToolFactory : public QObject, public ToolFactory { inline QList getRequiredInputChildrenTypes() const override { - return QList(); + return {}; } }; diff --git a/apps/cloud_composer/src/cloud_view.cpp b/apps/cloud_composer/src/cloud_view.cpp index 465c557a071..cd04e9dd152 100644 --- a/apps/cloud_composer/src/cloud_view.cpp +++ b/apps/cloud_composer/src/cloud_view.cpp @@ -105,7 +105,7 @@ void pcl::cloud_composer::CloudView::itemChanged (QStandardItem* changed_item) { qDebug () << "Item Changed - Redrawing!"; - CloudComposerItem* item = dynamic_cast (changed_item); + auto* item = dynamic_cast (changed_item); if (item) { item->paintView (vis_); @@ -127,7 +127,7 @@ pcl::cloud_composer::CloudView::rowsInserted (const QModelIndex& parent, int sta for (int row = start; row <= end; ++row) { QStandardItem* new_item = parent_item->child(row); - CloudComposerItem* item = dynamic_cast (new_item); + auto* item = dynamic_cast (new_item); if (item) item->paintView (vis_); @@ -155,7 +155,7 @@ pcl::cloud_composer::CloudView::rowsAboutToBeRemoved (const QModelIndex& parent, QStandardItem* item_to_remove = parent_item->child(row); if (item_to_remove) qDebug () << "Removing "<text (); - CloudComposerItem* item = dynamic_cast (item_to_remove); + auto* item = dynamic_cast (item_to_remove); if (item ) item->removeFromView (vis_); diff --git a/apps/cloud_composer/src/cloud_viewer.cpp b/apps/cloud_composer/src/cloud_viewer.cpp index 1479ef25847..430e403f03e 100644 --- a/apps/cloud_composer/src/cloud_viewer.cpp +++ b/apps/cloud_composer/src/cloud_viewer.cpp @@ -13,7 +13,7 @@ pcl::cloud_composer::CloudViewer::CloudViewer(QWidget* parent) : QTabWidget(pare void pcl::cloud_composer::CloudViewer::addModel(ProjectModel* new_model) { - CloudView* new_view = new CloudView(new_model); + auto* new_view = new CloudView(new_model); connect(new_model->getSelectionModel(), SIGNAL(selectionChanged(QItemSelection, QItemSelection)), new_view, diff --git a/apps/cloud_composer/src/commands.cpp b/apps/cloud_composer/src/commands.cpp index 03ff9c15659..f3ba31df740 100644 --- a/apps/cloud_composer/src/commands.cpp +++ b/apps/cloud_composer/src/commands.cpp @@ -7,8 +7,8 @@ pcl::cloud_composer::CloudCommand::CloudCommand( QList input_data, QUndoCommand* parent) : QUndoCommand(parent) , original_data_(std::move(input_data)) -, can_use_templates_(false) -, template_type_(-1) +, + {} pcl::cloud_composer::CloudCommand::~CloudCommand() @@ -53,7 +53,7 @@ pcl::cloud_composer::CloudCommand::canUseTemplates(ConstItemList& input_data) // Make sure all input items are clouds QList cloud_items; foreach (const CloudComposerItem* item, input_data) { - const CloudItem* cloud_item = dynamic_cast(item); + const auto* cloud_item = dynamic_cast(item); if (cloud_item) cloud_items.append(cloud_item); } @@ -501,7 +501,7 @@ pcl::cloud_composer::MergeCloudCommand::runCommand(AbstractTool* tool) original_data_, static_cast(template_type_)); else output_items = tool->performAction(original_data_); - MergeSelection* merge_selection = dynamic_cast(tool); + auto* merge_selection = dynamic_cast(tool); // If this is a merge selection we need to put the partially selected items into the // original data list too! We didn't send them before because merge selection already // knows about them (and needs to tree input list differently from selected items) diff --git a/apps/cloud_composer/src/items/cloud_composer_item.cpp b/apps/cloud_composer/src/items/cloud_composer_item.cpp index a87d5a2dba3..f5d17b266a5 100644 --- a/apps/cloud_composer/src/items/cloud_composer_item.cpp +++ b/apps/cloud_composer/src/items/cloud_composer_item.cpp @@ -24,7 +24,7 @@ pcl::cloud_composer::CloudComposerItem::~CloudComposerItem() pcl::cloud_composer::CloudComposerItem* pcl::cloud_composer::CloudComposerItem::clone() const { - CloudComposerItem* new_item = new CloudComposerItem(this->text()); + auto* new_item = new CloudComposerItem(this->text()); PropertiesModel* new_item_properties = new_item->getPropertiesModel(); new_item_properties->copyProperties(properties_); @@ -69,7 +69,7 @@ pcl::cloud_composer::CloudComposerItem::removeFromView( QMap pcl::cloud_composer::CloudComposerItem::getInspectorTabs() { - return QMap(); + return {}; } /* diff --git a/apps/cloud_composer/src/items/cloud_item.cpp b/apps/cloud_composer/src/items/cloud_item.cpp index d955fff374a..e8297839396 100644 --- a/apps/cloud_composer/src/items/cloud_item.cpp +++ b/apps/cloud_composer/src/items/cloud_item.cpp @@ -13,13 +13,12 @@ pcl::cloud_composer::CloudItem::CloudItem (QString name, const Eigen::Vector4f& origin, const Eigen::Quaternionf& orientation, bool make_templated_cloud) - : CloudComposerItem (std::move(name)) + : CloudComposerItem (name) , cloud_blob_ptr_ (cloud_ptr) , origin_ (origin) , orientation_ (orientation) - , template_cloud_set_ (false) - , point_type_ (PointTypeFlags::NONE) - , is_sanitized_ (false) + , + { //Sanitize the cloud data using passthrough @@ -59,7 +58,7 @@ pcl::cloud_composer::CloudItem::clone () const { pcl::PCLPointCloud2::Ptr cloud_copy (new pcl::PCLPointCloud2 (*cloud_blob_ptr_)); //Vector4f and Quaternionf do deep copies using constructor - CloudItem* new_item = new CloudItem (this->text (), cloud_copy, origin_,orientation_); + auto* new_item = new CloudItem (this->text (), cloud_copy, origin_,orientation_); PropertiesModel* new_item_properties = new_item->getPropertiesModel (); new_item_properties->copyProperties (properties_); diff --git a/apps/cloud_composer/src/items/fpfh_item.cpp b/apps/cloud_composer/src/items/fpfh_item.cpp index 95b8c64c8d2..6fd5efee5fa 100644 --- a/apps/cloud_composer/src/items/fpfh_item.cpp +++ b/apps/cloud_composer/src/items/fpfh_item.cpp @@ -39,7 +39,7 @@ pcl::cloud_composer::FPFHItem::getInspectorTabs() plot_.reset(new pcl::visualization::PCLPlotter); qvtk_ = new PCLQVTKWidget(); hist_page_ = new QWidget(); - QGridLayout* mainLayout = new QGridLayout(hist_page_); + auto* mainLayout = new QGridLayout(hist_page_); mainLayout->addWidget(qvtk_, 0, 0); } diff --git a/apps/cloud_composer/src/items/normals_item.cpp b/apps/cloud_composer/src/items/normals_item.cpp index 02267ad7922..20035444a6d 100644 --- a/apps/cloud_composer/src/items/normals_item.cpp +++ b/apps/cloud_composer/src/items/normals_item.cpp @@ -4,7 +4,7 @@ #include pcl::cloud_composer::NormalsItem::NormalsItem (QString name, const pcl::PointCloud::Ptr& normals_ptr, double radius) - : CloudComposerItem (std::move(name)) + : CloudComposerItem (name) , normals_ptr_ (normals_ptr) { @@ -22,7 +22,7 @@ pcl::cloud_composer::NormalsItem::clone () const { pcl::PointCloud::Ptr normals_copy (new pcl::PointCloud (*normals_ptr_)); //Vector4f and Quaternionf do deep copies using copy constructor - NormalsItem* new_item = new NormalsItem (this->text (), normals_copy, 0); + auto* new_item = new NormalsItem (this->text (), normals_copy, 0); PropertiesModel* new_item_properties = new_item->getPropertiesModel (); new_item_properties->copyProperties (properties_); @@ -37,7 +37,7 @@ pcl::cloud_composer::NormalsItem::paintView (pcl::visualization::PCLVisualizer:: if (parent ()->type () == CLOUD_ITEM) { QVariant cloud_ptr = parent ()->data (ItemDataRole::CLOUD_BLOB); - pcl::PCLPointCloud2::ConstPtr cloud_blob = cloud_ptr.value (); + auto cloud_blob = cloud_ptr.value (); pcl::PointCloud::Ptr cloud (new pcl::PointCloud); pcl::fromPCLPointCloud2 (*cloud_blob, *cloud); double scale = properties_->getProperty ("Scale").toDouble (); diff --git a/apps/cloud_composer/src/merge_selection.cpp b/apps/cloud_composer/src/merge_selection.cpp index 9999d9c67dc..237a5eedcde 100644 --- a/apps/cloud_composer/src/merge_selection.cpp +++ b/apps/cloud_composer/src/merge_selection.cpp @@ -18,7 +18,7 @@ pcl::cloud_composer::MergeSelection::performAction(ConstItemList input_data, PointTypeFlags::PointType type) { if (type != PointTypeFlags::NONE) { - switch ((std::uint8_t)type) { + switch (static_cast(type)) { case (PointTypeFlags::XYZ): return this->performTemplatedAction(input_data); case (PointTypeFlags::XYZ | PointTypeFlags::RGB): @@ -53,7 +53,7 @@ pcl::cloud_composer::MergeSelection::performAction(ConstItemList input_data, foreach (const CloudItem* input_cloud_item, selected_item_index_map_.keys()) { // If this cloud hasn't been completely selected if (!input_data.contains(input_cloud_item)) { - pcl::PCLPointCloud2::ConstPtr input_cloud = + auto input_cloud = input_cloud_item->data(ItemDataRole::CLOUD_BLOB) .value(); qDebug() << "Extracting " @@ -78,7 +78,7 @@ pcl::cloud_composer::MergeSelection::performAction(ConstItemList input_data, .value(); pose_found = true; } - CloudItem* new_cloud_item = new CloudItem(input_cloud_item->text(), + auto* new_cloud_item = new CloudItem(input_cloud_item->text(), original_minus_indices, source_origin, source_orientation); @@ -92,7 +92,7 @@ pcl::cloud_composer::MergeSelection::performAction(ConstItemList input_data, } // Just concatenate for all fully selected clouds foreach (const CloudComposerItem* input_item, input_data) { - pcl::PCLPointCloud2::ConstPtr input_cloud = + auto input_cloud = input_item->data(ItemDataRole::CLOUD_BLOB) .value(); @@ -101,7 +101,7 @@ pcl::cloud_composer::MergeSelection::performAction(ConstItemList input_data, merged_cloud = temp_cloud; } - CloudItem* cloud_item = new CloudItem( + auto* cloud_item = new CloudItem( "Cloud from Selection", merged_cloud, source_origin, source_orientation); output.append(cloud_item); diff --git a/apps/cloud_composer/src/point_selectors/click_trackball_interactor_style.cpp b/apps/cloud_composer/src/point_selectors/click_trackball_interactor_style.cpp index 96971e09ef2..178529cf3a4 100644 --- a/apps/cloud_composer/src/point_selectors/click_trackball_interactor_style.cpp +++ b/apps/cloud_composer/src/point_selectors/click_trackball_interactor_style.cpp @@ -52,9 +52,9 @@ pcl::cloud_composer::ClickTrackballStyleInteractor::OnLeftButtonUp() selected_actor->GetMatrix(end_matrix_); // Find the id of the actor we manipulated - pcl::visualization::CloudActorMap::const_iterator end = actors_->end(); + auto end = actors_->end(); QString manipulated_id; - for (pcl::visualization::CloudActorMap::const_iterator itr = actors_->begin(); + for (auto itr = actors_->begin(); itr != end; ++itr) { // qDebug () << "Id = "<first); @@ -63,7 +63,7 @@ pcl::cloud_composer::ClickTrackballStyleInteractor::OnLeftButtonUp() } } if (!manipulated_id.isEmpty()) { - ManipulationEvent* manip_event = new ManipulationEvent(); + auto* manip_event = new ManipulationEvent(); manip_event->addManipulation(manipulated_id, start_matrix_, end_matrix_); this->InvokeEvent(this->manipulation_complete_event_, manip_event); } @@ -85,9 +85,9 @@ pcl::cloud_composer::ClickTrackballStyleInteractor::OnRightButtonUp() selected_actor->GetMatrix(end_matrix_); // Find the id of the actor we manipulated - pcl::visualization::CloudActorMap::const_iterator end = actors_->end(); + auto end = actors_->end(); QString manipulated_id; - for (pcl::visualization::CloudActorMap::const_iterator itr = actors_->begin(); + for (auto itr = actors_->begin(); itr != end; ++itr) { // qDebug () << "Id = "<first); @@ -96,7 +96,7 @@ pcl::cloud_composer::ClickTrackballStyleInteractor::OnRightButtonUp() } } if (!manipulated_id.isEmpty()) { - ManipulationEvent* manip_event = new ManipulationEvent(); + auto* manip_event = new ManipulationEvent(); manip_event->addManipulation(manipulated_id, start_matrix_, end_matrix_); this->InvokeEvent(this->manipulation_complete_event_, manip_event); } diff --git a/apps/cloud_composer/src/point_selectors/rectangular_frustum_selector.cpp b/apps/cloud_composer/src/point_selectors/rectangular_frustum_selector.cpp index e1d87ac8ffb..9b8b39ac34f 100644 --- a/apps/cloud_composer/src/point_selectors/rectangular_frustum_selector.cpp +++ b/apps/cloud_composer/src/point_selectors/rectangular_frustum_selector.cpp @@ -39,7 +39,7 @@ pcl::cloud_composer::RectangularFrustumSelector::OnLeftButtonUp() vtkInteractorStyleRubberBandPick::OnLeftButtonUp(); vtkPlanes* frustum = - static_cast(this->GetInteractor()->GetPicker())->GetFrustum(); + dynamic_cast(this->GetInteractor()->GetPicker())->GetFrustum(); #if VTK_MAJOR_VERSION > 9 || (VTK_MAJOR_VERSION == 9 && VTK_MINOR_VERSION >= 4) vtkSmartPointer id_filter = vtkSmartPointer::New(); @@ -91,7 +91,7 @@ pcl::cloud_composer::RectangularFrustumSelector::OnLeftButtonUp() this->HighlightProp(nullptr); if (all_points->GetNumberOfPoints() > 0) { - SelectionEvent* selected = new SelectionEvent(all_points, + auto* selected = new SelectionEvent(all_points, selected_actor, selected_mapper, id_selected_data_map, diff --git a/apps/cloud_composer/src/point_selectors/selected_trackball_interactor_style.cpp b/apps/cloud_composer/src/point_selectors/selected_trackball_interactor_style.cpp index 16fef7815e7..0732f5969e8 100644 --- a/apps/cloud_composer/src/point_selectors/selected_trackball_interactor_style.cpp +++ b/apps/cloud_composer/src/point_selectors/selected_trackball_interactor_style.cpp @@ -31,7 +31,7 @@ pcl::cloud_composer::SelectedTrackballStyleInteractor::setSelectedActors() QModelIndexList selected_indexes = model_->getSelectionModel()->selectedIndexes(); foreach (QModelIndex index, selected_indexes) { QStandardItem* item = model_->itemFromIndex(index); - CloudItem* cloud_item = dynamic_cast(item); + auto* cloud_item = dynamic_cast(item); if (cloud_item) selected_cloud_ids.append(cloud_item->getId()); } @@ -71,7 +71,7 @@ pcl::cloud_composer::SelectedTrackballStyleInteractor::OnLeftButtonUp() vtkInteractorStyleTrackballActor::OnLeftButtonUp(); foreach (QString id, selected_actors_map_.keys()) { vtkLODActor* actor = selected_actors_map_.value(id); - ManipulationEvent* manip_event = new ManipulationEvent(); + auto* manip_event = new ManipulationEvent(); // Fetch the actor we manipulated vtkSmartPointer end_matrix = vtkSmartPointer::New(); actor->GetMatrix(end_matrix); @@ -86,7 +86,7 @@ pcl::cloud_composer::SelectedTrackballStyleInteractor::OnRightButtonUp() vtkInteractorStyleTrackballActor::OnRightButtonUp(); foreach (QString id, selected_actors_map_.keys()) { vtkLODActor* actor = selected_actors_map_.value(id); - ManipulationEvent* manip_event = new ManipulationEvent(); + auto* manip_event = new ManipulationEvent(); // Fetch the actor we manipulated vtkSmartPointer end_matrix = vtkSmartPointer::New(); actor->GetMatrix(end_matrix); diff --git a/apps/cloud_composer/src/project_model.cpp b/apps/cloud_composer/src/project_model.cpp index 39963959348..d20d96f85db 100644 --- a/apps/cloud_composer/src/project_model.cpp +++ b/apps/cloud_composer/src/project_model.cpp @@ -107,7 +107,7 @@ pcl::cloud_composer::ProjectModel::setPointSelection (const std::shared_ptr project_clouds; for (int i = 0; i < this->rowCount (); ++i) { - CloudItem* cloud_item = dynamic_cast (this->item (i)); + auto* cloud_item = dynamic_cast (this->item (i)); if ( cloud_item ) project_clouds.append ( cloud_item ); } @@ -137,7 +137,7 @@ pcl::cloud_composer::ProjectModel::manipulateClouds (const std::shared_ptr project_clouds; for (int i = 0; i < this->rowCount (); ++i) { - CloudItem* cloud_item = dynamic_cast (this->item (i)); + auto* cloud_item = dynamic_cast (this->item (i)); if ( cloud_item ) project_clouds.append ( cloud_item ); } @@ -146,7 +146,7 @@ pcl::cloud_composer::ProjectModel::manipulateClouds (const std::shared_ptr ids = transform_map.keys (); ConstItemList input_data; - TransformClouds* transform_tool = new TransformClouds (transform_map); + auto* transform_tool = new TransformClouds (transform_map); foreach (CloudItem* cloud_item, project_clouds) { if (ids.contains (cloud_item->getId ())) @@ -208,7 +208,7 @@ pcl::cloud_composer::ProjectModel::insertNewCloudFromFile () } short_filename += tr ("-%1").arg (k); } - CloudItem* new_item = new CloudItem (short_filename, cloud_blob, origin, orientation, true); + auto* new_item = new CloudItem (short_filename, cloud_blob, origin, orientation, true); insertNewCloudComposerItem (new_item, invisibleRootItem()); @@ -301,7 +301,7 @@ pcl::cloud_composer::ProjectModel::insertNewCloudFromRGBandDepth () { PointXYZRGB new_point; // std::uint8_t* p_i = &(cloud_blob->data[y * cloud_blob->row_step + x * cloud_blob->point_step]); - float depth = (float)(*depth_pixel) * scale; + float depth = static_cast(*depth_pixel) * scale; // qDebug () << "Depth = "<(x - centerX)) * depth * fl_const; + new_point.y = (static_cast(centerY - y)) * depth * fl_const; // vtk seems to start at the bottom left image corner new_point.z = depth; } @@ -362,7 +362,7 @@ pcl::cloud_composer::ProjectModel::saveSelectedCloudToFile () } QStandardItem* item = this->itemFromIndex (selected_indexes.value (0)); - CloudItem* cloud_to_save = dynamic_cast (item); + auto* cloud_to_save = dynamic_cast (item); if (!cloud_to_save ) { QMessageBox::warning (qobject_cast(this->parent ()), "Not a Cloud!", "Selected item is not a cloud, not saving!"); @@ -470,7 +470,7 @@ pcl::cloud_composer::ProjectModel::deleteSelectedItems () input_data.append (dynamic_cast (item)); } // qDebug () << "Input for command is "<setInputData (input_data); if (delete_command->runCommand (nullptr)) commandCompleted(delete_command); @@ -525,7 +525,7 @@ pcl::cloud_composer::ProjectModel::createNewCloudFromSelection () QMap selected_const_map; foreach ( CloudItem* item, selected_item_index_map_.keys ()) selected_const_map.insert (item, selected_item_index_map_.value (item)); - MergeSelection* merge_tool = new MergeSelection (selected_const_map); + auto* merge_tool = new MergeSelection (selected_const_map); //We don't call the enqueueToolAction function since that would abort if we only have a green selection //Move the tool object to the work queue thread diff --git a/apps/cloud_composer/src/properties_model.cpp b/apps/cloud_composer/src/properties_model.cpp index b9daf99d721..c5e3fcc5c29 100644 --- a/apps/cloud_composer/src/properties_model.cpp +++ b/apps/cloud_composer/src/properties_model.cpp @@ -58,11 +58,11 @@ pcl::cloud_composer::PropertiesModel::addProperty(const QString& prop_name, } QList new_row; - QStandardItem* new_property = new QStandardItem(prop_name); + auto* new_property = new QStandardItem(prop_name); new_property->setFlags(Qt::ItemIsSelectable); new_row.append(new_property); - QStandardItem* new_value = new QStandardItem(); + auto* new_value = new QStandardItem(); new_value->setFlags(flags); new_value->setData(value, Qt::EditRole); new_row.append(new_value); @@ -73,7 +73,7 @@ pcl::cloud_composer::PropertiesModel::addProperty(const QString& prop_name, void pcl::cloud_composer::PropertiesModel::addCategory(const QString& category_name) { - QStandardItem* new_category = new QStandardItem(category_name); + auto* new_category = new QStandardItem(category_name); appendRow(new_category); } @@ -86,7 +86,7 @@ pcl::cloud_composer::PropertiesModel::getProperty(const QString& prop_name) cons if (items.empty()) { qWarning() << "No property named " << prop_name << " found in " << parent_item_->text(); - return QVariant(); + return {}; } if (items.size() > 1) { qWarning() << "Multiple properties found with name " << prop_name << " in " diff --git a/apps/cloud_composer/src/signal_multiplexer.cpp b/apps/cloud_composer/src/signal_multiplexer.cpp index 16612f078d4..3f9191e93bd 100644 --- a/apps/cloud_composer/src/signal_multiplexer.cpp +++ b/apps/cloud_composer/src/signal_multiplexer.cpp @@ -111,7 +111,7 @@ pcl::cloud_composer::SignalMultiplexer::setCurrentObject(QObject* newObject) for (const auto& connection : connections) connect(connection); - ProjectModel* model = dynamic_cast(newObject); + auto* model = dynamic_cast(newObject); if (model) model->emitAllStateSignals(); diff --git a/apps/cloud_composer/src/tool_interface/abstract_tool.cpp b/apps/cloud_composer/src/tool_interface/abstract_tool.cpp index 21708ef50ca..6cb6632bbf0 100644 --- a/apps/cloud_composer/src/tool_interface/abstract_tool.cpp +++ b/apps/cloud_composer/src/tool_interface/abstract_tool.cpp @@ -17,5 +17,5 @@ pcl::cloud_composer::AbstractTool::performAction(QList PointTypeFlags::PointType) { qDebug() << "AbstractTool::performTemplatedAction"; - return QList(); + return {}; } diff --git a/apps/cloud_composer/src/toolbox_model.cpp b/apps/cloud_composer/src/toolbox_model.cpp index 8e3f70bd33e..b41ee385f94 100644 --- a/apps/cloud_composer/src/toolbox_model.cpp +++ b/apps/cloud_composer/src/toolbox_model.cpp @@ -13,7 +13,7 @@ pcl::cloud_composer::ToolBoxModel::ToolBoxModel(QTreeView* tool_view, : QStandardItemModel(parent) , tool_view_(tool_view) , parameter_view_(parameter_view_) -, project_model_(nullptr) +, {} pcl::cloud_composer::ToolBoxModel::ToolBoxModel(const ToolBoxModel&) @@ -25,7 +25,7 @@ pcl::cloud_composer::ToolBoxModel::addTool(ToolFactory* tool_factory) { // qDebug () << "Icon name:"<< tool_factory->getIconName (); QIcon new_tool_icon = QIcon(tool_factory->getIconName()); - QStandardItem* new_tool_item = + auto* new_tool_item = new QStandardItem(new_tool_icon, tool_factory->getPluginName()); new_tool_item->setEditable(false); @@ -53,7 +53,7 @@ pcl::cloud_composer::ToolBoxModel::addToolGroup(const QString& tool_group_name) { QList matches_name = findItems(tool_group_name); if (matches_name.empty()) { - QStandardItem* new_group_item = new QStandardItem(tool_group_name); + auto* new_group_item = new QStandardItem(tool_group_name); appendRow(new_group_item); new_group_item->setSelectable(false); new_group_item->setEditable(false); @@ -117,8 +117,8 @@ pcl::cloud_composer::ToolBoxModel::toolAction() "Cannot execute action, no tool selected!"); return; } - ToolFactory* tool_factory = (current_index.data(FACTORY)).value(); - PropertiesModel* parameter_model = + auto* tool_factory = (current_index.data(FACTORY)).value(); + auto* parameter_model = (current_index.data(PARAMETER_MODEL)).value(); // AbstractTool* tool = tool_factory->createTool(parameter_model); @@ -166,7 +166,7 @@ pcl::cloud_composer::ToolBoxModel::updateEnabledTools( // Go through tools, removing from enabled list if they fail to pass tests while (enabled_itr.hasNext()) { QStandardItem* tool_item = enabled_itr.next(); - ToolFactory* tool_factory = (tool_item->data(FACTORY)).value(); + auto* tool_factory = (tool_item->data(FACTORY)).value(); CloudComposerItem::ItemType input_type = tool_factory->getInputItemType(); QList required_children_types = tool_factory->getRequiredInputChildrenTypes(); diff --git a/apps/cloud_composer/src/transform_clouds.cpp b/apps/cloud_composer/src/transform_clouds.cpp index cde2459a371..6f47f19b071 100644 --- a/apps/cloud_composer/src/transform_clouds.cpp +++ b/apps/cloud_composer/src/transform_clouds.cpp @@ -13,7 +13,7 @@ pcl::cloud_composer::TransformClouds::performAction(ConstItemList input_data, PointTypeFlags::PointType type) { if (type != PointTypeFlags::NONE) { - switch ((std::uint8_t)type) { + switch (static_cast(type)) { case (PointTypeFlags::XYZ): return this->performTemplatedAction(input_data); case (PointTypeFlags::XYZ | PointTypeFlags::RGB): diff --git a/apps/cloud_composer/src/work_queue.cpp b/apps/cloud_composer/src/work_queue.cpp index b8662619d0b..bf0c6305fa7 100644 --- a/apps/cloud_composer/src/work_queue.cpp +++ b/apps/cloud_composer/src/work_queue.cpp @@ -31,7 +31,7 @@ pcl::cloud_composer::WorkQueue::actionFinished(ActionPair finished_action) void pcl::cloud_composer::WorkQueue::checkQueue() { - if (work_queue_.length() > 0) { + if (!work_queue_.empty()) { ActionPair action_to_execute = work_queue_.dequeue(); if (action_to_execute.command->runCommand(action_to_execute.tool)) { // Success, send the command back to the main thread diff --git a/apps/cloud_composer/tools/euclidean_clustering.cpp b/apps/cloud_composer/tools/euclidean_clustering.cpp index 2413544ec90..bd71994c46c 100644 --- a/apps/cloud_composer/tools/euclidean_clustering.cpp +++ b/apps/cloud_composer/tools/euclidean_clustering.cpp @@ -30,14 +30,14 @@ pcl::cloud_composer::EuclideanClusteringTool::performAction(ConstItemList input_ input_item = input_data.value(0); if (input_item->type() == CloudComposerItem::CLOUD_ITEM) { - const CloudItem* cloud_item = dynamic_cast(input_item); + const auto* cloud_item = dynamic_cast(input_item); if (cloud_item->isSanitized()) { double cluster_tolerance = parameter_model_->getProperty("Cluster Tolerance").toDouble(); int min_cluster_size = parameter_model_->getProperty("Min Cluster Size").toInt(); int max_cluster_size = parameter_model_->getProperty("Max Cluster Size").toInt(); - pcl::PCLPointCloud2::ConstPtr input_cloud = + auto input_cloud = input_item->data(ItemDataRole::CLOUD_BLOB) .value(); // Get the cloud in template form @@ -60,9 +60,9 @@ pcl::cloud_composer::EuclideanClusteringTool::performAction(ConstItemList input_ ec.extract(cluster_indices); ////////////////////////////////////////////////////////////////// // Get copies of the original origin and orientation - Eigen::Vector4f source_origin = + auto source_origin = input_item->data(ItemDataRole::ORIGIN).value(); - Eigen::Quaternionf source_orientation = + auto source_orientation = input_item->data(ItemDataRole::ORIENTATION).value(); // Vector to accumulate the extracted indices pcl::IndicesPtr extracted_indices(new pcl::Indices()); @@ -85,7 +85,7 @@ pcl::cloud_composer::EuclideanClusteringTool::performAction(ConstItemList input_ filter.filter(*cloud_filtered); qDebug() << "Cluster has " << cloud_filtered->width << " data points."; - CloudItem* cloud_item = + auto* cloud_item = new CloudItem(input_item->text() + tr("-Clstr %1").arg(cluster_count), cloud_filtered, source_origin, @@ -104,7 +104,7 @@ pcl::cloud_composer::EuclideanClusteringTool::performAction(ConstItemList input_ } qDebug() << "Cloud has " << remainder_cloud->width << " data points after clusters removed."; - CloudItem* cloud_item = new CloudItem(input_item->text() + " unclustered", + auto* cloud_item = new CloudItem(input_item->text() + " unclustered", remainder_cloud, source_origin, source_orientation); @@ -125,7 +125,7 @@ pcl::cloud_composer::PropertiesModel* pcl::cloud_composer::EuclideanClusteringToolFactory::createToolParameterModel( QObject* parent) { - PropertiesModel* parameter_model = new PropertiesModel(parent); + auto* parameter_model = new PropertiesModel(parent); parameter_model->addProperty( "Cluster Tolerance", 0.02, Qt::ItemIsEditable | Qt::ItemIsEnabled); diff --git a/apps/cloud_composer/tools/fpfh_estimation.cpp b/apps/cloud_composer/tools/fpfh_estimation.cpp index 9366754584b..6eac73aeee9 100644 --- a/apps/cloud_composer/tools/fpfh_estimation.cpp +++ b/apps/cloud_composer/tools/fpfh_estimation.cpp @@ -99,7 +99,7 @@ pcl::cloud_composer::PropertiesModel* pcl::cloud_composer::FPFHEstimationToolFactory::createToolParameterModel( QObject* parent) { - PropertiesModel* parameter_model = new PropertiesModel(parent); + auto* parameter_model = new PropertiesModel(parent); parameter_model->addProperty("Radius", 0.03, Qt::ItemIsEditable | Qt::ItemIsEnabled); diff --git a/apps/cloud_composer/tools/normal_estimation.cpp b/apps/cloud_composer/tools/normal_estimation.cpp index ddef0a393ed..4994c0b3115 100644 --- a/apps/cloud_composer/tools/normal_estimation.cpp +++ b/apps/cloud_composer/tools/normal_estimation.cpp @@ -30,7 +30,7 @@ pcl::cloud_composer::NormalEstimationTool::performAction(ConstItemList input_dat if (input_item->type() == CloudComposerItem::CLOUD_ITEM) { double radius = parameter_model_->getProperty("Radius").toDouble(); qDebug() << "Received Radius = " << radius; - pcl::PCLPointCloud2::ConstPtr input_cloud = + auto input_cloud = input_item->data(ItemDataRole::CLOUD_BLOB) .value(); qDebug() << "Got cloud size = " << input_cloud->width; @@ -57,7 +57,7 @@ pcl::cloud_composer::NormalEstimationTool::performAction(ConstItemList input_dat // Compute the features ne.compute(*cloud_normals); ////////////////////////////////////////////////////////////////// - NormalsItem* normals_item = + auto* normals_item = new NormalsItem(tr("Normals r=%1").arg(radius), cloud_normals, radius); output.append(normals_item); qDebug() << "Calced normals"; @@ -74,7 +74,7 @@ pcl::cloud_composer::PropertiesModel* pcl::cloud_composer::NormalEstimationToolFactory::createToolParameterModel( QObject* parent) { - PropertiesModel* parameter_model = new PropertiesModel(parent); + auto* parameter_model = new PropertiesModel(parent); parameter_model->addProperty("Radius", 0.04, Qt::ItemIsEditable | Qt::ItemIsEnabled); diff --git a/apps/cloud_composer/tools/organized_segmentation.cpp b/apps/cloud_composer/tools/organized_segmentation.cpp index 73679e871d3..587e127a52a 100644 --- a/apps/cloud_composer/tools/organized_segmentation.cpp +++ b/apps/cloud_composer/tools/organized_segmentation.cpp @@ -18,7 +18,7 @@ pcl::cloud_composer::OrganizedSegmentationTool::performAction( ConstItemList input_data, PointTypeFlags::PointType type) { if (type != PointTypeFlags::NONE) { - switch ((std::uint8_t)type) { + switch (static_cast(type)) { case (PointTypeFlags::XYZ): return this->performTemplatedAction(input_data); case (PointTypeFlags::XYZ | PointTypeFlags::RGB): @@ -40,7 +40,7 @@ pcl::cloud_composer::PropertiesModel* pcl::cloud_composer::OrganizedSegmentationToolFactory::createToolParameterModel( QObject* parent) { - PropertiesModel* parameter_model = new PropertiesModel(parent); + auto* parameter_model = new PropertiesModel(parent); parameter_model->addProperty( "Min Inliers", 1000, Qt::ItemIsEditable | Qt::ItemIsEnabled); diff --git a/apps/cloud_composer/tools/sanitize_cloud.cpp b/apps/cloud_composer/tools/sanitize_cloud.cpp index 90d371954cd..e0f990d7a4c 100644 --- a/apps/cloud_composer/tools/sanitize_cloud.cpp +++ b/apps/cloud_composer/tools/sanitize_cloud.cpp @@ -24,7 +24,7 @@ pcl::cloud_composer::SanitizeCloudTool::performAction(ConstItemList input_data, input_item = input_data.value(0); if (input_item->type() == CloudComposerItem::CLOUD_ITEM) { - pcl::PCLPointCloud2::ConstPtr input_cloud = + auto input_cloud = input_item->data(ItemDataRole::CLOUD_BLOB) .value(); @@ -43,12 +43,12 @@ pcl::cloud_composer::SanitizeCloudTool::performAction(ConstItemList input_data, ////////////////////////////////////////////////////////////////// // Get copies of the original origin and orientation - Eigen::Vector4f source_origin = + auto source_origin = input_item->data(ItemDataRole::ORIGIN).value(); - Eigen::Quaternionf source_orientation = + auto source_orientation = input_item->data(ItemDataRole::ORIENTATION).value(); // Put the modified cloud into an item, stick in output - CloudItem* cloud_item = new CloudItem(input_item->text() + tr(" sanitized"), + auto* cloud_item = new CloudItem(input_item->text() + tr(" sanitized"), cloud_filtered, source_origin, source_orientation); @@ -66,7 +66,7 @@ pcl::cloud_composer::SanitizeCloudTool::performAction(ConstItemList input_data, pcl::cloud_composer::PropertiesModel* pcl::cloud_composer::SanitizeCloudToolFactory::createToolParameterModel(QObject* parent) { - PropertiesModel* parameter_model = new PropertiesModel(parent); + auto* parameter_model = new PropertiesModel(parent); parameter_model->addProperty( "Keep Organized", false, Qt::ItemIsEditable | Qt::ItemIsEnabled); diff --git a/apps/cloud_composer/tools/statistical_outlier_removal.cpp b/apps/cloud_composer/tools/statistical_outlier_removal.cpp index d67426016a9..c8d4b4ddd41 100644 --- a/apps/cloud_composer/tools/statistical_outlier_removal.cpp +++ b/apps/cloud_composer/tools/statistical_outlier_removal.cpp @@ -32,7 +32,7 @@ pcl::cloud_composer::StatisticalOutlierRemovalTool::performAction( } if (input_item->type() == CloudComposerItem::CLOUD_ITEM) { - pcl::PCLPointCloud2::ConstPtr input_cloud = + auto input_cloud = input_item->data(ItemDataRole::CLOUD_BLOB) .value(); @@ -53,12 +53,12 @@ pcl::cloud_composer::StatisticalOutlierRemovalTool::performAction( ////////////////////////////////////////////////////////////////// // Get copies of the original origin and orientation - Eigen::Vector4f source_origin = + auto source_origin = input_item->data(ItemDataRole::ORIGIN).value(); - Eigen::Quaternionf source_orientation = + auto source_orientation = input_item->data(ItemDataRole::ORIENTATION).value(); // Put the modified cloud into an item, stick in output - CloudItem* cloud_item = new CloudItem(input_item->text() + tr(" sor filtered"), + auto* cloud_item = new CloudItem(input_item->text() + tr(" sor filtered"), cloud_filtered, source_origin, source_orientation); @@ -77,7 +77,7 @@ pcl::cloud_composer::PropertiesModel* pcl::cloud_composer::StatisticalOutlierRemovalToolFactory::createToolParameterModel( QObject* parent) { - PropertiesModel* parameter_model = new PropertiesModel(parent); + auto* parameter_model = new PropertiesModel(parent); parameter_model->addProperty("Mean K", 50, Qt::ItemIsEditable | Qt::ItemIsEnabled); parameter_model->addProperty( diff --git a/apps/cloud_composer/tools/supervoxels.cpp b/apps/cloud_composer/tools/supervoxels.cpp index 853a32e2555..10ea5ba46fe 100644 --- a/apps/cloud_composer/tools/supervoxels.cpp +++ b/apps/cloud_composer/tools/supervoxels.cpp @@ -18,7 +18,7 @@ pcl::cloud_composer::SupervoxelsTool::performAction(ConstItemList input_data, PointTypeFlags::PointType type) { if (type != PointTypeFlags::NONE) { - switch ((std::uint8_t)type) { + switch (static_cast(type)) { case (PointTypeFlags::XYZ | PointTypeFlags::RGB): return this->performTemplatedAction(input_data); case (PointTypeFlags::XYZ | PointTypeFlags::RGBA): @@ -44,7 +44,7 @@ pcl::cloud_composer::SupervoxelsTool::performTemplatedAction( pcl::cloud_composer::PropertiesModel* pcl::cloud_composer::SupervoxelsToolFactory::createToolParameterModel(QObject* parent) { - PropertiesModel* parameter_model = new PropertiesModel(parent); + auto* parameter_model = new PropertiesModel(parent); parameter_model->addProperty( "Resolution", 0.008, Qt::ItemIsEditable | Qt::ItemIsEnabled); diff --git a/apps/cloud_composer/tools/voxel_grid_downsample.cpp b/apps/cloud_composer/tools/voxel_grid_downsample.cpp index 3590c273d32..0a3de9e2e85 100644 --- a/apps/cloud_composer/tools/voxel_grid_downsample.cpp +++ b/apps/cloud_composer/tools/voxel_grid_downsample.cpp @@ -31,7 +31,7 @@ pcl::cloud_composer::VoxelGridDownsampleTool::performAction(ConstItemList input_ double leaf_y = parameter_model_->getProperty("Leaf Size y").toDouble(); double leaf_z = parameter_model_->getProperty("Leaf Size z").toDouble(); - pcl::PCLPointCloud2::ConstPtr input_cloud = + auto input_cloud = input_item->data(ItemDataRole::CLOUD_BLOB) .value(); @@ -39,7 +39,7 @@ pcl::cloud_composer::VoxelGridDownsampleTool::performAction(ConstItemList input_ // Create the filtering object pcl::VoxelGrid vox_grid; vox_grid.setInputCloud(input_cloud); - vox_grid.setLeafSize(float(leaf_x), float(leaf_y), float(leaf_z)); + vox_grid.setLeafSize(static_cast(leaf_x), static_cast(leaf_y), static_cast(leaf_z)); // Create output cloud pcl::PCLPointCloud2::Ptr cloud_filtered(new pcl::PCLPointCloud2); @@ -48,12 +48,12 @@ pcl::cloud_composer::VoxelGridDownsampleTool::performAction(ConstItemList input_ ////////////////////////////////////////////////////////////////// // Get copies of the original origin and orientation - Eigen::Vector4f source_origin = + auto source_origin = input_item->data(ItemDataRole::ORIGIN).value(); - Eigen::Quaternionf source_orientation = + auto source_orientation = input_item->data(ItemDataRole::ORIENTATION).value(); // Put the modified cloud into an item, stick in output - CloudItem* cloud_item = new CloudItem(input_item->text() + tr(" vox ds"), + auto* cloud_item = new CloudItem(input_item->text() + tr(" vox ds"), cloud_filtered, source_origin, source_orientation); @@ -72,7 +72,7 @@ pcl::cloud_composer::PropertiesModel* pcl::cloud_composer::VoxelGridDownsampleToolFactory::createToolParameterModel( QObject* parent) { - PropertiesModel* parameter_model = new PropertiesModel(parent); + auto* parameter_model = new PropertiesModel(parent); parameter_model->addProperty( "Leaf Size x", 0.01, Qt::ItemIsEditable | Qt::ItemIsEnabled); diff --git a/apps/in_hand_scanner/include/pcl/apps/in_hand_scanner/icp.h b/apps/in_hand_scanner/include/pcl/apps/in_hand_scanner/icp.h index 7496c578f0a..81cf85dddea 100644 --- a/apps/in_hand_scanner/include/pcl/apps/in_hand_scanner/icp.h +++ b/apps/in_hand_scanner/include/pcl/apps/in_hand_scanner/icp.h @@ -224,16 +224,16 @@ class PCL_EXPORTS ICP { KdTreePtr kd_tree_; // Convergence - float epsilon_; // in cm^2 + float epsilon_{10e-6f}; // in cm^2 // Registration failure - unsigned int max_iterations_; - float min_overlap_; // [0 1] - float max_fitness_; // in cm^2 + unsigned int max_iterations_{50}; + float min_overlap_{.75f}; // [0 1] + float max_fitness_{.1f}; // in cm^2 // Correspondence rejection - float factor_; - float max_angle_; // in degrees + float factor_{9.f}; + float max_angle_{45.f}; // in degrees }; } // End namespace ihs } // End namespace pcl diff --git a/apps/in_hand_scanner/include/pcl/apps/in_hand_scanner/impl/common_types.hpp b/apps/in_hand_scanner/include/pcl/apps/in_hand_scanner/impl/common_types.hpp index 17900bf5347..6960bd0c640 100644 --- a/apps/in_hand_scanner/include/pcl/apps/in_hand_scanner/impl/common_types.hpp +++ b/apps/in_hand_scanner/include/pcl/apps/in_hand_scanner/impl/common_types.hpp @@ -79,7 +79,7 @@ struct PointIHS : public pcl::ihs::_PointIHS { } inline PointIHS(const PointIHS& other) - { + : _PointIHS(other) { this->x = other.x; this->y = other.y; this->z = other.z; diff --git a/apps/in_hand_scanner/include/pcl/apps/in_hand_scanner/in_hand_scanner.h b/apps/in_hand_scanner/include/pcl/apps/in_hand_scanner/in_hand_scanner.h index b3d2abcf9e3..3d1fd916237 100644 --- a/apps/in_hand_scanner/include/pcl/apps/in_hand_scanner/in_hand_scanner.h +++ b/apps/in_hand_scanner/include/pcl/apps/in_hand_scanner/in_hand_scanner.h @@ -190,7 +190,7 @@ public Q_SLOTS: * \note The extension of the filename is ignored! */ void - saveAs(const std::string& filename, const FileType& filetype); + saveAs(const std::string& filename, const FileType& filetype) const; /** \see http://doc.qt.digia.com/qt/qwidget.html#keyPressEvent */ void @@ -272,16 +272,16 @@ public Q_SLOTS: VisualizationFPS visualization_fps_; /** \brief Switch between different branches of the scanning pipeline. */ - RunningMode running_mode_; + RunningMode running_mode_{RM_UNPROCESSED}; /** \brief The iteration of the scanning pipeline (grab - register - integrate). */ - unsigned int iteration_; + unsigned int iteration_{0}; /** \brief Used to get new data from the sensor. */ GrabberPtr grabber_; /** \brief This variable is true if the grabber is starting. */ - bool starting_grabber_; + bool starting_grabber_{false}; /** \brief Connection of the grabber signal with the data processing thread. */ boost::signals2::connection new_data_connection_; @@ -305,7 +305,7 @@ public Q_SLOTS: MeshPtr mesh_model_; /** \brief Prevent the application to crash while closing. */ - bool destructor_called_; + bool destructor_called_{false}; public: PCL_MAKE_ALIGNED_OPERATOR_NEW diff --git a/apps/in_hand_scanner/include/pcl/apps/in_hand_scanner/input_data_processing.h b/apps/in_hand_scanner/include/pcl/apps/in_hand_scanner/input_data_processing.h index 6c238fde75b..dcb8c3e06e3 100644 --- a/apps/in_hand_scanner/include/pcl/apps/in_hand_scanner/input_data_processing.h +++ b/apps/in_hand_scanner/include/pcl/apps/in_hand_scanner/input_data_processing.h @@ -350,25 +350,25 @@ class PCL_EXPORTS InputDataProcessing { NormalEstimationPtr normal_estimation_; - float x_min_; - float x_max_; - float y_min_; - float y_max_; - float z_min_; - float z_max_; + float x_min_{-15.f}; + float x_max_{15.f}; + float y_min_{-15.f}; + float y_max_{15.f}; + float z_min_{48.f}; + float z_max_{70.f}; - float h_min_; - float h_max_; - float s_min_; - float s_max_; - float v_min_; - float v_max_; + float h_min_{210.f}; + float h_max_{270.f}; + float s_min_{0.2f}; + float s_max_{1.f}; + float v_min_{0.2f}; + float v_max_{1.f}; - bool hsv_inverted_; - bool hsv_enabled_; + bool hsv_inverted_{false}; + bool hsv_enabled_{true}; - unsigned int size_dilate_; - unsigned int size_erode_; + unsigned int size_dilate_{3}; + unsigned int size_erode_{3}; }; } // End namespace ihs } // End namespace pcl diff --git a/apps/in_hand_scanner/include/pcl/apps/in_hand_scanner/integration.h b/apps/in_hand_scanner/include/pcl/apps/in_hand_scanner/integration.h index 4c7b37e6dbb..ce67a66bd61 100644 --- a/apps/in_hand_scanner/include/pcl/apps/in_hand_scanner/integration.h +++ b/apps/in_hand_scanner/include/pcl/apps/in_hand_scanner/integration.h @@ -229,25 +229,25 @@ class PCL_EXPORTS Integration { KdTreePtr kd_tree_; /** \brief Maximum squared distance below which points are averaged out. */ - float max_squared_distance_; + float max_squared_distance_{0.04f}; /** \brief Maximum angle between normals below which points are averaged out. In * degrees. */ - float max_angle_; + float max_angle_{45.f}; /** \brief Minimum weight above which points are added. */ - float min_weight_; + float min_weight_{.3f}; /** \brief Once a point reaches the maximum age it is decided if the point is removed * or kept in the mesh. */ - unsigned int max_age_; + unsigned int max_age_{30}; /** \brief A point is removed if it has not been observed from a minimum number of * directions. */ - unsigned int min_directions_; + unsigned int min_directions_{5}; }; } // End namespace ihs } // End namespace pcl diff --git a/apps/in_hand_scanner/include/pcl/apps/in_hand_scanner/offline_integration.h b/apps/in_hand_scanner/include/pcl/apps/in_hand_scanner/offline_integration.h index ed5b3490467..39136570d96 100644 --- a/apps/in_hand_scanner/include/pcl/apps/in_hand_scanner/offline_integration.h +++ b/apps/in_hand_scanner/include/pcl/apps/in_hand_scanner/offline_integration.h @@ -213,7 +213,7 @@ private Q_SLOTS: IntegrationPtr integration_; /** \brief Prevent the application to crash while closing. */ - bool destructor_called_; + bool destructor_called_{false}; public: PCL_MAKE_ALIGNED_OPERATOR_NEW diff --git a/apps/in_hand_scanner/include/pcl/apps/in_hand_scanner/opengl_viewer.h b/apps/in_hand_scanner/include/pcl/apps/in_hand_scanner/opengl_viewer.h index 4ce4e7ca95a..4ac2bacd862 100644 --- a/apps/in_hand_scanner/include/pcl/apps/in_hand_scanner/opengl_viewer.h +++ b/apps/in_hand_scanner/include/pcl/apps/in_hand_scanner/opengl_viewer.h @@ -302,7 +302,7 @@ public Q_SLOTS: /** \brief Please have a look at the documentation of calcFPS. */ class FPS { public: - FPS() : fps_(0.) {} + FPS() : {} inline double& value() @@ -327,7 +327,7 @@ public Q_SLOTS: ~FPS() = default; private: - double fps_; + double fps_{0.}; }; /** Measures the performance of the current thread (selected by passing the @@ -391,7 +391,7 @@ public Q_SLOTS: /** \brief Draw a wireframe box. */ void - drawBox(); + drawBox() const; /** \see http://doc.qt.digia.com/qt/qglwidget.html#initializeGL */ void @@ -431,25 +431,25 @@ public Q_SLOTS: Colormap colormap_; /** \brief The visibility confidence is normalized with this value. */ - float vis_conf_norm_; + float vis_conf_norm_{1}; /** \brief Meshes stored for visualization. */ FaceVertexMeshMap drawn_meshes_; /** \brief How to draw the mesh. */ - MeshRepresentation mesh_representation_; + MeshRepresentation mesh_representation_{MR_POINTS}; /** \brief How to color the shapes. */ - Coloring coloring_; + Coloring coloring_{COL_RGB}; /** \brief A box is drawn if this value is true. */ - bool draw_box_; + bool draw_box_{false}; /** \brief Coefficients of the drawn box. */ BoxCoefficients box_coefficients_; /** \brief Scaling factor to convert from meters to the unit of the drawn files. */ - double scaling_factor_; + double scaling_factor_{1.}; /** \brief Rotation of the camera. */ Eigen::Quaterniond R_cam_; @@ -465,13 +465,13 @@ public Q_SLOTS: /** \brief Set to true right after the mouse got pressed and false if the mouse got * moved. */ - bool mouse_pressed_begin_; + bool mouse_pressed_begin_{false}; /** \brief Mouse x-position of the previous mouse move event. */ - int x_prev_; + int x_prev_{0}; /** \brief Mouse y-position of the previous mouse move event. */ - int y_prev_; + int y_prev_{0}; public: PCL_MAKE_ALIGNED_OPERATOR_NEW diff --git a/apps/in_hand_scanner/src/icp.cpp b/apps/in_hand_scanner/src/icp.cpp index cbd16668eaa..26ce9b2bb52 100644 --- a/apps/in_hand_scanner/src/icp.cpp +++ b/apps/in_hand_scanner/src/icp.cpp @@ -55,14 +55,8 @@ pcl::ihs::ICP::ICP() : kd_tree_(new pcl::KdTreeFLANN()) , -epsilon_(10e-6f) -, max_iterations_(50) -, min_overlap_(.75f) -, max_fitness_(.1f) -, -factor_(9.f) -, max_angle_(45.f) + {} //////////////////////////////////////////////////////////////////////////////// @@ -232,7 +226,7 @@ pcl::ihs::ICP::findTransformation(const MeshConstPtr& mesh_model, cloud_model_corr.clear(); cloud_data_corr.clear(); sw.reset(); - for (CloudNormal::const_iterator it_d = cloud_data_selected->begin(); + for (auto it_d = cloud_data_selected->begin(); it_d != cloud_data_selected->end(); ++it_d) { // Transform the data point @@ -248,7 +242,7 @@ pcl::ihs::ICP::findTransformation(const MeshConstPtr& mesh_model, // Check the distance threshold if (squared_distance[0] < squared_distance_threshold) { - if ((std::size_t)index[0] >= cloud_model_selected->size()) { + if (static_cast(index[0]) >= cloud_model_selected->size()) { std::cerr << "ERROR in icp.cpp: Segfault!\n"; std::cerr << " Trying to access index " << index[0] << " >= " << cloud_model_selected->size() << std::endl; @@ -462,8 +456,8 @@ pcl::ihs::ICP::minimizePointPlane(const CloudNormal& cloud_source, xyz_t.reserve(n); nor_t.reserve(n); - CloudNormal::const_iterator it_s = cloud_source.begin(); - CloudNormal::const_iterator it_t = cloud_target.begin(); + auto it_s = cloud_source.begin(); + auto it_t = cloud_target.begin(); float accum = 0.f; Eigen::Vector4f pt_s, pt_t; @@ -474,7 +468,7 @@ pcl::ihs::ICP::minimizePointPlane(const CloudNormal& cloud_source, xyz_s.push_back(pt_s); xyz_t.push_back(pt_t); - nor_t.push_back(it_t->getNormalVector4fMap()); + nor_t.emplace_back(it_t->getNormalVector4fMap()); // Calculate the radius (L2 norm) of the bounding sphere through both shapes and // accumulate the average @@ -502,9 +496,9 @@ pcl::ihs::ICP::minimizePointPlane(const CloudNormal& cloud_source, Eigen::Vector4f b_t = Eigen::Vector4f::Zero(); // top Eigen::Vector4f b_b = Eigen::Vector4f::Zero(); // bottom - Vec4Xf::const_iterator it_xyz_s = xyz_s.begin(); - Vec4Xf::const_iterator it_xyz_t = xyz_t.begin(); - Vec4Xf::const_iterator it_nor_t = nor_t.begin(); + auto it_xyz_s = xyz_s.begin(); + auto it_xyz_t = xyz_t.begin(); + auto it_nor_t = nor_t.begin(); Eigen::Vector4f cross; for (; it_xyz_s != xyz_s.end(); ++it_xyz_s, ++it_xyz_t, ++it_nor_t) { diff --git a/apps/in_hand_scanner/src/in_hand_scanner.cpp b/apps/in_hand_scanner/src/in_hand_scanner.cpp index 95d2744c610..b8506c81541 100644 --- a/apps/in_hand_scanner/src/in_hand_scanner.cpp +++ b/apps/in_hand_scanner/src/in_hand_scanner.cpp @@ -62,16 +62,14 @@ pcl::ihs::InHandScanner::InHandScanner(Base* parent) : Base(parent) -, running_mode_(RM_UNPROCESSED) -, iteration_(0) -, starting_grabber_(false) -, input_data_processing_(new InputDataProcessing()) +, + input_data_processing_(new InputDataProcessing()) , icp_(new ICP()) , transformation_(Eigen::Matrix4f::Identity()) , integration_(new Integration()) , mesh_processing_(new MeshProcessing()) , mesh_model_(new Mesh()) -, destructor_called_(false) +, { // http://doc.qt.digia.com/qt/qmetatype.html#qRegisterMetaType qRegisterMetaType("RunningMode"); @@ -241,7 +239,7 @@ pcl::ihs::InHandScanner::reset() //////////////////////////////////////////////////////////////////////////////// void -pcl::ihs::InHandScanner::saveAs(const std::string& filename, const FileType& filetype) +pcl::ihs::InHandScanner::saveAs(const std::string& filename, const FileType& filetype) const { std::lock_guard lock(mutex_); if (destructor_called_) diff --git a/apps/in_hand_scanner/src/input_data_processing.cpp b/apps/in_hand_scanner/src/input_data_processing.cpp index 748d7da5955..59b0a03c848 100644 --- a/apps/in_hand_scanner/src/input_data_processing.cpp +++ b/apps/in_hand_scanner/src/input_data_processing.cpp @@ -46,22 +46,8 @@ pcl::ihs::InputDataProcessing::InputDataProcessing() : normal_estimation_(new NormalEstimation()) -, x_min_(-15.f) -, x_max_(15.f) -, y_min_(-15.f) -, y_max_(15.f) -, z_min_(48.f) -, z_max_(70.f) -, h_min_(210.f) -, h_max_(270.f) -, s_min_(0.2f) -, s_max_(1.f) -, v_min_(0.2f) -, v_max_(1.f) -, hsv_inverted_(false) -, hsv_enabled_(true) -, size_dilate_(3) -, size_erode_(3) +, + { // Normal estimation normal_estimation_->setNormalEstimationMethod(NormalEstimation::AVERAGE_3D_GRADIENT); @@ -220,8 +206,8 @@ pcl::ihs::InputDataProcessing::calculateNormals(const CloudXYZRGBAConstPtr& clou cloud_out->height = cloud_in->height; cloud_out->is_dense = false; - CloudNormals::const_iterator it_n = cloud_normals->begin(); - CloudXYZRGBNormal::iterator it_out = cloud_out->begin(); + auto it_n = cloud_normals->begin(); + auto it_out = cloud_out->begin(); PointXYZRGBNormal invalid_pt; invalid_pt.x = invalid_pt.y = invalid_pt.z = std::numeric_limits::quiet_NaN(); diff --git a/apps/in_hand_scanner/src/integration.cpp b/apps/in_hand_scanner/src/integration.cpp index 3d7517ac145..8a8686f15ba 100644 --- a/apps/in_hand_scanner/src/integration.cpp +++ b/apps/in_hand_scanner/src/integration.cpp @@ -51,12 +51,8 @@ pcl::ihs::Integration::Integration() : kd_tree_(new pcl::KdTreeFLANN()) -, max_squared_distance_(0.04f) -, // 0.2cm -max_angle_(45.f) -, min_weight_(.3f) -, max_age_(30) -, min_directions_(5) +, + {} //////////////////////////////////////////////////////////////////////////////// @@ -506,7 +502,7 @@ pcl::ihs::Integration::addToMesh(const PointIHS& pt_0, // 2 - 1 // | | // 3 - 0 - const unsigned char is_finite = + const auto is_finite = static_cast((1 * !std::isnan(pt_0.x)) | (2 * !std::isnan(pt_1.x)) | (4 * !std::isnan(pt_2.x)) | (8 * !std::isnan(pt_3.x))); diff --git a/apps/in_hand_scanner/src/main_window.cpp b/apps/in_hand_scanner/src/main_window.cpp index d97e9c14bb9..c2d62ce20de 100644 --- a/apps/in_hand_scanner/src/main_window.cpp +++ b/apps/in_hand_scanner/src/main_window.cpp @@ -66,14 +66,14 @@ pcl::ihs::MainWindow::MainWindow(QWidget* parent) { ui_->setupUi(this); - QWidget* spacer = new QWidget(); + auto* spacer = new QWidget(); spacer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); ui_->toolBar->insertWidget(ui_->actionHelp, spacer); constexpr double max = std::numeric_limits::max(); // In hand scanner - QHBoxLayout* layout = new QHBoxLayout(ui_->placeholder_in_hand_scanner); + auto* layout = new QHBoxLayout(ui_->placeholder_in_hand_scanner); layout->addWidget(ihs_); // ui_->centralWidget->setLayout (layout); diff --git a/apps/in_hand_scanner/src/offline_integration.cpp b/apps/in_hand_scanner/src/offline_integration.cpp index 9de7bee7fb6..31c22d64f61 100644 --- a/apps/in_hand_scanner/src/offline_integration.cpp +++ b/apps/in_hand_scanner/src/offline_integration.cpp @@ -64,7 +64,7 @@ pcl::ihs::OfflineIntegration::OfflineIntegration(Base* parent) , mesh_model_(new Mesh()) , normal_estimation_(new NormalEstimation()) , integration_(new Integration()) -, destructor_called_(false) +, { normal_estimation_->setNormalEstimationMethod(NormalEstimation::AVERAGE_3D_GRADIENT); normal_estimation_->setMaxDepthChangeFactor(0.02f); // in meters diff --git a/apps/in_hand_scanner/src/opengl_viewer.cpp b/apps/in_hand_scanner/src/opengl_viewer.cpp index 2002d50276a..9b1b1f020ae 100644 --- a/apps/in_hand_scanner/src/opengl_viewer.cpp +++ b/apps/in_hand_scanner/src/opengl_viewer.cpp @@ -63,9 +63,9 @@ // FaceVertexMesh //////////////////////////////////////////////////////////////////////////////// -pcl::ihs::detail::FaceVertexMesh::FaceVertexMesh() + : transformation(Eigen::Isometry3d::Identity()) -{} += default; //////////////////////////////////////////////////////////////////////////////// @@ -105,18 +105,12 @@ pcl::ihs::OpenGLViewer::OpenGLViewer(QWidget* parent) : QOpenGLWidget(parent) , timer_vis_(new QTimer(this)) , colormap_(Colormap::Constant(255)) -, vis_conf_norm_(1) -, mesh_representation_(MR_POINTS) -, coloring_(COL_RGB) -, draw_box_(false) -, scaling_factor_(1.) -, R_cam_(1., 0., 0., 0.) +, + R_cam_(1., 0., 0., 0.) , t_cam_(0., 0., 0.) , cam_pivot_(0., 0., 0.) -, cam_pivot_id_("") -, mouse_pressed_begin_(false) -, x_prev_(0) -, y_prev_(0) +, + { // Timer: Defines the update rate for the visualization connect(timer_vis_.get(), SIGNAL(timeout()), this, SLOT(timerCallback())); @@ -660,7 +654,7 @@ pcl::ihs::OpenGLViewer::setVisibilityConfidenceNormalization(const float vis_con QSize pcl::ihs::OpenGLViewer::minimumSizeHint() const { - return (QSize(160, 120)); + return ({160, 120}); } //////////////////////////////////////////////////////////////////////////////// @@ -668,7 +662,7 @@ pcl::ihs::OpenGLViewer::minimumSizeHint() const QSize pcl::ihs::OpenGLViewer::sizeHint() const { - return (QSize(640, 480)); + return ({640, 480}); } //////////////////////////////////////////////////////////////////////////////// @@ -971,7 +965,7 @@ pcl::ihs::OpenGLViewer::drawMeshes() case COL_VISCONF: { for (std::size_t i = 0; i < mesh.vertices.size(); ++i) { const unsigned int n = pcl::ihs::countDirections(mesh.vertices[i].directions); - const unsigned int index = + const auto index = static_cast(static_cast(colormap_.cols()) * static_cast(n) / vis_conf_norm_); @@ -996,7 +990,7 @@ pcl::ihs::OpenGLViewer::drawMeshes() glDrawElements(GL_TRIANGLES, 3 * mesh.triangles.size(), GL_UNSIGNED_INT, - &mesh.triangles[0]); + mesh.triangles.data()); break; } } @@ -1014,7 +1008,7 @@ pcl::ihs::OpenGLViewer::drawMeshes() //////////////////////////////////////////////////////////////////////////////// void -pcl::ihs::OpenGLViewer::drawBox() +pcl::ihs::OpenGLViewer::drawBox() const { BoxCoefficients coeffs; { diff --git a/apps/include/pcl/apps/face_detection/openni_frame_source.h b/apps/include/pcl/apps/face_detection/openni_frame_source.h index 1fe6f4aacfb..b78cbea047b 100644 --- a/apps/include/pcl/apps/face_detection/openni_frame_source.h +++ b/apps/include/pcl/apps/face_detection/openni_frame_source.h @@ -31,9 +31,9 @@ class PCL_EXPORTS OpenNIFrameSource { pcl::OpenNIGrabber grabber_; PointCloudPtr most_recent_frame_; - int frame_counter_; + int frame_counter_{0}; std::mutex mutex_; - bool active_; + bool active_{true}; }; } // namespace OpenNIFrameSource diff --git a/apps/include/pcl/apps/impl/dominant_plane_segmentation.hpp b/apps/include/pcl/apps/impl/dominant_plane_segmentation.hpp index 119c9f3b9d2..51aa9bc50c0 100644 --- a/apps/include/pcl/apps/impl/dominant_plane_segmentation.hpp +++ b/apps/include/pcl/apps/impl/dominant_plane_segmentation.hpp @@ -313,8 +313,8 @@ pcl::apps::DominantPlaneSegmentation::compute_fast( { int wsize = wsize_; - for (int i = 0; i < int(binary_cloud->width); i++) { - for (int j = 0; j < int(binary_cloud->height); j++) { + for (int i = 0; i < static_cast(binary_cloud->width); i++) { + for (int j = 0; j < static_cast(binary_cloud->height); j++) { if (binary_cloud->at(i, j).intensity != 0) { // check neighboring pixels, first left and then top // be aware of margins @@ -473,8 +473,8 @@ pcl::apps::DominantPlaneSegmentation::compute_fast( { std::map::iterator it; - for (int i = 0; i < int(binary_cloud->width); i++) { - for (int j = 0; j < int(binary_cloud->height); j++) { + for (int i = 0; i < static_cast(binary_cloud->width); i++) { + for (int j = 0; j < static_cast(binary_cloud->height); j++) { if (binary_cloud->at(i, j).intensity != 0) { // check if this is a root label... it = connected_labels.find(binary_cloud->at(i, j).intensity); @@ -504,7 +504,7 @@ pcl::apps::DominantPlaneSegmentation::compute_fast( int k = 0; for (const auto& cluster : clusters_map) { - if (int(cluster.second.indices.size()) >= object_cluster_min_size_) { + if (static_cast(cluster.second.indices.size()) >= object_cluster_min_size_) { clusters[k] = CloudPtr(new Cloud()); pcl::copyPointCloud(*input_, cluster.second.indices, *clusters[k]); diff --git a/apps/include/pcl/apps/nn_classification.h b/apps/include/pcl/apps/nn_classification.h index d1dc06dad69..3783c1c3b07 100644 --- a/apps/include/pcl/apps/nn_classification.h +++ b/apps/include/pcl/apps/nn_classification.h @@ -284,7 +284,7 @@ class NNClassification { std::make_shared, std::vector>>(); result->first.reserve(classes_.size()); result->second.reserve(classes_.size()); - for (std::vector::const_iterator it = sqr_distances->begin(); + for (auto it = sqr_distances->begin(); it != sqr_distances->end(); ++it) if (*it != std::numeric_limits::max()) { @@ -322,7 +322,7 @@ class NNClassification { std::make_shared, std::vector>>(); result->first.reserve(classes_.size()); result->second.reserve(classes_.size()); - for (std::vector::const_iterator it = sqr_distances->begin(); + for (auto it = sqr_distances->begin(); it != sqr_distances->end(); ++it) if (*it != std::numeric_limits::max()) { diff --git a/apps/include/pcl/apps/openni_passthrough.h b/apps/include/pcl/apps/openni_passthrough.h index 94087404a8e..79ab77bde9f 100644 --- a/apps/include/pcl/apps/openni_passthrough.h +++ b/apps/include/pcl/apps/openni_passthrough.h @@ -54,7 +54,7 @@ double now = pcl::getTime(); \ ++count; \ if (now - last >= 1.0) { \ - std::cout << "Average framerate(" << _WHAT_ << "): " \ + std::cout << "Average framerate(" << ((_WHAT_)) << "): " \ << double(count) / double(now - last) << " Hz" << std::endl; \ count = 0; \ last = now; \ diff --git a/apps/include/pcl/apps/organized_segmentation_demo.h b/apps/include/pcl/apps/organized_segmentation_demo.h index 5ba08a44670..5db6fa1abad 100644 --- a/apps/include/pcl/apps/organized_segmentation_demo.h +++ b/apps/include/pcl/apps/organized_segmentation_demo.h @@ -63,7 +63,7 @@ using PointT = pcl::PointXYZRGBA; double now = pcl::getTime(); \ ++count; \ if (now - last >= 1.0) { \ - std::cout << "Average framerate(" << _WHAT_ << "): " \ + std::cout << "Average framerate(" << (_WHAT_) << "): " \ << double(count) / double(now - last) << " Hz" << std::endl; \ count = 0; \ last = now; \ diff --git a/apps/include/pcl/apps/pcd_video_player.h b/apps/include/pcl/apps/pcd_video_player.h index b10c087079a..7d30fd9e266 100644 --- a/apps/include/pcl/apps/pcd_video_player.h +++ b/apps/include/pcl/apps/pcd_video_player.h @@ -61,7 +61,7 @@ double now = pcl::getTime(); \ ++count; \ if (now - last >= 1.0) { \ - std::cout << "Average framerate(" << _WHAT_ << "): " \ + std::cout << "Average framerate(" << (_WHAT_) << "): " \ << double(count) / double(now - last) << " Hz" << std::endl; \ count = 0; \ last = now; \ diff --git a/apps/include/pcl/apps/pcl_viewer_dialog.h b/apps/include/pcl/apps/pcl_viewer_dialog.h index 0a3cff7df22..5388c17b48a 100644 --- a/apps/include/pcl/apps/pcl_viewer_dialog.h +++ b/apps/include/pcl/apps/pcl_viewer_dialog.h @@ -20,7 +20,7 @@ class PCLViewerDialog : public QDialog { pcl::visualization::PCLVisualizer::Ptr vis_; public: - PCLViewerDialog(QWidget* parent = 0); + PCLViewerDialog(QWidget* parent = nullptr); void setPointClouds(CloudT::ConstPtr src_cloud, diff --git a/apps/include/pcl/apps/timer.h b/apps/include/pcl/apps/timer.h index 86e431f344a..d312fbe7ef4 100644 --- a/apps/include/pcl/apps/timer.h +++ b/apps/include/pcl/apps/timer.h @@ -51,7 +51,7 @@ double now = pcl::getTime(); \ ++count; \ if (now - last >= 1.0) { \ - std::cout << "Average framerate(" << _WHAT_ << "): " \ + std::cout << "Average framerate(" << (_WHAT_) << "): " \ << double(count) / double(now - last) << " Hz" << std::endl; \ count = 0; \ last = now; \ diff --git a/apps/modeler/include/pcl/apps/modeler/abstract_worker.h b/apps/modeler/include/pcl/apps/modeler/abstract_worker.h index bd73202d0f0..602335cf8f8 100755 --- a/apps/modeler/include/pcl/apps/modeler/abstract_worker.h +++ b/apps/modeler/include/pcl/apps/modeler/abstract_worker.h @@ -50,7 +50,7 @@ class AbstractWorker : public QObject { public: AbstractWorker(const QList& cloud_mesh_items, QWidget* parent = nullptr); - ~AbstractWorker(); + ~AbstractWorker() override; int exec(); diff --git a/apps/modeler/include/pcl/apps/modeler/channel_actor_item.h b/apps/modeler/include/pcl/apps/modeler/channel_actor_item.h index c82f362f704..e857883cb3c 100755 --- a/apps/modeler/include/pcl/apps/modeler/channel_actor_item.h +++ b/apps/modeler/include/pcl/apps/modeler/channel_actor_item.h @@ -59,7 +59,7 @@ class ChannelActorItem : public QTreeWidgetItem, public AbstractItem { const vtkSmartPointer& render_window, const vtkSmartPointer& actor, const std::string& channel_name); - ~ChannelActorItem(); + ~ChannelActorItem() override; void init(); diff --git a/apps/modeler/include/pcl/apps/modeler/icp_registration_worker.h b/apps/modeler/include/pcl/apps/modeler/icp_registration_worker.h index 3ae287f6a7f..e4f488f2f56 100755 --- a/apps/modeler/include/pcl/apps/modeler/icp_registration_worker.h +++ b/apps/modeler/include/pcl/apps/modeler/icp_registration_worker.h @@ -74,10 +74,10 @@ class ICPRegistrationWorker : public AbstractWorker { double y_min_, y_max_; double z_min_, z_max_; - DoubleParameter* max_correspondence_distance_; - IntParameter* max_iterations_; - DoubleParameter* transformation_epsilon_; - DoubleParameter* euclidean_fitness_epsilon_; + DoubleParameter* max_correspondence_distance_{nullptr}; + IntParameter* max_iterations_{nullptr}; + DoubleParameter* transformation_epsilon_{nullptr}; + DoubleParameter* euclidean_fitness_epsilon_{nullptr}; }; } // namespace modeler diff --git a/apps/modeler/include/pcl/apps/modeler/normal_estimation_worker.h b/apps/modeler/include/pcl/apps/modeler/normal_estimation_worker.h index de9fa97f60c..be3b6452463 100755 --- a/apps/modeler/include/pcl/apps/modeler/normal_estimation_worker.h +++ b/apps/modeler/include/pcl/apps/modeler/normal_estimation_worker.h @@ -47,7 +47,7 @@ class NormalEstimationWorker : public AbstractWorker { public: NormalEstimationWorker(const QList& cloud_mesh_items, QWidget* parent = nullptr); - ~NormalEstimationWorker(); + ~NormalEstimationWorker() override; protected: std::string @@ -70,7 +70,7 @@ class NormalEstimationWorker : public AbstractWorker { double y_min_, y_max_; double z_min_, z_max_; - DoubleParameter* search_radius_; + DoubleParameter* search_radius_{nullptr}; }; } // namespace modeler diff --git a/apps/modeler/include/pcl/apps/modeler/normals_actor_item.h b/apps/modeler/include/pcl/apps/modeler/normals_actor_item.h index e974a9d6cad..b5968892105 100755 --- a/apps/modeler/include/pcl/apps/modeler/normals_actor_item.h +++ b/apps/modeler/include/pcl/apps/modeler/normals_actor_item.h @@ -76,8 +76,8 @@ class NormalsActorItem : public ChannelActorItem { setProperties() override; private: - double level_; - double scale_; + double level_{10}; + double scale_{0.1}; }; } // namespace modeler diff --git a/apps/modeler/include/pcl/apps/modeler/parameter_dialog.h b/apps/modeler/include/pcl/apps/modeler/parameter_dialog.h index 6ebb15549e3..26edc33e94b 100755 --- a/apps/modeler/include/pcl/apps/modeler/parameter_dialog.h +++ b/apps/modeler/include/pcl/apps/modeler/parameter_dialog.h @@ -73,7 +73,7 @@ class ParameterDialog : public QDialog { protected: std::map name_parameter_map_; - ParameterModel* parameter_model_; + ParameterModel* parameter_model_{nullptr}; protected Q_SLOTS: void diff --git a/apps/modeler/include/pcl/apps/modeler/poisson_worker.h b/apps/modeler/include/pcl/apps/modeler/poisson_worker.h index d48d1b9610a..baf46d833bb 100755 --- a/apps/modeler/include/pcl/apps/modeler/poisson_worker.h +++ b/apps/modeler/include/pcl/apps/modeler/poisson_worker.h @@ -48,7 +48,7 @@ class PoissonReconstructionWorker : public AbstractWorker { public: PoissonReconstructionWorker(const QList& cloud_mesh_items, QWidget* parent = nullptr); - ~PoissonReconstructionWorker(); + ~PoissonReconstructionWorker() override; protected: std::string @@ -68,12 +68,12 @@ class PoissonReconstructionWorker : public AbstractWorker { processImpl(CloudMeshItem* cloud_mesh_item) override; private: - IntParameter* depth_; - IntParameter* solver_divide_; - IntParameter* iso_divide_; - IntParameter* degree_; - DoubleParameter* scale_; - DoubleParameter* samples_per_node_; + IntParameter* depth_{nullptr}; + IntParameter* solver_divide_{nullptr}; + IntParameter* iso_divide_{nullptr}; + IntParameter* degree_{nullptr}; + DoubleParameter* scale_{nullptr}; + DoubleParameter* samples_per_node_{nullptr}; }; } // namespace modeler diff --git a/apps/modeler/include/pcl/apps/modeler/render_window_item.h b/apps/modeler/include/pcl/apps/modeler/render_window_item.h index bafdaa66177..35463a6a60a 100755 --- a/apps/modeler/include/pcl/apps/modeler/render_window_item.h +++ b/apps/modeler/include/pcl/apps/modeler/render_window_item.h @@ -52,7 +52,7 @@ class BoolParameter; class RenderWindowItem : public QTreeWidgetItem, public AbstractItem { public: RenderWindowItem(QTreeWidget* parent); - ~RenderWindowItem(); + ~RenderWindowItem() override; inline RenderWindow* getRenderWindow() diff --git a/apps/modeler/include/pcl/apps/modeler/statistical_outlier_removal_worker.h b/apps/modeler/include/pcl/apps/modeler/statistical_outlier_removal_worker.h index 56d272033b7..d45c22781da 100755 --- a/apps/modeler/include/pcl/apps/modeler/statistical_outlier_removal_worker.h +++ b/apps/modeler/include/pcl/apps/modeler/statistical_outlier_removal_worker.h @@ -48,7 +48,7 @@ class StatisticalOutlierRemovalWorker : public AbstractWorker { public: StatisticalOutlierRemovalWorker(const QList& cloud_mesh_items, QWidget* parent = nullptr); - ~StatisticalOutlierRemovalWorker(); + ~StatisticalOutlierRemovalWorker() override; protected: std::string @@ -67,8 +67,8 @@ class StatisticalOutlierRemovalWorker : public AbstractWorker { processImpl(CloudMeshItem* cloud_mesh_item) override; private: - IntParameter* mean_k_; - DoubleParameter* stddev_mul_thresh_; + IntParameter* mean_k_{nullptr}; + DoubleParameter* stddev_mul_thresh_{nullptr}; }; } // namespace modeler diff --git a/apps/modeler/include/pcl/apps/modeler/thread_controller.h b/apps/modeler/include/pcl/apps/modeler/thread_controller.h index df98cbe36f4..efbcae6b2d4 100755 --- a/apps/modeler/include/pcl/apps/modeler/thread_controller.h +++ b/apps/modeler/include/pcl/apps/modeler/thread_controller.h @@ -49,7 +49,7 @@ class ThreadController : public QObject { public: ThreadController(); - ~ThreadController(); + ~ThreadController() override; bool runWorker(AbstractWorker* worker); diff --git a/apps/modeler/include/pcl/apps/modeler/voxel_grid_downsample_worker.h b/apps/modeler/include/pcl/apps/modeler/voxel_grid_downsample_worker.h index c68cbb13e56..f0a9310b5f9 100755 --- a/apps/modeler/include/pcl/apps/modeler/voxel_grid_downsample_worker.h +++ b/apps/modeler/include/pcl/apps/modeler/voxel_grid_downsample_worker.h @@ -47,7 +47,7 @@ class VoxelGridDownampleWorker : public AbstractWorker { public: VoxelGridDownampleWorker(const QList& cloud_mesh_items, QWidget* parent = nullptr); - ~VoxelGridDownampleWorker(); + ~VoxelGridDownampleWorker() override; protected: std::string @@ -70,9 +70,9 @@ class VoxelGridDownampleWorker : public AbstractWorker { double y_min_, y_max_; double z_min_, z_max_; - DoubleParameter* leaf_size_x_; - DoubleParameter* leaf_size_y_; - DoubleParameter* leaf_size_z_; + DoubleParameter* leaf_size_x_{nullptr}; + DoubleParameter* leaf_size_y_{nullptr}; + DoubleParameter* leaf_size_z_{nullptr}; }; } // namespace modeler diff --git a/apps/modeler/src/abstract_item.cpp b/apps/modeler/src/abstract_item.cpp index e3d337f4515..1837725d86e 100755 --- a/apps/modeler/src/abstract_item.cpp +++ b/apps/modeler/src/abstract_item.cpp @@ -39,7 +39,7 @@ #include ////////////////////////////////////////////////////////////////////////////////////////////// -pcl::modeler::AbstractItem::AbstractItem() {} +pcl::modeler::AbstractItem::AbstractItem() = default; ////////////////////////////////////////////////////////////////////////////////////////////// void diff --git a/apps/modeler/src/cloud_mesh.cpp b/apps/modeler/src/cloud_mesh.cpp index 5d350b8047a..2a44a259e02 100755 --- a/apps/modeler/src/cloud_mesh.cpp +++ b/apps/modeler/src/cloud_mesh.cpp @@ -155,7 +155,7 @@ pcl::modeler::CloudMesh::updateVtkPoints() if (vtk_points_->GetData() == nullptr) vtk_points_->SetData(vtkSmartPointer::New()); - vtkFloatArray* data = dynamic_cast(vtk_points_->GetData()); + auto* data = dynamic_cast(vtk_points_->GetData()); data->SetNumberOfComponents(3); // If the dataset has no invalid values, just copy all of them @@ -226,7 +226,7 @@ pcl::modeler::CloudMesh::transform( ry *= M_PI / 180; rz *= M_PI / 180; Eigen::Affine3f affine_transform = pcl::getTransformation( - float(tx), float(ty), float(tz), float(rx), float(ry), float(rz)); + static_cast(tx), static_cast(ty), static_cast(tz), static_cast(rx), static_cast(ry), static_cast(rz)); CloudMesh::PointCloud transform_cloud = mean_cloud; pcl::transformPointCloudWithNormals( mean_cloud, transform_cloud, affine_transform.matrix()); diff --git a/apps/modeler/src/cloud_mesh_item.cpp b/apps/modeler/src/cloud_mesh_item.cpp index 1ac45a5b322..a3802bad375 100755 --- a/apps/modeler/src/cloud_mesh_item.cpp +++ b/apps/modeler/src/cloud_mesh_item.cpp @@ -152,7 +152,7 @@ pcl::modeler::CloudMeshItem::prepareContextMenu(QMenu* menu) const void pcl::modeler::CloudMeshItem::createChannels() { - RenderWindowItem* render_window_item = dynamic_cast(parent()); + auto* render_window_item = dynamic_cast(parent()); vtkRenderWindow* win = getRenderWindowCompat(*(render_window_item->getRenderWindow())); @@ -161,7 +161,7 @@ pcl::modeler::CloudMeshItem::createChannels() addChild(new SurfaceActorItem(this, cloud_mesh_, win)); for (int i = 0, i_end = childCount(); i < i_end; ++i) { - ChannelActorItem* child_item = dynamic_cast(child(i)); + auto* child_item = dynamic_cast(child(i)); child_item->init(); } @@ -177,11 +177,11 @@ pcl::modeler::CloudMeshItem::updateChannels() cloud_mesh_->updateVtkPolygons(); for (int i = 0, i_end = childCount(); i < i_end; ++i) { - ChannelActorItem* child_item = dynamic_cast(child(i)); + auto* child_item = dynamic_cast(child(i)); child_item->update(); } - RenderWindowItem* render_window_item = dynamic_cast(parent()); + auto* render_window_item = dynamic_cast(parent()); render_window_item->getRenderWindow()->updateAxes(); } @@ -236,9 +236,9 @@ pcl::modeler::CloudMeshItem::setProperties() void pcl::modeler::CloudMeshItem::updateRenderWindow() { - RenderWindowItem* render_window_item = dynamic_cast(parent()); + auto* render_window_item = dynamic_cast(parent()); for (int i = 0, i_end = childCount(); i < i_end; ++i) { - ChannelActorItem* child_item = dynamic_cast(child(i)); + auto* child_item = dynamic_cast(child(i)); child_item->switchRenderWindow( getRenderWindowCompat(*render_window_item->getRenderWindow())); } diff --git a/apps/modeler/src/icp_registration_worker.cpp b/apps/modeler/src/icp_registration_worker.cpp index 2210d18cda3..7189522ebad 100755 --- a/apps/modeler/src/icp_registration_worker.cpp +++ b/apps/modeler/src/icp_registration_worker.cpp @@ -55,10 +55,8 @@ pcl::modeler::ICPRegistrationWorker::ICPRegistrationWorker( , y_max_(std::numeric_limits::min()) , z_min_(std::numeric_limits::max()) , z_max_(std::numeric_limits::min()) -, max_correspondence_distance_(nullptr) -, max_iterations_(nullptr) -, transformation_epsilon_(nullptr) -, euclidean_fitness_epsilon_(nullptr) +, + {} ////////////////////////////////////////////////////////////////////////////////////////////// @@ -70,14 +68,14 @@ pcl::modeler::ICPRegistrationWorker::initParameters(CloudMeshItem* cloud_mesh_it Eigen::Vector4f min_pt, max_pt; pcl::getMinMax3D(*(cloud_mesh_item->getCloudMesh()->getCloud()), min_pt, max_pt); - x_min_ = std::min(double(min_pt.x()), x_min_); - x_max_ = std::max(double(max_pt.x()), x_max_); + x_min_ = std::min(static_cast(min_pt.x()), x_min_); + x_max_ = std::max(static_cast(max_pt.x()), x_max_); - y_min_ = std::min(double(min_pt.y()), y_min_); - y_max_ = std::max(double(max_pt.y()), y_max_); + y_min_ = std::min(static_cast(min_pt.y()), y_min_); + y_max_ = std::max(static_cast(max_pt.y()), y_max_); - z_min_ = std::min(double(min_pt.z()), z_min_); - z_max_ = std::max(double(max_pt.z()), z_max_); + z_min_ = std::min(static_cast(min_pt.z()), z_min_); + z_max_ = std::max(static_cast(max_pt.z()), z_max_); } ////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/apps/modeler/src/main_window.cpp b/apps/modeler/src/main_window.cpp index 85381af7313..b1f8c40a960 100755 --- a/apps/modeler/src/main_window.cpp +++ b/apps/modeler/src/main_window.cpp @@ -282,7 +282,7 @@ pcl::modeler::MainWindow::updateRecentActions( } recent_items.removeDuplicates(); - int recent_number = std::min(int(MAX_RECENT_NUMBER), recent_items.size()); + int recent_number = std::min(static_cast(MAX_RECENT_NUMBER), recent_items.size()); for (int i = 0; i < recent_number; ++i) { QString text = tr("%1 %2").arg(i + 1).arg(recent_items[i]); recent_actions[i]->setText(text); diff --git a/apps/modeler/src/normal_estimation_worker.cpp b/apps/modeler/src/normal_estimation_worker.cpp index 08f577858a3..1fb924fd7c1 100755 --- a/apps/modeler/src/normal_estimation_worker.cpp +++ b/apps/modeler/src/normal_estimation_worker.cpp @@ -55,7 +55,7 @@ pcl::modeler::NormalEstimationWorker::NormalEstimationWorker( , y_max_(std::numeric_limits::min()) , z_min_(std::numeric_limits::max()) , z_max_(std::numeric_limits::min()) -, search_radius_(nullptr) +, {} ////////////////////////////////////////////////////////////////////////////////////////////// @@ -71,14 +71,14 @@ pcl::modeler::NormalEstimationWorker::initParameters(CloudMeshItem* cloud_mesh_i Eigen::Vector4f min_pt, max_pt; pcl::getMinMax3D(*(cloud_mesh_item->getCloudMesh()->getCloud()), min_pt, max_pt); - x_min_ = std::min(double(min_pt.x()), x_min_); - x_max_ = std::max(double(max_pt.x()), x_max_); + x_min_ = std::min(static_cast(min_pt.x()), x_min_); + x_max_ = std::max(static_cast(max_pt.x()), x_max_); - y_min_ = std::min(double(min_pt.y()), y_min_); - y_max_ = std::max(double(max_pt.y()), y_max_); + y_min_ = std::min(static_cast(min_pt.y()), y_min_); + y_max_ = std::max(static_cast(max_pt.y()), y_max_); - z_min_ = std::min(double(min_pt.z()), z_min_); - z_max_ = std::max(double(max_pt.z()), z_max_); + z_min_ = std::min(static_cast(min_pt.z()), z_min_); + z_max_ = std::max(static_cast(max_pt.z()), z_max_); } ////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/apps/modeler/src/normals_actor_item.cpp b/apps/modeler/src/normals_actor_item.cpp index a594127dfc2..f2b428a20e3 100644 --- a/apps/modeler/src/normals_actor_item.cpp +++ b/apps/modeler/src/normals_actor_item.cpp @@ -51,8 +51,8 @@ pcl::modeler::NormalsActorItem::NormalsActorItem( const vtkSmartPointer& render_window) : ChannelActorItem( parent, cloud_mesh, render_window, vtkSmartPointer::New(), "Normals") -, level_(10) -, scale_(0.1) +, + {} ////////////////////////////////////////////////////////////////////////////////////////////// @@ -70,11 +70,11 @@ pcl::modeler::NormalsActorItem::createNormalLines() if (points->GetData() == nullptr) points->SetData(vtkSmartPointer::New()); - vtkFloatArray* data = dynamic_cast(points->GetData()); + auto* data = dynamic_cast(points->GetData()); data->SetNumberOfComponents(3); if (cloud->is_dense) { - vtkIdType nr_normals = static_cast((cloud->size() - 1) / level_ + 1); + auto nr_normals = static_cast((cloud->size() - 1) / level_ + 1); data->SetNumberOfValues(2 * 3 * nr_normals); for (vtkIdType i = 0, j = 0; j < nr_normals; j++, i = static_cast(j * level_)) { @@ -82,9 +82,9 @@ pcl::modeler::NormalsActorItem::createNormalLines() data->SetValue(2 * j * 3 + 0, p.x); data->SetValue(2 * j * 3 + 1, p.y); data->SetValue(2 * j * 3 + 2, p.z); - data->SetValue(2 * j * 3 + 3, float(p.x + p.normal_x * scale_)); - data->SetValue(2 * j * 3 + 4, float(p.y + p.normal_y * scale_)); - data->SetValue(2 * j * 3 + 5, float(p.z + p.normal_z * scale_)); + data->SetValue(2 * j * 3 + 3, static_cast(p.x + p.normal_x * scale_)); + data->SetValue(2 * j * 3 + 4, static_cast(p.y + p.normal_y * scale_)); + data->SetValue(2 * j * 3 + 5, static_cast(p.z + p.normal_z * scale_)); lines->InsertNextCell(2); lines->InsertCellPoint(2 * j); @@ -95,7 +95,7 @@ pcl::modeler::NormalsActorItem::createNormalLines() pcl::IndicesPtr indices(new pcl::Indices()); pcl::removeNaNFromPointCloud(*cloud, *indices); - vtkIdType nr_normals = static_cast((indices->size() - 1) / level_ + 1); + auto nr_normals = static_cast((indices->size() - 1) / level_ + 1); data->SetNumberOfValues(2 * 3 * nr_normals); for (vtkIdType i = 0, j = 0; j < nr_normals; j++, i = static_cast(j * level_)) { @@ -103,9 +103,9 @@ pcl::modeler::NormalsActorItem::createNormalLines() data->SetValue(2 * j * 3 + 0, p.x); data->SetValue(2 * j * 3 + 1, p.y); data->SetValue(2 * j * 3 + 2, p.z); - data->SetValue(2 * j * 3 + 3, float(p.x + p.normal_x * scale_)); - data->SetValue(2 * j * 3 + 4, float(p.y + p.normal_y * scale_)); - data->SetValue(2 * j * 3 + 5, float(p.z + p.normal_z * scale_)); + data->SetValue(2 * j * 3 + 3, static_cast(p.x + p.normal_x * scale_)); + data->SetValue(2 * j * 3 + 4, static_cast(p.y + p.normal_y * scale_)); + data->SetValue(2 * j * 3 + 5, static_cast(p.z + p.normal_z * scale_)); lines->InsertNextCell(2); lines->InsertCellPoint(2 * j); diff --git a/apps/modeler/src/parameter.cpp b/apps/modeler/src/parameter.cpp index c7117d6d570..033fe2575c8 100755 --- a/apps/modeler/src/parameter.cpp +++ b/apps/modeler/src/parameter.cpp @@ -67,7 +67,7 @@ pcl::modeler::IntParameter::valueTip() QWidget* pcl::modeler::IntParameter::createEditor(QWidget* parent) { - QSpinBox* editor = new QSpinBox(parent); + auto* editor = new QSpinBox(parent); editor->setMinimum(low_); editor->setMaximum(high_); editor->setSingleStep(step_); @@ -79,7 +79,7 @@ pcl::modeler::IntParameter::createEditor(QWidget* parent) void pcl::modeler::IntParameter::setEditorData(QWidget* editor) { - QSpinBox* spinBox = static_cast(editor); + auto* spinBox = dynamic_cast(editor); spinBox->setAlignment(Qt::AlignHCenter); int value = int(*this); @@ -90,7 +90,7 @@ pcl::modeler::IntParameter::setEditorData(QWidget* editor) void pcl::modeler::IntParameter::getEditorData(QWidget* editor) { - QSpinBox* spinBox = static_cast(editor); + auto* spinBox = dynamic_cast(editor); int value = spinBox->text().toInt(); current_value_ = value; } @@ -116,7 +116,7 @@ pcl::modeler::BoolParameter::valueTip() QWidget* pcl::modeler::BoolParameter::createEditor(QWidget* parent) { - QCheckBox* editor = new QCheckBox(parent); + auto* editor = new QCheckBox(parent); return editor; } @@ -125,7 +125,7 @@ pcl::modeler::BoolParameter::createEditor(QWidget* parent) void pcl::modeler::BoolParameter::setEditorData(QWidget* editor) { - QCheckBox* checkBox = static_cast(editor); + auto* checkBox = dynamic_cast(editor); bool value = bool(*this); checkBox->setCheckState(value ? (Qt::Checked) : (Qt::Unchecked)); @@ -135,7 +135,7 @@ pcl::modeler::BoolParameter::setEditorData(QWidget* editor) void pcl::modeler::BoolParameter::getEditorData(QWidget* editor) { - QCheckBox* checkBox = static_cast(editor); + auto* checkBox = dynamic_cast(editor); bool value = (checkBox->checkState() == Qt::Checked); current_value_ = value; } @@ -161,7 +161,7 @@ pcl::modeler::DoubleParameter::valueTip() QWidget* pcl::modeler::DoubleParameter::createEditor(QWidget* parent) { - QDoubleSpinBox* editor = new QDoubleSpinBox(parent); + auto* editor = new QDoubleSpinBox(parent); editor->setMinimum(low_); editor->setMaximum(high_); editor->setSingleStep(step_); @@ -174,7 +174,7 @@ pcl::modeler::DoubleParameter::createEditor(QWidget* parent) void pcl::modeler::DoubleParameter::setEditorData(QWidget* editor) { - QDoubleSpinBox* spinBox = static_cast(editor); + auto* spinBox = dynamic_cast(editor); spinBox->setAlignment(Qt::AlignHCenter); double value = double(*this); @@ -185,7 +185,7 @@ pcl::modeler::DoubleParameter::setEditorData(QWidget* editor) void pcl::modeler::DoubleParameter::getEditorData(QWidget* editor) { - QDoubleSpinBox* spinBox = static_cast(editor); + auto* spinBox = dynamic_cast(editor); double value = spinBox->text().toDouble(); current_value_ = value; } @@ -211,7 +211,7 @@ pcl::modeler::ColorParameter::valueTip() QWidget* pcl::modeler::ColorParameter::createEditor(QWidget* parent) { - QColorDialog* editor = new QColorDialog(parent); + auto* editor = new QColorDialog(parent); return editor; } @@ -220,7 +220,7 @@ pcl::modeler::ColorParameter::createEditor(QWidget* parent) void pcl::modeler::ColorParameter::setEditorData(QWidget* editor) { - QColorDialog* color_dialog = static_cast(editor); + auto* color_dialog = dynamic_cast(editor); QColor value = QColor(*this); color_dialog->setCurrentColor(value); @@ -230,7 +230,7 @@ pcl::modeler::ColorParameter::setEditorData(QWidget* editor) void pcl::modeler::ColorParameter::getEditorData(QWidget* editor) { - QColorDialog* color_dialog = static_cast(editor); + auto* color_dialog = dynamic_cast(editor); QColor value = color_dialog->currentColor(); current_value_ = value; diff --git a/apps/modeler/src/parameter_dialog.cpp b/apps/modeler/src/parameter_dialog.cpp index dfa6c2156c5..1991069a8eb 100755 --- a/apps/modeler/src/parameter_dialog.cpp +++ b/apps/modeler/src/parameter_dialog.cpp @@ -62,7 +62,7 @@ pcl::modeler::ParameterDialog::addParameter(pcl::modeler::Parameter* parameter) ////////////////////////////////////////////////////////////////////////////////////////////// pcl::modeler::ParameterDialog::ParameterDialog(const std::string& title, QWidget* parent) -: QDialog(parent), parameter_model_(nullptr) +: QDialog(parent), { setModal(false); setWindowTitle(QString(title.c_str()) + " Parameters"); @@ -72,7 +72,7 @@ pcl::modeler::ParameterDialog::ParameterDialog(const std::string& title, int pcl::modeler::ParameterDialog::exec() { - pcl::modeler::ParameterModel parameterModel(int(name_parameter_map_.size()), 2, this); + pcl::modeler::ParameterModel parameterModel(static_cast(name_parameter_map_.size()), 2, this); parameter_model_ = ¶meterModel; QStringList headerLabels; @@ -85,10 +85,10 @@ pcl::modeler::ParameterDialog::exec() std::size_t currentRow = 0; for (const auto& name_parameter : name_parameter_map_) { - QModelIndex name = parameterModel.index(int(currentRow), 0, QModelIndex()); + QModelIndex name = parameterModel.index(static_cast(currentRow), 0, QModelIndex()); parameterModel.setData(name, QVariant(name_parameter.first.c_str())); - QModelIndex value = parameterModel.index(int(currentRow), 1, QModelIndex()); + QModelIndex value = parameterModel.index(static_cast(currentRow), 1, QModelIndex()); std::pair model_data = name_parameter.second->toModelData(); parameterModel.setData(value, model_data.first, model_data.second); @@ -109,9 +109,9 @@ pcl::modeler::ParameterDialog::exec() tableView.columnWidth(0) + tableView.columnWidth(1) + frameSize().width(); setMinimumWidth(totlen); - QPushButton* pushButtonReset = new QPushButton("Reset", this); - QPushButton* pushButtonApply = new QPushButton("Apply", this); - QPushButton* pushButtonCancel = new QPushButton("Cancel", this); + auto* pushButtonReset = new QPushButton("Reset", this); + auto* pushButtonApply = new QPushButton("Apply", this); + auto* pushButtonCancel = new QPushButton("Cancel", this); connect(pushButtonReset, SIGNAL(clicked()), this, SLOT(reset())); connect(pushButtonApply, SIGNAL(clicked()), this, SLOT(accept())); @@ -137,7 +137,7 @@ pcl::modeler::ParameterDialog::reset() for (auto& name_parameter : name_parameter_map_) { name_parameter.second->reset(); - QModelIndex value = parameter_model_->index(int(currentRow), 1, QModelIndex()); + QModelIndex value = parameter_model_->index(static_cast(currentRow), 1, QModelIndex()); std::pair model_data = name_parameter.second->toModelData(); parameter_model_->setData(value, model_data.first, model_data.second); @@ -149,10 +149,10 @@ pcl::modeler::ParameterDialog::reset() pcl::modeler::Parameter* pcl::modeler::ParameterDelegate::getCurrentParameter(const QModelIndex& index) const { - std::map::iterator currentParameter = parameter_map_.begin(); + auto currentParameter = parameter_map_.begin(); std::size_t currentRow = 0; - while (currentRow < (std::size_t)index.row() && + while (currentRow < static_cast(index.row()) && currentParameter != parameter_map_.end()) { ++currentParameter; ++currentRow; diff --git a/apps/modeler/src/points_actor_item.cpp b/apps/modeler/src/points_actor_item.cpp index 96711887ba4..141dd6ec08e 100755 --- a/apps/modeler/src/points_actor_item.cpp +++ b/apps/modeler/src/points_actor_item.cpp @@ -83,7 +83,7 @@ pcl::modeler::PointsActorItem::initImpl() actor->SetMapper(mapper); actor->SetNumberOfCloudPoints( - int(std::max(1, poly_data_->GetNumberOfPoints() / 10))); + static_cast(std::max(1, poly_data_->GetNumberOfPoints() / 10))); actor->GetProperty()->SetInterpolationToFlat(); } diff --git a/apps/modeler/src/poisson_worker.cpp b/apps/modeler/src/poisson_worker.cpp index 49b2e750497..57cf0280357 100755 --- a/apps/modeler/src/poisson_worker.cpp +++ b/apps/modeler/src/poisson_worker.cpp @@ -46,12 +46,8 @@ pcl::modeler::PoissonReconstructionWorker::PoissonReconstructionWorker( const QList& cloud_mesh_items, QWidget* parent) : AbstractWorker(cloud_mesh_items, parent) -, depth_(nullptr) -, solver_divide_(nullptr) -, iso_divide_(nullptr) -, degree_(nullptr) -, scale_(nullptr) -, samples_per_node_(nullptr) +, + {} ////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/apps/modeler/src/render_window.cpp b/apps/modeler/src/render_window.cpp index b63629b6ba1..888a113081f 100755 --- a/apps/modeler/src/render_window.cpp +++ b/apps/modeler/src/render_window.cpp @@ -65,7 +65,7 @@ pcl::modeler::RenderWindow::RenderWindow(RenderWindowItem* render_window_item, ////////////////////////////////////////////////////////////////////////////////////////////// pcl::modeler::RenderWindow::~RenderWindow() { - DockWidget* dock_widget = dynamic_cast(parent()); + auto* dock_widget = dynamic_cast(parent()); if (dock_widget != nullptr) { MainWindow::getInstance().removeDockWidget(dock_widget); dock_widget->deleteLater(); @@ -112,7 +112,7 @@ pcl::modeler::RenderWindow::focusInEvent(QFocusEvent* event) void pcl::modeler::RenderWindow::setActive(bool flag) { - DockWidget* dock_widget = dynamic_cast(parent()); + auto* dock_widget = dynamic_cast(parent()); if (dock_widget != nullptr) dock_widget->setFocusBasedStyle(flag); } @@ -121,7 +121,7 @@ pcl::modeler::RenderWindow::setActive(bool flag) void pcl::modeler::RenderWindow::setTitle(const QString& title) { - DockWidget* dock_widget = dynamic_cast(parent()); + auto* dock_widget = dynamic_cast(parent()); if (dock_widget != nullptr) dock_widget->setWindowTitle(title); } diff --git a/apps/modeler/src/render_window_item.cpp b/apps/modeler/src/render_window_item.cpp index 0b24410b341..70f8fc3c1b8 100755 --- a/apps/modeler/src/render_window_item.cpp +++ b/apps/modeler/src/render_window_item.cpp @@ -59,7 +59,7 @@ pcl::modeler::RenderWindowItem::~RenderWindowItem() { render_window_->deleteLate bool pcl::modeler::RenderWindowItem::openPointCloud(const QString& filename) { - CloudMeshItem* cloud_mesh_item = new CloudMeshItem(this, filename.toStdString()); + auto* cloud_mesh_item = new CloudMeshItem(this, filename.toStdString()); addChild(cloud_mesh_item); if (!cloud_mesh_item->open()) { @@ -77,7 +77,7 @@ pcl::modeler::RenderWindowItem::openPointCloud(const QString& filename) pcl::modeler::CloudMeshItem* pcl::modeler::RenderWindowItem::addPointCloud(CloudMesh::PointCloudPtr cloud) { - CloudMeshItem* cloud_mesh_item = new CloudMeshItem(this, std::move(cloud)); + auto* cloud_mesh_item = new CloudMeshItem(this, std::move(cloud)); addChild(cloud_mesh_item); treeWidget()->setCurrentItem(cloud_mesh_item); diff --git a/apps/modeler/src/scene_tree.cpp b/apps/modeler/src/scene_tree.cpp index 69919d50418..41eab675296 100755 --- a/apps/modeler/src/scene_tree.cpp +++ b/apps/modeler/src/scene_tree.cpp @@ -103,7 +103,7 @@ pcl::modeler::SceneTree::selectedRenderWindowItems() const void pcl::modeler::SceneTree::contextMenuEvent(QContextMenuEvent* event) { - AbstractItem* item = dynamic_cast(currentItem()); + auto* item = dynamic_cast(currentItem()); item->showContextMenu(&(event->globalPos())); } @@ -111,7 +111,7 @@ pcl::modeler::SceneTree::contextMenuEvent(QContextMenuEvent* event) void pcl::modeler::SceneTree::slotOnItemDoubleClicked(QTreeWidgetItem* item) { - AbstractItem* abstract_item = dynamic_cast(item); + auto* abstract_item = dynamic_cast(item); abstract_item->showPropertyEditor(); } @@ -285,7 +285,7 @@ pcl::modeler::SceneTree::slotICPRegistration() AbstractWorker* worker = new ICPRegistrationWorker( result, selected_cloud_mesh_items, &MainWindow::getInstance()); - ThreadController* thread_controller = new ThreadController(); + auto* thread_controller = new ThreadController(); QList selected_render_window_items = selectedRenderWindowItems(); for (auto& selected_render_window_item : selected_render_window_items) { @@ -307,7 +307,7 @@ pcl::modeler::SceneTree::slotVoxelGridDownsampleFilter() QList selected_cloud_mesh_items = selectedTypeItems(); AbstractWorker* worker = new VoxelGridDownampleWorker(selected_cloud_mesh_items, &MainWindow::getInstance()); - ThreadController* thread_controller = new ThreadController(); + auto* thread_controller = new ThreadController(); connect(worker, SIGNAL(dataUpdated(CloudMeshItem*)), thread_controller, @@ -322,7 +322,7 @@ pcl::modeler::SceneTree::slotStatisticalOutlierRemovalFilter() QList selected_cloud_mesh_items = selectedTypeItems(); AbstractWorker* worker = new StatisticalOutlierRemovalWorker( selected_cloud_mesh_items, &MainWindow::getInstance()); - ThreadController* thread_controller = new ThreadController(); + auto* thread_controller = new ThreadController(); connect(worker, SIGNAL(dataUpdated(CloudMeshItem*)), thread_controller, @@ -337,7 +337,7 @@ pcl::modeler::SceneTree::slotEstimateNormal() QList selected_cloud_mesh_items = selectedTypeItems(); AbstractWorker* worker = new NormalEstimationWorker(selected_cloud_mesh_items, &MainWindow::getInstance()); - ThreadController* thread_controller = new ThreadController(); + auto* thread_controller = new ThreadController(); connect(worker, SIGNAL(dataUpdated(CloudMeshItem*)), thread_controller, @@ -352,7 +352,7 @@ pcl::modeler::SceneTree::slotPoissonReconstruction() QList selected_cloud_mesh_items = selectedTypeItems(); AbstractWorker* worker = new PoissonReconstructionWorker(selected_cloud_mesh_items, &MainWindow::getInstance()); - ThreadController* thread_controller = new ThreadController(); + auto* thread_controller = new ThreadController(); connect(worker, SIGNAL(dataUpdated(CloudMeshItem*)), thread_controller, @@ -398,7 +398,7 @@ void pcl::modeler::SceneTree::slotUpdateOnInsertOrRemove() { for (int i = 0, i_end = topLevelItemCount(); i < i_end; ++i) { - RenderWindowItem* render_window_item = + auto* render_window_item = dynamic_cast(topLevelItem(i)); if (render_window_item == nullptr) continue; diff --git a/apps/modeler/src/statistical_outlier_removal_worker.cpp b/apps/modeler/src/statistical_outlier_removal_worker.cpp index 2d8272427f3..dd09f8685f7 100755 --- a/apps/modeler/src/statistical_outlier_removal_worker.cpp +++ b/apps/modeler/src/statistical_outlier_removal_worker.cpp @@ -45,8 +45,8 @@ pcl::modeler::StatisticalOutlierRemovalWorker::StatisticalOutlierRemovalWorker( const QList& cloud_mesh_items, QWidget* parent) : AbstractWorker(cloud_mesh_items, parent) -, mean_k_(nullptr) -, stddev_mul_thresh_(nullptr) +, + {} ////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/apps/modeler/src/surface_actor_item.cpp b/apps/modeler/src/surface_actor_item.cpp index aa5aa233587..0c4442b5a3a 100755 --- a/apps/modeler/src/surface_actor_item.cpp +++ b/apps/modeler/src/surface_actor_item.cpp @@ -80,7 +80,7 @@ pcl::modeler::SurfaceActorItem::initImpl() actor->SetMapper(mapper); actor->SetNumberOfCloudPoints( - int(std::max(1, poly_data_->GetNumberOfPoints() / 10))); + static_cast(std::max(1, poly_data_->GetNumberOfPoints() / 10))); actor->GetProperty()->SetInterpolationToFlat(); actor->GetProperty()->SetRepresentationToSurface(); diff --git a/apps/modeler/src/thread_controller.cpp b/apps/modeler/src/thread_controller.cpp index 9d391b2df59..88cfbc44054 100755 --- a/apps/modeler/src/thread_controller.cpp +++ b/apps/modeler/src/thread_controller.cpp @@ -43,7 +43,7 @@ #include ////////////////////////////////////////////////////////////////////////////////////////////// -pcl::modeler::ThreadController::ThreadController() {} +pcl::modeler::ThreadController::ThreadController() = default; ////////////////////////////////////////////////////////////////////////////////////////////// pcl::modeler::ThreadController::~ThreadController() @@ -62,7 +62,7 @@ pcl::modeler::ThreadController::runWorker(AbstractWorker* worker) return false; } - QThread* thread = new QThread; + auto* thread = new QThread; connect(this, SIGNAL(prepared()), worker, SLOT(process())); diff --git a/apps/modeler/src/voxel_grid_downsample_worker.cpp b/apps/modeler/src/voxel_grid_downsample_worker.cpp index cf3ea73fb2a..8414244f185 100755 --- a/apps/modeler/src/voxel_grid_downsample_worker.cpp +++ b/apps/modeler/src/voxel_grid_downsample_worker.cpp @@ -52,9 +52,8 @@ pcl::modeler::VoxelGridDownampleWorker::VoxelGridDownampleWorker( , y_max_(std::numeric_limits::min()) , z_min_(std::numeric_limits::max()) , z_max_(std::numeric_limits::min()) -, leaf_size_x_(nullptr) -, leaf_size_y_(nullptr) -, leaf_size_z_(nullptr) +, + {} ////////////////////////////////////////////////////////////////////////////////////////////// @@ -72,14 +71,14 @@ pcl::modeler::VoxelGridDownampleWorker::initParameters(CloudMeshItem* cloud_mesh Eigen::Vector4f min_pt, max_pt; pcl::getMinMax3D(*(cloud_mesh_item->getCloudMesh()->getCloud()), min_pt, max_pt); - x_min_ = std::min(double(min_pt.x()), x_min_); - x_max_ = std::max(double(max_pt.x()), x_max_); + x_min_ = std::min(static_cast(min_pt.x()), x_min_); + x_max_ = std::max(static_cast(max_pt.x()), x_max_); - y_min_ = std::min(double(min_pt.y()), y_min_); - y_max_ = std::max(double(max_pt.y()), y_max_); + y_min_ = std::min(static_cast(min_pt.y()), y_min_); + y_max_ = std::max(static_cast(max_pt.y()), y_max_); - z_min_ = std::min(double(min_pt.z()), z_min_); - z_max_ = std::max(double(max_pt.z()), z_max_); + z_min_ = std::min(static_cast(min_pt.z()), z_min_); + z_max_ = std::max(static_cast(max_pt.z()), z_max_); } ////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/cloudEditorWidget.h b/apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/cloudEditorWidget.h index 30ba56ebe04..b800089b654 100644 --- a/apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/cloudEditorWidget.h +++ b/apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/cloudEditorWidget.h @@ -268,10 +268,10 @@ public Q_SLOTS: CloudPtr cloud_ptr_; /// The display size, in pixels, of the cloud points - unsigned int point_size_; + unsigned int point_size_{2u}; /// The display size, in pixels, of the selected cloud points - unsigned int selected_point_size_; + unsigned int selected_point_size_{4u}; /// The transformation tool being used. Either a cloud transform tool or /// a selection transform tool is activated at a time. @@ -287,26 +287,26 @@ public Q_SLOTS: CommandQueuePtr command_queue_ptr_; /// The camera field of view - double cam_fov_; + double cam_fov_{60.0}; /// The camera aspect ratio - double cam_aspect_; + double cam_aspect_{1.0}; /// The camera near clipping plane - double cam_near_; + double cam_near_{0.0001}; /// The camera far clipping plane - double cam_far_; + double cam_far_{100.0}; /// @brief Initialize the texture used for rendering the cloud void initTexture(); /// The current scheme used for coloring the whole cloud - ColorScheme color_scheme_; + ColorScheme color_scheme_{COLOR_BY_PURE}; /// A flag indicates whether the cloud is initially colored or not. - bool is_colored_; + bool is_colored_{false}; using KeyMapFunc = std::function; diff --git a/apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/cloudTransformTool.h b/apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/cloudTransformTool.h index 33cdad5475a..c3bed348626 100644 --- a/apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/cloudTransformTool.h +++ b/apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/cloudTransformTool.h @@ -125,7 +125,7 @@ class CloudTransformTool : public ToolInterface { TrackBall trackball_; /// last recorded mouse positions - int x_, y_; + int x_{0}, y_{0}; /// scaling factor used to control the speed which the display scales the /// point cloud diff --git a/apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/command.h b/apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/command.h index 5b7f3af36df..a4fb100b4aa 100644 --- a/apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/command.h +++ b/apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/command.h @@ -60,7 +60,7 @@ class Command { /// @brief The default constructor. /// @details Derived commands are assumed to have undo by default. Each /// is free to override this. - Command() : has_undo_(true) {} + Command() = default; /// @brief Returns true if the command has an undo function. inline bool @@ -78,7 +78,7 @@ class Command { undo() = 0; /// @brief a flag indicates whether the command has an undo function. - bool has_undo_; + bool has_undo_{true}; private: /// @brief Copy Constructor - object is non-copyable diff --git a/apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/denoiseParameterForm.h b/apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/denoiseParameterForm.h index aa6e9eef1ce..72864b988c8 100644 --- a/apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/denoiseParameterForm.h +++ b/apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/denoiseParameterForm.h @@ -103,5 +103,5 @@ private Q_SLOTS: /// The standard deviation multiplier threshold float std_dev_thresh_; /// The flag indicating whether the OK button was pressed - bool ok_; + bool ok_{false}; }; diff --git a/apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/trackball.h b/apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/trackball.h index 88b861ca759..e06cbc5ca14 100644 --- a/apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/trackball.h +++ b/apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/trackball.h @@ -73,7 +73,7 @@ class TrackBall { boost::math::quaternion quat_; /// the original mouse screen coordinates converted to a 3d point - float origin_x_, origin_y_, origin_z_; + float origin_x_{0}, origin_y_{0}, origin_z_{0}; /// the radius of the trackball squared float radius_sqr_; diff --git a/apps/point_cloud_editor/src/cloud.cpp b/apps/point_cloud_editor/src/cloud.cpp index 41f87f87170..1e1aa63bb13 100644 --- a/apps/point_cloud_editor/src/cloud.cpp +++ b/apps/point_cloud_editor/src/cloud.cpp @@ -300,7 +300,7 @@ Cloud::draw (bool disable_highlight) const // draw the selected points glDrawElements(GL_POINTS, selection_ptr->size(), GL_UNSIGNED_INT, - &(partitioned_indices_[0])); + partitioned_indices_.data()); } } glPopMatrix(); diff --git a/apps/point_cloud_editor/src/cloudEditorWidget.cpp b/apps/point_cloud_editor/src/cloudEditorWidget.cpp index e442aada8b4..e3f4d225d51 100644 --- a/apps/point_cloud_editor/src/cloudEditorWidget.cpp +++ b/apps/point_cloud_editor/src/cloudEditorWidget.cpp @@ -73,10 +73,7 @@ #include CloudEditorWidget::CloudEditorWidget (QWidget *parent) - : QOpenGLWidget(parent), - point_size_(2.0f), selected_point_size_(4.0f), - cam_fov_(60.0), cam_aspect_(1.0), cam_near_(0.0001), cam_far_(100.0), - color_scheme_(COLOR_BY_PURE), is_colored_(false) + : QOpenGLWidget(parent) { setFocusPolicy(Qt::StrongFocus); command_queue_ptr_ = CommandQueuePtr(new CommandQueue()); @@ -91,7 +88,7 @@ void CloudEditorWidget::loadFile(const std::string &filename) { std::string ext = filename.substr(filename.find_last_of('.')+1); - FileLoadMap::iterator it = cloud_load_func_map_.find(ext); + auto it = cloud_load_func_map_.find(ext); if (it != cloud_load_func_map_.end()) (it->second)(this, filename); else @@ -328,8 +325,8 @@ CloudEditorWidget::undo () void CloudEditorWidget::increasePointSize () { - ((MainWindow*) parentWidget()) -> increaseSpinBoxValue(); - point_size_ = ((MainWindow*) parentWidget()) -> getSpinBoxValue(); + (dynamic_cast( parentWidget())) -> increaseSpinBoxValue(); + point_size_ = (dynamic_cast( parentWidget())) -> getSpinBoxValue(); if (!cloud_ptr_) return; cloud_ptr_->setPointSize(point_size_); @@ -339,8 +336,8 @@ CloudEditorWidget::increasePointSize () void CloudEditorWidget::decreasePointSize () { - ((MainWindow*) parentWidget()) -> decreaseSpinBoxValue(); - point_size_ = ((MainWindow*) parentWidget()) -> getSpinBoxValue(); + (dynamic_cast( parentWidget())) -> decreaseSpinBoxValue(); + point_size_ = (dynamic_cast( parentWidget())) -> getSpinBoxValue(); if (!cloud_ptr_) return; cloud_ptr_->setPointSize(point_size_); @@ -350,9 +347,9 @@ CloudEditorWidget::decreasePointSize () void CloudEditorWidget::increaseSelectedPointSize () { - ((MainWindow*) parentWidget()) -> increaseSelectedSpinBoxValue(); + (dynamic_cast( parentWidget())) -> increaseSelectedSpinBoxValue(); selected_point_size_ = - ((MainWindow*) parentWidget()) -> getSelectedSpinBoxValue(); + (dynamic_cast( parentWidget())) -> getSelectedSpinBoxValue(); if (!cloud_ptr_) return; cloud_ptr_->setHighlightPointSize(selected_point_size_); @@ -362,9 +359,9 @@ CloudEditorWidget::increaseSelectedPointSize () void CloudEditorWidget::decreaseSelectedPointSize () { - ((MainWindow*) parentWidget()) -> decreaseSelectedSpinBoxValue(); + (dynamic_cast( parentWidget())) -> decreaseSelectedSpinBoxValue(); selected_point_size_ = - ((MainWindow*) parentWidget()) -> getSelectedSpinBoxValue(); + (dynamic_cast( parentWidget())) -> getSelectedSpinBoxValue(); if (!cloud_ptr_) return; cloud_ptr_->setHighlightPointSize(selected_point_size_); @@ -480,7 +477,7 @@ CloudEditorWidget::resizeGL (int width, int height) height = static_cast(height*ratio); glViewport(0, 0, width, height); viewport_ = {0, 0, width, height}; - cam_aspect_ = double(width) / double(height); + cam_aspect_ = static_cast(width) / static_cast(height); glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluPerspective(cam_fov_, cam_aspect_, cam_near_, cam_far_); @@ -535,7 +532,7 @@ void CloudEditorWidget::keyPressEvent (QKeyEvent *event) { int key = event->key() + static_cast(event->modifiers()); - std::map::iterator it = key_map_.find(key); + auto it = key_map_.find(key); if (it != key_map_.end()) { (it->second)(this); @@ -620,23 +617,23 @@ CloudEditorWidget::initKeyMap () key_map_[Qt::Key_3] = &CloudEditorWidget::colorByY; key_map_[Qt::Key_4] = &CloudEditorWidget::colorByZ; key_map_[Qt::Key_5] = &CloudEditorWidget::colorByRGB; - key_map_[Qt::Key_C + (int) Qt::ControlModifier] = &CloudEditorWidget::copy; - key_map_[Qt::Key_X + (int) Qt::ControlModifier] = &CloudEditorWidget::cut; - key_map_[Qt::Key_V + (int) Qt::ControlModifier] = &CloudEditorWidget::paste; + key_map_[Qt::Key_C + static_cast(Qt::ControlModifier)] = &CloudEditorWidget::copy; + key_map_[Qt::Key_X + static_cast(Qt::ControlModifier)] = &CloudEditorWidget::cut; + key_map_[Qt::Key_V + static_cast(Qt::ControlModifier)] = &CloudEditorWidget::paste; key_map_[Qt::Key_S] = &CloudEditorWidget::select2D; key_map_[Qt::Key_E] = &CloudEditorWidget::select1D; key_map_[Qt::Key_T] = &CloudEditorWidget::transform; key_map_[Qt::Key_V] = &CloudEditorWidget::view; key_map_[Qt::Key_Delete] = &CloudEditorWidget::remove; - key_map_[Qt::Key_Z + (int) Qt::ControlModifier] = &CloudEditorWidget::undo; + key_map_[Qt::Key_Z + static_cast(Qt::ControlModifier)] = &CloudEditorWidget::undo; key_map_[Qt::Key_Equal] = &CloudEditorWidget::increasePointSize; key_map_[Qt::Key_Plus] = &CloudEditorWidget::increasePointSize; key_map_[Qt::Key_Minus] = &CloudEditorWidget::decreasePointSize; - key_map_[Qt::Key_Equal + (int) Qt::ControlModifier] = + key_map_[Qt::Key_Equal + static_cast(Qt::ControlModifier)] = &CloudEditorWidget::increaseSelectedPointSize; - key_map_[Qt::Key_Plus + (int) Qt::ControlModifier] = + key_map_[Qt::Key_Plus + static_cast(Qt::ControlModifier)] = &CloudEditorWidget::increaseSelectedPointSize; - key_map_[Qt::Key_Minus + (int) Qt::ControlModifier] = + key_map_[Qt::Key_Minus + static_cast(Qt::ControlModifier)] = &CloudEditorWidget::decreaseSelectedPointSize; key_map_[Qt::Key_Escape] = &CloudEditorWidget::cancelSelect; } diff --git a/apps/point_cloud_editor/src/cloudTransformTool.cpp b/apps/point_cloud_editor/src/cloudTransformTool.cpp index 4a875de5e94..5f2ddba1110 100644 --- a/apps/point_cloud_editor/src/cloudTransformTool.cpp +++ b/apps/point_cloud_editor/src/cloudTransformTool.cpp @@ -46,7 +46,7 @@ const float CloudTransformTool::DEFAULT_TRANSLATE_FACTOR_ = 0.001f; CloudTransformTool::CloudTransformTool (CloudPtr cloud_ptr) - : cloud_ptr_(std::move(cloud_ptr)), x_(0), y_(0), scale_factor_(DEFAULT_SCALE_FACTOR_), + : cloud_ptr_(std::move(cloud_ptr)), scale_factor_(DEFAULT_SCALE_FACTOR_), translate_factor_(DEFAULT_TRANSLATE_FACTOR_) { setIdentity(transform_matrix_); @@ -99,15 +99,15 @@ CloudTransformTool::getTranslateMatrix (int dx, int dy, float* matrix) { setIdentity(matrix); float scale = 1.0f / cloud_ptr_-> getScalingFactor(); - matrix[12] = float(dx) * translate_factor_ * scale; - matrix[13] = float(-dy) * translate_factor_ * scale; + matrix[12] = static_cast(dx) * translate_factor_ * scale; + matrix[13] = static_cast(-dy) * translate_factor_ * scale; } void CloudTransformTool::getZTranslateMatrix (int dy, float* matrix) { setIdentity(matrix); - matrix[14] = float(dy) * translate_factor_ / cloud_ptr_-> getScalingFactor(); + matrix[14] = static_cast(dy) * translate_factor_ / cloud_ptr_-> getScalingFactor(); } void diff --git a/apps/point_cloud_editor/src/denoiseParameterForm.cpp b/apps/point_cloud_editor/src/denoiseParameterForm.cpp index 13681dfdf33..5655af5697f 100644 --- a/apps/point_cloud_editor/src/denoiseParameterForm.cpp +++ b/apps/point_cloud_editor/src/denoiseParameterForm.cpp @@ -40,7 +40,7 @@ #include -DenoiseParameterForm::DenoiseParameterForm () : ok_(false) +DenoiseParameterForm::DenoiseParameterForm () { mean_K_line_ = new QLineEdit; std_dev_mul_thresh_line_ = new QLineEdit; diff --git a/apps/point_cloud_editor/src/select1DTool.cpp b/apps/point_cloud_editor/src/select1DTool.cpp index b60d7ee3509..8a02a54b3ab 100644 --- a/apps/point_cloud_editor/src/select1DTool.cpp +++ b/apps/point_cloud_editor/src/select1DTool.cpp @@ -74,7 +74,7 @@ Select1DTool::end (int x, int y, BitMask modifiers, BitMask buttons) GLint viewport[4]; glGetIntegerv(GL_VIEWPORT, viewport); IncIndex inc(1);// start the indexing from 1, since the clear color is 0 - unsigned int *index_arr = new unsigned int[cloud_ptr_->size()]; + auto *index_arr = new unsigned int[cloud_ptr_->size()]; std::generate_n(index_arr, cloud_ptr_->size(), inc); glPushClientAttrib(GL_CLIENT_VERTEX_ARRAY_BIT); diff --git a/apps/point_cloud_editor/src/selection.cpp b/apps/point_cloud_editor/src/selection.cpp index ac4aa1032ae..1acace33c32 100644 --- a/apps/point_cloud_editor/src/selection.cpp +++ b/apps/point_cloud_editor/src/selection.cpp @@ -95,7 +95,7 @@ Selection::isSelected (unsigned int index) const { if (index >= cloud_ptr_->size()) return (false); - iterator it = selected_indices_.find(index); + auto it = selected_indices_.find(index); if (it != selected_indices_.end()) return (true); return (false); diff --git a/apps/point_cloud_editor/src/selectionTransformTool.cpp b/apps/point_cloud_editor/src/selectionTransformTool.cpp index 16698d4bc6f..df87cc8dee9 100644 --- a/apps/point_cloud_editor/src/selectionTransformTool.cpp +++ b/apps/point_cloud_editor/src/selectionTransformTool.cpp @@ -91,8 +91,8 @@ SelectionTransformTool::update (int x, int y, BitMask, BitMask buttons) // selection motion is not applied directly (waits for end) // as such we can not update x and y immediately float scale = 1.0f / cloud_ptr_->getScalingFactor(); - cloud_ptr_->setSelectionTranslation ((float) dx * translate_factor_ * scale, - (float) -dy * translate_factor_ * scale, + cloud_ptr_->setSelectionTranslation (static_cast(dx) * translate_factor_ * scale, + static_cast(-dy) * translate_factor_ * scale, 0.0f); return; } @@ -103,7 +103,7 @@ SelectionTransformTool::update (int x, int y, BitMask, BitMask buttons) float scale = 1.0f / cloud_ptr_->getScalingFactor(); cloud_ptr_->setSelectionTranslation (0.0f, 0.0f, - (float) dy * translate_factor_ * scale); + static_cast(dy) * translate_factor_ * scale); return; } float transform[MATRIX_SIZE]; @@ -134,15 +134,15 @@ SelectionTransformTool::end (int x, int y, BitMask modifiers, BitMask buttons) if (modifiers_ & CTRL) { std::shared_ptr c(new TransformCommand(selection_ptr_, - cloud_ptr_, transform_matrix_, (float) dx * translate_factor_ * scale, - (float) -dy * translate_factor_ * scale, 0.0f)); + cloud_ptr_, transform_matrix_, static_cast(dx) * translate_factor_ * scale, + static_cast(-dy) * translate_factor_ * scale, 0.0f)); command_queue_ptr_->execute(c); } else if (modifiers_ & ALT) { std::shared_ptr c(new TransformCommand(selection_ptr_, cloud_ptr_, transform_matrix_, 0.0f, 0.0f, - (float) dy * translate_factor_ * scale)); + static_cast(dy) * translate_factor_ * scale)); command_queue_ptr_->execute(c); } else @@ -193,7 +193,7 @@ SelectionTransformTool::findSelectionCenter () return; float min_xyz[XYZ_SIZE] = {0.0f}; float max_xyz[XYZ_SIZE] = {0.0f}; - Selection::const_iterator it = selection_ptr_->begin(); + auto it = selection_ptr_->begin(); Point3D point_3d = cloud_ptr_->getObjectSpacePoint (*it); float *pt = &(point_3d.data[X]); std::copy(pt, pt + XYZ_SIZE, max_xyz); diff --git a/apps/point_cloud_editor/src/statisticsDialog.cpp b/apps/point_cloud_editor/src/statisticsDialog.cpp index 5d5edfe31ee..2cf6018b0a4 100644 --- a/apps/point_cloud_editor/src/statisticsDialog.cpp +++ b/apps/point_cloud_editor/src/statisticsDialog.cpp @@ -47,7 +47,7 @@ StatisticsDialog::StatisticsDialog(QWidget *) connect(button_box_, SIGNAL(accepted()), this, SLOT(accept())); stat_label_ = new QLabel(tr("")); - QVBoxLayout *main_layout_ = new QVBoxLayout; + auto *main_layout_ = new QVBoxLayout; main_layout_ -> addWidget(stat_label_); main_layout_ -> addWidget(button_box_); setLayout(main_layout_); diff --git a/apps/point_cloud_editor/src/trackball.cpp b/apps/point_cloud_editor/src/trackball.cpp index f95f7b085c8..49ddce00dd0 100644 --- a/apps/point_cloud_editor/src/trackball.cpp +++ b/apps/point_cloud_editor/src/trackball.cpp @@ -42,7 +42,7 @@ #include #include -TrackBall::TrackBall() : quat_(1.0f), origin_x_(0), origin_y_(0), origin_z_(0) +TrackBall::TrackBall() : quat_(1.0f) { radius_sqr_ = (TRACKBALL_RADIUS_SCALE * static_cast(WINDOW_WIDTH)) * (TRACKBALL_RADIUS_SCALE * static_cast(WINDOW_WIDTH)); diff --git a/apps/src/convolve.cpp b/apps/src/convolve.cpp index b236e609677..a20448d7ba4 100644 --- a/apps/src/convolve.cpp +++ b/apps/src/convolve.cpp @@ -73,8 +73,8 @@ main(int argc, char** argv) Eigen::ArrayXf gaussian_kernel(5); gaussian_kernel << 1.f / 16, 1.f / 4, 3.f / 8, 1.f / 4, 1.f / 16; pcl::console::print_info("convolution kernel:"); - for (Eigen::Index i = 0; i < gaussian_kernel.size(); ++i) - pcl::console::print_info(" %f", gaussian_kernel[i]); + for (float i : gaussian_kernel) + pcl::console::print_info(" %f", i); pcl::console::print_info("\n"); if (argc < 3) { diff --git a/apps/src/dinast_grabber_example.cpp b/apps/src/dinast_grabber_example.cpp index 4dc29b317b6..04dff42d318 100644 --- a/apps/src/dinast_grabber_example.cpp +++ b/apps/src/dinast_grabber_example.cpp @@ -61,7 +61,7 @@ class DinastProcessor { static double last = pcl::getTime(); if (++count == 30) { double now = pcl::getTime(); - std::cout << "Average framerate: " << double(count) / double(now - last) << " Hz" + std::cout << "Average framerate: " << static_cast(count) / (now - last) << " Hz" << std::endl; count = 0; last = now; diff --git a/apps/src/face_detection/openni_frame_source.cpp b/apps/src/face_detection/openni_frame_source.cpp index 10c3df3fdde..1e94db21cee 100644 --- a/apps/src/face_detection/openni_frame_source.cpp +++ b/apps/src/face_detection/openni_frame_source.cpp @@ -4,7 +4,7 @@ namespace OpenNIFrameSource { OpenNIFrameSource::OpenNIFrameSource(const std::string& device_id) -: grabber_(device_id), frame_counter_(0), active_(true) +: grabber_(device_id), { std::function frame_cb = [this](const PointCloudConstPtr& cloud) { onNewFrame(cloud); }; diff --git a/apps/src/feature_matching.cpp b/apps/src/feature_matching.cpp index 394ae3eef0d..f82ca90838d 100644 --- a/apps/src/feature_matching.cpp +++ b/apps/src/feature_matching.cpp @@ -140,9 +140,9 @@ class ICCVTutorial { pcl::CorrespondencesPtr correspondences_; Eigen::Matrix4f initial_transformation_matrix_; Eigen::Matrix4f transformation_matrix_; - bool show_source2target_; - bool show_target2source_; - bool show_correspondences; + bool show_source2target_{false}; + bool show_target2source_{false}; + bool show_correspondences{false}; }; template @@ -166,9 +166,8 @@ ICCVTutorial::ICCVTutorial( , source_features_(new pcl::PointCloud) , target_features_(new pcl::PointCloud) , correspondences_(new pcl::Correspondences) -, show_source2target_(false) -, show_target2source_(false) -, show_correspondences(false) +, + { visualizer_.registerKeyboardCallback( &ICCVTutorial::keyboard_callback, *this, nullptr); @@ -342,7 +341,7 @@ ICCVTutorial::filterCorrespondences() std::vector> correspondences; for (std::size_t cIdx = 0; cIdx < source2target_.size(); ++cIdx) if (target2source_[source2target_[cIdx]] == static_cast(cIdx)) - correspondences.push_back(std::make_pair(cIdx, source2target_[cIdx])); + correspondences.emplace_back(cIdx, source2target_[cIdx]); correspondences_->resize(correspondences.size()); for (std::size_t cIdx = 0; cIdx < correspondences.size(); ++cIdx) { @@ -593,14 +592,14 @@ main(int argc, char** argv) pcl::Keypoint::Ptr keypoint_detector; if (keypoint_type == 1) { - pcl::SIFTKeypoint* sift3D = + auto* sift3D = new pcl::SIFTKeypoint; sift3D->setScales(0.01f, 3, 2); sift3D->setMinimumContrast(0.0); keypoint_detector.reset(sift3D); } else { - pcl::HarrisKeypoint3D* harris3D = + auto* harris3D = new pcl::HarrisKeypoint3D( pcl::HarrisKeypoint3D::HARRIS); harris3D->setNonMaxSupression(true); @@ -644,7 +643,7 @@ main(int argc, char** argv) pcl::PCLSurfaceBase::Ptr surface_reconstruction; if (surface_type == 1) { - pcl::GreedyProjectionTriangulation* gp3 = + auto* gp3 = new pcl::GreedyProjectionTriangulation; // Set the maximum distance between connected points (maximum edge length) @@ -687,7 +686,7 @@ main(int argc, char** argv) } break; case 2: { - pcl::SHOTColorEstimationOMP* shot = + auto* shot = new pcl::SHOTColorEstimationOMP; shot->setRadiusSearch(0.04); pcl::Feature::Ptr feature_extractor(shot); diff --git a/apps/src/grabcut_2d.cpp b/apps/src/grabcut_2d.cpp index 02b3faec5f8..3c09facd399 100644 --- a/apps/src/grabcut_2d.cpp +++ b/apps/src/grabcut_2d.cpp @@ -232,12 +232,12 @@ GrabCutHelper::display(int display_type) { switch (display_type) { case 0: - glDrawPixels(image_->width, image_->height, GL_RGB, GL_FLOAT, &((*image_)[0])); + glDrawPixels(image_->width, image_->height, GL_RGB, GL_FLOAT, *image_->data()); break; case 1: glDrawPixels( - gmm_image_->width, gmm_image_->height, GL_RGB, GL_FLOAT, &((*gmm_image_)[0])); + gmm_image_->width, gmm_image_->height, GL_RGB, GL_FLOAT, *gmm_image_->data()); break; case 2: @@ -245,7 +245,7 @@ GrabCutHelper::display(int display_type) n_links_image_->height, GL_LUMINANCE, GL_FLOAT, - &((*n_links_image_)[0])); + *n_links_image_->data()); break; case 3: @@ -253,7 +253,7 @@ GrabCutHelper::display(int display_type) t_links_image_->height, GL_RGB, GL_FLOAT, - &((*t_links_image_)[0])); + *t_links_image_->data()); break; default: @@ -270,7 +270,7 @@ GrabCutHelper::overlayAlpha() alpha_image_->height, GL_ALPHA, GL_FLOAT, - &((*alpha_image_)[0])); + *alpha_image_->data()); } /* GUI interface */ @@ -297,7 +297,7 @@ display() display_image->height, GL_RGB, GL_FLOAT, - &((*display_image)[0])); + *display_image->data()); else grabcut.display(display_type); diff --git a/apps/src/manual_registration/manual_registration.cpp b/apps/src/manual_registration/manual_registration.cpp index b7cf5d8a009..16e9e3923fd 100644 --- a/apps/src/manual_registration/manual_registration.cpp +++ b/apps/src/manual_registration/manual_registration.cpp @@ -297,7 +297,7 @@ ManualRegistration::orthoChanged(int state) void ManualRegistration::applyTransformPressed() { - PCLViewerDialog* diag = new PCLViewerDialog(this); + auto* diag = new PCLViewerDialog(this); diag->setModal(true); diag->setGeometry(this->x(), this->y(), this->width(), this->height()); diag->setPointClouds(cloud_src_, cloud_dst_, Eigen::Affine3f(transform_)); diff --git a/apps/src/ni_agast.cpp b/apps/src/ni_agast.cpp index 6793e490d0a..701fc1ebae5 100644 --- a/apps/src/ni_agast.cpp +++ b/apps/src/ni_agast.cpp @@ -67,9 +67,8 @@ class AGASTDemo { : cloud_viewer_("AGAST 2D Keypoints -- PointCloud") , grabber_(grabber) , image_viewer_("AGAST 2D Keypoints -- Image") - , bmax_(255) - , threshold_(30) - , detector_type_(0) + , + {} ///////////////////////////////////////////////////////////////////////// @@ -129,7 +128,7 @@ class AGASTDemo { void keyboard_callback(const pcl::visualization::KeyboardEvent& event, void* cookie) { - AGASTDemo* obj = static_cast(cookie); + auto* obj = static_cast(cookie); if (event.getKeyCode()) { std::stringstream ss; @@ -289,8 +288,8 @@ class AGASTDemo { if (keypoints && !keypoints->empty()) { image_viewer_.removeLayer(getStrBool(keypts)); for (std::size_t i = 0; i < keypoints->size(); ++i) { - int u = int((*keypoints)[i].u); - int v = int((*keypoints)[i].v); + int u = static_cast((*keypoints)[i].u); + int v = static_cast((*keypoints)[i].v); image_viewer_.markPoint(u, v, visualization::red_color, @@ -330,9 +329,9 @@ class AGASTDemo { PointCloud::Ptr keypoints_; - double bmax_; - double threshold_; - int detector_type_; + double bmax_{255}; + double threshold_{30}; + int detector_type_{0}; private: boost::signals2::connection cloud_connection; diff --git a/apps/src/ni_brisk.cpp b/apps/src/ni_brisk.cpp index 274cdf5a8d6..2ad4645b8c8 100644 --- a/apps/src/ni_brisk.cpp +++ b/apps/src/ni_brisk.cpp @@ -107,8 +107,8 @@ class BRISKDemo { inline PointT bilinearInterpolation(const CloudConstPtr& cloud, float x, float y) { - int u = int(x); - int v = int(y); + int u = static_cast(x); + int v = static_cast(y); PointT pt; pt.x = pt.y = pt.z = 0; @@ -118,7 +118,7 @@ class BRISKDemo { const PointT& p3 = (*cloud)(u, v + 1); const PointT& p4 = (*cloud)(u + 1, v + 1); - float fx = x - float(u), fy = y - float(v); + float fx = x - static_cast(u), fy = y - static_cast(v); float fx1 = 1.0f - fx, fy1 = 1.0f - fy; float w1 = fx1 * fy1, w2 = fx * fy1, w3 = fx1 * fy, w4 = fx * fy; @@ -236,8 +236,8 @@ class BRISKDemo { image_viewer_.removeLayer(getStrBool(keypts)); for (std::size_t i = 0; i < keypoints->size(); ++i) { - int u = int((*keypoints)[i].x); - int v = int((*keypoints)[i].y); + int u = static_cast((*keypoints)[i].x); + int v = static_cast((*keypoints)[i].y); image_viewer_.markPoint(u, v, visualization::red_color, diff --git a/apps/src/ni_linemod.cpp b/apps/src/ni_linemod.cpp index 52452ec0bd6..a196a181b96 100644 --- a/apps/src/ni_linemod.cpp +++ b/apps/src/ni_linemod.cpp @@ -80,7 +80,7 @@ class NILinemod { : cloud_viewer_("PointCloud") , grabber_(grabber) , image_viewer_("Image") - , first_frame_(true) + , { added = false; @@ -566,7 +566,7 @@ class NILinemod { private: boost::signals2::connection cloud_connection, image_connection; - bool first_frame_; + bool first_frame_{true}; // Segmentation pcl::Indices indices_fullset_; diff --git a/apps/src/ni_susan.cpp b/apps/src/ni_susan.cpp index d67eb2568a7..c27067e6bb6 100644 --- a/apps/src/ni_susan.cpp +++ b/apps/src/ni_susan.cpp @@ -144,8 +144,8 @@ class SUSANDemo { if (keypoints && !keypoints->empty()) { image_viewer_.removeLayer(getStrBool(keypts)); for (std::size_t i = 0; i < keypoints->size(); ++i) { - int u = int((*keypoints)[i].label % cloud->width); - int v = cloud->height - int((*keypoints)[i].label / cloud->width); + int u = static_cast((*keypoints)[i].label % cloud->width); + int v = cloud->height - static_cast((*keypoints)[i].label / cloud->width); image_viewer_.markPoint(u, v, visualization::red_color, diff --git a/apps/src/openni_3d_concave_hull.cpp b/apps/src/openni_3d_concave_hull.cpp index d4c0309704a..1e4642ee8a1 100644 --- a/apps/src/openni_3d_concave_hull.cpp +++ b/apps/src/openni_3d_concave_hull.cpp @@ -57,7 +57,7 @@ using namespace std::chrono_literals; static double last = pcl::getTime(); \ if (++count == 100) { \ double now = pcl::getTime(); \ - std::cout << "Average framerate(" << _WHAT_ << "): " \ + std::cout << "Average framerate(" << (_WHAT_) << "): " \ << double(count) / double(now - last) << " Hz" << std::endl; \ count = 0; \ last = now; \ @@ -204,7 +204,7 @@ main(int argc, char** argv) return 1; } - std::string device_id = ""; + std::string device_id; if (pcl::console::parse_argument(argc, argv, "-device_id", device_id) == -1 && argc > 1 && argv[1][0] != '-') device_id = argv[1]; diff --git a/apps/src/openni_3d_convex_hull.cpp b/apps/src/openni_3d_convex_hull.cpp index 674ea43ead0..c976c4354c2 100644 --- a/apps/src/openni_3d_convex_hull.cpp +++ b/apps/src/openni_3d_convex_hull.cpp @@ -57,7 +57,7 @@ using namespace pcl::visualization; static double last = pcl::getTime(); \ if (++count == 100) { \ double now = pcl::getTime(); \ - std::cout << "Average framerate(" << _WHAT_ << "): " \ + std::cout << "Average framerate(" << (_WHAT_) << "): " \ << double(count) / double(now - last) << " Hz" << std::endl; \ count = 0; \ last = now; \ @@ -202,7 +202,7 @@ main(int argc, char** argv) return 1; } - std::string device_id = ""; + std::string device_id; if (pcl::console::parse_argument(argc, argv, "-device_id", device_id) == -1 && argc > 1 && argv[1][0] != '-') device_id = argv[1]; diff --git a/apps/src/openni_boundary_estimation.cpp b/apps/src/openni_boundary_estimation.cpp index 4b343c1faa4..7c911b33b22 100644 --- a/apps/src/openni_boundary_estimation.cpp +++ b/apps/src/openni_boundary_estimation.cpp @@ -64,7 +64,7 @@ using ColorHandlerConstPtr = ColorHandler::ConstPtr; double now = pcl::getTime(); \ ++count; \ if (now - last >= 1.0) { \ - std::cout << "Average framerate(" << _WHAT_ << "): " \ + std::cout << "Average framerate(" << (_WHAT_) << "): " \ << double(count) / double(now - last) << " Hz" << std::endl; \ count = 0; \ last = now; \ @@ -220,7 +220,7 @@ main(int argc, char** argv) return 1; } - std::string device_id = ""; + std::string device_id; if (pcl::console::parse_argument(argc, argv, "-device_id", device_id) == -1 && argc > 1 && argv[1][0] != '-') device_id = argv[1]; diff --git a/apps/src/openni_fast_mesh.cpp b/apps/src/openni_fast_mesh.cpp index e3701033940..828e7f0626a 100644 --- a/apps/src/openni_fast_mesh.cpp +++ b/apps/src/openni_fast_mesh.cpp @@ -56,7 +56,7 @@ using namespace std::chrono_literals; static double last = pcl::getTime(); \ if (++count == 100) { \ double now = pcl::getTime(); \ - std::cout << "Average framerate(" << _WHAT_ << "): " \ + std::cout << "Average framerate(" << (_WHAT_) << "): " \ << double(count) / double(now - last) << " Hz" << std::endl; \ count = 0; \ last = now; \ @@ -190,7 +190,7 @@ main(int argc, char** argv) return 1; } - std::string device_id = ""; + std::string device_id; if (pcl::console::parse_argument(argc, argv, "-device_id", device_id) == -1 && argc > 1 && argv[1][0] != '-') device_id = argv[1]; diff --git a/apps/src/openni_feature_persistence.cpp b/apps/src/openni_feature_persistence.cpp index 83412d7e970..4eb6926f1ed 100644 --- a/apps/src/openni_feature_persistence.cpp +++ b/apps/src/openni_feature_persistence.cpp @@ -62,7 +62,7 @@ using namespace std::chrono_literals; double now = pcl::getTime(); \ ++count; \ if (now - last >= 1.0) { \ - std::cout << "Average framerate(" << _WHAT_ << "): " \ + std::cout << "Average framerate(" << (_WHAT_) << "): " \ << double(count) / double(now - last) << " Hz" << std::endl; \ count = 0; \ last = now; \ @@ -285,7 +285,7 @@ main(int argc, char** argv) return 1; } - std::string device_id = ""; + std::string device_id; float subsampling_leaf_size = default_subsampling_leaf_size; double normal_search_radius = default_normal_search_radius; std::vector scales_vector_double = default_scales_vector; @@ -300,7 +300,7 @@ main(int argc, char** argv) argc, argv, "-normal_search_radius", normal_search_radius); pcl::console::parse_multiple_arguments(argc, argv, "-scales", scales_vector_double); for (std::size_t i = 0; i < scales_vector_double.size(); ++i) - scales_vector[i] = float(scales_vector_double[i]); + scales_vector[i] = static_cast(scales_vector_double[i]); pcl::console::parse_argument(argc, argv, "-persistence_alpha", alpha); ///////////////////////////////////////////////////////////////////// diff --git a/apps/src/openni_ii_normal_estimation.cpp b/apps/src/openni_ii_normal_estimation.cpp index 942447f35b2..d0f6fd516d2 100644 --- a/apps/src/openni_ii_normal_estimation.cpp +++ b/apps/src/openni_ii_normal_estimation.cpp @@ -55,7 +55,7 @@ using namespace std::chrono_literals; double now = pcl::getTime(); \ ++count; \ if (now - last >= 1.0) { \ - std::cout << "Average framerate(" << _WHAT_ << "): " \ + std::cout << "Average framerate(" << (_WHAT_) << "): " \ << double(count) / double(now - last) << " Hz" << std::endl; \ count = 0; \ last = now; \ @@ -229,7 +229,7 @@ main(int argc, char** argv) return 1; } - std::string device_id = ""; + std::string device_id; if (pcl::console::parse_argument(argc, argv, "-device_id", device_id) == -1 && argc > 1 && argv[1][0] != '-') device_id = argv[1]; diff --git a/apps/src/openni_klt.cpp b/apps/src/openni_klt.cpp index 504d40dd665..ad269bad8a2 100644 --- a/apps/src/openni_klt.cpp +++ b/apps/src/openni_klt.cpp @@ -56,7 +56,7 @@ double now = pcl::getTime(); \ ++count; \ if (now - last >= 1.0) { \ - std::cout << "Average framerate(" << _WHAT_ << "): " \ + std::cout << "Average framerate(" << (_WHAT_) << "): " \ << double(count) / double(now - last) << " Hz" << std::endl; \ count = 0; \ last = now; \ @@ -112,7 +112,7 @@ class OpenNIViewer { using CloudConstPtr = typename Cloud::ConstPtr; OpenNIViewer(pcl::Grabber& grabber) - : grabber_(grabber), rgb_data_(nullptr), rgb_data_size_(0), counter_(0) + : grabber_(grabber), {} void @@ -288,13 +288,13 @@ class OpenNIViewer { CloudConstPtr cloud_; openni_wrapper::Image::Ptr image_; - unsigned char* rgb_data_; - unsigned rgb_data_size_; + unsigned char* rgb_data_{nullptr}; + unsigned rgb_data_size_{0}; typename pcl::tracking::PyramidalKLTTracker::Ptr tracker_; pcl::PointCloud::ConstPtr keypoints_; pcl::PointIndicesConstPtr points_; pcl::shared_ptr> points_status_; - int counter_; + int counter_{0}; }; // Create the PCLVisualizer object diff --git a/apps/src/openni_mls_smoothing.cpp b/apps/src/openni_mls_smoothing.cpp index 641c341c745..3f96c705268 100644 --- a/apps/src/openni_mls_smoothing.cpp +++ b/apps/src/openni_mls_smoothing.cpp @@ -54,7 +54,7 @@ double now = pcl::getTime(); \ ++count; \ if (now - last >= 1.0) { \ - std::cout << "Average framerate(" << _WHAT_ << "): " \ + std::cout << "Average framerate(" << (_WHAT_) << "): " \ << double(count) / double(now - last) << " Hz" << std::endl; \ count = 0; \ last = now; \ @@ -221,7 +221,7 @@ main(int argc, char** argv) return 1; } - std::string device_id = ""; + std::string device_id; double search_radius = default_search_radius; double sqr_gauss_param = default_sqr_gauss_param; bool sqr_gauss_param_set = true; diff --git a/apps/src/openni_mobile_server.cpp b/apps/src/openni_mobile_server.cpp index aee1892abf6..d93e6cd5ad1 100644 --- a/apps/src/openni_mobile_server.cpp +++ b/apps/src/openni_mobile_server.cpp @@ -238,7 +238,7 @@ main(int argc, char** argv) return 1; } - std::string device_id = ""; + std::string device_id; int port = 11111; float leaf_x = 0.01f, leaf_y = 0.01f, leaf_z = 0.01f; diff --git a/apps/src/openni_octree_compression.cpp b/apps/src/openni_octree_compression.cpp index 4592cbd3407..e8e2c0a8540 100644 --- a/apps/src/openni_octree_compression.cpp +++ b/apps/src/openni_octree_compression.cpp @@ -108,7 +108,7 @@ char usage[] = "\n" double now = pcl::getTime(); \ ++count; \ if (now - last >= 1.0) { \ - std::cout << "Average framerate(" << _WHAT_ << "): " \ + std::cout << "Average framerate(" << (_WHAT_) << "): " \ << double(count) / double(now - last) << " Hz" << std::endl; \ count = 0; \ last = now; \ @@ -351,7 +351,7 @@ main(int argc, char** argv) // apply profile settings pointResolution = selectedProfile.pointResolution; - octreeResolution = float(selectedProfile.octreeResolution); + octreeResolution = static_cast(selectedProfile.octreeResolution); doVoxelGridDownDownSampling = selectedProfile.doVoxelGridDownSampling; iFrameRate = selectedProfile.iFrameRate; doColorEncoding = selectedProfile.doColorEncoding; diff --git a/apps/src/openni_organized_compression.cpp b/apps/src/openni_organized_compression.cpp index f68314f4bf7..75593da9b2f 100644 --- a/apps/src/openni_organized_compression.cpp +++ b/apps/src/openni_organized_compression.cpp @@ -92,7 +92,7 @@ char usage[] = "\n" double now = pcl::getTime(); \ ++count; \ if (now - last >= 1.0) { \ - std::cout << "Average framerate(" << _WHAT_ << "): " \ + std::cout << "Average framerate(" << (_WHAT_) << "): " \ << double(count) / double(now - last) << " Hz" << std::endl; \ count = 0; \ last = now; \ @@ -226,14 +226,14 @@ struct EventHelper { depth_image->fillDepthImageRaw( width, height, - &disparity_data[0], + disparity_data.data(), static_cast(width * sizeof(std::uint16_t))); if (image->getEncoding() != openni_wrapper::Image::RGB) { rgb_data.resize(width * height * 3); image->fillRGB(width, height, - &rgb_data[0], + rgb_data.data(), static_cast(width * sizeof(std::uint8_t) * 3)); } diff --git a/apps/src/openni_organized_edge_detection.cpp b/apps/src/openni_organized_edge_detection.cpp index 0042f36ffcb..5b8b3c5e04f 100644 --- a/apps/src/openni_organized_edge_detection.cpp +++ b/apps/src/openni_organized_edge_detection.cpp @@ -222,7 +222,7 @@ class OpenNIOrganizedEdgeDetection { ne.setInputCloud(cloud_.makeShared()); ne.compute(*normal_cloud); double normal_end = pcl::getTime(); - std::cout << "Normal Estimation took " << double(normal_end - normal_start) + std::cout << "Normal Estimation took " << (normal_end - normal_start) << std::endl; oed.setInputNormals(normal_cloud); @@ -234,12 +234,12 @@ class OpenNIOrganizedEdgeDetection { oed.compute(labels, label_indices); double oed_end = pcl::getTime(); - std::cout << "Edge Detection took " << double(oed_end - oed_start) << std::endl; - std::cout << "Frame took " << double(oed_end - normal_start) << std::endl; + std::cout << "Edge Detection took " << (oed_end - oed_start) << std::endl; + std::cout << "Frame took " << (oed_end - normal_start) << std::endl; // Make gray point cloud for (auto& point : cloud_.points) { - std::uint8_t gray = std::uint8_t((point.r + point.g + point.b) / 3); + auto gray = static_cast((point.r + point.g + point.b) / 3); point.r = point.g = point.b = gray; } @@ -325,7 +325,7 @@ main(int argc, char** argv) return 1; } - std::string device_id = ""; + std::string device_id; if (pcl::console::parse_argument(argc, argv, "-device_id", device_id) == -1 && argc > 1 && argv[1][0] != '-') device_id = argv[1]; diff --git a/apps/src/openni_organized_multi_plane_segmentation.cpp b/apps/src/openni_organized_multi_plane_segmentation.cpp index a587a7e2154..36f0c621254 100644 --- a/apps/src/openni_organized_multi_plane_segmentation.cpp +++ b/apps/src/openni_organized_multi_plane_segmentation.cpp @@ -144,7 +144,7 @@ class OpenNIOrganizedMultiPlaneSegmentation { ne.setInputCloud(prev_cloud); ne.compute(*normal_cloud); double normal_end = pcl::getTime(); - std::cout << "Normal Estimation took " << double(normal_end - normal_start) + std::cout << "Normal Estimation took " << (normal_end - normal_start) << std::endl; double plane_extract_start = pcl::getTime(); @@ -153,8 +153,8 @@ class OpenNIOrganizedMultiPlaneSegmentation { mps.segmentAndRefine(regions); double plane_extract_end = pcl::getTime(); std::cout << "Plane extraction took " - << double(plane_extract_end - plane_extract_start) << std::endl; - std::cout << "Frame took " << double(plane_extract_end - normal_start) + << (plane_extract_end - plane_extract_start) << std::endl; + std::cout << "Frame took " << (plane_extract_end - normal_start) << std::endl; pcl::PointCloud::Ptr cluster(new pcl::PointCloud); diff --git a/apps/src/openni_planar_convex_hull.cpp b/apps/src/openni_planar_convex_hull.cpp index d42481a2caa..ae3ae70a285 100644 --- a/apps/src/openni_planar_convex_hull.cpp +++ b/apps/src/openni_planar_convex_hull.cpp @@ -192,7 +192,7 @@ main(int argc, char** argv) return 1; } - std::string device_id = ""; + std::string device_id; double threshold = 0.05; if (pcl::console::parse_argument(argc, argv, "-device_id", device_id) == -1 && diff --git a/apps/src/openni_planar_segmentation.cpp b/apps/src/openni_planar_segmentation.cpp index d06d4fde3b0..a4920b9709b 100644 --- a/apps/src/openni_planar_segmentation.cpp +++ b/apps/src/openni_planar_segmentation.cpp @@ -185,7 +185,7 @@ main(int argc, char** argv) return 1; } - std::string device_id = ""; + std::string device_id; double threshold = 0.05; if (pcl::console::parse_argument(argc, argv, "-device_id", device_id) == -1 && diff --git a/apps/src/openni_shift_to_depth_conversion.cpp b/apps/src/openni_shift_to_depth_conversion.cpp index 7de78e4f2eb..00a842b8b2d 100644 --- a/apps/src/openni_shift_to_depth_conversion.cpp +++ b/apps/src/openni_shift_to_depth_conversion.cpp @@ -81,13 +81,13 @@ class SimpleOpenNIViewer { depth_image->fillDepthImageRaw( width, height, - &raw_shift_data[0], + raw_shift_data.data(), static_cast(width * sizeof(std::uint16_t))); // convert raw shift data to raw depth data raw_depth_data.resize(width * height); grabber_.convertShiftToDepth( - &raw_shift_data[0], &raw_depth_data[0], raw_shift_data.size()); + raw_shift_data.data(), raw_depth_data.data(), raw_shift_data.size()); // check for color data if (image->getEncoding() != openni_wrapper::Image::RGB) { @@ -95,7 +95,7 @@ class SimpleOpenNIViewer { rgb_data.resize(width * height * 3); image->fillRGB(width, height, - &rgb_data[0], + rgb_data.data(), static_cast(width * sizeof(std::uint8_t) * 3)); } diff --git a/apps/src/openni_tracking.cpp b/apps/src/openni_tracking.cpp index 174f889a19c..af765c1518e 100644 --- a/apps/src/openni_tracking.cpp +++ b/apps/src/openni_tracking.cpp @@ -82,7 +82,7 @@ double end_time = pcl::getTime(); \ static unsigned count = 0; \ if (++count == 10) { \ - std::cout << "Average framerate(" << _WHAT_ << "): " \ + std::cout << "Average framerate(" << (_WHAT_) << "): " \ << double(count) / double(duration) << " Hz" << std::endl; \ count = 0; \ duration = 0.0; \ @@ -121,10 +121,10 @@ class OpenNISegmentTracking { bool use_fixed) : viewer_("PCL OpenNI Tracking Viewer") , device_id_(device_id) - , new_cloud_(false) - , ne_(thread_nr) - , counter_(0) - , use_convex_hull_(use_convex_hull) + , + ne_(thread_nr) + , + use_convex_hull_(use_convex_hull) , visualize_non_downsample_(visualize_non_downsample) , visualize_particles_(visualize_particles) , downsampling_grid_size_(downsampling_grid_size) @@ -339,7 +339,7 @@ class OpenNISegmentTracking { FPS_CALC_BEGIN; double start = pcl::getTime(); pcl::VoxelGrid grid; - grid.setLeafSize(float(leaf_size), float(leaf_size), float(leaf_size)); + grid.setLeafSize(static_cast(leaf_size), static_cast(leaf_size), static_cast(leaf_size)); grid.setInputCloud(cloud); grid.filter(result); double end = pcl::getTime(); @@ -549,11 +549,11 @@ class OpenNISegmentTracking { double segment_distance = c[0] * c[0] + c[1] * c[1]; for (std::size_t i = 1; i < cluster_indices.size(); i++) { temp_cloud.reset(new Cloud); - extractSegmentCluster(target_cloud, cluster_indices, int(i), *temp_cloud); + extractSegmentCluster(target_cloud, cluster_indices, static_cast(i), *temp_cloud); pcl::compute3DCentroid(*temp_cloud, c); double distance = c[0] * c[0] + c[1] * c[1]; if (distance < segment_distance) { - segment_index = int(i); + segment_index = static_cast(i); segment_distance = distance; } } @@ -630,10 +630,10 @@ class OpenNISegmentTracking { std::string device_id_; std::mutex mtx_; - bool new_cloud_; + bool new_cloud_{false}; pcl::NormalEstimationOMP ne_; // to store threadpool ParticleFilter::Ptr tracker_; - int counter_; + int counter_{0}; bool use_convex_hull_; bool visualize_non_downsample_; bool visualize_particles_; @@ -669,7 +669,7 @@ main(int argc, char** argv) return 1; } - std::string device_id = ""; + std::string device_id; bool use_convex_hull = true; bool visualize_non_downsample = false; bool visualize_particles = true; diff --git a/apps/src/openni_uniform_sampling.cpp b/apps/src/openni_uniform_sampling.cpp index 6167cdacb3c..a3f45fcc7c1 100644 --- a/apps/src/openni_uniform_sampling.cpp +++ b/apps/src/openni_uniform_sampling.cpp @@ -55,7 +55,7 @@ using namespace std::chrono_literals; double now = pcl::getTime(); \ ++count; \ if (now - last >= 1.0) { \ - std::cout << "Average framerate(" << _WHAT_ << "): " \ + std::cout << "Average framerate(" << (_WHAT_) << "): " \ << double(count) / double(now - last) << " Hz" << std::endl; \ count = 0; \ last = now; \ @@ -188,7 +188,7 @@ main(int argc, char** argv) return 1; } - std::string device_id = ""; + std::string device_id; float leaf_res = 0.05f; if (pcl::console::parse_argument(argc, argv, "-device_id", device_id) == -1 && diff --git a/apps/src/openni_voxel_grid.cpp b/apps/src/openni_voxel_grid.cpp index 27749cbe325..cbac0039c6c 100644 --- a/apps/src/openni_voxel_grid.cpp +++ b/apps/src/openni_voxel_grid.cpp @@ -52,7 +52,7 @@ double now = pcl::getTime(); \ ++count; \ if (now - last >= 1.0) { \ - std::cout << "Average framerate(" << _WHAT_ << "): " \ + std::cout << "Average framerate(" << (_WHAT_) << "): " \ << double(count) / double(now - last) << " Hz" << std::endl; \ count = 0; \ last = now; \ @@ -187,7 +187,7 @@ main(int argc, char** argv) return 1; } - std::string device_id = ""; + std::string device_id; float min_v = 0.0f, max_v = 5.0f; std::string field_name = "z"; float leaf_x = 0.01f, leaf_y = 0.01f, leaf_z = 0.01f; diff --git a/apps/src/organized_segmentation_demo.cpp b/apps/src/organized_segmentation_demo.cpp index cbf81a72728..f08bd3f275a 100644 --- a/apps/src/organized_segmentation_demo.cpp +++ b/apps/src/organized_segmentation_demo.cpp @@ -35,11 +35,11 @@ displayPlanarRegions( pcl::PointXYZ pt2 = pcl::PointXYZ(centroid[0] + (0.5f * model[0]), centroid[1] + (0.5f * model[1]), centroid[2] + (0.5f * model[2])); - sprintf(name, "normal_%d", unsigned(i)); + sprintf(name, "normal_%d", static_cast(i)); viewer->addArrow(pt2, pt1, 1.0, 0, 0, false, name); contour->points = regions[i].getContour(); - sprintf(name, "plane_%02d", int(i)); + sprintf(name, "plane_%02d", static_cast(i)); pcl::visualization::PointCloudColorHandlerCustom color( contour, red[i % 6], grn[i % 6], blu[i % 6]); if (!viewer->updatePointCloud(contour, color, name)) @@ -59,7 +59,7 @@ displayEuclideanClusters(const pcl::PointCloud::CloudVectorType& cluster unsigned char blu[6] = {0, 0, 255, 0, 255, 255}; for (std::size_t i = 0; i < clusters.size(); i++) { - sprintf(name, "cluster_%d", int(i)); + sprintf(name, "cluster_%d", static_cast(i)); pcl::PointCloud::ConstPtr cluster_cloud( new pcl::PointCloud(clusters[i])); pcl::visualization::PointCloudColorHandlerCustom color0( @@ -126,15 +126,15 @@ removePreviousDataFromScreen(std::size_t prev_models_size, { char name[1024]; for (std::size_t i = 0; i < prev_models_size; i++) { - sprintf(name, "normal_%d", unsigned(i)); + sprintf(name, "normal_%d", static_cast(i)); viewer->removeShape(name); - sprintf(name, "plane_%02d", int(i)); + sprintf(name, "plane_%02d", static_cast(i)); viewer->removePointCloud(name); } for (std::size_t i = 0; i < prev_clusters_size; i++) { - sprintf(name, "cluster_%d", int(i)); + sprintf(name, "cluster_%d", static_cast(i)); viewer->removePointCloud(name); } } @@ -173,7 +173,7 @@ comparePointToRegion(PointT& pt, pt_vec[0] = pt.x; pt_vec[1] = pt.y; pt_vec[2] = pt.z; - Eigen::Vector3f projected(pt_vec - mc * float(ptp_dist)); + Eigen::Vector3f projected(pt_vec - mc * static_cast(ptp_dist)); PointT projected_pt; projected_pt.x = projected[0]; projected_pt.y = projected[1]; @@ -370,7 +370,7 @@ OrganizedSegmentationDemo::cloud_cb(const CloudConstPtr& cloud) mps.segment(regions); } double mps_end = pcl::getTime(); - std::cout << "MPS+Refine took: " << double(mps_end - mps_start) << std::endl; + std::cout << "MPS+Refine took: " << (mps_end - mps_start) << std::endl; // Segment Objects pcl::PointCloud::CloudVectorType clusters; diff --git a/apps/src/pcd_organized_edge_detection.cpp b/apps/src/pcd_organized_edge_detection.cpp index e1eb6f9af11..37a38b82d72 100644 --- a/apps/src/pcd_organized_edge_detection.cpp +++ b/apps/src/pcd_organized_edge_detection.cpp @@ -204,7 +204,7 @@ compute(const pcl::PCLPointCloud2::ConstPtr& input, // Make gray point clouds for (auto& point : cloud->points) { - std::uint8_t gray = std::uint8_t((point.r + point.g + point.b) / 3); + auto gray = static_cast((point.r + point.g + point.b) / 3); point.r = point.g = point.b = gray; } diff --git a/apps/src/pcd_organized_multi_plane_segmentation.cpp b/apps/src/pcd_organized_multi_plane_segmentation.cpp index 82d4507034d..8fe6e52df31 100644 --- a/apps/src/pcd_organized_multi_plane_segmentation.cpp +++ b/apps/src/pcd_organized_multi_plane_segmentation.cpp @@ -50,9 +50,9 @@ class PCDOrganizedMultiPlaneSegmentation { pcl::visualization::PCLVisualizer viewer; typename pcl::PointCloud::ConstPtr cloud; bool refine_; - float threshold_; - bool depth_dependent_; - bool polygon_refinement_; + float threshold_{0.02f}; + bool depth_dependent_{true}; + bool polygon_refinement_{false}; public: PCDOrganizedMultiPlaneSegmentation(typename pcl::PointCloud::ConstPtr cloud_, @@ -60,9 +60,8 @@ class PCDOrganizedMultiPlaneSegmentation { : viewer("Viewer") , cloud(cloud_) , refine_(refine) - , threshold_(0.02f) - , depth_dependent_(true) - , polygon_refinement_(false) + , + { viewer.setBackgroundColor(0, 0, 0); viewer.addCoordinateSystem(1.0, "global"); @@ -143,7 +142,7 @@ class PCDOrganizedMultiPlaneSegmentation { ne.setInputCloud(cloud); ne.compute(*normal_cloud); double normal_end = pcl::getTime(); - std::cout << "Normal Estimation took " << double(normal_end - normal_start) + std::cout << "Normal Estimation took " << (normal_end - normal_start) << std::endl; double plane_extract_start = pcl::getTime(); @@ -155,9 +154,9 @@ class PCDOrganizedMultiPlaneSegmentation { mps.segment(regions); double plane_extract_end = pcl::getTime(); std::cout << "Plane extraction took " - << double(plane_extract_end - plane_extract_start) + << (plane_extract_end - plane_extract_start) << " with planar regions found: " << regions.size() << std::endl; - std::cout << "Frame took " << double(plane_extract_end - normal_start) << std::endl; + std::cout << "Frame took " << (plane_extract_end - normal_start) << std::endl; typename pcl::PointCloud::Ptr cluster(new pcl::PointCloud); diff --git a/apps/src/pcd_select_object_plane.cpp b/apps/src/pcd_select_object_plane.cpp index b7914d72668..1db35b3ac5c 100644 --- a/apps/src/pcd_select_object_plane.cpp +++ b/apps/src/pcd_select_object_plane.cpp @@ -71,7 +71,7 @@ template class ObjectSelection { public: ObjectSelection() - : plane_comparator_(new EdgeAwarePlaneComparator), rgb_data_() + : plane_comparator_(new EdgeAwarePlaneComparator), { // Set the parameters for planar segmentation plane_comparator_->setDistanceThreshold(0.01f, false); @@ -650,7 +650,7 @@ class ObjectSelection { // Segmentation typename EdgeAwarePlaneComparator::Ptr plane_comparator_; PointIndices::Ptr plane_indices_; - unsigned char* rgb_data_; + unsigned char* rgb_data_{}; std::vector distance_map_; // Results diff --git a/apps/src/pcd_video_player/pcd_video_player.cpp b/apps/src/pcd_video_player/pcd_video_player.cpp index 66c3d4fa104..2140825c927 100644 --- a/apps/src/pcd_video_player/pcd_video_player.cpp +++ b/apps/src/pcd_video_player/pcd_video_player.cpp @@ -224,8 +224,8 @@ PCDVideoPlayer::selectFilesButtonPressed() return; } - for (int i = 0; i < qt_pcd_files.size(); i++) { - pcd_files_.push_back(qt_pcd_files.at(i).toStdString()); + for (const auto & qt_pcd_file : qt_pcd_files) { + pcd_files_.push_back(qt_pcd_file.toStdString()); } current_frame_ = 0; diff --git a/apps/src/ppf_object_recognition.cpp b/apps/src/ppf_object_recognition.cpp index 9889d0c6a5e..05524130070 100644 --- a/apps/src/ppf_object_recognition.cpp +++ b/apps/src/ppf_object_recognition.cpp @@ -114,7 +114,7 @@ main(int argc, char** argv) ppf_estimator.compute(*cloud_model_ppf); PPFHashMapSearch::Ptr hashmap_search( - new PPFHashMapSearch(12.0f / 180.0f * float(M_PI), 0.05f)); + new PPFHashMapSearch(12.0f / 180.0f * static_cast(M_PI), 0.05f)); hashmap_search->setInputFeatureCloud(cloud_model_ppf); hashmap_search_vector.push_back(hashmap_search); } @@ -130,7 +130,7 @@ main(int argc, char** argv) // set parameters for the PPF registration procedure ppf_registration.setSceneReferencePointSamplingRate(10); ppf_registration.setPositionClusteringThreshold(0.2f); - ppf_registration.setRotationClusteringThreshold(30.0f / 180.0f * float(M_PI)); + ppf_registration.setRotationClusteringThreshold(30.0f / 180.0f * static_cast(M_PI)); ppf_registration.setSearchMethod(hashmap_search_vector[model_i]); ppf_registration.setInputSource(cloud_models_with_normals[model_i]); ppf_registration.setInputTarget(cloud_scene_input); diff --git a/apps/src/pyramid_surface_matching.cpp b/apps/src/pyramid_surface_matching.cpp index 5fd5f8bc4cb..6754e44a858 100644 --- a/apps/src/pyramid_surface_matching.cpp +++ b/apps/src/pyramid_surface_matching.cpp @@ -85,10 +85,10 @@ main(int argc, char** argv) PCL_INFO("Finished calculating the features ...\n"); std::vector> dim_range_input, dim_range_target; for (std::size_t i = 0; i < 3; ++i) - dim_range_input.emplace_back(float(-M_PI), float(M_PI)); + dim_range_input.emplace_back(static_cast(-M_PI), static_cast(M_PI)); dim_range_input.emplace_back(0.0f, 1.0f); for (std::size_t i = 0; i < 3; ++i) - dim_range_target.emplace_back(float(-M_PI) * 10.0f, float(M_PI) * 10.0f); + dim_range_target.emplace_back(static_cast(-M_PI) * 10.0f, static_cast(M_PI) * 10.0f); dim_range_target.emplace_back(0.0f, 50.0f); PyramidFeatureHistogram::Ptr pyramid_a( diff --git a/apps/src/render_views_tesselated_sphere.cpp b/apps/src/render_views_tesselated_sphere.cpp index 9f6ba71ef8c..e9101ed98c1 100644 --- a/apps/src/render_views_tesselated_sphere.cpp +++ b/apps/src/render_views_tesselated_sphere.cpp @@ -123,7 +123,7 @@ pcl::apps::RenderViewsTesselatedSphere::generateViews() sphere->GetPoint(ptIds_com[2], p3_com); vtkTriangle::TriangleCenter(p1_com, p2_com, p3_com, center); cam_positions[i] = - Eigen::Vector3f(float(center[0]), float(center[1]), float(center[2])); + Eigen::Vector3f(static_cast(center[0]), static_cast(center[1]), static_cast(center[2])); i++; } } @@ -133,7 +133,7 @@ pcl::apps::RenderViewsTesselatedSphere::generateViews() double cam_pos[3]; sphere->GetPoint(i, cam_pos); cam_positions[i] = - Eigen::Vector3f(float(cam_pos[0]), float(cam_pos[1]), float(cam_pos[2])); + Eigen::Vector3f(static_cast(cam_pos[0]), static_cast(cam_pos[1]), static_cast(cam_pos[2])); } } @@ -275,7 +275,7 @@ pcl::apps::RenderViewsTesselatedSphere::generateViews() for (int x = 0; x < 4; x++) for (int y = 0; y < 4; y++) backToRealScale_eigen(x, y) = - float(backToRealScale->GetMatrix()->GetElement(x, y)); + static_cast(backToRealScale->GetMatrix()->GetElement(x, y)); pcl::PointCloud::Ptr cloud(new pcl::PointCloud); cloud->points.resize(resolution_ * resolution_); @@ -380,12 +380,12 @@ pcl::apps::RenderViewsTesselatedSphere::generateViews() ids = vtkIdTypeArray::SafeDownCast(hdw_selection->GetNode(0)->GetSelectionList()); double visible_area = 0; for (vtkIdType sel_id = 0; sel_id < (ids->GetNumberOfTuples()); sel_id++) { - int id_mesh = int(ids->GetValue(sel_id)); + int id_mesh = static_cast(ids->GetValue(sel_id)); if (id_mesh >= polydata->GetNumberOfPolys()) continue; vtkCell* cell = polydata->GetCell(id_mesh); - vtkTriangle* triangle = dynamic_cast(cell); + auto* triangle = dynamic_cast(cell); double p0[3]; double p1[3]; double p2[3]; @@ -396,7 +396,7 @@ pcl::apps::RenderViewsTesselatedSphere::generateViews() visible_area += area; } - entropies_.push_back(float(visible_area / totalArea)); + entropies_.push_back(static_cast(visible_area / totalArea)); } // transform cloud to give camera coordinates instead of world coordinates! @@ -406,7 +406,7 @@ pcl::apps::RenderViewsTesselatedSphere::generateViews() for (int x = 0; x < 4; x++) for (int y = 0; y < 4; y++) - trans_view(x, y) = float(view_transform->GetElement(x, y)); + trans_view(x, y) = static_cast(view_transform->GetElement(x, y)); // NOTE: vtk view coordinate system is different than the standard camera // coordinates (z forward, y down, x right) thus, the flipping in y and z @@ -445,7 +445,7 @@ pcl::apps::RenderViewsTesselatedSphere::generateViews() for (int x = 0; x < 4; x++) for (int y = 0; y < 4; y++) - pose_view(x, y) = float(transOCtoCC->GetMatrix()->GetElement(x, y)); + pose_view(x, y) = static_cast(transOCtoCC->GetMatrix()->GetElement(x, y)); poses_.push_back(pose_view); } diff --git a/apps/src/stereo_ground_segmentation.cpp b/apps/src/stereo_ground_segmentation.cpp index 576705de5d6..8bd74992bb7 100755 --- a/apps/src/stereo_ground_segmentation.cpp +++ b/apps/src/stereo_ground_segmentation.cpp @@ -265,16 +265,16 @@ class HRCSSegmentation { for (const auto& region_index : region_indices) { if (region_index.indices.size() > 1000) { - for (std::size_t j = 0; j < region_index.indices.size(); j++) { - pcl::PointXYZ ground_pt((*cloud)[region_index.indices[j]].x, - (*cloud)[region_index.indices[j]].y, - (*cloud)[region_index.indices[j]].z); + for (int indice : region_index.indices) { + pcl::PointXYZ ground_pt((*cloud)[indice].x, + (*cloud)[indice].y, + (*cloud)[indice].z); ground_cloud->points.push_back(ground_pt); - (*ground_image)[region_index.indices[j]].g = static_cast( - ((*cloud)[region_index.indices[j]].g + 255) / 2); - (*label_image)[region_index.indices[j]].r = 0; - (*label_image)[region_index.indices[j]].g = 255; - (*label_image)[region_index.indices[j]].b = 0; + (*ground_image)[indice].g = static_cast( + ((*cloud)[indice].g + 255) / 2); + (*label_image)[indice].r = 0; + (*label_image)[indice].g = 255; + (*label_image)[indice].b = 0; } // Compute plane info @@ -346,21 +346,21 @@ class HRCSSegmentation { pcl::PointCloud extended_ground_cloud; for (const auto& region_index : region_indices) { if (region_index.indices.size() > 1000) { - for (std::size_t j = 0; j < region_index.indices.size(); j++) { + for (int indice : region_index.indices) { // Check to see if it has already been labeled - if ((*ground_image)[region_index.indices[j]].g == - (*ground_image)[region_index.indices[j]].b) { - pcl::PointXYZ ground_pt((*cloud)[region_index.indices[j]].x, - (*cloud)[region_index.indices[j]].y, - (*cloud)[region_index.indices[j]].z); + if ((*ground_image)[indice].g == + (*ground_image)[indice].b) { + pcl::PointXYZ ground_pt((*cloud)[indice].x, + (*cloud)[indice].y, + (*cloud)[indice].z); ground_cloud->points.push_back(ground_pt); - (*ground_image)[region_index.indices[j]].r = static_cast( - ((*cloud)[region_index.indices[j]].r + 255) / 2); - (*ground_image)[region_index.indices[j]].g = static_cast( - ((*cloud)[region_index.indices[j]].g + 255) / 2); - (*label_image)[region_index.indices[j]].r = 128; - (*label_image)[region_index.indices[j]].g = 128; - (*label_image)[region_index.indices[j]].b = 0; + (*ground_image)[indice].r = static_cast( + ((*cloud)[indice].r + 255) / 2); + (*ground_image)[indice].g = static_cast( + ((*cloud)[indice].g + 255) / 2); + (*label_image)[indice].r = 128; + (*label_image)[indice].g = 128; + (*label_image)[indice].b = 0; } } } @@ -425,11 +425,11 @@ class HRCSSegmentation { if ((ptp_dist > 0.5) && (ptp_dist < 3.0)) { - for (std::size_t j = 0; j < euclidean_label_index.indices.size(); j++) { - (*ground_image)[euclidean_label_index.indices[j]].r = 255; - (*label_image)[euclidean_label_index.indices[j]].r = 255; - (*label_image)[euclidean_label_index.indices[j]].g = 0; - (*label_image)[euclidean_label_index.indices[j]].b = 0; + for (int indice : euclidean_label_index.indices) { + (*ground_image)[indice].r = 255; + (*label_image)[indice].r = 255; + (*label_image)[indice].g = 0; + (*label_image)[indice].b = 0; } } } diff --git a/common/include/pcl/common/fft/.clang-tidy b/common/include/pcl/common/fft/.clang-tidy new file mode 100644 index 00000000000..6b766d3d201 --- /dev/null +++ b/common/include/pcl/common/fft/.clang-tidy @@ -0,0 +1,3 @@ +--- +# Disable all clang-tidy checks for third-party code (kiss_fft) +Checks: '-*' diff --git a/common/src/fft/.clang-tidy b/common/src/fft/.clang-tidy new file mode 100644 index 00000000000..6b766d3d201 --- /dev/null +++ b/common/src/fft/.clang-tidy @@ -0,0 +1,3 @@ +--- +# Disable all clang-tidy checks for third-party code (kiss_fft) +Checks: '-*' diff --git a/features/include/pcl/features/ppfrgb.h b/features/include/pcl/features/ppfrgb.h index c50fee1d314..9bbf999ae79 100644 --- a/features/include/pcl/features/ppfrgb.h +++ b/features/include/pcl/features/ppfrgb.h @@ -64,7 +64,7 @@ namespace pcl * \param output the resulting point cloud (which should be of type pcl::PPFRGBSignature); */ void - computeFeature (PointCloudOut &output); + computeFeature (PointCloudOut &output) override; }; template diff --git a/geometry/include/pcl/geometry/impl/polygon_operations.hpp b/geometry/include/pcl/geometry/impl/polygon_operations.hpp index 585ba6ae93f..4b012864f67 100644 --- a/geometry/include/pcl/geometry/impl/polygon_operations.hpp +++ b/geometry/include/pcl/geometry/impl/polygon_operations.hpp @@ -218,7 +218,7 @@ pcl::approximatePolygon2D(const typename pcl::PointCloud::VectorType& po covariance.coeffRef(2) = covariance.coeff(1); - float norm = 1.0f / float(num_points); + float norm = 1.0f / static_cast(num_points); centroid *= norm; covariance *= norm; covariance.coeffRef(0) -= centroid[0] * centroid[0]; @@ -235,7 +235,7 @@ pcl::approximatePolygon2D(const typename pcl::PointCloud::VectorType& po direction[1] = polygon[result[nIdx]].y - polygon[result[rIdx]].y; direction.normalize(); - if (std::abs(direction.dot(normal)) > float(M_SQRT1_2)) { + if (std::abs(direction.dot(normal)) > static_cast(M_SQRT1_2)) { std::swap(normal[0], normal[1]); normal[0] = -normal[0]; } @@ -289,7 +289,7 @@ pcl::approximatePolygon2D(const typename pcl::PointCloud::VectorType& po } else { // we have a new polygon in results, but inverted (clockwise <-> counter-clockwise) - for (std::vector::reverse_iterator it = result.rbegin(); + for (auto it = result.rbegin(); it != result.rend(); ++it) approx_polygon.push_back(polygon[*it]); diff --git a/keypoints/include/pcl/keypoints/harris_2d.h b/keypoints/include/pcl/keypoints/harris_2d.h index 5305d4f0eaf..3e5b109373c 100644 --- a/keypoints/include/pcl/keypoints/harris_2d.h +++ b/keypoints/include/pcl/keypoints/harris_2d.h @@ -77,15 +77,14 @@ namespace pcl */ HarrisKeypoint2D (ResponseMethod method = HARRIS, int window_width = 3, int window_height = 3, int min_distance = 5, float threshold = 0.0) : threshold_ (threshold) - , refine_ (false) - , nonmax_ (true) - , method_ (method) - , threads_ (0) - , response_ (new pcl::PointCloud ()) + , + method_ (method) + , + response_ (new pcl::PointCloud ()) , window_width_ (window_width) , window_height_ (window_height) - , skipped_pixels_ (0) - , min_distance_ (min_distance) + , + min_distance_ (min_distance) { name_ = "HarrisKeypoint2D"; } @@ -156,13 +155,13 @@ namespace pcl /// threshold for non maxima suppression float threshold_; /// corner refinement - bool refine_; + bool refine_{false}; /// non maximas suppression - bool nonmax_; + bool nonmax_{true}; /// cornerness computation method ResponseMethod method_; /// number of threads to be used - unsigned int threads_; + unsigned int threads_{0}; private: Eigen::MatrixXf derivatives_rows_; @@ -184,7 +183,7 @@ namespace pcl /// half window height int half_window_height_; /// number of pixels to skip within search window - int skipped_pixels_; + int skipped_pixels_{0}; /// minimum distance between two keypoints int min_distance_; /// intensity field accessor diff --git a/keypoints/include/pcl/keypoints/impl/harris_2d.hpp b/keypoints/include/pcl/keypoints/impl/harris_2d.hpp index fa8da44a169..0c9905f8da9 100644 --- a/keypoints/include/pcl/keypoints/impl/harris_2d.hpp +++ b/keypoints/include/pcl/keypoints/impl/harris_2d.hpp @@ -43,6 +43,8 @@ #include +#include + namespace pcl { @@ -472,7 +474,7 @@ HarrisKeypoint2D::responseTomasi (PointCloudOut { computeSecondMomentMatrix (index, covar); // min egenvalue - out_point.intensity = ((covar[0] + covar[2] - sqrt((covar[0] - covar[2])*(covar[0] - covar[2]) + 4 * covar[1] * covar[1])) /2.0f); + out_point.intensity = ((covar[0] + covar[2] - std::sqrt((covar[0] - covar[2])*(covar[0] - covar[2]) + 4 * covar[1] * covar[1])) /2.0f); } } diff --git a/outofcore/include/pcl/outofcore/impl/lru_cache.hpp b/outofcore/include/pcl/outofcore/impl/lru_cache.hpp index 9bdef7920fd..1a81400ea3b 100644 --- a/outofcore/include/pcl/outofcore/impl/lru_cache.hpp +++ b/outofcore/include/pcl/outofcore/impl/lru_cache.hpp @@ -53,7 +53,7 @@ class LRUCache get (const KeyT& k) { // Get existing key - const CacheIterator it = cache_.find (k); + const auto it = cache_.find (k); assert(it != cache_.end ()); // Move key to MRU key index @@ -67,7 +67,7 @@ class LRUCache touch (const KeyT& key) { // Get existing key - const CacheIterator it = cache_.find (key); + const auto it = cache_.find (key); assert(it != cache_.end ()); // Move key to MRU key index @@ -93,7 +93,7 @@ class LRUCache while (size + item_size >= capacity_) { - const CacheIterator cache_it = cache_.find (*key_it); + const auto cache_it = cache_.find (*key_it); // Get tail item (Least Recently Used) std::size_t tail_timestamp = cache_it->second.first.timestamp; @@ -153,7 +153,7 @@ class LRUCache return false; // Get LRU item - const CacheIterator it = cache_.find (key_index_.front ()); + const auto it = cache_.find (key_index_.front ()); assert(it != cache_.end()); // Remove LRU item from cache and key index diff --git a/recognition/include/pcl/recognition/3rdparty/.clang-tidy b/recognition/include/pcl/recognition/3rdparty/.clang-tidy new file mode 100644 index 00000000000..ff63dfcacf5 --- /dev/null +++ b/recognition/include/pcl/recognition/3rdparty/.clang-tidy @@ -0,0 +1,3 @@ +--- +# Disable all clang-tidy checks for third-party code +Checks: '-*' diff --git a/recognition/include/pcl/recognition/crh_alignment.h b/recognition/include/pcl/recognition/crh_alignment.h index a8853e6f57d..3cec516a434 100644 --- a/recognition/include/pcl/recognition/crh_alignment.h +++ b/recognition/include/pcl/recognition/crh_alignment.h @@ -170,7 +170,7 @@ namespace pcl translation2 (2, 3) = centroid_input_[2] - centr[2]; Eigen::Matrix4f resultHom (translation2 * rollHomMatrix); - transforms_.push_back(resultHom.inverse()); + transforms_.emplace_back(resultHom.inverse()); } } @@ -194,7 +194,7 @@ namespace pcl int peak_distance = 5; int cutoff = nbins_ - 1; - kiss_fft_cpx * multAB = new kiss_fft_cpx[nr_bins_after_padding]; + auto * multAB = new kiss_fft_cpx[nr_bins_after_padding]; for (int i = 0; i < nr_bins_after_padding; i++) multAB[i].r = multAB[i].i = 0.f; @@ -221,7 +221,7 @@ namespace pcl multAB[nbins_ - 1].r = input_ftt_negate[0].histogram[nbins_ - 1] * target_ftt[0].histogram[nbins_ - 1]; kiss_fft_cfg mycfg = kiss_fft_alloc (nr_bins_after_padding, 1, nullptr, nullptr); - kiss_fft_cpx * invAB = new kiss_fft_cpx[nr_bins_after_padding]; + auto * invAB = new kiss_fft_cpx[nr_bins_after_padding]; kiss_fft (mycfg, multAB, invAB); std::vector < std::pair > scored_peaks (nr_bins_after_padding); diff --git a/segmentation/include/pcl/segmentation/euclidean_cluster_comparator.h b/segmentation/include/pcl/segmentation/euclidean_cluster_comparator.h index 67592875996..e3b0892d507 100644 --- a/segmentation/include/pcl/segmentation/euclidean_cluster_comparator.h +++ b/segmentation/include/pcl/segmentation/euclidean_cluster_comparator.h @@ -155,11 +155,11 @@ namespace pcl const std::uint32_t &label1 = (*labels_)[idx1].label; const std::uint32_t &label2 = (*labels_)[idx2].label; - const std::set::const_iterator it1 = exclude_labels_->find (label1); + const auto it1 = exclude_labels_->find (label1); if (it1 == exclude_labels_->end ()) return false; - const std::set::const_iterator it2 = exclude_labels_->find (label2); + const auto it2 = exclude_labels_->find (label2); if (it2 == exclude_labels_->end ()) return false; } diff --git a/surface/include/pcl/surface/3rdparty/.clang-tidy b/surface/include/pcl/surface/3rdparty/.clang-tidy new file mode 100644 index 00000000000..ff63dfcacf5 --- /dev/null +++ b/surface/include/pcl/surface/3rdparty/.clang-tidy @@ -0,0 +1,3 @@ +--- +# Disable all clang-tidy checks for third-party code +Checks: '-*' diff --git a/surface/include/pcl/surface/on_nurbs/fitting_curve_2d.h b/surface/include/pcl/surface/on_nurbs/fitting_curve_2d.h index 6e9c90e8655..49db7046ef9 100644 --- a/surface/include/pcl/surface/on_nurbs/fitting_curve_2d.h +++ b/surface/include/pcl/surface/on_nurbs/fitting_curve_2d.h @@ -58,12 +58,9 @@ namespace pcl /** \brief Parameters for fitting */ struct Parameter { - double smoothness; - double rScale; - Parameter () : - smoothness (0.1), rScale (1.0) - { - } + double smoothness{0.1}; + double rScale{1.0}; + Parameter () = default; }; struct FitParameter diff --git a/surface/include/pcl/surface/on_nurbs/fitting_curve_2d_apdm.h b/surface/include/pcl/surface/on_nurbs/fitting_curve_2d_apdm.h index 72853647919..24fa6fc0c44 100644 --- a/surface/include/pcl/surface/on_nurbs/fitting_curve_2d_apdm.h +++ b/surface/include/pcl/surface/on_nurbs/fitting_curve_2d_apdm.h @@ -58,18 +58,14 @@ namespace pcl /** \brief Parameters for fitting */ struct Parameter { - double interior_sigma2; - double smoothness; - double closest_point_weight; - double closest_point_sigma2; - unsigned closest_point_resolution; - double smooth_concavity; - double rScale; - Parameter () : - interior_sigma2 (0.1), smoothness (0.1), closest_point_weight (0.1), closest_point_sigma2 (0.1), - closest_point_resolution (0), smooth_concavity (1.0), rScale (1.0) - { - } + double interior_sigma2{0.1}; + double smoothness{0.1}; + double closest_point_weight{0.1}; + double closest_point_sigma2{0.1}; + unsigned closest_point_resolution{0}; + double smooth_concavity{1.0}; + double rScale{1.0}; + Parameter () = default; }; struct FitParameter diff --git a/surface/include/pcl/surface/on_nurbs/fitting_curve_2d_pdm.h b/surface/include/pcl/surface/on_nurbs/fitting_curve_2d_pdm.h index 59c457131b4..10ea6bcddc2 100644 --- a/surface/include/pcl/surface/on_nurbs/fitting_curve_2d_pdm.h +++ b/surface/include/pcl/surface/on_nurbs/fitting_curve_2d_pdm.h @@ -58,12 +58,9 @@ namespace pcl /** \brief Parameters for fitting */ struct Parameter { - double smoothness; - double rScale; - Parameter () : - smoothness (0.1), rScale (1.0) - { - } + double smoothness{0.1}; + double rScale{1.0}; + Parameter () = default; }; struct FitParameter diff --git a/surface/include/pcl/surface/on_nurbs/fitting_surface_im.h b/surface/include/pcl/surface/on_nurbs/fitting_surface_im.h index 3fefdcf3b2d..047c70660a9 100644 --- a/surface/include/pcl/surface/on_nurbs/fitting_surface_im.h +++ b/surface/include/pcl/surface/on_nurbs/fitting_surface_im.h @@ -59,11 +59,8 @@ namespace pcl /** \brief Parameters for fitting */ struct Parameter { - double smoothness; - Parameter () : - smoothness (0.1) - { - } + double smoothness{0.1}; + Parameter () = default; }; protected: diff --git a/surface/include/pcl/surface/on_nurbs/nurbs_data.h b/surface/include/pcl/surface/on_nurbs/nurbs_data.h index d74f3503bac..c3052357547 100644 --- a/surface/include/pcl/surface/on_nurbs/nurbs_data.h +++ b/surface/include/pcl/surface/on_nurbs/nurbs_data.h @@ -51,9 +51,9 @@ namespace pcl { // http://eigen.tuxfamily.org/dox-devel/TopicStlContainers.html - typedef std::vector > vector_vec2i; - typedef std::vector > vector_vec2d; - typedef std::vector > vector_vec3d; + using vector_vec2i = std::vector>; + using vector_vec2d = std::vector>; + using vector_vec3d = std::vector>; /** \brief Data structure for NURBS surface fitting * (FittingSurface, FittingSurfaceTDM, FittingCylinder, GlobalOptimization, GlobalOptimizationTDM) */ diff --git a/surface/include/pcl/surface/on_nurbs/nurbs_solve.h b/surface/include/pcl/surface/on_nurbs/nurbs_solve.h index 491da21a465..c4739746331 100644 --- a/surface/include/pcl/surface/on_nurbs/nurbs_solve.h +++ b/surface/include/pcl/surface/on_nurbs/nurbs_solve.h @@ -53,10 +53,7 @@ namespace pcl { public: /** \brief Empty constructor */ - NurbsSolve () : - m_quiet (true) - { - } + NurbsSolve () = default; /** \brief Assign size and dimension (2D, 3D) of system of equations. */ void @@ -122,7 +119,7 @@ namespace pcl } private: - bool m_quiet; + bool m_quiet{true}; SparseMat m_Ksparse; Eigen::MatrixXd m_Keig; Eigen::MatrixXd m_xeig; diff --git a/surface/src/3rdparty/.clang-tidy b/surface/src/3rdparty/.clang-tidy new file mode 100644 index 00000000000..ff63dfcacf5 --- /dev/null +++ b/surface/src/3rdparty/.clang-tidy @@ -0,0 +1,3 @@ +--- +# Disable all clang-tidy checks for third-party code +Checks: '-*' diff --git a/tracking/include/pcl/tracking/hsv_color_coherence.h b/tracking/include/pcl/tracking/hsv_color_coherence.h index 5d444db9407..92882272c94 100644 --- a/tracking/include/pcl/tracking/hsv_color_coherence.h +++ b/tracking/include/pcl/tracking/hsv_color_coherence.h @@ -22,10 +22,6 @@ class HSVColorCoherence : public PointCoherence { */ HSVColorCoherence() : PointCoherence() - , weight_(1.0) - , h_weight_(1.0) - , s_weight_(1.0) - , v_weight_(0.0) {} /** \brief set the weight of coherence @@ -101,16 +97,16 @@ class HSVColorCoherence : public PointCoherence { computeCoherence(PointInT& source, PointInT& target) override; /** \brief the weight of coherence (w) */ - double weight_; + double weight_{1.0}; /** \brief the hue weight (w_h) */ - double h_weight_; + double h_weight_{1.0}; /** \brief the saturation weight (w_s) */ - double s_weight_; + double s_weight_{1.0}; /** \brief the value weight (w_v) */ - double v_weight_; + double v_weight_{0.0}; }; } // namespace tracking } // namespace pcl diff --git a/tracking/include/pcl/tracking/impl/pyramidal_klt.hpp b/tracking/include/pcl/tracking/impl/pyramidal_klt.hpp index 29d0fc9b6f8..761757a4879 100644 --- a/tracking/include/pcl/tracking/impl/pyramidal_klt.hpp +++ b/tracking/include/pcl/tracking/impl/pyramidal_klt.hpp @@ -196,7 +196,7 @@ PyramidalKLTTracker::derivatives(const FloatImage& src, ++trow0; float* trow1 = row1; ++trow1; - const float* src_ptr = &(src[0]); + const float* src_ptr = src.data(); for (int y = 0; y < height; y++) { const float* srow0 = src_ptr + (y > 0 ? y - 1 : height > 1 ? 1 : 0) * width; @@ -486,9 +486,9 @@ PyramidalKLTTracker::spatialGradient( covariance.setZero(); for (int y = 0; y < track_height_; y++) { - const float* img_ptr = &(img[0]) + (y + location[1]) * step + location[0]; - const float* grad_x_ptr = &(grad_x[0]) + (y + location[1]) * step + location[0]; - const float* grad_y_ptr = &(grad_y[0]) + (y + location[1]) * step + location[0]; + const float* img_ptr = img.data() + (y + location[1]) * step + location[0]; + const float* grad_x_ptr = grad_x.data() + (y + location[1]) * step + location[0]; + const float* grad_y_ptr = grad_y.data() + (y + location[1]) * step + location[0]; float* win_ptr = win.data() + y * win.cols(); float* grad_x_win_ptr = grad_x_win.data() + y * grad_x_win.cols(); @@ -527,7 +527,7 @@ PyramidalKLTTracker::mismatchVector( const int step = next.width; b.setZero(); for (int y = 0; y < track_height_; y++) { - const float* next_ptr = &(next[0]) + (y + location[1]) * step + location[0]; + const float* next_ptr = next.data() + (y + location[1]) * step + location[0]; const float* prev_ptr = prev.data() + y * prev.cols(); const float* prev_grad_x_ptr = prev_grad_x.data() + y * prev_grad_x.cols(); const float* prev_grad_y_ptr = prev_grad_y.data() + y * prev_grad_y.cols(); @@ -587,9 +587,9 @@ PyramidalKLTTracker::track( iprev_point[1] = std::floor(prev_pt[1]); if (iprev_point[0] < -track_width_ || - (std::uint32_t)iprev_point[0] >= grad_x.width || + static_cast(iprev_point[0]) >= grad_x.width || iprev_point[1] < -track_height_ || - (std::uint32_t)iprev_point[1] >= grad_y.height) { + static_cast(iprev_point[1]) >= grad_y.height) { if (level == 0) status[ptidx] = -1; continue; @@ -633,8 +633,8 @@ PyramidalKLTTracker::track( for (unsigned int j = 0; j < max_iterations_; j++) { Eigen::Array2i inext_pt = next_pt.floor().cast(); - if (inext_pt[0] < -track_width_ || (std::uint32_t)inext_pt[0] >= next.width || - inext_pt[1] < -track_height_ || (std::uint32_t)inext_pt[1] >= next.height) { + if (inext_pt[0] < -track_width_ || static_cast(inext_pt[0]) >= next.width || + inext_pt[1] < -track_height_ || static_cast(inext_pt[1]) >= next.height) { if (level == 0) status[ptidx] = -1; break; @@ -679,9 +679,9 @@ PyramidalKLTTracker::track( inext_point[1] = std::floor(next_point[1]); if (inext_point[0] < -track_width_ || - (std::uint32_t)inext_point[0] >= next.width || + static_cast(inext_point[0]) >= next.width || inext_point[1] < -track_height_ || - (std::uint32_t)inext_point[1] >= next.height) { + static_cast(inext_point[1]) >= next.height) { status[ptidx] = -1; continue; } diff --git a/tracking/include/pcl/tracking/pyramidal_klt.h b/tracking/include/pcl/tracking/pyramidal_klt.h index d5b44908355..d72deec517a 100644 --- a/tracking/include/pcl/tracking/pyramidal_klt.h +++ b/tracking/include/pcl/tracking/pyramidal_klt.h @@ -85,8 +85,8 @@ class PyramidalKLTTracker : public Tracker { , nb_levels_(nb_levels) , track_width_(tracking_window_width) , track_height_(tracking_window_height) - , threads_(0) - , initialized_(false) + , + { tracker_name_ = "PyramidalKLTTracker"; accuracy_ = 0.1; @@ -418,11 +418,11 @@ class PyramidalKLTTracker : public Tracker { float epsilon_; float max_residue_; /** \brief number of hardware threads */ - unsigned int threads_; + unsigned int threads_{0}; /** \brief intensity accessor */ IntensityT intensity_; /** \brief is the tracker initialized ? */ - bool initialized_; + bool initialized_{false}; /** \brief compute transformation from successfully tracked points */ pcl::TransformationFromCorrespondences transformation_computer_; /** \brief computed transformation between tracked points */ From 969bdbd25d4200ea0c11b14a0a429bc48cd3010e Mon Sep 17 00:00:00 2001 From: Norm Evangelista Date: Thu, 20 Nov 2025 14:02:18 -0800 Subject: [PATCH 4/8] Fixed clang-format escapes from recent commits --- .../apps/3d_rec_framework/pc_source/source.h | 3 +- .../pipeline/impl/local_recognizer.hpp | 3 +- .../cloud_composer/impl/merge_selection.hpp | 5 +- .../cloud_composer/impl/transform_clouds.hpp | 3 +- .../tools/impl/organized_segmentation.hpp | 16 +++--- .../cloud_composer/tools/impl/supervoxels.hpp | 6 +-- apps/cloud_composer/src/commands.cpp | 5 +- apps/cloud_composer/src/merge_selection.cpp | 16 +++--- .../click_trackball_interactor_style.cpp | 8 +-- .../rectangular_frustum_selector.cpp | 8 +-- apps/cloud_composer/src/toolbox_model.cpp | 4 +- .../tools/euclidean_clustering.cpp | 14 +++-- .../tools/normal_estimation.cpp | 5 +- apps/cloud_composer/tools/sanitize_cloud.cpp | 11 ++-- .../tools/statistical_outlier_removal.cpp | 11 ++-- .../tools/voxel_grid_downsample.cpp | 15 +++--- .../include/pcl/apps/in_hand_scanner/icp.h | 2 +- .../in_hand_scanner/impl/common_types.hpp | 3 +- apps/in_hand_scanner/src/icp.cpp | 10 +--- apps/in_hand_scanner/src/in_hand_scanner.cpp | 4 +- .../src/input_data_processing.cpp | 2 - apps/in_hand_scanner/src/integration.cpp | 5 +- .../src/offline_integration.cpp | 1 - apps/include/pcl/apps/nn_classification.h | 8 +-- apps/modeler/src/cloud_mesh.cpp | 8 ++- apps/modeler/src/icp_registration_worker.cpp | 2 - apps/modeler/src/main_window.cpp | 3 +- apps/modeler/src/normal_estimation_worker.cpp | 1 - apps/modeler/src/normals_actor_item.cpp | 2 - apps/modeler/src/parameter_dialog.cpp | 14 +++-- apps/modeler/src/poisson_worker.cpp | 2 - apps/modeler/src/scene_tree.cpp | 3 +- .../statistical_outlier_removal_worker.cpp | 2 - .../src/voxel_grid_downsample_worker.cpp | 2 - apps/src/dinast_grabber_example.cpp | 4 +- .../face_detection/openni_frame_source.cpp | 2 +- apps/src/feature_matching.cpp | 10 ++-- apps/src/ni_agast.cpp | 2 - apps/src/ni_linemod.cpp | 1 - apps/src/ni_susan.cpp | 3 +- apps/src/openni_klt.cpp | 3 +- ...nni_organized_multi_plane_segmentation.cpp | 3 +- apps/src/openni_tracking.cpp | 13 ++--- ...pcd_organized_multi_plane_segmentation.cpp | 8 +-- apps/src/pcd_select_object_plane.cpp | 3 +- .../src/pcd_video_player/pcd_video_player.cpp | 2 +- apps/src/ppf_object_recognition.cpp | 3 +- apps/src/pyramid_surface_matching.cpp | 3 +- apps/src/render_views_tesselated_sphere.cpp | 11 ++-- apps/src/stereo_ground_segmentation.cpp | 51 +++++++++---------- .../pcl/geometry/impl/polygon_operations.hpp | 4 +- .../pcl/tracking/hsv_color_coherence.h | 3 +- .../pcl/tracking/impl/pyramidal_klt.hpp | 6 ++- tracking/include/pcl/tracking/pyramidal_klt.h | 2 - 54 files changed, 145 insertions(+), 199 deletions(-) mode change 100755 => 100644 apps/src/stereo_ground_segmentation.cpp diff --git a/apps/3d_rec_framework/include/pcl/apps/3d_rec_framework/pc_source/source.h b/apps/3d_rec_framework/include/pcl/apps/3d_rec_framework/pc_source/source.h index e51afd192ab..8e475f6f4bc 100644 --- a/apps/3d_rec_framework/include/pcl/apps/3d_rec_framework/pc_source/source.h +++ b/apps/3d_rec_framework/include/pcl/apps/3d_rec_framework/pc_source/source.h @@ -51,8 +51,7 @@ class Model { if (resolution <= 0) return assembled_; - auto it = - voxelized_assembled_.find(resolution); + auto it = voxelized_assembled_.find(resolution); if (it == voxelized_assembled_.end()) { PointTPtr voxelized(new pcl::PointCloud); pcl::VoxelGrid grid_; diff --git a/apps/3d_rec_framework/include/pcl/apps/3d_rec_framework/pipeline/impl/local_recognizer.hpp b/apps/3d_rec_framework/include/pcl/apps/3d_rec_framework/pipeline/impl/local_recognizer.hpp index 73fee8ec022..44e1277d3f8 100644 --- a/apps/3d_rec_framework/include/pcl/apps/3d_rec_framework/pipeline/impl/local_recognizer.hpp +++ b/apps/3d_rec_framework/include/pcl/apps/3d_rec_framework/pipeline/impl/local_recognizer.hpp @@ -485,8 +485,7 @@ pcl::rec_3d_framework::LocalRecognitionPipeline:: if (use_cache_) { std::pair pair_model_view = std::make_pair(model.id_, view_id); - auto it = - keypoints_cache_.find(pair_model_view); + auto it = keypoints_cache_.find(pair_model_view); if (it != keypoints_cache_.end()) { keypoints_cloud = it->second; diff --git a/apps/cloud_composer/include/pcl/apps/cloud_composer/impl/merge_selection.hpp b/apps/cloud_composer/include/pcl/apps/cloud_composer/impl/merge_selection.hpp index e7917878cc8..b2bd99c8e81 100644 --- a/apps/cloud_composer/include/pcl/apps/cloud_composer/impl/merge_selection.hpp +++ b/apps/cloud_composer/include/pcl/apps/cloud_composer/impl/merge_selection.hpp @@ -102,9 +102,8 @@ pcl::cloud_composer::MergeSelection::performTemplatedAction( } // Just concatenate for all fully selected clouds foreach (const CloudComposerItem* input_item, input_data) { - auto input_cloud = - input_item->data(ItemDataRole::CLOUD_TEMPLATED) - .value::Ptr>(); + auto input_cloud = input_item->data(ItemDataRole::CLOUD_TEMPLATED) + .value::Ptr>(); *merged_cloud += *input_cloud; } CloudItem* cloud_item = CloudItem::createCloudItemFromTemplate( diff --git a/apps/cloud_composer/include/pcl/apps/cloud_composer/impl/transform_clouds.hpp b/apps/cloud_composer/include/pcl/apps/cloud_composer/impl/transform_clouds.hpp index 77d63739861..5d16ae4eae2 100644 --- a/apps/cloud_composer/include/pcl/apps/cloud_composer/impl/transform_clouds.hpp +++ b/apps/cloud_composer/include/pcl/apps/cloud_composer/impl/transform_clouds.hpp @@ -68,8 +68,7 @@ pcl::cloud_composer::TransformClouds::performTemplatedAction( foreach (const CloudComposerItem* input_item, input_data) { qDebug() << "Transforming cloud " << input_item->getId(); QVariant variant = input_item->data(ItemDataRole::CLOUD_TEMPLATED); - auto input_cloud = - variant.value::Ptr>(); + auto input_cloud = variant.value::Ptr>(); Eigen::Matrix4f transform; if (transform_map_.contains("AllSelectedClouds")) diff --git a/apps/cloud_composer/include/pcl/apps/cloud_composer/tools/impl/organized_segmentation.hpp b/apps/cloud_composer/include/pcl/apps/cloud_composer/tools/impl/organized_segmentation.hpp index 3f776e3572f..ed34dbbddeb 100644 --- a/apps/cloud_composer/include/pcl/apps/cloud_composer/tools/impl/organized_segmentation.hpp +++ b/apps/cloud_composer/include/pcl/apps/cloud_composer/tools/impl/organized_segmentation.hpp @@ -66,8 +66,7 @@ pcl::cloud_composer::OrganizedSegmentationTool::performTemplatedAction( "item! (input list)"; return output; } - auto input_cloud = - variant.value::Ptr>(); + auto input_cloud = variant.value::Ptr>(); if (!input_cloud->isOrganized()) { qCritical() << "Organized Segmentation requires an organized cloud!"; return output; @@ -89,14 +88,12 @@ pcl::cloud_composer::OrganizedSegmentationTool::performTemplatedAction( input_item->getChildren(CloudComposerItem::NORMALS_ITEM); // Get the normals cloud, we just use the first normals that were found if there are // more than one - auto input_normals = - normals_list.value(0) - ->data(ItemDataRole::CLOUD_TEMPLATED) - .value::ConstPtr>(); + auto input_normals = normals_list.value(0) + ->data(ItemDataRole::CLOUD_TEMPLATED) + .value::ConstPtr>(); QVariant variant = input_item->data(ItemDataRole::CLOUD_TEMPLATED); - auto input_cloud = - variant.value::Ptr>(); + auto input_cloud = variant.value::Ptr>(); pcl::OrganizedMultiPlaneSegmentation mps; mps.setMinInliers(min_inliers); @@ -143,7 +140,8 @@ pcl::cloud_composer::OrganizedSegmentationTool::performTemplatedAction( pcl::IndicesPtr extracted_indices(new pcl::Indices()); for (std::size_t i = 0; i < euclidean_label_indices.size(); i++) { - if (euclidean_label_indices[i].indices.size() >= static_cast(min_cluster_size)) { + if (euclidean_label_indices[i].indices.size() >= + static_cast(min_cluster_size)) { typename PointCloud::Ptr cluster(new PointCloud); pcl::copyPointCloud(*input_cloud, euclidean_label_indices[i].indices, *cluster); qDebug() << "Found cluster with size " << cluster->width; diff --git a/apps/cloud_composer/include/pcl/apps/cloud_composer/tools/impl/supervoxels.hpp b/apps/cloud_composer/include/pcl/apps/cloud_composer/tools/impl/supervoxels.hpp index 9c717a6c70b..b401fd28751 100644 --- a/apps/cloud_composer/include/pcl/apps/cloud_composer/tools/impl/supervoxels.hpp +++ b/apps/cloud_composer/include/pcl/apps/cloud_composer/tools/impl/supervoxels.hpp @@ -64,15 +64,13 @@ pcl::cloud_composer::SupervoxelsTool::performTemplatedAction( "item! (input list)"; return output; } - auto input_cloud = - variant.value::Ptr>(); + auto input_cloud = variant.value::Ptr>(); // TODO: Check if Voxelized } foreach (const CloudComposerItem* input_item, input_data) { QVariant variant = input_item->data(ItemDataRole::CLOUD_TEMPLATED); - auto input_cloud = - variant.value::Ptr>(); + auto input_cloud = variant.value::Ptr>(); float resolution = parameter_model_->getProperty("Resolution").toFloat(); qDebug() << "Octree resolution = " << resolution; diff --git a/apps/cloud_composer/src/commands.cpp b/apps/cloud_composer/src/commands.cpp index f3ba31df740..60095d85178 100644 --- a/apps/cloud_composer/src/commands.cpp +++ b/apps/cloud_composer/src/commands.cpp @@ -5,10 +5,7 @@ pcl::cloud_composer::CloudCommand::CloudCommand( QList input_data, QUndoCommand* parent) -: QUndoCommand(parent) -, original_data_(std::move(input_data)) -, - +: QUndoCommand(parent) , original_data_(std::move(input_data)) {} pcl::cloud_composer::CloudCommand::~CloudCommand() diff --git a/apps/cloud_composer/src/merge_selection.cpp b/apps/cloud_composer/src/merge_selection.cpp index 237a5eedcde..0db12df5ce7 100644 --- a/apps/cloud_composer/src/merge_selection.cpp +++ b/apps/cloud_composer/src/merge_selection.cpp @@ -53,9 +53,8 @@ pcl::cloud_composer::MergeSelection::performAction(ConstItemList input_data, foreach (const CloudItem* input_cloud_item, selected_item_index_map_.keys()) { // If this cloud hasn't been completely selected if (!input_data.contains(input_cloud_item)) { - auto input_cloud = - input_cloud_item->data(ItemDataRole::CLOUD_BLOB) - .value(); + auto input_cloud = input_cloud_item->data(ItemDataRole::CLOUD_BLOB) + .value(); qDebug() << "Extracting " << selected_item_index_map_.value(input_cloud_item)->indices.size() << " points out of " << input_cloud->width; @@ -79,9 +78,9 @@ pcl::cloud_composer::MergeSelection::performAction(ConstItemList input_data, pose_found = true; } auto* new_cloud_item = new CloudItem(input_cloud_item->text(), - original_minus_indices, - source_origin, - source_orientation); + original_minus_indices, + source_origin, + source_orientation); output.append(new_cloud_item); pcl::PCLPointCloud2::Ptr temp_cloud = pcl::make_shared(); concatenate(*merged_cloud, *selected_points, *temp_cloud); @@ -92,9 +91,8 @@ pcl::cloud_composer::MergeSelection::performAction(ConstItemList input_data, } // Just concatenate for all fully selected clouds foreach (const CloudComposerItem* input_item, input_data) { - auto input_cloud = - input_item->data(ItemDataRole::CLOUD_BLOB) - .value(); + auto input_cloud = input_item->data(ItemDataRole::CLOUD_BLOB) + .value(); pcl::PCLPointCloud2::Ptr temp_cloud = pcl::make_shared(); concatenate(*merged_cloud, *input_cloud, *temp_cloud); diff --git a/apps/cloud_composer/src/point_selectors/click_trackball_interactor_style.cpp b/apps/cloud_composer/src/point_selectors/click_trackball_interactor_style.cpp index 178529cf3a4..1f6bea5245d 100644 --- a/apps/cloud_composer/src/point_selectors/click_trackball_interactor_style.cpp +++ b/apps/cloud_composer/src/point_selectors/click_trackball_interactor_style.cpp @@ -54,9 +54,7 @@ pcl::cloud_composer::ClickTrackballStyleInteractor::OnLeftButtonUp() // Find the id of the actor we manipulated auto end = actors_->end(); QString manipulated_id; - for (auto itr = actors_->begin(); - itr != end; - ++itr) { + for (auto itr = actors_->begin(); itr != end; ++itr) { // qDebug () << "Id = "<first); if ((itr->second).actor == selected_actor) { manipulated_id = (QString::fromStdString(itr->first)); @@ -87,9 +85,7 @@ pcl::cloud_composer::ClickTrackballStyleInteractor::OnRightButtonUp() // Find the id of the actor we manipulated auto end = actors_->end(); QString manipulated_id; - for (auto itr = actors_->begin(); - itr != end; - ++itr) { + for (auto itr = actors_->begin(); itr != end; ++itr) { // qDebug () << "Id = "<first); if ((itr->second).actor == selected_actor) { manipulated_id = (QString::fromStdString(itr->first)); diff --git a/apps/cloud_composer/src/point_selectors/rectangular_frustum_selector.cpp b/apps/cloud_composer/src/point_selectors/rectangular_frustum_selector.cpp index 9b8b39ac34f..c94a135cab5 100644 --- a/apps/cloud_composer/src/point_selectors/rectangular_frustum_selector.cpp +++ b/apps/cloud_composer/src/point_selectors/rectangular_frustum_selector.cpp @@ -92,10 +92,10 @@ pcl::cloud_composer::RectangularFrustumSelector::OnLeftButtonUp() if (all_points->GetNumberOfPoints() > 0) { auto* selected = new SelectionEvent(all_points, - selected_actor, - selected_mapper, - id_selected_data_map, - this->CurrentRenderer); + selected_actor, + selected_mapper, + id_selected_data_map, + this->CurrentRenderer); this->InvokeEvent(this->selection_complete_event_, selected); } } diff --git a/apps/cloud_composer/src/toolbox_model.cpp b/apps/cloud_composer/src/toolbox_model.cpp index b41ee385f94..950ce4317d1 100644 --- a/apps/cloud_composer/src/toolbox_model.cpp +++ b/apps/cloud_composer/src/toolbox_model.cpp @@ -13,7 +13,6 @@ pcl::cloud_composer::ToolBoxModel::ToolBoxModel(QTreeView* tool_view, : QStandardItemModel(parent) , tool_view_(tool_view) , parameter_view_(parameter_view_) -, {} pcl::cloud_composer::ToolBoxModel::ToolBoxModel(const ToolBoxModel&) @@ -25,8 +24,7 @@ pcl::cloud_composer::ToolBoxModel::addTool(ToolFactory* tool_factory) { // qDebug () << "Icon name:"<< tool_factory->getIconName (); QIcon new_tool_icon = QIcon(tool_factory->getIconName()); - auto* new_tool_item = - new QStandardItem(new_tool_icon, tool_factory->getPluginName()); + auto* new_tool_item = new QStandardItem(new_tool_icon, tool_factory->getPluginName()); new_tool_item->setEditable(false); new_tool_item->setData(QVariant::fromValue(tool_factory), FACTORY); diff --git a/apps/cloud_composer/tools/euclidean_clustering.cpp b/apps/cloud_composer/tools/euclidean_clustering.cpp index bd71994c46c..b41d5b97d39 100644 --- a/apps/cloud_composer/tools/euclidean_clustering.cpp +++ b/apps/cloud_composer/tools/euclidean_clustering.cpp @@ -37,9 +37,8 @@ pcl::cloud_composer::EuclideanClusteringTool::performAction(ConstItemList input_ int min_cluster_size = parameter_model_->getProperty("Min Cluster Size").toInt(); int max_cluster_size = parameter_model_->getProperty("Max Cluster Size").toInt(); - auto input_cloud = - input_item->data(ItemDataRole::CLOUD_BLOB) - .value(); + auto input_cloud = input_item->data(ItemDataRole::CLOUD_BLOB) + .value(); // Get the cloud in template form pcl::PointCloud::Ptr cloud(new pcl::PointCloud); pcl::fromPCLPointCloud2(*input_cloud, *cloud); @@ -85,11 +84,10 @@ pcl::cloud_composer::EuclideanClusteringTool::performAction(ConstItemList input_ filter.filter(*cloud_filtered); qDebug() << "Cluster has " << cloud_filtered->width << " data points."; - auto* cloud_item = - new CloudItem(input_item->text() + tr("-Clstr %1").arg(cluster_count), - cloud_filtered, - source_origin, - source_orientation); + auto* cloud_item = new CloudItem(input_item->text() + tr("-Clstr %1").arg(cluster_count), + cloud_filtered, + source_origin, + source_orientation); output.append(cloud_item); ++cluster_count; } diff --git a/apps/cloud_composer/tools/normal_estimation.cpp b/apps/cloud_composer/tools/normal_estimation.cpp index 4994c0b3115..b8c963e1da5 100644 --- a/apps/cloud_composer/tools/normal_estimation.cpp +++ b/apps/cloud_composer/tools/normal_estimation.cpp @@ -30,9 +30,8 @@ pcl::cloud_composer::NormalEstimationTool::performAction(ConstItemList input_dat if (input_item->type() == CloudComposerItem::CLOUD_ITEM) { double radius = parameter_model_->getProperty("Radius").toDouble(); qDebug() << "Received Radius = " << radius; - auto input_cloud = - input_item->data(ItemDataRole::CLOUD_BLOB) - .value(); + auto input_cloud = input_item->data(ItemDataRole::CLOUD_BLOB) + .value(); qDebug() << "Got cloud size = " << input_cloud->width; //////////////// THE WORK - COMPUTING NORMALS /////////////////// pcl::PointCloud::Ptr cloud(new pcl::PointCloud); diff --git a/apps/cloud_composer/tools/sanitize_cloud.cpp b/apps/cloud_composer/tools/sanitize_cloud.cpp index e0f990d7a4c..ee34930c21e 100644 --- a/apps/cloud_composer/tools/sanitize_cloud.cpp +++ b/apps/cloud_composer/tools/sanitize_cloud.cpp @@ -24,9 +24,8 @@ pcl::cloud_composer::SanitizeCloudTool::performAction(ConstItemList input_data, input_item = input_data.value(0); if (input_item->type() == CloudComposerItem::CLOUD_ITEM) { - auto input_cloud = - input_item->data(ItemDataRole::CLOUD_BLOB) - .value(); + auto input_cloud = input_item->data(ItemDataRole::CLOUD_BLOB) + .value(); bool keep_organized = parameter_model_->getProperty("Keep Organized").toBool(); @@ -49,9 +48,9 @@ pcl::cloud_composer::SanitizeCloudTool::performAction(ConstItemList input_data, input_item->data(ItemDataRole::ORIENTATION).value(); // Put the modified cloud into an item, stick in output auto* cloud_item = new CloudItem(input_item->text() + tr(" sanitized"), - cloud_filtered, - source_origin, - source_orientation); + cloud_filtered, + source_origin, + source_orientation); output.append(cloud_item); } diff --git a/apps/cloud_composer/tools/statistical_outlier_removal.cpp b/apps/cloud_composer/tools/statistical_outlier_removal.cpp index c8d4b4ddd41..fd064e9e5d5 100644 --- a/apps/cloud_composer/tools/statistical_outlier_removal.cpp +++ b/apps/cloud_composer/tools/statistical_outlier_removal.cpp @@ -32,9 +32,8 @@ pcl::cloud_composer::StatisticalOutlierRemovalTool::performAction( } if (input_item->type() == CloudComposerItem::CLOUD_ITEM) { - auto input_cloud = - input_item->data(ItemDataRole::CLOUD_BLOB) - .value(); + auto input_cloud = input_item->data(ItemDataRole::CLOUD_BLOB) + .value(); int mean_k = parameter_model_->getProperty("Mean K").toInt(); double std_dev_thresh = parameter_model_->getProperty("Std Dev Thresh").toDouble(); @@ -59,9 +58,9 @@ pcl::cloud_composer::StatisticalOutlierRemovalTool::performAction( input_item->data(ItemDataRole::ORIENTATION).value(); // Put the modified cloud into an item, stick in output auto* cloud_item = new CloudItem(input_item->text() + tr(" sor filtered"), - cloud_filtered, - source_origin, - source_orientation); + cloud_filtered, + source_origin, + source_orientation); output.append(cloud_item); } diff --git a/apps/cloud_composer/tools/voxel_grid_downsample.cpp b/apps/cloud_composer/tools/voxel_grid_downsample.cpp index 0a3de9e2e85..790fff9ce8b 100644 --- a/apps/cloud_composer/tools/voxel_grid_downsample.cpp +++ b/apps/cloud_composer/tools/voxel_grid_downsample.cpp @@ -31,15 +31,16 @@ pcl::cloud_composer::VoxelGridDownsampleTool::performAction(ConstItemList input_ double leaf_y = parameter_model_->getProperty("Leaf Size y").toDouble(); double leaf_z = parameter_model_->getProperty("Leaf Size z").toDouble(); - auto input_cloud = - input_item->data(ItemDataRole::CLOUD_BLOB) - .value(); + auto input_cloud = input_item->data(ItemDataRole::CLOUD_BLOB) + .value(); //////////////// THE WORK - FILTERING OUTLIERS /////////////////// // Create the filtering object pcl::VoxelGrid vox_grid; vox_grid.setInputCloud(input_cloud); - vox_grid.setLeafSize(static_cast(leaf_x), static_cast(leaf_y), static_cast(leaf_z)); + vox_grid.setLeafSize(static_cast(leaf_x), + static_cast(leaf_y), + static_cast(leaf_z)); // Create output cloud pcl::PCLPointCloud2::Ptr cloud_filtered(new pcl::PCLPointCloud2); @@ -54,9 +55,9 @@ pcl::cloud_composer::VoxelGridDownsampleTool::performAction(ConstItemList input_ input_item->data(ItemDataRole::ORIENTATION).value(); // Put the modified cloud into an item, stick in output auto* cloud_item = new CloudItem(input_item->text() + tr(" vox ds"), - cloud_filtered, - source_origin, - source_orientation); + cloud_filtered, + source_origin, + source_orientation); output.append(cloud_item); } diff --git a/apps/in_hand_scanner/include/pcl/apps/in_hand_scanner/icp.h b/apps/in_hand_scanner/include/pcl/apps/in_hand_scanner/icp.h index 81cf85dddea..f7748dadf7e 100644 --- a/apps/in_hand_scanner/include/pcl/apps/in_hand_scanner/icp.h +++ b/apps/in_hand_scanner/include/pcl/apps/in_hand_scanner/icp.h @@ -229,7 +229,7 @@ class PCL_EXPORTS ICP { // Registration failure unsigned int max_iterations_{50}; float min_overlap_{.75f}; // [0 1] - float max_fitness_{.1f}; // in cm^2 + float max_fitness_{.1f}; // in cm^2 // Correspondence rejection float factor_{9.f}; diff --git a/apps/in_hand_scanner/include/pcl/apps/in_hand_scanner/impl/common_types.hpp b/apps/in_hand_scanner/include/pcl/apps/in_hand_scanner/impl/common_types.hpp index 6960bd0c640..868f31f5ea8 100644 --- a/apps/in_hand_scanner/include/pcl/apps/in_hand_scanner/impl/common_types.hpp +++ b/apps/in_hand_scanner/include/pcl/apps/in_hand_scanner/impl/common_types.hpp @@ -78,8 +78,7 @@ struct PointIHS : public pcl::ihs::_PointIHS { this->directions = 0; } - inline PointIHS(const PointIHS& other) - : _PointIHS(other) { + inline PointIHS(const PointIHS& other) : _PointIHS(other) { this->x = other.x; this->y = other.y; this->z = other.z; diff --git a/apps/in_hand_scanner/src/icp.cpp b/apps/in_hand_scanner/src/icp.cpp index 26ce9b2bb52..bdc5e13000f 100644 --- a/apps/in_hand_scanner/src/icp.cpp +++ b/apps/in_hand_scanner/src/icp.cpp @@ -51,12 +51,7 @@ //////////////////////////////////////////////////////////////////////////////// -pcl::ihs::ICP::ICP() -: kd_tree_(new pcl::KdTreeFLANN()) -, - - - +pcl::ihs::ICP::ICP() : kd_tree_(new pcl::KdTreeFLANN()) {} //////////////////////////////////////////////////////////////////////////////// @@ -226,8 +221,7 @@ pcl::ihs::ICP::findTransformation(const MeshConstPtr& mesh_model, cloud_model_corr.clear(); cloud_data_corr.clear(); sw.reset(); - for (auto it_d = cloud_data_selected->begin(); - it_d != cloud_data_selected->end(); + for (auto it_d = cloud_data_selected->begin(); it_d != cloud_data_selected->end(); ++it_d) { // Transform the data point pt_d = *it_d; diff --git a/apps/in_hand_scanner/src/in_hand_scanner.cpp b/apps/in_hand_scanner/src/in_hand_scanner.cpp index b8506c81541..1edc799617b 100644 --- a/apps/in_hand_scanner/src/in_hand_scanner.cpp +++ b/apps/in_hand_scanner/src/in_hand_scanner.cpp @@ -69,7 +69,6 @@ pcl::ihs::InHandScanner::InHandScanner(Base* parent) , integration_(new Integration()) , mesh_processing_(new MeshProcessing()) , mesh_model_(new Mesh()) -, { // http://doc.qt.digia.com/qt/qmetatype.html#qRegisterMetaType qRegisterMetaType("RunningMode"); @@ -239,7 +238,8 @@ pcl::ihs::InHandScanner::reset() //////////////////////////////////////////////////////////////////////////////// void -pcl::ihs::InHandScanner::saveAs(const std::string& filename, const FileType& filetype) const +pcl::ihs::InHandScanner::saveAs(const std::string& filename, + const FileType& filetype) const { std::lock_guard lock(mutex_); if (destructor_called_) diff --git a/apps/in_hand_scanner/src/input_data_processing.cpp b/apps/in_hand_scanner/src/input_data_processing.cpp index 59b0a03c848..94f73dea0b2 100644 --- a/apps/in_hand_scanner/src/input_data_processing.cpp +++ b/apps/in_hand_scanner/src/input_data_processing.cpp @@ -46,8 +46,6 @@ pcl::ihs::InputDataProcessing::InputDataProcessing() : normal_estimation_(new NormalEstimation()) -, - { // Normal estimation normal_estimation_->setNormalEstimationMethod(NormalEstimation::AVERAGE_3D_GRADIENT); diff --git a/apps/in_hand_scanner/src/integration.cpp b/apps/in_hand_scanner/src/integration.cpp index 8a8686f15ba..2d29a69d9f3 100644 --- a/apps/in_hand_scanner/src/integration.cpp +++ b/apps/in_hand_scanner/src/integration.cpp @@ -50,10 +50,7 @@ //////////////////////////////////////////////////////////////////////////////// pcl::ihs::Integration::Integration() -: kd_tree_(new pcl::KdTreeFLANN()) -, - -{} +: kd_tree_(new pcl::KdTreeFLANN()) {} //////////////////////////////////////////////////////////////////////////////// diff --git a/apps/in_hand_scanner/src/offline_integration.cpp b/apps/in_hand_scanner/src/offline_integration.cpp index 31c22d64f61..8bd9b01853f 100644 --- a/apps/in_hand_scanner/src/offline_integration.cpp +++ b/apps/in_hand_scanner/src/offline_integration.cpp @@ -64,7 +64,6 @@ pcl::ihs::OfflineIntegration::OfflineIntegration(Base* parent) , mesh_model_(new Mesh()) , normal_estimation_(new NormalEstimation()) , integration_(new Integration()) -, { normal_estimation_->setNormalEstimationMethod(NormalEstimation::AVERAGE_3D_GRADIENT); normal_estimation_->setMaxDepthChangeFactor(0.02f); // in meters diff --git a/apps/include/pcl/apps/nn_classification.h b/apps/include/pcl/apps/nn_classification.h index 3783c1c3b07..db548dbd9af 100644 --- a/apps/include/pcl/apps/nn_classification.h +++ b/apps/include/pcl/apps/nn_classification.h @@ -284,9 +284,7 @@ class NNClassification { std::make_shared, std::vector>>(); result->first.reserve(classes_.size()); result->second.reserve(classes_.size()); - for (auto it = sqr_distances->begin(); - it != sqr_distances->end(); - ++it) + for (auto it = sqr_distances->begin(); it != sqr_distances->end(); ++it) if (*it != std::numeric_limits::max()) { result->first.push_back(classes_[it - sqr_distances->begin()]); result->second.push_back(sqrt(*it)); @@ -322,9 +320,7 @@ class NNClassification { std::make_shared, std::vector>>(); result->first.reserve(classes_.size()); result->second.reserve(classes_.size()); - for (auto it = sqr_distances->begin(); - it != sqr_distances->end(); - ++it) + for (auto it = sqr_distances->begin(); it != sqr_distances->end(); ++it) if (*it != std::numeric_limits::max()) { result->first.push_back(classes_[it - sqr_distances->begin()]); // TODO leave it squared, and relate param to sigma... diff --git a/apps/modeler/src/cloud_mesh.cpp b/apps/modeler/src/cloud_mesh.cpp index 2a44a259e02..215c09952af 100755 --- a/apps/modeler/src/cloud_mesh.cpp +++ b/apps/modeler/src/cloud_mesh.cpp @@ -225,8 +225,12 @@ pcl::modeler::CloudMesh::transform( rx *= M_PI / 180; ry *= M_PI / 180; rz *= M_PI / 180; - Eigen::Affine3f affine_transform = pcl::getTransformation( - static_cast(tx), static_cast(ty), static_cast(tz), static_cast(rx), static_cast(ry), static_cast(rz)); + Eigen::Affine3f affine_transform = pcl::getTransformation(static_cast(tx), + static_cast(ty), + static_cast(tz), + static_cast(rx), + static_cast(ry), + static_cast(rz)); CloudMesh::PointCloud transform_cloud = mean_cloud; pcl::transformPointCloudWithNormals( mean_cloud, transform_cloud, affine_transform.matrix()); diff --git a/apps/modeler/src/icp_registration_worker.cpp b/apps/modeler/src/icp_registration_worker.cpp index 7189522ebad..7f353ae1a20 100755 --- a/apps/modeler/src/icp_registration_worker.cpp +++ b/apps/modeler/src/icp_registration_worker.cpp @@ -55,8 +55,6 @@ pcl::modeler::ICPRegistrationWorker::ICPRegistrationWorker( , y_max_(std::numeric_limits::min()) , z_min_(std::numeric_limits::max()) , z_max_(std::numeric_limits::min()) -, - {} ////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/apps/modeler/src/main_window.cpp b/apps/modeler/src/main_window.cpp index b1f8c40a960..fc58ca8a2ba 100755 --- a/apps/modeler/src/main_window.cpp +++ b/apps/modeler/src/main_window.cpp @@ -282,7 +282,8 @@ pcl::modeler::MainWindow::updateRecentActions( } recent_items.removeDuplicates(); - int recent_number = std::min(static_cast(MAX_RECENT_NUMBER), recent_items.size()); + int recent_number = + std::min(static_cast(MAX_RECENT_NUMBER), recent_items.size()); for (int i = 0; i < recent_number; ++i) { QString text = tr("%1 %2").arg(i + 1).arg(recent_items[i]); recent_actions[i]->setText(text); diff --git a/apps/modeler/src/normal_estimation_worker.cpp b/apps/modeler/src/normal_estimation_worker.cpp index 1fb924fd7c1..88611909e72 100755 --- a/apps/modeler/src/normal_estimation_worker.cpp +++ b/apps/modeler/src/normal_estimation_worker.cpp @@ -55,7 +55,6 @@ pcl::modeler::NormalEstimationWorker::NormalEstimationWorker( , y_max_(std::numeric_limits::min()) , z_min_(std::numeric_limits::max()) , z_max_(std::numeric_limits::min()) -, {} ////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/apps/modeler/src/normals_actor_item.cpp b/apps/modeler/src/normals_actor_item.cpp index f2b428a20e3..08d97025d13 100644 --- a/apps/modeler/src/normals_actor_item.cpp +++ b/apps/modeler/src/normals_actor_item.cpp @@ -51,8 +51,6 @@ pcl::modeler::NormalsActorItem::NormalsActorItem( const vtkSmartPointer& render_window) : ChannelActorItem( parent, cloud_mesh, render_window, vtkSmartPointer::New(), "Normals") -, - {} ////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/apps/modeler/src/parameter_dialog.cpp b/apps/modeler/src/parameter_dialog.cpp index 1991069a8eb..ca3a9ddd0aa 100755 --- a/apps/modeler/src/parameter_dialog.cpp +++ b/apps/modeler/src/parameter_dialog.cpp @@ -62,7 +62,7 @@ pcl::modeler::ParameterDialog::addParameter(pcl::modeler::Parameter* parameter) ////////////////////////////////////////////////////////////////////////////////////////////// pcl::modeler::ParameterDialog::ParameterDialog(const std::string& title, QWidget* parent) -: QDialog(parent), +: QDialog(parent) { setModal(false); setWindowTitle(QString(title.c_str()) + " Parameters"); @@ -72,7 +72,8 @@ pcl::modeler::ParameterDialog::ParameterDialog(const std::string& title, int pcl::modeler::ParameterDialog::exec() { - pcl::modeler::ParameterModel parameterModel(static_cast(name_parameter_map_.size()), 2, this); + pcl::modeler::ParameterModel parameterModel( + static_cast(name_parameter_map_.size()), 2, this); parameter_model_ = ¶meterModel; QStringList headerLabels; @@ -85,10 +86,12 @@ pcl::modeler::ParameterDialog::exec() std::size_t currentRow = 0; for (const auto& name_parameter : name_parameter_map_) { - QModelIndex name = parameterModel.index(static_cast(currentRow), 0, QModelIndex()); + QModelIndex name = parameterModel.index( + static_cast(currentRow), 0, QModelIndex()); parameterModel.setData(name, QVariant(name_parameter.first.c_str())); - QModelIndex value = parameterModel.index(static_cast(currentRow), 1, QModelIndex()); + QModelIndex value = parameterModel.index( + static_cast(currentRow), 1, QModelIndex()); std::pair model_data = name_parameter.second->toModelData(); parameterModel.setData(value, model_data.first, model_data.second); @@ -137,7 +140,8 @@ pcl::modeler::ParameterDialog::reset() for (auto& name_parameter : name_parameter_map_) { name_parameter.second->reset(); - QModelIndex value = parameter_model_->index(static_cast(currentRow), 1, QModelIndex()); + QModelIndex value = + parameter_model_->index(static_cast(currentRow), 1, QModelIndex()); std::pair model_data = name_parameter.second->toModelData(); parameter_model_->setData(value, model_data.first, model_data.second); diff --git a/apps/modeler/src/poisson_worker.cpp b/apps/modeler/src/poisson_worker.cpp index 57cf0280357..7b434fbcc90 100755 --- a/apps/modeler/src/poisson_worker.cpp +++ b/apps/modeler/src/poisson_worker.cpp @@ -46,8 +46,6 @@ pcl::modeler::PoissonReconstructionWorker::PoissonReconstructionWorker( const QList& cloud_mesh_items, QWidget* parent) : AbstractWorker(cloud_mesh_items, parent) -, - {} ////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/apps/modeler/src/scene_tree.cpp b/apps/modeler/src/scene_tree.cpp index 41eab675296..b5aebfbb7d4 100755 --- a/apps/modeler/src/scene_tree.cpp +++ b/apps/modeler/src/scene_tree.cpp @@ -398,8 +398,7 @@ void pcl::modeler::SceneTree::slotUpdateOnInsertOrRemove() { for (int i = 0, i_end = topLevelItemCount(); i < i_end; ++i) { - auto* render_window_item = - dynamic_cast(topLevelItem(i)); + auto* render_window_item = dynamic_cast(topLevelItem(i)); if (render_window_item == nullptr) continue; diff --git a/apps/modeler/src/statistical_outlier_removal_worker.cpp b/apps/modeler/src/statistical_outlier_removal_worker.cpp index dd09f8685f7..8839edba121 100755 --- a/apps/modeler/src/statistical_outlier_removal_worker.cpp +++ b/apps/modeler/src/statistical_outlier_removal_worker.cpp @@ -45,8 +45,6 @@ pcl::modeler::StatisticalOutlierRemovalWorker::StatisticalOutlierRemovalWorker( const QList& cloud_mesh_items, QWidget* parent) : AbstractWorker(cloud_mesh_items, parent) -, - {} ////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/apps/modeler/src/voxel_grid_downsample_worker.cpp b/apps/modeler/src/voxel_grid_downsample_worker.cpp index 8414244f185..7faf8597570 100755 --- a/apps/modeler/src/voxel_grid_downsample_worker.cpp +++ b/apps/modeler/src/voxel_grid_downsample_worker.cpp @@ -52,8 +52,6 @@ pcl::modeler::VoxelGridDownampleWorker::VoxelGridDownampleWorker( , y_max_(std::numeric_limits::min()) , z_min_(std::numeric_limits::max()) , z_max_(std::numeric_limits::min()) -, - {} ////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/apps/src/dinast_grabber_example.cpp b/apps/src/dinast_grabber_example.cpp index 04dff42d318..cf9ce4aab96 100644 --- a/apps/src/dinast_grabber_example.cpp +++ b/apps/src/dinast_grabber_example.cpp @@ -61,8 +61,8 @@ class DinastProcessor { static double last = pcl::getTime(); if (++count == 30) { double now = pcl::getTime(); - std::cout << "Average framerate: " << static_cast(count) / (now - last) << " Hz" - << std::endl; + std::cout << "Average framerate: " << static_cast(count) / (now - last) + << " Hz" << std::endl; count = 0; last = now; } diff --git a/apps/src/face_detection/openni_frame_source.cpp b/apps/src/face_detection/openni_frame_source.cpp index 1e94db21cee..5a41a3cbfa1 100644 --- a/apps/src/face_detection/openni_frame_source.cpp +++ b/apps/src/face_detection/openni_frame_source.cpp @@ -4,7 +4,7 @@ namespace OpenNIFrameSource { OpenNIFrameSource::OpenNIFrameSource(const std::string& device_id) -: grabber_(device_id), +: grabber_(device_id) { std::function frame_cb = [this](const PointCloudConstPtr& cloud) { onNewFrame(cloud); }; diff --git a/apps/src/feature_matching.cpp b/apps/src/feature_matching.cpp index f82ca90838d..219c04ecde9 100644 --- a/apps/src/feature_matching.cpp +++ b/apps/src/feature_matching.cpp @@ -166,8 +166,6 @@ ICCVTutorial::ICCVTutorial( , source_features_(new pcl::PointCloud) , target_features_(new pcl::PointCloud) , correspondences_(new pcl::Correspondences) -, - { visualizer_.registerKeyboardCallback( &ICCVTutorial::keyboard_callback, *this, nullptr); @@ -599,9 +597,8 @@ main(int argc, char** argv) keypoint_detector.reset(sift3D); } else { - auto* harris3D = - new pcl::HarrisKeypoint3D( - pcl::HarrisKeypoint3D::HARRIS); + auto* harris3D = new pcl::HarrisKeypoint3D( + pcl::HarrisKeypoint3D::HARRIS); harris3D->setNonMaxSupression(true); harris3D->setRadius(0.01f); harris3D->setRadiusSearch(0.01f); @@ -643,8 +640,7 @@ main(int argc, char** argv) pcl::PCLSurfaceBase::Ptr surface_reconstruction; if (surface_type == 1) { - auto* gp3 = - new pcl::GreedyProjectionTriangulation; + auto* gp3 = new pcl::GreedyProjectionTriangulation; // Set the maximum distance between connected points (maximum edge length) gp3->setSearchRadius(0.025); diff --git a/apps/src/ni_agast.cpp b/apps/src/ni_agast.cpp index 701fc1ebae5..9595e5bf557 100644 --- a/apps/src/ni_agast.cpp +++ b/apps/src/ni_agast.cpp @@ -67,8 +67,6 @@ class AGASTDemo { : cloud_viewer_("AGAST 2D Keypoints -- PointCloud") , grabber_(grabber) , image_viewer_("AGAST 2D Keypoints -- Image") - , - {} ///////////////////////////////////////////////////////////////////////// diff --git a/apps/src/ni_linemod.cpp b/apps/src/ni_linemod.cpp index a196a181b96..707ba5b6b09 100644 --- a/apps/src/ni_linemod.cpp +++ b/apps/src/ni_linemod.cpp @@ -80,7 +80,6 @@ class NILinemod { : cloud_viewer_("PointCloud") , grabber_(grabber) , image_viewer_("Image") - , { added = false; diff --git a/apps/src/ni_susan.cpp b/apps/src/ni_susan.cpp index c27067e6bb6..b644f48cada 100644 --- a/apps/src/ni_susan.cpp +++ b/apps/src/ni_susan.cpp @@ -145,7 +145,8 @@ class SUSANDemo { image_viewer_.removeLayer(getStrBool(keypts)); for (std::size_t i = 0; i < keypoints->size(); ++i) { int u = static_cast((*keypoints)[i].label % cloud->width); - int v = cloud->height - static_cast((*keypoints)[i].label / cloud->width); + int v = + cloud->height - static_cast((*keypoints)[i].label / cloud->width); image_viewer_.markPoint(u, v, visualization::red_color, diff --git a/apps/src/openni_klt.cpp b/apps/src/openni_klt.cpp index ad269bad8a2..be92c0b00ee 100644 --- a/apps/src/openni_klt.cpp +++ b/apps/src/openni_klt.cpp @@ -112,8 +112,7 @@ class OpenNIViewer { using CloudConstPtr = typename Cloud::ConstPtr; OpenNIViewer(pcl::Grabber& grabber) - : grabber_(grabber), - {} + : grabber_(grabber) {} void detect_keypoints(const CloudConstPtr& cloud) diff --git a/apps/src/openni_organized_multi_plane_segmentation.cpp b/apps/src/openni_organized_multi_plane_segmentation.cpp index 36f0c621254..2a1b3a58590 100644 --- a/apps/src/openni_organized_multi_plane_segmentation.cpp +++ b/apps/src/openni_organized_multi_plane_segmentation.cpp @@ -154,8 +154,7 @@ class OpenNIOrganizedMultiPlaneSegmentation { double plane_extract_end = pcl::getTime(); std::cout << "Plane extraction took " << (plane_extract_end - plane_extract_start) << std::endl; - std::cout << "Frame took " << (plane_extract_end - normal_start) - << std::endl; + std::cout << "Frame took " << (plane_extract_end - normal_start) << std::endl; pcl::PointCloud::Ptr cluster(new pcl::PointCloud); diff --git a/apps/src/openni_tracking.cpp b/apps/src/openni_tracking.cpp index af765c1518e..3c0b6f8379c 100644 --- a/apps/src/openni_tracking.cpp +++ b/apps/src/openni_tracking.cpp @@ -121,10 +121,8 @@ class OpenNISegmentTracking { bool use_fixed) : viewer_("PCL OpenNI Tracking Viewer") , device_id_(device_id) - , - ne_(thread_nr) - , - use_convex_hull_(use_convex_hull) + , ne_(thread_nr) + , use_convex_hull_(use_convex_hull) , visualize_non_downsample_(visualize_non_downsample) , visualize_particles_(visualize_particles) , downsampling_grid_size_(downsampling_grid_size) @@ -339,7 +337,9 @@ class OpenNISegmentTracking { FPS_CALC_BEGIN; double start = pcl::getTime(); pcl::VoxelGrid grid; - grid.setLeafSize(static_cast(leaf_size), static_cast(leaf_size), static_cast(leaf_size)); + grid.setLeafSize(static_cast(leaf_size), + static_cast(leaf_size), + static_cast(leaf_size)); grid.setInputCloud(cloud); grid.filter(result); double end = pcl::getTime(); @@ -549,7 +549,8 @@ class OpenNISegmentTracking { double segment_distance = c[0] * c[0] + c[1] * c[1]; for (std::size_t i = 1; i < cluster_indices.size(); i++) { temp_cloud.reset(new Cloud); - extractSegmentCluster(target_cloud, cluster_indices, static_cast(i), *temp_cloud); + extractSegmentCluster( + target_cloud, cluster_indices, static_cast(i), *temp_cloud); pcl::compute3DCentroid(*temp_cloud, c); double distance = c[0] * c[0] + c[1] * c[1]; if (distance < segment_distance) { diff --git a/apps/src/pcd_organized_multi_plane_segmentation.cpp b/apps/src/pcd_organized_multi_plane_segmentation.cpp index 8fe6e52df31..fd21ec1ddba 100644 --- a/apps/src/pcd_organized_multi_plane_segmentation.cpp +++ b/apps/src/pcd_organized_multi_plane_segmentation.cpp @@ -60,8 +60,6 @@ class PCDOrganizedMultiPlaneSegmentation { : viewer("Viewer") , cloud(cloud_) , refine_(refine) - , - { viewer.setBackgroundColor(0, 0, 0); viewer.addCoordinateSystem(1.0, "global"); @@ -142,8 +140,7 @@ class PCDOrganizedMultiPlaneSegmentation { ne.setInputCloud(cloud); ne.compute(*normal_cloud); double normal_end = pcl::getTime(); - std::cout << "Normal Estimation took " << (normal_end - normal_start) - << std::endl; + std::cout << "Normal Estimation took " << (normal_end - normal_start) << std::endl; double plane_extract_start = pcl::getTime(); mps.setInputNormals(normal_cloud); @@ -153,8 +150,7 @@ class PCDOrganizedMultiPlaneSegmentation { else mps.segment(regions); double plane_extract_end = pcl::getTime(); - std::cout << "Plane extraction took " - << (plane_extract_end - plane_extract_start) + std::cout << "Plane extraction took " << (plane_extract_end - plane_extract_start) << " with planar regions found: " << regions.size() << std::endl; std::cout << "Frame took " << (plane_extract_end - normal_start) << std::endl; diff --git a/apps/src/pcd_select_object_plane.cpp b/apps/src/pcd_select_object_plane.cpp index 1db35b3ac5c..c0584037b6b 100644 --- a/apps/src/pcd_select_object_plane.cpp +++ b/apps/src/pcd_select_object_plane.cpp @@ -70,8 +70,7 @@ using namespace std::chrono_literals; template class ObjectSelection { public: - ObjectSelection() - : plane_comparator_(new EdgeAwarePlaneComparator), + ObjectSelection() : plane_comparator_(new EdgeAwarePlaneComparator) { // Set the parameters for planar segmentation plane_comparator_->setDistanceThreshold(0.01f, false); diff --git a/apps/src/pcd_video_player/pcd_video_player.cpp b/apps/src/pcd_video_player/pcd_video_player.cpp index 2140825c927..f7402765f88 100644 --- a/apps/src/pcd_video_player/pcd_video_player.cpp +++ b/apps/src/pcd_video_player/pcd_video_player.cpp @@ -224,7 +224,7 @@ PCDVideoPlayer::selectFilesButtonPressed() return; } - for (const auto & qt_pcd_file : qt_pcd_files) { + for (const auto& qt_pcd_file : qt_pcd_files) { pcd_files_.push_back(qt_pcd_file.toStdString()); } diff --git a/apps/src/ppf_object_recognition.cpp b/apps/src/ppf_object_recognition.cpp index 05524130070..4be5cb54f36 100644 --- a/apps/src/ppf_object_recognition.cpp +++ b/apps/src/ppf_object_recognition.cpp @@ -130,7 +130,8 @@ main(int argc, char** argv) // set parameters for the PPF registration procedure ppf_registration.setSceneReferencePointSamplingRate(10); ppf_registration.setPositionClusteringThreshold(0.2f); - ppf_registration.setRotationClusteringThreshold(30.0f / 180.0f * static_cast(M_PI)); + ppf_registration.setRotationClusteringThreshold(30.0f / 180.0f * + static_cast(M_PI)); ppf_registration.setSearchMethod(hashmap_search_vector[model_i]); ppf_registration.setInputSource(cloud_models_with_normals[model_i]); ppf_registration.setInputTarget(cloud_scene_input); diff --git a/apps/src/pyramid_surface_matching.cpp b/apps/src/pyramid_surface_matching.cpp index 6754e44a858..310c740b850 100644 --- a/apps/src/pyramid_surface_matching.cpp +++ b/apps/src/pyramid_surface_matching.cpp @@ -88,7 +88,8 @@ main(int argc, char** argv) dim_range_input.emplace_back(static_cast(-M_PI), static_cast(M_PI)); dim_range_input.emplace_back(0.0f, 1.0f); for (std::size_t i = 0; i < 3; ++i) - dim_range_target.emplace_back(static_cast(-M_PI) * 10.0f, static_cast(M_PI) * 10.0f); + dim_range_target.emplace_back(static_cast(-M_PI) * 10.0f, + static_cast(M_PI) * 10.0f); dim_range_target.emplace_back(0.0f, 50.0f); PyramidFeatureHistogram::Ptr pyramid_a( diff --git a/apps/src/render_views_tesselated_sphere.cpp b/apps/src/render_views_tesselated_sphere.cpp index e9101ed98c1..5fa7dcb9dfc 100644 --- a/apps/src/render_views_tesselated_sphere.cpp +++ b/apps/src/render_views_tesselated_sphere.cpp @@ -123,7 +123,9 @@ pcl::apps::RenderViewsTesselatedSphere::generateViews() sphere->GetPoint(ptIds_com[2], p3_com); vtkTriangle::TriangleCenter(p1_com, p2_com, p3_com, center); cam_positions[i] = - Eigen::Vector3f(static_cast(center[0]), static_cast(center[1]), static_cast(center[2])); + Eigen::Vector3f(static_cast(center[0]), + static_cast(center[1]), + static_cast(center[2])); i++; } } @@ -133,7 +135,9 @@ pcl::apps::RenderViewsTesselatedSphere::generateViews() double cam_pos[3]; sphere->GetPoint(i, cam_pos); cam_positions[i] = - Eigen::Vector3f(static_cast(cam_pos[0]), static_cast(cam_pos[1]), static_cast(cam_pos[2])); + Eigen::Vector3f(static_cast(cam_pos[0]), + static_cast(cam_pos[1]), + static_cast(cam_pos[2])); } } @@ -445,7 +449,8 @@ pcl::apps::RenderViewsTesselatedSphere::generateViews() for (int x = 0; x < 4; x++) for (int y = 0; y < 4; y++) - pose_view(x, y) = static_cast(transOCtoCC->GetMatrix()->GetElement(x, y)); + pose_view(x, y) = static_cast( + transOCtoCC->GetMatrix()->GetElement(x, y)); poses_.push_back(pose_view); } diff --git a/apps/src/stereo_ground_segmentation.cpp b/apps/src/stereo_ground_segmentation.cpp old mode 100755 new mode 100644 index 8bd74992bb7..f2eaa0d9aa3 --- a/apps/src/stereo_ground_segmentation.cpp +++ b/apps/src/stereo_ground_segmentation.cpp @@ -265,16 +265,15 @@ class HRCSSegmentation { for (const auto& region_index : region_indices) { if (region_index.indices.size() > 1000) { - for (int indice : region_index.indices) { - pcl::PointXYZ ground_pt((*cloud)[indice].x, - (*cloud)[indice].y, - (*cloud)[indice].z); + for (int index : region_index.indices) { + pcl::PointXYZ ground_pt( + (*cloud)[index].x, (*cloud)[index].y, (*cloud)[index].z); ground_cloud->points.push_back(ground_pt); - (*ground_image)[indice].g = static_cast( - ((*cloud)[indice].g + 255) / 2); - (*label_image)[indice].r = 0; - (*label_image)[indice].g = 255; - (*label_image)[indice].b = 0; + (*ground_image)[index].g = + static_cast(((*cloud)[index].g + 255) / 2); + (*label_image)[index].r = 0; + (*label_image)[index].g = 255; + (*label_image)[index].b = 0; } // Compute plane info @@ -346,21 +345,19 @@ class HRCSSegmentation { pcl::PointCloud extended_ground_cloud; for (const auto& region_index : region_indices) { if (region_index.indices.size() > 1000) { - for (int indice : region_index.indices) { + for (int index : region_index.indices) { // Check to see if it has already been labeled - if ((*ground_image)[indice].g == - (*ground_image)[indice].b) { - pcl::PointXYZ ground_pt((*cloud)[indice].x, - (*cloud)[indice].y, - (*cloud)[indice].z); + if ((*ground_image)[index].g == (*ground_image)[index].b) { + pcl::PointXYZ ground_pt( + (*cloud)[index].x, (*cloud)[index].y, (*cloud)[index].z); ground_cloud->points.push_back(ground_pt); - (*ground_image)[indice].r = static_cast( - ((*cloud)[indice].r + 255) / 2); - (*ground_image)[indice].g = static_cast( - ((*cloud)[indice].g + 255) / 2); - (*label_image)[indice].r = 128; - (*label_image)[indice].g = 128; - (*label_image)[indice].b = 0; + (*ground_image)[index].r = + static_cast(((*cloud)[index].r + 255) / 2); + (*ground_image)[index].g = + static_cast(((*cloud)[index].g + 255) / 2); + (*label_image)[index].r = 128; + (*label_image)[index].g = 128; + (*label_image)[index].b = 0; } } } @@ -425,11 +422,11 @@ class HRCSSegmentation { if ((ptp_dist > 0.5) && (ptp_dist < 3.0)) { - for (int indice : euclidean_label_index.indices) { - (*ground_image)[indice].r = 255; - (*label_image)[indice].r = 255; - (*label_image)[indice].g = 0; - (*label_image)[indice].b = 0; + for (int index : euclidean_label_index.indices) { + (*ground_image)[index].r = 255; + (*label_image)[index].r = 255; + (*label_image)[index].g = 0; + (*label_image)[index].b = 0; } } } diff --git a/geometry/include/pcl/geometry/impl/polygon_operations.hpp b/geometry/include/pcl/geometry/impl/polygon_operations.hpp index 4b012864f67..de12bad1955 100644 --- a/geometry/include/pcl/geometry/impl/polygon_operations.hpp +++ b/geometry/include/pcl/geometry/impl/polygon_operations.hpp @@ -289,9 +289,7 @@ pcl::approximatePolygon2D(const typename pcl::PointCloud::VectorType& po } else { // we have a new polygon in results, but inverted (clockwise <-> counter-clockwise) - for (auto it = result.rbegin(); - it != result.rend(); - ++it) + for (auto it = result.rbegin(); it != result.rend(); ++it) approx_polygon.push_back(polygon[*it]); } } diff --git a/tracking/include/pcl/tracking/hsv_color_coherence.h b/tracking/include/pcl/tracking/hsv_color_coherence.h index 92882272c94..9bf58b8c921 100644 --- a/tracking/include/pcl/tracking/hsv_color_coherence.h +++ b/tracking/include/pcl/tracking/hsv_color_coherence.h @@ -21,8 +21,7 @@ class HSVColorCoherence : public PointCoherence { * default to 1.0 and v_weight_ defaults to 0.0. */ HSVColorCoherence() - : PointCoherence() - {} + : PointCoherence() {} /** \brief set the weight of coherence * \param[in] weight the weight of coherence. diff --git a/tracking/include/pcl/tracking/impl/pyramidal_klt.hpp b/tracking/include/pcl/tracking/impl/pyramidal_klt.hpp index 761757a4879..105e03832d4 100644 --- a/tracking/include/pcl/tracking/impl/pyramidal_klt.hpp +++ b/tracking/include/pcl/tracking/impl/pyramidal_klt.hpp @@ -633,8 +633,10 @@ PyramidalKLTTracker::track( for (unsigned int j = 0; j < max_iterations_; j++) { Eigen::Array2i inext_pt = next_pt.floor().cast(); - if (inext_pt[0] < -track_width_ || static_cast(inext_pt[0]) >= next.width || - inext_pt[1] < -track_height_ || static_cast(inext_pt[1]) >= next.height) { + if (inext_pt[0] < -track_width_ || + static_cast(inext_pt[0]) >= next.width || + inext_pt[1] < -track_height_ || + static_cast(inext_pt[1]) >= next.height) { if (level == 0) status[ptidx] = -1; break; diff --git a/tracking/include/pcl/tracking/pyramidal_klt.h b/tracking/include/pcl/tracking/pyramidal_klt.h index d72deec517a..bd651e30f92 100644 --- a/tracking/include/pcl/tracking/pyramidal_klt.h +++ b/tracking/include/pcl/tracking/pyramidal_klt.h @@ -85,8 +85,6 @@ class PyramidalKLTTracker : public Tracker { , nb_levels_(nb_levels) , track_width_(tracking_window_width) , track_height_(tracking_window_height) - , - { tracker_name_ = "PyramidalKLTTracker"; accuracy_ = 0.1; From 34343f9b8373815248ff60853fdfcd35954aef45 Mon Sep 17 00:00:00 2001 From: Norm Evangelista Date: Thu, 20 Nov 2025 16:15:19 -0800 Subject: [PATCH 5/8] Fixed yet more clang-format escapes --- .../pipeline/local_recognizer.h | 2 +- .../src/tools/openni_frame_source.cpp | 2 +- .../cloud_composer/impl/merge_selection.hpp | 5 ++--- apps/cloud_composer/src/toolbox_model.cpp | 4 +--- .../tools/euclidean_clustering.cpp | 15 ++++++++------- .../apps/in_hand_scanner/impl/common_types.hpp | 3 ++- apps/in_hand_scanner/src/icp.cpp | 3 +-- apps/in_hand_scanner/src/in_hand_scanner.cpp | 3 +-- apps/in_hand_scanner/src/integration.cpp | 7 +++---- apps/in_hand_scanner/src/opengl_viewer.cpp | 14 +++++--------- apps/modeler/src/parameter_dialog.cpp | 8 ++++---- .../src/face_detection/openni_frame_source.cpp | 3 +-- apps/src/feature_matching.cpp | 3 +-- apps/src/openni_klt.cpp | 3 +-- .../pcd_organized_multi_plane_segmentation.cpp | 4 +--- apps/src/render_views_tesselated_sphere.cpp | 18 ++++++++---------- .../include/pcl/tracking/hsv_color_coherence.h | 3 +-- 17 files changed, 42 insertions(+), 58 deletions(-) mode change 100755 => 100644 apps/modeler/src/parameter_dialog.cpp diff --git a/apps/3d_rec_framework/include/pcl/apps/3d_rec_framework/pipeline/local_recognizer.h b/apps/3d_rec_framework/include/pcl/apps/3d_rec_framework/pipeline/local_recognizer.h index 20f50ad52c4..0932cd70e6d 100644 --- a/apps/3d_rec_framework/include/pcl/apps/3d_rec_framework/pipeline/local_recognizer.h +++ b/apps/3d_rec_framework/include/pcl/apps/3d_rec_framework/pipeline/local_recognizer.h @@ -195,7 +195,7 @@ class PCL_EXPORTS LocalRecognitionPipeline { } public: - LocalRecognitionPipeline() : + LocalRecognitionPipeline() : { use_cache_ = false; threshold_accept_model_hypothesis_ = 0.2f; diff --git a/apps/3d_rec_framework/src/tools/openni_frame_source.cpp b/apps/3d_rec_framework/src/tools/openni_frame_source.cpp index a6eb42bdc39..b612bb218d7 100644 --- a/apps/3d_rec_framework/src/tools/openni_frame_source.cpp +++ b/apps/3d_rec_framework/src/tools/openni_frame_source.cpp @@ -5,7 +5,7 @@ namespace OpenNIFrameSource { OpenNIFrameSource::OpenNIFrameSource(const std::string& device_id) -: grabber_(device_id), +: grabber_(device_id), { std::function frame_cb = [this](const PointCloudConstPtr& cloud) { onNewFrame(cloud); }; diff --git a/apps/cloud_composer/include/pcl/apps/cloud_composer/impl/merge_selection.hpp b/apps/cloud_composer/include/pcl/apps/cloud_composer/impl/merge_selection.hpp index b2bd99c8e81..dbc139df5df 100644 --- a/apps/cloud_composer/include/pcl/apps/cloud_composer/impl/merge_selection.hpp +++ b/apps/cloud_composer/include/pcl/apps/cloud_composer/impl/merge_selection.hpp @@ -74,9 +74,8 @@ pcl::cloud_composer::MergeSelection::performTemplatedAction( input_cloud_item->printNumPoints(); // If this cloud hasn't been completely selected if (!input_data.contains(input_cloud_item)) { - auto input_cloud = - input_cloud_item->data(ItemDataRole::CLOUD_TEMPLATED) - .value::Ptr>(); + auto input_cloud = input_cloud_item->data(ItemDataRole::CLOUD_TEMPLATED) + .value::Ptr>(); qDebug() << "Extracting " << selected_item_index_map_.value(input_cloud_item)->indices.size() << " points out of " << input_cloud->width; diff --git a/apps/cloud_composer/src/toolbox_model.cpp b/apps/cloud_composer/src/toolbox_model.cpp index 950ce4317d1..3de7028ecdc 100644 --- a/apps/cloud_composer/src/toolbox_model.cpp +++ b/apps/cloud_composer/src/toolbox_model.cpp @@ -10,9 +10,7 @@ pcl::cloud_composer::ToolBoxModel::ToolBoxModel(QTreeView* tool_view, QTreeView* parameter_view_, QObject* parent) -: QStandardItemModel(parent) -, tool_view_(tool_view) -, parameter_view_(parameter_view_) +: QStandardItemModel(parent), tool_view_(tool_view), parameter_view_(parameter_view_) {} pcl::cloud_composer::ToolBoxModel::ToolBoxModel(const ToolBoxModel&) diff --git a/apps/cloud_composer/tools/euclidean_clustering.cpp b/apps/cloud_composer/tools/euclidean_clustering.cpp index b41d5b97d39..5f53011cf01 100644 --- a/apps/cloud_composer/tools/euclidean_clustering.cpp +++ b/apps/cloud_composer/tools/euclidean_clustering.cpp @@ -84,10 +84,11 @@ pcl::cloud_composer::EuclideanClusteringTool::performAction(ConstItemList input_ filter.filter(*cloud_filtered); qDebug() << "Cluster has " << cloud_filtered->width << " data points."; - auto* cloud_item = new CloudItem(input_item->text() + tr("-Clstr %1").arg(cluster_count), - cloud_filtered, - source_origin, - source_orientation); + auto* cloud_item = + new CloudItem(input_item->text() + tr("-Clstr %1").arg(cluster_count), + cloud_filtered, + source_origin, + source_orientation); output.append(cloud_item); ++cluster_count; } @@ -103,9 +104,9 @@ pcl::cloud_composer::EuclideanClusteringTool::performAction(ConstItemList input_ qDebug() << "Cloud has " << remainder_cloud->width << " data points after clusters removed."; auto* cloud_item = new CloudItem(input_item->text() + " unclustered", - remainder_cloud, - source_origin, - source_orientation); + remainder_cloud, + source_origin, + source_orientation); output.push_front(cloud_item); } else diff --git a/apps/in_hand_scanner/include/pcl/apps/in_hand_scanner/impl/common_types.hpp b/apps/in_hand_scanner/include/pcl/apps/in_hand_scanner/impl/common_types.hpp index 868f31f5ea8..650441f3335 100644 --- a/apps/in_hand_scanner/include/pcl/apps/in_hand_scanner/impl/common_types.hpp +++ b/apps/in_hand_scanner/include/pcl/apps/in_hand_scanner/impl/common_types.hpp @@ -78,7 +78,8 @@ struct PointIHS : public pcl::ihs::_PointIHS { this->directions = 0; } - inline PointIHS(const PointIHS& other) : _PointIHS(other) { + inline PointIHS(const PointIHS& other) : _PointIHS(other) + { this->x = other.x; this->y = other.y; this->z = other.z; diff --git a/apps/in_hand_scanner/src/icp.cpp b/apps/in_hand_scanner/src/icp.cpp index bdc5e13000f..373f25a3f41 100644 --- a/apps/in_hand_scanner/src/icp.cpp +++ b/apps/in_hand_scanner/src/icp.cpp @@ -51,8 +51,7 @@ //////////////////////////////////////////////////////////////////////////////// -pcl::ihs::ICP::ICP() : kd_tree_(new pcl::KdTreeFLANN()) -{} +pcl::ihs::ICP::ICP() : kd_tree_(new pcl::KdTreeFLANN()) {} //////////////////////////////////////////////////////////////////////////////// diff --git a/apps/in_hand_scanner/src/in_hand_scanner.cpp b/apps/in_hand_scanner/src/in_hand_scanner.cpp index 1edc799617b..e5dcd527fe2 100644 --- a/apps/in_hand_scanner/src/in_hand_scanner.cpp +++ b/apps/in_hand_scanner/src/in_hand_scanner.cpp @@ -62,8 +62,7 @@ pcl::ihs::InHandScanner::InHandScanner(Base* parent) : Base(parent) -, - input_data_processing_(new InputDataProcessing()) +, input_data_processing_(new InputDataProcessing()) , icp_(new ICP()) , transformation_(Eigen::Matrix4f::Identity()) , integration_(new Integration()) diff --git a/apps/in_hand_scanner/src/integration.cpp b/apps/in_hand_scanner/src/integration.cpp index 2d29a69d9f3..c6b3f0faebf 100644 --- a/apps/in_hand_scanner/src/integration.cpp +++ b/apps/in_hand_scanner/src/integration.cpp @@ -49,8 +49,7 @@ //////////////////////////////////////////////////////////////////////////////// -pcl::ihs::Integration::Integration() -: kd_tree_(new pcl::KdTreeFLANN()) {} +pcl::ihs::Integration::Integration() : kd_tree_(new pcl::KdTreeFLANN()) {} //////////////////////////////////////////////////////////////////////////////// @@ -339,8 +338,8 @@ pcl::ihs::Integration::merge(const CloudXYZRGBNormalConstPtr& cloud_data, pt_m.directions); } // dot normals - } // squared distance - } // !isnan && min weight + } // squared distance + } // !isnan && min weight // Connect // 4 2 - 1 // diff --git a/apps/in_hand_scanner/src/opengl_viewer.cpp b/apps/in_hand_scanner/src/opengl_viewer.cpp index 9b1b1f020ae..d9a22727ab3 100644 --- a/apps/in_hand_scanner/src/opengl_viewer.cpp +++ b/apps/in_hand_scanner/src/opengl_viewer.cpp @@ -63,7 +63,6 @@ // FaceVertexMesh //////////////////////////////////////////////////////////////////////////////// - : transformation(Eigen::Isometry3d::Identity()) = default; @@ -105,12 +104,9 @@ pcl::ihs::OpenGLViewer::OpenGLViewer(QWidget* parent) : QOpenGLWidget(parent) , timer_vis_(new QTimer(this)) , colormap_(Colormap::Constant(255)) -, - R_cam_(1., 0., 0., 0.) +, R_cam_(1., 0., 0., 0.) , t_cam_(0., 0., 0.) , cam_pivot_(0., 0., 0.) -, - { // Timer: Defines the update rate for the visualization connect(timer_vis_.get(), SIGNAL(timeout()), this, SLOT(timerCallback())); @@ -131,11 +127,11 @@ pcl::ihs::OpenGLViewer::OpenGLViewer(QWidget* parent) // colormap). ////////////////////////////////////////////////////////////////////////////// - //#include - //#include + // #include + // #include - //#include - //#include + // #include + // #include // int // main() diff --git a/apps/modeler/src/parameter_dialog.cpp b/apps/modeler/src/parameter_dialog.cpp old mode 100755 new mode 100644 index ca3a9ddd0aa..73a930bc555 --- a/apps/modeler/src/parameter_dialog.cpp +++ b/apps/modeler/src/parameter_dialog.cpp @@ -86,12 +86,12 @@ pcl::modeler::ParameterDialog::exec() std::size_t currentRow = 0; for (const auto& name_parameter : name_parameter_map_) { - QModelIndex name = parameterModel.index( - static_cast(currentRow), 0, QModelIndex()); + QModelIndex name = + parameterModel.index(static_cast(currentRow), 0, QModelIndex()); parameterModel.setData(name, QVariant(name_parameter.first.c_str())); - QModelIndex value = parameterModel.index( - static_cast(currentRow), 1, QModelIndex()); + QModelIndex value = + parameterModel.index(static_cast(currentRow), 1, QModelIndex()); std::pair model_data = name_parameter.second->toModelData(); parameterModel.setData(value, model_data.first, model_data.second); diff --git a/apps/src/face_detection/openni_frame_source.cpp b/apps/src/face_detection/openni_frame_source.cpp index 5a41a3cbfa1..310cb50900b 100644 --- a/apps/src/face_detection/openni_frame_source.cpp +++ b/apps/src/face_detection/openni_frame_source.cpp @@ -3,8 +3,7 @@ namespace OpenNIFrameSource { -OpenNIFrameSource::OpenNIFrameSource(const std::string& device_id) -: grabber_(device_id) +OpenNIFrameSource::OpenNIFrameSource(const std::string& device_id) : grabber_(device_id) { std::function frame_cb = [this](const PointCloudConstPtr& cloud) { onNewFrame(cloud); }; diff --git a/apps/src/feature_matching.cpp b/apps/src/feature_matching.cpp index 219c04ecde9..077eace391c 100644 --- a/apps/src/feature_matching.cpp +++ b/apps/src/feature_matching.cpp @@ -590,8 +590,7 @@ main(int argc, char** argv) pcl::Keypoint::Ptr keypoint_detector; if (keypoint_type == 1) { - auto* sift3D = - new pcl::SIFTKeypoint; + auto* sift3D = new pcl::SIFTKeypoint; sift3D->setScales(0.01f, 3, 2); sift3D->setMinimumContrast(0.0); keypoint_detector.reset(sift3D); diff --git a/apps/src/openni_klt.cpp b/apps/src/openni_klt.cpp index be92c0b00ee..89e69d8073f 100644 --- a/apps/src/openni_klt.cpp +++ b/apps/src/openni_klt.cpp @@ -111,8 +111,7 @@ class OpenNIViewer { using Cloud = pcl::PointCloud; using CloudConstPtr = typename Cloud::ConstPtr; - OpenNIViewer(pcl::Grabber& grabber) - : grabber_(grabber) {} + OpenNIViewer(pcl::Grabber& grabber) : grabber_(grabber) {} void detect_keypoints(const CloudConstPtr& cloud) diff --git a/apps/src/pcd_organized_multi_plane_segmentation.cpp b/apps/src/pcd_organized_multi_plane_segmentation.cpp index fd21ec1ddba..1f20c205a3f 100644 --- a/apps/src/pcd_organized_multi_plane_segmentation.cpp +++ b/apps/src/pcd_organized_multi_plane_segmentation.cpp @@ -57,9 +57,7 @@ class PCDOrganizedMultiPlaneSegmentation { public: PCDOrganizedMultiPlaneSegmentation(typename pcl::PointCloud::ConstPtr cloud_, bool refine) - : viewer("Viewer") - , cloud(cloud_) - , refine_(refine) + : viewer("Viewer"), cloud(cloud_), refine_(refine) { viewer.setBackgroundColor(0, 0, 0); viewer.addCoordinateSystem(1.0, "global"); diff --git a/apps/src/render_views_tesselated_sphere.cpp b/apps/src/render_views_tesselated_sphere.cpp index 5fa7dcb9dfc..1d9c2536a26 100644 --- a/apps/src/render_views_tesselated_sphere.cpp +++ b/apps/src/render_views_tesselated_sphere.cpp @@ -122,10 +122,9 @@ pcl::apps::RenderViewsTesselatedSphere::generateViews() sphere->GetPoint(ptIds_com[1], p2_com); sphere->GetPoint(ptIds_com[2], p3_com); vtkTriangle::TriangleCenter(p1_com, p2_com, p3_com, center); - cam_positions[i] = - Eigen::Vector3f(static_cast(center[0]), - static_cast(center[1]), - static_cast(center[2])); + cam_positions[i] = Eigen::Vector3f(static_cast(center[0]), + static_cast(center[1]), + static_cast(center[2])); i++; } } @@ -134,10 +133,9 @@ pcl::apps::RenderViewsTesselatedSphere::generateViews() for (vtkIdType i = 0; i < sphere->GetNumberOfPoints(); i++) { double cam_pos[3]; sphere->GetPoint(i, cam_pos); - cam_positions[i] = - Eigen::Vector3f(static_cast(cam_pos[0]), - static_cast(cam_pos[1]), - static_cast(cam_pos[2])); + cam_positions[i] = Eigen::Vector3f(static_cast(cam_pos[0]), + static_cast(cam_pos[1]), + static_cast(cam_pos[2])); } } @@ -449,8 +447,8 @@ pcl::apps::RenderViewsTesselatedSphere::generateViews() for (int x = 0; x < 4; x++) for (int y = 0; y < 4; y++) - pose_view(x, y) = static_cast( - transOCtoCC->GetMatrix()->GetElement(x, y)); + pose_view(x, y) = + static_cast(transOCtoCC->GetMatrix()->GetElement(x, y)); poses_.push_back(pose_view); } diff --git a/tracking/include/pcl/tracking/hsv_color_coherence.h b/tracking/include/pcl/tracking/hsv_color_coherence.h index 9bf58b8c921..c0ca4cb062e 100644 --- a/tracking/include/pcl/tracking/hsv_color_coherence.h +++ b/tracking/include/pcl/tracking/hsv_color_coherence.h @@ -20,8 +20,7 @@ class HSVColorCoherence : public PointCoherence { /** \brief initialize the weights of the computation. weight_, h_weight_, s_weight_ * default to 1.0 and v_weight_ defaults to 0.0. */ - HSVColorCoherence() - : PointCoherence() {} + HSVColorCoherence() : PointCoherence() {} /** \brief set the weight of coherence * \param[in] weight the weight of coherence. From 4c8d4fcd324bd11e1761a216626823a46ad98d20 Mon Sep 17 00:00:00 2001 From: Norm Evangelista Date: Thu, 20 Nov 2025 16:27:16 -0800 Subject: [PATCH 6/8] Fixed some clang-format stragglers --- apps/cloud_composer/src/commands.cpp | 2 +- apps/src/ni_linemod.cpp | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/apps/cloud_composer/src/commands.cpp b/apps/cloud_composer/src/commands.cpp index 60095d85178..684f707e733 100644 --- a/apps/cloud_composer/src/commands.cpp +++ b/apps/cloud_composer/src/commands.cpp @@ -5,7 +5,7 @@ pcl::cloud_composer::CloudCommand::CloudCommand( QList input_data, QUndoCommand* parent) -: QUndoCommand(parent) , original_data_(std::move(input_data)) +: QUndoCommand(parent), original_data_(std::move(input_data)) {} pcl::cloud_composer::CloudCommand::~CloudCommand() diff --git a/apps/src/ni_linemod.cpp b/apps/src/ni_linemod.cpp index 707ba5b6b09..a5532c8008c 100644 --- a/apps/src/ni_linemod.cpp +++ b/apps/src/ni_linemod.cpp @@ -77,9 +77,7 @@ class NILinemod { bool added; NILinemod(Grabber& grabber) - : cloud_viewer_("PointCloud") - , grabber_(grabber) - , image_viewer_("Image") + : cloud_viewer_("PointCloud"), grabber_(grabber), image_viewer_("Image") { added = false; From 5a2e42c3b50195df2b8153e3ab0b9dd99a42d9ed Mon Sep 17 00:00:00 2001 From: Norm Evangelista Date: Thu, 20 Nov 2025 16:48:48 -0800 Subject: [PATCH 7/8] Manual fix of clang-format escape --- apps/in_hand_scanner/src/integration.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/in_hand_scanner/src/integration.cpp b/apps/in_hand_scanner/src/integration.cpp index c6b3f0faebf..fe21546b798 100644 --- a/apps/in_hand_scanner/src/integration.cpp +++ b/apps/in_hand_scanner/src/integration.cpp @@ -338,8 +338,8 @@ pcl::ihs::Integration::merge(const CloudXYZRGBNormalConstPtr& cloud_data, pt_m.directions); } // dot normals - } // squared distance - } // !isnan && min weight + } // squared distance + } // !isnan && min weight // Connect // 4 2 - 1 // From aaff7bab74068dcb7eb6d02a6c91d58bdb5317df Mon Sep 17 00:00:00 2001 From: Norm Evangelista Date: Thu, 20 Nov 2025 16:48:48 -0800 Subject: [PATCH 8/8] Manual fix of clang-format escape --- apps/3d_rec_framework/CMakeLists.txt | 4 +- .../feature_wrapper/local/local_estimator.h | 8 +- .../feature_wrapper/normal_estimator.h | 5 +- .../apps/3d_rec_framework/pc_source/source.h | 3 +- .../impl/global_nn_recognizer_crh.hpp | 6 +- .../impl/global_nn_recognizer_cvfh.hpp | 6 +- .../pipeline/impl/local_recognizer.hpp | 9 +- .../pipeline/local_recognizer.h | 2 +- .../tools/openni_frame_source.h | 4 +- .../utils/persistence_utils.h | 2 +- .../tools/local_recognition_mian_dataset.cpp | 2 +- .../src/tools/openni_frame_source.cpp | 2 +- apps/CMakeLists.txt | 102 +-- apps/cloud_composer/CMakeLists.txt | 6 +- .../pcl/apps/cloud_composer/cloud_browser.h | 69 +- .../pcl/apps/cloud_composer/cloud_composer.h | 243 +++--- .../pcl/apps/cloud_composer/cloud_view.h | 236 +++-- .../pcl/apps/cloud_composer/cloud_viewer.h | 74 +- .../pcl/apps/cloud_composer/commands.h | 339 ++++---- .../apps/cloud_composer/impl/cloud_item.hpp | 55 +- .../cloud_composer/impl/merge_selection.hpp | 118 ++- .../cloud_composer/impl/transform_clouds.hpp | 81 +- .../pcl/apps/cloud_composer/item_inspector.h | 105 +-- .../items/cloud_composer_item.h | 241 +++--- .../apps/cloud_composer/items/cloud_item.h | 301 ++++--- .../pcl/apps/cloud_composer/items/fpfh_item.h | 70 +- .../apps/cloud_composer/items/normals_item.h | 68 +- .../pcl/apps/cloud_composer/merge_selection.h | 57 +- .../click_trackball_interactor_style.h | 146 ++-- .../point_selectors/interactor_style_switch.h | 210 +++-- .../point_selectors/manipulation_event.h | 61 +- .../rectangular_frustum_selector.h | 95 +- .../selected_trackball_interactor_style.h | 165 ++-- .../point_selectors/selection_event.h | 107 ++- .../pcl/apps/cloud_composer/project_model.h | 326 ++++--- .../apps/cloud_composer/properties_model.h | 94 +- .../apps/cloud_composer/signal_multiplexer.h | 207 ++--- .../tool_interface/abstract_tool.h | 270 +++--- .../tool_interface/tool_factory.h | 93 +- .../pcl/apps/cloud_composer/toolbox_model.h | 140 +-- .../tools/euclidean_clustering.h | 112 ++- .../cloud_composer/tools/fpfh_estimation.h | 116 ++- .../tools/impl/organized_segmentation.hpp | 222 +++-- .../cloud_composer/tools/impl/supervoxels.hpp | 193 +++-- .../cloud_composer/tools/normal_estimation.h | 112 ++- .../tools/organized_segmentation.h | 216 +++-- .../cloud_composer/tools/sanitize_cloud.h | 120 ++- .../tools/statistical_outlier_removal.h | 111 ++- .../apps/cloud_composer/tools/supervoxels.h | 218 +++-- .../tools/voxel_grid_downsample.h | 112 ++- .../apps/cloud_composer/transform_clouds.h | 49 +- .../pcl/apps/cloud_composer/work_queue.h | 75 +- apps/cloud_composer/src/cloud_composer.cpp | 513 ++++++----- apps/cloud_composer/src/cloud_view.cpp | 6 +- apps/cloud_composer/src/cloud_viewer.cpp | 70 +- apps/cloud_composer/src/commands.cpp | 663 +++++++------- apps/cloud_composer/src/item_inspector.cpp | 150 ++-- .../src/items/cloud_composer_item.cpp | 94 +- apps/cloud_composer/src/items/cloud_item.cpp | 9 +- apps/cloud_composer/src/items/fpfh_item.cpp | 74 +- .../cloud_composer/src/items/normals_item.cpp | 6 +- apps/cloud_composer/src/main.cpp | 10 +- apps/cloud_composer/src/merge_selection.cpp | 146 ++-- .../click_trackball_interactor_style.cpp | 120 +-- .../interactor_style_switch.cpp | 161 ++-- .../point_selectors/manipulation_event.cpp | 10 +- .../rectangular_frustum_selector.cpp | 149 ++-- .../selected_trackball_interactor_style.cpp | 410 +++++---- .../src/point_selectors/selection_event.cpp | 52 +- apps/cloud_composer/src/project_model.cpp | 20 +- apps/cloud_composer/src/properties_model.cpp | 171 ++-- .../cloud_composer/src/signal_multiplexer.cpp | 100 +-- .../src/tool_interface/abstract_tool.cpp | 26 +- apps/cloud_composer/src/toolbox_model.cpp | 331 +++---- apps/cloud_composer/src/transform_clouds.cpp | 47 +- apps/cloud_composer/src/work_queue.cpp | 65 +- .../tools/euclidean_clustering.cpp | 178 ++-- apps/cloud_composer/tools/fpfh_estimation.cpp | 130 ++- .../tools/normal_estimation.cpp | 92 +- .../tools/organized_segmentation.cpp | 81 +- apps/cloud_composer/tools/sanitize_cloud.cpp | 99 +-- .../tools/statistical_outlier_removal.cpp | 113 +-- apps/cloud_composer/tools/supervoxels.cpp | 79 +- .../tools/voxel_grid_downsample.cpp | 114 +-- apps/in_hand_scanner/CMakeLists.txt | 10 +- .../include/pcl/apps/in_hand_scanner/boost.h | 48 ++ .../include/pcl/apps/in_hand_scanner/eigen.h | 49 ++ .../include/pcl/apps/in_hand_scanner/icp.h | 12 +- .../in_hand_scanner/impl/common_types.hpp | 2 +- .../apps/in_hand_scanner/in_hand_scanner.h | 10 +- .../in_hand_scanner/input_data_processing.h | 32 +- .../pcl/apps/in_hand_scanner/integration.h | 10 +- .../in_hand_scanner/offline_integration.h | 2 +- .../pcl/apps/in_hand_scanner/opengl_viewer.h | 22 +- apps/in_hand_scanner/src/icp.cpp | 31 +- apps/in_hand_scanner/src/in_hand_scanner.cpp | 7 +- .../src/input_data_processing.cpp | 20 +- apps/in_hand_scanner/src/integration.cpp | 12 +- apps/in_hand_scanner/src/main_window.cpp | 4 +- .../src/offline_integration.cpp | 1 + apps/in_hand_scanner/src/opengl_viewer.cpp | 30 +- .../apps/face_detection/openni_frame_source.h | 4 +- .../apps/impl/dominant_plane_segmentation.hpp | 14 +- apps/include/pcl/apps/nn_classification.h | 8 +- apps/include/pcl/apps/openni_passthrough.h | 2 +- .../pcl/apps/organized_segmentation_demo.h | 2 +- apps/include/pcl/apps/pcd_video_player.h | 2 +- apps/include/pcl/apps/pcl_viewer_dialog.h | 2 +- apps/include/pcl/apps/timer.h | 2 +- apps/include/pcl/apps/vfh_nn_classifier.h | 1 - apps/modeler/CMakeLists.txt | 7 +- .../pcl/apps/modeler/abstract_worker.h | 2 +- .../pcl/apps/modeler/channel_actor_item.h | 2 +- .../apps/modeler/icp_registration_worker.h | 8 +- .../apps/modeler/normal_estimation_worker.h | 4 +- .../pcl/apps/modeler/normals_actor_item.h | 4 +- .../pcl/apps/modeler/parameter_dialog.h | 2 +- .../include/pcl/apps/modeler/poisson_worker.h | 14 +- .../pcl/apps/modeler/render_window_item.h | 2 +- .../statistical_outlier_removal_worker.h | 6 +- .../pcl/apps/modeler/thread_controller.h | 2 +- .../modeler/voxel_grid_downsample_worker.h | 8 +- apps/modeler/src/abstract_item.cpp | 2 +- apps/modeler/src/cloud_mesh.cpp | 10 +- apps/modeler/src/cloud_mesh_item.cpp | 12 +- apps/modeler/src/icp_registration_worker.cpp | 16 +- apps/modeler/src/main_window.cpp | 3 +- apps/modeler/src/normal_estimation_worker.cpp | 14 +- apps/modeler/src/normals_actor_item.cpp | 20 +- apps/modeler/src/parameter.cpp | 24 +- apps/modeler/src/parameter_dialog.cpp | 24 +- apps/modeler/src/points_actor_item.cpp | 2 +- apps/modeler/src/poisson_worker.cpp | 6 + apps/modeler/src/render_window.cpp | 6 +- apps/modeler/src/render_window_item.cpp | 4 +- apps/modeler/src/scene_tree.cpp | 17 +- .../statistical_outlier_removal_worker.cpp | 2 + apps/modeler/src/surface_actor_item.cpp | 2 +- apps/modeler/src/thread_controller.cpp | 4 +- .../src/voxel_grid_downsample_worker.cpp | 15 +- apps/point_cloud_editor/CMakeLists.txt | 6 +- .../pcl/apps/point_cloud_editor/cloud.h | 809 +++++++++--------- .../point_cloud_editor/cloudEditorWidget.h | 493 +++++------ .../point_cloud_editor/cloudTransformTool.h | 192 +++-- .../pcl/apps/point_cloud_editor/command.h | 81 +- .../apps/point_cloud_editor/commandQueue.h | 133 +-- .../pcl/apps/point_cloud_editor/common.h | 2 +- .../pcl/apps/point_cloud_editor/copyBuffer.h | 89 +- .../pcl/apps/point_cloud_editor/copyCommand.h | 97 +-- .../pcl/apps/point_cloud_editor/cutCommand.h | 112 +-- .../apps/point_cloud_editor/deleteCommand.h | 66 +- .../apps/point_cloud_editor/denoiseCommand.h | 32 +- .../point_cloud_editor/denoiseParameterForm.h | 105 +-- .../pcl/apps/point_cloud_editor/localTypes.h | 45 +- .../pcl/apps/point_cloud_editor/mainWindow.h | 276 +++--- .../apps/point_cloud_editor/pasteCommand.h | 79 +- .../apps/point_cloud_editor/select1DTool.h | 113 +-- .../apps/point_cloud_editor/select2DTool.h | 221 ++--- .../pcl/apps/point_cloud_editor/selection.h | 278 +++--- .../selectionTransformTool.h | 228 ++--- .../pcl/apps/point_cloud_editor/statistics.h | 80 +- .../point_cloud_editor/statisticsDialog.h | 51 +- .../apps/point_cloud_editor/toolInterface.h | 125 +-- .../pcl/apps/point_cloud_editor/trackball.h | 67 +- .../point_cloud_editor/transformCommand.h | 129 ++- apps/point_cloud_editor/src/cloud.cpp | 4 +- .../src/cloudEditorWidget.cpp | 62 +- .../src/cloudTransformTool.cpp | 8 +- .../src/denoiseParameterForm.cpp | 2 +- apps/point_cloud_editor/src/select1DTool.cpp | 2 +- apps/point_cloud_editor/src/selection.cpp | 4 +- .../src/selectionTransformTool.cpp | 14 +- .../src/statisticsDialog.cpp | 2 +- apps/point_cloud_editor/src/trackball.cpp | 2 +- apps/src/convolve.cpp | 4 +- apps/src/dinast_grabber_example.cpp | 4 +- .../filesystem_face_detection.cpp | 4 +- .../face_detection/openni_frame_source.cpp | 3 +- apps/src/feature_matching.cpp | 24 +- apps/src/grabcut_2d.cpp | 12 +- .../manual_registration.cpp | 2 +- ...multiscale_feature_persistence_example.cpp | 1 - apps/src/ni_agast.cpp | 15 +- apps/src/ni_brisk.cpp | 10 +- apps/src/ni_linemod.cpp | 7 +- apps/src/ni_susan.cpp | 5 +- apps/src/openni_3d_concave_hull.cpp | 4 +- apps/src/openni_3d_convex_hull.cpp | 4 +- apps/src/openni_boundary_estimation.cpp | 5 +- apps/src/openni_fast_mesh.cpp | 4 +- apps/src/openni_feature_persistence.cpp | 7 +- apps/src/openni_ii_normal_estimation.cpp | 4 +- apps/src/openni_klt.cpp | 12 +- apps/src/openni_mls_smoothing.cpp | 4 +- apps/src/openni_mobile_server.cpp | 4 +- apps/src/openni_octree_compression.cpp | 8 +- apps/src/openni_organized_compression.cpp | 10 +- apps/src/openni_organized_edge_detection.cpp | 10 +- ...nni_organized_multi_plane_segmentation.cpp | 7 +- apps/src/openni_planar_convex_hull.cpp | 2 +- apps/src/openni_planar_segmentation.cpp | 2 +- apps/src/openni_shift_to_depth_conversion.cpp | 6 +- apps/src/openni_tracking.cpp | 19 +- apps/src/openni_uniform_sampling.cpp | 4 +- apps/src/openni_voxel_grid.cpp | 4 +- apps/src/organized_segmentation_demo.cpp | 16 +- apps/src/pcd_organized_edge_detection.cpp | 2 +- ...pcd_organized_multi_plane_segmentation.cpp | 21 +- apps/src/pcd_select_object_plane.cpp | 5 +- .../src/pcd_video_player/pcd_video_player.cpp | 4 +- apps/src/ppf_object_recognition.cpp | 6 +- apps/src/pyramid_surface_matching.cpp | 6 +- apps/src/render_views_tesselated_sphere.cpp | 23 +- apps/src/stereo_ground_segmentation.cpp | 51 +- apps/src/surfel_smoothing_test.cpp | 1 - 215 files changed, 7654 insertions(+), 7361 deletions(-) create mode 100644 apps/in_hand_scanner/include/pcl/apps/in_hand_scanner/boost.h create mode 100644 apps/in_hand_scanner/include/pcl/apps/in_hand_scanner/eigen.h mode change 100644 => 100755 apps/modeler/src/parameter_dialog.cpp mode change 100644 => 100755 apps/src/stereo_ground_segmentation.cpp diff --git a/apps/3d_rec_framework/CMakeLists.txt b/apps/3d_rec_framework/CMakeLists.txt index a75d17047a1..57015b61634 100644 --- a/apps/3d_rec_framework/CMakeLists.txt +++ b/apps/3d_rec_framework/CMakeLists.txt @@ -16,6 +16,8 @@ if(NOT build) return() endif() +include_directories("${CMAKE_CURRENT_BINARY_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}/include") + set(incs_fw "include/pcl/${SUBSYS_NAME}/${SUBSUBSYS_NAME}/feature_wrapper/normal_estimator.h" ) @@ -89,7 +91,7 @@ PCL_ADD_INCLUDES("${SUBSUBSYS_NAME}" "${SUBSYS_NAME}/${SUBSUBSYS_NAME}/pipeline/ set(LIB_NAME "pcl_${SUBSUBSYS_NAME}") PCL_ADD_LIBRARY(${LIB_NAME} COMPONENT ${SUBSUBSYS_NAME} SOURCES ${srcs} ${impl_incs_pipeline} ${incs_utils} ${incs_fw} ${incs_fw_global} ${incs_fw_local} ${incc_tools_framework} ${incs_pipelines} ${incs_pc_source}) -target_link_libraries("${LIB_NAME}" pcl_apps pcl_common pcl_io pcl_filters pcl_keypoints pcl_recognition pcl_visualization pcl_segmentation pcl_surface pcl_features pcl_sample_consensus pcl_search pcl_registration) +target_link_libraries("${LIB_NAME}" pcl_apps pcl_common pcl_io pcl_filters pcl_visualization pcl_segmentation pcl_surface pcl_features pcl_sample_consensus pcl_search pcl_registration) if(WITH_OPENNI) target_link_libraries("${LIB_NAME}" ${OPENNI_LIBRARIES}) diff --git a/apps/3d_rec_framework/include/pcl/apps/3d_rec_framework/feature_wrapper/local/local_estimator.h b/apps/3d_rec_framework/include/pcl/apps/3d_rec_framework/feature_wrapper/local/local_estimator.h index 7a92ebbee43..e777aeab1c6 100644 --- a/apps/3d_rec_framework/include/pcl/apps/3d_rec_framework/feature_wrapper/local/local_estimator.h +++ b/apps/3d_rec_framework/include/pcl/apps/3d_rec_framework/feature_wrapper/local/local_estimator.h @@ -12,7 +12,6 @@ #include #include #include -#include #include #include @@ -87,8 +86,11 @@ class UniformSamplingExtractor : public KeypointExtractor { pcl::PointCloud filtered_keypoints; // create a search object typename pcl::search::Search::Ptr tree; - tree.reset(pcl::search::autoSelectMethod( - input, false, pcl::search::Purpose::radius_search)); + if (input->isOrganized()) + tree.reset(new pcl::search::OrganizedNeighbor()); + else + tree.reset(new pcl::search::KdTree(false)); + tree->setInputCloud(input); neighborhood_indices_.reset(new std::vector); neighborhood_indices_->resize(keypoints_cloud->size()); diff --git a/apps/3d_rec_framework/include/pcl/apps/3d_rec_framework/feature_wrapper/normal_estimator.h b/apps/3d_rec_framework/include/pcl/apps/3d_rec_framework/feature_wrapper/normal_estimator.h index bd21f8cc34b..64ec3e95abe 100644 --- a/apps/3d_rec_framework/include/pcl/apps/3d_rec_framework/feature_wrapper/normal_estimator.h +++ b/apps/3d_rec_framework/include/pcl/apps/3d_rec_framework/feature_wrapper/normal_estimator.h @@ -12,9 +12,8 @@ #include #include #include -#include // for KdTree -#include // for pcl::make_shared -#include // for pcl::index_t +#include // for pcl::make_shared +#include // for pcl::index_t namespace pcl { namespace rec_3d_framework { diff --git a/apps/3d_rec_framework/include/pcl/apps/3d_rec_framework/pc_source/source.h b/apps/3d_rec_framework/include/pcl/apps/3d_rec_framework/pc_source/source.h index 8e475f6f4bc..e2a14ac7e48 100644 --- a/apps/3d_rec_framework/include/pcl/apps/3d_rec_framework/pc_source/source.h +++ b/apps/3d_rec_framework/include/pcl/apps/3d_rec_framework/pc_source/source.h @@ -51,7 +51,8 @@ class Model { if (resolution <= 0) return assembled_; - auto it = voxelized_assembled_.find(resolution); + typename std::map::iterator it = + voxelized_assembled_.find(resolution); if (it == voxelized_assembled_.end()) { PointTPtr voxelized(new pcl::PointCloud); pcl::VoxelGrid grid_; diff --git a/apps/3d_rec_framework/include/pcl/apps/3d_rec_framework/pipeline/impl/global_nn_recognizer_crh.hpp b/apps/3d_rec_framework/include/pcl/apps/3d_rec_framework/pipeline/impl/global_nn_recognizer_crh.hpp index 4dad194506e..af7ab87d642 100644 --- a/apps/3d_rec_framework/include/pcl/apps/3d_rec_framework/pipeline/impl/global_nn_recognizer_crh.hpp +++ b/apps/3d_rec_framework/include/pcl/apps/3d_rec_framework/pipeline/impl/global_nn_recognizer_crh.hpp @@ -22,7 +22,11 @@ pcl::rec_3d_framework::GlobalNNCRHRecognizer::getP using mv_pair = std::pair; mv_pair pair_model_view = std::make_pair(model.id_, view_id); - auto it = poses_cache_.find(pair_model_view); + std::map, + Eigen::aligned_allocator>>:: + iterator it = poses_cache_.find(pair_model_view); if (it != poses_cache_.end()) { pose_matrix = it->second; diff --git a/apps/3d_rec_framework/include/pcl/apps/3d_rec_framework/pipeline/impl/global_nn_recognizer_cvfh.hpp b/apps/3d_rec_framework/include/pcl/apps/3d_rec_framework/pipeline/impl/global_nn_recognizer_cvfh.hpp index 08d17d7caaf..6a583006cd7 100644 --- a/apps/3d_rec_framework/include/pcl/apps/3d_rec_framework/pipeline/impl/global_nn_recognizer_cvfh.hpp +++ b/apps/3d_rec_framework/include/pcl/apps/3d_rec_framework/pipeline/impl/global_nn_recognizer_cvfh.hpp @@ -22,7 +22,11 @@ pcl::rec_3d_framework::GlobalNNCVFHRecognizer::get using mv_pair = std::pair; mv_pair pair_model_view = std::make_pair(model.id_, view_id); - auto it = poses_cache_.find(pair_model_view); + std::map, + Eigen::aligned_allocator>>:: + iterator it = poses_cache_.find(pair_model_view); if (it != poses_cache_.end()) { pose_matrix = it->second; diff --git a/apps/3d_rec_framework/include/pcl/apps/3d_rec_framework/pipeline/impl/local_recognizer.hpp b/apps/3d_rec_framework/include/pcl/apps/3d_rec_framework/pipeline/impl/local_recognizer.hpp index 44e1277d3f8..1bf8388f7fe 100644 --- a/apps/3d_rec_framework/include/pcl/apps/3d_rec_framework/pipeline/impl/local_recognizer.hpp +++ b/apps/3d_rec_framework/include/pcl/apps/3d_rec_framework/pipeline/impl/local_recognizer.hpp @@ -460,7 +460,11 @@ pcl::rec_3d_framework::LocalRecognitionPipeline::g using mv_pair = std::pair; mv_pair pair_model_view = std::make_pair(model.id_, view_id); - auto it = poses_cache_.find(pair_model_view); + std::map, + Eigen::aligned_allocator>>:: + iterator it = poses_cache_.find(pair_model_view); if (it != poses_cache_.end()) { pose_matrix = it->second; @@ -485,7 +489,8 @@ pcl::rec_3d_framework::LocalRecognitionPipeline:: if (use_cache_) { std::pair pair_model_view = std::make_pair(model.id_, view_id); - auto it = keypoints_cache_.find(pair_model_view); + typename std::map, PointInTPtr>::iterator it = + keypoints_cache_.find(pair_model_view); if (it != keypoints_cache_.end()) { keypoints_cloud = it->second; diff --git a/apps/3d_rec_framework/include/pcl/apps/3d_rec_framework/pipeline/local_recognizer.h b/apps/3d_rec_framework/include/pcl/apps/3d_rec_framework/pipeline/local_recognizer.h index 0932cd70e6d..8aece90423d 100644 --- a/apps/3d_rec_framework/include/pcl/apps/3d_rec_framework/pipeline/local_recognizer.h +++ b/apps/3d_rec_framework/include/pcl/apps/3d_rec_framework/pipeline/local_recognizer.h @@ -195,7 +195,7 @@ class PCL_EXPORTS LocalRecognitionPipeline { } public: - LocalRecognitionPipeline() : + LocalRecognitionPipeline() : search_model_("") { use_cache_ = false; threshold_accept_model_hypothesis_ = 0.2f; diff --git a/apps/3d_rec_framework/include/pcl/apps/3d_rec_framework/tools/openni_frame_source.h b/apps/3d_rec_framework/include/pcl/apps/3d_rec_framework/tools/openni_frame_source.h index b78cbea047b..1fe6f4aacfb 100644 --- a/apps/3d_rec_framework/include/pcl/apps/3d_rec_framework/tools/openni_frame_source.h +++ b/apps/3d_rec_framework/include/pcl/apps/3d_rec_framework/tools/openni_frame_source.h @@ -31,9 +31,9 @@ class PCL_EXPORTS OpenNIFrameSource { pcl::OpenNIGrabber grabber_; PointCloudPtr most_recent_frame_; - int frame_counter_{0}; + int frame_counter_; std::mutex mutex_; - bool active_{true}; + bool active_; }; } // namespace OpenNIFrameSource diff --git a/apps/3d_rec_framework/include/pcl/apps/3d_rec_framework/utils/persistence_utils.h b/apps/3d_rec_framework/include/pcl/apps/3d_rec_framework/utils/persistence_utils.h index fcaba10419f..528a7daf4a8 100644 --- a/apps/3d_rec_framework/include/pcl/apps/3d_rec_framework/utils/persistence_utils.h +++ b/apps/3d_rec_framework/include/pcl/apps/3d_rec_framework/utils/persistence_utils.h @@ -54,7 +54,7 @@ writeMatrixToFile(const std::string& file, Eigen::Matrix4f& matrix) for (std::size_t i = 0; i < 4; i++) { for (std::size_t j = 0; j < 4; j++) { out << matrix(i, j); - if (i != 3 || j != 3) + if (!(i == 3 && j == 3)) out << " "; } } diff --git a/apps/3d_rec_framework/src/tools/local_recognition_mian_dataset.cpp b/apps/3d_rec_framework/src/tools/local_recognition_mian_dataset.cpp index f6ab05df515..220952347f4 100644 --- a/apps/3d_rec_framework/src/tools/local_recognition_mian_dataset.cpp +++ b/apps/3d_rec_framework/src/tools/local_recognition_mian_dataset.cpp @@ -102,7 +102,7 @@ recognizeAndVisualize( for (std::size_t i = 0; i < files.size(); i++) { std::cout << files[i] << std::endl; if (scene != -1) - if (static_cast(scene) != i) + if ((std::size_t)scene != i) continue; const std::string file = ply_files_dir.string() + files[i]; diff --git a/apps/3d_rec_framework/src/tools/openni_frame_source.cpp b/apps/3d_rec_framework/src/tools/openni_frame_source.cpp index b612bb218d7..1d0645dd3a5 100644 --- a/apps/3d_rec_framework/src/tools/openni_frame_source.cpp +++ b/apps/3d_rec_framework/src/tools/openni_frame_source.cpp @@ -5,7 +5,7 @@ namespace OpenNIFrameSource { OpenNIFrameSource::OpenNIFrameSource(const std::string& device_id) -: grabber_(device_id), +: grabber_(device_id), frame_counter_(0), active_(true) { std::function frame_cb = [this](const PointCloudConstPtr& cloud) { onNewFrame(cloud); }; diff --git a/apps/CMakeLists.txt b/apps/CMakeLists.txt index ff551b13bb8..b501bac85c5 100644 --- a/apps/CMakeLists.txt +++ b/apps/CMakeLists.txt @@ -15,40 +15,16 @@ set(CMAKE_AUTOMOC ON) set(CMAKE_AUTORCC ON) set(CMAKE_AUTOUIC ON) -list(APPEND CMAKE_AUTOUIC_SEARCH_PATHS "src") - -if(VTK_FOUND) - set(incs "include/pcl/${SUBSYS_NAME}/render_views_tesselated_sphere.h") - set(srcs "src/render_views_tesselated_sphere.cpp") -endif() - -if(QHULL_FOUND) - set(incs - "include/pcl/${SUBSYS_NAME}/dominant_plane_segmentation.h" - "include/pcl/${SUBSYS_NAME}/timer.h" - ${incs} - ) - set(impl_incs "include/pcl/${SUBSYS_NAME}/impl/dominant_plane_segmentation.hpp") - set(srcs "src/dominant_plane_segmentation.cpp" ${srcs}) -endif() - -set(LIB_NAME "pcl_${SUBSYS_NAME}") -PCL_ADD_LIBRARY(${LIB_NAME} COMPONENT ${SUBSYS_NAME} SOURCES ${srcs} ${impl_incs} ${incs}) -target_link_libraries("${LIB_NAME}" pcl_common pcl_io pcl_filters pcl_visualization pcl_segmentation pcl_surface pcl_features pcl_sample_consensus pcl_search) -PCL_MAKE_PKGCONFIG(${LIB_NAME} COMPONENT ${SUBSYS_NAME} DESC ${SUBSYS_DESC}) -# Install include files -PCL_ADD_INCLUDES("${SUBSYS_NAME}" "${SUBSYS_NAME}" ${incs}) -PCL_ADD_INCLUDES("${SUBSYS_NAME}" "${SUBSYS_NAME}/impl" ${impl_incs}) - # to be filled with all targets the apps subsystem set(PCL_APPS_ALL_TARGETS) +include_directories("${CMAKE_CURRENT_BINARY_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}/include") + PCL_ADD_EXECUTABLE(pcl_test_search_speed COMPONENT ${SUBSYS_NAME} SOURCES src/test_search.cpp) target_link_libraries(pcl_test_search_speed pcl_common pcl_io pcl_search pcl_kdtree pcl_visualization) PCL_ADD_EXECUTABLE(pcl_nn_classification_example COMPONENT ${SUBSYS_NAME} SOURCES src/nn_classification_example.cpp) target_link_libraries(pcl_nn_classification_example pcl_common pcl_io pcl_features pcl_kdtree) -target_include_directories(pcl_nn_classification_example PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include) PCL_ADD_EXECUTABLE(pcl_pyramid_surface_matching COMPONENT ${SUBSYS_NAME} SOURCES src/pyramid_surface_matching.cpp) target_link_libraries(pcl_pyramid_surface_matching pcl_common pcl_io pcl_features pcl_registration pcl_filters) @@ -62,6 +38,9 @@ if(LIBUSB_FOUND) endif() if(VTK_FOUND) + set(incs "include/pcl/${SUBSYS_NAME}/render_views_tesselated_sphere.h") + set(srcs "src/render_views_tesselated_sphere.cpp") + PCL_ADD_EXECUTABLE(pcl_ppf_object_recognition COMPONENT ${SUBSYS_NAME} SOURCES src/ppf_object_recognition.cpp) target_link_libraries(pcl_ppf_object_recognition pcl_common pcl_io pcl_filters pcl_features pcl_registration pcl_visualization pcl_sample_consensus pcl_segmentation) @@ -91,9 +70,8 @@ if(VTK_FOUND) PCL_ADD_EXECUTABLE(pcl_face_trainer COMPONENT ${SUBSYS_NAME} SOURCES src/face_detection/face_trainer.cpp) target_link_libraries(pcl_face_trainer pcl_features pcl_recognition pcl_common pcl_io pcl_filters pcl_visualization pcl_segmentation pcl_sample_consensus pcl_surface pcl_keypoints pcl_ml pcl_search pcl_kdtree) - PCL_ADD_EXECUTABLE(pcl_fs_face_detector COMPONENT ${SUBSYS_NAME} SOURCES src/face_detection/filesystem_face_detection.cpp BUNDLE) + PCL_ADD_EXECUTABLE(pcl_fs_face_detector COMPONENT ${SUBSYS_NAME} SOURCES src/face_detection//filesystem_face_detection.cpp BUNDLE) target_link_libraries(pcl_fs_face_detector pcl_features pcl_recognition pcl_common pcl_io pcl_filters pcl_visualization pcl_segmentation pcl_sample_consensus pcl_surface pcl_keypoints pcl_ml pcl_search pcl_kdtree) - target_include_directories(pcl_fs_face_detector PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include) PCL_ADD_EXECUTABLE(pcl_stereo_ground_segmentation COMPONENT ${SUBSYS_NAME} SOURCES src/stereo_ground_segmentation.cpp) target_link_libraries(pcl_stereo_ground_segmentation pcl_common pcl_io pcl_filters pcl_visualization pcl_segmentation pcl_features pcl_stereo) @@ -113,7 +91,6 @@ if(VTK_FOUND) BUNDLE) target_link_libraries(pcl_manual_registration pcl_common pcl_io pcl_visualization pcl_segmentation pcl_features pcl_surface pcl_registration ${QTX}::Widgets) - target_include_directories(pcl_manual_registration PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include) PCL_ADD_EXECUTABLE(pcl_pcd_video_player COMPONENT @@ -124,8 +101,7 @@ if(VTK_FOUND) src/pcd_video_player/pcd_video_player.ui BUNDLE) - target_link_libraries(pcl_pcd_video_player pcl_common pcl_io pcl_registration pcl_visualization pcl_segmentation pcl_features pcl_surface ${QTX}::Widgets) - target_include_directories(pcl_pcd_video_player PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include) + target_link_libraries(pcl_pcd_video_player pcl_common pcl_io pcl_visualization pcl_segmentation pcl_features pcl_surface ${QTX}::Widgets) endif() if(WITH_OPENNI) @@ -178,7 +154,6 @@ if(VTK_FOUND) PCL_ADD_EXECUTABLE(pcl_openni_face_detector COMPONENT ${SUBSYS_NAME} SOURCES src/face_detection//openni_face_detection.cpp src/face_detection//openni_frame_source.cpp BUNDLE) target_link_libraries(pcl_openni_face_detector pcl_features pcl_recognition pcl_common pcl_io pcl_filters pcl_visualization pcl_segmentation pcl_sample_consensus pcl_surface pcl_keypoints pcl_ml pcl_search pcl_kdtree) - target_include_directories(pcl_openni_face_detector PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include) if(QT_FOUND AND HAVE_QVTK) # OpenNI Passthrough application demo @@ -186,13 +161,13 @@ if(VTK_FOUND) COMPONENT ${SUBSYS_NAME} SOURCES - include/pcl/apps/openni_passthrough_qt.h include/pcl/apps/openni_passthrough.h src/openni_passthrough.cpp src/openni_passthrough.ui) target_link_libraries(pcl_openni_passthrough pcl_common pcl_io pcl_filters pcl_visualization ${QTX}::Widgets) - target_include_directories(pcl_openni_passthrough PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include) + + list(APPEND CMAKE_AUTOUIC_SEARCH_PATHS "src") # OpenNI Organized Connected Component application demo PCL_ADD_EXECUTABLE(pcl_organized_segmentation_demo @@ -205,51 +180,48 @@ if(VTK_FOUND) src/organized_segmentation_demo.ui BUNDLE) target_link_libraries(pcl_organized_segmentation_demo pcl_common pcl_io pcl_visualization pcl_segmentation pcl_features pcl_surface ${QTX}::Widgets) - target_include_directories(pcl_organized_segmentation_demo PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include) endif() if(QHULL_FOUND) - PCL_ADD_EXECUTABLE(pcl_openni_3d_convex_hull COMPONENT ${SUBSYS_NAME} SOURCES src/openni_3d_convex_hull.cpp BUNDLE) - target_link_libraries(pcl_openni_3d_convex_hull pcl_common pcl_io pcl_filters pcl_visualization pcl_segmentation pcl_sample_consensus pcl_features pcl_surface) - - PCL_ADD_EXECUTABLE(pcl_openni_3d_concave_hull COMPONENT ${SUBSYS_NAME} SOURCES src/openni_3d_concave_hull.cpp BUNDLE) - target_link_libraries(pcl_openni_3d_concave_hull pcl_common pcl_io pcl_filters pcl_visualization pcl_segmentation pcl_sample_consensus pcl_features pcl_surface) - - PCL_ADD_EXECUTABLE(pcl_openni_tracking COMPONENT ${SUBSYS_NAME} SOURCES src/openni_tracking.cpp BUNDLE) - target_link_libraries(pcl_openni_tracking pcl_common pcl_io pcl_surface pcl_visualization pcl_filters pcl_features pcl_segmentation pcl_tracking pcl_search) - - PCL_ADD_EXECUTABLE(pcl_openni_planar_convex_hull COMPONENT ${SUBSYS_NAME} SOURCES src/openni_planar_convex_hull.cpp BUNDLE) - target_link_libraries(pcl_openni_planar_convex_hull pcl_common pcl_io pcl_filters pcl_visualization pcl_segmentation pcl_sample_consensus pcl_surface) - - PCL_ADD_EXECUTABLE(pcl_ni_linemod COMPONENT ${SUBSYS_NAME} SOURCES src/ni_linemod.cpp BUNDLE) - target_link_libraries(pcl_ni_linemod pcl_common pcl_io pcl_filters pcl_visualization pcl_segmentation pcl_sample_consensus pcl_features pcl_surface pcl_search) - target_include_directories(pcl_ni_linemod PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include) + PCL_ADD_EXECUTABLE(pcl_openni_3d_convex_hull COMPONENT ${SUBSYS_NAME} SOURCES src/openni_3d_convex_hull.cpp BUNDLE) + target_link_libraries(pcl_openni_3d_convex_hull pcl_common pcl_io pcl_filters pcl_visualization pcl_segmentation pcl_sample_consensus pcl_features pcl_surface) + + PCL_ADD_EXECUTABLE(pcl_openni_3d_concave_hull COMPONENT ${SUBSYS_NAME} SOURCES src/openni_3d_concave_hull.cpp BUNDLE) + target_link_libraries(pcl_openni_3d_concave_hull pcl_common pcl_io pcl_filters pcl_visualization pcl_segmentation pcl_sample_consensus pcl_features pcl_surface) + + PCL_ADD_EXECUTABLE(pcl_openni_tracking COMPONENT ${SUBSYS_NAME} SOURCES src/openni_tracking.cpp BUNDLE) + target_link_libraries(pcl_openni_tracking pcl_common pcl_io pcl_surface pcl_visualization pcl_filters pcl_features pcl_segmentation pcl_tracking pcl_search) + + PCL_ADD_EXECUTABLE(pcl_openni_planar_convex_hull COMPONENT ${SUBSYS_NAME} SOURCES src/openni_planar_convex_hull.cpp BUNDLE) + target_link_libraries(pcl_openni_planar_convex_hull pcl_common pcl_io pcl_filters pcl_visualization pcl_segmentation pcl_sample_consensus pcl_surface) + + PCL_ADD_EXECUTABLE(pcl_ni_linemod COMPONENT ${SUBSYS_NAME} SOURCES src/ni_linemod.cpp BUNDLE) + target_link_libraries(pcl_ni_linemod pcl_common pcl_io pcl_filters pcl_visualization pcl_segmentation pcl_sample_consensus pcl_features pcl_surface pcl_search) endif() # QHULL_FOUND PCL_ADD_EXECUTABLE(pcl_ni_agast COMPONENT ${SUBSYS_NAME} SOURCES src/ni_agast.cpp BUNDLE) target_link_libraries(pcl_ni_agast pcl_common pcl_io pcl_filters pcl_visualization pcl_segmentation pcl_sample_consensus pcl_features pcl_keypoints pcl_surface pcl_search) - target_include_directories(pcl_ni_agast PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include) PCL_ADD_EXECUTABLE(pcl_ni_brisk COMPONENT ${SUBSYS_NAME} SOURCES src/ni_brisk.cpp BUNDLE) target_link_libraries(pcl_ni_brisk pcl_common pcl_io pcl_filters pcl_visualization pcl_segmentation pcl_sample_consensus pcl_features pcl_keypoints pcl_surface pcl_search) - target_include_directories(pcl_ni_brisk PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include) PCL_ADD_EXECUTABLE(pcl_ni_susan COMPONENT ${SUBSYS_NAME} SOURCES src/ni_susan.cpp BUNDLE) target_link_libraries(pcl_ni_susan pcl_common pcl_visualization pcl_features pcl_keypoints pcl_search) - target_include_directories(pcl_ni_susan PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include) PCL_ADD_EXECUTABLE(pcl_ni_trajkovic COMPONENT ${SUBSYS_NAME} SOURCES src/ni_trajkovic.cpp BUNDLE) target_link_libraries(pcl_ni_trajkovic pcl_common pcl_visualization pcl_features pcl_keypoints pcl_search) - target_include_directories(pcl_ni_trajkovic PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include) PCL_ADD_EXECUTABLE(pcl_openni_klt COMPONENT ${SUBSYS_NAME} SOURCES src/openni_klt.cpp BUNDLE) - target_link_libraries(pcl_openni_klt pcl_common pcl_io pcl_keypoints pcl_visualization pcl_tracking) + target_link_libraries(pcl_openni_klt pcl_common pcl_io pcl_visualization pcl_tracking) endif() # WITH_OPENNI endif() # VTK_FOUND # OpenGL and GLUT if(OPENGL_FOUND AND GLUT_FOUND) + if(NOT WIN32) + include_directories(SYSTEM "${OPENGL_INCLUDE_DIR}") + endif() PCL_ADD_EXECUTABLE(pcl_grabcut_2d COMPONENT ${SUBSYS_NAME} SOURCES src/grabcut_2d.cpp BUNDLE) if(APPLE) set(_glut_target ${GLUT_glut_LIBRARY}) @@ -264,9 +236,27 @@ set(PCL_APPS_MODULES_NAMES_UNSORTED ${PCL_APPS_MODULES_NAMES}) topological_sort(PCL_APPS_MODULES_NAMES PCL_APPS_ _DEPENDS) sort_relative(PCL_APPS_MODULES_NAMES_UNSORTED PCL_APPS_MODULES_NAMES PCL_APPS_MODULES_DIRS) foreach(subdir ${PCL_APPS_MODULES_DIRS}) - add_subdirectory("${CMAKE_CURRENT_SOURCE_DIR}/${subdir}") +add_subdirectory("${CMAKE_CURRENT_SOURCE_DIR}/${subdir}") endforeach() +if(QHULL_FOUND) + set(incs + "include/pcl/${SUBSYS_NAME}/dominant_plane_segmentation.h" + "include/pcl/${SUBSYS_NAME}/timer.h" + ${incs} + ) + set(impl_incs "include/pcl/${SUBSYS_NAME}/impl/dominant_plane_segmentation.hpp") + set(srcs "src/dominant_plane_segmentation.cpp" ${srcs}) +endif() + +set(LIB_NAME "pcl_${SUBSYS_NAME}") +PCL_ADD_LIBRARY(${LIB_NAME} COMPONENT ${SUBSYS_NAME} SOURCES ${srcs} ${impl_incs} ${incs}) +target_link_libraries("${LIB_NAME}" pcl_common pcl_io pcl_filters pcl_visualization pcl_segmentation pcl_surface pcl_features pcl_sample_consensus pcl_search) +PCL_MAKE_PKGCONFIG(${LIB_NAME} COMPONENT ${SUBSYS_NAME} DESC ${SUBSYS_DESC}) +# Install include files +PCL_ADD_INCLUDES("${SUBSYS_NAME}" "${SUBSYS_NAME}" ${incs}) +PCL_ADD_INCLUDES("${SUBSYS_NAME}" "${SUBSYS_NAME}/impl" ${impl_incs}) + if(CMAKE_GENERATOR_IS_IDE) set(SUBSYS_TARGET_NAME APPS_BUILD) else() diff --git a/apps/cloud_composer/CMakeLists.txt b/apps/cloud_composer/CMakeLists.txt index 47668e169a4..3e2629fa1c8 100644 --- a/apps/cloud_composer/CMakeLists.txt +++ b/apps/cloud_composer/CMakeLists.txt @@ -5,7 +5,7 @@ set(SUBSUBSYS_NAME cloud_composer) set(SUBSUBSYS_DESC "Cloud Composer - Application for Manipulating Point Clouds") -set(SUBSUBSYS_DEPS common io visualization features filters apps) +set(SUBSUBSYS_DEPS common io visualization filters apps) set(SUBSUBSYS_EXT_DEPS vtk ${QTX}) set(REASON "") set(DEFAULT OFF) @@ -28,6 +28,8 @@ if(NOT build) return() endif() +include_directories("${CMAKE_CURRENT_BINARY_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}/include") + #Create subdirectory for plugin libs set(CLOUD_COMPOSER_PLUGIN_DIR "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/cloud_composer_plugins") make_directory("${CLOUD_COMPOSER_PLUGIN_DIR}") @@ -71,7 +73,7 @@ set(PCL_LIB_TYPE STATIC) PCL_ADD_LIBRARY(pcl_cc_tool_interface COMPONENT ${SUBSUBSYS_NAME} SOURCES ${INTERFACE_HEADERS} ${INTERFACE_SOURCES}) -target_link_libraries(pcl_cc_tool_interface pcl_common pcl_features pcl_filters pcl_search pcl_visualization ${QTX}::Widgets) +target_link_libraries(pcl_cc_tool_interface pcl_common pcl_filters pcl_search pcl_visualization ${QTX}::Widgets) set(PCL_LIB_TYPE ${PCL_LIB_TYPE_ORIGIN}) diff --git a/apps/cloud_composer/include/pcl/apps/cloud_composer/cloud_browser.h b/apps/cloud_composer/include/pcl/apps/cloud_composer/cloud_browser.h index 973ca0015e1..c5e8c7d691b 100644 --- a/apps/cloud_composer/include/pcl/apps/cloud_composer/cloud_browser.h +++ b/apps/cloud_composer/include/pcl/apps/cloud_composer/cloud_browser.h @@ -42,35 +42,40 @@ class QItemSelectionModel; -namespace pcl { -namespace cloud_composer { -/** \brief View class for displaying project composition - * \author Jeremie Papon - * \ingroup cloud_composer - */ -class ProjectModel; -class CloudBrowser : public QTreeView { - Q_OBJECT -public: - CloudBrowser(QWidget* parent = nullptr); - - void - setModel(QAbstractItemModel* new_model) override; - -private: - ProjectModel* current_project_model_; -}; - -class BackgroundDelegate : public QStyledItemDelegate { -public: - explicit BackgroundDelegate(QObject* parent = nullptr) : QStyledItemDelegate(parent) - {} - - void - paint(QPainter* painter, - const QStyleOptionViewItem& option, - const QModelIndex& index) const override; -}; - -} // namespace cloud_composer -} // namespace pcl +namespace pcl +{ + namespace cloud_composer + { + /** \brief View class for displaying project composition + * \author Jeremie Papon + * \ingroup cloud_composer + */ + class ProjectModel; + class CloudBrowser : public QTreeView + { + Q_OBJECT + public: + CloudBrowser (QWidget* parent = nullptr); + + void + setModel (QAbstractItemModel* new_model) override; + + private: + ProjectModel* current_project_model_; + + }; + + class BackgroundDelegate : public QStyledItemDelegate + { + public: + explicit + BackgroundDelegate (QObject *parent = nullptr) + : QStyledItemDelegate(parent) {} + + void + paint (QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override; + + }; + + } +} diff --git a/apps/cloud_composer/include/pcl/apps/cloud_composer/cloud_composer.h b/apps/cloud_composer/include/pcl/apps/cloud_composer/cloud_composer.h index 1da2fb7158a..9fbfdcc5b17 100644 --- a/apps/cloud_composer/include/pcl/apps/cloud_composer/cloud_composer.h +++ b/apps/cloud_composer/include/pcl/apps/cloud_composer/cloud_composer.h @@ -37,7 +37,7 @@ #pragma once -// PCL +//PCL #include #include @@ -45,122 +45,125 @@ class QTreeView; -namespace pcl { -namespace cloud_composer { -class ProjectModel; -class CloudViewer; -class CloudCommand; -class ToolFactory; -class ToolBoxModel; -class SignalMultiplexer; - -/** \brief MainWindow of cloud_composer application - * \author Jeremie Papon - * \ingroup cloud_composer - * The following member objects are defined in the ui file and can be manipulated: - * * cloud_viewer_ is the view which contains the PCLVisualizer & QVTKWidget - * * cloud_browser_ is the tree view in the left dock - * * item_inspector_ is the details view in the left dock - * * tool_box_view_ is the tool box in right dock - * * tool_parameter_view_ shows adjustable parameters for currently selected tool - * * undo_view_ is the undo stack view in the right dock - */ -class ComposerMainWindow : public QMainWindow, private Ui::ComposerMainWindow { - Q_OBJECT -public: - explicit ComposerMainWindow(QWidget* parent = nullptr); - ~ComposerMainWindow(); - -Q_SIGNALS: - /** \brief Signal emitted when the active project is switched - ie a different project - * tab is selected */ - void - activeProjectChanged(ProjectModel* new_model, ProjectModel* previous_model); - - /** \brief This signal tells the current project to insert a cloud using a file dialog - * box */ - void - insertNewCloudFromFile(); - - /** \brief This signal tells the current project to insert a cloud from and RGB and - * Depth image using a file dialog box */ - void - insertNewCloudFromRGBandDepth(); - - /** \brief This signal tells the current project to save currently selected cloud to - * file */ - void - saveSelectedCloudToFile(); - -public Q_SLOTS: - // Slots for File Menu Actions - void on_action_new_project__triggered(/*QString name = "unsaved project"*/); - void - on_action_open_cloud_as_new_project__triggered(); - void - on_action_open_project__triggered(); - void - on_action_save_project__triggered(); - void - on_action_save_project_as__triggered(); - void - on_action_save_selected_cloud__triggered(); - void - on_action_exit__triggered(); - - // Slots for Edit Menu Actions - void - on_action_insert_from_file__triggered(); - void - on_action_insert_from_openNi_source__triggered(); - void - on_action_insert_from_rgb_depth__triggered(); - - void - setCurrentModel(ProjectModel* model); - - void - setMouseStyleAction(interactor_styles::INTERACTOR_STYLES selected_style); - - void - enqueueToolAction(AbstractTool* tool); - -private: - void - connectFileActions(); - void - connectEditActions(); - - void - connectViewActions(); - - void - initializeCloudBrowser(); - void - initializeCloudViewer(); - void - initializeItemInspector(); - - void - initializeToolBox(); - void - initializePlugins(); - - /** \brief Pointer to the model which is currently being viewed */ - ProjectModel* current_model_; - QItemSelectionModel* current_selection_model_; - - QMap name_model_map_; - - QUndoGroup* undo_group_; - - QItemSelectionModel* tool_selection_model_; - ToolBoxModel* tool_box_model_; - - SignalMultiplexer* multiplexer_; - - QActionGroup* mouse_style_group_; -}; - -} // namespace cloud_composer -} // namespace pcl +namespace pcl +{ + namespace cloud_composer + { + class ProjectModel; + class CloudViewer; + class CloudCommand; + class ToolFactory; + class ToolBoxModel; + class SignalMultiplexer; + + /** \brief MainWindow of cloud_composer application + * \author Jeremie Papon + * \ingroup cloud_composer + * The following member objects are defined in the ui file and can be manipulated: + * * cloud_viewer_ is the view which contains the PCLVisualizer & QVTKWidget + * * cloud_browser_ is the tree view in the left dock + * * item_inspector_ is the details view in the left dock + * * tool_box_view_ is the tool box in right dock + * * tool_parameter_view_ shows adjustable parameters for currently selected tool + * * undo_view_ is the undo stack view in the right dock + */ + class ComposerMainWindow : public QMainWindow, private Ui::ComposerMainWindow + { + Q_OBJECT + public: + explicit ComposerMainWindow (QWidget *parent = nullptr); + ~ComposerMainWindow (); + + Q_SIGNALS: + /** \brief Signal emitted when the active project is switched - ie a different project tab is selected */ + void + activeProjectChanged (ProjectModel* new_model, ProjectModel* previous_model); + + /** \brief This signal tells the current project to insert a cloud using a file dialog box */ + void + insertNewCloudFromFile (); + + /** \brief This signal tells the current project to insert a cloud from and RGB and Depth image using a file dialog box */ + void + insertNewCloudFromRGBandDepth (); + + /** \brief This signal tells the current project to save currently selected cloud to file */ + void + saveSelectedCloudToFile (); + + public Q_SLOTS: + //Slots for File Menu Actions + void + on_action_new_project__triggered (/*QString name = "unsaved project"*/); + void + on_action_open_cloud_as_new_project__triggered (); + void + on_action_open_project__triggered (); + void + on_action_save_project__triggered (); + void + on_action_save_project_as__triggered (); + void + on_action_save_selected_cloud__triggered (); + void + on_action_exit__triggered (); + + //Slots for Edit Menu Actions + void + on_action_insert_from_file__triggered (); + void + on_action_insert_from_openNi_source__triggered (); + void + on_action_insert_from_rgb_depth__triggered (); + + + + void + setCurrentModel (ProjectModel* model); + + void + setMouseStyleAction (interactor_styles::INTERACTOR_STYLES selected_style); + + void + enqueueToolAction (AbstractTool* tool); + + private: + void + connectFileActions (); + void + connectEditActions (); + + void + connectViewActions (); + + void + initializeCloudBrowser (); + void + initializeCloudViewer (); + void + initializeItemInspector (); + + void + initializeToolBox (); + void + initializePlugins (); + + + /** \brief Pointer to the model which is currently being viewed */ + ProjectModel* current_model_; + QItemSelectionModel* current_selection_model_; + + QMap name_model_map_; + + QUndoGroup *undo_group_; + + QItemSelectionModel* tool_selection_model_; + ToolBoxModel* tool_box_model_; + + SignalMultiplexer* multiplexer_; + + QActionGroup* mouse_style_group_; + }; + + } +} diff --git a/apps/cloud_composer/include/pcl/apps/cloud_composer/cloud_view.h b/apps/cloud_composer/include/pcl/apps/cloud_composer/cloud_view.h index 09723d2beff..27780fa5ebf 100644 --- a/apps/cloud_composer/include/pcl/apps/cloud_composer/cloud_view.h +++ b/apps/cloud_composer/include/pcl/apps/cloud_composer/cloud_view.h @@ -37,138 +37,130 @@ #pragma once -#include +#include + +#include + #include #include +#include -#include -#include -#include -#include #include +#include +#include #include class QItemSelection; class QStandardItem; -namespace pcl { -namespace cloud_composer { -class ProjectModel; -/** \brief View class for displaying ProjectModel data using PCLVisualizer - * \author Jeremie Papon - * \ingroup cloud_composer - */ -class CloudView : public QWidget { - Q_OBJECT - -public: - CloudView(QWidget* parent = nullptr); - CloudView(const CloudView& to_copy); - CloudView(ProjectModel* model, QWidget* parent = nullptr); - - void - setModel(ProjectModel* new_model); - - ProjectModel* - getModel() const - { - return model_; - } - - PCLQVTKWidget* - getQVTK() const - { - return qvtk_; - } - - pcl::visualization::PCLVisualizer::Ptr - getPCLVisualizer() const +namespace pcl +{ + namespace cloud_composer { - return vis_; + class ProjectModel; + /** \brief View class for displaying ProjectModel data using PCLVisualizer + * \author Jeremie Papon + * \ingroup cloud_composer + */ + class CloudView : public QWidget + { + Q_OBJECT + + public: + CloudView (QWidget* parent = nullptr); + CloudView (const CloudView& to_copy); + CloudView (ProjectModel* model, QWidget* parent = nullptr); + + void + setModel (ProjectModel* new_model); + + ProjectModel* + getModel () const { return model_; } + + PCLQVTKWidget* + getQVTK() const { return qvtk_; } + + pcl::visualization::PCLVisualizer::Ptr + getPCLVisualizer () const { return vis_; } + + void + setAxisVisibility (bool visible); + + void + setInteractorStyle (interactor_styles::INTERACTOR_STYLES style); + public Q_SLOTS: + void + refresh (); + + /** \brief Slot called when the item selected in cloud browser changes */ + void + selectedItemChanged (const QItemSelection & selected, const QItemSelection & deselected); + + /** \brief Slot called when the data in model changes */ + void + dataChanged ( const QModelIndex & topLeft, const QModelIndex & bottomRight ); + + protected Q_SLOTS: + /** \brief Slot called when an item in the model changes + * \param topLeft + * \param bottomRight + */ + void + itemChanged (QStandardItem* item); + + /** \brief Slot called when rows inserted to model + * \param start Start of new rows (inclusive) + * \param end End of new rows (inclusive) + */ + void + rowsInserted (const QModelIndex& parent, int start, int end); + + void + rowsAboutToBeRemoved (const QModelIndex& parent, int start, int end); + + void + selectionCompleted (vtkObject* caller, unsigned long event_id, void* client_data, void* call_data); + + void + manipulationCompleted (vtkObject* caller, unsigned long event_id, void* client_data, void* call_data); + + protected: + void + paintEvent (QPaintEvent* event) override; + void + resizeEvent (QResizeEvent* event) override; + // void scrollContentsBy (int dx, int dy); + + + + private: + void + connectSignalsAndSlots (); + + /** \brief Internal function for setting up the style_switch_ */ + void + initializeInteractorSwitch (); + + void + addOrientationMarkerWidgetAxes (); + void + removeOrientationMarkerWidgetAxes (); + + pcl::visualization::PCLVisualizer::Ptr vis_; + ProjectModel* model_; + + PCLQVTKWidget* qvtk_; + + vtkSmartPointer style_switch_; + + vtkSmartPointer axes_widget_; + vtkSmartPointer axes_; + + /** \brief Manages VTK events by connecting them to QT slots */ + vtkSmartPointer connections_; + }; } +} - void - setAxisVisibility(bool visible); - - void - setInteractorStyle(interactor_styles::INTERACTOR_STYLES style); -public Q_SLOTS: - void - refresh(); - - /** \brief Slot called when the item selected in cloud browser changes */ - void - selectedItemChanged(const QItemSelection& selected, const QItemSelection& deselected); - - /** \brief Slot called when the data in model changes */ - void - dataChanged(const QModelIndex& topLeft, const QModelIndex& bottomRight); - -protected Q_SLOTS: - /** \brief Slot called when an item in the model changes - * \param topLeft - * \param bottomRight - */ - void - itemChanged(QStandardItem* item); - - /** \brief Slot called when rows inserted to model - * \param start Start of new rows (inclusive) - * \param end End of new rows (inclusive) - */ - void - rowsInserted(const QModelIndex& parent, int start, int end); - - void - rowsAboutToBeRemoved(const QModelIndex& parent, int start, int end); - - void - selectionCompleted(vtkObject* caller, - unsigned long event_id, - void* client_data, - void* call_data); - - void - manipulationCompleted(vtkObject* caller, - unsigned long event_id, - void* client_data, - void* call_data); - -protected: - void - paintEvent(QPaintEvent* event) override; - void - resizeEvent(QResizeEvent* event) override; - // void scrollContentsBy (int dx, int dy); - -private: - void - connectSignalsAndSlots(); - - /** \brief Internal function for setting up the style_switch_ */ - void - initializeInteractorSwitch(); - - void - addOrientationMarkerWidgetAxes(); - void - removeOrientationMarkerWidgetAxes(); - - pcl::visualization::PCLVisualizer::Ptr vis_; - ProjectModel* model_; - - PCLQVTKWidget* qvtk_; - - vtkSmartPointer style_switch_; - - vtkSmartPointer axes_widget_; - vtkSmartPointer axes_; - - /** \brief Manages VTK events by connecting them to QT slots */ - vtkSmartPointer connections_; -}; -} // namespace cloud_composer -} // namespace pcl - -Q_DECLARE_METATYPE(pcl::cloud_composer::CloudView); +Q_DECLARE_METATYPE (pcl::cloud_composer::CloudView); diff --git a/apps/cloud_composer/include/pcl/apps/cloud_composer/cloud_viewer.h b/apps/cloud_composer/include/pcl/apps/cloud_composer/cloud_viewer.h index 3e6489fc5f2..df10dc1f09f 100644 --- a/apps/cloud_composer/include/pcl/apps/cloud_composer/cloud_viewer.h +++ b/apps/cloud_composer/include/pcl/apps/cloud_composer/cloud_viewer.h @@ -37,44 +37,48 @@ #pragma once -#include -#include -#include - #include -namespace pcl { -namespace cloud_composer { - -/** \brief Tabbed widget for containing CloudView widgets - * \author Jeremie Papon - * \ingroup cloud_composer - */ -class CloudViewer : public QTabWidget { - Q_OBJECT - -public: - CloudViewer(QWidget* parent = nullptr); - ProjectModel* - getModel() const; - -public Q_SLOTS: - void - addModel(ProjectModel* new_model); +#include +#include +#include - void - modelChanged(int index); +namespace pcl +{ + namespace cloud_composer + { + + /** \brief Tabbed widget for containing CloudView widgets + * \author Jeremie Papon + * \ingroup cloud_composer + */ + class CloudViewer : public QTabWidget + { + Q_OBJECT - void - addNewProject(ProjectModel* new_model); + public: + + CloudViewer (QWidget* parent = nullptr); + ProjectModel* getModel () const; -Q_SIGNALS: - void - newModelSelected(ProjectModel* new_model); + public Q_SLOTS: + void + addModel (ProjectModel* new_model); + + void + modelChanged (int index); + + void + addNewProject (ProjectModel* new_model); + + Q_SIGNALS: + void + newModelSelected (ProjectModel *new_model); -private: - pcl::visualization::PCLVisualizer::Ptr vis_; - QMap model_view_map_; -}; -} // namespace cloud_composer -} // namespace pcl + private: + + pcl::visualization::PCLVisualizer::Ptr vis_; + QMap model_view_map_; + }; + } +} diff --git a/apps/cloud_composer/include/pcl/apps/cloud_composer/commands.h b/apps/cloud_composer/include/pcl/apps/cloud_composer/commands.h index 9ef05cde3e8..5186af6a8d3 100644 --- a/apps/cloud_composer/include/pcl/apps/cloud_composer/commands.h +++ b/apps/cloud_composer/include/pcl/apps/cloud_composer/commands.h @@ -41,171 +41,180 @@ #include -namespace pcl { -namespace cloud_composer { -class AbstractTool; -class ProjectModel; -struct OutputPair { - QList input_items_; - QList output_items_; -}; - -class CloudCommand : public QUndoCommand { -public: - CloudCommand(ConstItemList input_data, QUndoCommand* parent = nullptr); - - ~CloudCommand() override; - - virtual bool - runCommand(AbstractTool* tool) = 0; - - void - undo() override = 0; - - void - redo() override = 0; - - // QList - // executeToolOnTemplateCloud (AbstractTool* tool, ConstItemList &input_data); - - void - setProjectModel(ProjectModel* model); - - inline void - setInputData(ConstItemList input_data) - { - original_data_ = std::move(input_data); - } - -protected: - /** \brief Removes the original item(s) from the model and replaces with the - * replacement(s) Replacements are only inserted once, original items must have same - * parent This stores the removed items in removed_items_ - */ - bool - replaceOriginalWithNew(const QList& originals, - const QList& new_items); - - /** \brief This removes new_items from the model and restores originals */ - bool - restoreOriginalRemoveNew(const QList& originals, - const QList& new_items); - - ConstItemList original_data_; - - QMap removed_to_parent_map_; - QList output_data_; - ProjectModel* project_model_; - - /** \brief This determines if we delete original items or not on destruction - * If the command is being deleted because stack is at limit, then we want - * to only delete the originals, since the command is staying for good (new items - * shouldn't be deleted) On the other hand, if we destruct after an undo, then we want - * to delete the new items (but not the originals) - */ - bool last_was_undo_; - - /** \brief This is used to check if a templated version of a tool can be used - * For this to return true, all items must be clouds, and must have the same template - * type - */ - bool - canUseTemplates(ConstItemList& input_data); - - bool can_use_templates_{false}; - int template_type_{-1}; -}; - -class ModifyItemCommand : public CloudCommand { -public: - ModifyItemCommand(ConstItemList input_data, QUndoCommand* parent = nullptr); - - bool - runCommand(AbstractTool* tool) override; - - void - undo() override; - - void - redo() override; - -private: -}; - -class NewItemCloudCommand : public CloudCommand { -public: - NewItemCloudCommand(ConstItemList input_data, QUndoCommand* parent = nullptr); - - bool - runCommand(AbstractTool* tool) override; - - void - undo() override; - - void - redo() override; -}; - -class SplitCloudCommand : public CloudCommand { -public: - SplitCloudCommand(ConstItemList input_data, QUndoCommand* parent = nullptr); - - bool - runCommand(AbstractTool* tool) override; - - void - undo() override; - - void - redo() override; - -private: -}; - -class DeleteItemCommand : public CloudCommand { -public: - DeleteItemCommand(ConstItemList input_data, QUndoCommand* parent = nullptr); - - bool - runCommand(AbstractTool* tool) override; - - void - undo() override; - - void - redo() override; - -private: -}; - -class MergeCloudCommand : public CloudCommand { -public: - /** \brief Construct for a merge command - * \param[in] input_data Input list of CloudItem s from the project model which will - * be merged \param[in] temporary_clouds Input list of CloudItems which - */ - MergeCloudCommand(ConstItemList input_data, QUndoCommand* parent = nullptr); - - bool - runCommand(AbstractTool* tool) override; - - void - undo() override; - - void - redo() override; - - inline void - setSelectedIndicesMap( - const QMap& selected_item_index_map) +namespace pcl +{ + namespace cloud_composer { - selected_item_index_map_ = selected_item_index_map; + class AbstractTool; + class ProjectModel; + struct OutputPair + { + QList input_items_; + QList output_items_; + }; + + + + class CloudCommand : public QUndoCommand + { + public: + CloudCommand (ConstItemList input_data, QUndoCommand* parent = nullptr); + + + ~CloudCommand (); + + virtual bool + runCommand (AbstractTool* tool) = 0; + + void + undo () override = 0; + + void + redo () override = 0; + + //QList + // executeToolOnTemplateCloud (AbstractTool* tool, ConstItemList &input_data); + + void + setProjectModel (ProjectModel* model); + + inline void + setInputData (ConstItemList input_data) + { + original_data_ = std::move(input_data); + } + protected: + /** \brief Removes the original item(s) from the model and replaces with the replacement(s) + * Replacements are only inserted once, original items must have same parent + * This stores the removed items in removed_items_ + */ + bool + replaceOriginalWithNew (const QList & originals, const QList & new_items); + + /** \brief This removes new_items from the model and restores originals */ + bool + restoreOriginalRemoveNew (const QList & originals, const QList & new_items); + + ConstItemList original_data_; + + QMap removed_to_parent_map_; + QList output_data_; + ProjectModel* project_model_; + + /** \brief This determines if we delete original items or not on destruction + * If the command is being deleted because stack is at limit, then we want + * to only delete the originals, since the command is staying for good (new items shouldn't be deleted) + * On the other hand, if we destruct after an undo, then we want to delete the new items (but not the originals) + */ + bool last_was_undo_; + + /** \brief This is used to check if a templated version of a tool can be used + * For this to return true, all items must be clouds, and must have the same template type + */ + bool + canUseTemplates (ConstItemList &input_data); + + bool can_use_templates_; + int template_type_; + }; + + class ModifyItemCommand : public CloudCommand + { + public: + ModifyItemCommand (ConstItemList input_data, QUndoCommand* parent = nullptr); + + bool + runCommand (AbstractTool* tool) override; + + void + undo () override; + + void + redo () override; + private: + + + + }; + + class NewItemCloudCommand : public CloudCommand + { + public: + NewItemCloudCommand (ConstItemList input_data, QUndoCommand* parent = nullptr); + + bool + runCommand (AbstractTool* tool) override; + + void + undo () override; + + void + redo () override; + + }; + + + class SplitCloudCommand : public CloudCommand + { + public: + SplitCloudCommand (ConstItemList input_data, QUndoCommand* parent = nullptr); + + bool + runCommand (AbstractTool* tool) override; + + void + undo () override; + + void + redo () override; + private: + + }; + + class DeleteItemCommand : public CloudCommand + { + public: + DeleteItemCommand (ConstItemList input_data, QUndoCommand* parent = nullptr); + + bool + runCommand (AbstractTool* tool) override; + + void + undo () override; + + void + redo () override; + private: + }; + + class MergeCloudCommand : public CloudCommand + { + public: + /** \brief Construct for a merge command + * \param[in] input_data Input list of CloudItem s from the project model which will be merged + * \param[in] temporary_clouds Input list of CloudItems which + */ + MergeCloudCommand (ConstItemList input_data, QUndoCommand* parent = nullptr); + + bool + runCommand (AbstractTool* tool) override; + + void + undo () override; + + void + redo () override; + + inline void + setSelectedIndicesMap( const QMap & selected_item_index_map) + { + selected_item_index_map_ = selected_item_index_map; + } + + private: + QMap selected_item_index_map_; + }; } +} -private: - QMap selected_item_index_map_; -}; -} // namespace cloud_composer -} // namespace pcl - -Q_DECLARE_METATYPE(ConstItemList); +Q_DECLARE_METATYPE (ConstItemList); diff --git a/apps/cloud_composer/include/pcl/apps/cloud_composer/impl/cloud_item.hpp b/apps/cloud_composer/include/pcl/apps/cloud_composer/impl/cloud_item.hpp index 8ee74eaf3c0..6689967c065 100644 --- a/apps/cloud_composer/include/pcl/apps/cloud_composer/impl/cloud_item.hpp +++ b/apps/cloud_composer/include/pcl/apps/cloud_composer/impl/cloud_item.hpp @@ -1,4 +1,4 @@ -/* + /* * Software License Agreement (BSD License) * * Point Cloud Library (PCL) - www.pointclouds.org @@ -39,48 +39,45 @@ #define IMPL_CLOUD_ITEM_H_ #include -#include -#include // for pcl::make_shared +#include // for pcl::make_shared #include +#include -template -void -pcl::cloud_composer::CloudItem::printNumPoints() const +template void +pcl::cloud_composer::CloudItem::printNumPoints () const { - QVariant variant = this->data(ItemDataRole::CLOUD_TEMPLATED); + QVariant variant = this->data (ItemDataRole::CLOUD_TEMPLATED); typename PointCloud::Ptr cloud; - if (variant.canConvert::Ptr>()) { - cloud = variant.value::Ptr>(); + if ( variant.canConvert ::Ptr> () ) + { + cloud = variant.value ::Ptr> (); } - else { - qWarning() - << "Attempted to cast to template type which does not exist in this item!"; + else + { + qWarning () << "Attempted to cast to template type which does not exist in this item!"; return; } - qDebug() << "CLOUD HAS WIDTH = " << cloud->width; + qDebug () << "CLOUD HAS WIDTH = "<< cloud->width; + } -template -pcl::cloud_composer::CloudItem* -pcl::cloud_composer::CloudItem::createCloudItemFromTemplate( - const QString& name, typename PointCloud::Ptr cloud_ptr) + + +template pcl::cloud_composer::CloudItem* +pcl::cloud_composer::CloudItem::createCloudItemFromTemplate (const QString& name, typename PointCloud::Ptr cloud_ptr) { - pcl::PCLPointCloud2::Ptr cloud_blob = pcl::make_shared(); - toPCLPointCloud2(*cloud_ptr, *cloud_blob); - auto* cloud_item = - new CloudItem(name, cloud_blob, Eigen::Vector4f(), Eigen::Quaternionf(), false); - cloud_item->setData(QVariant::fromValue(cloud_ptr), ItemDataRole::CLOUD_TEMPLATED); - cloud_item->setPointType(); + pcl::PCLPointCloud2::Ptr cloud_blob = pcl::make_shared (); + toPCLPointCloud2 (*cloud_ptr, *cloud_blob); + CloudItem* cloud_item = new CloudItem ( name, cloud_blob, Eigen::Vector4f (), Eigen::Quaternionf (), false); + cloud_item->setData (QVariant::fromValue(cloud_ptr), ItemDataRole::CLOUD_TEMPLATED); + cloud_item->setPointType (); return cloud_item; } -#define PCL_INSTANTIATE_createCloudItemFromTemplate(T) \ - template pcl::cloud_composer::CloudItem* \ - pcl::cloud_composer::CloudItem::createCloudItemFromTemplate( \ - const QString, typename PointCloud::Ptr); -#define PCL_INSTANTIATE_printNumPoints(T) \ - template void pcl::cloud_composer::CloudItem::getNumPoints(); +#define PCL_INSTANTIATE_createCloudItemFromTemplate(T) template pcl::cloud_composer::CloudItem* pcl::cloud_composer::CloudItem::createCloudItemFromTemplate(const QString, typename PointCloud::Ptr); + +#define PCL_INSTANTIATE_printNumPoints(T) template void pcl::cloud_composer::CloudItem::getNumPoints(); #endif diff --git a/apps/cloud_composer/include/pcl/apps/cloud_composer/impl/merge_selection.hpp b/apps/cloud_composer/include/pcl/apps/cloud_composer/impl/merge_selection.hpp index dbc139df5df..9574b738433 100644 --- a/apps/cloud_composer/include/pcl/apps/cloud_composer/impl/merge_selection.hpp +++ b/apps/cloud_composer/include/pcl/apps/cloud_composer/impl/merge_selection.hpp @@ -1,4 +1,4 @@ -/* + /* * Software License Agreement (BSD License) * * Point Cloud Library (PCL) - www.pointclouds.org @@ -38,83 +38,81 @@ #ifndef IMPL_MERGE_SELECTION_H_ #define IMPL_MERGE_SELECTION_H_ -#include #include -#include #include +#include -template -QList -pcl::cloud_composer::MergeSelection::performTemplatedAction( - const QList& input_data) +template QList +pcl::cloud_composer::MergeSelection::performTemplatedAction (const QList & input_data) { - QList output; - - foreach (const CloudComposerItem* input_item, input_data) { - QVariant variant = input_item->data(ItemDataRole::CLOUD_TEMPLATED); - if (!variant.canConvert::Ptr>()) { - qWarning() << "Attempted to cast to template type which does not exist in this " - "item! (input list)"; + QList output; + + foreach (const CloudComposerItem* input_item, input_data) + { + QVariant variant = input_item->data (ItemDataRole::CLOUD_TEMPLATED); + if ( ! variant.canConvert ::Ptr> () ) + { + qWarning () << "Attempted to cast to template type which does not exist in this item! (input list)"; return output; } } - foreach (const CloudItem* input_item, selected_item_index_map_.keys()) { - QVariant variant = input_item->data(ItemDataRole::CLOUD_TEMPLATED); - if (!variant.canConvert::Ptr>()) { - qWarning() << "Attempted to cast to template type which does not exist in this " - "item! (selected list)"; + foreach (const CloudItem* input_item, selected_item_index_map_.keys ()) + { + QVariant variant = input_item->data (ItemDataRole::CLOUD_TEMPLATED); + if ( ! variant.canConvert ::Ptr> () ) + { + qWarning () << "Attempted to cast to template type which does not exist in this item! (selected list)"; return output; } - } + } pcl::ExtractIndices filter; - typename PointCloud::Ptr merged_cloud(new PointCloud); - - foreach (const CloudItem* input_cloud_item, selected_item_index_map_.keys()) { - input_cloud_item->printNumPoints(); - // If this cloud hasn't been completely selected - if (!input_data.contains(input_cloud_item)) { - auto input_cloud = input_cloud_item->data(ItemDataRole::CLOUD_TEMPLATED) - .value::Ptr>(); - qDebug() << "Extracting " - << selected_item_index_map_.value(input_cloud_item)->indices.size() - << " points out of " << input_cloud->width; - filter.setInputCloud(input_cloud); - filter.setIndices(selected_item_index_map_.value(input_cloud_item)); - typename PointCloud::Ptr original_minus_indices(new PointCloud); - filter.setNegative(true); - filter.filter(*original_minus_indices); - filter.setNegative(false); - typename PointCloud::Ptr selected_points(new PointCloud); - filter.filter(*selected_points); - - qDebug() << "Original minus indices is " << original_minus_indices->width; + typename PointCloud::Ptr merged_cloud (new PointCloud); - CloudItem* new_cloud_item = CloudItem::createCloudItemFromTemplate( - input_cloud_item->text(), original_minus_indices); - - output.append(new_cloud_item); + foreach (const CloudItem* input_cloud_item, selected_item_index_map_.keys ()) + { + input_cloud_item->printNumPoints (); + //If this cloud hasn't been completely selected + if (!input_data.contains (input_cloud_item)) + { + typename PointCloud::Ptr input_cloud = input_cloud_item->data (ItemDataRole::CLOUD_TEMPLATED).value ::Ptr> (); + qDebug () << "Extracting "<indices.size() << " points out of "<width; + filter.setInputCloud (input_cloud); + filter.setIndices (selected_item_index_map_.value (input_cloud_item)); + typename PointCloud::Ptr original_minus_indices (new PointCloud); + filter.setNegative (true); + filter.filter (*original_minus_indices); + filter.setNegative (false); + typename PointCloud::Ptr selected_points (new PointCloud); + filter.filter (*selected_points); + + qDebug () << "Original minus indices is "<width; + + CloudItem* new_cloud_item = CloudItem::createCloudItemFromTemplate(input_cloud_item->text (),original_minus_indices); + + output.append (new_cloud_item); *merged_cloud += *selected_points; } - // Append the input item to the original list - // input_data.append (input_cloud_item); + //Append the input item to the original list + //input_data.append (input_cloud_item); } - // Just concatenate for all fully selected clouds - foreach (const CloudComposerItem* input_item, input_data) { - auto input_cloud = input_item->data(ItemDataRole::CLOUD_TEMPLATED) - .value::Ptr>(); + //Just concatenate for all fully selected clouds + foreach (const CloudComposerItem* input_item, input_data) + { + typename PointCloud::Ptr input_cloud = input_item->data (ItemDataRole::CLOUD_TEMPLATED).value ::Ptr> (); *merged_cloud += *input_cloud; } - CloudItem* cloud_item = CloudItem::createCloudItemFromTemplate( - "Cloud from Selection", merged_cloud); - - output.append(cloud_item); - + CloudItem* cloud_item = CloudItem::createCloudItemFromTemplate("Cloud from Selection",merged_cloud); + + output.append (cloud_item); + return output; + } -#define PCL_INSTANTIATE_performTemplatedAction(T) \ - template void pcl::cloud_composer::MergeSelection::performTemplatedAction( \ - QList); -#endif // IMPL_MERGE_SELECTION_H_ +#define PCL_INSTANTIATE_performTemplatedAction(T) template void pcl::cloud_composer::MergeSelection::performTemplatedAction (QList ); + + + +#endif //IMPL_MERGE_SELECTION_H_ diff --git a/apps/cloud_composer/include/pcl/apps/cloud_composer/impl/transform_clouds.hpp b/apps/cloud_composer/include/pcl/apps/cloud_composer/impl/transform_clouds.hpp index 5d16ae4eae2..92574aec769 100644 --- a/apps/cloud_composer/include/pcl/apps/cloud_composer/impl/transform_clouds.hpp +++ b/apps/cloud_composer/include/pcl/apps/cloud_composer/impl/transform_clouds.hpp @@ -1,4 +1,4 @@ -/* + /* * Software License Agreement (BSD License) * * Point Cloud Library (PCL) - www.pointclouds.org @@ -38,60 +38,61 @@ #ifndef IMPL_TRANSFORM_CLOUDS_HPP_ #define IMPL_TRANSFORM_CLOUDS_HPP_ -#include #include -#include +#include #include +#include -template -QList -pcl::cloud_composer::TransformClouds::performTemplatedAction( - const QList& input_data) +template QList +pcl::cloud_composer::TransformClouds::performTemplatedAction (const QList & input_data) { - QList output; - - foreach (const CloudComposerItem* input_item, input_data) { - QVariant variant = input_item->data(ItemDataRole::CLOUD_TEMPLATED); - if (!variant.canConvert::Ptr>()) { - qWarning() << "Attempted to cast to template type which does not exist in this " - "item! (input list)"; + QList output; + + foreach (const CloudComposerItem* input_item, input_data) + { + QVariant variant = input_item->data (ItemDataRole::CLOUD_TEMPLATED); + if ( ! variant.canConvert ::Ptr> () ) + { + qWarning () << "Attempted to cast to template type which does not exist in this item! (input list)"; return output; } - if (!transform_map_.contains("AllSelectedClouds") && - !transform_map_.contains(input_item->getId())) { - qCritical() << "No transform found for id " << input_item->getId() - << " in TransformClouds::performTemplatedAction"; + if (!transform_map_.contains ("AllSelectedClouds") && !transform_map_.contains (input_item->getId ())) + { + qCritical () << "No transform found for id "<getId ()<<" in TransformClouds::performTemplatedAction"; return output; } } - - foreach (const CloudComposerItem* input_item, input_data) { - qDebug() << "Transforming cloud " << input_item->getId(); - QVariant variant = input_item->data(ItemDataRole::CLOUD_TEMPLATED); - auto input_cloud = variant.value::Ptr>(); - + + foreach (const CloudComposerItem* input_item, input_data) + { + qDebug () << "Transforming cloud "<getId (); + QVariant variant = input_item->data (ItemDataRole::CLOUD_TEMPLATED); + typename PointCloud ::Ptr input_cloud = variant.value ::Ptr> (); + Eigen::Matrix4f transform; - if (transform_map_.contains("AllSelectedClouds")) - pcl::visualization::PCLVisualizer::convertToEigenMatrix( - transform_map_.value("AllSelectedClouds"), transform); + if (transform_map_.contains ("AllSelectedClouds")) + pcl::visualization::PCLVisualizer::convertToEigenMatrix (transform_map_.value ("AllSelectedClouds"), transform); else - pcl::visualization::PCLVisualizer::convertToEigenMatrix( - transform_map_.value(input_item->getId()), transform); - - typename PointCloud::Ptr transformed_cloud(new PointCloud); + pcl::visualization::PCLVisualizer::convertToEigenMatrix (transform_map_.value (input_item->getId ()), transform); + + typename PointCloud::Ptr transformed_cloud (new PointCloud); + + transformPointCloud (*input_cloud, *transformed_cloud, transform); + CloudItem* new_cloud_item = CloudItem::createCloudItemFromTemplate(input_item->text (),transformed_cloud); + + output.append (new_cloud_item); + } - transformPointCloud(*input_cloud, *transformed_cloud, transform); - CloudItem* new_cloud_item = CloudItem::createCloudItemFromTemplate( - input_item->text(), transformed_cloud); + - output.append(new_cloud_item); - } return output; + } -#define PCL_INSTANTIATE_performTemplatedAction(T) \ - template void pcl::cloud_composer::TransformClouds::performTemplatedAction( \ - QList); -#endif // IMPL_TRANSFORM_CLOUDS_HPP_ +#define PCL_INSTANTIATE_performTemplatedAction(T) template void pcl::cloud_composer::TransformClouds::performTemplatedAction (QList ); + + + +#endif //IMPL_TRANSFORM_CLOUDS_HPP_ diff --git a/apps/cloud_composer/include/pcl/apps/cloud_composer/item_inspector.h b/apps/cloud_composer/include/pcl/apps/cloud_composer/item_inspector.h index f03ab1e812b..dcf7f78cc42 100644 --- a/apps/cloud_composer/include/pcl/apps/cloud_composer/item_inspector.h +++ b/apps/cloud_composer/include/pcl/apps/cloud_composer/item_inspector.h @@ -37,58 +37,65 @@ #pragma once +#include + #include #include -#include - class QItemSelectionModel; class QTreeView; -namespace pcl { -namespace cloud_composer { -/** \brief View class for displaying properties of an item - * \author Jeremie Papon - * \ingroup cloud_composer - */ -class ItemInspector : public QTabWidget { - Q_OBJECT -public: - ItemInspector(QWidget* parent = nullptr); - -public Q_SLOTS: - void - setModel(ProjectModel* new_model); - void - selectionChanged(const QModelIndex& current, const QModelIndex& previous); - void - itemChanged(QStandardItem* item); - -private: - void - createItemWidgets(); - /** \brief Stores the state of the current tree view in item_treestate_map_ */ - void - storeTreeState(); - /** \brief Restores the state of \param model 's view from item_treestate_map_ */ - void - restoreTreeState(); - /** \brief Removes the extra tabs the item might have */ - void - removeTabs(); - /** \brief Refreshes the data shown in the current displayed view widget */ - void - updateView(); - - //! The tree object used to display/edit parameters - QTreeView* parameter_view_; - - ProjectModel* current_project_model_; - PropertiesModel* current_item_properties_model_; - const QItemSelectionModel* current_selection_model_; - QMap itemtype_widget_map; - QMap> item_treestate_map_; -}; - -} // namespace cloud_composer -} // namespace pcl +namespace pcl +{ + namespace cloud_composer + { + /** \brief View class for displaying properties of an item + * \author Jeremie Papon + * \ingroup cloud_composer + */ + class ItemInspector : public QTabWidget + { + Q_OBJECT + public: + ItemInspector (QWidget* parent = nullptr); + + public Q_SLOTS: + void + setModel (ProjectModel* new_model); + void + selectionChanged (const QModelIndex ¤t, const QModelIndex &previous); + void + itemChanged (QStandardItem* item); + + + + private: + void + createItemWidgets (); + /** \brief Stores the state of the current tree view in item_treestate_map_ */ + void + storeTreeState (); + /** \brief Restores the state of \param model 's view from item_treestate_map_ */ + void + restoreTreeState (); + /** \brief Removes the extra tabs the item might have */ + void + removeTabs (); + /** \brief Refreshes the data shown in the current displayed view widget */ + void + updateView (); + + //! The tree object used to display/edit parameters + QTreeView* parameter_view_; + + + ProjectModel* current_project_model_; + PropertiesModel* current_item_properties_model_; + const QItemSelectionModel *current_selection_model_; + QMap itemtype_widget_map; + QMap > item_treestate_map_; + }; + + + } +} diff --git a/apps/cloud_composer/include/pcl/apps/cloud_composer/items/cloud_composer_item.h b/apps/cloud_composer/include/pcl/apps/cloud_composer/items/cloud_composer_item.h index 3a60dcc1d8b..07f9bc10355 100644 --- a/apps/cloud_composer/include/pcl/apps/cloud_composer/items/cloud_composer_item.h +++ b/apps/cloud_composer/include/pcl/apps/cloud_composer/items/cloud_composer_item.h @@ -37,133 +37,128 @@ #pragma once -#include -#include #include +#include +#include -static QStringList ITEM_TYPES_STRINGS(QStringList() << "Cloud Composer Item" - << "Cloud Item" - << "Normals Item" - << "FPFH Item"); - -namespace pcl { -namespace cloud_composer { -class PropertiesModel; -namespace ItemDataRole { -enum { - PROPERTIES = Qt::UserRole, - ITEM_ID, - CLOUD_BLOB, - CLOUD_TEMPLATED, - GEOMETRY_HANDLER, - COLOR_HANDLER, - ORIGIN, - ORIENTATION, - KD_TREE_SEARCH -}; -}; -class CloudComposerItem : public QStandardItem { -public: - enum ItemType { - CLOUD_COMPOSER_ITEM = QStandardItem::UserType, - CLOUD_ITEM, - NORMALS_ITEM, - FPFH_ITEM - }; - - CloudComposerItem(const QString& name = "default item"); - CloudComposerItem(const CloudComposerItem& to_copy); - ~CloudComposerItem() override; - - inline int - type() const override - { - return CLOUD_COMPOSER_ITEM; - } - - /** \brief Convenience function to get Item's ID String */ - inline QString - getId() const - { - return data(ItemDataRole::ITEM_ID).toString(); - } - - /** \brief Convenience function to get Item's Property Pointer */ - inline PropertiesModel* - getPropertiesModel() const - { - return properties_; - } - - /** \brief Returns all children of item type type*/ - QList - getChildren(ItemType type) const; - - void - addChild(CloudComposerItem* item_arg); - - CloudComposerItem* - clone() const override; - - // /** \brief Convenience function which pulls out a cloud Ptr of type CloudPtrT */ - // template - // CloudPtrT - // getCloudPtr () const; - - /** \brief Paint View function - reimplement in item subclass if it can be displayed - * in PCLVisualizer*/ - virtual void - paintView(pcl::visualization::PCLVisualizer::Ptr vis) const; - - /** \brief Remove from View function - reimplement in item subclass if it can be - * displayed in PCLVisualizer*/ - virtual void - removeFromView(pcl::visualization::PCLVisualizer::Ptr vis) const; - - /** \brief Inspector additional tabs paint function - reimplement in item subclass if - * item has additional tabs to show in Inspector*/ - virtual QMap - getInspectorTabs(); - - /** \brief The property model calls this when a property changes */ - inline void - propertyChanged() - { - emitDataChanged(); - } - - virtual bool - isSanitized() const - { - return false; - } - -protected: - /** \brief Model for storing the properties of the item - pointer kept for convenience - */ - PropertiesModel* properties_; -}; - -/** \brief Templated helper class for converting QVariant to/from pointer classes */ -template -class VPtr { -public: - static T* - asPtr(const QVariant& v) - { - return (static_cast(v.value())); - } +static QStringList ITEM_TYPES_STRINGS(QStringList() + << "Cloud Composer Item" + << "Cloud Item" + << "Normals Item" + << "FPFH Item" + ); - static QVariant - asQVariant(T* ptr) +namespace pcl +{ + namespace cloud_composer { - return (QVariant::fromValue(static_cast(ptr))); + class PropertiesModel; + namespace ItemDataRole + { + enum + { + PROPERTIES = Qt::UserRole, + ITEM_ID, + CLOUD_BLOB, + CLOUD_TEMPLATED, + GEOMETRY_HANDLER, + COLOR_HANDLER, + ORIGIN, + ORIENTATION, + KD_TREE_SEARCH + }; + }; + class CloudComposerItem : public QStandardItem + { + public: + + + enum ItemType + { + CLOUD_COMPOSER_ITEM = QStandardItem::UserType, + CLOUD_ITEM, + NORMALS_ITEM, + FPFH_ITEM + }; + + CloudComposerItem (const QString& name = "default item"); + CloudComposerItem (const CloudComposerItem& to_copy); + ~CloudComposerItem (); + + inline int + type () const override { return CLOUD_COMPOSER_ITEM; } + + /** \brief Convenience function to get Item's ID String */ + inline QString + getId () const { return data (ItemDataRole::ITEM_ID).toString (); } + + /** \brief Convenience function to get Item's Property Pointer */ + inline PropertiesModel* + getPropertiesModel () const { return properties_; } + + /** \brief Returns all children of item type type*/ + QList + getChildren (ItemType type) const; + + void + addChild (CloudComposerItem* item_arg); + + CloudComposerItem* + clone () const override; + + // /** \brief Convenience function which pulls out a cloud Ptr of type CloudPtrT */ + // template + // CloudPtrT + // getCloudPtr () const; + + /** \brief Paint View function - reimplement in item subclass if it can be displayed in PCLVisualizer*/ + virtual void + paintView (pcl::visualization::PCLVisualizer::Ptr vis) const; + + /** \brief Remove from View function - reimplement in item subclass if it can be displayed in PCLVisualizer*/ + virtual void + removeFromView (pcl::visualization::PCLVisualizer::Ptr vis) const; + + /** \brief Inspector additional tabs paint function - reimplement in item subclass if item has additional tabs to show in Inspector*/ + virtual QMap + getInspectorTabs (); + + /** \brief The property model calls this when a property changes */ + inline void + propertyChanged () + { + emitDataChanged (); + } + + virtual bool + isSanitized () const { return false; } + protected: + + /** \brief Model for storing the properties of the item - pointer kept for convenience */ + PropertiesModel* properties_; + + }; + + + + /** \brief Templated helper class for converting QVariant to/from pointer classes */ + template class VPtr + { + public: + static T* asPtr (const QVariant& v) + { + return (static_cast (v.value ())); + } + + static QVariant asQVariant (T* ptr) + { + return (QVariant::fromValue (static_cast(ptr))); + } + }; + } -}; - -} // namespace cloud_composer -} // namespace pcl +} -using ConstItemList = QList; +using ConstItemList = QList; -Q_DECLARE_METATYPE(pcl::cloud_composer::CloudComposerItem); +Q_DECLARE_METATYPE (pcl::cloud_composer::CloudComposerItem); diff --git a/apps/cloud_composer/include/pcl/apps/cloud_composer/items/cloud_item.h b/apps/cloud_composer/include/pcl/apps/cloud_composer/items/cloud_item.h index 126e8ff2faa..aabf5aab381 100644 --- a/apps/cloud_composer/include/pcl/apps/cloud_composer/items/cloud_item.h +++ b/apps/cloud_composer/include/pcl/apps/cloud_composer/items/cloud_item.h @@ -37,171 +37,162 @@ #pragma once +#include + #include -#include -#include -#include -#include + +#include +#include +#include #include #include -#include -#include -#include +#include +#include +#include +#include -#include -// Typedefs to make things sane -using GeometryHandler = - pcl::visualization::PointCloudGeometryHandler; +//Typedefs to make things sane +using GeometryHandler = pcl::visualization::PointCloudGeometryHandler; using ColorHandler = pcl::visualization::PointCloudColorHandler; -namespace pcl { -namespace cloud_composer { -namespace PointTypeFlags { -enum PointType { - NONE = 0, - XYZ = (1 << 0), - RGB = (1 << 1), - RGBA = (1 << 2), - NORMAL = (1 << 3), - HSV = (1 << 4), - AXIS = (1 << 5), -}; -} -class CloudItem : public CloudComposerItem { -public: - // This is needed because we have members which are Vector4f and Quaternionf - PCL_MAKE_ALIGNED_OPERATOR_NEW - - CloudItem(const QString name, - const pcl::PCLPointCloud2::Ptr& cloud_ptr, - const Eigen::Vector4f& origin = Eigen::Vector4f(), - const Eigen::Quaternionf& orientation = Eigen::Quaternionf(), - bool make_templated_cloud = true); - - CloudItem(const CloudItem& to_copy); - - /** \brief This creates a CloudItem from a templated cloud type */ - template - static CloudItem* - createCloudItemFromTemplate(const QString& name, - typename PointCloud::Ptr cloud_ptr); - - /** \brief virtual data getter which calls QStandardItem::data; used to create - * template cloud if not created yet WARNING : This function modifies "this" - it sets - * up the templated type if you request one when it doesn't exist yet! It had to - * remain const because it is virtual, and we need to keep run-time polymorphism - */ - QVariant - data(int role = Qt::UserRole + 1) const override; - - /** \brief Virtual data setter which calls QStandardItem::data; used to ensure that - * template_cloud_set_ is set when a templated cloud is added */ - void - setData(const QVariant& value, int role = Qt::UserRole + 1) override; - - inline int - type() const override - { - return CLOUD_ITEM; - } - - CloudItem* - clone() const override; - - /** \brief Paint View function - puts this cloud item into a PCLVisualizer object*/ - void - paintView(pcl::visualization::PCLVisualizer::Ptr vis) const override; - - /** \brief Remove from View function - removes this cloud from a PCLVisualizer - * object*/ - void - removeFromView(pcl::visualization::PCLVisualizer::Ptr vis) const override; - - /** \brief Initializes and stores a templated PointCloud object with point type - * matching the blob */ - void - setTemplateCloudFromBlob(); - - int - getPointType() const - { - return point_type_; - } - - template - void - printNumPoints() const; - - bool - isSanitized() const override - { - return is_sanitized_; - } - -private: - // These are just stored for convenience - pcl::PCLPointCloud2::Ptr cloud_blob_ptr_; - ColorHandler::ConstPtr color_handler_; - GeometryHandler::ConstPtr geometry_handler_; - - // We keep actual local copies of these. - Eigen::Vector4f origin_; - Eigen::Quaternionf orientation_; - - bool template_cloud_set_{false}; - - // Internal Storage of the templated type of this cloud - int point_type_{PointTypeFlags::NONE}; - - bool - checkIfFinite(); - - bool is_sanitized_{false}; - - // Helper functions which set the point_type_ based on the current point type - template - inline void - setPointType() +namespace pcl +{ + namespace cloud_composer { - qCritical() << "CloudItem::setPointType for type with no specialization"; - point_type_ = PointTypeFlags::NONE; + namespace PointTypeFlags + { + enum PointType + { + NONE = 0, + XYZ = (1 << 0), + RGB = (1 << 1), + RGBA = (1 << 2), + NORMAL = (1 << 3), + HSV = (1 << 4), + AXIS = (1 << 5), + }; + } + class CloudItem : public CloudComposerItem + { + public: + + //This is needed because we have members which are Vector4f and Quaternionf + PCL_MAKE_ALIGNED_OPERATOR_NEW + + CloudItem (const QString name, + const pcl::PCLPointCloud2::Ptr& cloud_ptr, + const Eigen::Vector4f& origin = Eigen::Vector4f (), + const Eigen::Quaternionf& orientation = Eigen::Quaternionf (), + bool make_templated_cloud = true); + + CloudItem (const CloudItem& to_copy); + + /** \brief This creates a CloudItem from a templated cloud type */ + template + static CloudItem* + createCloudItemFromTemplate (const QString& name, typename PointCloud::Ptr cloud_ptr); + + /** \brief virtual data getter which calls QStandardItem::data; used to create template cloud if not created yet + * WARNING : This function modifies "this" - it sets up the templated type if you request one when it doesn't exist yet! + * It had to remain const because it is virtual, and we need to keep run-time polymorphism + */ + QVariant + data (int role = Qt::UserRole +1) const override; + + /** \brief Virtual data setter which calls QStandardItem::data; used to ensure that template_cloud_set_ is set + * when a templated cloud is added */ + void + setData ( const QVariant & value, int role = Qt::UserRole + 1 ) override; + + inline int + type () const override { return CLOUD_ITEM; } + + CloudItem* + clone () const override; + + /** \brief Paint View function - puts this cloud item into a PCLVisualizer object*/ + void + paintView (pcl::visualization::PCLVisualizer::Ptr vis) const override; + + /** \brief Remove from View function - removes this cloud from a PCLVisualizer object*/ + void + removeFromView (pcl::visualization::PCLVisualizer::Ptr vis) const override; + + /** \brief Initializes and stores a templated PointCloud object with point type matching the blob */ + void + setTemplateCloudFromBlob (); + + int + getPointType () const { return point_type_; } + + template void + printNumPoints () const; + + bool + isSanitized () const override { return is_sanitized_; } + private: + + //These are just stored for convenience + pcl::PCLPointCloud2::Ptr cloud_blob_ptr_; + ColorHandler::ConstPtr color_handler_; + GeometryHandler::ConstPtr geometry_handler_; + + //We keep actual local copies of these. + Eigen::Vector4f origin_; + Eigen::Quaternionf orientation_; + + bool template_cloud_set_; + + //Internal Storage of the templated type of this cloud + int point_type_; + + bool + checkIfFinite (); + + bool is_sanitized_; + + //Helper functions which set the point_type_ based on the current point type + template inline void + setPointType () + { + qCritical () << "CloudItem::setPointType for type with no specialization"; + point_type_ = PointTypeFlags::NONE; + } + + }; + + template <> inline void + CloudItem::setPointType () + { + point_type_ = PointTypeFlags::XYZ; + } + template <> inline void + CloudItem::setPointType () + { + point_type_ = PointTypeFlags::XYZ | PointTypeFlags::RGB; + } + template <> inline void + CloudItem::setPointType () + { + point_type_ = PointTypeFlags::XYZ | PointTypeFlags::RGBA; + } + + } -}; - -template <> -inline void -CloudItem::setPointType() -{ - point_type_ = PointTypeFlags::XYZ; -} -template <> -inline void -CloudItem::setPointType() -{ - point_type_ = PointTypeFlags::XYZ | PointTypeFlags::RGB; } -template <> -inline void -CloudItem::setPointType() -{ - point_type_ = PointTypeFlags::XYZ | PointTypeFlags::RGBA; -} - -} // namespace cloud_composer -} // namespace pcl -// Add PointCloud types to QT MetaType System -Q_DECLARE_METATYPE(pcl::PCLPointCloud2::ConstPtr); -Q_DECLARE_METATYPE(GeometryHandler::ConstPtr); -Q_DECLARE_METATYPE(ColorHandler::ConstPtr); -Q_DECLARE_METATYPE(Eigen::Vector4f); -Q_DECLARE_METATYPE(Eigen::Quaternionf); +//Add PointCloud types to QT MetaType System +Q_DECLARE_METATYPE (pcl::PCLPointCloud2::ConstPtr); +Q_DECLARE_METATYPE (GeometryHandler::ConstPtr); +Q_DECLARE_METATYPE (ColorHandler::ConstPtr); +Q_DECLARE_METATYPE (Eigen::Vector4f); +Q_DECLARE_METATYPE (Eigen::Quaternionf); -Q_DECLARE_METATYPE(pcl::search::KdTree::Ptr); -Q_DECLARE_METATYPE(pcl::search::KdTree::Ptr); -Q_DECLARE_METATYPE(pcl::search::KdTree::Ptr); +Q_DECLARE_METATYPE (pcl::search::KdTree::Ptr); +Q_DECLARE_METATYPE (pcl::search::KdTree::Ptr); +Q_DECLARE_METATYPE (pcl::search::KdTree::Ptr); -Q_DECLARE_METATYPE(pcl::PointCloud::Ptr); -Q_DECLARE_METATYPE(pcl::PointCloud::Ptr); -Q_DECLARE_METATYPE(pcl::PointCloud::Ptr); +Q_DECLARE_METATYPE (pcl::PointCloud ::Ptr); +Q_DECLARE_METATYPE (pcl::PointCloud ::Ptr); +Q_DECLARE_METATYPE (pcl::PointCloud ::Ptr); diff --git a/apps/cloud_composer/include/pcl/apps/cloud_composer/items/fpfh_item.h b/apps/cloud_composer/include/pcl/apps/cloud_composer/items/fpfh_item.h index e1241504fa1..5a634272a8a 100644 --- a/apps/cloud_composer/include/pcl/apps/cloud_composer/items/fpfh_item.h +++ b/apps/cloud_composer/include/pcl/apps/cloud_composer/items/fpfh_item.h @@ -37,45 +37,47 @@ #pragma once -#include -#include -#include -#include #include +#include -namespace pcl { -namespace cloud_composer { - -class FPFHItem : public CloudComposerItem { -public: - FPFHItem(QString name, - const pcl::PointCloud::Ptr& fpfh_ptr, - double radius); - FPFHItem(const FPFHItem& to_copy); +#include +#include +#include - inline int - type() const override +namespace pcl +{ + namespace cloud_composer { - return FPFH_ITEM; - } - - FPFHItem* - clone() const override; + + class FPFHItem : public CloudComposerItem + { + public: - /** \brief Inspector additional tabs paint function - get the histogram plot widget*/ - QMap - getInspectorTabs() override; + FPFHItem (QString name, + const pcl::PointCloud::Ptr& fpfh_ptr, + double radius); + FPFHItem (const FPFHItem& to_copy); + + inline int + type () const override { return FPFH_ITEM; } -private: - pcl::PointCloud::Ptr fpfh_ptr_; - double radius_; - pcl::visualization::PCLPlotter::Ptr plot_; - PCLQVTKWidget* qvtk_; - QWidget* hist_page_; -}; + FPFHItem* + clone () const override; + + /** \brief Inspector additional tabs paint function - get the histogram plot widget*/ + QMap + getInspectorTabs () override; + + private: + pcl::PointCloud::Ptr fpfh_ptr_; + double radius_; + pcl::visualization::PCLPlotter::Ptr plot_; + PCLQVTKWidget* qvtk_; + QWidget *hist_page_; + }; -} // namespace cloud_composer -} // namespace pcl + } +} -Q_DECLARE_METATYPE(pcl::PointCloud::Ptr); -Q_DECLARE_METATYPE(pcl::PointCloud::ConstPtr); +Q_DECLARE_METATYPE (pcl::PointCloud::Ptr); +Q_DECLARE_METATYPE (pcl::PointCloud::ConstPtr); diff --git a/apps/cloud_composer/include/pcl/apps/cloud_composer/items/normals_item.h b/apps/cloud_composer/include/pcl/apps/cloud_composer/items/normals_item.h index 40fb5c3cfdc..73c687bd298 100644 --- a/apps/cloud_composer/include/pcl/apps/cloud_composer/items/normals_item.h +++ b/apps/cloud_composer/include/pcl/apps/cloud_composer/items/normals_item.h @@ -37,43 +37,47 @@ #pragma once -#include -#include #include +#include -namespace pcl { -namespace cloud_composer { - -class NormalsItem : public CloudComposerItem { -public: - NormalsItem(QString name, - const pcl::PointCloud::Ptr& normals_ptr, - double radius); - NormalsItem(const NormalsItem& to_copy); +#include - inline int - type() const override +namespace pcl +{ + namespace cloud_composer { - return NORMALS_ITEM; - } - - NormalsItem* - clone() const override; + + class NormalsItem : public CloudComposerItem + { + public: - void - paintView(pcl::visualization::PCLVisualizer::Ptr vis) const override; + NormalsItem (QString name, + const pcl::PointCloud::Ptr& normals_ptr, + double radius); + NormalsItem (const NormalsItem& to_copy); + + inline int + type () const override { return NORMALS_ITEM; } - /** \brief Remove from View function - removes the normal cloud from a PCLVisualizer - * object*/ - void - removeFromView(pcl::visualization::PCLVisualizer::Ptr vis) const override; + NormalsItem* + clone () const override; + + void + paintView (pcl::visualization::PCLVisualizer::Ptr vis) const override; + + /** \brief Remove from View function - removes the normal cloud from a PCLVisualizer object*/ + void + removeFromView (pcl::visualization::PCLVisualizer::Ptr vis) const override; + + private: + pcl::PointCloud::Ptr normals_ptr_; -private: - pcl::PointCloud::Ptr normals_ptr_; -}; - -} // namespace cloud_composer -} // namespace pcl + }; + + + + } +} -Q_DECLARE_METATYPE(pcl::PointCloud::Ptr); -Q_DECLARE_METATYPE(pcl::PointCloud::ConstPtr); +Q_DECLARE_METATYPE (pcl::PointCloud::Ptr); +Q_DECLARE_METATYPE (pcl::PointCloud::ConstPtr); diff --git a/apps/cloud_composer/include/pcl/apps/cloud_composer/merge_selection.h b/apps/cloud_composer/include/pcl/apps/cloud_composer/merge_selection.h index 0e4181c3bcd..af3d7afa95f 100644 --- a/apps/cloud_composer/include/pcl/apps/cloud_composer/merge_selection.h +++ b/apps/cloud_composer/include/pcl/apps/cloud_composer/merge_selection.h @@ -39,38 +39,31 @@ #include -namespace pcl { -namespace cloud_composer { -class MergeSelection : public MergeCloudTool { - Q_OBJECT -public: - MergeSelection( - QMap selected_item_index_map, - QObject* parent = nullptr); - - QList - performAction(QList input_data, - PointTypeFlags::PointType type = PointTypeFlags::NONE) override; - - inline QString - getToolName() const override +namespace pcl +{ + namespace cloud_composer { - return "Merge Selection Tool"; - } + class MergeSelection : public MergeCloudTool + { + Q_OBJECT + public: + MergeSelection (QMap selected_item_index_map, QObject* parent = nullptr); + + QList + performAction (QList input_data, PointTypeFlags::PointType type = PointTypeFlags::NONE) override; + + inline QString + getToolName () const override { return "Merge Selection Tool";} + + QList + getSelectedItems () { return selected_item_index_map_.keys ();} + + template QList + performTemplatedAction (const QList & input_data); + + private: + QMap selected_item_index_map_; + }; - QList - getSelectedItems() - { - return selected_item_index_map_.keys(); } - - template - QList - performTemplatedAction(const QList& input_data); - -private: - QMap selected_item_index_map_; -}; - -} // namespace cloud_composer -} // namespace pcl +} diff --git a/apps/cloud_composer/include/pcl/apps/cloud_composer/point_selectors/click_trackball_interactor_style.h b/apps/cloud_composer/include/pcl/apps/cloud_composer/point_selectors/click_trackball_interactor_style.h index 7bb9d3fac7c..2477b33b525 100644 --- a/apps/cloud_composer/include/pcl/apps/cloud_composer/point_selectors/click_trackball_interactor_style.h +++ b/apps/cloud_composer/include/pcl/apps/cloud_composer/point_selectors/click_trackball_interactor_style.h @@ -41,83 +41,73 @@ #include -namespace pcl { -namespace cloud_composer { - -class ClickTrackballStyleInteractor : public vtkInteractorStyleTrackballActor { -public: - static ClickTrackballStyleInteractor* - New(); - vtkTypeMacro(ClickTrackballStyleInteractor, vtkInteractorStyleTrackballActor); - - ClickTrackballStyleInteractor(); - - /** \brief Pass a pointer to the actor map - * \param[in] actors the actor map that will be used with this style - */ - inline void - setCloudActorMap(const pcl::visualization::CloudActorMapPtr& actors) - { - actors_ = actors; - } - - /** \brief Get the cloud actor map pointer. */ - inline pcl::visualization::CloudActorMapPtr - getCloudActorMap() const - { - return (actors_); - } - - /** \brief Pass a set of renderers to the interactor style. - * \param[in] rens the vtkRendererCollection to use - */ - void - setRendererCollection(vtkSmartPointer& rens) - { - renderers_ = rens; - } - - /** \brief Function called on left mouse button release, ie, end of rectangular drag - */ - void - OnLeftButtonDown() override; - - /** \brief Function called on left mouse button release, ie, end of rectangular drag - */ - void - OnLeftButtonUp() override; - - void - OnRightButtonDown() override; - - void - OnRightButtonUp() override; - - /** \brief Event emitted once a valid selection has been made */ - int manipulation_complete_event_; - - inline void - setProjectModel(ProjectModel* model) +namespace pcl +{ + namespace cloud_composer { - model_ = model; + + class ClickTrackballStyleInteractor : public vtkInteractorStyleTrackballActor + { + public: + static ClickTrackballStyleInteractor* New(); + vtkTypeMacro(ClickTrackballStyleInteractor,vtkInteractorStyleTrackballActor); + + ClickTrackballStyleInteractor (); + + /** \brief Pass a pointer to the actor map + * \param[in] actors the actor map that will be used with this style + */ + inline void + setCloudActorMap (const pcl::visualization::CloudActorMapPtr &actors) { actors_ = actors; } + + /** \brief Get the cloud actor map pointer. */ + inline pcl::visualization::CloudActorMapPtr + getCloudActorMap () const { return (actors_); } + + /** \brief Pass a set of renderers to the interactor style. + * \param[in] rens the vtkRendererCollection to use + */ + void + setRendererCollection (vtkSmartPointer &rens) { renderers_ = rens; } + + /** \brief Function called on left mouse button release, ie, end of rectangular drag */ + void + OnLeftButtonDown () override; + + /** \brief Function called on left mouse button release, ie, end of rectangular drag */ + void + OnLeftButtonUp () override; + + void + OnRightButtonDown () override; + + void + OnRightButtonUp () override; + + /** \brief Event emitted once a valid selection has been made */ + int manipulation_complete_event_; + + inline void + setProjectModel (ProjectModel* model) { model_ = model; } + private: + + + /** \brief Actor map stored internally. */ + pcl::visualization::CloudActorMapPtr actors_; + + /** \brief Collection of vtkRenderers stored internally. */ + vtkSmartPointer renderers_; + + /** \brief Internal Pointer to Project Model */ + ProjectModel* model_; + + vtkSmartPointer start_matrix_; + vtkSmartPointer end_matrix_; + + vtkSmartPointer transform_; + + }; + } - -private: - /** \brief Actor map stored internally. */ - pcl::visualization::CloudActorMapPtr actors_; - - /** \brief Collection of vtkRenderers stored internally. */ - vtkSmartPointer renderers_; - - /** \brief Internal Pointer to Project Model */ - ProjectModel* model_; - - vtkSmartPointer start_matrix_; - vtkSmartPointer end_matrix_; - - vtkSmartPointer transform_; -}; - -} // namespace cloud_composer - -} // namespace pcl + +} diff --git a/apps/cloud_composer/include/pcl/apps/cloud_composer/point_selectors/interactor_style_switch.h b/apps/cloud_composer/include/pcl/apps/cloud_composer/point_selectors/interactor_style_switch.h index f7905862197..1f4fcd17544 100644 --- a/apps/cloud_composer/include/pcl/apps/cloud_composer/point_selectors/interactor_style_switch.h +++ b/apps/cloud_composer/include/pcl/apps/cloud_composer/point_selectors/interactor_style_switch.h @@ -37,122 +37,118 @@ #pragma once +#include + +#include #include #include -#include #include -#include - +#include #include -#include -#include #include -#include #include -#include +#include +#include +#include class QVTKWidget; -namespace pcl { -namespace cloud_composer { -namespace interactor_styles { -enum INTERACTOR_STYLES { - PCL_VISUALIZER = 0, - RECTANGULAR_FRUSTUM, - SELECTED_TRACKBALL, - CLICK_TRACKBALL -}; -} -namespace interactor_events { -enum { - SELECTION_COMPLETE_EVENT = vtkCommand::UserEvent + 1, - MANIPULATION_COMPLETE_EVENT -}; -}; - -class RectangularFrustumSelector; -class SelectedTrackballStyleInteractor; -class ClickTrackballStyleInteractor; -class ProjectModel; - -class InteractorStyleSwitch : public vtkInteractorStyle { -public: - static InteractorStyleSwitch* - New(); - vtkTypeMacro(InteractorStyleSwitch, vtkInteractorStyle); - - InteractorStyleSwitch(); - - void - SetInteractor(vtkRenderWindowInteractor* iren) override; - - vtkGetObjectMacro(current_style_, vtkInteractorStyle); - - void - initializeInteractorStyles(pcl::visualization::PCLVisualizer::Ptr vis, - ProjectModel* model); - - inline void - setQVTKWidget(QVTKWidget* qvtk) - { - qvtk_ = qvtk; - } - - void - setCurrentInteractorStyle(interactor_styles::INTERACTOR_STYLES interactor_style); - - // vtkSmartPointer - // getPCLVisInteractorStyle () { return pcl_vis_style_; } - - inline vtkSmartPointer - getInteractorStyle(const interactor_styles::INTERACTOR_STYLES interactor_style) const +namespace pcl +{ + namespace cloud_composer { - return name_to_style_map_.value(interactor_style); + namespace interactor_styles + { + enum INTERACTOR_STYLES + { + PCL_VISUALIZER = 0, + RECTANGULAR_FRUSTUM, + SELECTED_TRACKBALL, + CLICK_TRACKBALL + }; + } + namespace interactor_events + { + enum + { + SELECTION_COMPLETE_EVENT = vtkCommand::UserEvent + 1, + MANIPULATION_COMPLETE_EVENT + }; + }; + + class RectangularFrustumSelector; + class SelectedTrackballStyleInteractor; + class ClickTrackballStyleInteractor; + class ProjectModel; + + class InteractorStyleSwitch : public vtkInteractorStyle + { + public: + static InteractorStyleSwitch *New(); + vtkTypeMacro(InteractorStyleSwitch, vtkInteractorStyle); + + InteractorStyleSwitch(); + + void + SetInteractor(vtkRenderWindowInteractor *iren) override; + + vtkGetObjectMacro(current_style_, vtkInteractorStyle); + + void + initializeInteractorStyles (pcl::visualization::PCLVisualizer::Ptr vis, ProjectModel* model); + + inline void + setQVTKWidget (QVTKWidget* qvtk) { qvtk_ = qvtk; } + + void + setCurrentInteractorStyle (interactor_styles::INTERACTOR_STYLES interactor_style); + + // vtkSmartPointer + // getPCLVisInteractorStyle () { return pcl_vis_style_; } + + inline vtkSmartPointer + getInteractorStyle (const interactor_styles::INTERACTOR_STYLES interactor_style) const + { return name_to_style_map_.value (interactor_style); } + + + void SetDefaultRenderer(vtkRenderer*) override; + + void SetCurrentRenderer(vtkRenderer*) override; + + void + OnLeave () override; + + protected: + void + setCurrentStyle(); + + QMap > name_to_style_map_; + + + vtkRenderWindowInteractor* render_window_interactor_; + vtkSmartPointer rens_; + + vtkInteractorStyle* current_style_; + vtkSmartPointer pcl_vis_style_; + vtkSmartPointer rectangular_frustum_selector_; + + vtkSmartPointer selected_trackball_interactor_style_; + + vtkSmartPointer click_trackball_interactor_style_; + vtkSmartPointer area_picker_; + vtkSmartPointer point_picker_; + + /** \brief Internal pointer to QVTKWidget that this Switch works with */ + QVTKWidget* qvtk_; + /** \brief Internal pointer to PCLVisualizer that this Switch works with */ + pcl::visualization::PCLVisualizer::Ptr vis_; + private: + InteractorStyleSwitch(const InteractorStyleSwitch&); // Not implemented. + void operator=(const InteractorStyleSwitch&); // Not implemented. + ProjectModel* project_model_; + }; + } - - void - SetDefaultRenderer(vtkRenderer*) override; - - void - SetCurrentRenderer(vtkRenderer*) override; - - void - OnLeave() override; - -protected: - void - setCurrentStyle(); - - QMap> - name_to_style_map_; - - vtkRenderWindowInteractor* render_window_interactor_; - vtkSmartPointer rens_; - - vtkInteractorStyle* current_style_; - vtkSmartPointer pcl_vis_style_; - vtkSmartPointer rectangular_frustum_selector_; - - vtkSmartPointer - selected_trackball_interactor_style_; - - vtkSmartPointer click_trackball_interactor_style_; - vtkSmartPointer area_picker_; - vtkSmartPointer point_picker_; - - /** \brief Internal pointer to QVTKWidget that this Switch works with */ - QVTKWidget* qvtk_; - /** \brief Internal pointer to PCLVisualizer that this Switch works with */ - pcl::visualization::PCLVisualizer::Ptr vis_; - -private: - InteractorStyleSwitch(const InteractorStyleSwitch&); // Not implemented. - void - operator=(const InteractorStyleSwitch&); // Not implemented. - ProjectModel* project_model_; -}; - -} // namespace cloud_composer - -} // namespace pcl + +} diff --git a/apps/cloud_composer/include/pcl/apps/cloud_composer/point_selectors/manipulation_event.h b/apps/cloud_composer/include/pcl/apps/cloud_composer/point_selectors/manipulation_event.h index 883222cdfe6..73efe79c25d 100644 --- a/apps/cloud_composer/include/pcl/apps/cloud_composer/point_selectors/manipulation_event.h +++ b/apps/cloud_composer/include/pcl/apps/cloud_composer/point_selectors/manipulation_event.h @@ -39,36 +39,35 @@ #include -namespace pcl { -namespace cloud_composer { - -class ManipulationEvent { - -public: - ManipulationEvent() = default; - - void - addManipulation(const QString& id, - const vtkSmartPointer& start, - const vtkSmartPointer& end); - - inline QMap> - getStartMap() const - { - return id_start_map_; - } - - inline QMap> - getEndMap() const +namespace pcl +{ + namespace cloud_composer { - return id_end_map_; + + + class ManipulationEvent + { + + public: + ManipulationEvent () + {} + + void + addManipulation (const QString& id, const vtkSmartPointer& start, const vtkSmartPointer& end); + + inline QMap > + getStartMap () const { return id_start_map_;} + + inline QMap > + getEndMap () const { return id_end_map_;} + + + private: + QMap > id_start_map_; + QMap > id_end_map_; + + }; + } - -private: - QMap> id_start_map_; - QMap> id_end_map_; -}; - -} // namespace cloud_composer - -} // namespace pcl + +} diff --git a/apps/cloud_composer/include/pcl/apps/cloud_composer/point_selectors/rectangular_frustum_selector.h b/apps/cloud_composer/include/pcl/apps/cloud_composer/point_selectors/rectangular_frustum_selector.h index 6ad55d6eb95..bed9b5d570a 100644 --- a/apps/cloud_composer/include/pcl/apps/cloud_composer/point_selectors/rectangular_frustum_selector.h +++ b/apps/cloud_composer/include/pcl/apps/cloud_composer/point_selectors/rectangular_frustum_selector.h @@ -39,62 +39,55 @@ #include -#include -#include #include +#include +#include -namespace pcl { -namespace cloud_composer { - -class RectangularFrustumSelector : public vtkInteractorStyleRubberBandPick { -public: - static RectangularFrustumSelector* - New(); - vtkTypeMacro(RectangularFrustumSelector, vtkInteractorStyleRubberBandPick); - - RectangularFrustumSelector(); - - /** \brief Pass a pointer to the actor map - * \param[in] actors the actor map that will be used with this style - */ - inline void - setCloudActorMap(const pcl::visualization::CloudActorMapPtr& actors) - { - actors_ = actors; - } - - /** \brief Get the cloud actor map pointer. */ - inline pcl::visualization::CloudActorMapPtr - getCloudActorMap() const - { - return (actors_); - } - - /** \brief Pass a set of renderers to the interactor style. - * \param[in] rens the vtkRendererCollection to use - */ - void - setRendererCollection(vtkSmartPointer& rens) +namespace pcl +{ + namespace cloud_composer { - renderers_ = rens; - } + + class RectangularFrustumSelector : public vtkInteractorStyleRubberBandPick + { + public: + static RectangularFrustumSelector* New(); + vtkTypeMacro(RectangularFrustumSelector,vtkInteractorStyleRubberBandPick); + + RectangularFrustumSelector (); + + /** \brief Pass a pointer to the actor map + * \param[in] actors the actor map that will be used with this style + */ + inline void + setCloudActorMap (const pcl::visualization::CloudActorMapPtr &actors) { actors_ = actors; } - /** \brief Function called on left mouse button release, ie, end of rectangular drag - */ - void - OnLeftButtonUp() override; + /** \brief Get the cloud actor map pointer. */ + inline pcl::visualization::CloudActorMapPtr + getCloudActorMap () const { return (actors_); } - /** \brief Event emitted once a valid selection has been made */ - int selection_complete_event_; + /** \brief Pass a set of renderers to the interactor style. + * \param[in] rens the vtkRendererCollection to use + */ + void + setRendererCollection (vtkSmartPointer &rens) { renderers_ = rens; } -private: - /** \brief Actor map stored internally. */ - pcl::visualization::CloudActorMapPtr actors_; + /** \brief Function called on left mouse button release, ie, end of rectangular drag */ + void + OnLeftButtonUp () override; - /** \brief Collection of vtkRenderers stored internally. */ - vtkSmartPointer renderers_; -}; + /** \brief Event emitted once a valid selection has been made */ + int selection_complete_event_; + private: -} // namespace cloud_composer - -} // namespace pcl + + /** \brief Actor map stored internally. */ + pcl::visualization::CloudActorMapPtr actors_; + + /** \brief Collection of vtkRenderers stored internally. */ + vtkSmartPointer renderers_; + }; + + } + +} diff --git a/apps/cloud_composer/include/pcl/apps/cloud_composer/point_selectors/selected_trackball_interactor_style.h b/apps/cloud_composer/include/pcl/apps/cloud_composer/point_selectors/selected_trackball_interactor_style.h index 9133b19e2b5..3a9a20b32bc 100644 --- a/apps/cloud_composer/include/pcl/apps/cloud_composer/point_selectors/selected_trackball_interactor_style.h +++ b/apps/cloud_composer/include/pcl/apps/cloud_composer/point_selectors/selected_trackball_interactor_style.h @@ -38,94 +38,85 @@ #include #include -#include #include +#include -namespace pcl { -namespace cloud_composer { - -class SelectedTrackballStyleInteractor : public vtkInteractorStyleTrackballActor { -public: - static SelectedTrackballStyleInteractor* - New(); - vtkTypeMacro(SelectedTrackballStyleInteractor, vtkInteractorStyleTrackballActor); - - SelectedTrackballStyleInteractor(); - - /** \brief Pass a pointer to the actor map - * \param[in] actors the actor map that will be used with this style - */ - inline void - setCloudActorMap(const pcl::visualization::CloudActorMapPtr& actors) - { - actors_ = actors; - } - - /** \brief Get the cloud actor map pointer. */ - inline pcl::visualization::CloudActorMapPtr - getCloudActorMap() const - { - return (actors_); - } - - /** \brief Pass a set of renderers to the interactor style. - * \param[in] rens the vtkRendererCollection to use - */ - void - setRendererCollection(vtkSmartPointer& rens) - { - renderers_ = rens; - } - - /** \brief Function called on left mouse button click, ie, beginning of trackball */ - void - OnLeftButtonDown() override; - - void - OnRightButtonDown() override; - - /** \brief Function called on left mouse button release, ie, end of trackball*/ - void - OnLeftButtonUp() override; - - void - OnRightButtonUp() override; - - void - Rotate() override; - void - Spin() override; - void - Pan() override; - void - UniformScale() override; - - /** \brief Event emitted once a valid selection has been made */ - int manipulation_complete_event_; - - inline void - setProjectModel(ProjectModel* model) +namespace pcl +{ + namespace cloud_composer { - model_ = model; + + class SelectedTrackballStyleInteractor : public vtkInteractorStyleTrackballActor + { + public: + static SelectedTrackballStyleInteractor* New(); + vtkTypeMacro(SelectedTrackballStyleInteractor,vtkInteractorStyleTrackballActor); + + SelectedTrackballStyleInteractor (); + + /** \brief Pass a pointer to the actor map + * \param[in] actors the actor map that will be used with this style + */ + inline void + setCloudActorMap (const pcl::visualization::CloudActorMapPtr &actors) { actors_ = actors; } + + /** \brief Get the cloud actor map pointer. */ + inline pcl::visualization::CloudActorMapPtr + getCloudActorMap () const { return (actors_); } + + /** \brief Pass a set of renderers to the interactor style. + * \param[in] rens the vtkRendererCollection to use + */ + void + setRendererCollection (vtkSmartPointer &rens) { renderers_ = rens; } + + /** \brief Function called on left mouse button click, ie, beginning of trackball */ + void + OnLeftButtonDown () override; + + void + OnRightButtonDown () override; + + /** \brief Function called on left mouse button release, ie, end of trackball*/ + void + OnLeftButtonUp () override; + + void + OnRightButtonUp () override; + + void + Rotate() override; + void + Spin() override; + void + Pan() override; + void + UniformScale() override; + + /** \brief Event emitted once a valid selection has been made */ + int manipulation_complete_event_; + + inline void + setProjectModel (ProjectModel* model) { model_ = model; } + private: + + void + setSelectedActors (); + + /** \brief Actor map stored internally. */ + pcl::visualization::CloudActorMapPtr actors_; + + /** \brief Collection of vtkRenderers stored internally. */ + vtkSmartPointer renderers_; + + /** \brief Internal Pointer to Project Model */ + ProjectModel* model_; + + QMap > start_matrix_map_; + QMap selected_actors_map_; + + }; + } - -private: - void - setSelectedActors(); - - /** \brief Actor map stored internally. */ - pcl::visualization::CloudActorMapPtr actors_; - - /** \brief Collection of vtkRenderers stored internally. */ - vtkSmartPointer renderers_; - - /** \brief Internal Pointer to Project Model */ - ProjectModel* model_; - - QMap> start_matrix_map_; - QMap selected_actors_map_; -}; - -} // namespace cloud_composer - -} // namespace pcl + +} diff --git a/apps/cloud_composer/include/pcl/apps/cloud_composer/point_selectors/selection_event.h b/apps/cloud_composer/include/pcl/apps/cloud_composer/point_selectors/selection_event.h index e32d819afae..0e40fcb5e24 100644 --- a/apps/cloud_composer/include/pcl/apps/cloud_composer/point_selectors/selection_event.h +++ b/apps/cloud_composer/include/pcl/apps/cloud_composer/point_selectors/selection_event.h @@ -39,68 +39,57 @@ #include +#include +#include #include #include -#include #include -#include - -namespace pcl { -namespace cloud_composer { -class RectangularFrustumSelector; - -class SelectionEvent { - -public: - SelectionEvent(vtkSmartPointer selected_points, - vtkSmartPointer selected_actor, - vtkSmartPointer selected_mapper, - QMap id_selected_map, - vtkRenderer* renderer) - : selected_points_(std::move(selected_points)) - , selected_actor_(std::move(selected_actor)) - , selected_mapper_(std::move(selected_mapper)) - , id_selected_data_map_(std::move(id_selected_map)) - , renderer_(renderer) - {} - - ~SelectionEvent(); - - inline vtkIdType - getNumPoints() const - { - return selected_points_->GetNumberOfPoints(); - } - vtkSmartPointer - getPolyData() const +namespace pcl +{ + namespace cloud_composer { - return selected_points_; + class RectangularFrustumSelector; + + class SelectionEvent + { + + public: + SelectionEvent (vtkSmartPointer selected_points, vtkSmartPointer selected_actor, vtkSmartPointer selected_mapper, QMap < QString, vtkPolyData* > id_selected_map, vtkRenderer* renderer) + : selected_points_ (std::move(selected_points)) + , selected_actor_ (std::move(selected_actor)) + , selected_mapper_ (std::move(selected_mapper)) + , id_selected_data_map_ (std::move(id_selected_map)) + , renderer_ (renderer) + {} + + ~SelectionEvent (); + + inline vtkIdType + getNumPoints () const { return selected_points_->GetNumberOfPoints (); } + + vtkSmartPointer + getPolyData () const { return selected_points_; } + + vtkSmartPointer + getMapper () const { return selected_mapper_; } + + vtkSmartPointer + getActor () const { return selected_actor_; } + + void + findIndicesInItem (CloudItem* cloud_item, const pcl::PointIndices::Ptr& indices); + + private: + + vtkSmartPointer selected_points_; + vtkSmartPointer selected_actor_; + vtkSmartPointer selected_mapper_; + QMap < QString, vtkPolyData* > id_selected_data_map_; + vtkRenderer* renderer_; + + }; + } - - vtkSmartPointer - getMapper() const - { - return selected_mapper_; - } - - vtkSmartPointer - getActor() const - { - return selected_actor_; - } - - void - findIndicesInItem(CloudItem* cloud_item, const pcl::PointIndices::Ptr& indices); - -private: - vtkSmartPointer selected_points_; - vtkSmartPointer selected_actor_; - vtkSmartPointer selected_mapper_; - QMap id_selected_data_map_; - vtkRenderer* renderer_; -}; - -} // namespace cloud_composer - -} // namespace pcl + +} diff --git a/apps/cloud_composer/include/pcl/apps/cloud_composer/project_model.h b/apps/cloud_composer/include/pcl/apps/cloud_composer/project_model.h index dd6c7094563..d4b30999923 100644 --- a/apps/cloud_composer/include/pcl/apps/cloud_composer/project_model.h +++ b/apps/cloud_composer/include/pcl/apps/cloud_composer/project_model.h @@ -37,179 +37,175 @@ #pragma once +#include +#include + +#include + #include -#include +#include #include -#include -#include +#include #include -#include -#include - class QItemSelection; class QItemSelectionModel; -namespace pcl { -namespace cloud_composer { -class CloudCommand; -class AbstractTool; -class WorkQueue; -class CloudComposerItem; -class CloudView; -class InteractorStyleSwitch; - -class ProjectModel : public QStandardItemModel { - Q_OBJECT - -public: - ProjectModel(QObject* parent = nullptr); - ProjectModel(const ProjectModel& to_copy); - ~ProjectModel() override; - - ProjectModel(QString project_name, QObject* parent = nullptr); - - inline const QString - getName() - { - return horizontalHeaderItem(0)->text(); - } - - inline QUndoStack* - getUndoStack() +namespace pcl +{ + namespace cloud_composer { - return undo_stack_; + class CloudCommand; + class AbstractTool; + class WorkQueue; + class CloudComposerItem; + class CloudView; + class InteractorStyleSwitch; + + class ProjectModel : public QStandardItemModel + { + Q_OBJECT + + public: + ProjectModel (QObject *parent = nullptr); + ProjectModel (const ProjectModel& to_copy); + ~ProjectModel (); + + ProjectModel (QString project_name, QObject *parent = nullptr); + + inline const QString + getName () { return horizontalHeaderItem (0)->text (); } + + inline QUndoStack* + getUndoStack () { return undo_stack_; } + + /** \brief Sets the name of the project using the horizontalHeaderItem */ + void + setName (const QString& new_name); + + /** \brief Returns the selection model which is used for this project */ + inline QItemSelectionModel* + getSelectionModel () + { + return selection_model_; + } + + + + /** \brief Takes tool object issues signal to work queue to take control of it */ + void + enqueueToolAction (AbstractTool* tool); + + /** \brief Helper function which inserts the item into this model and makes connections for properties */ + void + insertNewCloudComposerItem (CloudComposerItem* new_item, QStandardItem* parent_item); + + /** \brief Sets the CloudView that this project is rendering in */ + void + setCloudView (CloudView* view); + + /** \brief This sets the selection for points which have been selected in the QVTKWindow */ + void + setPointSelection (const std::shared_ptr& selected_event); + + /** \brief This is invoked to perform the manipulations specified on the model */ + void + manipulateClouds (const std::shared_ptr& manip_event); + public Q_SLOTS: + void + commandCompleted (CloudCommand* command); + + void + clearSelection (); + + void + deleteSelectedItems (); + + /** \brief Loads from file and inserts a new pointcloud into the model */ + void + insertNewCloudFromFile (); + + /** \brief Loads from rgb and depth file and inserts a new pointcloud into the model */ + void + insertNewCloudFromRGBandDepth (); + + /** \brief Opens a file dialog and saves selected cloud to file */ + void + saveSelectedCloudToFile (); + + /** \brief This emits all the state signals, which updates the GUI action button status (enabled/disabled)" */ + void + emitAllStateSignals (); + + /** \brief This sets whether the CloudView for this project shows axes */ + void + setAxisVisibility (bool visible); + + /** \brief Slot called when the mouse style selected in the GUI changes */ + void + mouseStyleChanged (QAction* new_style_action); + + /** \brief Slot Called whenever the item selection_model_ changes */ + void + itemSelectionChanged ( const QItemSelection &, const QItemSelection &); + + /** \brief Creates a new cloud from the selected items and points */ + void + createNewCloudFromSelection (); + + /** \brief Selects all items in the model */ + void + selectAllItems (QStandardItem* item = nullptr ); + Q_SIGNALS: + void + enqueueNewAction (AbstractTool* tool, ConstItemList data); + + /** \brief Catch-all signal emitted whenever the model changes */ + void + modelChanged (); + + void + axisVisible (const bool axis_visible); + + void + deleteAvailable (bool can_delete); + + void + newCloudFromSelectionAvailable (bool can_create); + + void + mouseStyleState (interactor_styles::INTERACTOR_STYLES); + + private: + /** \brief Checks to see if selection contains only CloudItem s */ + bool + onlyCloudItemsSelected (); + + QItemSelectionModel* selection_model_; + QMap name_to_type_map_; + QUndoStack* undo_stack_; + WorkQueue* work_queue_; + QThread* work_thread_; + CloudView* cloud_view_; + + /** \brief Stores last directory used in file read/write operations */ + QDir last_directory_; + + //Variables for toggle action status + bool axis_visible_; + QMap selected_style_map_; + /** \brief Internal helper function for updating map */ + void + setSelectedStyle (interactor_styles::INTERACTOR_STYLES style); + + /** \brief Internal pointer storing the last selection event arriving from vtk */ + std::shared_ptr selection_event_; + /** \brief Map which stores which cloud items and indices were selected in the selection_event_ */ + QMap selected_item_index_map_; + }; } +} - /** \brief Sets the name of the project using the horizontalHeaderItem */ - void - setName(const QString& new_name); - - /** \brief Returns the selection model which is used for this project */ - inline QItemSelectionModel* - getSelectionModel() - { - return selection_model_; - } - - /** \brief Takes tool object issues signal to work queue to take control of it */ - void - enqueueToolAction(AbstractTool* tool); - - /** \brief Helper function which inserts the item into this model and makes - * connections for properties */ - void - insertNewCloudComposerItem(CloudComposerItem* new_item, QStandardItem* parent_item); - - /** \brief Sets the CloudView that this project is rendering in */ - void - setCloudView(CloudView* view); - - /** \brief This sets the selection for points which have been selected in the - * QVTKWindow */ - void - setPointSelection(const std::shared_ptr& selected_event); - - /** \brief This is invoked to perform the manipulations specified on the model */ - void - manipulateClouds(const std::shared_ptr& manip_event); -public Q_SLOTS: - void - commandCompleted(CloudCommand* command); - - void - clearSelection(); - - void - deleteSelectedItems(); - - /** \brief Loads from file and inserts a new pointcloud into the model */ - void - insertNewCloudFromFile(); - - /** \brief Loads from rgb and depth file and inserts a new pointcloud into the model - */ - void - insertNewCloudFromRGBandDepth(); - - /** \brief Opens a file dialog and saves selected cloud to file */ - void - saveSelectedCloudToFile(); - - /** \brief This emits all the state signals, which updates the GUI action button - * status (enabled/disabled)" */ - void - emitAllStateSignals(); - - /** \brief This sets whether the CloudView for this project shows axes */ - void - setAxisVisibility(bool visible); - - /** \brief Slot called when the mouse style selected in the GUI changes */ - void - mouseStyleChanged(QAction* new_style_action); - - /** \brief Slot Called whenever the item selection_model_ changes */ - void - itemSelectionChanged(const QItemSelection&, const QItemSelection&); - - /** \brief Creates a new cloud from the selected items and points */ - void - createNewCloudFromSelection(); - - /** \brief Selects all items in the model */ - void - selectAllItems(QStandardItem* item = nullptr); -Q_SIGNALS: - void - enqueueNewAction(AbstractTool* tool, ConstItemList data); - - /** \brief Catch-all signal emitted whenever the model changes */ - void - modelChanged(); - - void - axisVisible(const bool axis_visible); - - void - deleteAvailable(bool can_delete); - - void - newCloudFromSelectionAvailable(bool can_create); - - void mouseStyleState(interactor_styles::INTERACTOR_STYLES); - -private: - /** \brief Checks to see if selection contains only CloudItem s */ - bool - onlyCloudItemsSelected(); - - QItemSelectionModel* selection_model_; - QMap name_to_type_map_; - QUndoStack* undo_stack_; - WorkQueue* work_queue_; - QThread* work_thread_; - CloudView* cloud_view_; - - /** \brief Stores last directory used in file read/write operations */ - QDir last_directory_; - - // Variables for toggle action status - bool axis_visible_; - QMap selected_style_map_; - /** \brief Internal helper function for updating map */ - void - setSelectedStyle(interactor_styles::INTERACTOR_STYLES style); - - /** \brief Internal pointer storing the last selection event arriving from vtk */ - std::shared_ptr selection_event_; - /** \brief Map which stores which cloud items and indices were selected in the - * selection_event_ */ - QMap selected_item_index_map_; -}; -} // namespace cloud_composer -} // namespace pcl - -Q_DECLARE_METATYPE(pcl::cloud_composer::ProjectModel); -Q_DECLARE_METATYPE(pcl::cloud_composer::interactor_styles::INTERACTOR_STYLES); +Q_DECLARE_METATYPE (pcl::cloud_composer::ProjectModel); +Q_DECLARE_METATYPE (pcl::cloud_composer::interactor_styles::INTERACTOR_STYLES); diff --git a/apps/cloud_composer/include/pcl/apps/cloud_composer/properties_model.h b/apps/cloud_composer/include/pcl/apps/cloud_composer/properties_model.h index a4747ca42a5..57460d14062 100644 --- a/apps/cloud_composer/include/pcl/apps/cloud_composer/properties_model.h +++ b/apps/cloud_composer/include/pcl/apps/cloud_composer/properties_model.h @@ -39,50 +39,52 @@ #include -namespace pcl { -namespace cloud_composer { -class CloudComposerItem; -class PropertiesModel : public QStandardItemModel { - Q_OBJECT -public: - /** \brief Constructor used for tool parameters */ - PropertiesModel(QObject* parent = nullptr); - /** \brief Constructor used for item parameters */ - PropertiesModel(CloudComposerItem* parent_item, QObject* parent = nullptr); - PropertiesModel(const PropertiesModel& to_copy); +namespace pcl +{ + namespace cloud_composer + { + class CloudComposerItem; + class PropertiesModel : public QStandardItemModel + { + Q_OBJECT + public: + + /** \brief Constructor used for tool parameters */ + PropertiesModel (QObject *parent = nullptr); + /** \brief Constructor used for item parameters */ + PropertiesModel (CloudComposerItem* parent_item, QObject *parent = nullptr); + PropertiesModel (const PropertiesModel& to_copy); + + /** \brief Helper function for adding a new property */ + void + addProperty (const QString& prop_name, const QVariant& value, const Qt::ItemFlags flags = Qt::ItemIsSelectable, const QString& category = ""); + + /** \brief Helper function for adding a new property category */ + void + addCategory (const QString& category_name); + + /** \brief Helper function to get a property */ + QVariant + getProperty (const QString& prop_name) const; + + void + copyProperties (const PropertiesModel* to_copy); + + public Q_SLOTS: + void + propertyChanged (QStandardItem* property_item); + + Q_SIGNALS: + void + propertyChanged (const QStandardItem* property_item, const CloudComposerItem* parent_item_); + + + private: + CloudComposerItem* parent_item_; + + }; + } +} - /** \brief Helper function for adding a new property */ - void - addProperty(const QString& prop_name, - const QVariant& value, - const Qt::ItemFlags flags = Qt::ItemIsSelectable, - const QString& category = ""); - - /** \brief Helper function for adding a new property category */ - void - addCategory(const QString& category_name); - - /** \brief Helper function to get a property */ - QVariant - getProperty(const QString& prop_name) const; - - void - copyProperties(const PropertiesModel* to_copy); - -public Q_SLOTS: - void - propertyChanged(QStandardItem* property_item); - -Q_SIGNALS: - void - propertyChanged(const QStandardItem* property_item, - const CloudComposerItem* parent_item_); - -private: - CloudComposerItem* parent_item_; -}; -} // namespace cloud_composer -} // namespace pcl - -Q_DECLARE_METATYPE(pcl::cloud_composer::PropertiesModel); -Q_DECLARE_METATYPE(pcl::cloud_composer::PropertiesModel*); +Q_DECLARE_METATYPE (pcl::cloud_composer::PropertiesModel); +Q_DECLARE_METATYPE (pcl::cloud_composer::PropertiesModel*); diff --git a/apps/cloud_composer/include/pcl/apps/cloud_composer/signal_multiplexer.h b/apps/cloud_composer/include/pcl/apps/cloud_composer/signal_multiplexer.h index 4e27838b25a..c8a5224f524 100644 --- a/apps/cloud_composer/include/pcl/apps/cloud_composer/signal_multiplexer.h +++ b/apps/cloud_composer/include/pcl/apps/cloud_composer/signal_multiplexer.h @@ -1,12 +1,12 @@ /* * Software License Agreement (BSD License) * - * + * * Class to multiplex signal and slot connections. Qt 3 code from: * http://doc.trolltech.com/qq/qq08-action-multiplexer.html. * Converted to Qt 4 by a.somers@rathenau.nl. - * Modified for use in cloud_composer by jpapon@gmail.com - * + * Modified for use in cloud_composer by jpapon@gmail.com + * * Point Cloud Library (PCL) - www.pointclouds.org * * All rights reserved. @@ -46,105 +46,106 @@ #include #include -namespace pcl { -namespace cloud_composer { -class SignalMultiplexer : public QObject { - Q_OBJECT - -public: - SignalMultiplexer(QObject* parent = nullptr); - - /** - Use this connect function instead of QObject::connect() to connect - an actions activation signal to the receiving, multiplexed object. - - @param sender the sending action or object - @param signal the signal in the sender object that is connected to - @param slot the slot in the receiving object that is set through @ref - setCurrentObject that the signal should be connected to. - - @see connect(const char *signal, QObject *receiver, const char *slot) - @see disconnect(QObject *sender, const char *signal, const char *slot) - */ - void - connect(QObject* sender, const char* signal, const char* slot); - - /** - Disconnects a signal connection from a sending object to a multiplexed - receiving object. - @see connect(const char *signal, QObject *receiver, const char *slot) - */ - bool - disconnect(QObject* sender, const char* signal, const char* slot); - - /** - Use this connect function instead of QObject::connect() to connect - a multiplexed object's (status) signal to an action object's slot. - - @param signal the signal in the multiplexed sender object that is set through - @ref setCurrentObject that the connection should be from - @param receiver the receiving action or object - @param slot the slot in the receiving object - - @see connect(QObject *sender, const char *signal, const char *slot) - @see disconnect(const char *signal, QObject *receiver, const char *slot) - */ - void - connect(const char* signal, QObject* receiver, const char* slot); - - /** - Disconnects a signal from a multiplexed object to a receiving (action) - object. - @see connect(const char *signal, QObject *receiver, const char *slot) - */ - bool - disconnect(const char* signal, QObject* receiver, const char* slot); - - /** - @returns the object the connections are currently made with. - */ - QObject* - currentObject() const +namespace pcl +{ + namespace cloud_composer { - return object; + class SignalMultiplexer : public QObject + { + Q_OBJECT + + public: + SignalMultiplexer(QObject *parent = nullptr); + + /** + Use this connect function instead of QObject::connect() to connect + an actions activation signal to the receiving, multiplexed object. + + @param sender the sending action or object + @param signal the signal in the sender object that is connected to + @param slot the slot in the receiving object that is set through @ref + setCurrentObject that the signal should be connected to. + + @see connect(const char *signal, QObject *receiver, const char *slot) + @see disconnect(QObject *sender, const char *signal, const char *slot) + */ + void + connect (QObject *sender, const char *signal, const char *slot); + + /** + Disconnects a signal connection from a sending object to a multiplexed + receiving object. + @see connect(const char *signal, QObject *receiver, const char *slot) + */ + bool + disconnect (QObject *sender, const char *signal, const char *slot); + + /** + Use this connect function instead of QObject::connect() to connect + a multiplexed object's (status) signal to an action object's slot. + + @param signal the signal in the multiplexed sender object that is set through + @ref setCurrentObject that the connection should be from + @param receiver the receiving action or object + @param slot the slot in the receiving object + + @see connect(QObject *sender, const char *signal, const char *slot) + @see disconnect(const char *signal, QObject *receiver, const char *slot) + */ + void + connect (const char *signal, QObject *receiver, const char *slot); + + /** + Disconnects a signal from a multiplexed object to a receiving (action) + object. + @see connect(const char *signal, QObject *receiver, const char *slot) + */ + bool + disconnect (const char *signal, QObject *receiver, const char *slot); + + /** + @returns the object the connections are currently made with. + */ + QObject + *currentObject () const { return object; } + + public Q_SLOTS: + /** + Sets the current object the signals that are managed by the + SignalMultiplexer instance should be connected to. Any connections + of these signals to the previous object will be disconnected. + After the connections are hooked to the new object, the + @ref currentObjectChanged signal will be emitted. + + @param newObject the new object that the signals should be connected to + */ + void + setCurrentObject (QObject *newObject); + + Q_SIGNALS: + /** + Emitted when a new object is set to receive the signals managed by + this SignalMultiplexer instance. + */ + void + currentObjectChanged (QObject* newObject); + + private: + struct Connection + { + QPointer sender; + QPointer receiver; + const char *signal; + const char *slot; + }; + + void + connect (const Connection &conn); + void + disconnect (const Connection &conn); + + QPointer object; + QList connections; + }; } - -public Q_SLOTS: - /** - Sets the current object the signals that are managed by the - SignalMultiplexer instance should be connected to. Any connections - of these signals to the previous object will be disconnected. - After the connections are hooked to the new object, the - @ref currentObjectChanged signal will be emitted. - - @param newObject the new object that the signals should be connected to - */ - void - setCurrentObject(QObject* newObject); - -Q_SIGNALS: - /** - Emitted when a new object is set to receive the signals managed by - this SignalMultiplexer instance. - */ - void - currentObjectChanged(QObject* newObject); - -private: - struct Connection { - QPointer sender; - QPointer receiver; - const char* signal; - const char* slot; - }; - - void - connect(const Connection& conn); - void - disconnect(const Connection& conn); - - QPointer object; - QList connections; -}; -} // namespace cloud_composer -} // namespace pcl +} diff --git a/apps/cloud_composer/include/pcl/apps/cloud_composer/tool_interface/abstract_tool.h b/apps/cloud_composer/include/pcl/apps/cloud_composer/tool_interface/abstract_tool.h index aac5565ef4c..1eb18eaf1a0 100644 --- a/apps/cloud_composer/include/pcl/apps/cloud_composer/tool_interface/abstract_tool.h +++ b/apps/cloud_composer/include/pcl/apps/cloud_composer/tool_interface/abstract_tool.h @@ -43,145 +43,137 @@ #include -namespace pcl { -namespace cloud_composer { - -class AbstractTool : public QObject { - Q_OBJECT -public: - AbstractTool(PropertiesModel* parameter_model, QObject* parent); - - ~AbstractTool() override { qDebug() << "Tool Destructed"; } - - /** \brief Function called which does work in plugin - * \param data input_data from the model - const for good reason - * Returned list will become the output, replacing input_data in the model - you must - * deep copy the input_data, since undo works by switching back and forth - */ - virtual QList - performAction(QList input_data, - PointTypeFlags::PointType type = PointTypeFlags::NONE) = 0; - - virtual CloudCommand* - createCommand(QList input_data) = 0; - - QString - getActionText() const - { - return action_text_; - } - - void - setActionText(const QString& text) - { - action_text_ = text; - } - - virtual QString - getToolName() const = 0; - -protected: - PropertiesModel* parameter_model_; - -private: - QString action_text_; -}; - -class ModifyItemTool : public AbstractTool { - Q_OBJECT -public: - ModifyItemTool(PropertiesModel* parameter_model, QObject* parent) - : AbstractTool(parameter_model, parent) - {} - - QList - performAction(QList input_data, - PointTypeFlags::PointType type = PointTypeFlags::NONE) override = 0; - - inline CloudCommand* - createCommand(QList input_data) override +namespace pcl +{ + namespace cloud_composer { - return new ModifyItemCommand(input_data); - } + + + class AbstractTool : public QObject + { + Q_OBJECT + public: + + AbstractTool (PropertiesModel* parameter_model, QObject* parent); + + ~AbstractTool () { qDebug() << "Tool Destructed"; } + + /** \brief Function called which does work in plugin + * \param data input_data from the model - const for good reason + * Returned list will become the output, replacing input_data in the model - you must deep copy + * the input_data, since undo works by switching back and forth + */ + virtual QList + performAction (QList input_data, PointTypeFlags::PointType type = PointTypeFlags::NONE) = 0; + + virtual CloudCommand* + createCommand (QList input_data) = 0; + + QString + getActionText () const {return action_text_;} + + void + setActionText (const QString& text) { action_text_ = text; } + + virtual QString + getToolName () const = 0; + + protected: + + PropertiesModel* parameter_model_; + + private: + QString action_text_; + + }; + + class ModifyItemTool : public AbstractTool + { + Q_OBJECT + public: + ModifyItemTool (PropertiesModel* parameter_model, QObject* parent) + : AbstractTool (parameter_model, parent) + {} + + QList + performAction (QList input_data, PointTypeFlags::PointType type = PointTypeFlags::NONE) override = 0; + + inline CloudCommand* + createCommand (QList input_data) override + { + return new ModifyItemCommand (input_data); + } + + inline QString + getToolName () const override { return "ModifyItemTool";} + + }; + + class NewItemTool : public AbstractTool + { + Q_OBJECT + public: + NewItemTool (PropertiesModel* parameter_model, QObject* parent) + : AbstractTool (parameter_model, parent) + {} + + QList + performAction (QList input_data, PointTypeFlags::PointType type = PointTypeFlags::NONE) override = 0; + + inline CloudCommand* + createCommand (QList input_data) override + { + return new NewItemCloudCommand (input_data); + } + + inline QString + getToolName () const override { return "NewItemTool";} + + }; + + class SplitItemTool : public AbstractTool + { + Q_OBJECT + public: + SplitItemTool (PropertiesModel* parameter_model, QObject* parent) + : AbstractTool (parameter_model, parent) + {} + + QList + performAction (QList input_data, PointTypeFlags::PointType type = PointTypeFlags::NONE) override = 0; + + inline CloudCommand* + createCommand (QList input_data) override + { + return new SplitCloudCommand (input_data); + } + + inline QString + getToolName () const override { return "SplitItemTool";} + + }; + + class MergeCloudTool : public AbstractTool + { + Q_OBJECT + public: + MergeCloudTool (PropertiesModel* parameter_model, QObject* parent) + : AbstractTool (parameter_model, parent) + {} + + QList + performAction (QList input_data, PointTypeFlags::PointType type = PointTypeFlags::NONE) override = 0; + + inline CloudCommand* + createCommand (QList input_data) override + { + return new MergeCloudCommand (input_data); + } + + inline QString + getToolName () const override { return "MergeCloudTool";} + + }; - inline QString - getToolName() const override - { - return "ModifyItemTool"; } -}; - -class NewItemTool : public AbstractTool { - Q_OBJECT -public: - NewItemTool(PropertiesModel* parameter_model, QObject* parent) - : AbstractTool(parameter_model, parent) - {} - - QList - performAction(QList input_data, - PointTypeFlags::PointType type = PointTypeFlags::NONE) override = 0; - - inline CloudCommand* - createCommand(QList input_data) override - { - return new NewItemCloudCommand(input_data); - } - - inline QString - getToolName() const override - { - return "NewItemTool"; - } -}; - -class SplitItemTool : public AbstractTool { - Q_OBJECT -public: - SplitItemTool(PropertiesModel* parameter_model, QObject* parent) - : AbstractTool(parameter_model, parent) - {} - - QList - performAction(QList input_data, - PointTypeFlags::PointType type = PointTypeFlags::NONE) override = 0; - - inline CloudCommand* - createCommand(QList input_data) override - { - return new SplitCloudCommand(input_data); - } - - inline QString - getToolName() const override - { - return "SplitItemTool"; - } -}; - -class MergeCloudTool : public AbstractTool { - Q_OBJECT -public: - MergeCloudTool(PropertiesModel* parameter_model, QObject* parent) - : AbstractTool(parameter_model, parent) - {} - - QList - performAction(QList input_data, - PointTypeFlags::PointType type = PointTypeFlags::NONE) override = 0; - - inline CloudCommand* - createCommand(QList input_data) override - { - return new MergeCloudCommand(input_data); - } - - inline QString - getToolName() const override - { - return "MergeCloudTool"; - } -}; - -} // namespace cloud_composer -} // namespace pcl +} diff --git a/apps/cloud_composer/include/pcl/apps/cloud_composer/tool_interface/tool_factory.h b/apps/cloud_composer/include/pcl/apps/cloud_composer/tool_interface/tool_factory.h index a8a7a242fdb..65781efadcd 100644 --- a/apps/cloud_composer/include/pcl/apps/cloud_composer/tool_interface/tool_factory.h +++ b/apps/cloud_composer/include/pcl/apps/cloud_composer/tool_interface/tool_factory.h @@ -41,52 +41,55 @@ class QAction; -namespace pcl { -namespace cloud_composer { - -class AbstractTool; -class AbstractCommand; -class PropertiesModel; - -class ToolFactory { -public: - virtual AbstractTool* - createTool(PropertiesModel* parameter_model = nullptr, QObject* parent = nullptr) = 0; - - virtual PropertiesModel* - createToolParameterModel(QObject* parent) = 0; - - virtual QString - getPluginName() const = 0; - - virtual QString - getToolGroupName() const = 0; - - virtual QString - getIconName() const = 0; - - /** \brief Reimplement this function to return the proper number if tool requires more - * than one input item */ - inline virtual int - getNumInputItems() const +namespace pcl +{ + namespace cloud_composer { - return 1; - } - - /** \brief Returns a list of allowed input item types. Implement in tools so GUI can - * prevent impossible actions */ - virtual CloudComposerItem::ItemType - getInputItemType() const = 0; + + + class AbstractTool; + class AbstractCommand; + class PropertiesModel; + + class ToolFactory + { + public: + virtual AbstractTool* + createTool (PropertiesModel* parameter_model = nullptr, QObject* parent = nullptr) = 0; + + virtual PropertiesModel* + createToolParameterModel (QObject* parent) = 0; + + virtual QString + getPluginName () const = 0; + + virtual QString + getToolGroupName () const = 0; + + virtual QString + getIconName () const = 0; + + /** \brief Reimplement this function to return the proper number if tool requires more than one input item */ + inline virtual int + getNumInputItems () const + { + return 1; + } + + /** \brief Returns a list of allowed input item types. Implement in tools so GUI can prevent impossible actions */ + virtual CloudComposerItem::ItemType + getInputItemType () const = 0; + + /** \brief Returns a list of required input children. Implement in tools so GUI can prevent impossible actions */ + virtual QList + getRequiredInputChildrenTypes () const = 0; + + }; - /** \brief Returns a list of required input children. Implement in tools so GUI can - * prevent impossible actions */ - virtual QList - getRequiredInputChildrenTypes() const = 0; -}; - -} // namespace cloud_composer -} // namespace pcl + } +} -Q_DECLARE_METATYPE(pcl::cloud_composer::ToolFactory*); +Q_DECLARE_METATYPE (pcl::cloud_composer::ToolFactory*); -Q_DECLARE_INTERFACE(pcl::cloud_composer::ToolFactory, "cloud_composer.ToolFactory/1.0") +Q_DECLARE_INTERFACE(pcl::cloud_composer::ToolFactory, + "cloud_composer.ToolFactory/1.0") diff --git a/apps/cloud_composer/include/pcl/apps/cloud_composer/toolbox_model.h b/apps/cloud_composer/include/pcl/apps/cloud_composer/toolbox_model.h index 377bf94ce7c..0121b56be5d 100644 --- a/apps/cloud_composer/include/pcl/apps/cloud_composer/toolbox_model.h +++ b/apps/cloud_composer/include/pcl/apps/cloud_composer/toolbox_model.h @@ -44,7 +44,8 @@ class QItemSelection; class QItemSelectionModel; class QTreeView; -enum TOOLBOX_ROLES { +enum TOOLBOX_ROLES +{ FACTORY = Qt::UserRole, PARAMETER_MODEL, ALLOWED_INPUT_ITEM_TYPES, @@ -52,72 +53,71 @@ enum TOOLBOX_ROLES { }; class QTreeView; -namespace pcl { -namespace cloud_composer { - -class CloudCommand; -class AbstractTool; -class ToolFactory; -class ProjectModel; - -class ToolBoxModel : public QStandardItemModel { - Q_OBJECT - -public: - ToolBoxModel(QTreeView* tool_view = nullptr, - QTreeView* parameter_view = nullptr, - QObject* parent = nullptr); - ToolBoxModel(const ToolBoxModel& to_copy); - - void - addTool(ToolFactory* tool_factory); - - void - setSelectionModel(QItemSelectionModel* selection_model); - - /** \brief Enables/Disables Tools based on currently selected items from model */ - void - updateEnabledTools(const QItemSelection& current_selection); - - void - enableAllTools(); - -public Q_SLOTS: - void - activeProjectChanged(ProjectModel* new_model, ProjectModel* previous_model); - - void - selectedToolChanged(const QModelIndex& current, const QModelIndex& previous); - - void - toolAction(); - - /** \brief This slot is called when the selection in cloud browser changes. Updates - * enabling of tools */ - void - selectedItemChanged(const QItemSelection& selected, const QItemSelection& deselected); - - /** \brief This slot is called whenever the current project model emits layoutChanged, - * and calls updateEnabledTools */ - void - modelChanged(); -Q_SIGNALS: - void - enqueueToolAction(AbstractTool* tool); - -private: - QStandardItem* - addToolGroup(const QString& tool_group_name); - - QTreeView* tool_view_; - QTreeView* parameter_view_; - QItemSelectionModel* selection_model_; - QSet tool_items; - - ProjectModel* project_model_{nullptr}; -}; -} // namespace cloud_composer -} // namespace pcl - -Q_DECLARE_METATYPE(pcl::cloud_composer::ToolBoxModel); -Q_DECLARE_METATYPE(QStandardItemModel*); +namespace pcl +{ + namespace cloud_composer + { + + class CloudCommand; + class AbstractTool; + class ToolFactory; + class ProjectModel; + + class ToolBoxModel : public QStandardItemModel + { + Q_OBJECT + + public: + ToolBoxModel (QTreeView* tool_view = nullptr, QTreeView* parameter_view = nullptr, QObject *parent = nullptr); + ToolBoxModel (const ToolBoxModel& to_copy); + + void + addTool (ToolFactory* tool_factory); + + void + setSelectionModel (QItemSelectionModel* selection_model); + + /** \brief Enables/Disables Tools based on currently selected items from model */ + void + updateEnabledTools (const QItemSelection& current_selection); + + void + enableAllTools (); + + public Q_SLOTS: + void + activeProjectChanged (ProjectModel* new_model, ProjectModel* previous_model); + + void + selectedToolChanged (const QModelIndex & current, const QModelIndex & previous); + + void + toolAction (); + + /** \brief This slot is called when the selection in cloud browser changes. Updates enabling of tools */ + void + selectedItemChanged ( const QItemSelection & selected, const QItemSelection & deselected ); + + /** \brief This slot is called whenever the current project model emits layoutChanged, and calls updateEnabledTools */ + void + modelChanged (); + Q_SIGNALS: + void + enqueueToolAction (AbstractTool* tool); + + private: + QStandardItem* + addToolGroup (const QString& tool_group_name); + + QTreeView* tool_view_; + QTreeView* parameter_view_; + QItemSelectionModel* selection_model_; + QSet tool_items; + + ProjectModel* project_model_; + }; + } +} + +Q_DECLARE_METATYPE (pcl::cloud_composer::ToolBoxModel); +Q_DECLARE_METATYPE (QStandardItemModel*); diff --git a/apps/cloud_composer/include/pcl/apps/cloud_composer/tools/euclidean_clustering.h b/apps/cloud_composer/include/pcl/apps/cloud_composer/tools/euclidean_clustering.h index cc886e279ca..9a9e82d75ec 100644 --- a/apps/cloud_composer/include/pcl/apps/cloud_composer/tools/euclidean_clustering.h +++ b/apps/cloud_composer/include/pcl/apps/cloud_composer/tools/euclidean_clustering.h @@ -40,68 +40,62 @@ #include #include -namespace pcl { -namespace cloud_composer { -class EuclideanClusteringTool : public SplitItemTool { - Q_OBJECT -public: - EuclideanClusteringTool(PropertiesModel* parameter_model, QObject* parent); - - QList - performAction(QList input_data, - PointTypeFlags::PointType type = PointTypeFlags::NONE) override; - - inline QString - getToolName() const override - { - return "Euclidean Clustering Tool"; - } -}; - -class EuclideanClusteringToolFactory : public QObject, public ToolFactory { - Q_OBJECT - Q_INTERFACES(pcl::cloud_composer::ToolFactory) - Q_PLUGIN_METADATA(IID "cloud_composer.ToolFactory/1.0") -public: - SplitItemTool* - createTool(PropertiesModel* parameter_model, QObject* parent = nullptr) override - { - return new EuclideanClusteringTool(parameter_model, parent); - } - - PropertiesModel* - createToolParameterModel(QObject* parent) override; - - inline QString - getPluginName() const override +namespace pcl +{ + namespace cloud_composer { - return "Euclidean Clustering"; - } + class EuclideanClusteringTool : public SplitItemTool + { + Q_OBJECT + public: + EuclideanClusteringTool (PropertiesModel* parameter_model, QObject* parent); + + QList + performAction (QList input_data, PointTypeFlags::PointType type = PointTypeFlags::NONE) override; + + inline QString + getToolName () const override { return "Euclidean Clustering Tool";} + }; - inline QString - getToolGroupName() const override - { - return "Segmentation"; - } + + class EuclideanClusteringToolFactory : public QObject, public ToolFactory + { + Q_OBJECT + Q_INTERFACES (pcl::cloud_composer::ToolFactory) + Q_PLUGIN_METADATA(IID "cloud_composer.ToolFactory/1.0") + public: + SplitItemTool* + createTool (PropertiesModel* parameter_model, QObject* parent = nullptr) override + { + return new EuclideanClusteringTool(parameter_model, parent); + } + + PropertiesModel* + createToolParameterModel (QObject* parent) override; + + inline QString + getPluginName () const override { return "Euclidean Clustering";} + + inline QString + getToolGroupName () const override { return "Segmentation";} + + inline QString + getIconName () const override { return ":/euclidean_clustering.png"; } + + inline CloudComposerItem::ItemType + getInputItemType () const override + { + return CloudComposerItem::CLOUD_ITEM; + } + + inline QList + getRequiredInputChildrenTypes () const override + { + return QList (); + } + }; - inline QString - getIconName() const override - { - return ":/euclidean_clustering.png"; - } - inline CloudComposerItem::ItemType - getInputItemType() const override - { - return CloudComposerItem::CLOUD_ITEM; - } - inline QList - getRequiredInputChildrenTypes() const override - { - return {}; } -}; - -} // namespace cloud_composer -} // namespace pcl +} diff --git a/apps/cloud_composer/include/pcl/apps/cloud_composer/tools/fpfh_estimation.h b/apps/cloud_composer/include/pcl/apps/cloud_composer/tools/fpfh_estimation.h index 35210217fb9..10287e4c1aa 100644 --- a/apps/cloud_composer/include/pcl/apps/cloud_composer/tools/fpfh_estimation.h +++ b/apps/cloud_composer/include/pcl/apps/cloud_composer/tools/fpfh_estimation.h @@ -40,70 +40,64 @@ #include #include -namespace pcl { -namespace cloud_composer { - -class FPFHEstimationTool : public NewItemTool { - Q_OBJECT -public: - FPFHEstimationTool(PropertiesModel* parameter_model, QObject* parent); - - QList - performAction(QList input_data, - PointTypeFlags::PointType type = PointTypeFlags::NONE) override; - - inline QString - getToolName() const override +namespace pcl +{ + namespace cloud_composer { - return "FPFH Estimation Tool"; - } -}; + + class FPFHEstimationTool : public NewItemTool + { + Q_OBJECT + public: + FPFHEstimationTool (PropertiesModel* parameter_model, QObject* parent); + + QList + performAction (QList input_data, PointTypeFlags::PointType type = PointTypeFlags::NONE) override; + + inline QString + getToolName () const override { return "FPFH Estimation Tool";} + }; -class FPFHEstimationToolFactory : public QObject, public ToolFactory { - Q_OBJECT - Q_INTERFACES(pcl::cloud_composer::ToolFactory) - Q_PLUGIN_METADATA(IID "cloud_composer.ToolFactory/1.0") -public: - NewItemTool* - createTool(PropertiesModel* parameter_model, QObject* parent = nullptr) override - { - return new FPFHEstimationTool(parameter_model, parent); - } + + class FPFHEstimationToolFactory : public QObject, public ToolFactory + { + Q_OBJECT + Q_INTERFACES (pcl::cloud_composer::ToolFactory) + Q_PLUGIN_METADATA(IID "cloud_composer.ToolFactory/1.0") + public: + NewItemTool* + createTool (PropertiesModel* parameter_model, QObject* parent = nullptr) override + { + return new FPFHEstimationTool(parameter_model, parent); + } + + PropertiesModel* + createToolParameterModel (QObject* parent) override; + + inline QString + getPluginName () const override { return "FPFH Estimation";} + + QString + getToolGroupName () const override { return "Feature Estimation";} + + QString + getIconName () const override { return ":/fpfh_estimation.png"; } + + inline CloudComposerItem::ItemType + getInputItemType () const override + { + return CloudComposerItem::CLOUD_ITEM; + } + + inline QList + getRequiredInputChildrenTypes () const override + { + QList input_types; + return (input_types << CloudComposerItem::NORMALS_ITEM); + } + }; - PropertiesModel* - createToolParameterModel(QObject* parent) override; - inline QString - getPluginName() const override - { - return "FPFH Estimation"; - } - QString - getToolGroupName() const override - { - return "Feature Estimation"; } - - QString - getIconName() const override - { - return ":/fpfh_estimation.png"; - } - - inline CloudComposerItem::ItemType - getInputItemType() const override - { - return CloudComposerItem::CLOUD_ITEM; - } - - inline QList - getRequiredInputChildrenTypes() const override - { - QList input_types; - return (input_types << CloudComposerItem::NORMALS_ITEM); - } -}; - -} // namespace cloud_composer -} // namespace pcl +} diff --git a/apps/cloud_composer/include/pcl/apps/cloud_composer/tools/impl/organized_segmentation.hpp b/apps/cloud_composer/include/pcl/apps/cloud_composer/tools/impl/organized_segmentation.hpp index ed34dbbddeb..708ea1f34b1 100644 --- a/apps/cloud_composer/include/pcl/apps/cloud_composer/tools/impl/organized_segmentation.hpp +++ b/apps/cloud_composer/include/pcl/apps/cloud_composer/tools/impl/organized_segmentation.hpp @@ -38,158 +38,144 @@ #ifndef IMPL_ORGANIZED_SEGMENTATION_HPP_ #define IMPL_ORGANIZED_SEGMENTATION_HPP_ +#include #include #include -#include -#include -#include -#include -#include -#include +#include // for pcl::make_shared +#include + #include #include +#include #include -#include // for pcl::make_shared -#include +#include +#include +#include -template -QList -pcl::cloud_composer::OrganizedSegmentationTool::performTemplatedAction( - const QList& input_data) -{ - QList output; - foreach (const CloudComposerItem* input_item, input_data) { - QVariant variant = input_item->data(ItemDataRole::CLOUD_TEMPLATED); - if (!variant.canConvert::Ptr>()) { - qWarning() << "Attempted to cast to template type which does not exist in this " - "item! (input list)"; +template QList +pcl::cloud_composer::OrganizedSegmentationTool::performTemplatedAction (const QList & input_data) +{ + QList output; + + foreach (const CloudComposerItem* input_item, input_data) + { + QVariant variant = input_item->data (ItemDataRole::CLOUD_TEMPLATED); + if ( ! variant.canConvert ::Ptr> () ) + { + qWarning () << "Attempted to cast to template type which does not exist in this item! (input list)"; return output; } - auto input_cloud = variant.value::Ptr>(); - if (!input_cloud->isOrganized()) { - qCritical() << "Organized Segmentation requires an organized cloud!"; + typename PointCloud ::Ptr input_cloud = variant.value ::Ptr> (); + if ( ! input_cloud->isOrganized ()) + { + qCritical () << "Organized Segmentation requires an organized cloud!"; return output; } } - int min_inliers = parameter_model_->getProperty("Min Inliers").toInt(); - int min_plane_size = parameter_model_->getProperty("Min Plane Size").toInt(); - double angular_threshold = - parameter_model_->getProperty("Angular Threshold").toDouble(); - double distance_threshold = - parameter_model_->getProperty("Distance Threshold").toDouble(); - double cluster_distance_threshold = - parameter_model_->getProperty("Cluster Dist. Thresh.").toDouble(); - int min_cluster_size = parameter_model_->getProperty("Min Cluster Size").toInt(); - - foreach (const CloudComposerItem* input_item, input_data) { - QList normals_list = - input_item->getChildren(CloudComposerItem::NORMALS_ITEM); - // Get the normals cloud, we just use the first normals that were found if there are - // more than one - auto input_normals = normals_list.value(0) - ->data(ItemDataRole::CLOUD_TEMPLATED) - .value::ConstPtr>(); - - QVariant variant = input_item->data(ItemDataRole::CLOUD_TEMPLATED); - auto input_cloud = variant.value::Ptr>(); + int min_inliers = parameter_model_->getProperty ("Min Inliers").toInt (); + int min_plane_size = parameter_model_->getProperty ("Min Plane Size").toInt (); + double angular_threshold = parameter_model_->getProperty ("Angular Threshold").toDouble (); + double distance_threshold = parameter_model_->getProperty ("Distance Threshold").toDouble (); + double cluster_distance_threshold = parameter_model_->getProperty ("Cluster Dist. Thresh.").toDouble (); + int min_cluster_size = parameter_model_->getProperty ("Min Cluster Size").toInt (); + + foreach (const CloudComposerItem* input_item, input_data) + { + QList normals_list = input_item->getChildren (CloudComposerItem::NORMALS_ITEM); + //Get the normals cloud, we just use the first normals that were found if there are more than one + pcl::PointCloud::ConstPtr input_normals = normals_list.value(0)->data(ItemDataRole::CLOUD_TEMPLATED).value ::ConstPtr> (); + + QVariant variant = input_item->data (ItemDataRole::CLOUD_TEMPLATED); + typename PointCloud ::Ptr input_cloud = variant.value ::Ptr> (); pcl::OrganizedMultiPlaneSegmentation mps; - mps.setMinInliers(min_inliers); - mps.setAngularThreshold(pcl::deg2rad(angular_threshold)); // convert to radians - mps.setDistanceThreshold(distance_threshold); - mps.setInputNormals(input_normals); - mps.setInputCloud(input_cloud); - std::vector, - Eigen::aligned_allocator>> - regions; + mps.setMinInliers (min_inliers); + mps.setAngularThreshold (pcl::deg2rad (angular_threshold)); // convert to radians + mps.setDistanceThreshold (distance_threshold); + mps.setInputNormals (input_normals); + mps.setInputCloud (input_cloud); + std::vector, Eigen::aligned_allocator > > regions; std::vector model_coefficients; std::vector inlier_indices; - pcl::PointCloud::Ptr labels(new pcl::PointCloud); + pcl::PointCloud::Ptr labels (new pcl::PointCloud); std::vector label_indices; std::vector boundary_indices; - mps.segmentAndRefine(regions, - model_coefficients, - inlier_indices, - labels, - label_indices, - boundary_indices); - - auto plane_labels = pcl::make_shared>(); - for (std::size_t i = 0; i < label_indices.size(); ++i) - if (label_indices[i].indices.size() > static_cast(min_plane_size)) - plane_labels->insert(i); + mps.segmentAndRefine (regions, model_coefficients, inlier_indices, labels, label_indices, boundary_indices); + + auto plane_labels = pcl::make_shared > (); + for (std::size_t i = 0; i < label_indices.size (); ++i) + if (label_indices[i].indices.size () > (std::size_t) min_plane_size) + plane_labels->insert (i); typename PointCloud::CloudVectorType clusters; - typename EuclideanClusterComparator::Ptr - euclidean_cluster_comparator( - new EuclideanClusterComparator); - euclidean_cluster_comparator->setInputCloud(input_cloud); - euclidean_cluster_comparator->setLabels(labels); - euclidean_cluster_comparator->setExcludeLabels(plane_labels); - euclidean_cluster_comparator->setDistanceThreshold(cluster_distance_threshold, - false); + typename EuclideanClusterComparator::Ptr euclidean_cluster_comparator(new EuclideanClusterComparator); + euclidean_cluster_comparator->setInputCloud (input_cloud); + euclidean_cluster_comparator->setLabels (labels); + euclidean_cluster_comparator->setExcludeLabels (plane_labels); + euclidean_cluster_comparator->setDistanceThreshold (cluster_distance_threshold, false); pcl::PointCloud euclidean_labels; std::vector euclidean_label_indices; - pcl::OrganizedConnectedComponentSegmentation - euclidean_segmentation(euclidean_cluster_comparator); - euclidean_segmentation.setInputCloud(input_cloud); - euclidean_segmentation.segment(euclidean_labels, euclidean_label_indices); - - pcl::IndicesPtr extracted_indices(new pcl::Indices()); - for (std::size_t i = 0; i < euclidean_label_indices.size(); i++) { - if (euclidean_label_indices[i].indices.size() >= - static_cast(min_cluster_size)) { - typename PointCloud::Ptr cluster(new PointCloud); - pcl::copyPointCloud(*input_cloud, euclidean_label_indices[i].indices, *cluster); - qDebug() << "Found cluster with size " << cluster->width; - QString name = input_item->text() + tr("- Clstr %1").arg(i); - CloudItem* new_cloud_item = - CloudItem::createCloudItemFromTemplate(name, cluster); - output.append(new_cloud_item); - extracted_indices->insert(extracted_indices->end(), - euclidean_label_indices[i].indices.begin(), - euclidean_label_indices[i].indices.end()); + pcl::OrganizedConnectedComponentSegmentation euclidean_segmentation (euclidean_cluster_comparator); + euclidean_segmentation.setInputCloud (input_cloud); + euclidean_segmentation.segment (euclidean_labels, euclidean_label_indices); + + pcl::IndicesPtr extracted_indices (new pcl::Indices ()); + for (std::size_t i = 0; i < euclidean_label_indices.size (); i++) + { + if (euclidean_label_indices[i].indices.size () >= (std::size_t) min_cluster_size) + { + typename PointCloud::Ptr cluster (new PointCloud); + pcl::copyPointCloud (*input_cloud,euclidean_label_indices[i].indices,*cluster); + qDebug () << "Found cluster with size " << cluster->width; + QString name = input_item->text () + tr ("- Clstr %1").arg (i); + CloudItem* new_cloud_item = CloudItem::createCloudItemFromTemplate(name,cluster); + output.append (new_cloud_item); + extracted_indices->insert (extracted_indices->end (), euclidean_label_indices[i].indices.begin (), euclidean_label_indices[i].indices.end ()); } } - for (std::size_t i = 0; i < label_indices.size(); i++) { - if (label_indices[i].indices.size() >= static_cast(min_plane_size)) { - typename PointCloud::Ptr plane(new PointCloud); - pcl::copyPointCloud(*input_cloud, label_indices[i].indices, *plane); - qDebug() << "Found plane with size " << plane->width; - QString name = input_item->text() + tr("- Plane %1").arg(i); - CloudItem* new_cloud_item = - CloudItem::createCloudItemFromTemplate(name, plane); - output.append(new_cloud_item); - extracted_indices->insert(extracted_indices->end(), - label_indices[i].indices.begin(), - label_indices[i].indices.end()); + for (std::size_t i = 0; i < label_indices.size (); i++) + { + if (label_indices[i].indices.size () >= (std::size_t) min_plane_size) + { + typename PointCloud::Ptr plane (new PointCloud); + pcl::copyPointCloud (*input_cloud,label_indices[i].indices,*plane); + qDebug () << "Found plane with size " << plane->width; + QString name = input_item->text () + tr ("- Plane %1").arg (i); + CloudItem* new_cloud_item = CloudItem::createCloudItemFromTemplate(name,plane); + output.append (new_cloud_item); + extracted_indices->insert (extracted_indices->end (), label_indices[i].indices.begin (), label_indices[i].indices.end ()); + } } - typename PointCloud::Ptr leftovers(new PointCloud); - if (extracted_indices->empty()) - pcl::copyPointCloud(*input_cloud, *leftovers); - else { + typename PointCloud::Ptr leftovers (new PointCloud); + if (extracted_indices->empty ()) + pcl::copyPointCloud (*input_cloud,*leftovers); + else + { pcl::ExtractIndices filter; - filter.setInputCloud(input_cloud); - filter.setIndices(extracted_indices); - filter.setNegative(true); - filter.filter(*leftovers); + filter.setInputCloud (input_cloud); + filter.setIndices (extracted_indices); + filter.setNegative (true); + filter.filter (*leftovers); } - CloudItem* leftover_cloud_item = - CloudItem::createCloudItemFromTemplate(input_item->text(), leftovers); - output.append(leftover_cloud_item); + CloudItem* leftover_cloud_item = CloudItem::createCloudItemFromTemplate(input_item->text(),leftovers); + output.append (leftover_cloud_item); } + + + return output; + } -#define PCL_INSTANTIATE_performTemplatedAction(T) \ - template void \ - pcl::cloud_composer::OrganizedSegmentationTool::performTemplatedAction( \ - QList); -#endif // IMPL_TRANSFORM_CLOUDS_HPP_ +#define PCL_INSTANTIATE_performTemplatedAction(T) template void pcl::cloud_composer::OrganizedSegmentationTool::performTemplatedAction (QList ); + + + +#endif //IMPL_TRANSFORM_CLOUDS_HPP_ diff --git a/apps/cloud_composer/include/pcl/apps/cloud_composer/tools/impl/supervoxels.hpp b/apps/cloud_composer/include/pcl/apps/cloud_composer/tools/impl/supervoxels.hpp index b401fd28751..2d83912fdc2 100644 --- a/apps/cloud_composer/include/pcl/apps/cloud_composer/tools/impl/supervoxels.hpp +++ b/apps/cloud_composer/include/pcl/apps/cloud_composer/tools/impl/supervoxels.hpp @@ -1,115 +1,124 @@ /* - * Software License Agreement (BSD License) - * - * Point Cloud Library (PCL) - www.pointclouds.org - * Copyright (c) 2012, Jeremie Papon. - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * * Neither the name of Willow Garage, Inc. nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - */ +* Software License Agreement (BSD License) +* +* Point Cloud Library (PCL) - www.pointclouds.org +* Copyright (c) 2012, Jeremie Papon. +* +* All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above +* copyright notice, this list of conditions and the following +* disclaimer in the documentation and/or other materials provided +* with the distribution. +* * Neither the name of Willow Garage, Inc. nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +* POSSIBILITY OF SUCH DAMAGE. +* +*/ #ifndef IMPL_SUPERVOXELS_HPP_ #define IMPL_SUPERVOXELS_HPP_ +#include #include #include -#include -#include #include #include +#include -template -QList -pcl::cloud_composer::SupervoxelsTool::performTemplatedAction( - const QList& input_data) -{ - QList output; - foreach (const CloudComposerItem* input_item, input_data) { - // if ( !input_item->isSanitized () ) - // { - // qCritical () << "SupervoxelsTool requires sanitized input!"; - // return output; - // } - QVariant variant = input_item->data(ItemDataRole::CLOUD_TEMPLATED); - if (!variant.canConvert::Ptr>()) { - qWarning() << "Attempted to cast to template type which does not exist in this " - "item! (input list)"; +template QList +pcl::cloud_composer::SupervoxelsTool::performTemplatedAction (const QList & input_data) +{ + QList output; + + foreach (const CloudComposerItem* input_item, input_data) + { + // if ( !input_item->isSanitized () ) + // { + // qCritical () << "SupervoxelsTool requires sanitized input!"; + // return output; + // } + QVariant variant = input_item->data (ItemDataRole::CLOUD_TEMPLATED); + if ( ! variant.canConvert ::Ptr> () ) + { + qWarning () << "Attempted to cast to template type which does not exist in this item! (input list)"; return output; } - auto input_cloud = variant.value::Ptr>(); - // TODO: Check if Voxelized - } - - foreach (const CloudComposerItem* input_item, input_data) { - QVariant variant = input_item->data(ItemDataRole::CLOUD_TEMPLATED); - auto input_cloud = variant.value::Ptr>(); - - float resolution = parameter_model_->getProperty("Resolution").toFloat(); - qDebug() << "Octree resolution = " << resolution; - float seed_resolution = parameter_model_->getProperty("Seed Resolution").toFloat(); - qDebug() << "Seed resolution = " << seed_resolution; - - float rgb_weight = parameter_model_->getProperty("RGB Weight").toFloat(); - float normal_weight = parameter_model_->getProperty("Normals Weight").toFloat(); - float spatial_weight = parameter_model_->getProperty("Spatial Weight").toFloat(); - - pcl::SupervoxelClustering super(resolution, seed_resolution); - super.setInputCloud(input_cloud); - super.setColorImportance(rgb_weight); - super.setSpatialImportance(spatial_weight); - super.setNormalImportance(normal_weight); - std::map::Ptr> supervoxel_clusters; - super.extract(supervoxel_clusters); - - std::map::Ptr> - refined_supervoxel_clusters; - super.refineSupervoxels(3, refined_supervoxel_clusters); + typename PointCloud ::Ptr input_cloud = variant.value ::Ptr> (); + //TODO: Check if Voxelized + +} + + foreach (const CloudComposerItem* input_item, input_data) + { + QVariant variant = input_item->data (ItemDataRole::CLOUD_TEMPLATED); + typename PointCloud ::Ptr input_cloud = variant.value ::Ptr> (); + + float resolution = parameter_model_->getProperty("Resolution").toFloat (); + qDebug () << "Octree resolution = "<getProperty("Seed Resolution").toFloat (); + qDebug () << "Seed resolution = "<getProperty("RGB Weight").toFloat (); + float normal_weight = parameter_model_->getProperty("Normals Weight").toFloat (); + float spatial_weight = parameter_model_->getProperty("Spatial Weight").toFloat (); + + + pcl::SupervoxelClustering super (resolution, seed_resolution); + super.setInputCloud (input_cloud); + super.setColorImportance (rgb_weight); + super.setSpatialImportance (spatial_weight); + super.setNormalImportance (normal_weight); + std::map ::Ptr > supervoxel_clusters; + super.extract (supervoxel_clusters); + + std::map ::Ptr > refined_supervoxel_clusters; + super.refineSupervoxels (3, refined_supervoxel_clusters); + auto label_segments = super.getLabeledVoxelCloud(); auto color_segments = pcl::make_shared>(); pcl::copyPointCloud(*label_segments, *color_segments); for (size_t i = 0; i < label_segments->size(); ++i) - color_segments->at(i).rgba = - GlasbeyLUT::at(label_segments->at(i).label % GlasbeyLUT::size()).rgba; - CloudItem* cloud_item_out = CloudItem::createCloudItemFromTemplate( - input_item->text(), color_segments); - - output.append(cloud_item_out); + color_segments->at(i).rgba = GlasbeyLUT::at(label_segments->at(i).label % GlasbeyLUT::size()).rgba; + CloudItem* cloud_item_out = CloudItem::createCloudItemFromTemplate(input_item->text(), color_segments); + + output.append (cloud_item_out); + } - + + + + return output; + } -#define PCL_INSTANTIATE_performTemplatedAction(T) \ - template void pcl::cloud_composer::SupervoxelsTool::performTemplatedAction( \ - QList); -#endif // IMPL_SUPERVOXELS_HPP_ + + +#define PCL_INSTANTIATE_performTemplatedAction(T) template void pcl::cloud_composer::SupervoxelsTool::performTemplatedAction (QList ); + + + +#endif //IMPL_SUPERVOXELS_HPP_ diff --git a/apps/cloud_composer/include/pcl/apps/cloud_composer/tools/normal_estimation.h b/apps/cloud_composer/include/pcl/apps/cloud_composer/tools/normal_estimation.h index 003095341b4..b5091cc009a 100644 --- a/apps/cloud_composer/include/pcl/apps/cloud_composer/tools/normal_estimation.h +++ b/apps/cloud_composer/include/pcl/apps/cloud_composer/tools/normal_estimation.h @@ -40,68 +40,62 @@ #include #include -namespace pcl { -namespace cloud_composer { -class NormalEstimationTool : public NewItemTool { - Q_OBJECT -public: - NormalEstimationTool(PropertiesModel* parameter_model, QObject* parent); - - QList - performAction(QList input_data, - PointTypeFlags::PointType type = PointTypeFlags::NONE) override; - - inline QString - getToolName() const override - { - return "Normal Estimation Tool"; - } -}; - -class NormalEstimationToolFactory : public QObject, public ToolFactory { - Q_OBJECT - Q_INTERFACES(pcl::cloud_composer::ToolFactory) - Q_PLUGIN_METADATA(IID "cloud_composer.ToolFactory/1.0") -public: - NewItemTool* - createTool(PropertiesModel* parameter_model, QObject* parent = nullptr) override - { - return new NormalEstimationTool(parameter_model, parent); - } - - PropertiesModel* - createToolParameterModel(QObject* parent) override; - - inline QString - getPluginName() const override +namespace pcl +{ + namespace cloud_composer { - return "Normal Estimation"; - } + class NormalEstimationTool : public NewItemTool + { + Q_OBJECT + public: + NormalEstimationTool (PropertiesModel* parameter_model, QObject* parent); + + QList + performAction (QList input_data, PointTypeFlags::PointType type = PointTypeFlags::NONE) override; + + inline QString + getToolName () const override { return "Normal Estimation Tool";} + }; - QString - getToolGroupName() const override - { - return "Feature Estimation"; - } + + class NormalEstimationToolFactory : public QObject, public ToolFactory + { + Q_OBJECT + Q_INTERFACES (pcl::cloud_composer::ToolFactory) + Q_PLUGIN_METADATA(IID "cloud_composer.ToolFactory/1.0") + public: + NewItemTool* + createTool (PropertiesModel* parameter_model, QObject* parent = nullptr) override + { + return new NormalEstimationTool(parameter_model, parent); + } + + PropertiesModel* + createToolParameterModel (QObject* parent) override; + + inline QString + getPluginName () const override { return "Normal Estimation";} + + QString + getToolGroupName () const override { return "Feature Estimation";} + + QString + getIconName () const override { return ":/normal_estimation.png"; } + + inline CloudComposerItem::ItemType + getInputItemType () const override + { + return CloudComposerItem::CLOUD_ITEM; + } + + inline QList + getRequiredInputChildrenTypes () const override + { + return QList (); + } + }; - QString - getIconName() const override - { - return ":/normal_estimation.png"; - } - inline CloudComposerItem::ItemType - getInputItemType() const override - { - return CloudComposerItem::CLOUD_ITEM; - } - inline QList - getRequiredInputChildrenTypes() const override - { - return {}; } -}; - -} // namespace cloud_composer -} // namespace pcl +} diff --git a/apps/cloud_composer/include/pcl/apps/cloud_composer/tools/organized_segmentation.h b/apps/cloud_composer/include/pcl/apps/cloud_composer/tools/organized_segmentation.h index 41aaf9e4fd7..a35d946d2ba 100644 --- a/apps/cloud_composer/include/pcl/apps/cloud_composer/tools/organized_segmentation.h +++ b/apps/cloud_composer/include/pcl/apps/cloud_composer/tools/organized_segmentation.h @@ -1,112 +1,106 @@ -/* - * Software License Agreement (BSD License) - * - * Point Cloud Library (PCL) - www.pointclouds.org - * Copyright (c) 2012, Jeremie Papon. - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * * Neither the name of Willow Garage, Inc. nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - */ - + /* + * Software License Agreement (BSD License) + * + * Point Cloud Library (PCL) - www.pointclouds.org + * Copyright (c) 2012, Jeremie Papon. + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * * Neither the name of Willow Garage, Inc. nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + */ + #pragma once - -#include -#include - -namespace pcl { -namespace cloud_composer { -class OrganizedSegmentationTool : public SplitItemTool { - Q_OBJECT -public: - OrganizedSegmentationTool(PropertiesModel* parameter_model, QObject* parent); - - QList - performAction(QList input_data, - PointTypeFlags::PointType type = PointTypeFlags::NONE) override; - - template - QList - performTemplatedAction(const QList& input_data); - - inline QString - getToolName() const override - { - return "Organized Segmentation Tool"; - } -}; - -class OrganizedSegmentationToolFactory : public QObject, public ToolFactory { - Q_OBJECT - Q_INTERFACES(pcl::cloud_composer::ToolFactory) - Q_PLUGIN_METADATA(IID "cloud_composer.ToolFactory/1.0") -public: - SplitItemTool* - createTool(PropertiesModel* parameter_model, QObject* parent = nullptr) override - { - return new OrganizedSegmentationTool(parameter_model, parent); - } - - PropertiesModel* - createToolParameterModel(QObject* parent) override; - - inline QString - getPluginName() const override - { - return "Organized Segmentation"; - } - - inline QString - getToolGroupName() const override - { - return "Segmentation"; - } - - inline QString - getIconName() const override - { - return ":/organized_segmentation.png"; - } - - inline CloudComposerItem::ItemType - getInputItemType() const override - { - return CloudComposerItem::CLOUD_ITEM; - } - - inline QList - getRequiredInputChildrenTypes() const override - { - QList input_types; - return (input_types << CloudComposerItem::NORMALS_ITEM); - } -}; - -} // namespace cloud_composer -} // namespace pcl + + #include + #include + + + namespace pcl + { + namespace cloud_composer + { + class OrganizedSegmentationTool : public SplitItemTool + { + Q_OBJECT + public: + OrganizedSegmentationTool (PropertiesModel* parameter_model, QObject* parent); + + QList + performAction (QList input_data, PointTypeFlags::PointType type = PointTypeFlags::NONE) override; + + template QList + performTemplatedAction (const QList & input_data); + + inline QString + getToolName () const override { return "Organized Segmentation Tool";} + }; + + + class OrganizedSegmentationToolFactory : public QObject, public ToolFactory + { + Q_OBJECT + Q_INTERFACES (pcl::cloud_composer::ToolFactory) + Q_PLUGIN_METADATA(IID "cloud_composer.ToolFactory/1.0") + public: + SplitItemTool* + createTool (PropertiesModel* parameter_model, QObject* parent = nullptr) override + { + return new OrganizedSegmentationTool(parameter_model, parent); + } + + PropertiesModel* + createToolParameterModel (QObject* parent) override; + + inline QString + getPluginName () const override { return "Organized Segmentation";} + + inline QString + getToolGroupName () const override { return "Segmentation";} + + inline QString + getIconName () const override { return ":/organized_segmentation.png"; } + + inline CloudComposerItem::ItemType + getInputItemType () const override + { + return CloudComposerItem::CLOUD_ITEM; + } + + inline QList + getRequiredInputChildrenTypes () const override + { + QList input_types; + return (input_types << CloudComposerItem::NORMALS_ITEM); + } + }; + + + + } + } diff --git a/apps/cloud_composer/include/pcl/apps/cloud_composer/tools/sanitize_cloud.h b/apps/cloud_composer/include/pcl/apps/cloud_composer/tools/sanitize_cloud.h index bb031c6c19d..f1c54653917 100644 --- a/apps/cloud_composer/include/pcl/apps/cloud_composer/tools/sanitize_cloud.h +++ b/apps/cloud_composer/include/pcl/apps/cloud_composer/tools/sanitize_cloud.h @@ -40,68 +40,62 @@ #include #include -namespace pcl { -namespace cloud_composer { -class SanitizeCloudTool : public ModifyItemTool { - Q_OBJECT -public: - SanitizeCloudTool(PropertiesModel* parameter_model, QObject* parent); - - QList - performAction(QList input_data, - PointTypeFlags::PointType type = PointTypeFlags::NONE) override; - - inline QString - getToolName() const override - { - return "Sanitize Cloud Tool"; - } -}; - -class SanitizeCloudToolFactory : public QObject, public ToolFactory { - Q_OBJECT - Q_INTERFACES(pcl::cloud_composer::ToolFactory) - Q_PLUGIN_METADATA(IID "cloud_composer.ToolFactory/1.0") -public: - ModifyItemTool* - createTool(PropertiesModel* parameter_model, QObject* parent = nullptr) override - { - return new SanitizeCloudTool(parameter_model, parent); - } - - PropertiesModel* - createToolParameterModel(QObject* parent) override; - - inline QString - getPluginName() const override - { - return "Sanitize Cloud"; - } - - QString - getToolGroupName() const override - { - return "Filters"; - } - - QString - getIconName() const override +namespace pcl +{ + namespace cloud_composer { - return ":/sanitize_cloud.png"; + class SanitizeCloudTool : public ModifyItemTool + { + Q_OBJECT + public: + SanitizeCloudTool (PropertiesModel* parameter_model, QObject* parent); + + QList + performAction (QList input_data, PointTypeFlags::PointType type = PointTypeFlags::NONE) override; + + inline QString + getToolName () const override { return "Sanitize Cloud Tool";} + }; + + + class SanitizeCloudToolFactory : public QObject, public ToolFactory + { + Q_OBJECT + Q_INTERFACES (pcl::cloud_composer::ToolFactory) + Q_PLUGIN_METADATA(IID "cloud_composer.ToolFactory/1.0") + public: + ModifyItemTool* + createTool (PropertiesModel* parameter_model, QObject* parent = nullptr) override + { + return new SanitizeCloudTool(parameter_model, parent); + } + + PropertiesModel* + createToolParameterModel (QObject* parent) override; + + inline QString + getPluginName () const override { return "Sanitize Cloud";} + + QString + getToolGroupName () const override { return "Filters";} + + QString + getIconName () const override { return ":/sanitize_cloud.png"; } + + inline CloudComposerItem::ItemType + getInputItemType () const override + { + return CloudComposerItem::CLOUD_ITEM; + } + + inline QList + getRequiredInputChildrenTypes () const override + { + return QList (); + } + }; + + + + } } - - inline CloudComposerItem::ItemType - getInputItemType() const override - { - return CloudComposerItem::CLOUD_ITEM; - } - - inline QList - getRequiredInputChildrenTypes() const override - { - return {}; - } -}; - -} // namespace cloud_composer -} // namespace pcl diff --git a/apps/cloud_composer/include/pcl/apps/cloud_composer/tools/statistical_outlier_removal.h b/apps/cloud_composer/include/pcl/apps/cloud_composer/tools/statistical_outlier_removal.h index a27a79dc986..86ce2cbebbd 100644 --- a/apps/cloud_composer/include/pcl/apps/cloud_composer/tools/statistical_outlier_removal.h +++ b/apps/cloud_composer/include/pcl/apps/cloud_composer/tools/statistical_outlier_removal.h @@ -40,68 +40,63 @@ #include #include -namespace pcl { -namespace cloud_composer { -class StatisticalOutlierRemovalTool : public ModifyItemTool { - Q_OBJECT -public: - StatisticalOutlierRemovalTool(PropertiesModel* parameter_model, QObject* parent); - QList - performAction(QList input_data, - PointTypeFlags::PointType type = PointTypeFlags::NONE) override; - - inline QString - getToolName() const override +namespace pcl +{ + namespace cloud_composer { - return "Statistical Outlier Removal Tool"; - } -}; + class StatisticalOutlierRemovalTool : public ModifyItemTool + { + Q_OBJECT + public: + StatisticalOutlierRemovalTool (PropertiesModel* parameter_model, QObject* parent); + + QList + performAction (QList input_data, PointTypeFlags::PointType type = PointTypeFlags::NONE) override; + + inline QString + getToolName () const override { return "Statistical Outlier Removal Tool";} + }; -class StatisticalOutlierRemovalToolFactory : public QObject, public ToolFactory { - Q_OBJECT - Q_INTERFACES(pcl::cloud_composer::ToolFactory) - Q_PLUGIN_METADATA(IID "cloud_composer.ToolFactory/1.0") -public: - ModifyItemTool* - createTool(PropertiesModel* parameter_model, QObject* parent = nullptr) override - { - return new StatisticalOutlierRemovalTool(parameter_model, parent); - } + + class StatisticalOutlierRemovalToolFactory : public QObject, public ToolFactory + { + Q_OBJECT + Q_INTERFACES (pcl::cloud_composer::ToolFactory) + Q_PLUGIN_METADATA(IID "cloud_composer.ToolFactory/1.0") + public: + ModifyItemTool* + createTool (PropertiesModel* parameter_model, QObject* parent = nullptr) override + { + return new StatisticalOutlierRemovalTool(parameter_model, parent); + } + + PropertiesModel* + createToolParameterModel (QObject* parent) override; + + inline QString + getPluginName () const override { return "Statistical Outlier Removal";} + + QString + getToolGroupName () const override { return "Filters";} + + QString + getIconName () const override { return ":/statistical_outlier_removal.png"; } + + inline CloudComposerItem::ItemType + getInputItemType () const override + { + return CloudComposerItem::CLOUD_ITEM; + } + + inline QList + getRequiredInputChildrenTypes () const override + { + return QList (); + } + }; - PropertiesModel* - createToolParameterModel(QObject* parent) override; - inline QString - getPluginName() const override - { - return "Statistical Outlier Removal"; - } - QString - getToolGroupName() const override - { - return "Filters"; } - - QString - getIconName() const override - { - return ":/statistical_outlier_removal.png"; - } - - inline CloudComposerItem::ItemType - getInputItemType() const override - { - return CloudComposerItem::CLOUD_ITEM; - } - - inline QList - getRequiredInputChildrenTypes() const override - { - return {}; - } -}; - -} // namespace cloud_composer -} // namespace pcl +} diff --git a/apps/cloud_composer/include/pcl/apps/cloud_composer/tools/supervoxels.h b/apps/cloud_composer/include/pcl/apps/cloud_composer/tools/supervoxels.h index 1383a599a18..39c6ea6656c 100644 --- a/apps/cloud_composer/include/pcl/apps/cloud_composer/tools/supervoxels.h +++ b/apps/cloud_composer/include/pcl/apps/cloud_composer/tools/supervoxels.h @@ -1,112 +1,108 @@ -/* - * Software License Agreement (BSD License) - * - * Point Cloud Library (PCL) - www.pointclouds.org - * Copyright (c) 2012, Jeremie Papon. - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * * Neither the name of Willow Garage, Inc. nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - */ - + /* + * Software License Agreement (BSD License) + * + * Point Cloud Library (PCL) - www.pointclouds.org + * Copyright (c) 2012, Jeremie Papon. + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * * Neither the name of Willow Garage, Inc. nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + */ + #pragma once - -#include -#include - -namespace pcl { -namespace cloud_composer { -class SupervoxelsTool : public SplitItemTool { - Q_OBJECT -public: - SupervoxelsTool(PropertiesModel* parameter_model, QObject* parent); - - QList - performAction(QList input_data, - PointTypeFlags::PointType type = PointTypeFlags::NONE) override; - - template - QList - performTemplatedAction(const QList& input_data); - - inline QString - getToolName() const override - { - return "Voxel Superpixels Tool"; - } -}; - -class SupervoxelsToolFactory : public QObject, public ToolFactory { - Q_OBJECT - Q_INTERFACES(pcl::cloud_composer::ToolFactory) - Q_PLUGIN_METADATA(IID "cloud_composer.ToolFactory/1.0") -public: - SplitItemTool* - createTool(PropertiesModel* parameter_model, QObject* parent = nullptr) override - { - return new SupervoxelsTool(parameter_model, parent); - } - - PropertiesModel* - createToolParameterModel(QObject* parent) override; - - inline QString - getPluginName() const override - { - return "Supervoxels"; - } - - inline QString - getToolGroupName() const override - { - return "Segmentation"; - } - - inline QString - getIconName() const override - { - return ":/supervoxels.png"; - } - - inline CloudComposerItem::ItemType - getInputItemType() const override - { - return CloudComposerItem::CLOUD_ITEM; - } - - inline QList - getRequiredInputChildrenTypes() const override - { - QList input_types; - return input_types; - } -}; - -} // namespace cloud_composer -} // namespace pcl + + #include + #include + + + namespace pcl + { + namespace cloud_composer + { + class SupervoxelsTool : public SplitItemTool + { + Q_OBJECT + public: + SupervoxelsTool (PropertiesModel* parameter_model, QObject* parent); + + QList + performAction (QList input_data, PointTypeFlags::PointType type = PointTypeFlags::NONE) override; + + template QList + performTemplatedAction (const QList & input_data); + + inline QString + getToolName () const override { return "Voxel Superpixels Tool";} + + + }; + + + class SupervoxelsToolFactory : public QObject, public ToolFactory + { + Q_OBJECT + Q_INTERFACES (pcl::cloud_composer::ToolFactory) + Q_PLUGIN_METADATA(IID "cloud_composer.ToolFactory/1.0") + public: + SplitItemTool* + createTool (PropertiesModel* parameter_model, QObject* parent = nullptr) override + { + return new SupervoxelsTool(parameter_model, parent); + } + + PropertiesModel* + createToolParameterModel (QObject* parent) override; + + inline QString + getPluginName () const override { return "Supervoxels";} + + inline QString + getToolGroupName () const override { return "Segmentation";} + + inline QString + getIconName () const override { return ":/supervoxels.png"; } + + inline CloudComposerItem::ItemType + getInputItemType () const override + { + return CloudComposerItem::CLOUD_ITEM; + } + + inline QList + getRequiredInputChildrenTypes () const override + { + QList input_types; + return input_types; + } + }; + + + + } + } diff --git a/apps/cloud_composer/include/pcl/apps/cloud_composer/tools/voxel_grid_downsample.h b/apps/cloud_composer/include/pcl/apps/cloud_composer/tools/voxel_grid_downsample.h index 868b532a9d0..85499ca89b6 100644 --- a/apps/cloud_composer/include/pcl/apps/cloud_composer/tools/voxel_grid_downsample.h +++ b/apps/cloud_composer/include/pcl/apps/cloud_composer/tools/voxel_grid_downsample.h @@ -40,68 +40,62 @@ #include #include -namespace pcl { -namespace cloud_composer { -class VoxelGridDownsampleTool : public ModifyItemTool { - Q_OBJECT -public: - VoxelGridDownsampleTool(PropertiesModel* parameter_model, QObject* parent); - - QList - performAction(QList input_data, - PointTypeFlags::PointType type = PointTypeFlags::NONE) override; - - inline QString - getToolName() const override - { - return "Voxel Grid Downsample Tool"; - } -}; - -class VoxelGridDownsampleToolFactory : public QObject, public ToolFactory { - Q_OBJECT - Q_INTERFACES(pcl::cloud_composer::ToolFactory) - Q_PLUGIN_METADATA(IID "cloud_composer.ToolFactory/1.0") -public: - ModifyItemTool* - createTool(PropertiesModel* parameter_model, QObject* parent = nullptr) override - { - return new VoxelGridDownsampleTool(parameter_model, parent); - } - - PropertiesModel* - createToolParameterModel(QObject* parent) override; - - inline QString - getPluginName() const override +namespace pcl +{ + namespace cloud_composer { - return "Voxel Grid Downsample"; - } + class VoxelGridDownsampleTool : public ModifyItemTool + { + Q_OBJECT + public: + VoxelGridDownsampleTool (PropertiesModel* parameter_model, QObject* parent); + + QList + performAction (QList input_data, PointTypeFlags::PointType type = PointTypeFlags::NONE) override; + + inline QString + getToolName () const override { return "Voxel Grid Downsample Tool";} + }; - QString - getToolGroupName() const override - { - return "Filters"; - } + + class VoxelGridDownsampleToolFactory : public QObject, public ToolFactory + { + Q_OBJECT + Q_INTERFACES (pcl::cloud_composer::ToolFactory) + Q_PLUGIN_METADATA(IID "cloud_composer.ToolFactory/1.0") + public: + ModifyItemTool* + createTool (PropertiesModel* parameter_model, QObject* parent = nullptr) override + { + return new VoxelGridDownsampleTool(parameter_model, parent); + } + + PropertiesModel* + createToolParameterModel (QObject* parent) override; + + inline QString + getPluginName () const override { return "Voxel Grid Downsample";} + + QString + getToolGroupName () const override { return "Filters";} + + QString + getIconName () const override { return ":/voxel_grid_downsample.png"; } + + inline CloudComposerItem::ItemType + getInputItemType () const override + { + return CloudComposerItem::CLOUD_ITEM; + } + + inline QList + getRequiredInputChildrenTypes () const override + { + return QList (); + } + }; - QString - getIconName() const override - { - return ":/voxel_grid_downsample.png"; - } - inline CloudComposerItem::ItemType - getInputItemType() const override - { - return CloudComposerItem::CLOUD_ITEM; - } - inline QList - getRequiredInputChildrenTypes() const override - { - return {}; } -}; - -} // namespace cloud_composer -} // namespace pcl +} diff --git a/apps/cloud_composer/include/pcl/apps/cloud_composer/transform_clouds.h b/apps/cloud_composer/include/pcl/apps/cloud_composer/transform_clouds.h index e647b9f0da3..e2215296d35 100644 --- a/apps/cloud_composer/include/pcl/apps/cloud_composer/transform_clouds.h +++ b/apps/cloud_composer/include/pcl/apps/cloud_composer/transform_clouds.h @@ -39,31 +39,28 @@ #include -namespace pcl { -namespace cloud_composer { -class TransformClouds : public ModifyItemTool { - Q_OBJECT -public: - TransformClouds(QMap> transform_map, - QObject* parent = nullptr); - - QList - performAction(QList input_data, - PointTypeFlags::PointType type = PointTypeFlags::NONE) override; - - inline QString - getToolName() const override +namespace pcl +{ + namespace cloud_composer { - return "Transform Clouds Tool"; - } + class TransformClouds : public ModifyItemTool + { + Q_OBJECT + public: + TransformClouds (QMap > transform_map, QObject* parent = nullptr); + + QList + performAction (QList input_data, PointTypeFlags::PointType type = PointTypeFlags::NONE) override; + + inline QString + getToolName () const override { return "Transform Clouds Tool";} + + template QList + performTemplatedAction (const QList & input_data); + + private: + QMap > transform_map_; + }; - template - QList - performTemplatedAction(const QList& input_data); - -private: - QMap> transform_map_; -}; - -} // namespace cloud_composer -} // namespace pcl + } +} diff --git a/apps/cloud_composer/include/pcl/apps/cloud_composer/work_queue.h b/apps/cloud_composer/include/pcl/apps/cloud_composer/work_queue.h index fb6227ca82c..95652a67029 100644 --- a/apps/cloud_composer/include/pcl/apps/cloud_composer/work_queue.h +++ b/apps/cloud_composer/include/pcl/apps/cloud_composer/work_queue.h @@ -37,42 +37,47 @@ #pragma once -#include - #include -namespace pcl { -namespace cloud_composer { -class AbstractTool; -class CloudComposerItem; - -struct ActionPair { - CloudCommand* command; - AbstractTool* tool; -}; - -class WorkQueue : public QObject { - Q_OBJECT -public: - WorkQueue(QObject* parent = nullptr); -public Q_SLOTS: - void - enqueueNewAction(AbstractTool* new_tool, ConstItemList input_data); - - void - actionFinished(ActionPair finished_action); - - void - checkQueue(); -Q_SIGNALS: - void - commandProgress(QString command_text, double progress); +#include - void - commandComplete(CloudCommand* completed_command); +namespace pcl +{ + namespace cloud_composer + { + class AbstractTool; + class CloudComposerItem; + + struct ActionPair + { + CloudCommand* command; + AbstractTool* tool; + }; + + class WorkQueue : public QObject + { + Q_OBJECT + public: + WorkQueue (QObject* parent = nullptr); + public Q_SLOTS: + void + enqueueNewAction (AbstractTool* new_tool, ConstItemList input_data); + + void + actionFinished (ActionPair finished_action); + + void + checkQueue (); + Q_SIGNALS: + void + commandProgress (QString command_text, double progress); -private: - QQueue work_queue_; -}; -} // namespace cloud_composer -} // namespace pcl + void + commandComplete (CloudCommand* completed_command); + + private: + QQueue work_queue_; + + }; + } +} diff --git a/apps/cloud_composer/src/cloud_composer.cpp b/apps/cloud_composer/src/cloud_composer.cpp index 1c551d4db3d..1302b59819c 100644 --- a/apps/cloud_composer/src/cloud_composer.cpp +++ b/apps/cloud_composer/src/cloud_composer.cpp @@ -1,14 +1,14 @@ #include -#include +#include #include -#include +#include #include -#include -#include -#include -#include +#include #include +#include #include +#include +#include #include #include @@ -16,233 +16,215 @@ #include ///////////////////////////////////////////////////////////// -pcl::cloud_composer::ComposerMainWindow::ComposerMainWindow(QWidget* parent) -: QMainWindow(parent) +pcl::cloud_composer::ComposerMainWindow::ComposerMainWindow (QWidget *parent) + : QMainWindow (parent) { - setupUi(this); - - this->setCorner(Qt::BottomLeftCorner, Qt::LeftDockWidgetArea); - this->setCorner(Qt::BottomRightCorner, Qt::RightDockWidgetArea); - - // Register types in Qt - qRegisterMetaType("PCLPointCloud2Ptr"); - qRegisterMetaType("GeometryHandlerConstPtr"); - qRegisterMetaType("ColorHandlerConstPtr"); - qRegisterMetaType("EigenVector4f"); - qRegisterMetaType("EigenQuaternionf"); - qRegisterMetaType("ProjectModel"); - qRegisterMetaType("CloudView"); - qRegisterMetaType("ConstComposerItemList"); - + setupUi (this); + + this->setCorner (Qt::BottomLeftCorner, Qt::LeftDockWidgetArea); + this->setCorner (Qt::BottomRightCorner, Qt::RightDockWidgetArea); + + //Register types in Qt + qRegisterMetaType ("PCLPointCloud2Ptr"); + qRegisterMetaType ("GeometryHandlerConstPtr"); + qRegisterMetaType ("ColorHandlerConstPtr"); + qRegisterMetaType ("EigenVector4f"); + qRegisterMetaType ("EigenQuaternionf"); + qRegisterMetaType ("ProjectModel"); + qRegisterMetaType ("CloudView"); + qRegisterMetaType ("ConstComposerItemList"); + current_model_ = nullptr; - - multiplexer_ = new SignalMultiplexer(this); - - initializeCloudBrowser(); - initializeCloudViewer(); - initializeItemInspector(); - initializeToolBox(); - initializePlugins(); - - undo_group_ = new QUndoGroup(this); - undo_view_->setGroup(undo_group_); - - // Auto connect signals and slots - // QMetaObject::connectSlotsByName(this); - connectFileActions(); - connectEditActions(); - connectViewActions(); + + multiplexer_ = new SignalMultiplexer (this); + + initializeCloudBrowser (); + initializeCloudViewer (); + initializeItemInspector (); + initializeToolBox (); + initializePlugins (); + + undo_group_ = new QUndoGroup (this); + undo_view_->setGroup (undo_group_); + + //Auto connect signals and slots + // QMetaObject::connectSlotsByName(this); + connectFileActions (); + connectEditActions (); + connectViewActions (); + } -pcl::cloud_composer::ComposerMainWindow::~ComposerMainWindow() +pcl::cloud_composer::ComposerMainWindow::~ComposerMainWindow () { - foreach (ProjectModel* to_delete, name_model_map_.values()) - to_delete->deleteLater(); + foreach (ProjectModel* to_delete, name_model_map_.values ()) + to_delete->deleteLater (); } void -pcl::cloud_composer::ComposerMainWindow::connectFileActions() -{} +pcl::cloud_composer::ComposerMainWindow::connectFileActions () +{ + + +} void -pcl::cloud_composer::ComposerMainWindow::connectEditActions() +pcl::cloud_composer::ComposerMainWindow::connectEditActions () { - // Replace the actions in the menu with undo actions created using the undo group - QAction* action_temp = undo_group_->createUndoAction(this); - action_temp->setShortcut(action_undo_->shortcut()); - menuEdit->insertAction(action_redo_, action_temp); - menuEdit->removeAction(action_undo_); + //Replace the actions in the menu with undo actions created using the undo group + QAction* action_temp = undo_group_->createUndoAction (this); + action_temp->setShortcut (action_undo_->shortcut ()); + menuEdit->insertAction (action_redo_, action_temp); + menuEdit->removeAction (action_undo_); action_undo_ = action_temp; - - action_temp = undo_group_->createRedoAction(this); - action_temp->setShortcut(action_redo_->shortcut()); - menuEdit->insertAction(action_redo_, action_temp); - menuEdit->removeAction(action_redo_); + + action_temp = undo_group_->createRedoAction (this); + action_temp->setShortcut (action_redo_->shortcut ()); + menuEdit->insertAction (action_redo_, action_temp); + menuEdit->removeAction (action_redo_); action_redo_ = action_temp; - - multiplexer_->connect( - action_clear_selection_, SIGNAL(triggered()), SLOT(clearSelection())); - - multiplexer_->connect( - action_delete_, SIGNAL(triggered()), SLOT(deleteSelectedItems())); - multiplexer_->connect( - SIGNAL(deleteAvailable(bool)), action_delete_, SLOT(setEnabled(bool))); - - multiplexer_->connect( - this, SIGNAL(insertNewCloudFromFile()), SLOT(insertNewCloudFromFile())); - multiplexer_->connect(this, - SIGNAL(insertNewCloudFromRGBandDepth()), - SLOT(insertNewCloudFromRGBandDepth())); - multiplexer_->connect( - this, SIGNAL(saveSelectedCloudToFile()), SLOT(saveSelectedCloudToFile())); - - mouse_style_group_ = new QActionGroup(this); - mouse_style_group_->addAction(action_trackball_camera_style_); - mouse_style_group_->addAction(action_manipulate_clicked_); - mouse_style_group_->addAction(action_manipulate_selected_); - mouse_style_group_->addAction(action_rectangular_frustum_select_); - mouse_style_group_->setExclusive(true); - multiplexer_->connect(mouse_style_group_, - SIGNAL(triggered(QAction*)), - SLOT(mouseStyleChanged(QAction*))); - multiplexer_->connect( - SIGNAL(mouseStyleState(interactor_styles::INTERACTOR_STYLES)), - this, - SLOT(setMouseStyleAction(interactor_styles::INTERACTOR_STYLES))); - action_trackball_camera_style_->setData( - QVariant::fromValue(interactor_styles::PCL_VISUALIZER)); - action_rectangular_frustum_select_->setData( - QVariant::fromValue(interactor_styles::RECTANGULAR_FRUSTUM)); - action_manipulate_selected_->setData( - QVariant::fromValue(interactor_styles::SELECTED_TRACKBALL)); - action_manipulate_clicked_->setData( - QVariant::fromValue(interactor_styles::CLICK_TRACKBALL)); - // multiplexer_->connect (action_manipulate_selected_, SIGNAL (triggered ()), SLOT - // (selectedTrackballInteractorStyle ())); - - multiplexer_->connect(action_new_cloud_from_selection_, - SIGNAL(triggered()), - SLOT(createNewCloudFromSelection())); - multiplexer_->connect(SIGNAL(newCloudFromSelectionAvailable(bool)), - action_new_cloud_from_selection_, - SLOT(setEnabled(bool))); - - multiplexer_->connect( - action_select_all_, SIGNAL(triggered()), SLOT(selectAllItems())); + + multiplexer_->connect (action_clear_selection_, SIGNAL (triggered ()), SLOT (clearSelection ())); + + multiplexer_->connect (action_delete_, SIGNAL (triggered ()), SLOT (deleteSelectedItems ())); + multiplexer_->connect (SIGNAL (deleteAvailable (bool)), action_delete_, SLOT (setEnabled (bool))); + + multiplexer_->connect (this, SIGNAL (insertNewCloudFromFile()), SLOT (insertNewCloudFromFile())); + multiplexer_->connect (this, SIGNAL (insertNewCloudFromRGBandDepth()), SLOT (insertNewCloudFromRGBandDepth())); + multiplexer_->connect (this, SIGNAL (saveSelectedCloudToFile()), SLOT (saveSelectedCloudToFile())); + + + mouse_style_group_ = new QActionGroup (this); + mouse_style_group_->addAction (action_trackball_camera_style_); + mouse_style_group_->addAction (action_manipulate_clicked_); + mouse_style_group_->addAction (action_manipulate_selected_); + mouse_style_group_->addAction (action_rectangular_frustum_select_); + mouse_style_group_->setExclusive (true); + multiplexer_->connect (mouse_style_group_, SIGNAL (triggered (QAction*)), SLOT (mouseStyleChanged (QAction*))); + multiplexer_->connect(SIGNAL (mouseStyleState (interactor_styles::INTERACTOR_STYLES)), this, SLOT(setMouseStyleAction(interactor_styles::INTERACTOR_STYLES))); + action_trackball_camera_style_->setData (QVariant::fromValue (interactor_styles::PCL_VISUALIZER)); + action_rectangular_frustum_select_->setData (QVariant::fromValue (interactor_styles::RECTANGULAR_FRUSTUM)); + action_manipulate_selected_->setData (QVariant::fromValue (interactor_styles::SELECTED_TRACKBALL)); + action_manipulate_clicked_->setData (QVariant::fromValue (interactor_styles::CLICK_TRACKBALL)); + //multiplexer_->connect (action_manipulate_selected_, SIGNAL (triggered ()), SLOT (selectedTrackballInteractorStyle ())); + + + multiplexer_->connect (action_new_cloud_from_selection_, SIGNAL (triggered ()), SLOT (createNewCloudFromSelection ())); + multiplexer_->connect (SIGNAL (newCloudFromSelectionAvailable (bool)), action_new_cloud_from_selection_, SLOT (setEnabled (bool))); + + multiplexer_->connect (action_select_all_, SIGNAL (triggered ()), SLOT (selectAllItems ())); } void -pcl::cloud_composer::ComposerMainWindow::setMouseStyleAction( - interactor_styles::INTERACTOR_STYLES selected_style) +pcl::cloud_composer::ComposerMainWindow::setMouseStyleAction (interactor_styles::INTERACTOR_STYLES selected_style) { - action_trackball_camera_style_->setChecked(false); - action_rectangular_frustum_select_->setChecked(false); - action_manipulate_selected_->setChecked(false); - action_manipulate_clicked_->setChecked(false); - - switch (selected_style) { - case interactor_styles::PCL_VISUALIZER: - action_trackball_camera_style_->setChecked(true); - break; - case interactor_styles::CLICK_TRACKBALL: - action_manipulate_clicked_->setChecked(true); - break; - case interactor_styles::RECTANGULAR_FRUSTUM: - action_rectangular_frustum_select_->setChecked(true); - break; - case interactor_styles::SELECTED_TRACKBALL: - action_manipulate_selected_->setChecked(true); - break; - default: - action_trackball_camera_style_->setChecked(true); + action_trackball_camera_style_->setChecked (false); + action_rectangular_frustum_select_->setChecked (false); + action_manipulate_selected_->setChecked (false); + action_manipulate_clicked_->setChecked (false); + + switch (selected_style) + { + case interactor_styles::PCL_VISUALIZER : + action_trackball_camera_style_->setChecked (true); + break; + case interactor_styles::CLICK_TRACKBALL : + action_manipulate_clicked_->setChecked (true); + break; + case interactor_styles::RECTANGULAR_FRUSTUM : + action_rectangular_frustum_select_->setChecked (true); + break; + case interactor_styles::SELECTED_TRACKBALL : + action_manipulate_selected_->setChecked (true); + break; + default : + action_trackball_camera_style_->setChecked (true); + } } void -pcl::cloud_composer::ComposerMainWindow::connectViewActions() +pcl::cloud_composer::ComposerMainWindow::connectViewActions () { - multiplexer_->connect( - action_show_axes_, SIGNAL(toggled(bool)), SLOT(setAxisVisibility(bool))); - multiplexer_->connect( - SIGNAL(axisVisible(bool)), action_show_axes_, SLOT(setChecked(bool))); + multiplexer_->connect (action_show_axes_, SIGNAL (toggled (bool)), SLOT (setAxisVisibility (bool))); + multiplexer_->connect (SIGNAL (axisVisible (bool)), action_show_axes_, SLOT (setChecked (bool))); + } void -pcl::cloud_composer::ComposerMainWindow::initializeCloudBrowser() +pcl::cloud_composer::ComposerMainWindow::initializeCloudBrowser () { - cloud_browser_->setSelectionMode(QAbstractItemView::ExtendedSelection); - + cloud_browser_->setSelectionMode (QAbstractItemView::ExtendedSelection); + cloud_browser_->setStyleSheet("selection-background-color: red;"); + } void -pcl::cloud_composer::ComposerMainWindow::initializeCloudViewer() +pcl::cloud_composer::ComposerMainWindow::initializeCloudViewer () { - // Signal emitted when user selects new tab (ie different project) in the viewer - connect(cloud_viewer_, - SIGNAL(newModelSelected(ProjectModel*)), - this, - SLOT(setCurrentModel(ProjectModel*))); + //Signal emitted when user selects new tab (ie different project) in the viewer + connect (cloud_viewer_, SIGNAL (newModelSelected (ProjectModel*)), + this, SLOT (setCurrentModel (ProjectModel*))); + } void -pcl::cloud_composer::ComposerMainWindow::initializeItemInspector() -{} +pcl::cloud_composer::ComposerMainWindow::initializeItemInspector () +{ + +} void -pcl::cloud_composer::ComposerMainWindow::initializeToolBox() +pcl::cloud_composer::ComposerMainWindow::initializeToolBox () { - tool_box_model_ = new ToolBoxModel(tool_box_view_, tool_parameter_view_, this); - tool_selection_model_ = new QItemSelectionModel(tool_box_model_); - tool_box_model_->setSelectionModel(tool_selection_model_); - - tool_box_view_->setModel(tool_box_model_); - tool_box_view_->setSelectionModel(tool_selection_model_); - tool_box_view_->setIconSize(QSize(32, 32)); - tool_box_view_->setIndentation(10); - - connect(tool_selection_model_, - SIGNAL(currentChanged(const QModelIndex&, const QModelIndex&)), - tool_box_model_, - SLOT(selectedToolChanged(const QModelIndex&, const QModelIndex&))); - - connect(tool_box_model_, - SIGNAL(enqueueToolAction(AbstractTool*)), - this, - SLOT(enqueueToolAction(AbstractTool*))); - - connect(this, - SIGNAL(activeProjectChanged(ProjectModel*, ProjectModel*)), - tool_box_model_, - SLOT(activeProjectChanged(ProjectModel*, ProjectModel*))); - - // TODO : Remove this, tools should have a better way of being run - connect(action_run_tool_, SIGNAL(clicked()), tool_box_model_, SLOT(toolAction())); - // tool_box_view_->setStyleSheet("branch:has-siblings:!adjoins-item:image none"); - // tool_box_view_->setStyleSheet("branch:!has-children:!has-siblings:adjoins-item:image: - // none"); + tool_box_model_ = new ToolBoxModel (tool_box_view_, tool_parameter_view_,this); + tool_selection_model_ = new QItemSelectionModel (tool_box_model_); + tool_box_model_->setSelectionModel (tool_selection_model_); + + tool_box_view_->setModel (tool_box_model_); + tool_box_view_->setSelectionModel (tool_selection_model_); + tool_box_view_->setIconSize (QSize (32,32)); + tool_box_view_->setIndentation (10); + + connect ( tool_selection_model_, SIGNAL (currentChanged (const QModelIndex&, const QModelIndex&)), + tool_box_model_, SLOT (selectedToolChanged (const QModelIndex&, const QModelIndex&))); + + connect ( tool_box_model_, SIGNAL (enqueueToolAction (AbstractTool*)), + this, SLOT (enqueueToolAction (AbstractTool*))); + + connect (this, SIGNAL (activeProjectChanged (ProjectModel*,ProjectModel*)), + tool_box_model_, SLOT (activeProjectChanged (ProjectModel*,ProjectModel*))); + + //TODO : Remove this, tools should have a better way of being run + connect ( action_run_tool_, SIGNAL (clicked ()), + tool_box_model_, SLOT (toolAction ())); + //tool_box_view_->setStyleSheet("branch:has-siblings:!adjoins-item:image none"); + // tool_box_view_->setStyleSheet("branch:!has-children:!has-siblings:adjoins-item:image: none"); + + } -void -pcl::cloud_composer::ComposerMainWindow::initializePlugins() + +void +pcl::cloud_composer::ComposerMainWindow::initializePlugins () { - QDir plugin_dir = QCoreApplication::applicationDirPath(); - qDebug() << plugin_dir.path() << " " - << QDir::cleanPath("../lib/cloud_composer_plugins"); + QDir plugin_dir = QCoreApplication::applicationDirPath (); + qDebug() << plugin_dir.path ()<< " "<(plugin); + QObject *plugin = loader.instance (); + ToolFactory* tool_factory = qobject_cast (plugin); if (tool_factory) { - qWarning() << "Loaded " << tool_factory->getPluginName(); - // Create the action button for this tool - tool_box_model_->addTool(tool_factory); + qWarning () << "Loaded " << tool_factory->getPluginName (); + //Create the action button for this tool + tool_box_model_->addTool (tool_factory); + } - else { - qDebug() << "Could not load " << plugin_dir.relativeFilePath(filename); - qDebug() << loader.errorString(); + else{ + qDebug() << "Could not load " << plugin_dir.relativeFilePath (filename); + qDebug() << loader.errorString (); } + } } -void -pcl::cloud_composer::ComposerMainWindow::setCurrentModel(ProjectModel* model) + + +void +pcl::cloud_composer::ComposerMainWindow::setCurrentModel (ProjectModel* model) { - emit activeProjectChanged(model, current_model_); + emit activeProjectChanged (model, current_model_); current_model_ = model; - // qDebug () << "Setting cloud browser model"; - cloud_browser_->setModel(current_model_); - // qDebug () << "Setting cloud browser selection model"; - cloud_browser_->setSelectionModel(current_model_->getSelectionModel()); - // qDebug () << "Item inspector setting model"; - item_inspector_->setModel(current_model_); - // qDebug () << "Setting active stack in undo group"; - undo_group_->setActiveStack(current_model_->getUndoStack()); - - multiplexer_->setCurrentObject(current_model_); + //qDebug () << "Setting cloud browser model"; + cloud_browser_->setModel (current_model_); + //qDebug () << "Setting cloud browser selection model"; + cloud_browser_->setSelectionModel (current_model_->getSelectionModel ()); + //qDebug () << "Item inspector setting model"; + item_inspector_->setModel (current_model_); + //qDebug () << "Setting active stack in undo group"; + undo_group_->setActiveStack (current_model_->getUndoStack ()); + + multiplexer_->setCurrentObject (current_model_); } void -pcl::cloud_composer::ComposerMainWindow::enqueueToolAction(AbstractTool* tool) +pcl::cloud_composer::ComposerMainWindow::enqueueToolAction (AbstractTool* tool) { if (current_model_) - current_model_->enqueueToolAction(tool); + current_model_->enqueueToolAction (tool); else - QMessageBox::warning( - this, "No Project Open!", "Cannot use tool, no project is open!"); + QMessageBox::warning (this, "No Project Open!", "Cannot use tool, no project is open!"); } ///////// FILE MENU SLOTS /////////// -void pcl::cloud_composer::ComposerMainWindow::on_action_new_project__triggered( - /*QString name*/) +void +pcl::cloud_composer::ComposerMainWindow::on_action_new_project__triggered (/*QString name*/) { QString name("unsaved project"); - qDebug() << "Creating New Project"; - ProjectModel* new_project_model = new ProjectModel(this); + qDebug () << "Creating New Project"; + ProjectModel* new_project_model = new ProjectModel (this); // Check if we have a project with this name already, append int if so - if (name_model_map_.contains(name)) { + if (name_model_map_.contains (name)) + { int k = 2; - while (name_model_map_.contains(name + tr("-%1").arg(k))) + while (name_model_map_.contains (name + tr ("-%1").arg (k))) ++k; - name += tr("-%1").arg(k); + name += tr ("-%1").arg (k); } - // qDebug () << "Setting name"; - new_project_model->setName(name); - // qDebug () << "Inserting into map"; - name_model_map_.insert(name, new_project_model); - // qDebug () << "Adding to undo group"; - undo_group_->addStack(new_project_model->getUndoStack()); - // qDebug () << "Setting current model"; - cloud_viewer_->addNewProject(new_project_model); - - setCurrentModel(new_project_model); - // qDebug () << "Project " <setName (name); + //qDebug () << "Inserting into map"; + name_model_map_.insert (name,new_project_model); + //qDebug () << "Adding to undo group"; + undo_group_->addStack (new_project_model->getUndoStack ()); + //qDebug () << "Setting current model"; + cloud_viewer_->addNewProject (new_project_model); + + setCurrentModel (new_project_model); + //qDebug () << "Project " <trigger(); - - emit insertNewCloudFromFile(); + action_new_project_->trigger (); + + emit insertNewCloudFromFile (); } void -pcl::cloud_composer::ComposerMainWindow::on_action_insert_from_rgb_depth__triggered() +pcl::cloud_composer::ComposerMainWindow::on_action_insert_from_rgb_depth__triggered () { if (!current_model_) - action_new_project_->trigger(); - - emit insertNewCloudFromRGBandDepth(); + action_new_project_->trigger (); + + emit insertNewCloudFromRGBandDepth (); } + void -pcl::cloud_composer::ComposerMainWindow:: - on_action_insert_from_openNi_source__triggered() +pcl::cloud_composer::ComposerMainWindow::on_action_insert_from_openNi_source__triggered () { - qDebug() << "Inserting cloud from OpenNi Source..."; + qDebug () << "Inserting cloud from OpenNi Source..."; } + + + diff --git a/apps/cloud_composer/src/cloud_view.cpp b/apps/cloud_composer/src/cloud_view.cpp index cd04e9dd152..465c557a071 100644 --- a/apps/cloud_composer/src/cloud_view.cpp +++ b/apps/cloud_composer/src/cloud_view.cpp @@ -105,7 +105,7 @@ void pcl::cloud_composer::CloudView::itemChanged (QStandardItem* changed_item) { qDebug () << "Item Changed - Redrawing!"; - auto* item = dynamic_cast (changed_item); + CloudComposerItem* item = dynamic_cast (changed_item); if (item) { item->paintView (vis_); @@ -127,7 +127,7 @@ pcl::cloud_composer::CloudView::rowsInserted (const QModelIndex& parent, int sta for (int row = start; row <= end; ++row) { QStandardItem* new_item = parent_item->child(row); - auto* item = dynamic_cast (new_item); + CloudComposerItem* item = dynamic_cast (new_item); if (item) item->paintView (vis_); @@ -155,7 +155,7 @@ pcl::cloud_composer::CloudView::rowsAboutToBeRemoved (const QModelIndex& parent, QStandardItem* item_to_remove = parent_item->child(row); if (item_to_remove) qDebug () << "Removing "<text (); - auto* item = dynamic_cast (item_to_remove); + CloudComposerItem* item = dynamic_cast (item_to_remove); if (item ) item->removeFromView (vis_); diff --git a/apps/cloud_composer/src/cloud_viewer.cpp b/apps/cloud_composer/src/cloud_viewer.cpp index 430e403f03e..f47c1c053ae 100644 --- a/apps/cloud_composer/src/cloud_viewer.cpp +++ b/apps/cloud_composer/src/cloud_viewer.cpp @@ -1,62 +1,66 @@ -#include #include #include +#include #include -pcl::cloud_composer::CloudViewer::CloudViewer(QWidget* parent) : QTabWidget(parent) +pcl::cloud_composer::CloudViewer::CloudViewer (QWidget* parent) + : QTabWidget (parent) { - connect(this, SIGNAL(currentChanged(int)), this, SLOT(modelChanged(int))); + connect (this, SIGNAL (currentChanged (int)), + this, SLOT (modelChanged (int))); } void -pcl::cloud_composer::CloudViewer::addModel(ProjectModel* new_model) +pcl::cloud_composer::CloudViewer::addModel (ProjectModel* new_model) { - auto* new_view = new CloudView(new_model); - connect(new_model->getSelectionModel(), - SIGNAL(selectionChanged(QItemSelection, QItemSelection)), - new_view, - SLOT(selectedItemChanged(QItemSelection, QItemSelection))); - new_model->setCloudView(new_view); - - QStandardItem* title = new_model->horizontalHeaderItem(0); - this->addTab(new_view, title->text()); + CloudView* new_view = new CloudView (new_model); + connect (new_model->getSelectionModel (), SIGNAL (selectionChanged (QItemSelection,QItemSelection)), + new_view, SLOT (selectedItemChanged (QItemSelection,QItemSelection))); + new_model->setCloudView (new_view); + + QStandardItem* title = new_model->horizontalHeaderItem (0); + this->addTab (new_view, title->text ()); + + model_view_map_.insert (new_model,new_view); + + setCurrentWidget (model_view_map_.value (new_model)); + //Refresh the view + new_view->refresh (); - model_view_map_.insert(new_model, new_view); - - setCurrentWidget(model_view_map_.value(new_model)); - // Refresh the view - new_view->refresh(); } - + pcl::cloud_composer::ProjectModel* -pcl::cloud_composer::CloudViewer::getModel() const +pcl::cloud_composer::CloudViewer::getModel () const { if (this->count() == 0) return nullptr; - return dynamic_cast(currentWidget())->getModel(); + return dynamic_cast (currentWidget ())->getModel (); } void -pcl::cloud_composer::CloudViewer::addNewProject(ProjectModel* new_model) +pcl::cloud_composer::CloudViewer::addNewProject (ProjectModel* new_model) { - // If we're already there, abort - if (new_model == getModel()) + //If we're already there, abort + if (new_model == getModel ()) return; - // Check whether we've seen the model yet - if (!model_view_map_.contains(new_model)) { - addModel(new_model); + //Check whether we've seen the model yet + if ( !model_view_map_.contains (new_model)) + { + addModel (new_model); } - else { - setCurrentWidget(model_view_map_.value(new_model)); - // Refresh the view - model_view_map_.value(new_model)->refresh(); + else + { + setCurrentWidget (model_view_map_.value (new_model)); + //Refresh the view + model_view_map_.value (new_model)->refresh (); } } void -pcl::cloud_composer::CloudViewer::modelChanged(int) +pcl::cloud_composer::CloudViewer::modelChanged (int) { - emit newModelSelected(getModel()); + emit newModelSelected (getModel ()); } + diff --git a/apps/cloud_composer/src/commands.cpp b/apps/cloud_composer/src/commands.cpp index 684f707e733..c8a0b9730d0 100644 --- a/apps/cloud_composer/src/commands.cpp +++ b/apps/cloud_composer/src/commands.cpp @@ -1,29 +1,38 @@ #include -#include -#include #include +#include +#include -pcl::cloud_composer::CloudCommand::CloudCommand( - QList input_data, QUndoCommand* parent) -: QUndoCommand(parent), original_data_(std::move(input_data)) -{} +pcl::cloud_composer::CloudCommand::CloudCommand (QList input_data, QUndoCommand* parent) + : QUndoCommand (parent) + , original_data_ (std::move(input_data)) + , can_use_templates_(false) + , template_type_ (-1) +{ -pcl::cloud_composer::CloudCommand::~CloudCommand() +} + +pcl::cloud_composer::CloudCommand::~CloudCommand () { - qDebug() << "Command Destructor"; - // If we have removed items, we delete them - if (!last_was_undo_) { - qDebug() << "Last was redo, removing original items "; - QList items_to_remove = removed_to_parent_map_.keys(); - foreach (QStandardItem* to_remove, items_to_remove) { - delete to_remove; + qDebug () << "Command Destructor"; + //If we have removed items, we delete them + if (!last_was_undo_) + { + qDebug () << "Last was redo, removing original items "; + QList items_to_remove = removed_to_parent_map_.keys (); + foreach (QStandardItem* to_remove, items_to_remove) + { + delete to_remove; } } - else { - qDebug() << "Last was undo, removing new items"; - foreach (OutputPair output_pair, output_data_) { - QList new_items = output_pair.output_items_; - foreach (CloudComposerItem* item, new_items) { + else + { + qDebug () << "Last was undo, removing new items"; + foreach (OutputPair output_pair, output_data_) + { + QList new_items = output_pair.output_items_; + foreach (CloudComposerItem* item, new_items) + { delete item; } } @@ -32,43 +41,44 @@ pcl::cloud_composer::CloudCommand::~CloudCommand() ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// void -pcl::cloud_composer::CloudCommand::setProjectModel(ProjectModel* model) +pcl::cloud_composer::CloudCommand::setProjectModel (ProjectModel* model) { project_model_ = model; } bool -pcl::cloud_composer::CloudCommand::canUseTemplates(ConstItemList& input_data) +pcl::cloud_composer::CloudCommand::canUseTemplates (ConstItemList &input_data) { - // Make sure the input list isn't empty - if (input_data.empty()) { - qCritical() << "Cannot call a templated tool on an empty input in " - "CloudCommand::executeToolOnTemplateCloud!"; + //Make sure the input list isn't empty + if (input_data.empty ()) + { + qCritical () << "Cannot call a templated tool on an empty input in CloudCommand::executeToolOnTemplateCloud!"; template_type_ = -2; return false; } - // Make sure all input items are clouds - QList cloud_items; - foreach (const CloudComposerItem* item, input_data) { - const auto* cloud_item = dynamic_cast(item); + //Make sure all input items are clouds + QList cloud_items; + foreach (const CloudComposerItem* item, input_data) + { + const CloudItem* cloud_item = dynamic_cast (item); if (cloud_item) - cloud_items.append(cloud_item); + cloud_items.append (cloud_item); } - if (cloud_items.size() != input_data.size()) { - qCritical() << "All input items are not clouds in " - "CloudCommand::executeToolOnTemplateCloud!"; + if (cloud_items.size () != input_data.size ()) + { + qCritical () << "All input items are not clouds in CloudCommand::executeToolOnTemplateCloud!"; template_type_ = -3; return false; } - + // Now make sure all input clouds have the same templated type - int type = cloud_items.value(0)->getPointType(); - foreach (const CloudItem* cloud_item, cloud_items) { - if (cloud_item->getPointType() != type) { - qCritical() << "All input point cloud template types in " - "CloudCommand::executeToolOnTemplateCloud are not the same!"; - qCritical() << cloud_item->text() << "'s type does not match " - << cloud_items.value(0)->type(); + int type = cloud_items.value (0)->getPointType (); + foreach (const CloudItem* cloud_item, cloud_items) + { + if (cloud_item->getPointType () != type) + { + qCritical () << "All input point cloud template types in CloudCommand::executeToolOnTemplateCloud are not the same!"; + qCritical () << cloud_item->text () << "'s type does not match "<type (); template_type_ = -3; return false; } @@ -79,114 +89,111 @@ pcl::cloud_composer::CloudCommand::canUseTemplates(ConstItemList& input_data) } /* -QList -pcl::cloud_composer::CloudCommand::executeToolOnTemplateCloud (AbstractTool* tool, -ConstItemList &input_data) +QList +pcl::cloud_composer::CloudCommand::executeToolOnTemplateCloud (AbstractTool* tool, ConstItemList &input_data) { QList output; // If can_use_templates_ is false and type is -1 we haven't checked if we can yet if (!can_use_templates_ && template_type_ == -1) this->canUseTemplates (input_data); - - + + //If this is true now, we can go ahead and run it if (can_use_templates_ && template_type_ >= 0) { - output = tool->performAction( input_data, static_cast -(template_type_)); + output = tool->performAction( input_data, static_cast (template_type_)); } else { - qDebug () << "Tried CloudCommand::executeToolOnTemplateCloud but input data was not -templated clouds!"; + qDebug () << "Tried CloudCommand::executeToolOnTemplateCloud but input data was not templated clouds!"; } return output; - + } */ ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -bool -pcl::cloud_composer::CloudCommand::replaceOriginalWithNew( - const QList& originals, - const QList& new_items) -{ - // Find the input item's parent - if (originals.empty()) { - qCritical() << "No items to replace specified!"; +bool +pcl::cloud_composer::CloudCommand::replaceOriginalWithNew (const QList & originals, const QList & new_items) +{ + //Find the input item's parent + if (originals.empty ()) + { + qCritical () << "No items to replace specified!"; return false; } - - QStandardItem* parent_item = originals.value(0)->parent(); - // Verify that all items have same parent - foreach (const CloudComposerItem* item, originals) { - if (item->parent() != parent_item) { - qCritical() << "All original items must have same parent!"; + + QStandardItem* parent_item = originals.value(0)->parent (); + //Verify that all items have same parent + foreach (const CloudComposerItem* item, originals) + { + if (item->parent () != parent_item) + { + qCritical () << "All original items must have same parent!"; return false; } } // If parent is 0, it's parent is invisiblerootitem (That's how Qt defines it... boo!) if (parent_item == nullptr) - parent_item = project_model_->invisibleRootItem(); - - // Now remove all the originals - foreach (const CloudComposerItem* item, originals) { - QPersistentModelIndex original_index = - QPersistentModelIndex(project_model_->indexFromItem(item)); - if (!original_index.isValid()) { - qCritical() << "Index of item to replace is not valid!"; + parent_item = project_model_->invisibleRootItem (); + + //Now remove all the originals + foreach (const CloudComposerItem* item, originals) + { + QPersistentModelIndex original_index = QPersistentModelIndex(project_model_->indexFromItem (item)); + if (!original_index.isValid ()) + { + qCritical () << "Index of item to replace is not valid!"; return false; } - QList removed_items = parent_item->takeRow(original_index.row()); - removed_to_parent_map_.insert(removed_items.value(0), parent_item); + QList removed_items = parent_item->takeRow (original_index.row ()); + removed_to_parent_map_.insert (removed_items.value(0),parent_item); } - // Insert the new items below the parent item' - foreach (CloudComposerItem* item, new_items) { - parent_item->appendRow(item); + //Insert the new items below the parent item' + foreach (CloudComposerItem* item, new_items) + { + parent_item->appendRow (item); } return true; } ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -bool -pcl::cloud_composer::CloudCommand::restoreOriginalRemoveNew( - const QList& originals, - const QList& new_items) -{ - - // Now remove all the new items - foreach (CloudComposerItem* item, new_items) { - QStandardItem* parent_item = item->parent(); - // If parent is 0, it's parent is invisiblerootitem (That's how Qt defines it... - // boo!) +bool +pcl::cloud_composer::CloudCommand::restoreOriginalRemoveNew (const QList & originals, const QList & new_items) +{ + + //Now remove all the new items + foreach (CloudComposerItem* item, new_items) + { + QStandardItem* parent_item = item->parent (); + // If parent is 0, it's parent is invisiblerootitem (That's how Qt defines it... boo!) if (parent_item == nullptr) - parent_item = project_model_->invisibleRootItem(); - QPersistentModelIndex to_remove_index = - QPersistentModelIndex(project_model_->indexFromItem(item)); - if (!to_remove_index.isValid()) { - qCritical() << "Index of item to remove while restoring originals not valid"; + parent_item = project_model_->invisibleRootItem (); + QPersistentModelIndex to_remove_index = QPersistentModelIndex(project_model_->indexFromItem (item)); + if (!to_remove_index.isValid ()) + { + qCritical () << "Index of item to remove while restoring originals not valid"; return false; } - // Take them, they're still stored so we don't worry about them - QList removed = parent_item->takeRow(to_remove_index.row()); - } - // Restore the original items - foreach (const CloudComposerItem* item, originals) { - // Point iterator to the correct spot - // Find doesn't modify parameter so it should accept a const pointer, but it can't - // be because it is templated to the map type So we hack to get around this with a - // const cast - const auto& itr = removed_to_parent_map_.find(const_cast(item)); - QStandardItem* parent = itr.value(); - QStandardItem* original = itr.key(); - parent->appendRow(original); - int num = removed_to_parent_map_.remove(original); + //Take them, they're still stored so we don't worry about them + QList removed = parent_item->takeRow (to_remove_index.row ()); + } + //Restore the original items + foreach (const CloudComposerItem* item, originals) + { + //Point iterator to the correct spot + // Find doesn't modify parameter so it should accept a const pointer, but it can't be because it is templated to the map type + // So we hack to get around this with a const cast + const auto& itr = removed_to_parent_map_.find (const_cast (item)); + QStandardItem* parent = itr.value (); + QStandardItem* original = itr.key (); + parent->appendRow (original); + int num = removed_to_parent_map_.remove (original); if (num > 1) - qCritical() << "More than one item with same pointer in removed_to_parent_map_, " - "this is undefined behavior"; - else if (num == 0) - qCritical() << "Could not find key in map to remove, not good!"; + qCritical () << "More than one item with same pointer in removed_to_parent_map_, this is undefined behavior"; + else if (num == 0) + qCritical () << "Could not find key in map to remove, not good!"; } return true; @@ -195,42 +202,44 @@ pcl::cloud_composer::CloudCommand::restoreOriginalRemoveNew( ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////// MODIFY CLOUD COMMAND -pcl::cloud_composer::ModifyItemCommand::ModifyItemCommand( - QList input_data, QUndoCommand* parent) -: CloudCommand(std::move(input_data), parent) -{} +pcl::cloud_composer::ModifyItemCommand::ModifyItemCommand (QList input_data, QUndoCommand* parent) + : CloudCommand (std::move(input_data), parent) +{ + +} bool -pcl::cloud_composer::ModifyItemCommand::runCommand(AbstractTool* tool) +pcl::cloud_composer::ModifyItemCommand::runCommand (AbstractTool* tool) { - this->setText(tool->getToolName()); - // For modify item cloud command, each selected item should be processed separately + this->setText (tool->getToolName ()); + //For modify item cloud command, each selected item should be processed separately int num_items_returned = 0; - foreach (const CloudComposerItem* item, original_data_) { - QList input_list; - input_list.append(item); - QList output; + foreach (const CloudComposerItem *item, original_data_) + { + QList input_list; + input_list.append (item); + QList output; if (canUseTemplates(input_list)) - output = tool->performAction( - input_list, static_cast(template_type_)); + output = tool->performAction (input_list, static_cast (template_type_)); else - output = tool->performAction(input_list); - if (output.empty()) - qWarning() << "Warning: Tool " << tool->getToolName() - << "returned no item in a ModifyItemCommand"; - else { + output = tool->performAction (input_list); + if (output.empty ()) + qWarning () << "Warning: Tool " << tool->getToolName () << "returned no item in a ModifyItemCommand"; + else + { OutputPair output_pair = {input_list, output}; - output_data_.append(output_pair); + output_data_.append (output_pair); num_items_returned++; } - if (output.size() > 1) { - qCritical() << "Tool " << tool->getToolName() - << "returned multiple items in a ModifyCloudCommand"; + if (output.size () > 1) + { + qCritical () << "Tool " << tool->getToolName () << "returned multiple items in a ModifyCloudCommand"; } + } - if (num_items_returned != original_data_.size()) { - qDebug() << "Modify Item command generated " << num_items_returned - << " which does not match input of " << original_data_.size() << " items"; + if (num_items_returned != original_data_.size ()) + { + qDebug () << "Modify Item command generated "< input_data, QUndoCommand* parent) -: CloudCommand(std::move(input_data), parent) -{} +pcl::cloud_composer::NewItemCloudCommand::NewItemCloudCommand (QList input_data, QUndoCommand* parent) + : CloudCommand (std::move(input_data), parent) +{ + +} bool -pcl::cloud_composer::NewItemCloudCommand::runCommand(AbstractTool* tool) +pcl::cloud_composer::NewItemCloudCommand::runCommand (AbstractTool* tool) { - this->setText(tool->getToolName()); - // For new item cloud command, each selected item should be processed separately - // e.g. calculate normals for every selected cloud + this->setText (tool->getToolName ()); + //For new item cloud command, each selected item should be processed separately + //e.g. calculate normals for every selected cloud int num_new_items = 0; - foreach (const CloudComposerItem* item, original_data_) { - QList input_list; - input_list.append(item); - QList output; + foreach (const CloudComposerItem *item, original_data_) + { + QList input_list; + input_list.append (item); + QList output; if (canUseTemplates(input_list)) - output = tool->performAction( - input_list, static_cast(template_type_)); + output = tool->performAction (input_list, static_cast (template_type_)); else - output = tool->performAction(input_list); - if (output.empty()) - qWarning() << "Warning: Tool " << tool->getToolName() - << "returned no item in a NewItemCloudCommand"; - else { + output = tool->performAction (input_list); + if (output.empty ()) + qWarning () << "Warning: Tool " << tool->getToolName () << "returned no item in a NewItemCloudCommand"; + else + { OutputPair output_pair = {input_list, output}; - output_data_.append(output_pair); - num_new_items += output.size(); + output_data_.append (output_pair); + num_new_items += output.size (); } + } - if (num_new_items > 0) { - qDebug() << "New Item command generated " << num_new_items << " new items"; + if (num_new_items > 0) + { + qDebug () << "New Item command generated "< output_items = output_pair.output_items_; - // Find the input_item index in the project_model_ - QModelIndex input_index = project_model_->indexFromItem(const_input_item); - if (!input_index.isValid()) { - qCritical() << "Index of input cloud item is no longer valid, cannot undo " - "NewItemCloudCommand"; + qDebug () << "Undo in NewItemCloudCommand"; + foreach (OutputPair output_pair, output_data_) + { + //Each pair can only have one input item, so get it + const CloudComposerItem* const_input_item = output_pair.input_items_.value (0); + QList output_items = output_pair.output_items_; + //Find the input_item index in the project_model_ + QModelIndex input_index = project_model_->indexFromItem (const_input_item); + if (!input_index.isValid ()) + { + qCritical () << "Index of input cloud item is no longer valid, cannot undo NewItemCloudCommand"; return; } - // Get a copy of the input item we can modify - QStandardItem* item_to_change = project_model_->itemFromIndex(input_index); - // Remove the items we added - foreach (CloudComposerItem* output_item, output_items) { - QModelIndex output_index = project_model_->indexFromItem(output_item); - item_to_change->takeRow(output_index.row()); + //Get a copy of the input item we can modify + QStandardItem* item_to_change = project_model_->itemFromIndex (input_index); + //Remove the items we added + foreach (CloudComposerItem* output_item, output_items) + { + QModelIndex output_index = project_model_->indexFromItem (output_item); + item_to_change->takeRow (output_index.row ()); } + } } ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// void -pcl::cloud_composer::NewItemCloudCommand::redo() +pcl::cloud_composer::NewItemCloudCommand::redo () { last_was_undo_ = false; - qDebug() << "Redo in NewItemCloudCommand - output data size=" << output_data_.size(); - foreach (OutputPair output_pair, output_data_) { - // Each pair can only have one input item, so get it - const CloudComposerItem* const_input_item = output_pair.input_items_.value(0); - QList output_items = output_pair.output_items_; - // Find the input_item index in the project_model_ - QPersistentModelIndex input_index = - QPersistentModelIndex(project_model_->indexFromItem(const_input_item)); - if (!input_index.isValid()) { - qCritical() - << "Index of input cloud item is no longer valid upon command completion!"; + qDebug () << "Redo in NewItemCloudCommand - output data size="< output_items = output_pair.output_items_; + //Find the input_item index in the project_model_ + QPersistentModelIndex input_index = QPersistentModelIndex(project_model_->indexFromItem (const_input_item)); + if (!input_index.isValid ()) + { + qCritical () << "Index of input cloud item is no longer valid upon command completion!"; return; } - // Get a copy of the input item we can modify - QStandardItem* input_item = (project_model_->itemFromIndex(input_index)); - // Append the output items to the input item - foreach (CloudComposerItem* output_item, output_items) { - input_item->appendRow(output_item); + //Get a copy of the input item we can modify + QStandardItem* input_item = (project_model_->itemFromIndex (input_index)); + //Append the output items to the input item + foreach (CloudComposerItem* output_item, output_items) + { + input_item->appendRow (output_item); } } } + ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -//////////// Split CLOUD COMMAND -////////////////////////////////////////////////////////////////////////////// +//////////// Split CLOUD COMMAND /////////////////////////////////////////////////////////////////////////// -pcl::cloud_composer::SplitCloudCommand::SplitCloudCommand( - QList input_data, QUndoCommand* parent) -: CloudCommand(std::move(input_data), parent) -{} +pcl::cloud_composer::SplitCloudCommand::SplitCloudCommand (QList input_data, QUndoCommand* parent) + : CloudCommand (std::move(input_data), parent) +{ + +} bool -pcl::cloud_composer::SplitCloudCommand::runCommand(AbstractTool* tool) +pcl::cloud_composer::SplitCloudCommand::runCommand (AbstractTool* tool) { - this->setText(tool->getToolName()); - // For split cloud command, each selected item should be processed separately - // e.g. calculate normals for every selected cloud + this->setText (tool->getToolName ()); + //For split cloud command, each selected item should be processed separately + //e.g. calculate normals for every selected cloud int num_new_items = 0; - foreach (const CloudComposerItem* item, original_data_) { - // Check to see if this is a cloud - QList input_list; - input_list.append(item); - QList output; + foreach (const CloudComposerItem *item, original_data_) + { + //Check to see if this is a cloud + QList input_list; + input_list.append (item); + QList output; if (canUseTemplates(input_list)) - output = tool->performAction( - input_list, static_cast(template_type_)); + output = tool->performAction (input_list, static_cast (template_type_)); else - output = tool->performAction(input_list); - if (output.empty()) - qWarning() << "Warning: Tool " << tool->getToolName() - << "returned no item in a SplitCloudCommand"; - else { - qDebug() << "Split command returned " << output.size() << " items"; + output = tool->performAction (input_list); + if (output.empty ()) + qWarning () << "Warning: Tool " << tool->getToolName () << "returned no item in a SplitCloudCommand"; + else + { + qDebug () << "Split command returned "< 0) { - qDebug() << "Split Item command generated " << num_new_items << " new items"; + if (num_new_items > 0) + { + qDebug () << "Split Item command generated "< input_data, QUndoCommand* parent) -: CloudCommand(std::move(input_data), parent) -{} +pcl::cloud_composer::DeleteItemCommand::DeleteItemCommand (QList input_data, QUndoCommand* parent) + : CloudCommand (std::move(input_data), parent) +{ + +} bool -pcl::cloud_composer::DeleteItemCommand::runCommand(AbstractTool*) +pcl::cloud_composer::DeleteItemCommand::runCommand (AbstractTool*) { - - // For delete item command, each selected item should be processed separately - // e.g. delete every selected item - foreach (const CloudComposerItem* item, original_data_) { - QList output; - QList to_delete; - to_delete.append(item); + + //For delete item command, each selected item should be processed separately + //e.g. delete every selected item + foreach (const CloudComposerItem *item, original_data_) + { + QList output; + QList to_delete; + to_delete.append (item); OutputPair output_pair = {to_delete, output}; - output_data_.append(output_pair); - this->setText("Delete " + item->text()); + output_data_.append (output_pair); + this->setText ("Delete "+item->text ()); } - if (!original_data_.empty()) - this->setText("Delete multiple items"); + if (!original_data_.empty ()) + this->setText ("Delete multiple items"); return true; } ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// void -pcl::cloud_composer::DeleteItemCommand::undo() +pcl::cloud_composer::DeleteItemCommand::undo () { last_was_undo_ = true; - // Add the original items back into the model - foreach (OutputPair output_pair, output_data_) { - if (!restoreOriginalRemoveNew(output_pair.input_items_, output_pair.output_items_)) - qCritical() << "Failed to restore items in DeleteItemCommand::undo!"; + //Add the original items back into the model + foreach (OutputPair output_pair, output_data_) + { + if (!restoreOriginalRemoveNew (output_pair.input_items_, output_pair.output_items_)) + qCritical () << "Failed to restore items in DeleteItemCommand::undo!"; } } ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// void -pcl::cloud_composer::DeleteItemCommand::redo() +pcl::cloud_composer::DeleteItemCommand::redo () { last_was_undo_ = false; - qDebug() << "Redo in DeleteItemCommand - num items to delete=" << output_data_.size(); - foreach (OutputPair output_pair, output_data_) { - // Replace the input with the output for this pair - if (!replaceOriginalWithNew(output_pair.input_items_, output_pair.output_items_)) - qCritical() << "Removal of items failed in DeleteItemCommand::redo"; + qDebug () << "Redo in DeleteItemCommand - num items to delete="< output_items; + //In merge command, input clouds will be combined, so send them to tool together + QList output_items; if (canUseTemplates(original_data_)) - output_items = tool->performAction( - original_data_, static_cast(template_type_)); + output_items = tool->performAction (original_data_, static_cast (template_type_)); else - output_items = tool->performAction(original_data_); - auto* merge_selection = dynamic_cast(tool); - // If this is a merge selection we need to put the partially selected items into the - // original data list too! We didn't send them before because merge selection already - // knows about them (and needs to tree input list differently from selected items) - if (merge_selection) { - QList selected_items = merge_selection->getSelectedItems(); + output_items = tool->performAction (original_data_); + MergeSelection* merge_selection = dynamic_cast (tool); + // If this is a merge selection we need to put the partially selected items into the original data list too! + // We didn't send them before because merge selection already knows about them (and needs to tree input list differently from selected items) + if (merge_selection) + { + QList selected_items = merge_selection->getSelectedItems(); foreach (const CloudItem* item, selected_items) - original_data_.append(item); + original_data_.append (item); } OutputPair output_pair = {original_data_, output_items}; - output_data_.append(output_pair); - - if (output_items.empty()) { - qWarning() << "Warning: Tool " << tool->getToolName() - << "returned no item in a MergeCloudCommand"; + output_data_.append (output_pair); + + if (output_items.empty ()) + { + qWarning () << "Warning: Tool " << tool->getToolName () << "returned no item in a MergeCloudCommand"; return false; } - - this->setText("Merge Clouds"); + + this->setText ("Merge Clouds"); return true; } ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// void -pcl::cloud_composer::MergeCloudCommand::undo() +pcl::cloud_composer::MergeCloudCommand::undo () { last_was_undo_ = true; - // Add the original items back into the model - foreach (OutputPair output_pair, output_data_) { - if (!restoreOriginalRemoveNew(output_pair.input_items_, output_pair.output_items_)) - qCritical() << "Failed to restore original clouds in MergeCloudCommand::undo!"; + //Add the original items back into the model + foreach (OutputPair output_pair, output_data_) + { + if (!restoreOriginalRemoveNew (output_pair.input_items_, output_pair.output_items_)) + qCritical () << "Failed to restore original clouds in MergeCloudCommand::undo!"; } } ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// void -pcl::cloud_composer::MergeCloudCommand::redo() +pcl::cloud_composer::MergeCloudCommand::redo () { - qDebug() << "Redo in MergeCloudCommand "; + qDebug () << "Redo in MergeCloudCommand "; last_was_undo_ = false; - // There is only one output_pair, but that's ok - foreach (OutputPair output_pair, output_data_) { - // Replace the input with the output for this pair - // This works because all input clouds must have same parent, the root item (clouds - // must be on top level) - if (!replaceOriginalWithNew(output_pair.input_items_, output_pair.output_items_)) - qCritical() << "Removal of items failed in MergeCloudCommand::redo"; + //There is only one output_pair, but that's ok + foreach (OutputPair output_pair, output_data_) + { + //Replace the input with the output for this pair + // This works because all input clouds must have same parent, the root item (clouds must be on top level) + if (! replaceOriginalWithNew (output_pair.input_items_, output_pair.output_items_)) + qCritical () << "Removal of items failed in MergeCloudCommand::redo"; + } } + diff --git a/apps/cloud_composer/src/item_inspector.cpp b/apps/cloud_composer/src/item_inspector.cpp index 5851c6da7b2..c32914f26ce 100644 --- a/apps/cloud_composer/src/item_inspector.cpp +++ b/apps/cloud_composer/src/item_inspector.cpp @@ -3,121 +3,133 @@ #include -pcl::cloud_composer::ItemInspector::ItemInspector(QWidget* parent) : QTabWidget(parent) +pcl::cloud_composer::ItemInspector::ItemInspector (QWidget* parent) + : QTabWidget(parent) { current_item_properties_model_ = nullptr; current_project_model_ = nullptr; current_selection_model_ = nullptr; + + parameter_view_ = new QTreeView (); + addTab (parameter_view_, "Parameters"); - parameter_view_ = new QTreeView(); - addTab(parameter_view_, "Parameters"); + } void -pcl::cloud_composer::ItemInspector::setModel(ProjectModel* new_model) +pcl::cloud_composer::ItemInspector::setModel (ProjectModel* new_model) { // DISABLED: JUST KEEP TREES ALWAYS EXPANDED - // If we have a model loaded, save its tree state - // if (current_item_properties_model_) - // storeTreeState (); - QItemSelectionModel* new_selection_model = new_model->getSelectionModel(); + //If we have a model loaded, save its tree state + //if (current_item_properties_model_) + // storeTreeState (); + QItemSelectionModel* new_selection_model = new_model->getSelectionModel (); current_project_model_ = new_model; - - if (current_selection_model_) { - disconnect(current_selection_model_, - SIGNAL(currentChanged(const QModelIndex, const QModelIndex)), - this, - SLOT(selectionChanged(const QModelIndex, const QModelIndex))); - removeTabs(); + + if (current_selection_model_) + { + disconnect (current_selection_model_, SIGNAL (currentChanged (const QModelIndex, const QModelIndex)), + this, SLOT (selectionChanged (const QModelIndex, const QModelIndex))); + removeTabs (); + } current_selection_model_ = new_selection_model; - connect(current_selection_model_, - SIGNAL(currentChanged(const QModelIndex, const QModelIndex)), - this, - SLOT(selectionChanged(const QModelIndex, const QModelIndex))); - - updateView(); + connect (current_selection_model_, SIGNAL (currentChanged (const QModelIndex, const QModelIndex)), + this, SLOT (selectionChanged (const QModelIndex,const QModelIndex))); + + updateView (); + } void -pcl::cloud_composer::ItemInspector::selectionChanged(const QModelIndex&, - const QModelIndex&) +pcl::cloud_composer::ItemInspector::selectionChanged (const QModelIndex &, const QModelIndex &) { - // If we have a model loaded, save its tree state - // if (current_item_properties_model_) - // storeTreeState (); + //If we have a model loaded, save its tree state + // if (current_item_properties_model_) + // storeTreeState (); if (current_project_model_) - updateView(); + updateView (); + } void -pcl::cloud_composer::ItemInspector::storeTreeState() +pcl::cloud_composer::ItemInspector::storeTreeState () { - QList expanded_list; - int row_count = current_item_properties_model_->rowCount(); - for (int i = 0; i < row_count; ++i) { - QModelIndex index = current_item_properties_model_->index(i, 0); - if (parameter_view_->isExpanded(index)) { - expanded_list << QPersistentModelIndex(index); + QList expanded_list; + int row_count = current_item_properties_model_->rowCount (); + for (int i = 0; i < row_count ; ++i) + { + QModelIndex index = current_item_properties_model_->index (i, 0); + if (parameter_view_->isExpanded (index)) + { + expanded_list << QPersistentModelIndex (index); } } // save list - item_treestate_map_.insert(current_item_properties_model_, expanded_list); + item_treestate_map_.insert (current_item_properties_model_, expanded_list); } void -pcl::cloud_composer::ItemInspector::restoreTreeState() +pcl::cloud_composer::ItemInspector::restoreTreeState () { - if (item_treestate_map_.contains(current_item_properties_model_)) { - parameter_view_->setUpdatesEnabled(false); - - foreach (QPersistentModelIndex item_index, - item_treestate_map_.value(current_item_properties_model_)) { - if (item_index.isValid()) - parameter_view_->setExpanded(item_index, true); + if (item_treestate_map_.contains (current_item_properties_model_)) + { + parameter_view_->setUpdatesEnabled (false); + + foreach (QPersistentModelIndex item_index, item_treestate_map_.value (current_item_properties_model_)) + { + if (item_index.isValid ()) + parameter_view_->setExpanded (item_index, true); } - parameter_view_->setUpdatesEnabled(true); + parameter_view_->setUpdatesEnabled (true); } + } -void -pcl::cloud_composer::ItemInspector::itemChanged(QStandardItem*) -{} +void +pcl::cloud_composer::ItemInspector::itemChanged (QStandardItem *) +{ + + +} void -pcl::cloud_composer::ItemInspector::removeTabs() +pcl::cloud_composer::ItemInspector::removeTabs () { - clear(); - addTab(parameter_view_, "Parameters"); + clear (); + addTab (parameter_view_, "Parameters"); } void -pcl::cloud_composer::ItemInspector::updateView() +pcl::cloud_composer::ItemInspector::updateView () { current_item_properties_model_ = nullptr; - QModelIndex current_item = current_selection_model_->currentIndex(); + QModelIndex current_item = current_selection_model_->currentIndex (); const QStandardItemModel* model = nullptr; CloudComposerItem* cloud_item = nullptr; - if (current_item.isValid()) - model = dynamic_cast(current_item.model()); - - if (model) { - cloud_item = dynamic_cast(model->itemFromIndex(current_item)); - if (cloud_item) { - current_item_properties_model_ = - cloud_item->data(ItemDataRole::PROPERTIES).value(); - // Display any additional graphical data if this item has any - QMap tabs = cloud_item->getInspectorTabs(); - foreach (QString tab_name, tabs.keys()) { - addTab(tabs.value(tab_name), tab_name); - tabs.value(tab_name)->show(); + if (current_item.isValid ()) + model = dynamic_cast (current_item.model ()); + + if (model) + { + cloud_item = dynamic_cast (model->itemFromIndex (current_item)); + if (cloud_item) + { + current_item_properties_model_ = cloud_item->data (ItemDataRole::PROPERTIES).value (); + //Display any additional graphical data if this item has any + QMap tabs = cloud_item->getInspectorTabs (); + foreach (QString tab_name, tabs.keys ()) + { + addTab (tabs.value (tab_name), tab_name); + tabs.value (tab_name)->show (); } } } - - parameter_view_->setModel(current_item_properties_model_); - parameter_view_->resizeColumnToContents(0); + + + parameter_view_->setModel (current_item_properties_model_); + parameter_view_->resizeColumnToContents (0); // restoreTreeState (); - parameter_view_->expandAll(); + parameter_view_->expandAll (); } diff --git a/apps/cloud_composer/src/items/cloud_composer_item.cpp b/apps/cloud_composer/src/items/cloud_composer_item.cpp index f5d17b266a5..2d5c786f7c5 100644 --- a/apps/cloud_composer/src/items/cloud_composer_item.cpp +++ b/apps/cloud_composer/src/items/cloud_composer_item.cpp @@ -2,74 +2,74 @@ #include -pcl::cloud_composer::CloudComposerItem::CloudComposerItem(const QString& name) -: QStandardItem(name) +pcl::cloud_composer::CloudComposerItem::CloudComposerItem (const QString& name) + : QStandardItem(name) { - // Set up the properties, store pointer locally for convenience - properties_ = new PropertiesModel(this); - - QString item_id = name + QString("%1").arg((long)this); - - this->setData(QVariant::fromValue(properties_), ItemDataRole::PROPERTIES); - this->setData(QVariant(item_id), ItemDataRole::ITEM_ID); - - this->setForeground(QBrush(Qt::black)); + //Set up the properties, store pointer locally for convenience + properties_ = new PropertiesModel (this); + + QString item_id = name + QString ("%1").arg ((long)this); + + + this->setData (QVariant::fromValue (properties_), ItemDataRole::PROPERTIES); + this->setData (QVariant (item_id), ItemDataRole::ITEM_ID); + + this->setForeground (QBrush (Qt::black)); } -pcl::cloud_composer::CloudComposerItem::~CloudComposerItem() +pcl::cloud_composer::CloudComposerItem::~CloudComposerItem () { - properties_->deleteLater(); + properties_->deleteLater (); } pcl::cloud_composer::CloudComposerItem* -pcl::cloud_composer::CloudComposerItem::clone() const +pcl::cloud_composer::CloudComposerItem::clone () const { - auto* new_item = new CloudComposerItem(this->text()); - - PropertiesModel* new_item_properties = new_item->getPropertiesModel(); - new_item_properties->copyProperties(properties_); - - return new_item; + CloudComposerItem* new_item = new CloudComposerItem (this->text ()); + + PropertiesModel* new_item_properties = new_item->getPropertiesModel (); + new_item_properties->copyProperties (properties_); + + return new_item; } -QList -pcl::cloud_composer::CloudComposerItem::getChildren( - CloudComposerItem::ItemType type) const +QList +pcl::cloud_composer::CloudComposerItem::getChildren (CloudComposerItem::ItemType type) const { - QList items; - for (int i = 0; i < this->rowCount(); ++i) { - if (this->child(i)->type() == type) { - items.append(dynamic_cast(this->child(i))); + QList items; + for (int i = 0; i < this->rowCount (); ++i) + { + if ( this->child (i)->type () == type ) + { + items.append (dynamic_cast (this->child (i))); } } - + return items; } -void -pcl::cloud_composer::CloudComposerItem::addChild(CloudComposerItem* item_arg) +void +pcl::cloud_composer::CloudComposerItem::addChild (CloudComposerItem *item_arg) { - this->appendRow(item_arg); + this->appendRow (item_arg); } void -pcl::cloud_composer::CloudComposerItem::paintView( - pcl::visualization::PCLVisualizer::Ptr) const +pcl::cloud_composer::CloudComposerItem::paintView (pcl::visualization::PCLVisualizer::Ptr) const { - qDebug() << "Paint View in Cloud Composer Item - doing nothing"; + qDebug () << "Paint View in Cloud Composer Item - doing nothing"; } void -pcl::cloud_composer::CloudComposerItem::removeFromView( - pcl::visualization::PCLVisualizer::Ptr) const +pcl::cloud_composer::CloudComposerItem::removeFromView (pcl::visualization::PCLVisualizer::Ptr) const { - qDebug() << "Remove from View in Cloud Composer Item - doing nothing"; + qDebug () << "Remove from View in Cloud Composer Item - doing nothing"; } -QMap -pcl::cloud_composer::CloudComposerItem::getInspectorTabs() +QMap +pcl::cloud_composer::CloudComposerItem::getInspectorTabs () { - return {}; + return QMap (); } /* @@ -78,13 +78,15 @@ CloudPtrT pcl::cloud_composer::CloudComposerItem::getCloudPtr () const { QVariant cloud_variant = this->data (CLOUD); - // Get Extract the pointer from the cloud contained in this item, if the type can't be -converted, default-constructed value is returned CloudPtrT ptr; if -(cloud_variant.canConvert ()) ptr = cloud_variant.value (); + // Get Extract the pointer from the cloud contained in this item, if the type can't be converted, default-constructed value is returned + CloudPtrT ptr; + if (cloud_variant.canConvert ()) + ptr = cloud_variant.value (); else - qCritical () << "Requested Cloud of incorrect type from "<text ()<<" correct -type is "<text ()<<" correct type is "<text (), cloud_copy, origin_,orientation_); + CloudItem* new_item = new CloudItem (this->text (), cloud_copy, origin_,orientation_); PropertiesModel* new_item_properties = new_item->getPropertiesModel (); new_item_properties->copyProperties (properties_); diff --git a/apps/cloud_composer/src/items/fpfh_item.cpp b/apps/cloud_composer/src/items/fpfh_item.cpp index 6fd5efee5fa..96a7e9b3173 100644 --- a/apps/cloud_composer/src/items/fpfh_item.cpp +++ b/apps/cloud_composer/src/items/fpfh_item.cpp @@ -1,53 +1,48 @@ #include +#include #include -#include - -pcl::cloud_composer::FPFHItem::FPFHItem( - QString name, - const pcl::PointCloud::Ptr& fpfh_ptr, - double radius) -: CloudComposerItem(std::move(name)), fpfh_ptr_(fpfh_ptr), radius_(radius) +pcl::cloud_composer::FPFHItem::FPFHItem (QString name, const pcl::PointCloud::Ptr& fpfh_ptr, double radius) + : CloudComposerItem (std::move(name)) + , fpfh_ptr_ (fpfh_ptr) + , radius_ (radius) { pcl::PointCloud::ConstPtr fpfh_const = fpfh_ptr; - this->setData(QVariant::fromValue(fpfh_const), ItemDataRole::CLOUD_TEMPLATED); - properties_->addCategory("Core Properties"); - properties_->addProperty( - "Radius", QVariant(radius_), Qt::ItemIsEnabled, "Core Properties"); + this->setData (QVariant::fromValue (fpfh_const), ItemDataRole::CLOUD_TEMPLATED); + properties_->addCategory ("Core Properties"); + properties_->addProperty ("Radius", QVariant (radius_), Qt::ItemIsEnabled, "Core Properties"); } pcl::cloud_composer::FPFHItem* -pcl::cloud_composer::FPFHItem::clone() const +pcl::cloud_composer::FPFHItem::clone () const { - pcl::PointCloud::Ptr fpfh_copy( - new pcl::PointCloud(*fpfh_ptr_)); - FPFHItem* new_item = new FPFHItem(this->text(), fpfh_copy, radius_); - - PropertiesModel* new_item_properties = new_item->getPropertiesModel(); - new_item_properties->copyProperties(properties_); - - return new_item; + pcl::PointCloud::Ptr fpfh_copy (new pcl::PointCloud (*fpfh_ptr_)); + FPFHItem* new_item = new FPFHItem (this->text (), fpfh_copy, radius_); + + PropertiesModel* new_item_properties = new_item->getPropertiesModel (); + new_item_properties->copyProperties (properties_); + + return new_item; } -QMap -pcl::cloud_composer::FPFHItem::getInspectorTabs() -{ - // Create the plotter and QVTKWidget if it doesn't exist - if (!plot_) { - plot_.reset(new pcl::visualization::PCLPlotter); +QMap +pcl::cloud_composer::FPFHItem::getInspectorTabs () +{ + //Create the plotter and QVTKWidget if it doesn't exist + if (!plot_) + { + plot_.reset (new pcl::visualization::PCLPlotter); qvtk_ = new PCLQVTKWidget(); - hist_page_ = new QWidget(); - auto* mainLayout = new QGridLayout(hist_page_); - mainLayout->addWidget(qvtk_, 0, 0); + hist_page_ = new QWidget (); + QGridLayout *mainLayout = new QGridLayout (hist_page_); + mainLayout-> addWidget (qvtk_,0,0); } - // Plot the histogram - plot_->addFeatureHistogram(*fpfh_ptr_, - fpfh_ptr_->width, - data(ItemDataRole::ITEM_ID).toString().toStdString()); - // Set the render window of the QVTK widget, update + //Plot the histogram + plot_->addFeatureHistogram (*fpfh_ptr_, fpfh_ptr_->width, data(ItemDataRole::ITEM_ID).toString().toStdString ()); + //Set the render window of the QVTK widget, update plot_->setViewInteractor(getInteractorCompat(*qvtk_)); setRenderWindowCompat(*qvtk_, *(plot_->getRenderWindow())); #if VTK_MAJOR_VERSION > 8 @@ -55,9 +50,12 @@ pcl::cloud_composer::FPFHItem::getInspectorTabs() #else qvtk_->update(); #endif // VTK_MAJOR_VERSION > 8 - qvtk_->show(); - - QMap tabs; - tabs.insert("Histogram", hist_page_); + qvtk_->show (); + + + QMap tabs; + tabs.insert ("Histogram",hist_page_); return tabs; } + + diff --git a/apps/cloud_composer/src/items/normals_item.cpp b/apps/cloud_composer/src/items/normals_item.cpp index 20035444a6d..02267ad7922 100644 --- a/apps/cloud_composer/src/items/normals_item.cpp +++ b/apps/cloud_composer/src/items/normals_item.cpp @@ -4,7 +4,7 @@ #include pcl::cloud_composer::NormalsItem::NormalsItem (QString name, const pcl::PointCloud::Ptr& normals_ptr, double radius) - : CloudComposerItem (name) + : CloudComposerItem (std::move(name)) , normals_ptr_ (normals_ptr) { @@ -22,7 +22,7 @@ pcl::cloud_composer::NormalsItem::clone () const { pcl::PointCloud::Ptr normals_copy (new pcl::PointCloud (*normals_ptr_)); //Vector4f and Quaternionf do deep copies using copy constructor - auto* new_item = new NormalsItem (this->text (), normals_copy, 0); + NormalsItem* new_item = new NormalsItem (this->text (), normals_copy, 0); PropertiesModel* new_item_properties = new_item->getPropertiesModel (); new_item_properties->copyProperties (properties_); @@ -37,7 +37,7 @@ pcl::cloud_composer::NormalsItem::paintView (pcl::visualization::PCLVisualizer:: if (parent ()->type () == CLOUD_ITEM) { QVariant cloud_ptr = parent ()->data (ItemDataRole::CLOUD_BLOB); - auto cloud_blob = cloud_ptr.value (); + pcl::PCLPointCloud2::ConstPtr cloud_blob = cloud_ptr.value (); pcl::PointCloud::Ptr cloud (new pcl::PointCloud); pcl::fromPCLPointCloud2 (*cloud_blob, *cloud); double scale = properties_->getProperty ("Scale").toDouble (); diff --git a/apps/cloud_composer/src/main.cpp b/apps/cloud_composer/src/main.cpp index d16a6f6a146..939bad15e72 100644 --- a/apps/cloud_composer/src/main.cpp +++ b/apps/cloud_composer/src/main.cpp @@ -2,12 +2,12 @@ /////////// MAIN //////////////////// int -main(int argc, char** argv) +main (int argc, char ** argv) { // Initialize QT - QApplication app(argc, argv); - + QApplication app (argc, argv); + pcl::cloud_composer::ComposerMainWindow cc; - cc.show(); - return (QApplication::exec()); + cc.show (); + return (QApplication::exec ()); } diff --git a/apps/cloud_composer/src/merge_selection.cpp b/apps/cloud_composer/src/merge_selection.cpp index 0db12df5ce7..63b670f2985 100644 --- a/apps/cloud_composer/src/merge_selection.cpp +++ b/apps/cloud_composer/src/merge_selection.cpp @@ -1,108 +1,112 @@ -#include -#include #include +#include + #include -#include -#include // for pcl::make_shared +#include // for pcl::make_shared #include +#include +#include -pcl::cloud_composer::MergeSelection::MergeSelection( - QMap selected_item_index_map, - QObject* parent) -: MergeCloudTool(nullptr, parent) -, selected_item_index_map_(std::move(selected_item_index_map)) -{} +pcl::cloud_composer::MergeSelection::MergeSelection (QMap selected_item_index_map, QObject* parent) + : MergeCloudTool (nullptr, parent) + , selected_item_index_map_ (std::move(selected_item_index_map)) +{ + +} -QList -pcl::cloud_composer::MergeSelection::performAction(ConstItemList input_data, - PointTypeFlags::PointType type) +QList +pcl::cloud_composer::MergeSelection::performAction (ConstItemList input_data, PointTypeFlags::PointType type) { - if (type != PointTypeFlags::NONE) { - switch (static_cast(type)) { - case (PointTypeFlags::XYZ): - return this->performTemplatedAction(input_data); - case (PointTypeFlags::XYZ | PointTypeFlags::RGB): - return this->performTemplatedAction(input_data); - case (PointTypeFlags::XYZ | PointTypeFlags::RGBA): - return this->performTemplatedAction(input_data); + if (type != PointTypeFlags::NONE) + { + switch ((std::uint8_t) type) + { + case (PointTypeFlags::XYZ): + return this->performTemplatedAction (input_data); + case (PointTypeFlags::XYZ | PointTypeFlags::RGB): + return this->performTemplatedAction (input_data); + case (PointTypeFlags::XYZ | PointTypeFlags::RGBA): + return this->performTemplatedAction (input_data); } } - QList output; + QList output; // Check input data length - if (input_data.empty() && selected_item_index_map_.isEmpty()) { - qCritical() << "Empty input in MergeSelection!"; + if ( input_data.empty () && selected_item_index_map_.isEmpty() ) + { + qCritical () << "Empty input in MergeSelection!"; return output; } - // Make sure all input items are cloud items - foreach (const CloudComposerItem* input_item, input_data) { - if (input_item->type() != CloudComposerItem::CLOUD_ITEM) { - qCritical() << "Input in MergeSelection not valid, contained non-CloudItem input"; + //Make sure all input items are cloud items + foreach (const CloudComposerItem* input_item, input_data) + { + if (input_item->type () != CloudComposerItem::CLOUD_ITEM ) + { + qCritical () << "Input in MergeSelection not valid, contained non-CloudItem input"; return output; } } pcl::ExtractIndices filter; - pcl::PCLPointCloud2::Ptr merged_cloud(new pcl::PCLPointCloud2); - // To Save the pose of the first original item + pcl::PCLPointCloud2::Ptr merged_cloud (new pcl::PCLPointCloud2); + //To Save the pose of the first original item Eigen::Vector4f source_origin; Eigen::Quaternionf source_orientation; bool pose_found = false; - foreach (const CloudItem* input_cloud_item, selected_item_index_map_.keys()) { - // If this cloud hasn't been completely selected - if (!input_data.contains(input_cloud_item)) { - auto input_cloud = input_cloud_item->data(ItemDataRole::CLOUD_BLOB) - .value(); - qDebug() << "Extracting " - << selected_item_index_map_.value(input_cloud_item)->indices.size() - << " points out of " << input_cloud->width; - filter.setInputCloud(input_cloud); - filter.setIndices(selected_item_index_map_.value(input_cloud_item)); - pcl::PCLPointCloud2::Ptr original_minus_indices = - pcl::make_shared(); - filter.setNegative(true); - filter.filter(*original_minus_indices); - filter.setNegative(false); - pcl::PCLPointCloud2::Ptr selected_points(new pcl::PCLPointCloud2); - filter.filter(*selected_points); + foreach (const CloudItem* input_cloud_item, selected_item_index_map_.keys ()) + { + //If this cloud hasn't been completely selected + if (!input_data.contains (input_cloud_item)) + { + pcl::PCLPointCloud2::ConstPtr input_cloud = input_cloud_item->data (ItemDataRole::CLOUD_BLOB).value (); + qDebug () << "Extracting "<indices.size() << " points out of "<width; + filter.setInputCloud (input_cloud); + filter.setIndices (selected_item_index_map_.value (input_cloud_item)); + pcl::PCLPointCloud2::Ptr original_minus_indices = pcl::make_shared (); + filter.setNegative (true); + filter.filter (*original_minus_indices); + filter.setNegative (false); + pcl::PCLPointCloud2::Ptr selected_points (new pcl::PCLPointCloud2); + filter.filter (*selected_points); - qDebug() << "Original minus indices is " << original_minus_indices->width; + qDebug () << "Original minus indices is "<width; - if (!pose_found) { - source_origin = - input_cloud_item->data(ItemDataRole::ORIGIN).value(); - source_orientation = input_cloud_item->data(ItemDataRole::ORIENTATION) - .value(); + if (!pose_found) + { + source_origin = input_cloud_item->data (ItemDataRole::ORIGIN).value (); + source_orientation = input_cloud_item->data (ItemDataRole::ORIENTATION).value (); pose_found = true; } - auto* new_cloud_item = new CloudItem(input_cloud_item->text(), - original_minus_indices, - source_origin, - source_orientation); - output.append(new_cloud_item); - pcl::PCLPointCloud2::Ptr temp_cloud = pcl::make_shared(); - concatenate(*merged_cloud, *selected_points, *temp_cloud); + CloudItem* new_cloud_item = new CloudItem (input_cloud_item->text () + , original_minus_indices + , source_origin + , source_orientation); + output.append (new_cloud_item); + pcl::PCLPointCloud2::Ptr temp_cloud = pcl::make_shared (); + concatenate (*merged_cloud, *selected_points, *temp_cloud); merged_cloud = temp_cloud; } - // Append the input item to the original list - // input_data.append (input_cloud_item); + //Append the input item to the original list + //input_data.append (input_cloud_item); } - // Just concatenate for all fully selected clouds - foreach (const CloudComposerItem* input_item, input_data) { - auto input_cloud = input_item->data(ItemDataRole::CLOUD_BLOB) - .value(); + //Just concatenate for all fully selected clouds + foreach (const CloudComposerItem* input_item, input_data) + { + pcl::PCLPointCloud2::ConstPtr input_cloud = input_item->data (ItemDataRole::CLOUD_BLOB).value (); - pcl::PCLPointCloud2::Ptr temp_cloud = pcl::make_shared(); - concatenate(*merged_cloud, *input_cloud, *temp_cloud); + pcl::PCLPointCloud2::Ptr temp_cloud = pcl::make_shared (); + concatenate (*merged_cloud, *input_cloud, *temp_cloud); merged_cloud = temp_cloud; } - auto* cloud_item = new CloudItem( - "Cloud from Selection", merged_cloud, source_origin, source_orientation); + CloudItem* cloud_item = new CloudItem ("Cloud from Selection" + , merged_cloud + , source_origin + , source_orientation); - output.append(cloud_item); + output.append (cloud_item); return output; } diff --git a/apps/cloud_composer/src/point_selectors/click_trackball_interactor_style.cpp b/apps/cloud_composer/src/point_selectors/click_trackball_interactor_style.cpp index 1f6bea5245d..791e0218ad6 100644 --- a/apps/cloud_composer/src/point_selectors/click_trackball_interactor_style.cpp +++ b/apps/cloud_composer/src/point_selectors/click_trackball_interactor_style.cpp @@ -4,101 +4,117 @@ #include + #include // For vtkStandardNewMacro #include -namespace pcl { -namespace cloud_composer { -vtkStandardNewMacro(ClickTrackballStyleInteractor); +namespace pcl +{ + namespace cloud_composer + { + vtkStandardNewMacro(ClickTrackballStyleInteractor); + } } -} // namespace pcl -pcl::cloud_composer::ClickTrackballStyleInteractor::ClickTrackballStyleInteractor() +pcl::cloud_composer::ClickTrackballStyleInteractor::ClickTrackballStyleInteractor () { manipulation_complete_event_ = interactor_events::MANIPULATION_COMPLETE_EVENT; - start_matrix_ = vtkSmartPointer::New(); - end_matrix_ = vtkSmartPointer::New(); - transform_ = vtkSmartPointer::New(); + start_matrix_= vtkSmartPointer::New (); + end_matrix_ = vtkSmartPointer::New (); + transform_ = vtkSmartPointer::New (); } void -pcl::cloud_composer::ClickTrackballStyleInteractor::OnLeftButtonDown() +pcl::cloud_composer::ClickTrackballStyleInteractor::OnLeftButtonDown () { vtkInteractorStyleTrackballActor::OnLeftButtonDown(); - + vtkActor* selected_actor = vtkActor::SafeDownCast(this->InteractionProp); if (selected_actor) - selected_actor->GetMatrix(start_matrix_); + selected_actor->GetMatrix (start_matrix_); + } void -pcl::cloud_composer::ClickTrackballStyleInteractor::OnRightButtonDown() +pcl::cloud_composer::ClickTrackballStyleInteractor::OnRightButtonDown () { vtkInteractorStyleTrackballActor::OnRightButtonDown(); - + vtkActor* selected_actor = vtkActor::SafeDownCast(this->InteractionProp); if (selected_actor) - selected_actor->GetMatrix(start_matrix_); + selected_actor->GetMatrix (start_matrix_); + } void -pcl::cloud_composer::ClickTrackballStyleInteractor::OnLeftButtonUp() +pcl::cloud_composer::ClickTrackballStyleInteractor::OnLeftButtonUp () { vtkInteractorStyleTrackballActor::OnLeftButtonUp(); - vtkSmartPointer selected_actor = - vtkActor::SafeDownCast(this->InteractionProp); - if (selected_actor) { - // Fetch the actor we manipulated - - selected_actor->GetMatrix(end_matrix_); + vtkSmartPointer selected_actor = vtkActor::SafeDownCast(this->InteractionProp); + if (selected_actor) + { + //Fetch the actor we manipulated + + selected_actor->GetMatrix (end_matrix_); // Find the id of the actor we manipulated - auto end = actors_->end(); + pcl::visualization::CloudActorMap::const_iterator end = actors_->end (); QString manipulated_id; - for (auto itr = actors_->begin(); itr != end; ++itr) { - // qDebug () << "Id = "<first); - if ((itr->second).actor == selected_actor) { - manipulated_id = (QString::fromStdString(itr->first)); + for( pcl::visualization::CloudActorMap::const_iterator itr = actors_->begin (); itr != end; ++itr) + { + //qDebug () << "Id = "<first); + if ( (itr->second).actor == selected_actor) + { + manipulated_id = (QString::fromStdString (itr->first)); + } } - if (!manipulated_id.isEmpty()) { - auto* manip_event = new ManipulationEvent(); - manip_event->addManipulation(manipulated_id, start_matrix_, end_matrix_); - this->InvokeEvent(this->manipulation_complete_event_, manip_event); + if ( !manipulated_id.isEmpty() ) + { + ManipulationEvent* manip_event = new ManipulationEvent (); + manip_event->addManipulation (manipulated_id, start_matrix_, end_matrix_); + this->InvokeEvent (this->manipulation_complete_event_, manip_event); } - else { - qWarning() << "Could not find actor which matches manipulated actor in " - "ClickTrackballStyleInteractor::OnLeftButtonUp!!!"; + else + { + qWarning () << "Could not find actor which matches manipulated actor in ClickTrackballStyleInteractor::OnLeftButtonUp!!!"; } } } void -pcl::cloud_composer::ClickTrackballStyleInteractor::OnRightButtonUp() +pcl::cloud_composer::ClickTrackballStyleInteractor::OnRightButtonUp () { vtkInteractorStyleTrackballActor::OnRightButtonUp(); - vtkSmartPointer selected_actor = - vtkActor::SafeDownCast(this->InteractionProp); - if (selected_actor) { - // Fetch the actor we manipulated - - selected_actor->GetMatrix(end_matrix_); + vtkSmartPointer selected_actor = vtkActor::SafeDownCast(this->InteractionProp); + if (selected_actor) + { + //Fetch the actor we manipulated + + selected_actor->GetMatrix (end_matrix_); // Find the id of the actor we manipulated - auto end = actors_->end(); + pcl::visualization::CloudActorMap::const_iterator end = actors_->end (); QString manipulated_id; - for (auto itr = actors_->begin(); itr != end; ++itr) { - // qDebug () << "Id = "<first); - if ((itr->second).actor == selected_actor) { - manipulated_id = (QString::fromStdString(itr->first)); + for( pcl::visualization::CloudActorMap::const_iterator itr = actors_->begin (); itr != end; ++itr) + { + //qDebug () << "Id = "<first); + if ( (itr->second).actor == selected_actor) + { + manipulated_id = (QString::fromStdString (itr->first)); + } } - if (!manipulated_id.isEmpty()) { - auto* manip_event = new ManipulationEvent(); - manip_event->addManipulation(manipulated_id, start_matrix_, end_matrix_); - this->InvokeEvent(this->manipulation_complete_event_, manip_event); + if ( !manipulated_id.isEmpty() ) + { + ManipulationEvent* manip_event = new ManipulationEvent (); + manip_event->addManipulation (manipulated_id, start_matrix_, end_matrix_); + this->InvokeEvent (this->manipulation_complete_event_, manip_event); } - else { - qWarning() << "Could not find actor which matches manipulated actor in " - "ClickTrackballStyleInteractor::OnRightButtonUp!!!"; + else + { + qWarning () << "Could not find actor which matches manipulated actor in ClickTrackballStyleInteractor::OnRightButtonUp!!!"; } } + } + + diff --git a/apps/cloud_composer/src/point_selectors/interactor_style_switch.cpp b/apps/cloud_composer/src/point_selectors/interactor_style_switch.cpp index a04d2d45a27..3744a244a32 100644 --- a/apps/cloud_composer/src/point_selectors/interactor_style_switch.cpp +++ b/apps/cloud_composer/src/point_selectors/interactor_style_switch.cpp @@ -1,7 +1,7 @@ -#include #include #include #include +#include #include #include @@ -9,113 +9,118 @@ #include #include -namespace pcl { -namespace cloud_composer { -vtkStandardNewMacro(InteractorStyleSwitch); +namespace pcl +{ + namespace cloud_composer + { + vtkStandardNewMacro(InteractorStyleSwitch); + } } -} // namespace pcl -pcl::cloud_composer::InteractorStyleSwitch::InteractorStyleSwitch() +pcl::cloud_composer::InteractorStyleSwitch::InteractorStyleSwitch () { - pcl_vis_style_ = - vtkSmartPointer::New(); - name_to_style_map_.insert(interactor_styles::PCL_VISUALIZER, pcl_vis_style_); - - rectangular_frustum_selector_ = vtkSmartPointer::New(); - name_to_style_map_.insert(interactor_styles::RECTANGULAR_FRUSTUM, - rectangular_frustum_selector_); - - selected_trackball_interactor_style_ = - vtkSmartPointer::New(); - name_to_style_map_.insert(interactor_styles::SELECTED_TRACKBALL, - selected_trackball_interactor_style_); - - click_trackball_interactor_style_ = - vtkSmartPointer::New(); - name_to_style_map_.insert(interactor_styles::CLICK_TRACKBALL, - click_trackball_interactor_style_); - + pcl_vis_style_ = vtkSmartPointer::New (); + name_to_style_map_.insert (interactor_styles::PCL_VISUALIZER, pcl_vis_style_); + + rectangular_frustum_selector_ = vtkSmartPointer::New (); + name_to_style_map_.insert (interactor_styles::RECTANGULAR_FRUSTUM, rectangular_frustum_selector_); + + selected_trackball_interactor_style_ = vtkSmartPointer ::New (); + name_to_style_map_.insert (interactor_styles::SELECTED_TRACKBALL, selected_trackball_interactor_style_); + + click_trackball_interactor_style_ = vtkSmartPointer ::New (); + name_to_style_map_.insert (interactor_styles::CLICK_TRACKBALL, click_trackball_interactor_style_); + area_picker_ = vtkSmartPointer::New(); - point_picker_ = vtkSmartPointer::New(); - + point_picker_ = vtkSmartPointer::New (); + current_style_ = nullptr; + } void -pcl::cloud_composer::InteractorStyleSwitch::initializeInteractorStyles( - pcl::visualization::PCLVisualizer::Ptr vis, ProjectModel* model) +pcl::cloud_composer::InteractorStyleSwitch::initializeInteractorStyles (pcl::visualization::PCLVisualizer::Ptr vis, ProjectModel* model) { - qDebug() << "Initializing Interactor Styles"; + qDebug () << "Initializing Interactor Styles"; vis_ = std::move(vis); project_model_ = model; - - pcl_vis_style_->Initialize(); - rens_ = vis_->getRendererCollection(); - pcl_vis_style_->setRendererCollection(rens_); - pcl_vis_style_->setCloudActorMap(vis_->getCloudActorMap()); - - rectangular_frustum_selector_->setCloudActorMap(vis_->getCloudActorMap()); - - selected_trackball_interactor_style_->setCloudActorMap(vis_->getCloudActorMap()); - selected_trackball_interactor_style_->setProjectModel(project_model_); - - click_trackball_interactor_style_->setCloudActorMap(vis_->getCloudActorMap()); - click_trackball_interactor_style_->setProjectModel(project_model_); + + pcl_vis_style_->Initialize (); + rens_ = vis_->getRendererCollection (); + pcl_vis_style_->setRendererCollection (rens_); + pcl_vis_style_->setCloudActorMap (vis_->getCloudActorMap ()); + + rectangular_frustum_selector_->setCloudActorMap (vis_->getCloudActorMap ()); + + selected_trackball_interactor_style_->setCloudActorMap (vis_->getCloudActorMap ()); + selected_trackball_interactor_style_->setProjectModel (project_model_); + + click_trackball_interactor_style_->setCloudActorMap (vis_->getCloudActorMap ()); + click_trackball_interactor_style_->setProjectModel (project_model_); } void -pcl::cloud_composer::InteractorStyleSwitch::setCurrentInteractorStyle( - interactor_styles::INTERACTOR_STYLES interactor_style) +pcl::cloud_composer::InteractorStyleSwitch::setCurrentInteractorStyle (interactor_styles::INTERACTOR_STYLES interactor_style) { - qDebug() << "Setting interactor style"; - vtkSmartPointer style_ptr = - name_to_style_map_.value(interactor_style); + qDebug () << "Setting interactor style"; + vtkSmartPointer style_ptr = name_to_style_map_.value (interactor_style); if (current_style_) - current_style_->SetInteractor(nullptr); - current_style_ = style_ptr; - - if (current_style_) { - qDebug() << "Modifying current interactor of style!"; - current_style_->SetInteractor(this->Interactor); - current_style_->SetTDxStyle(this->TDxStyle); - - if (interactor_style == interactor_styles::RECTANGULAR_FRUSTUM) { - vtkInteractorStyleRubberBandPick* rubber_band_style = - vtkInteractorStyleRubberBandPick::SafeDownCast(current_style_); - if (rubber_band_style) { - vis_->getRenderWindow()->GetInteractor()->SetPicker(area_picker_); - rubber_band_style->StartSelect(); + current_style_->SetInteractor (nullptr); + current_style_= style_ptr; + + if (current_style_) + { + qDebug () << "Modifying current interactor of style!"; + current_style_->SetInteractor (this->Interactor); + current_style_->SetTDxStyle (this->TDxStyle); + + if (interactor_style == interactor_styles::RECTANGULAR_FRUSTUM) + { + vtkInteractorStyleRubberBandPick* rubber_band_style = vtkInteractorStyleRubberBandPick::SafeDownCast (current_style_); + if (rubber_band_style) + { + vis_->getRenderWindow ()->GetInteractor ()->SetPicker (area_picker_); + rubber_band_style->StartSelect (); } } + + } + + + } //---------------------------------------------------------------------------- -void -pcl::cloud_composer::InteractorStyleSwitch::SetInteractor( - vtkRenderWindowInteractor* iren) +void +pcl::cloud_composer::InteractorStyleSwitch::SetInteractor (vtkRenderWindowInteractor *iren) { - if (iren == this->Interactor) { + if(iren == this->Interactor) + { return; } // if we already have an Interactor then stop observing it - if (this->Interactor) { + if(this->Interactor) + { this->Interactor->RemoveObserver(this->EventCallbackCommand); } this->Interactor = iren; // add observers for each of the events handled in ProcessEvents - if (iren) { - iren->AddObserver( - vtkCommand::CharEvent, this->EventCallbackCommand, this->Priority); - - iren->AddObserver( - vtkCommand::DeleteEvent, this->EventCallbackCommand, this->Priority); + if(iren) + { + iren->AddObserver(vtkCommand::CharEvent, + this->EventCallbackCommand, + this->Priority); + + iren->AddObserver(vtkCommand::DeleteEvent, + this->EventCallbackCommand, + this->Priority); } } //---------------------------------------------------------------------------- -void -pcl::cloud_composer::InteractorStyleSwitch::SetDefaultRenderer(vtkRenderer* renderer) +void +pcl::cloud_composer::InteractorStyleSwitch::SetDefaultRenderer (vtkRenderer* renderer) { vtkInteractorStyle::SetDefaultRenderer(renderer); pcl_vis_style_->SetDefaultRenderer(renderer); @@ -123,8 +128,8 @@ pcl::cloud_composer::InteractorStyleSwitch::SetDefaultRenderer(vtkRenderer* rend } //---------------------------------------------------------------------------- -void -pcl::cloud_composer::InteractorStyleSwitch::SetCurrentRenderer(vtkRenderer* renderer) +void +pcl::cloud_composer::InteractorStyleSwitch::SetCurrentRenderer (vtkRenderer* renderer) { this->vtkInteractorStyle::SetCurrentRenderer(renderer); pcl_vis_style_->SetCurrentRenderer(renderer); @@ -132,7 +137,7 @@ pcl::cloud_composer::InteractorStyleSwitch::SetCurrentRenderer(vtkRenderer* rend } void -pcl::cloud_composer::InteractorStyleSwitch::OnLeave() +pcl::cloud_composer::InteractorStyleSwitch::OnLeave () { - qDebug() << "ON LEAVE"; + qDebug () << "ON LEAVE"; } diff --git a/apps/cloud_composer/src/point_selectors/manipulation_event.cpp b/apps/cloud_composer/src/point_selectors/manipulation_event.cpp index f416edfbd10..7c70d738fa2 100644 --- a/apps/cloud_composer/src/point_selectors/manipulation_event.cpp +++ b/apps/cloud_composer/src/point_selectors/manipulation_event.cpp @@ -1,11 +1,9 @@ #include void -pcl::cloud_composer::ManipulationEvent::addManipulation( - const QString& id, - const vtkSmartPointer& start, - const vtkSmartPointer& end) +pcl::cloud_composer::ManipulationEvent::addManipulation (const QString& id, const vtkSmartPointer& start, const vtkSmartPointer& end) { - id_start_map_.insert(id, start); - id_end_map_.insert(id, end); + id_start_map_.insert (id, start); + id_end_map_.insert (id, end); + } diff --git a/apps/cloud_composer/src/point_selectors/rectangular_frustum_selector.cpp b/apps/cloud_composer/src/point_selectors/rectangular_frustum_selector.cpp index c94a135cab5..22f0de1c526 100644 --- a/apps/cloud_composer/src/point_selectors/rectangular_frustum_selector.cpp +++ b/apps/cloud_composer/src/point_selectors/rectangular_frustum_selector.cpp @@ -3,99 +3,88 @@ #include -#include -#include -#include -#if VTK_MAJOR_VERSION > 9 || (VTK_MAJOR_VERSION == 9 && VTK_MINOR_VERSION >= 4) -#include -#else -#include -#endif -#include -#include #include +#include +#include #include +#include +#include +#include -namespace pcl { -namespace cloud_composer { -vtkStandardNewMacro(RectangularFrustumSelector); +namespace pcl +{ + namespace cloud_composer + { + vtkStandardNewMacro(RectangularFrustumSelector); + } } -} // namespace pcl -pcl::cloud_composer::RectangularFrustumSelector::RectangularFrustumSelector() +pcl::cloud_composer::RectangularFrustumSelector::RectangularFrustumSelector () { selection_complete_event_ = interactor_events::SELECTION_COMPLETE_EVENT; } void -pcl::cloud_composer::RectangularFrustumSelector::OnLeftButtonUp() +pcl::cloud_composer::RectangularFrustumSelector::OnLeftButtonUp () { - + vtkSmartPointer selected_actor = vtkSmartPointer::New(); - vtkSmartPointer selected_mapper = - vtkSmartPointer::New(); + vtkSmartPointer selected_mapper = vtkSmartPointer::New(); selected_actor->SetMapper(selected_mapper); - - vtkInteractorStyleRubberBandPick::OnLeftButtonUp(); - - vtkPlanes* frustum = - dynamic_cast(this->GetInteractor()->GetPicker())->GetFrustum(); - -#if VTK_MAJOR_VERSION > 9 || (VTK_MAJOR_VERSION == 9 && VTK_MINOR_VERSION >= 4) - vtkSmartPointer id_filter = vtkSmartPointer::New(); -#else - vtkSmartPointer id_filter = vtkSmartPointer::New(); -#endif - id_filter->PointIdsOn(); - - vtkSmartPointer extract_geometry = - vtkSmartPointer::New(); - extract_geometry->SetImplicitFunction(frustum); - extract_geometry->SetInputConnection(id_filter->GetOutputPort()); - - vtkSmartPointer glyph_filter = - vtkSmartPointer::New(); - glyph_filter->SetInputConnection(extract_geometry->GetOutputPort()); - - vtkSmartPointer append = vtkAppendPolyData::New(); - - QMap id_selected_data_map; - for (const auto& actor : *actors_) { - const pcl::visualization::CloudActor* act = &actor.second; - vtkMapper* mapper = act->actor->GetMapper(); - vtkDataSet* data = mapper->GetInput(); - vtkPolyData* poly_data = vtkPolyData::SafeDownCast(data); - id_filter->SetInputData(poly_data); - - vtkSmartPointer selected = vtkSmartPointer::New(); - glyph_filter->SetOutput(selected); - glyph_filter->Update(); - if (selected->GetNumberOfPoints() > 0) { - qDebug() << "Selected " << selected->GetNumberOfPoints() << " points."; - id_selected_data_map.insert(QString::fromStdString(actor.first), selected); - append->AddInputData(selected); - } + + vtkInteractorStyleRubberBandPick::OnLeftButtonUp (); + + vtkPlanes* frustum = static_cast (this->GetInteractor ()->GetPicker ())->GetFrustum (); + + vtkSmartPointer id_filter = vtkSmartPointer::New (); + id_filter->PointIdsOn (); + + vtkSmartPointer extract_geometry = vtkSmartPointer::New (); + extract_geometry->SetImplicitFunction (frustum); + extract_geometry->SetInputConnection (id_filter->GetOutputPort ()); + + vtkSmartPointer glyph_filter = vtkSmartPointer::New (); + glyph_filter->SetInputConnection (extract_geometry->GetOutputPort ()); + + vtkSmartPointer append = vtkAppendPolyData::New (); + + QMap < QString, vtkPolyData* > id_selected_data_map; + for (const auto &actor : *actors_) + { + const pcl::visualization::CloudActor *act = &actor.second; + vtkMapper* mapper = act->actor->GetMapper (); + vtkDataSet* data = mapper->GetInput (); + vtkPolyData* poly_data = vtkPolyData::SafeDownCast (data); + id_filter->SetInputData (poly_data); + + vtkSmartPointer selected = vtkSmartPointer::New (); + glyph_filter->SetOutput (selected); + glyph_filter->Update (); + if (selected->GetNumberOfPoints() > 0) + { + qDebug () << "Selected " << selected->GetNumberOfPoints () << " points."; + id_selected_data_map.insert ( QString::fromStdString (actor.first), selected); + append->AddInputData (selected); + } } - append->Update(); - vtkSmartPointer all_points = append->GetOutput(); - qDebug() << "Allpoints = " << all_points->GetNumberOfPoints(); - - selected_mapper->SetInputData(all_points); - selected_mapper->ScalarVisibilityOff(); - - selected_actor->GetProperty()->SetColor(0.0, 1.0, 0.0); //(R,G,B) - selected_actor->GetProperty()->SetPointSize(3); - - this->CurrentRenderer->AddActor(selected_actor); - this->GetInteractor()->GetRenderWindow()->Render(); - this->HighlightProp(nullptr); - - if (all_points->GetNumberOfPoints() > 0) { - auto* selected = new SelectionEvent(all_points, - selected_actor, - selected_mapper, - id_selected_data_map, - this->CurrentRenderer); - this->InvokeEvent(this->selection_complete_event_, selected); + append->Update (); + vtkSmartPointer all_points = append->GetOutput (); + qDebug () << "Allpoints = " <GetNumberOfPoints (); + + selected_mapper->SetInputData (all_points); + selected_mapper->ScalarVisibilityOff (); + + selected_actor->GetProperty ()->SetColor (0.0, 1.0, 0.0); //(R,G,B) + selected_actor->GetProperty ()->SetPointSize (3); + + this->CurrentRenderer->AddActor (selected_actor); + this->GetInteractor ()->GetRenderWindow ()->Render (); + this->HighlightProp (nullptr); + + if (all_points->GetNumberOfPoints () > 0) + { + SelectionEvent* selected = new SelectionEvent (all_points, selected_actor, selected_mapper, id_selected_data_map, this->CurrentRenderer); + this->InvokeEvent (this->selection_complete_event_, selected); } } + diff --git a/apps/cloud_composer/src/point_selectors/selected_trackball_interactor_style.cpp b/apps/cloud_composer/src/point_selectors/selected_trackball_interactor_style.cpp index 0732f5969e8..264e5f2f64b 100644 --- a/apps/cloud_composer/src/point_selectors/selected_trackball_interactor_style.cpp +++ b/apps/cloud_composer/src/point_selectors/selected_trackball_interactor_style.cpp @@ -4,116 +4,124 @@ #include #include -#include -#include +#include #include -#include +#include +#include #include -#include #include +#include -namespace pcl { -namespace cloud_composer { -vtkStandardNewMacro(SelectedTrackballStyleInteractor); + +namespace pcl +{ + namespace cloud_composer + { + vtkStandardNewMacro(SelectedTrackballStyleInteractor); + } } -} // namespace pcl -pcl::cloud_composer::SelectedTrackballStyleInteractor:: - SelectedTrackballStyleInteractor() +pcl::cloud_composer::SelectedTrackballStyleInteractor::SelectedTrackballStyleInteractor () { - manipulation_complete_event_ = interactor_events::MANIPULATION_COMPLETE_EVENT; + manipulation_complete_event_ = interactor_events::MANIPULATION_COMPLETE_EVENT; } void -pcl::cloud_composer::SelectedTrackballStyleInteractor::setSelectedActors() +pcl::cloud_composer::SelectedTrackballStyleInteractor::setSelectedActors () { - QList selected_cloud_ids; - QModelIndexList selected_indexes = model_->getSelectionModel()->selectedIndexes(); - foreach (QModelIndex index, selected_indexes) { - QStandardItem* item = model_->itemFromIndex(index); - auto* cloud_item = dynamic_cast(item); + QList selected_cloud_ids; + QModelIndexList selected_indexes = model_->getSelectionModel()->selectedIndexes (); + foreach (QModelIndex index, selected_indexes) + { + QStandardItem* item = model_->itemFromIndex (index); + CloudItem* cloud_item = dynamic_cast (item); if (cloud_item) - selected_cloud_ids.append(cloud_item->getId()); + selected_cloud_ids.append (cloud_item->getId ()); } - - for (const auto& actorItem : *actors_) { - QString id = QString::fromStdString(actorItem.first); - if (selected_cloud_ids.contains(id)) { + + for (const auto &actorItem : *actors_) + { + QString id = QString::fromStdString (actorItem.first); + if (selected_cloud_ids.contains (id)) + { vtkLODActor* actor = actorItem.second.actor; - qDebug() << "Adding " << id << " to selected manip! ptr =" << actor; - selected_actors_map_.insert(id, actor); - vtkSmartPointer start_matrix = vtkSmartPointer::New(); - actor->GetMatrix(start_matrix); - start_matrix_map_.insert(id, start_matrix); + qDebug () << "Adding "<getId())) { - vtkPolyData* points_in_item = id_selected_data_map_.value(cloud_item->getId()); - vtkIdTypeArray* point_ids = vtkIdTypeArray::SafeDownCast( - points_in_item->GetPointData()->GetArray("vtkIdFilter_Ids")); - - indices->indices.resize(point_ids->GetNumberOfTuples()); - for (vtkIdType i = 0; i < point_ids->GetNumberOfTuples(); ++i) { - // qDebug () << "id="<GetValue (i); - indices->indices[i] = point_ids->GetValue(i); + if (id_selected_data_map_.contains (cloud_item->getId ())) + { + vtkPolyData* points_in_item = id_selected_data_map_.value (cloud_item->getId ()); + vtkIdTypeArray* point_ids = vtkIdTypeArray::SafeDownCast(points_in_item->GetPointData ()->GetArray ("vtkIdFilter_Ids")); + + indices->indices.resize (point_ids->GetNumberOfTuples ()); + for(vtkIdType i =0; i < point_ids->GetNumberOfTuples (); ++i) + { + //qDebug () << "id="<GetValue (i); + indices->indices[i] = point_ids->GetValue (i); } - // qDebug () << points_in_item->GetNumberOfPoints () << " selected points in - // "<getId (); + //qDebug () << points_in_item->GetNumberOfPoints () << " selected points in "<getId (); } + } diff --git a/apps/cloud_composer/src/project_model.cpp b/apps/cloud_composer/src/project_model.cpp index d20d96f85db..39963959348 100644 --- a/apps/cloud_composer/src/project_model.cpp +++ b/apps/cloud_composer/src/project_model.cpp @@ -107,7 +107,7 @@ pcl::cloud_composer::ProjectModel::setPointSelection (const std::shared_ptr project_clouds; for (int i = 0; i < this->rowCount (); ++i) { - auto* cloud_item = dynamic_cast (this->item (i)); + CloudItem* cloud_item = dynamic_cast (this->item (i)); if ( cloud_item ) project_clouds.append ( cloud_item ); } @@ -137,7 +137,7 @@ pcl::cloud_composer::ProjectModel::manipulateClouds (const std::shared_ptr project_clouds; for (int i = 0; i < this->rowCount (); ++i) { - auto* cloud_item = dynamic_cast (this->item (i)); + CloudItem* cloud_item = dynamic_cast (this->item (i)); if ( cloud_item ) project_clouds.append ( cloud_item ); } @@ -146,7 +146,7 @@ pcl::cloud_composer::ProjectModel::manipulateClouds (const std::shared_ptr ids = transform_map.keys (); ConstItemList input_data; - auto* transform_tool = new TransformClouds (transform_map); + TransformClouds* transform_tool = new TransformClouds (transform_map); foreach (CloudItem* cloud_item, project_clouds) { if (ids.contains (cloud_item->getId ())) @@ -208,7 +208,7 @@ pcl::cloud_composer::ProjectModel::insertNewCloudFromFile () } short_filename += tr ("-%1").arg (k); } - auto* new_item = new CloudItem (short_filename, cloud_blob, origin, orientation, true); + CloudItem* new_item = new CloudItem (short_filename, cloud_blob, origin, orientation, true); insertNewCloudComposerItem (new_item, invisibleRootItem()); @@ -301,7 +301,7 @@ pcl::cloud_composer::ProjectModel::insertNewCloudFromRGBandDepth () { PointXYZRGB new_point; // std::uint8_t* p_i = &(cloud_blob->data[y * cloud_blob->row_step + x * cloud_blob->point_step]); - float depth = static_cast(*depth_pixel) * scale; + float depth = (float)(*depth_pixel) * scale; // qDebug () << "Depth = "<(x - centerX)) * depth * fl_const; - new_point.y = (static_cast(centerY - y)) * depth * fl_const; // vtk seems to start at the bottom left image corner + new_point.x = ((float)(x - centerX)) * depth * fl_const; + new_point.y = ((float)(centerY - y)) * depth * fl_const; // vtk seems to start at the bottom left image corner new_point.z = depth; } @@ -362,7 +362,7 @@ pcl::cloud_composer::ProjectModel::saveSelectedCloudToFile () } QStandardItem* item = this->itemFromIndex (selected_indexes.value (0)); - auto* cloud_to_save = dynamic_cast (item); + CloudItem* cloud_to_save = dynamic_cast (item); if (!cloud_to_save ) { QMessageBox::warning (qobject_cast(this->parent ()), "Not a Cloud!", "Selected item is not a cloud, not saving!"); @@ -470,7 +470,7 @@ pcl::cloud_composer::ProjectModel::deleteSelectedItems () input_data.append (dynamic_cast (item)); } // qDebug () << "Input for command is "<setInputData (input_data); if (delete_command->runCommand (nullptr)) commandCompleted(delete_command); @@ -525,7 +525,7 @@ pcl::cloud_composer::ProjectModel::createNewCloudFromSelection () QMap selected_const_map; foreach ( CloudItem* item, selected_item_index_map_.keys ()) selected_const_map.insert (item, selected_item_index_map_.value (item)); - auto* merge_tool = new MergeSelection (selected_const_map); + MergeSelection* merge_tool = new MergeSelection (selected_const_map); //We don't call the enqueueToolAction function since that would abort if we only have a green selection //Move the tool object to the work queue thread diff --git a/apps/cloud_composer/src/properties_model.cpp b/apps/cloud_composer/src/properties_model.cpp index c5e3fcc5c29..5ac24ddb669 100644 --- a/apps/cloud_composer/src/properties_model.cpp +++ b/apps/cloud_composer/src/properties_model.cpp @@ -1,129 +1,126 @@ -#include #include +#include #include -pcl::cloud_composer::PropertiesModel::PropertiesModel(QObject* parent) -: QStandardItemModel(parent) +pcl::cloud_composer::PropertiesModel::PropertiesModel (QObject* parent) + : QStandardItemModel (parent) { - setHorizontalHeaderItem(0, new QStandardItem("Name")); - setHorizontalHeaderItem(1, new QStandardItem("Value")); + setHorizontalHeaderItem (0, new QStandardItem ("Name")); + setHorizontalHeaderItem (1, new QStandardItem ("Value")); } -pcl::cloud_composer::PropertiesModel::PropertiesModel(CloudComposerItem* parent_item, - QObject* parent) -: QStandardItemModel(parent), parent_item_(parent_item) +pcl::cloud_composer::PropertiesModel::PropertiesModel (CloudComposerItem* parent_item, QObject* parent) + : QStandardItemModel (parent) + , parent_item_ (parent_item) { - setHorizontalHeaderItem(0, new QStandardItem("Name")); - setHorizontalHeaderItem(1, new QStandardItem("Value")); - - connect(this, - SIGNAL(itemChanged(QStandardItem*)), - this, - SLOT(propertyChanged(QStandardItem*))); + setHorizontalHeaderItem (0, new QStandardItem ("Name")); + setHorizontalHeaderItem (1, new QStandardItem ("Value")); + + connect (this, SIGNAL (itemChanged (QStandardItem*)), + this, SLOT (propertyChanged (QStandardItem*))); } -pcl::cloud_composer::PropertiesModel::PropertiesModel(const PropertiesModel& to_copy) -: QStandardItemModel() +pcl::cloud_composer::PropertiesModel::PropertiesModel (const PropertiesModel& to_copy) +: QStandardItemModel () { - for (int i = 0; i < to_copy.rowCount(); ++i) { - QList new_row; - QStandardItem* parent = to_copy.item(i, 0); - QModelIndex parent_index = to_copy.index(i, 0); - new_row.append(parent->clone()); - for (int j = 0; j < to_copy.columnCount(parent_index); ++j) { - if (to_copy.item(i, j)) - new_row.append(to_copy.item(i, j)->clone()); + for (int i=0; i < to_copy.rowCount (); ++i){ + QList new_row; + QStandardItem* parent = to_copy.item(i,0); + QModelIndex parent_index = to_copy.index(i,0); + new_row.append (parent->clone ()); + for (int j=0; j < to_copy.columnCount (parent_index); ++j) + { + if (to_copy.item (i,j)) + new_row.append (to_copy.item(i,j)->clone ()); } - appendRow(new_row); + appendRow (new_row); } } void -pcl::cloud_composer::PropertiesModel::addProperty(const QString& prop_name, - const QVariant& value, - Qt::ItemFlags flags, - const QString& category) +pcl::cloud_composer::PropertiesModel::addProperty (const QString& prop_name, const QVariant& value, Qt::ItemFlags flags, const QString& category) { - QStandardItem* parent_item = invisibleRootItem(); - if (category.size() > 0) { - QList items = findItems(category); - if (items.empty()) - qWarning() << "No category named " << prop_name << " found in " - << parent_item_->text() << " adding to root"; - else if (items.size() > 1) - qCritical() << "Multiple categories with same name found!! This is not good..."; + QStandardItem* parent_item = invisibleRootItem (); + if (category.size () > 0) + { + QList items = findItems (category); + if (items.empty ()) + qWarning () << "No category named "<text ()<<" adding to root"; + else if (items.size () > 1) + qCritical () << "Multiple categories with same name found!! This is not good..."; else - parent_item = items.at(0); + parent_item = items.at (0); } - QList new_row; - auto* new_property = new QStandardItem(prop_name); - new_property->setFlags(Qt::ItemIsSelectable); - new_row.append(new_property); - - auto* new_value = new QStandardItem(); - new_value->setFlags(flags); - new_value->setData(value, Qt::EditRole); - new_row.append(new_value); - - parent_item->appendRow(new_row); + QList new_row; + QStandardItem* new_property = new QStandardItem (prop_name); + new_property->setFlags (Qt::ItemIsSelectable); + new_row.append (new_property); + + QStandardItem* new_value = new QStandardItem (); + new_value->setFlags (flags); + new_value->setData (value, Qt::EditRole); + new_row.append (new_value); + + parent_item->appendRow (new_row); } void -pcl::cloud_composer::PropertiesModel::addCategory(const QString& category_name) +pcl::cloud_composer::PropertiesModel::addCategory (const QString& category_name) { - auto* new_category = new QStandardItem(category_name); - appendRow(new_category); + QStandardItem* new_category = new QStandardItem (category_name); + appendRow (new_category); } -QVariant -pcl::cloud_composer::PropertiesModel::getProperty(const QString& prop_name) const +QVariant +pcl::cloud_composer::PropertiesModel::getProperty (const QString& prop_name) const { - // qDebug () << "Searching for property " << prop_name; - QList items = - findItems(prop_name, Qt::MatchExactly | Qt::MatchRecursive, 0); - if (items.empty()) { - qWarning() << "No property named " << prop_name << " found in " - << parent_item_->text(); - return {}; + //qDebug () << "Searching for property " << prop_name; + QList items = findItems (prop_name, Qt::MatchExactly | Qt::MatchRecursive, 0); + if (items.empty ()) + { + qWarning () << "No property named "<text (); + return QVariant (); } - if (items.size() > 1) { - qWarning() << "Multiple properties found with name " << prop_name << " in " - << parent_item_->text(); + if (items.size () > 1) + { + qWarning () << "Multiple properties found with name "<text (); } - // qDebug () << "Found properties size ="<text() << " cols =" << to_copy->columnCount(); - new_row.append(parent->clone()); - for (int j = 1; j < to_copy->columnCount(); ++j) { - if (to_copy->item(i, j)) { - new_row.append(to_copy->item(i, j)->clone()); + for (int i=0; i < to_copy->rowCount (); ++i){ + QList new_row; + QStandardItem* parent = to_copy->item(i,0); + qDebug () << "Copying "<text()<< " cols ="<columnCount (); + new_row.append (parent->clone ()); + for (int j=1; j < to_copy->columnCount (); ++j) + { + if (to_copy->item (i,j)) + { + new_row.append (to_copy->item(i,j)->clone ()); } } - appendRow(new_row); + appendRow (new_row); } } + void -pcl::cloud_composer::PropertiesModel::propertyChanged(QStandardItem*) +pcl::cloud_composer::PropertiesModel::propertyChanged (QStandardItem*) { - // qDebug () << "Property Changed in properties model"; - parent_item_->propertyChanged(); + //qDebug () << "Property Changed in properties model"; + parent_item_->propertyChanged (); } diff --git a/apps/cloud_composer/src/signal_multiplexer.cpp b/apps/cloud_composer/src/signal_multiplexer.cpp index 3f9191e93bd..be0506b6496 100644 --- a/apps/cloud_composer/src/signal_multiplexer.cpp +++ b/apps/cloud_composer/src/signal_multiplexer.cpp @@ -1,14 +1,15 @@ -#include #include +#include + +pcl::cloud_composer::SignalMultiplexer::SignalMultiplexer (QObject* parent) + : QObject (parent) +{ + +} -pcl::cloud_composer::SignalMultiplexer::SignalMultiplexer(QObject* parent) -: QObject(parent) -{} void -pcl::cloud_composer::SignalMultiplexer::connect(QObject* sender, - const char* signal, - const char* slot) +pcl::cloud_composer::SignalMultiplexer::connect (QObject* sender, const char* signal, const char* slot) { Connection conn; conn.sender = sender; @@ -16,13 +17,12 @@ pcl::cloud_composer::SignalMultiplexer::connect(QObject* sender, conn.slot = slot; connections << conn; - connect(conn); + connect (conn); } + void -pcl::cloud_composer::SignalMultiplexer::connect(const char* signal, - QObject* receiver, - const char* slot) +pcl::cloud_composer::SignalMultiplexer::connect (const char* signal, QObject* receiver, const char* slot) { Connection conn; conn.receiver = receiver; @@ -30,20 +30,21 @@ pcl::cloud_composer::SignalMultiplexer::connect(const char* signal, conn.slot = slot; connections << conn; - connect(conn); + connect (conn); } + bool -pcl::cloud_composer::SignalMultiplexer::disconnect(QObject* sender, - const char* signal, - const char* slot) +pcl::cloud_composer::SignalMultiplexer::disconnect (QObject* sender, const char* signal, const char* slot) { - QMutableListIterator it(connections); - while (it.hasNext()) { + QMutableListIterator it (connections); + while (it.hasNext ()) + { Connection conn = it.next(); - if ((QObject*)conn.sender == sender && qstrcmp(conn.signal, signal) == 0 && - qstrcmp(conn.slot, slot) == 0) { - disconnect(conn); + if ( (QObject*) conn.sender == sender && + qstrcmp (conn.signal, signal) == 0 && qstrcmp (conn.slot, slot) == 0) + { + disconnect (conn); it.remove(); return true; } @@ -51,17 +52,18 @@ pcl::cloud_composer::SignalMultiplexer::disconnect(QObject* sender, return false; } + bool -pcl::cloud_composer::SignalMultiplexer::disconnect(const char* signal, - QObject* receiver, - const char* slot) +pcl::cloud_composer::SignalMultiplexer::disconnect (const char* signal, QObject* receiver, const char* slot) { - QMutableListIterator it(connections); - while (it.hasNext()) { + QMutableListIterator it (connections); + while (it.hasNext ()) + { Connection conn = it.next(); - if ((QObject*)conn.receiver == receiver && qstrcmp(conn.signal, signal) == 0 && - qstrcmp(conn.slot, slot) == 0) { - disconnect(conn); + if ( (QObject*) conn.receiver == receiver && + qstrcmp (conn.signal, signal) == 0 && qstrcmp (conn.slot, slot) == 0) + { + disconnect (conn); it.remove(); return true; } @@ -69,8 +71,9 @@ pcl::cloud_composer::SignalMultiplexer::disconnect(const char* signal, return false; } + void -pcl::cloud_composer::SignalMultiplexer::connect(const Connection& conn) +pcl::cloud_composer::SignalMultiplexer::connect (const Connection& conn) { if (!object) return; @@ -78,13 +81,14 @@ pcl::cloud_composer::SignalMultiplexer::connect(const Connection& conn) return; if (conn.sender) - QObject::connect((QObject*)conn.sender, conn.signal, (QObject*)object, conn.slot); + QObject::connect ( (QObject*) conn.sender, conn.signal, (QObject*) object, conn.slot); else - QObject::connect((QObject*)object, conn.signal, (QObject*)conn.receiver, conn.slot); + QObject::connect ( (QObject*) object, conn.signal, (QObject*) conn.receiver, conn.slot); } -void -pcl::cloud_composer::SignalMultiplexer::disconnect(const Connection& conn) + +void +pcl::cloud_composer::SignalMultiplexer::disconnect (const Connection& conn) { if (!object) return; @@ -92,29 +96,29 @@ pcl::cloud_composer::SignalMultiplexer::disconnect(const Connection& conn) return; if (conn.sender) - QObject::disconnect( - (QObject*)conn.sender, conn.signal, (QObject*)object, conn.slot); + QObject::disconnect ( (QObject*) conn.sender, conn.signal, (QObject*) object, conn.slot); else - QObject::disconnect( - (QObject*)object, conn.signal, (QObject*)conn.receiver, conn.slot); + QObject::disconnect ( (QObject*) object, conn.signal, (QObject*) conn.receiver, conn.slot); + } -void -pcl::cloud_composer::SignalMultiplexer::setCurrentObject(QObject* newObject) + +void +pcl::cloud_composer::SignalMultiplexer::setCurrentObject (QObject* newObject) { if (newObject == object) return; - for (const auto& connection : connections) - disconnect(connection); + for (const auto &connection : connections) + disconnect (connection); object = newObject; - for (const auto& connection : connections) - connect(connection); + for (const auto &connection : connections) + connect (connection); - auto* model = dynamic_cast(newObject); + ProjectModel* model = dynamic_cast (newObject); if (model) - model->emitAllStateSignals(); - - // let the world know about who's on top now - emit currentObjectChanged(object); + model->emitAllStateSignals (); + + //let the world know about who's on top now + emit currentObjectChanged (object); } diff --git a/apps/cloud_composer/src/tool_interface/abstract_tool.cpp b/apps/cloud_composer/src/tool_interface/abstract_tool.cpp index 6cb6632bbf0..8a23d6947db 100644 --- a/apps/cloud_composer/src/tool_interface/abstract_tool.cpp +++ b/apps/cloud_composer/src/tool_interface/abstract_tool.cpp @@ -1,21 +1,23 @@ #include -pcl::cloud_composer::AbstractTool::AbstractTool(PropertiesModel* parameter_model, - QObject* parent) -: QObject(parent) - +pcl::cloud_composer::AbstractTool::AbstractTool (PropertiesModel* parameter_model, QObject* parent) + : QObject (parent) + { - parameter_model_ = new PropertiesModel(this); - // If there's a model copy it into the local copy - if (parameter_model) { + parameter_model_ = new PropertiesModel (this); + //If there's a model copy it into the local copy + if (parameter_model) + { parameter_model_->copyProperties(parameter_model); + } + + } -QList -pcl::cloud_composer::AbstractTool::performAction(QList, - PointTypeFlags::PointType) +QList +pcl::cloud_composer::AbstractTool::performAction (QList , PointTypeFlags::PointType) { - qDebug() << "AbstractTool::performTemplatedAction"; - return {}; + qDebug () << "AbstractTool::performTemplatedAction"; + return QList (); } diff --git a/apps/cloud_composer/src/toolbox_model.cpp b/apps/cloud_composer/src/toolbox_model.cpp index 3de7028ecdc..dd70fbd2c13 100644 --- a/apps/cloud_composer/src/toolbox_model.cpp +++ b/apps/cloud_composer/src/toolbox_model.cpp @@ -1,238 +1,247 @@ -#include -#include +#include #include #include -#include +#include +#include #include #include -pcl::cloud_composer::ToolBoxModel::ToolBoxModel(QTreeView* tool_view, - QTreeView* parameter_view_, - QObject* parent) -: QStandardItemModel(parent), tool_view_(tool_view), parameter_view_(parameter_view_) -{} +pcl::cloud_composer::ToolBoxModel::ToolBoxModel (QTreeView* tool_view, QTreeView* parameter_view_, QObject* parent) +: QStandardItemModel (parent) +, tool_view_ (tool_view) +, parameter_view_ (parameter_view_) +, project_model_ (nullptr) +{ + +} -pcl::cloud_composer::ToolBoxModel::ToolBoxModel(const ToolBoxModel&) -: QStandardItemModel() -{} +pcl::cloud_composer::ToolBoxModel::ToolBoxModel (const ToolBoxModel&) +: QStandardItemModel () +{ +} void -pcl::cloud_composer::ToolBoxModel::addTool(ToolFactory* tool_factory) +pcl::cloud_composer::ToolBoxModel::addTool (ToolFactory* tool_factory) { - // qDebug () << "Icon name:"<< tool_factory->getIconName (); - QIcon new_tool_icon = QIcon(tool_factory->getIconName()); - auto* new_tool_item = new QStandardItem(new_tool_icon, tool_factory->getPluginName()); - new_tool_item->setEditable(false); - - new_tool_item->setData(QVariant::fromValue(tool_factory), FACTORY); - PropertiesModel* new_tool_parameters = tool_factory->createToolParameterModel(this); - new_tool_item->setData(QVariant::fromValue(new_tool_parameters), PARAMETER_MODEL); - - tool_items.insert(new_tool_item); - QStandardItem* group_item = addToolGroup(tool_factory->getToolGroupName()); - group_item->appendRow(new_tool_item); - // Expand the view for this tool group + //qDebug () << "Icon name:"<< tool_factory->getIconName (); + QIcon new_tool_icon = QIcon (tool_factory->getIconName ()); + QStandardItem* new_tool_item = new QStandardItem (new_tool_icon, tool_factory->getPluginName ()); + new_tool_item->setEditable (false); + + new_tool_item->setData (QVariant::fromValue (tool_factory), FACTORY); + PropertiesModel* new_tool_parameters= tool_factory->createToolParameterModel (this); + new_tool_item->setData (QVariant::fromValue (new_tool_parameters), PARAMETER_MODEL); + + tool_items.insert (new_tool_item); + QStandardItem* group_item = addToolGroup (tool_factory->getToolGroupName ()); + group_item->appendRow (new_tool_item); + //Expand the view for this tool group QModelIndex group_index = this->indexFromItem(group_item); - tool_view_->setExpanded(group_index, true); + tool_view_->setExpanded (group_index, true); } void -pcl::cloud_composer::ToolBoxModel::setSelectionModel( - QItemSelectionModel* selection_model) +pcl::cloud_composer::ToolBoxModel::setSelectionModel (QItemSelectionModel* selection_model) { selection_model_ = selection_model; } - + QStandardItem* -pcl::cloud_composer::ToolBoxModel::addToolGroup(const QString& tool_group_name) +pcl::cloud_composer::ToolBoxModel::addToolGroup (const QString& tool_group_name) { - QList matches_name = findItems(tool_group_name); - if (matches_name.empty()) { - auto* new_group_item = new QStandardItem(tool_group_name); - appendRow(new_group_item); - new_group_item->setSelectable(false); - new_group_item->setEditable(false); + QList matches_name = findItems (tool_group_name); + if (matches_name.empty ()) + { + QStandardItem* new_group_item = new QStandardItem (tool_group_name); + appendRow (new_group_item); + new_group_item->setSelectable (false); + new_group_item->setEditable (false); return new_group_item; } - if (matches_name.size() > 1) { - qWarning() << "Multiple tool groups with same name in ToolBoxModel!!"; + if (matches_name.size () > 1) + { + qWarning () << "Multiple tool groups with same name in ToolBoxModel!!"; } - - return matches_name.value(0); + + return matches_name.value (0); + } -void -pcl::cloud_composer::ToolBoxModel::activeProjectChanged(ProjectModel* new_model, - ProjectModel*) +void +pcl::cloud_composer::ToolBoxModel::activeProjectChanged(ProjectModel* new_model, ProjectModel*) { - // Disconnect old project model signal for selection change - if (project_model_) { - disconnect(project_model_->getSelectionModel(), - SIGNAL(selectionChanged(QItemSelection, QItemSelection)), - this, - SLOT(selectedItemChanged(QItemSelection, QItemSelection))); - disconnect(project_model_, SIGNAL(modelChanged()), this, SLOT(modelChanged())); - } - qDebug() << "Active project changed in ToolBox Model!"; + //Disconnect old project model signal for selection change + if (project_model_) + { + disconnect (project_model_->getSelectionModel (), SIGNAL (selectionChanged (QItemSelection,QItemSelection)), + this, SLOT (selectedItemChanged (QItemSelection,QItemSelection))); + disconnect (project_model_, SIGNAL (modelChanged()), + this, SLOT (modelChanged())); + + } + qDebug () << "Active project changed in ToolBox Model!"; project_model_ = new_model; - - // Update enabled tools, make connection for doing this automatically - if (project_model_) { - updateEnabledTools(project_model_->getSelectionModel()->selection()); - connect(project_model_->getSelectionModel(), - SIGNAL(selectionChanged(QItemSelection, QItemSelection)), - this, - SLOT(selectedItemChanged(QItemSelection, QItemSelection))); - connect(project_model_, SIGNAL(modelChanged()), this, SLOT(modelChanged())); + + //Update enabled tools, make connection for doing this automatically + if (project_model_) + { + updateEnabledTools (project_model_->getSelectionModel ()->selection ()); + connect (project_model_->getSelectionModel (), SIGNAL (selectionChanged (QItemSelection,QItemSelection)), + this, SLOT (selectedItemChanged (QItemSelection,QItemSelection))); + connect (project_model_, SIGNAL (modelChanged()), + this, SLOT (modelChanged())); } + } void -pcl::cloud_composer::ToolBoxModel::selectedToolChanged(const QModelIndex& current, - const QModelIndex&) +pcl::cloud_composer::ToolBoxModel::selectedToolChanged (const QModelIndex & current, const QModelIndex &) { - // qDebug() << "Selected Tool changed"; - if (!parameter_view_) { - qCritical() << "Toolbox parameter view not set!!!"; + //qDebug() << "Selected Tool changed"; + if (!parameter_view_) + { + qCritical () << "Toolbox parameter view not set!!!"; return; - } - QVariant parameter_model = current.data(PARAMETER_MODEL); - parameter_view_->setModel(parameter_model.value()); - parameter_view_->expandAll(); + } + QVariant parameter_model = current.data (PARAMETER_MODEL); + parameter_view_->setModel ( parameter_model.value ()); + parameter_view_->expandAll (); } + void -pcl::cloud_composer::ToolBoxModel::toolAction() +pcl::cloud_composer::ToolBoxModel::toolAction () { - QModelIndex current_index = selection_model_->currentIndex(); - if (!current_index.isValid()) { - QMessageBox::warning(qobject_cast(this->parent()), - "No Tool Selected", - "Cannot execute action, no tool selected!"); + QModelIndex current_index = selection_model_->currentIndex (); + if (!current_index.isValid ()) + { + QMessageBox::warning (qobject_cast(this->parent ()), "No Tool Selected", "Cannot execute action, no tool selected!"); return; } - auto* tool_factory = (current_index.data(FACTORY)).value(); - auto* parameter_model = - (current_index.data(PARAMETER_MODEL)).value(); + ToolFactory* tool_factory = (current_index.data (FACTORY)).value (); + PropertiesModel* parameter_model = (current_index.data (PARAMETER_MODEL)).value (); // - AbstractTool* tool = tool_factory->createTool(parameter_model); - - emit enqueueToolAction(tool); + AbstractTool* tool = tool_factory->createTool (parameter_model); + + emit enqueueToolAction (tool); } -void -pcl::cloud_composer::ToolBoxModel::selectedItemChanged(const QItemSelection& selected, - const QItemSelection&) +void +pcl::cloud_composer::ToolBoxModel::selectedItemChanged ( const QItemSelection & selected, const QItemSelection &) { - updateEnabledTools(selected); + updateEnabledTools (selected); } -void -pcl::cloud_composer::ToolBoxModel::enableAllTools() +void +pcl::cloud_composer::ToolBoxModel::enableAllTools () { - foreach (QStandardItem* tool, tool_items) { - tool->setEnabled(true); + foreach (QStandardItem* tool, tool_items) + { + tool->setEnabled (true); } } void -pcl::cloud_composer::ToolBoxModel::modelChanged() +pcl::cloud_composer::ToolBoxModel::modelChanged () { - updateEnabledTools(project_model_->getSelectionModel()->selection()); + updateEnabledTools (project_model_->getSelectionModel ()->selection ()); } void -pcl::cloud_composer::ToolBoxModel::updateEnabledTools( - const QItemSelection& current_selection) +pcl::cloud_composer::ToolBoxModel::updateEnabledTools (const QItemSelection& current_selection) { - // qDebug () << "UPDATING ENABLED TOOLS!"; - QModelIndexList current_indices = current_selection.indexes(); - QMultiMap type_items_map; - foreach (QModelIndex current, current_indices) { - if (current.isValid()) { - QStandardItem* current_item = project_model_->itemFromIndex(current); - type_items_map.insert(current_item->type(), current_item); + //qDebug () << "UPDATING ENABLED TOOLS!"; + QModelIndexList current_indices = current_selection.indexes (); + QMultiMap < int, QStandardItem* > type_items_map; + foreach (QModelIndex current, current_indices) + { + if (current.isValid ()) + { + QStandardItem* current_item = project_model_->itemFromIndex (current); + type_items_map.insert (current_item->type (), current_item); } } - enableAllTools(); - QList enabled_tools = tool_items.values(); - QMap disabled_tools; + enableAllTools (); + QList enabled_tools = tool_items.values (); + QMap disabled_tools; QMutableListIterator enabled_itr(enabled_tools); - // Go through tools, removing from enabled list if they fail to pass tests - while (enabled_itr.hasNext()) { - QStandardItem* tool_item = enabled_itr.next(); - auto* tool_factory = (tool_item->data(FACTORY)).value(); - CloudComposerItem::ItemType input_type = tool_factory->getInputItemType(); - QList required_children_types = - tool_factory->getRequiredInputChildrenTypes(); - // Check if enough items for tool are selected - if (tool_factory->getNumInputItems() > current_indices.size()) { - enabled_itr.remove(); - disabled_tools.insert(tool_item, - tr("Tool Requires %1 Items (%2 Selected)") - .arg(tool_factory->getNumInputItems()) - .arg(current_indices.size())); + //Go through tools, removing from enabled list if they fail to pass tests + while (enabled_itr.hasNext()) + { + QStandardItem* tool_item = enabled_itr.next (); + ToolFactory* tool_factory = (tool_item->data (FACTORY)).value (); + CloudComposerItem::ItemType input_type = tool_factory->getInputItemType (); + QList required_children_types = tool_factory->getRequiredInputChildrenTypes(); + //Check if enough items for tool are selected + if ( tool_factory-> getNumInputItems() > current_indices.size() ) + { + enabled_itr.remove (); + disabled_tools.insert (tool_item, tr("Tool Requires %1 Items (%2 Selected)").arg(tool_factory-> getNumInputItems()).arg(current_indices.size ())); } - // Check if selection includes at least one item with correct input type - else if (!type_items_map.keys().contains(input_type)) { - enabled_itr.remove(); - disabled_tools.insert( - tool_item, - tr("Tool Requires item type %1 selected") - .arg(ITEM_TYPES_STRINGS.value(input_type - - CloudComposerItem::CLOUD_COMPOSER_ITEM))); + //Check if selection includes at least one item with correct input type + else if ( ! type_items_map.keys ().contains (input_type)) + { + enabled_itr.remove (); + disabled_tools.insert (tool_item, tr("Tool Requires item type %1 selected").arg (ITEM_TYPES_STRINGS.value (input_type - CloudComposerItem::CLOUD_COMPOSER_ITEM))); } - // Check if any of selected items have required children - else if (!required_children_types.empty()) { - QList matching_selected_items = type_items_map.values(input_type); + //Check if any of selected items have required children + else if ( !required_children_types.empty ()) + { + QList matching_selected_items = type_items_map.values (input_type); bool found_valid_items = false; - QList missing_children = required_children_types; - foreach (QStandardItem* item, matching_selected_items) { - QList found_children_types; - if (!item->hasChildren()) + QList missing_children = required_children_types; + foreach (QStandardItem* item, matching_selected_items) + { + QList found_children_types; + if (!item->hasChildren ()) continue; - - // Find types of all children + + //Find types of all children for (int i = 0; i < item->rowCount(); ++i) - found_children_types.append( - static_cast(item->child(i)->type())); - // Make temporary copy, remove type from it if is present as child - QList req_children_temp = required_children_types; + found_children_types.append ( static_cast(item->child (i)->type ())); + //Make temporary copy, remove type from it if is present as child + QList req_children_temp = required_children_types; foreach (CloudComposerItem::ItemType type, found_children_types) - req_children_temp.removeAll(type); - // If temporary is empty, we found all required children - if (req_children_temp.isEmpty()) { + req_children_temp.removeAll (type); + //If temporary is empty, we found all required children + if (req_children_temp.isEmpty ()) + { found_valid_items = true; break; } - // Otherwise, set missing children list - if (req_children_temp.size() < missing_children.size()) + //Otherwise, set missing children list + if (req_children_temp.size () < missing_children.size ()) missing_children = req_children_temp; + + } - // If we didn't find all required children - if (!found_valid_items) { - enabled_itr.remove(); + //If we didn't find all required children + if (!found_valid_items) + { + enabled_itr.remove (); QString missing_children_string; foreach (CloudComposerItem::ItemType type, missing_children) - missing_children_string.append( - " " + - ITEM_TYPES_STRINGS.value(type - CloudComposerItem::CLOUD_COMPOSER_ITEM)); - disabled_tools.insert( - tool_item, - tr("Tool Requires child item of type(s) %1").arg(missing_children_string)); + missing_children_string.append (" "+ITEM_TYPES_STRINGS.value (type - CloudComposerItem::CLOUD_COMPOSER_ITEM)); + disabled_tools.insert (tool_item, tr ("Tool Requires child item of type(s) %1").arg (missing_children_string)); } } } - foreach (QStandardItem* tool, tool_items) { - if (enabled_tools.contains(tool)) { - // qDebug () << tool->text() << " is enabled!"; - tool->setToolTip(tool->text() + " is enabled"); + foreach (QStandardItem* tool, tool_items) + { + if (enabled_tools.contains (tool)) + { + //qDebug () << tool->text() << " is enabled!"; + tool->setToolTip (tool->text() + " is enabled"); } - else { - // qDebug () << tool->text() << " disabled: "<setToolTip(disabled_tools.value(tool)); - tool->setEnabled(false); + else + { + // qDebug () << tool->text() << " disabled: "<setToolTip (disabled_tools.value (tool)); + tool->setEnabled (false); } } + + + } diff --git a/apps/cloud_composer/src/transform_clouds.cpp b/apps/cloud_composer/src/transform_clouds.cpp index 6f47f19b071..54658e745fa 100644 --- a/apps/cloud_composer/src/transform_clouds.cpp +++ b/apps/cloud_composer/src/transform_clouds.cpp @@ -1,31 +1,36 @@ -#include -#include #include +#include + #include -pcl::cloud_composer::TransformClouds::TransformClouds( - QMap> transform_map, QObject* parent) -: ModifyItemTool(nullptr, parent), transform_map_(std::move(transform_map)) -{} +#include + +pcl::cloud_composer::TransformClouds::TransformClouds (QMap > transform_map, QObject* parent) + : ModifyItemTool (nullptr, parent) + , transform_map_ (std::move(transform_map)) +{ + +} -QList -pcl::cloud_composer::TransformClouds::performAction(ConstItemList input_data, - PointTypeFlags::PointType type) +QList +pcl::cloud_composer::TransformClouds::performAction (ConstItemList input_data, PointTypeFlags::PointType type) { - if (type != PointTypeFlags::NONE) { - switch (static_cast(type)) { - case (PointTypeFlags::XYZ): - return this->performTemplatedAction(input_data); - case (PointTypeFlags::XYZ | PointTypeFlags::RGB): - return this->performTemplatedAction(input_data); - case (PointTypeFlags::XYZ | PointTypeFlags::RGBA): - return this->performTemplatedAction(input_data); + if (type != PointTypeFlags::NONE) + { + switch ((std::uint8_t) type) + { + case (PointTypeFlags::XYZ): + return this->performTemplatedAction (input_data); + case (PointTypeFlags::XYZ | PointTypeFlags::RGB): + return this->performTemplatedAction (input_data); + case (PointTypeFlags::XYZ | PointTypeFlags::RGBA): + return this->performTemplatedAction (input_data); } } + + QList output; - QList output; - - qCritical() << "Transform requires templated types!"; - + qCritical () << "Transform requires templated types!"; + return output; } diff --git a/apps/cloud_composer/src/work_queue.cpp b/apps/cloud_composer/src/work_queue.cpp index bf0c6305fa7..2d4fb11d09c 100644 --- a/apps/cloud_composer/src/work_queue.cpp +++ b/apps/cloud_composer/src/work_queue.cpp @@ -1,45 +1,58 @@ -#include #include +#include -pcl::cloud_composer::WorkQueue::WorkQueue(QObject* parent) : QObject(parent) {} +pcl::cloud_composer::WorkQueue::WorkQueue (QObject* parent) + : QObject (parent) +{ + + + +} void -pcl::cloud_composer::WorkQueue::enqueueNewAction(AbstractTool* new_tool, - ConstItemList input_data) +pcl::cloud_composer::WorkQueue::enqueueNewAction (AbstractTool* new_tool, ConstItemList input_data) { ActionPair new_action; - // Create a command which will manage data for the tool - new_action.command = new_tool->createCommand(std::move(input_data)); + //Create a command which will manage data for the tool + new_action.command = new_tool->createCommand (std::move(input_data)); new_action.tool = new_tool; - - work_queue_.enqueue(new_action); - checkQueue(); + + work_queue_.enqueue (new_action); + checkQueue (); } void -pcl::cloud_composer::WorkQueue::actionFinished(ActionPair finished_action) +pcl::cloud_composer::WorkQueue::actionFinished (ActionPair finished_action) { - // Signal the project model that the command is done - emit commandComplete(finished_action.command); - - // Queue the tool for deletion - finished_action.tool->deleteLater(); - // Check if there are any remaining commands in queue - checkQueue(); + //Signal the project model that the command is done + emit commandComplete (finished_action.command); + + //Queue the tool for deletion + finished_action.tool->deleteLater (); + //Check if there are any remaining commands in queue + checkQueue (); + } void -pcl::cloud_composer::WorkQueue::checkQueue() +pcl::cloud_composer::WorkQueue::checkQueue ( ) { - if (!work_queue_.empty()) { - ActionPair action_to_execute = work_queue_.dequeue(); - if (action_to_execute.command->runCommand(action_to_execute.tool)) { - // Success, send the command back to the main thread - actionFinished(action_to_execute); + if (work_queue_.length () > 0) + { + ActionPair action_to_execute = work_queue_.dequeue (); + if (action_to_execute.command->runCommand (action_to_execute.tool)) + { + //Success, send the command back to the main thread + actionFinished (action_to_execute); } - else { - qDebug() << "FAILED TO EXECUTE COMMAND"; - // Failure, what to do with data?? + else + { + qDebug () << "FAILED TO EXECUTE COMMAND"; + //Failure, what to do with data?? } + + } + + } diff --git a/apps/cloud_composer/tools/euclidean_clustering.cpp b/apps/cloud_composer/tools/euclidean_clustering.cpp index 5f53011cf01..fc1a407350a 100644 --- a/apps/cloud_composer/tools/euclidean_clustering.cpp +++ b/apps/cloud_composer/tools/euclidean_clustering.cpp @@ -1,137 +1,131 @@ -#include #include +#include + +#include // for pcl::make_shared +#include #include #include #include -#include // for pcl::make_shared -#include Q_PLUGIN_METADATA(IID "cloud_composer.ToolFactory/1.0") -pcl::cloud_composer::EuclideanClusteringTool::EuclideanClusteringTool( - PropertiesModel* parameter_model, QObject* parent) -: SplitItemTool(parameter_model, parent) -{} +pcl::cloud_composer::EuclideanClusteringTool::EuclideanClusteringTool (PropertiesModel* parameter_model, QObject* parent) + : SplitItemTool (parameter_model, parent) +{ + +} -QList -pcl::cloud_composer::EuclideanClusteringTool::performAction(ConstItemList input_data, - PointTypeFlags::PointType) +QList +pcl::cloud_composer::EuclideanClusteringTool::performAction (ConstItemList input_data, PointTypeFlags::PointType) { - QList output; + QList output; const CloudComposerItem* input_item; // Check input data length - if (input_data.empty()) { - qCritical() << "Empty input in Euclidean Clustering Tool!"; + if ( input_data.empty ()) + { + qCritical () << "Empty input in Euclidean Clustering Tool!"; return output; } - if (input_data.size() > 1) { - qWarning() << "Input vector has more than one item in Euclidean Clustering!"; + if ( input_data.size () > 1) + { + qWarning () << "Input vector has more than one item in Euclidean Clustering!"; } - input_item = input_data.value(0); + input_item = input_data.value (0); - if (input_item->type() == CloudComposerItem::CLOUD_ITEM) { - const auto* cloud_item = dynamic_cast(input_item); - if (cloud_item->isSanitized()) { - double cluster_tolerance = - parameter_model_->getProperty("Cluster Tolerance").toDouble(); - int min_cluster_size = parameter_model_->getProperty("Min Cluster Size").toInt(); - int max_cluster_size = parameter_model_->getProperty("Max Cluster Size").toInt(); + if (input_item->type () == CloudComposerItem::CLOUD_ITEM) + { + const CloudItem* cloud_item = dynamic_cast (input_item); + if ( cloud_item->isSanitized()) + { + double cluster_tolerance = parameter_model_->getProperty ("Cluster Tolerance").toDouble(); + int min_cluster_size = parameter_model_->getProperty ("Min Cluster Size").toInt(); + int max_cluster_size = parameter_model_->getProperty ("Max Cluster Size").toInt(); - auto input_cloud = input_item->data(ItemDataRole::CLOUD_BLOB) - .value(); - // Get the cloud in template form - pcl::PointCloud::Ptr cloud(new pcl::PointCloud); - pcl::fromPCLPointCloud2(*input_cloud, *cloud); + pcl::PCLPointCloud2::ConstPtr input_cloud = input_item->data (ItemDataRole::CLOUD_BLOB).value (); + //Get the cloud in template form + pcl::PointCloud::Ptr cloud (new pcl::PointCloud); + pcl::fromPCLPointCloud2 (*input_cloud, *cloud); //////////////// THE WORK - COMPUTING CLUSTERS /////////////////// // Creating the KdTree object for the search method of the extraction - pcl::search::KdTree::Ptr tree( - new pcl::search::KdTree); - tree->setInputCloud(cloud); + pcl::search::KdTree::Ptr tree (new pcl::search::KdTree); + tree->setInputCloud (cloud); std::vector cluster_indices; pcl::EuclideanClusterExtraction ec; - ec.setClusterTolerance(cluster_tolerance); - ec.setMinClusterSize(min_cluster_size); - ec.setMaxClusterSize(max_cluster_size); - ec.setSearchMethod(tree); - ec.setInputCloud(cloud); - ec.extract(cluster_indices); + ec.setClusterTolerance (cluster_tolerance); + ec.setMinClusterSize (min_cluster_size); + ec.setMaxClusterSize (max_cluster_size); + ec.setSearchMethod (tree); + ec.setInputCloud (cloud); + ec.extract (cluster_indices); ////////////////////////////////////////////////////////////////// - // Get copies of the original origin and orientation - auto source_origin = - input_item->data(ItemDataRole::ORIGIN).value(); - auto source_orientation = - input_item->data(ItemDataRole::ORIENTATION).value(); - // Vector to accumulate the extracted indices - pcl::IndicesPtr extracted_indices(new pcl::Indices()); - // Put found clusters into new cloud_items! - qDebug() << "Found " << cluster_indices.size() << " clusters!"; + //Get copies of the original origin and orientation + Eigen::Vector4f source_origin = input_item->data (ItemDataRole::ORIGIN).value (); + Eigen::Quaternionf source_orientation = input_item->data (ItemDataRole::ORIENTATION).value (); + //Vector to accumulate the extracted indices + pcl::IndicesPtr extracted_indices (new pcl::Indices ()); + //Put found clusters into new cloud_items! + qDebug () << "Found "< filter; - for (const auto& cluster : cluster_indices) { - filter.setInputCloud(input_cloud); - // It's annoying that I have to do this, but Euclidean returns a PointIndices - // struct - pcl::PointIndices::ConstPtr indices_ptr = - pcl::make_shared(cluster); - filter.setIndices(indices_ptr); - extracted_indices->insert( - extracted_indices->end(), cluster.indices.begin(), cluster.indices.end()); - // This means remove the other points - filter.setKeepOrganized(false); - pcl::PCLPointCloud2::Ptr cloud_filtered(new pcl::PCLPointCloud2); - filter.filter(*cloud_filtered); + for (const auto& cluster : cluster_indices) + { + filter.setInputCloud (input_cloud); + // It's annoying that I have to do this, but Euclidean returns a PointIndices struct + pcl::PointIndices::ConstPtr indices_ptr = pcl::make_shared(cluster); + filter.setIndices (indices_ptr); + extracted_indices->insert (extracted_indices->end (), cluster.indices.begin (), cluster.indices.end ()); + //This means remove the other points + filter.setKeepOrganized (false); + pcl::PCLPointCloud2::Ptr cloud_filtered (new pcl::PCLPointCloud2); + filter.filter (*cloud_filtered); qDebug() << "Cluster has " << cloud_filtered->width << " data points."; - auto* cloud_item = - new CloudItem(input_item->text() + tr("-Clstr %1").arg(cluster_count), - cloud_filtered, - source_origin, - source_orientation); - output.append(cloud_item); + CloudItem* cloud_item = new CloudItem (input_item->text ()+tr("-Clstr %1").arg(cluster_count) + , cloud_filtered + , source_origin + , source_orientation); + output.append (cloud_item); ++cluster_count; } - // We copy input cloud over for special case that no clusters found, since - // ExtractIndices doesn't work for 0 length vectors - pcl::PCLPointCloud2::Ptr remainder_cloud(new pcl::PCLPointCloud2(*input_cloud)); - if (!cluster_indices.empty()) { - // make a cloud containing all the remaining points - filter.setIndices(extracted_indices); - filter.setNegative(true); - filter.filter(*remainder_cloud); + //We copy input cloud over for special case that no clusters found, since ExtractIndices doesn't work for 0 length vectors + pcl::PCLPointCloud2::Ptr remainder_cloud (new pcl::PCLPointCloud2(*input_cloud)); + if (!cluster_indices.empty ()) + { + //make a cloud containing all the remaining points + filter.setIndices (extracted_indices); + filter.setNegative (true); + filter.filter (*remainder_cloud); } - qDebug() << "Cloud has " << remainder_cloud->width - << " data points after clusters removed."; - auto* cloud_item = new CloudItem(input_item->text() + " unclustered", - remainder_cloud, - source_origin, - source_orientation); - output.push_front(cloud_item); + qDebug() << "Cloud has " << remainder_cloud->width << " data points after clusters removed."; + CloudItem* cloud_item = new CloudItem (input_item->text ()+ " unclustered" + , remainder_cloud + , source_origin + , source_orientation); + output.push_front (cloud_item); } else - qCritical() << "Input item in Clustering is not SANITIZED!!!"; + qCritical () << "Input item in Clustering is not SANITIZED!!!"; } - else { - qCritical() << "Input item in Clustering is not a cloud!!!"; + else + { + qCritical () << "Input item in Clustering is not a cloud!!!"; } + return output; } /////////////////// PARAMETER MODEL ///////////////////////////////// pcl::cloud_composer::PropertiesModel* -pcl::cloud_composer::EuclideanClusteringToolFactory::createToolParameterModel( - QObject* parent) +pcl::cloud_composer::EuclideanClusteringToolFactory::createToolParameterModel (QObject* parent) { - auto* parameter_model = new PropertiesModel(parent); + PropertiesModel* parameter_model = new PropertiesModel(parent); - parameter_model->addProperty( - "Cluster Tolerance", 0.02, Qt::ItemIsEditable | Qt::ItemIsEnabled); - parameter_model->addProperty( - "Min Cluster Size", 100, Qt::ItemIsEditable | Qt::ItemIsEnabled); - parameter_model->addProperty( - "Max Cluster Size", 25000, Qt::ItemIsEditable | Qt::ItemIsEnabled); + parameter_model->addProperty ("Cluster Tolerance", 0.02, Qt::ItemIsEditable | Qt::ItemIsEnabled); + parameter_model->addProperty ("Min Cluster Size", 100, Qt::ItemIsEditable | Qt::ItemIsEnabled); + parameter_model->addProperty ("Max Cluster Size", 25000, Qt::ItemIsEditable | Qt::ItemIsEnabled); return parameter_model; } diff --git a/apps/cloud_composer/tools/fpfh_estimation.cpp b/apps/cloud_composer/tools/fpfh_estimation.cpp index 6eac73aeee9..a65056a1567 100644 --- a/apps/cloud_composer/tools/fpfh_estimation.cpp +++ b/apps/cloud_composer/tools/fpfh_estimation.cpp @@ -1,107 +1,105 @@ +#include #include -#include #include -#include +#include + #include -#include #include +#include Q_PLUGIN_METADATA(IID "cloud_composer.ToolFactory/1.0") -pcl::cloud_composer::FPFHEstimationTool::FPFHEstimationTool( - PropertiesModel* parameter_model, QObject* parent) -: NewItemTool(parameter_model, parent) -{} +pcl::cloud_composer::FPFHEstimationTool::FPFHEstimationTool (PropertiesModel* parameter_model, QObject* parent) + : NewItemTool (parameter_model, parent) +{ -QList -pcl::cloud_composer::FPFHEstimationTool::performAction(ConstItemList input_data, - PointTypeFlags::PointType) + +} + +QList +pcl::cloud_composer::FPFHEstimationTool::performAction (ConstItemList input_data, PointTypeFlags::PointType) { - QList output; + QList output; const CloudComposerItem* input_item; // Check input data length - if (input_data.empty()) { - qCritical() << "Empty input in FPFH Estimation Tool!"; + if ( input_data.empty ()) + { + qCritical () << "Empty input in FPFH Estimation Tool!"; return output; } - if (input_data.size() > 1) { - qWarning() << "Input vector has more than one item in FPFH Estimation!"; + if ( input_data.size () > 1) + { + qWarning () << "Input vector has more than one item in FPFH Estimation!"; } - input_item = input_data.value(0); - - if (input_item->type() == CloudComposerItem::CLOUD_ITEM) { - // Check if this cloud has normals computed! - QList normals_list = - input_item->getChildren(CloudComposerItem::NORMALS_ITEM); - if (normals_list.empty()) { - qCritical() << "No normals item child found in this cloud item"; + input_item = input_data.value (0); + + + if (input_item->type () == CloudComposerItem::CLOUD_ITEM) + { + //Check if this cloud has normals computed! + QList normals_list = input_item->getChildren (CloudComposerItem::NORMALS_ITEM); + if ( normals_list.empty () ) + { + qCritical () << "No normals item child found in this cloud item"; return output; } - qDebug() << "Found item text=" << normals_list.at(0)->text(); + qDebug () << "Found item text="<text(); double radius = parameter_model_->getProperty("Radius").toDouble(); - - pcl::PCLPointCloud2::ConstPtr input_cloud = - input_item->data(ItemDataRole::CLOUD_BLOB) - .value(); - // Get the cloud in template form - pcl::PointCloud::Ptr cloud(new pcl::PointCloud); - pcl::fromPCLPointCloud2(*input_cloud, *cloud); - - // Get the normals cloud, we just use the first normals that were found if there are - // more than one - pcl::PointCloud::ConstPtr input_normals = - normals_list.value(0) - ->data(ItemDataRole::CLOUD_TEMPLATED) - .value::ConstPtr>(); - + + pcl::PCLPointCloud2::ConstPtr input_cloud = input_item->data (ItemDataRole::CLOUD_BLOB).value (); + //Get the cloud in template form + pcl::PointCloud::Ptr cloud (new pcl::PointCloud); + pcl::fromPCLPointCloud2 (*input_cloud, *cloud); + + //Get the normals cloud, we just use the first normals that were found if there are more than one + pcl::PointCloud::ConstPtr input_normals = normals_list.value(0)->data(ItemDataRole::CLOUD_TEMPLATED).value ::ConstPtr> (); + pcl::FPFHEstimation fpfh; - // qDebug () << "Input cloud size = "<size (); + // qDebug () << "Input cloud size = "<size (); //////////////// THE WORK - COMPUTING FPFH /////////////////// // Create the FPFH estimation class, and pass the input dataset+normals to it - fpfh.setInputCloud(cloud); - fpfh.setInputNormals(input_normals); + fpfh.setInputCloud (cloud); + fpfh.setInputNormals (input_normals); // Create an empty kdtree representation, and pass it to the FPFH estimation object. - // Its content will be filled inside the object, based on the given input dataset - // (as no other search surface is given). - qDebug() << "Building KD Tree"; - pcl::search::KdTree::Ptr tree(new pcl::search::KdTree); - fpfh.setSearchMethod(tree); + // Its content will be filled inside the object, based on the given input dataset (as no other search surface is given). + qDebug () << "Building KD Tree"; + pcl::search::KdTree::Ptr tree (new pcl::search::KdTree); + fpfh.setSearchMethod (tree); // Output datasets - pcl::PointCloud::Ptr fpfhs( - new pcl::PointCloud()); + pcl::PointCloud::Ptr fpfhs (new pcl::PointCloud ()); // Use all neighbors in a sphere of radius 5cm - // IMPORTANT: the radius used here has to be larger than the radius used to estimate - // the surface normals!!! - fpfh.setRadiusSearch(radius); + // IMPORTANT: the radius used here has to be larger than the radius used to estimate the surface normals!!! + fpfh.setRadiusSearch (radius); // Compute the features - qDebug() << "Computing FPFH features"; - fpfh.compute(*fpfhs); - qDebug() << "Size of computed features =" << fpfhs->width; + qDebug () << "Computing FPFH features"; + fpfh.compute (*fpfhs); + qDebug () << "Size of computed features ="<width; ////////////////////////////////////////////////////////////////// - FPFHItem* fpfh_item = new FPFHItem(tr("FPFH r=%1").arg(radius), fpfhs, radius); - output.append(fpfh_item); + FPFHItem* fpfh_item = new FPFHItem (tr("FPFH r=%1").arg(radius),fpfhs,radius); + output.append (fpfh_item); } - else { - qCritical() << "Input item in FPFH Estimation is not a cloud!!!"; + else + { + qCritical () << "Input item in FPFH Estimation is not a cloud!!!"; } - + + return output; } /////////////////// PARAMETER MODEL ///////////////////////////////// pcl::cloud_composer::PropertiesModel* -pcl::cloud_composer::FPFHEstimationToolFactory::createToolParameterModel( - QObject* parent) +pcl::cloud_composer::FPFHEstimationToolFactory::createToolParameterModel (QObject* parent) { - auto* parameter_model = new PropertiesModel(parent); - - parameter_model->addProperty("Radius", 0.03, Qt::ItemIsEditable | Qt::ItemIsEnabled); - + PropertiesModel* parameter_model = new PropertiesModel(parent); + + parameter_model->addProperty ("Radius", 0.03, Qt::ItemIsEditable | Qt::ItemIsEnabled); + return parameter_model; } diff --git a/apps/cloud_composer/tools/normal_estimation.cpp b/apps/cloud_composer/tools/normal_estimation.cpp index b8c963e1da5..55ced5d3e92 100644 --- a/apps/cloud_composer/tools/normal_estimation.cpp +++ b/apps/cloud_composer/tools/normal_estimation.cpp @@ -1,81 +1,83 @@ -#include #include +#include + #include #include Q_PLUGIN_METADATA(IID "cloud_composer.ToolFactory/1.0") -pcl::cloud_composer::NormalEstimationTool::NormalEstimationTool( - PropertiesModel* parameter_model, QObject* parent) -: NewItemTool(parameter_model, parent) -{} +pcl::cloud_composer::NormalEstimationTool::NormalEstimationTool (PropertiesModel* parameter_model, QObject* parent) + : NewItemTool (parameter_model, parent) +{ + + +} -QList -pcl::cloud_composer::NormalEstimationTool::performAction(ConstItemList input_data, - PointTypeFlags::PointType) +QList +pcl::cloud_composer::NormalEstimationTool::performAction (ConstItemList input_data, PointTypeFlags::PointType) { - QList output; + QList output; const CloudComposerItem* input_item; // Check input data length - if (input_data.empty()) { - qCritical() << "Empty input in Normal Estimation Tool!"; + if ( input_data.empty ()) + { + qCritical () << "Empty input in Normal Estimation Tool!"; return output; } - if (input_data.size() > 1) { - qWarning() << "Input vector has more than one item in Normal Estimation!"; + if ( input_data.size () > 1) + { + qWarning () << "Input vector has more than one item in Normal Estimation!"; } - input_item = input_data.value(0); - + input_item = input_data.value (0); + pcl::PCLPointCloud2::ConstPtr input_cloud; - if (input_item->type() == CloudComposerItem::CLOUD_ITEM) { + if (input_item->type () == CloudComposerItem::CLOUD_ITEM) + { double radius = parameter_model_->getProperty("Radius").toDouble(); - qDebug() << "Received Radius = " << radius; - auto input_cloud = input_item->data(ItemDataRole::CLOUD_BLOB) - .value(); - qDebug() << "Got cloud size = " << input_cloud->width; + qDebug () << "Received Radius = " <data (ItemDataRole::CLOUD_BLOB).value (); + qDebug () << "Got cloud size = "<width; //////////////// THE WORK - COMPUTING NORMALS /////////////////// - pcl::PointCloud::Ptr cloud(new pcl::PointCloud); - pcl::fromPCLPointCloud2(*input_cloud, *cloud); + pcl::PointCloud::Ptr cloud (new pcl::PointCloud); + pcl::fromPCLPointCloud2 (*input_cloud, *cloud); // Create the normal estimation class, and pass the input dataset to it pcl::NormalEstimation ne; - ne.setInputCloud(cloud); + ne.setInputCloud (cloud); - // Create an empty kdtree representation, and pass it to the normal estimation - // object. Its content will be filled inside the object, based on the given input - // dataset (as no other search surface is given). - pcl::search::KdTree::Ptr tree( - new pcl::search::KdTree()); - ne.setSearchMethod(tree); + // Create an empty kdtree representation, and pass it to the normal estimation object. + // Its content will be filled inside the object, based on the given input dataset (as no other search surface is given). + pcl::search::KdTree::Ptr tree (new pcl::search::KdTree ()); + ne.setSearchMethod (tree); // Output datasets - pcl::PointCloud::Ptr cloud_normals(new pcl::PointCloud); + pcl::PointCloud::Ptr cloud_normals (new pcl::PointCloud); // Use all neighbors in a sphere of radius 3cm - ne.setRadiusSearch(radius); + ne.setRadiusSearch (radius); // Compute the features - ne.compute(*cloud_normals); + ne.compute (*cloud_normals); ////////////////////////////////////////////////////////////////// - auto* normals_item = - new NormalsItem(tr("Normals r=%1").arg(radius), cloud_normals, radius); - output.append(normals_item); - qDebug() << "Calced normals"; + NormalsItem* normals_item = new NormalsItem (tr("Normals r=%1").arg(radius),cloud_normals,radius); + output.append (normals_item); + qDebug () << "Calced normals"; } - else { - qDebug() << "Input item in Normal Estimation is not a cloud!!!"; + else + { + qDebug () << "Input item in Normal Estimation is not a cloud!!!"; } - + + return output; } /////////////////// PARAMETER MODEL ///////////////////////////////// pcl::cloud_composer::PropertiesModel* -pcl::cloud_composer::NormalEstimationToolFactory::createToolParameterModel( - QObject* parent) +pcl::cloud_composer::NormalEstimationToolFactory::createToolParameterModel (QObject* parent) { - auto* parameter_model = new PropertiesModel(parent); - - parameter_model->addProperty("Radius", 0.04, Qt::ItemIsEditable | Qt::ItemIsEnabled); - + PropertiesModel* parameter_model = new PropertiesModel(parent); + + parameter_model->addProperty ("Radius", 0.04, Qt::ItemIsEditable | Qt::ItemIsEnabled); + return parameter_model; } diff --git a/apps/cloud_composer/tools/organized_segmentation.cpp b/apps/cloud_composer/tools/organized_segmentation.cpp index 587e127a52a..47d7430fad0 100644 --- a/apps/cloud_composer/tools/organized_segmentation.cpp +++ b/apps/cloud_composer/tools/organized_segmentation.cpp @@ -1,59 +1,58 @@ -#include -#include #include +#include + +#include #include #include #include -#include + + +#include Q_PLUGIN_METADATA(IID "cloud_composer.ToolFactory/1.0") -pcl::cloud_composer::OrganizedSegmentationTool::OrganizedSegmentationTool( - PropertiesModel* parameter_model, QObject* parent) -: SplitItemTool(parameter_model, parent) -{} +pcl::cloud_composer::OrganizedSegmentationTool::OrganizedSegmentationTool (PropertiesModel* parameter_model, QObject* parent) +: SplitItemTool (parameter_model, parent) +{ + +} -QList -pcl::cloud_composer::OrganizedSegmentationTool::performAction( - ConstItemList input_data, PointTypeFlags::PointType type) +QList +pcl::cloud_composer::OrganizedSegmentationTool::performAction (ConstItemList input_data, PointTypeFlags::PointType type) { - if (type != PointTypeFlags::NONE) { - switch (static_cast(type)) { - case (PointTypeFlags::XYZ): - return this->performTemplatedAction(input_data); - case (PointTypeFlags::XYZ | PointTypeFlags::RGB): - return this->performTemplatedAction(input_data); - case (PointTypeFlags::XYZ | PointTypeFlags::RGBA): - return this->performTemplatedAction(input_data); + if (type != PointTypeFlags::NONE) + { + switch ((std::uint8_t) type) + { + case (PointTypeFlags::XYZ): + return this->performTemplatedAction (input_data); + case (PointTypeFlags::XYZ | PointTypeFlags::RGB): + return this->performTemplatedAction (input_data); + case (PointTypeFlags::XYZ | PointTypeFlags::RGBA): + return this->performTemplatedAction (input_data); } } - - QList output; - - qCritical() << "organized_segmentation requires templated types!"; - + + QList output; + + qCritical () << "organized_segmentation requires templated types!"; + return output; -} +} /////////////////// PARAMETER MODEL ///////////////////////////////// pcl::cloud_composer::PropertiesModel* -pcl::cloud_composer::OrganizedSegmentationToolFactory::createToolParameterModel( - QObject* parent) +pcl::cloud_composer::OrganizedSegmentationToolFactory::createToolParameterModel (QObject* parent) { - auto* parameter_model = new PropertiesModel(parent); - - parameter_model->addProperty( - "Min Inliers", 1000, Qt::ItemIsEditable | Qt::ItemIsEnabled); - parameter_model->addProperty( - "Min Plane Size", 10000, Qt::ItemIsEditable | Qt::ItemIsEnabled); - parameter_model->addProperty( - "Angular Threshold", 2.0, Qt::ItemIsEditable | Qt::ItemIsEnabled); - parameter_model->addProperty( - "Distance Threshold", 0.02, Qt::ItemIsEditable | Qt::ItemIsEnabled); - parameter_model->addProperty( - "Cluster Dist. Thresh.", 0.01, Qt::ItemIsEditable | Qt::ItemIsEnabled); - parameter_model->addProperty( - "Min Cluster Size", 1000, Qt::ItemIsEditable | Qt::ItemIsEnabled); - + PropertiesModel* parameter_model = new PropertiesModel(parent); + + parameter_model->addProperty ("Min Inliers", 1000, Qt::ItemIsEditable | Qt::ItemIsEnabled); + parameter_model->addProperty ("Min Plane Size", 10000, Qt::ItemIsEditable | Qt::ItemIsEnabled); + parameter_model->addProperty ("Angular Threshold", 2.0, Qt::ItemIsEditable | Qt::ItemIsEnabled); + parameter_model->addProperty ("Distance Threshold", 0.02, Qt::ItemIsEditable | Qt::ItemIsEnabled); + parameter_model->addProperty ("Cluster Dist. Thresh.", 0.01, Qt::ItemIsEditable | Qt::ItemIsEnabled); + parameter_model->addProperty ("Min Cluster Size", 1000, Qt::ItemIsEditable | Qt::ItemIsEnabled); + + return parameter_model; } diff --git a/apps/cloud_composer/tools/sanitize_cloud.cpp b/apps/cloud_composer/tools/sanitize_cloud.cpp index ee34930c21e..d56d5276c36 100644 --- a/apps/cloud_composer/tools/sanitize_cloud.cpp +++ b/apps/cloud_composer/tools/sanitize_cloud.cpp @@ -1,74 +1,75 @@ -#include #include +#include #include -#include // for pcl::make_shared +#include // for pcl::make_shared Q_PLUGIN_METADATA(IID "cloud_composer.ToolFactory/1.0") -pcl::cloud_composer::SanitizeCloudTool::SanitizeCloudTool( - PropertiesModel* parameter_model, QObject* parent) -: ModifyItemTool(parameter_model, parent) -{} +pcl::cloud_composer::SanitizeCloudTool::SanitizeCloudTool (PropertiesModel* parameter_model, QObject* parent) +: ModifyItemTool (parameter_model, parent) +{ +} -QList -pcl::cloud_composer::SanitizeCloudTool::performAction(ConstItemList input_data, - PointTypeFlags::PointType) +QList +pcl::cloud_composer::SanitizeCloudTool::performAction (ConstItemList input_data, PointTypeFlags::PointType) { - QList output; + QList output; const CloudComposerItem* input_item; // Check input data length - if (input_data.empty()) { - qCritical() << "Empty input in SanitizeCloudTool!"; + if ( input_data.empty ()) + { + qCritical () << "Empty input in SanitizeCloudTool!"; return output; } - input_item = input_data.value(0); - - if (input_item->type() == CloudComposerItem::CLOUD_ITEM) { - auto input_cloud = input_item->data(ItemDataRole::CLOUD_BLOB) - .value(); - - bool keep_organized = parameter_model_->getProperty("Keep Organized").toBool(); - + input_item = input_data.value (0); + + if (input_item->type () == CloudComposerItem::CLOUD_ITEM ) + { + pcl::PCLPointCloud2::ConstPtr input_cloud = input_item->data (ItemDataRole::CLOUD_BLOB).value (); + + bool keep_organized = parameter_model_->getProperty("Keep Organized").toBool (); + //////////////// THE WORK - FILTERING NANS /////////////////// // Create the filtering object pcl::PassThrough pass_filter; - pass_filter.setInputCloud(input_cloud); - pass_filter.setKeepOrganized(keep_organized); - - // Create output cloud - pcl::PCLPointCloud2::Ptr cloud_filtered = pcl::make_shared(); - // Filter! - pass_filter.filter(*cloud_filtered); - + pass_filter.setInputCloud (input_cloud); + pass_filter.setKeepOrganized (keep_organized); + + //Create output cloud + pcl::PCLPointCloud2::Ptr cloud_filtered = pcl::make_shared (); + //Filter! + pass_filter.filter (*cloud_filtered); + ////////////////////////////////////////////////////////////////// - // Get copies of the original origin and orientation - auto source_origin = - input_item->data(ItemDataRole::ORIGIN).value(); - auto source_orientation = - input_item->data(ItemDataRole::ORIENTATION).value(); - // Put the modified cloud into an item, stick in output - auto* cloud_item = new CloudItem(input_item->text() + tr(" sanitized"), - cloud_filtered, - source_origin, - source_orientation); - - output.append(cloud_item); + //Get copies of the original origin and orientation + Eigen::Vector4f source_origin = input_item->data (ItemDataRole::ORIGIN).value (); + Eigen::Quaternionf source_orientation = input_item->data (ItemDataRole::ORIENTATION).value (); + //Put the modified cloud into an item, stick in output + CloudItem* cloud_item = new CloudItem (input_item->text () + tr (" sanitized") + , cloud_filtered + , source_origin + , source_orientation); + + + output.append (cloud_item); } - else { - qDebug() << "Input item in StatisticalOutlierRemovalTool is not a cloud!!!"; + else + { + qDebug () << "Input item in StatisticalOutlierRemovalTool is not a cloud!!!"; } - + + return output; } /////////////////// PARAMETER MODEL ///////////////////////////////// pcl::cloud_composer::PropertiesModel* -pcl::cloud_composer::SanitizeCloudToolFactory::createToolParameterModel(QObject* parent) +pcl::cloud_composer::SanitizeCloudToolFactory::createToolParameterModel (QObject* parent) { - auto* parameter_model = new PropertiesModel(parent); - - parameter_model->addProperty( - "Keep Organized", false, Qt::ItemIsEditable | Qt::ItemIsEnabled); - + PropertiesModel* parameter_model = new PropertiesModel(parent); + + parameter_model->addProperty ("Keep Organized", false, Qt::ItemIsEditable | Qt::ItemIsEnabled); + return parameter_model; } + diff --git a/apps/cloud_composer/tools/statistical_outlier_removal.cpp b/apps/cloud_composer/tools/statistical_outlier_removal.cpp index fd064e9e5d5..3213a9755d5 100644 --- a/apps/cloud_composer/tools/statistical_outlier_removal.cpp +++ b/apps/cloud_composer/tools/statistical_outlier_removal.cpp @@ -1,86 +1,89 @@ -#include #include +#include + #include #include Q_PLUGIN_METADATA(IID "cloud_composer.ToolFactory/1.0") -pcl::cloud_composer::StatisticalOutlierRemovalTool::StatisticalOutlierRemovalTool( - PropertiesModel* parameter_model, QObject* parent) -: ModifyItemTool(parameter_model, parent) -{} +pcl::cloud_composer::StatisticalOutlierRemovalTool::StatisticalOutlierRemovalTool (PropertiesModel* parameter_model, QObject* parent) + : ModifyItemTool (parameter_model, parent) +{ -QList -pcl::cloud_composer::StatisticalOutlierRemovalTool::performAction( - ConstItemList input_data, PointTypeFlags::PointType) + +} + +QList +pcl::cloud_composer::StatisticalOutlierRemovalTool::performAction (ConstItemList input_data, PointTypeFlags::PointType) { - QList output; + QList output; const CloudComposerItem* input_item; // Check input data length - if (input_data.empty()) { - qCritical() << "Empty input in StatisticalOutlierRemovalTool!"; + if ( input_data.empty ()) + { + qCritical () << "Empty input in StatisticalOutlierRemovalTool!"; return output; } - if (input_data.size() > 1) { - qWarning() - << "Input vector has more than one item in StatisticalOutlierRemovalTool"; + if ( input_data.size () > 1) + { + qWarning () << "Input vector has more than one item in StatisticalOutlierRemovalTool"; } - input_item = input_data.value(0); - if (!input_item->isSanitized()) { - qCritical() << "StatisticalOutlierRemovalTool requires sanitized input!"; + input_item = input_data.value (0); + if ( !input_item->isSanitized () ) + { + qCritical () << "StatisticalOutlierRemovalTool requires sanitized input!"; return output; } - - if (input_item->type() == CloudComposerItem::CLOUD_ITEM) { - auto input_cloud = input_item->data(ItemDataRole::CLOUD_BLOB) - .value(); - - int mean_k = parameter_model_->getProperty("Mean K").toInt(); - double std_dev_thresh = parameter_model_->getProperty("Std Dev Thresh").toDouble(); - + + if (input_item->type () == CloudComposerItem::CLOUD_ITEM ) + { + pcl::PCLPointCloud2::ConstPtr input_cloud = input_item->data (ItemDataRole::CLOUD_BLOB).value (); + + int mean_k = parameter_model_->getProperty("Mean K").toInt (); + double std_dev_thresh = parameter_model_->getProperty ("Std Dev Thresh").toDouble (); + //////////////// THE WORK - FILTERING OUTLIERS /////////////////// // Create the filtering object pcl::StatisticalOutlierRemoval sor; - sor.setInputCloud(input_cloud); - sor.setMeanK(mean_k); - sor.setStddevMulThresh(std_dev_thresh); - - // Create output cloud - pcl::PCLPointCloud2::Ptr cloud_filtered(new pcl::PCLPointCloud2); - // Filter! - sor.filter(*cloud_filtered); + sor.setInputCloud (input_cloud); + sor.setMeanK (mean_k); + sor.setStddevMulThresh (std_dev_thresh); + + //Create output cloud + pcl::PCLPointCloud2::Ptr cloud_filtered (new pcl::PCLPointCloud2); + //Filter! + sor.filter (*cloud_filtered); ////////////////////////////////////////////////////////////////// - // Get copies of the original origin and orientation - auto source_origin = - input_item->data(ItemDataRole::ORIGIN).value(); - auto source_orientation = - input_item->data(ItemDataRole::ORIENTATION).value(); - // Put the modified cloud into an item, stick in output - auto* cloud_item = new CloudItem(input_item->text() + tr(" sor filtered"), - cloud_filtered, - source_origin, - source_orientation); + //Get copies of the original origin and orientation + Eigen::Vector4f source_origin = input_item->data (ItemDataRole::ORIGIN).value (); + Eigen::Quaternionf source_orientation = input_item->data (ItemDataRole::ORIENTATION).value (); + //Put the modified cloud into an item, stick in output + CloudItem* cloud_item = new CloudItem (input_item->text () + tr (" sor filtered") + , cloud_filtered + , source_origin + , source_orientation); - output.append(cloud_item); + + output.append (cloud_item); } - else { - qDebug() << "Input item in StatisticalOutlierRemovalTool is not a cloud!!!"; + else + { + qDebug () << "Input item in StatisticalOutlierRemovalTool is not a cloud!!!"; } - + + return output; } /////////////////// PARAMETER MODEL ///////////////////////////////// pcl::cloud_composer::PropertiesModel* -pcl::cloud_composer::StatisticalOutlierRemovalToolFactory::createToolParameterModel( - QObject* parent) +pcl::cloud_composer::StatisticalOutlierRemovalToolFactory::createToolParameterModel (QObject* parent) { - auto* parameter_model = new PropertiesModel(parent); - - parameter_model->addProperty("Mean K", 50, Qt::ItemIsEditable | Qt::ItemIsEnabled); - parameter_model->addProperty( - "Std Dev Thresh", 1.0, Qt::ItemIsEditable | Qt::ItemIsEnabled); - + PropertiesModel* parameter_model = new PropertiesModel(parent); + + parameter_model->addProperty ("Mean K", 50, Qt::ItemIsEditable | Qt::ItemIsEnabled); + parameter_model->addProperty ("Std Dev Thresh", 1.0, Qt::ItemIsEditable | Qt::ItemIsEnabled); + return parameter_model; } diff --git a/apps/cloud_composer/tools/supervoxels.cpp b/apps/cloud_composer/tools/supervoxels.cpp index 10ea5ba46fe..6c22b37f9fc 100644 --- a/apps/cloud_composer/tools/supervoxels.cpp +++ b/apps/cloud_composer/tools/supervoxels.cpp @@ -1,61 +1,56 @@ -#include -#include #include +#include #include #include -#include #include +#include + +#include Q_PLUGIN_METADATA(IID "cloud_composer.ToolFactory/1.0") -pcl::cloud_composer::SupervoxelsTool::SupervoxelsTool(PropertiesModel* parameter_model, - QObject* parent) -: SplitItemTool(parameter_model, parent) -{} +pcl::cloud_composer::SupervoxelsTool::SupervoxelsTool (PropertiesModel* parameter_model, QObject* parent) +: SplitItemTool (parameter_model, parent) +{ + +} -QList -pcl::cloud_composer::SupervoxelsTool::performAction(ConstItemList input_data, - PointTypeFlags::PointType type) +QList +pcl::cloud_composer::SupervoxelsTool::performAction (ConstItemList input_data, PointTypeFlags::PointType type) { - if (type != PointTypeFlags::NONE) { - switch (static_cast(type)) { - case (PointTypeFlags::XYZ | PointTypeFlags::RGB): - return this->performTemplatedAction(input_data); - case (PointTypeFlags::XYZ | PointTypeFlags::RGBA): - return this->performTemplatedAction(input_data); + if (type != PointTypeFlags::NONE) + { + switch ((std::uint8_t) type) + { + case (PointTypeFlags::XYZ | PointTypeFlags::RGB): + return this->performTemplatedAction (input_data); + case (PointTypeFlags::XYZ | PointTypeFlags::RGBA): + return this->performTemplatedAction (input_data); } } - - QList output; - - qCritical() << "supervoxels requires templated types!"; - + + QList output; + + qCritical () << "supervoxels requires templated types!"; + return output; -} +} + +template QList pcl::cloud_composer::SupervoxelsTool::performTemplatedAction (const QList &); +//template QList pcl::cloud_composer::SupervoxelsTool::performTemplatedAction (const QList &); -template QList -pcl::cloud_composer::SupervoxelsTool::performTemplatedAction( - const QList&); -// template QList -// pcl::cloud_composer::SupervoxelsTool::performTemplatedAction -// (const QList &); /////////////////// PARAMETER MODEL ///////////////////////////////// pcl::cloud_composer::PropertiesModel* -pcl::cloud_composer::SupervoxelsToolFactory::createToolParameterModel(QObject* parent) +pcl::cloud_composer::SupervoxelsToolFactory::createToolParameterModel (QObject* parent) { - auto* parameter_model = new PropertiesModel(parent); - - parameter_model->addProperty( - "Resolution", 0.008, Qt::ItemIsEditable | Qt::ItemIsEnabled); - parameter_model->addProperty( - "Seed Resolution", 0.08, Qt::ItemIsEditable | Qt::ItemIsEnabled); - parameter_model->addProperty( - "RGB Weight", 0.2, Qt::ItemIsEditable | Qt::ItemIsEnabled); - parameter_model->addProperty( - "Normals Weight", 0.8, Qt::ItemIsEditable | Qt::ItemIsEnabled); - parameter_model->addProperty( - "Spatial Weight", 0.4, Qt::ItemIsEditable | Qt::ItemIsEnabled); - + PropertiesModel* parameter_model = new PropertiesModel(parent); + + parameter_model->addProperty ("Resolution", 0.008, Qt::ItemIsEditable | Qt::ItemIsEnabled); + parameter_model->addProperty ("Seed Resolution", 0.08, Qt::ItemIsEditable | Qt::ItemIsEnabled); + parameter_model->addProperty ("RGB Weight", 0.2, Qt::ItemIsEditable | Qt::ItemIsEnabled); + parameter_model->addProperty ("Normals Weight", 0.8, Qt::ItemIsEditable | Qt::ItemIsEnabled); + parameter_model->addProperty ("Spatial Weight", 0.4, Qt::ItemIsEditable | Qt::ItemIsEnabled); + return parameter_model; } diff --git a/apps/cloud_composer/tools/voxel_grid_downsample.cpp b/apps/cloud_composer/tools/voxel_grid_downsample.cpp index 790fff9ce8b..5b15c3409d4 100644 --- a/apps/cloud_composer/tools/voxel_grid_downsample.cpp +++ b/apps/cloud_composer/tools/voxel_grid_downsample.cpp @@ -1,86 +1,88 @@ -#include #include +#include + #include #include + Q_PLUGIN_METADATA(IID "cloud_composer.ToolFactory/1.0") -pcl::cloud_composer::VoxelGridDownsampleTool::VoxelGridDownsampleTool( - PropertiesModel* parameter_model, QObject* parent) -: ModifyItemTool(parameter_model, parent) -{} +pcl::cloud_composer::VoxelGridDownsampleTool::VoxelGridDownsampleTool (PropertiesModel* parameter_model, QObject* parent) + : ModifyItemTool (parameter_model, parent) +{ + + +} -QList -pcl::cloud_composer::VoxelGridDownsampleTool::performAction(ConstItemList input_data, - PointTypeFlags::PointType) +QList +pcl::cloud_composer::VoxelGridDownsampleTool::performAction (ConstItemList input_data, PointTypeFlags::PointType) { - QList output; + QList output; const CloudComposerItem* input_item; // Check input data length - if (input_data.empty()) { - qCritical() << "Empty input in VoxelGridDownsampleTool!"; + if ( input_data.empty ()) + { + qCritical () << "Empty input in VoxelGridDownsampleTool!"; return output; } - if (input_data.size() > 1) { - qWarning() << "Input vector has more than one item in VoxelGridDownsampleTool"; + if ( input_data.size () > 1) + { + qWarning () << "Input vector has more than one item in VoxelGridDownsampleTool"; } - input_item = input_data.value(0); - - if (input_item->type() == CloudComposerItem::CLOUD_ITEM) { - double leaf_x = parameter_model_->getProperty("Leaf Size x").toDouble(); - double leaf_y = parameter_model_->getProperty("Leaf Size y").toDouble(); - double leaf_z = parameter_model_->getProperty("Leaf Size z").toDouble(); - - auto input_cloud = input_item->data(ItemDataRole::CLOUD_BLOB) - .value(); - + input_item = input_data.value (0); + + if (input_item->type () == CloudComposerItem::CLOUD_ITEM) + { + double leaf_x = parameter_model_->getProperty("Leaf Size x").toDouble (); + double leaf_y = parameter_model_->getProperty("Leaf Size y").toDouble (); + double leaf_z = parameter_model_->getProperty("Leaf Size z").toDouble (); + + pcl::PCLPointCloud2::ConstPtr input_cloud = input_item->data (ItemDataRole::CLOUD_BLOB).value (); + //////////////// THE WORK - FILTERING OUTLIERS /////////////////// // Create the filtering object pcl::VoxelGrid vox_grid; - vox_grid.setInputCloud(input_cloud); - vox_grid.setLeafSize(static_cast(leaf_x), - static_cast(leaf_y), - static_cast(leaf_z)); - - // Create output cloud - pcl::PCLPointCloud2::Ptr cloud_filtered(new pcl::PCLPointCloud2); - // Filter! - vox_grid.filter(*cloud_filtered); + vox_grid.setInputCloud (input_cloud); + vox_grid.setLeafSize (float (leaf_x), float (leaf_y), float (leaf_z)); + + + //Create output cloud + pcl::PCLPointCloud2::Ptr cloud_filtered (new pcl::PCLPointCloud2); + //Filter! + vox_grid.filter (*cloud_filtered); ////////////////////////////////////////////////////////////////// - // Get copies of the original origin and orientation - auto source_origin = - input_item->data(ItemDataRole::ORIGIN).value(); - auto source_orientation = - input_item->data(ItemDataRole::ORIENTATION).value(); - // Put the modified cloud into an item, stick in output - auto* cloud_item = new CloudItem(input_item->text() + tr(" vox ds"), - cloud_filtered, - source_origin, - source_orientation); + //Get copies of the original origin and orientation + Eigen::Vector4f source_origin = input_item->data (ItemDataRole::ORIGIN).value (); + Eigen::Quaternionf source_orientation = input_item->data (ItemDataRole::ORIENTATION).value (); + //Put the modified cloud into an item, stick in output + CloudItem* cloud_item = new CloudItem (input_item->text () + tr (" vox ds") + , cloud_filtered + , source_origin + , source_orientation); - output.append(cloud_item); + + output.append (cloud_item); } - else { - qDebug() << "Input item in VoxelGridDownsampleTool is not a cloud!!!"; + else + { + qDebug () << "Input item in VoxelGridDownsampleTool is not a cloud!!!"; } - + + return output; } /////////////////// PARAMETER MODEL ///////////////////////////////// pcl::cloud_composer::PropertiesModel* -pcl::cloud_composer::VoxelGridDownsampleToolFactory::createToolParameterModel( - QObject* parent) +pcl::cloud_composer::VoxelGridDownsampleToolFactory::createToolParameterModel (QObject* parent) { - auto* parameter_model = new PropertiesModel(parent); - - parameter_model->addProperty( - "Leaf Size x", 0.01, Qt::ItemIsEditable | Qt::ItemIsEnabled); - parameter_model->addProperty( - "Leaf Size y", 0.01, Qt::ItemIsEditable | Qt::ItemIsEnabled); - parameter_model->addProperty( - "Leaf Size z", 0.01, Qt::ItemIsEditable | Qt::ItemIsEnabled); + PropertiesModel* parameter_model = new PropertiesModel(parent); + + parameter_model->addProperty ("Leaf Size x", 0.01, Qt::ItemIsEditable | Qt::ItemIsEnabled); + parameter_model->addProperty ("Leaf Size y", 0.01, Qt::ItemIsEditable | Qt::ItemIsEnabled); + parameter_model->addProperty ("Leaf Size z", 0.01, Qt::ItemIsEditable | Qt::ItemIsEnabled); + return parameter_model; } diff --git a/apps/in_hand_scanner/CMakeLists.txt b/apps/in_hand_scanner/CMakeLists.txt index 8a670a5b81a..97e2c72ee11 100644 --- a/apps/in_hand_scanner/CMakeLists.txt +++ b/apps/in_hand_scanner/CMakeLists.txt @@ -1,7 +1,7 @@ set(SUBSUBSYS_NAME in_hand_scanner) set(SUBSUBSYS_DESC "In-hand scanner for small objects") -set(SUBSUBSYS_DEPS common geometry features io kdtree) -set(SUBSUBSYS_LIBS pcl_common pcl_geometry pcl_features pcl_io pcl_kdtree) +set(SUBSUBSYS_DEPS common features io kdtree apps) +set(SUBSUBSYS_LIBS pcl_common pcl_features pcl_io pcl_kdtree) set(SUBSUBSYS_EXT_DEPS ${QTX} OpenGL OpenGL_GLU openni) set(REASON "") set(DEFAULT OFF) @@ -19,7 +19,9 @@ pcl_add_doc("${SUBSUBSYS_NAME}") ################################################################################ set(INCS + "include/pcl/${SUBSYS_NAME}/${SUBSUBSYS_NAME}/boost.h" "include/pcl/${SUBSYS_NAME}/${SUBSUBSYS_NAME}/common_types.h" + "include/pcl/${SUBSYS_NAME}/${SUBSUBSYS_NAME}/eigen.h" "include/pcl/${SUBSYS_NAME}/${SUBSUBSYS_NAME}/icp.h" "include/pcl/${SUBSYS_NAME}/${SUBSUBSYS_NAME}/input_data_processing.h" "include/pcl/${SUBSYS_NAME}/${SUBSUBSYS_NAME}/integration.h" @@ -75,6 +77,8 @@ if(NOT build) return() endif() +include_directories("${CMAKE_CURRENT_BINARY_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}/include") + set(EXE_NAME "pcl_${SUBSUBSYS_NAME}") PCL_ADD_EXECUTABLE( @@ -89,7 +93,6 @@ PCL_ADD_EXECUTABLE( BUNDLE) target_link_libraries("${EXE_NAME}" ${SUBSUBSYS_LIBS} ${OPENGL_LIBRARIES} ${QTX}::Concurrent ${QTX}::Widgets ${QTX}::OpenGL) -target_include_directories(${EXE_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include) if (${QTX} MATCHES "Qt6") target_link_libraries("${EXE_NAME}" ${QTX}::OpenGLWidgets) endif() @@ -109,7 +112,6 @@ PCL_ADD_EXECUTABLE( BUNDLE) target_link_libraries(pcl_offline_integration ${SUBSUBSYS_LIBS} ${OPENGL_LIBRARIES} ${QTX}::Concurrent ${QTX}::Widgets ${QTX}::OpenGL) -target_include_directories(pcl_offline_integration PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include) if (${QTX} MATCHES "Qt6") target_link_libraries(pcl_offline_integration ${QTX}::OpenGLWidgets) endif() diff --git a/apps/in_hand_scanner/include/pcl/apps/in_hand_scanner/boost.h b/apps/in_hand_scanner/include/pcl/apps/in_hand_scanner/boost.h new file mode 100644 index 00000000000..f4f535427ba --- /dev/null +++ b/apps/in_hand_scanner/include/pcl/apps/in_hand_scanner/boost.h @@ -0,0 +1,48 @@ +/* + * Software License Agreement (BSD License) + * + * Point Cloud Library (PCL) - www.pointclouds.org + * Copyright (c) 2009-2012, Willow Garage, Inc. + * Copyright (c) 2012-, Open Perception, Inc. + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * * Neither the name of the copyright holder(s) nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * $Id$ + * + */ + +#pragma once + +#ifdef __GNUC__ +#pragma GCC system_header +#endif +PCL_DEPRECATED_HEADER(1, 15, "Please include the needed boost headers directly.") +#include +#include diff --git a/apps/in_hand_scanner/include/pcl/apps/in_hand_scanner/eigen.h b/apps/in_hand_scanner/include/pcl/apps/in_hand_scanner/eigen.h new file mode 100644 index 00000000000..a4380316268 --- /dev/null +++ b/apps/in_hand_scanner/include/pcl/apps/in_hand_scanner/eigen.h @@ -0,0 +1,49 @@ +/* + * Software License Agreement (BSD License) + * + * Point Cloud Library (PCL) - www.pointclouds.org + * Copyright (c) 2009-2012, Willow Garage, Inc. + * Copyright (c) 2012-, Open Perception, Inc. + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * * Neither the name of the copyright holder(s) nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * $Id$ + * + */ + +#pragma once + +#ifdef __GNUC__ +#pragma GCC system_header +#endif +PCL_DEPRECATED_HEADER(1, 15, "Please include the needed eigen headers directly.") +#include +#include +#include diff --git a/apps/in_hand_scanner/include/pcl/apps/in_hand_scanner/icp.h b/apps/in_hand_scanner/include/pcl/apps/in_hand_scanner/icp.h index f7748dadf7e..7496c578f0a 100644 --- a/apps/in_hand_scanner/include/pcl/apps/in_hand_scanner/icp.h +++ b/apps/in_hand_scanner/include/pcl/apps/in_hand_scanner/icp.h @@ -224,16 +224,16 @@ class PCL_EXPORTS ICP { KdTreePtr kd_tree_; // Convergence - float epsilon_{10e-6f}; // in cm^2 + float epsilon_; // in cm^2 // Registration failure - unsigned int max_iterations_{50}; - float min_overlap_{.75f}; // [0 1] - float max_fitness_{.1f}; // in cm^2 + unsigned int max_iterations_; + float min_overlap_; // [0 1] + float max_fitness_; // in cm^2 // Correspondence rejection - float factor_{9.f}; - float max_angle_{45.f}; // in degrees + float factor_; + float max_angle_; // in degrees }; } // End namespace ihs } // End namespace pcl diff --git a/apps/in_hand_scanner/include/pcl/apps/in_hand_scanner/impl/common_types.hpp b/apps/in_hand_scanner/include/pcl/apps/in_hand_scanner/impl/common_types.hpp index 650441f3335..17900bf5347 100644 --- a/apps/in_hand_scanner/include/pcl/apps/in_hand_scanner/impl/common_types.hpp +++ b/apps/in_hand_scanner/include/pcl/apps/in_hand_scanner/impl/common_types.hpp @@ -78,7 +78,7 @@ struct PointIHS : public pcl::ihs::_PointIHS { this->directions = 0; } - inline PointIHS(const PointIHS& other) : _PointIHS(other) + inline PointIHS(const PointIHS& other) { this->x = other.x; this->y = other.y; diff --git a/apps/in_hand_scanner/include/pcl/apps/in_hand_scanner/in_hand_scanner.h b/apps/in_hand_scanner/include/pcl/apps/in_hand_scanner/in_hand_scanner.h index 3d1fd916237..b3d2abcf9e3 100644 --- a/apps/in_hand_scanner/include/pcl/apps/in_hand_scanner/in_hand_scanner.h +++ b/apps/in_hand_scanner/include/pcl/apps/in_hand_scanner/in_hand_scanner.h @@ -190,7 +190,7 @@ public Q_SLOTS: * \note The extension of the filename is ignored! */ void - saveAs(const std::string& filename, const FileType& filetype) const; + saveAs(const std::string& filename, const FileType& filetype); /** \see http://doc.qt.digia.com/qt/qwidget.html#keyPressEvent */ void @@ -272,16 +272,16 @@ public Q_SLOTS: VisualizationFPS visualization_fps_; /** \brief Switch between different branches of the scanning pipeline. */ - RunningMode running_mode_{RM_UNPROCESSED}; + RunningMode running_mode_; /** \brief The iteration of the scanning pipeline (grab - register - integrate). */ - unsigned int iteration_{0}; + unsigned int iteration_; /** \brief Used to get new data from the sensor. */ GrabberPtr grabber_; /** \brief This variable is true if the grabber is starting. */ - bool starting_grabber_{false}; + bool starting_grabber_; /** \brief Connection of the grabber signal with the data processing thread. */ boost::signals2::connection new_data_connection_; @@ -305,7 +305,7 @@ public Q_SLOTS: MeshPtr mesh_model_; /** \brief Prevent the application to crash while closing. */ - bool destructor_called_{false}; + bool destructor_called_; public: PCL_MAKE_ALIGNED_OPERATOR_NEW diff --git a/apps/in_hand_scanner/include/pcl/apps/in_hand_scanner/input_data_processing.h b/apps/in_hand_scanner/include/pcl/apps/in_hand_scanner/input_data_processing.h index dcb8c3e06e3..6c238fde75b 100644 --- a/apps/in_hand_scanner/include/pcl/apps/in_hand_scanner/input_data_processing.h +++ b/apps/in_hand_scanner/include/pcl/apps/in_hand_scanner/input_data_processing.h @@ -350,25 +350,25 @@ class PCL_EXPORTS InputDataProcessing { NormalEstimationPtr normal_estimation_; - float x_min_{-15.f}; - float x_max_{15.f}; - float y_min_{-15.f}; - float y_max_{15.f}; - float z_min_{48.f}; - float z_max_{70.f}; + float x_min_; + float x_max_; + float y_min_; + float y_max_; + float z_min_; + float z_max_; - float h_min_{210.f}; - float h_max_{270.f}; - float s_min_{0.2f}; - float s_max_{1.f}; - float v_min_{0.2f}; - float v_max_{1.f}; + float h_min_; + float h_max_; + float s_min_; + float s_max_; + float v_min_; + float v_max_; - bool hsv_inverted_{false}; - bool hsv_enabled_{true}; + bool hsv_inverted_; + bool hsv_enabled_; - unsigned int size_dilate_{3}; - unsigned int size_erode_{3}; + unsigned int size_dilate_; + unsigned int size_erode_; }; } // End namespace ihs } // End namespace pcl diff --git a/apps/in_hand_scanner/include/pcl/apps/in_hand_scanner/integration.h b/apps/in_hand_scanner/include/pcl/apps/in_hand_scanner/integration.h index ce67a66bd61..4c7b37e6dbb 100644 --- a/apps/in_hand_scanner/include/pcl/apps/in_hand_scanner/integration.h +++ b/apps/in_hand_scanner/include/pcl/apps/in_hand_scanner/integration.h @@ -229,25 +229,25 @@ class PCL_EXPORTS Integration { KdTreePtr kd_tree_; /** \brief Maximum squared distance below which points are averaged out. */ - float max_squared_distance_{0.04f}; + float max_squared_distance_; /** \brief Maximum angle between normals below which points are averaged out. In * degrees. */ - float max_angle_{45.f}; + float max_angle_; /** \brief Minimum weight above which points are added. */ - float min_weight_{.3f}; + float min_weight_; /** \brief Once a point reaches the maximum age it is decided if the point is removed * or kept in the mesh. */ - unsigned int max_age_{30}; + unsigned int max_age_; /** \brief A point is removed if it has not been observed from a minimum number of * directions. */ - unsigned int min_directions_{5}; + unsigned int min_directions_; }; } // End namespace ihs } // End namespace pcl diff --git a/apps/in_hand_scanner/include/pcl/apps/in_hand_scanner/offline_integration.h b/apps/in_hand_scanner/include/pcl/apps/in_hand_scanner/offline_integration.h index 39136570d96..ed5b3490467 100644 --- a/apps/in_hand_scanner/include/pcl/apps/in_hand_scanner/offline_integration.h +++ b/apps/in_hand_scanner/include/pcl/apps/in_hand_scanner/offline_integration.h @@ -213,7 +213,7 @@ private Q_SLOTS: IntegrationPtr integration_; /** \brief Prevent the application to crash while closing. */ - bool destructor_called_{false}; + bool destructor_called_; public: PCL_MAKE_ALIGNED_OPERATOR_NEW diff --git a/apps/in_hand_scanner/include/pcl/apps/in_hand_scanner/opengl_viewer.h b/apps/in_hand_scanner/include/pcl/apps/in_hand_scanner/opengl_viewer.h index 4ac2bacd862..4ce4e7ca95a 100644 --- a/apps/in_hand_scanner/include/pcl/apps/in_hand_scanner/opengl_viewer.h +++ b/apps/in_hand_scanner/include/pcl/apps/in_hand_scanner/opengl_viewer.h @@ -302,7 +302,7 @@ public Q_SLOTS: /** \brief Please have a look at the documentation of calcFPS. */ class FPS { public: - FPS() : {} + FPS() : fps_(0.) {} inline double& value() @@ -327,7 +327,7 @@ public Q_SLOTS: ~FPS() = default; private: - double fps_{0.}; + double fps_; }; /** Measures the performance of the current thread (selected by passing the @@ -391,7 +391,7 @@ public Q_SLOTS: /** \brief Draw a wireframe box. */ void - drawBox() const; + drawBox(); /** \see http://doc.qt.digia.com/qt/qglwidget.html#initializeGL */ void @@ -431,25 +431,25 @@ public Q_SLOTS: Colormap colormap_; /** \brief The visibility confidence is normalized with this value. */ - float vis_conf_norm_{1}; + float vis_conf_norm_; /** \brief Meshes stored for visualization. */ FaceVertexMeshMap drawn_meshes_; /** \brief How to draw the mesh. */ - MeshRepresentation mesh_representation_{MR_POINTS}; + MeshRepresentation mesh_representation_; /** \brief How to color the shapes. */ - Coloring coloring_{COL_RGB}; + Coloring coloring_; /** \brief A box is drawn if this value is true. */ - bool draw_box_{false}; + bool draw_box_; /** \brief Coefficients of the drawn box. */ BoxCoefficients box_coefficients_; /** \brief Scaling factor to convert from meters to the unit of the drawn files. */ - double scaling_factor_{1.}; + double scaling_factor_; /** \brief Rotation of the camera. */ Eigen::Quaterniond R_cam_; @@ -465,13 +465,13 @@ public Q_SLOTS: /** \brief Set to true right after the mouse got pressed and false if the mouse got * moved. */ - bool mouse_pressed_begin_{false}; + bool mouse_pressed_begin_; /** \brief Mouse x-position of the previous mouse move event. */ - int x_prev_{0}; + int x_prev_; /** \brief Mouse y-position of the previous mouse move event. */ - int y_prev_{0}; + int y_prev_; public: PCL_MAKE_ALIGNED_OPERATOR_NEW diff --git a/apps/in_hand_scanner/src/icp.cpp b/apps/in_hand_scanner/src/icp.cpp index 373f25a3f41..cbd16668eaa 100644 --- a/apps/in_hand_scanner/src/icp.cpp +++ b/apps/in_hand_scanner/src/icp.cpp @@ -51,7 +51,19 @@ //////////////////////////////////////////////////////////////////////////////// -pcl::ihs::ICP::ICP() : kd_tree_(new pcl::KdTreeFLANN()) {} +pcl::ihs::ICP::ICP() +: kd_tree_(new pcl::KdTreeFLANN()) +, + +epsilon_(10e-6f) +, max_iterations_(50) +, min_overlap_(.75f) +, max_fitness_(.1f) +, + +factor_(9.f) +, max_angle_(45.f) +{} //////////////////////////////////////////////////////////////////////////////// @@ -220,7 +232,8 @@ pcl::ihs::ICP::findTransformation(const MeshConstPtr& mesh_model, cloud_model_corr.clear(); cloud_data_corr.clear(); sw.reset(); - for (auto it_d = cloud_data_selected->begin(); it_d != cloud_data_selected->end(); + for (CloudNormal::const_iterator it_d = cloud_data_selected->begin(); + it_d != cloud_data_selected->end(); ++it_d) { // Transform the data point pt_d = *it_d; @@ -235,7 +248,7 @@ pcl::ihs::ICP::findTransformation(const MeshConstPtr& mesh_model, // Check the distance threshold if (squared_distance[0] < squared_distance_threshold) { - if (static_cast(index[0]) >= cloud_model_selected->size()) { + if ((std::size_t)index[0] >= cloud_model_selected->size()) { std::cerr << "ERROR in icp.cpp: Segfault!\n"; std::cerr << " Trying to access index " << index[0] << " >= " << cloud_model_selected->size() << std::endl; @@ -449,8 +462,8 @@ pcl::ihs::ICP::minimizePointPlane(const CloudNormal& cloud_source, xyz_t.reserve(n); nor_t.reserve(n); - auto it_s = cloud_source.begin(); - auto it_t = cloud_target.begin(); + CloudNormal::const_iterator it_s = cloud_source.begin(); + CloudNormal::const_iterator it_t = cloud_target.begin(); float accum = 0.f; Eigen::Vector4f pt_s, pt_t; @@ -461,7 +474,7 @@ pcl::ihs::ICP::minimizePointPlane(const CloudNormal& cloud_source, xyz_s.push_back(pt_s); xyz_t.push_back(pt_t); - nor_t.emplace_back(it_t->getNormalVector4fMap()); + nor_t.push_back(it_t->getNormalVector4fMap()); // Calculate the radius (L2 norm) of the bounding sphere through both shapes and // accumulate the average @@ -489,9 +502,9 @@ pcl::ihs::ICP::minimizePointPlane(const CloudNormal& cloud_source, Eigen::Vector4f b_t = Eigen::Vector4f::Zero(); // top Eigen::Vector4f b_b = Eigen::Vector4f::Zero(); // bottom - auto it_xyz_s = xyz_s.begin(); - auto it_xyz_t = xyz_t.begin(); - auto it_nor_t = nor_t.begin(); + Vec4Xf::const_iterator it_xyz_s = xyz_s.begin(); + Vec4Xf::const_iterator it_xyz_t = xyz_t.begin(); + Vec4Xf::const_iterator it_nor_t = nor_t.begin(); Eigen::Vector4f cross; for (; it_xyz_s != xyz_s.end(); ++it_xyz_s, ++it_xyz_t, ++it_nor_t) { diff --git a/apps/in_hand_scanner/src/in_hand_scanner.cpp b/apps/in_hand_scanner/src/in_hand_scanner.cpp index e5dcd527fe2..95d2744c610 100644 --- a/apps/in_hand_scanner/src/in_hand_scanner.cpp +++ b/apps/in_hand_scanner/src/in_hand_scanner.cpp @@ -62,12 +62,16 @@ pcl::ihs::InHandScanner::InHandScanner(Base* parent) : Base(parent) +, running_mode_(RM_UNPROCESSED) +, iteration_(0) +, starting_grabber_(false) , input_data_processing_(new InputDataProcessing()) , icp_(new ICP()) , transformation_(Eigen::Matrix4f::Identity()) , integration_(new Integration()) , mesh_processing_(new MeshProcessing()) , mesh_model_(new Mesh()) +, destructor_called_(false) { // http://doc.qt.digia.com/qt/qmetatype.html#qRegisterMetaType qRegisterMetaType("RunningMode"); @@ -237,8 +241,7 @@ pcl::ihs::InHandScanner::reset() //////////////////////////////////////////////////////////////////////////////// void -pcl::ihs::InHandScanner::saveAs(const std::string& filename, - const FileType& filetype) const +pcl::ihs::InHandScanner::saveAs(const std::string& filename, const FileType& filetype) { std::lock_guard lock(mutex_); if (destructor_called_) diff --git a/apps/in_hand_scanner/src/input_data_processing.cpp b/apps/in_hand_scanner/src/input_data_processing.cpp index 94f73dea0b2..748d7da5955 100644 --- a/apps/in_hand_scanner/src/input_data_processing.cpp +++ b/apps/in_hand_scanner/src/input_data_processing.cpp @@ -46,6 +46,22 @@ pcl::ihs::InputDataProcessing::InputDataProcessing() : normal_estimation_(new NormalEstimation()) +, x_min_(-15.f) +, x_max_(15.f) +, y_min_(-15.f) +, y_max_(15.f) +, z_min_(48.f) +, z_max_(70.f) +, h_min_(210.f) +, h_max_(270.f) +, s_min_(0.2f) +, s_max_(1.f) +, v_min_(0.2f) +, v_max_(1.f) +, hsv_inverted_(false) +, hsv_enabled_(true) +, size_dilate_(3) +, size_erode_(3) { // Normal estimation normal_estimation_->setNormalEstimationMethod(NormalEstimation::AVERAGE_3D_GRADIENT); @@ -204,8 +220,8 @@ pcl::ihs::InputDataProcessing::calculateNormals(const CloudXYZRGBAConstPtr& clou cloud_out->height = cloud_in->height; cloud_out->is_dense = false; - auto it_n = cloud_normals->begin(); - auto it_out = cloud_out->begin(); + CloudNormals::const_iterator it_n = cloud_normals->begin(); + CloudXYZRGBNormal::iterator it_out = cloud_out->begin(); PointXYZRGBNormal invalid_pt; invalid_pt.x = invalid_pt.y = invalid_pt.z = std::numeric_limits::quiet_NaN(); diff --git a/apps/in_hand_scanner/src/integration.cpp b/apps/in_hand_scanner/src/integration.cpp index fe21546b798..3d7517ac145 100644 --- a/apps/in_hand_scanner/src/integration.cpp +++ b/apps/in_hand_scanner/src/integration.cpp @@ -49,7 +49,15 @@ //////////////////////////////////////////////////////////////////////////////// -pcl::ihs::Integration::Integration() : kd_tree_(new pcl::KdTreeFLANN()) {} +pcl::ihs::Integration::Integration() +: kd_tree_(new pcl::KdTreeFLANN()) +, max_squared_distance_(0.04f) +, // 0.2cm +max_angle_(45.f) +, min_weight_(.3f) +, max_age_(30) +, min_directions_(5) +{} //////////////////////////////////////////////////////////////////////////////// @@ -498,7 +506,7 @@ pcl::ihs::Integration::addToMesh(const PointIHS& pt_0, // 2 - 1 // | | // 3 - 0 - const auto is_finite = + const unsigned char is_finite = static_cast((1 * !std::isnan(pt_0.x)) | (2 * !std::isnan(pt_1.x)) | (4 * !std::isnan(pt_2.x)) | (8 * !std::isnan(pt_3.x))); diff --git a/apps/in_hand_scanner/src/main_window.cpp b/apps/in_hand_scanner/src/main_window.cpp index c2d62ce20de..d97e9c14bb9 100644 --- a/apps/in_hand_scanner/src/main_window.cpp +++ b/apps/in_hand_scanner/src/main_window.cpp @@ -66,14 +66,14 @@ pcl::ihs::MainWindow::MainWindow(QWidget* parent) { ui_->setupUi(this); - auto* spacer = new QWidget(); + QWidget* spacer = new QWidget(); spacer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); ui_->toolBar->insertWidget(ui_->actionHelp, spacer); constexpr double max = std::numeric_limits::max(); // In hand scanner - auto* layout = new QHBoxLayout(ui_->placeholder_in_hand_scanner); + QHBoxLayout* layout = new QHBoxLayout(ui_->placeholder_in_hand_scanner); layout->addWidget(ihs_); // ui_->centralWidget->setLayout (layout); diff --git a/apps/in_hand_scanner/src/offline_integration.cpp b/apps/in_hand_scanner/src/offline_integration.cpp index 8bd9b01853f..9de7bee7fb6 100644 --- a/apps/in_hand_scanner/src/offline_integration.cpp +++ b/apps/in_hand_scanner/src/offline_integration.cpp @@ -64,6 +64,7 @@ pcl::ihs::OfflineIntegration::OfflineIntegration(Base* parent) , mesh_model_(new Mesh()) , normal_estimation_(new NormalEstimation()) , integration_(new Integration()) +, destructor_called_(false) { normal_estimation_->setNormalEstimationMethod(NormalEstimation::AVERAGE_3D_GRADIENT); normal_estimation_->setMaxDepthChangeFactor(0.02f); // in meters diff --git a/apps/in_hand_scanner/src/opengl_viewer.cpp b/apps/in_hand_scanner/src/opengl_viewer.cpp index d9a22727ab3..2002d50276a 100644 --- a/apps/in_hand_scanner/src/opengl_viewer.cpp +++ b/apps/in_hand_scanner/src/opengl_viewer.cpp @@ -63,8 +63,9 @@ // FaceVertexMesh //////////////////////////////////////////////////////////////////////////////// +pcl::ihs::detail::FaceVertexMesh::FaceVertexMesh() : transformation(Eigen::Isometry3d::Identity()) -= default; +{} //////////////////////////////////////////////////////////////////////////////// @@ -104,9 +105,18 @@ pcl::ihs::OpenGLViewer::OpenGLViewer(QWidget* parent) : QOpenGLWidget(parent) , timer_vis_(new QTimer(this)) , colormap_(Colormap::Constant(255)) +, vis_conf_norm_(1) +, mesh_representation_(MR_POINTS) +, coloring_(COL_RGB) +, draw_box_(false) +, scaling_factor_(1.) , R_cam_(1., 0., 0., 0.) , t_cam_(0., 0., 0.) , cam_pivot_(0., 0., 0.) +, cam_pivot_id_("") +, mouse_pressed_begin_(false) +, x_prev_(0) +, y_prev_(0) { // Timer: Defines the update rate for the visualization connect(timer_vis_.get(), SIGNAL(timeout()), this, SLOT(timerCallback())); @@ -127,11 +137,11 @@ pcl::ihs::OpenGLViewer::OpenGLViewer(QWidget* parent) // colormap). ////////////////////////////////////////////////////////////////////////////// - // #include - // #include + //#include + //#include - // #include - // #include + //#include + //#include // int // main() @@ -650,7 +660,7 @@ pcl::ihs::OpenGLViewer::setVisibilityConfidenceNormalization(const float vis_con QSize pcl::ihs::OpenGLViewer::minimumSizeHint() const { - return ({160, 120}); + return (QSize(160, 120)); } //////////////////////////////////////////////////////////////////////////////// @@ -658,7 +668,7 @@ pcl::ihs::OpenGLViewer::minimumSizeHint() const QSize pcl::ihs::OpenGLViewer::sizeHint() const { - return ({640, 480}); + return (QSize(640, 480)); } //////////////////////////////////////////////////////////////////////////////// @@ -961,7 +971,7 @@ pcl::ihs::OpenGLViewer::drawMeshes() case COL_VISCONF: { for (std::size_t i = 0; i < mesh.vertices.size(); ++i) { const unsigned int n = pcl::ihs::countDirections(mesh.vertices[i].directions); - const auto index = + const unsigned int index = static_cast(static_cast(colormap_.cols()) * static_cast(n) / vis_conf_norm_); @@ -986,7 +996,7 @@ pcl::ihs::OpenGLViewer::drawMeshes() glDrawElements(GL_TRIANGLES, 3 * mesh.triangles.size(), GL_UNSIGNED_INT, - mesh.triangles.data()); + &mesh.triangles[0]); break; } } @@ -1004,7 +1014,7 @@ pcl::ihs::OpenGLViewer::drawMeshes() //////////////////////////////////////////////////////////////////////////////// void -pcl::ihs::OpenGLViewer::drawBox() const +pcl::ihs::OpenGLViewer::drawBox() { BoxCoefficients coeffs; { diff --git a/apps/include/pcl/apps/face_detection/openni_frame_source.h b/apps/include/pcl/apps/face_detection/openni_frame_source.h index b78cbea047b..1fe6f4aacfb 100644 --- a/apps/include/pcl/apps/face_detection/openni_frame_source.h +++ b/apps/include/pcl/apps/face_detection/openni_frame_source.h @@ -31,9 +31,9 @@ class PCL_EXPORTS OpenNIFrameSource { pcl::OpenNIGrabber grabber_; PointCloudPtr most_recent_frame_; - int frame_counter_{0}; + int frame_counter_; std::mutex mutex_; - bool active_{true}; + bool active_; }; } // namespace OpenNIFrameSource diff --git a/apps/include/pcl/apps/impl/dominant_plane_segmentation.hpp b/apps/include/pcl/apps/impl/dominant_plane_segmentation.hpp index 51aa9bc50c0..549f893bcff 100644 --- a/apps/include/pcl/apps/impl/dominant_plane_segmentation.hpp +++ b/apps/include/pcl/apps/impl/dominant_plane_segmentation.hpp @@ -120,6 +120,7 @@ pcl::apps::DominantPlaneSegmentation::compute_table_plane() // Compute the plane coefficients Eigen::Vector4f model_coefficients; + EIGEN_ALIGN16 Eigen::Matrix3f covariance_matrix; model_coefficients[0] = table_coefficients_->values[0]; model_coefficients[1] = table_coefficients_->values[1]; @@ -250,6 +251,7 @@ pcl::apps::DominantPlaneSegmentation::compute_fast( // Compute the plane coefficients Eigen::Vector4f model_coefficients; + EIGEN_ALIGN16 Eigen::Matrix3f covariance_matrix; model_coefficients[0] = table_coefficients_->values[0]; model_coefficients[1] = table_coefficients_->values[1]; @@ -313,8 +315,8 @@ pcl::apps::DominantPlaneSegmentation::compute_fast( { int wsize = wsize_; - for (int i = 0; i < static_cast(binary_cloud->width); i++) { - for (int j = 0; j < static_cast(binary_cloud->height); j++) { + for (int i = 0; i < int(binary_cloud->width); i++) { + for (int j = 0; j < int(binary_cloud->height); j++) { if (binary_cloud->at(i, j).intensity != 0) { // check neighboring pixels, first left and then top // be aware of margins @@ -473,8 +475,8 @@ pcl::apps::DominantPlaneSegmentation::compute_fast( { std::map::iterator it; - for (int i = 0; i < static_cast(binary_cloud->width); i++) { - for (int j = 0; j < static_cast(binary_cloud->height); j++) { + for (int i = 0; i < int(binary_cloud->width); i++) { + for (int j = 0; j < int(binary_cloud->height); j++) { if (binary_cloud->at(i, j).intensity != 0) { // check if this is a root label... it = connected_labels.find(binary_cloud->at(i, j).intensity); @@ -504,7 +506,7 @@ pcl::apps::DominantPlaneSegmentation::compute_fast( int k = 0; for (const auto& cluster : clusters_map) { - if (static_cast(cluster.second.indices.size()) >= object_cluster_min_size_) { + if (int(cluster.second.indices.size()) >= object_cluster_min_size_) { clusters[k] = CloudPtr(new Cloud()); pcl::copyPointCloud(*input_, cluster.second.indices, *clusters[k]); @@ -624,6 +626,7 @@ pcl::apps::DominantPlaneSegmentation::compute( // Compute the plane coefficients Eigen::Vector4f model_coefficients; + EIGEN_ALIGN16 Eigen::Matrix3f covariance_matrix; model_coefficients[0] = table_coefficients_->values[0]; model_coefficients[1] = table_coefficients_->values[1]; @@ -792,6 +795,7 @@ pcl::apps::DominantPlaneSegmentation::compute_full( // Compute the plane coefficients Eigen::Vector4f model_coefficients; + EIGEN_ALIGN16 Eigen::Matrix3f covariance_matrix; model_coefficients[0] = table_coefficients_->values[0]; model_coefficients[1] = table_coefficients_->values[1]; diff --git a/apps/include/pcl/apps/nn_classification.h b/apps/include/pcl/apps/nn_classification.h index db548dbd9af..d1dc06dad69 100644 --- a/apps/include/pcl/apps/nn_classification.h +++ b/apps/include/pcl/apps/nn_classification.h @@ -284,7 +284,9 @@ class NNClassification { std::make_shared, std::vector>>(); result->first.reserve(classes_.size()); result->second.reserve(classes_.size()); - for (auto it = sqr_distances->begin(); it != sqr_distances->end(); ++it) + for (std::vector::const_iterator it = sqr_distances->begin(); + it != sqr_distances->end(); + ++it) if (*it != std::numeric_limits::max()) { result->first.push_back(classes_[it - sqr_distances->begin()]); result->second.push_back(sqrt(*it)); @@ -320,7 +322,9 @@ class NNClassification { std::make_shared, std::vector>>(); result->first.reserve(classes_.size()); result->second.reserve(classes_.size()); - for (auto it = sqr_distances->begin(); it != sqr_distances->end(); ++it) + for (std::vector::const_iterator it = sqr_distances->begin(); + it != sqr_distances->end(); + ++it) if (*it != std::numeric_limits::max()) { result->first.push_back(classes_[it - sqr_distances->begin()]); // TODO leave it squared, and relate param to sigma... diff --git a/apps/include/pcl/apps/openni_passthrough.h b/apps/include/pcl/apps/openni_passthrough.h index 79ab77bde9f..94087404a8e 100644 --- a/apps/include/pcl/apps/openni_passthrough.h +++ b/apps/include/pcl/apps/openni_passthrough.h @@ -54,7 +54,7 @@ double now = pcl::getTime(); \ ++count; \ if (now - last >= 1.0) { \ - std::cout << "Average framerate(" << ((_WHAT_)) << "): " \ + std::cout << "Average framerate(" << _WHAT_ << "): " \ << double(count) / double(now - last) << " Hz" << std::endl; \ count = 0; \ last = now; \ diff --git a/apps/include/pcl/apps/organized_segmentation_demo.h b/apps/include/pcl/apps/organized_segmentation_demo.h index 5db6fa1abad..5ba08a44670 100644 --- a/apps/include/pcl/apps/organized_segmentation_demo.h +++ b/apps/include/pcl/apps/organized_segmentation_demo.h @@ -63,7 +63,7 @@ using PointT = pcl::PointXYZRGBA; double now = pcl::getTime(); \ ++count; \ if (now - last >= 1.0) { \ - std::cout << "Average framerate(" << (_WHAT_) << "): " \ + std::cout << "Average framerate(" << _WHAT_ << "): " \ << double(count) / double(now - last) << " Hz" << std::endl; \ count = 0; \ last = now; \ diff --git a/apps/include/pcl/apps/pcd_video_player.h b/apps/include/pcl/apps/pcd_video_player.h index 7d30fd9e266..b10c087079a 100644 --- a/apps/include/pcl/apps/pcd_video_player.h +++ b/apps/include/pcl/apps/pcd_video_player.h @@ -61,7 +61,7 @@ double now = pcl::getTime(); \ ++count; \ if (now - last >= 1.0) { \ - std::cout << "Average framerate(" << (_WHAT_) << "): " \ + std::cout << "Average framerate(" << _WHAT_ << "): " \ << double(count) / double(now - last) << " Hz" << std::endl; \ count = 0; \ last = now; \ diff --git a/apps/include/pcl/apps/pcl_viewer_dialog.h b/apps/include/pcl/apps/pcl_viewer_dialog.h index 5388c17b48a..0a3cff7df22 100644 --- a/apps/include/pcl/apps/pcl_viewer_dialog.h +++ b/apps/include/pcl/apps/pcl_viewer_dialog.h @@ -20,7 +20,7 @@ class PCLViewerDialog : public QDialog { pcl::visualization::PCLVisualizer::Ptr vis_; public: - PCLViewerDialog(QWidget* parent = nullptr); + PCLViewerDialog(QWidget* parent = 0); void setPointClouds(CloudT::ConstPtr src_cloud, diff --git a/apps/include/pcl/apps/timer.h b/apps/include/pcl/apps/timer.h index d312fbe7ef4..86e431f344a 100644 --- a/apps/include/pcl/apps/timer.h +++ b/apps/include/pcl/apps/timer.h @@ -51,7 +51,7 @@ double now = pcl::getTime(); \ ++count; \ if (now - last >= 1.0) { \ - std::cout << "Average framerate(" << (_WHAT_) << "): " \ + std::cout << "Average framerate(" << _WHAT_ << "): " \ << double(count) / double(now - last) << " Hz" << std::endl; \ count = 0; \ last = now; \ diff --git a/apps/include/pcl/apps/vfh_nn_classifier.h b/apps/include/pcl/apps/vfh_nn_classifier.h index eaa38ca9397..6da5036293c 100644 --- a/apps/include/pcl/apps/vfh_nn_classifier.h +++ b/apps/include/pcl/apps/vfh_nn_classifier.h @@ -41,7 +41,6 @@ #include #include #include -#include // for KdTree #include #include diff --git a/apps/modeler/CMakeLists.txt b/apps/modeler/CMakeLists.txt index f7d2bae150d..c48442c2f1c 100644 --- a/apps/modeler/CMakeLists.txt +++ b/apps/modeler/CMakeLists.txt @@ -23,6 +23,8 @@ if(NOT build) return() endif() +include_directories("${CMAKE_CURRENT_BINARY_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}/include") + # Set Qt files and resources here set(uis main_window.ui @@ -33,7 +35,7 @@ set(resources ) set(incs - "include/pcl/${SUBSYS_NAME}/${SUBSUBSYS_NAME}/main_window.h" + "include/pcl/${SUBSYS_NAME}/${SUBSUBSYS_NAME}/main_window.h" "include/pcl/${SUBSYS_NAME}/${SUBSUBSYS_NAME}/scene_tree.h" "include/pcl/${SUBSYS_NAME}/${SUBSUBSYS_NAME}/parameter_dialog.h" "include/pcl/${SUBSYS_NAME}/${SUBSUBSYS_NAME}/thread_controller.h" @@ -112,8 +114,7 @@ PCL_ADD_EXECUTABLE( ${incs} ${impl_incs}) -target_link_libraries("${EXE_NAME}" pcl_common pcl_io pcl_kdtree pcl_filters pcl_registration pcl_visualization pcl_segmentation pcl_surface pcl_features pcl_sample_consensus pcl_search ${QTX}::Widgets) -target_include_directories(${EXE_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include) +target_link_libraries("${EXE_NAME}" pcl_common pcl_io pcl_kdtree pcl_filters pcl_visualization pcl_segmentation pcl_surface pcl_features pcl_sample_consensus pcl_search ${QTX}::Widgets) # Install include files PCL_ADD_INCLUDES("${SUBSUBSYS_NAME}" "${SUBSUBSYS_NAME}" ${incs}) diff --git a/apps/modeler/include/pcl/apps/modeler/abstract_worker.h b/apps/modeler/include/pcl/apps/modeler/abstract_worker.h index 602335cf8f8..bd73202d0f0 100755 --- a/apps/modeler/include/pcl/apps/modeler/abstract_worker.h +++ b/apps/modeler/include/pcl/apps/modeler/abstract_worker.h @@ -50,7 +50,7 @@ class AbstractWorker : public QObject { public: AbstractWorker(const QList& cloud_mesh_items, QWidget* parent = nullptr); - ~AbstractWorker() override; + ~AbstractWorker(); int exec(); diff --git a/apps/modeler/include/pcl/apps/modeler/channel_actor_item.h b/apps/modeler/include/pcl/apps/modeler/channel_actor_item.h index e857883cb3c..c82f362f704 100755 --- a/apps/modeler/include/pcl/apps/modeler/channel_actor_item.h +++ b/apps/modeler/include/pcl/apps/modeler/channel_actor_item.h @@ -59,7 +59,7 @@ class ChannelActorItem : public QTreeWidgetItem, public AbstractItem { const vtkSmartPointer& render_window, const vtkSmartPointer& actor, const std::string& channel_name); - ~ChannelActorItem() override; + ~ChannelActorItem(); void init(); diff --git a/apps/modeler/include/pcl/apps/modeler/icp_registration_worker.h b/apps/modeler/include/pcl/apps/modeler/icp_registration_worker.h index e4f488f2f56..3ae287f6a7f 100755 --- a/apps/modeler/include/pcl/apps/modeler/icp_registration_worker.h +++ b/apps/modeler/include/pcl/apps/modeler/icp_registration_worker.h @@ -74,10 +74,10 @@ class ICPRegistrationWorker : public AbstractWorker { double y_min_, y_max_; double z_min_, z_max_; - DoubleParameter* max_correspondence_distance_{nullptr}; - IntParameter* max_iterations_{nullptr}; - DoubleParameter* transformation_epsilon_{nullptr}; - DoubleParameter* euclidean_fitness_epsilon_{nullptr}; + DoubleParameter* max_correspondence_distance_; + IntParameter* max_iterations_; + DoubleParameter* transformation_epsilon_; + DoubleParameter* euclidean_fitness_epsilon_; }; } // namespace modeler diff --git a/apps/modeler/include/pcl/apps/modeler/normal_estimation_worker.h b/apps/modeler/include/pcl/apps/modeler/normal_estimation_worker.h index be3b6452463..de9fa97f60c 100755 --- a/apps/modeler/include/pcl/apps/modeler/normal_estimation_worker.h +++ b/apps/modeler/include/pcl/apps/modeler/normal_estimation_worker.h @@ -47,7 +47,7 @@ class NormalEstimationWorker : public AbstractWorker { public: NormalEstimationWorker(const QList& cloud_mesh_items, QWidget* parent = nullptr); - ~NormalEstimationWorker() override; + ~NormalEstimationWorker(); protected: std::string @@ -70,7 +70,7 @@ class NormalEstimationWorker : public AbstractWorker { double y_min_, y_max_; double z_min_, z_max_; - DoubleParameter* search_radius_{nullptr}; + DoubleParameter* search_radius_; }; } // namespace modeler diff --git a/apps/modeler/include/pcl/apps/modeler/normals_actor_item.h b/apps/modeler/include/pcl/apps/modeler/normals_actor_item.h index b5968892105..e974a9d6cad 100755 --- a/apps/modeler/include/pcl/apps/modeler/normals_actor_item.h +++ b/apps/modeler/include/pcl/apps/modeler/normals_actor_item.h @@ -76,8 +76,8 @@ class NormalsActorItem : public ChannelActorItem { setProperties() override; private: - double level_{10}; - double scale_{0.1}; + double level_; + double scale_; }; } // namespace modeler diff --git a/apps/modeler/include/pcl/apps/modeler/parameter_dialog.h b/apps/modeler/include/pcl/apps/modeler/parameter_dialog.h index 26edc33e94b..6ebb15549e3 100755 --- a/apps/modeler/include/pcl/apps/modeler/parameter_dialog.h +++ b/apps/modeler/include/pcl/apps/modeler/parameter_dialog.h @@ -73,7 +73,7 @@ class ParameterDialog : public QDialog { protected: std::map name_parameter_map_; - ParameterModel* parameter_model_{nullptr}; + ParameterModel* parameter_model_; protected Q_SLOTS: void diff --git a/apps/modeler/include/pcl/apps/modeler/poisson_worker.h b/apps/modeler/include/pcl/apps/modeler/poisson_worker.h index baf46d833bb..d48d1b9610a 100755 --- a/apps/modeler/include/pcl/apps/modeler/poisson_worker.h +++ b/apps/modeler/include/pcl/apps/modeler/poisson_worker.h @@ -48,7 +48,7 @@ class PoissonReconstructionWorker : public AbstractWorker { public: PoissonReconstructionWorker(const QList& cloud_mesh_items, QWidget* parent = nullptr); - ~PoissonReconstructionWorker() override; + ~PoissonReconstructionWorker(); protected: std::string @@ -68,12 +68,12 @@ class PoissonReconstructionWorker : public AbstractWorker { processImpl(CloudMeshItem* cloud_mesh_item) override; private: - IntParameter* depth_{nullptr}; - IntParameter* solver_divide_{nullptr}; - IntParameter* iso_divide_{nullptr}; - IntParameter* degree_{nullptr}; - DoubleParameter* scale_{nullptr}; - DoubleParameter* samples_per_node_{nullptr}; + IntParameter* depth_; + IntParameter* solver_divide_; + IntParameter* iso_divide_; + IntParameter* degree_; + DoubleParameter* scale_; + DoubleParameter* samples_per_node_; }; } // namespace modeler diff --git a/apps/modeler/include/pcl/apps/modeler/render_window_item.h b/apps/modeler/include/pcl/apps/modeler/render_window_item.h index 35463a6a60a..bafdaa66177 100755 --- a/apps/modeler/include/pcl/apps/modeler/render_window_item.h +++ b/apps/modeler/include/pcl/apps/modeler/render_window_item.h @@ -52,7 +52,7 @@ class BoolParameter; class RenderWindowItem : public QTreeWidgetItem, public AbstractItem { public: RenderWindowItem(QTreeWidget* parent); - ~RenderWindowItem() override; + ~RenderWindowItem(); inline RenderWindow* getRenderWindow() diff --git a/apps/modeler/include/pcl/apps/modeler/statistical_outlier_removal_worker.h b/apps/modeler/include/pcl/apps/modeler/statistical_outlier_removal_worker.h index d45c22781da..56d272033b7 100755 --- a/apps/modeler/include/pcl/apps/modeler/statistical_outlier_removal_worker.h +++ b/apps/modeler/include/pcl/apps/modeler/statistical_outlier_removal_worker.h @@ -48,7 +48,7 @@ class StatisticalOutlierRemovalWorker : public AbstractWorker { public: StatisticalOutlierRemovalWorker(const QList& cloud_mesh_items, QWidget* parent = nullptr); - ~StatisticalOutlierRemovalWorker() override; + ~StatisticalOutlierRemovalWorker(); protected: std::string @@ -67,8 +67,8 @@ class StatisticalOutlierRemovalWorker : public AbstractWorker { processImpl(CloudMeshItem* cloud_mesh_item) override; private: - IntParameter* mean_k_{nullptr}; - DoubleParameter* stddev_mul_thresh_{nullptr}; + IntParameter* mean_k_; + DoubleParameter* stddev_mul_thresh_; }; } // namespace modeler diff --git a/apps/modeler/include/pcl/apps/modeler/thread_controller.h b/apps/modeler/include/pcl/apps/modeler/thread_controller.h index efbcae6b2d4..df98cbe36f4 100755 --- a/apps/modeler/include/pcl/apps/modeler/thread_controller.h +++ b/apps/modeler/include/pcl/apps/modeler/thread_controller.h @@ -49,7 +49,7 @@ class ThreadController : public QObject { public: ThreadController(); - ~ThreadController() override; + ~ThreadController(); bool runWorker(AbstractWorker* worker); diff --git a/apps/modeler/include/pcl/apps/modeler/voxel_grid_downsample_worker.h b/apps/modeler/include/pcl/apps/modeler/voxel_grid_downsample_worker.h index f0a9310b5f9..c68cbb13e56 100755 --- a/apps/modeler/include/pcl/apps/modeler/voxel_grid_downsample_worker.h +++ b/apps/modeler/include/pcl/apps/modeler/voxel_grid_downsample_worker.h @@ -47,7 +47,7 @@ class VoxelGridDownampleWorker : public AbstractWorker { public: VoxelGridDownampleWorker(const QList& cloud_mesh_items, QWidget* parent = nullptr); - ~VoxelGridDownampleWorker() override; + ~VoxelGridDownampleWorker(); protected: std::string @@ -70,9 +70,9 @@ class VoxelGridDownampleWorker : public AbstractWorker { double y_min_, y_max_; double z_min_, z_max_; - DoubleParameter* leaf_size_x_{nullptr}; - DoubleParameter* leaf_size_y_{nullptr}; - DoubleParameter* leaf_size_z_{nullptr}; + DoubleParameter* leaf_size_x_; + DoubleParameter* leaf_size_y_; + DoubleParameter* leaf_size_z_; }; } // namespace modeler diff --git a/apps/modeler/src/abstract_item.cpp b/apps/modeler/src/abstract_item.cpp index 1837725d86e..e3d337f4515 100755 --- a/apps/modeler/src/abstract_item.cpp +++ b/apps/modeler/src/abstract_item.cpp @@ -39,7 +39,7 @@ #include ////////////////////////////////////////////////////////////////////////////////////////////// -pcl::modeler::AbstractItem::AbstractItem() = default; +pcl::modeler::AbstractItem::AbstractItem() {} ////////////////////////////////////////////////////////////////////////////////////////////// void diff --git a/apps/modeler/src/cloud_mesh.cpp b/apps/modeler/src/cloud_mesh.cpp index 215c09952af..5d350b8047a 100755 --- a/apps/modeler/src/cloud_mesh.cpp +++ b/apps/modeler/src/cloud_mesh.cpp @@ -155,7 +155,7 @@ pcl::modeler::CloudMesh::updateVtkPoints() if (vtk_points_->GetData() == nullptr) vtk_points_->SetData(vtkSmartPointer::New()); - auto* data = dynamic_cast(vtk_points_->GetData()); + vtkFloatArray* data = dynamic_cast(vtk_points_->GetData()); data->SetNumberOfComponents(3); // If the dataset has no invalid values, just copy all of them @@ -225,12 +225,8 @@ pcl::modeler::CloudMesh::transform( rx *= M_PI / 180; ry *= M_PI / 180; rz *= M_PI / 180; - Eigen::Affine3f affine_transform = pcl::getTransformation(static_cast(tx), - static_cast(ty), - static_cast(tz), - static_cast(rx), - static_cast(ry), - static_cast(rz)); + Eigen::Affine3f affine_transform = pcl::getTransformation( + float(tx), float(ty), float(tz), float(rx), float(ry), float(rz)); CloudMesh::PointCloud transform_cloud = mean_cloud; pcl::transformPointCloudWithNormals( mean_cloud, transform_cloud, affine_transform.matrix()); diff --git a/apps/modeler/src/cloud_mesh_item.cpp b/apps/modeler/src/cloud_mesh_item.cpp index a3802bad375..1ac45a5b322 100755 --- a/apps/modeler/src/cloud_mesh_item.cpp +++ b/apps/modeler/src/cloud_mesh_item.cpp @@ -152,7 +152,7 @@ pcl::modeler::CloudMeshItem::prepareContextMenu(QMenu* menu) const void pcl::modeler::CloudMeshItem::createChannels() { - auto* render_window_item = dynamic_cast(parent()); + RenderWindowItem* render_window_item = dynamic_cast(parent()); vtkRenderWindow* win = getRenderWindowCompat(*(render_window_item->getRenderWindow())); @@ -161,7 +161,7 @@ pcl::modeler::CloudMeshItem::createChannels() addChild(new SurfaceActorItem(this, cloud_mesh_, win)); for (int i = 0, i_end = childCount(); i < i_end; ++i) { - auto* child_item = dynamic_cast(child(i)); + ChannelActorItem* child_item = dynamic_cast(child(i)); child_item->init(); } @@ -177,11 +177,11 @@ pcl::modeler::CloudMeshItem::updateChannels() cloud_mesh_->updateVtkPolygons(); for (int i = 0, i_end = childCount(); i < i_end; ++i) { - auto* child_item = dynamic_cast(child(i)); + ChannelActorItem* child_item = dynamic_cast(child(i)); child_item->update(); } - auto* render_window_item = dynamic_cast(parent()); + RenderWindowItem* render_window_item = dynamic_cast(parent()); render_window_item->getRenderWindow()->updateAxes(); } @@ -236,9 +236,9 @@ pcl::modeler::CloudMeshItem::setProperties() void pcl::modeler::CloudMeshItem::updateRenderWindow() { - auto* render_window_item = dynamic_cast(parent()); + RenderWindowItem* render_window_item = dynamic_cast(parent()); for (int i = 0, i_end = childCount(); i < i_end; ++i) { - auto* child_item = dynamic_cast(child(i)); + ChannelActorItem* child_item = dynamic_cast(child(i)); child_item->switchRenderWindow( getRenderWindowCompat(*render_window_item->getRenderWindow())); } diff --git a/apps/modeler/src/icp_registration_worker.cpp b/apps/modeler/src/icp_registration_worker.cpp index 7f353ae1a20..2210d18cda3 100755 --- a/apps/modeler/src/icp_registration_worker.cpp +++ b/apps/modeler/src/icp_registration_worker.cpp @@ -55,6 +55,10 @@ pcl::modeler::ICPRegistrationWorker::ICPRegistrationWorker( , y_max_(std::numeric_limits::min()) , z_min_(std::numeric_limits::max()) , z_max_(std::numeric_limits::min()) +, max_correspondence_distance_(nullptr) +, max_iterations_(nullptr) +, transformation_epsilon_(nullptr) +, euclidean_fitness_epsilon_(nullptr) {} ////////////////////////////////////////////////////////////////////////////////////////////// @@ -66,14 +70,14 @@ pcl::modeler::ICPRegistrationWorker::initParameters(CloudMeshItem* cloud_mesh_it Eigen::Vector4f min_pt, max_pt; pcl::getMinMax3D(*(cloud_mesh_item->getCloudMesh()->getCloud()), min_pt, max_pt); - x_min_ = std::min(static_cast(min_pt.x()), x_min_); - x_max_ = std::max(static_cast(max_pt.x()), x_max_); + x_min_ = std::min(double(min_pt.x()), x_min_); + x_max_ = std::max(double(max_pt.x()), x_max_); - y_min_ = std::min(static_cast(min_pt.y()), y_min_); - y_max_ = std::max(static_cast(max_pt.y()), y_max_); + y_min_ = std::min(double(min_pt.y()), y_min_); + y_max_ = std::max(double(max_pt.y()), y_max_); - z_min_ = std::min(static_cast(min_pt.z()), z_min_); - z_max_ = std::max(static_cast(max_pt.z()), z_max_); + z_min_ = std::min(double(min_pt.z()), z_min_); + z_max_ = std::max(double(max_pt.z()), z_max_); } ////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/apps/modeler/src/main_window.cpp b/apps/modeler/src/main_window.cpp index fc58ca8a2ba..85381af7313 100755 --- a/apps/modeler/src/main_window.cpp +++ b/apps/modeler/src/main_window.cpp @@ -282,8 +282,7 @@ pcl::modeler::MainWindow::updateRecentActions( } recent_items.removeDuplicates(); - int recent_number = - std::min(static_cast(MAX_RECENT_NUMBER), recent_items.size()); + int recent_number = std::min(int(MAX_RECENT_NUMBER), recent_items.size()); for (int i = 0; i < recent_number; ++i) { QString text = tr("%1 %2").arg(i + 1).arg(recent_items[i]); recent_actions[i]->setText(text); diff --git a/apps/modeler/src/normal_estimation_worker.cpp b/apps/modeler/src/normal_estimation_worker.cpp index 88611909e72..468d7362fea 100755 --- a/apps/modeler/src/normal_estimation_worker.cpp +++ b/apps/modeler/src/normal_estimation_worker.cpp @@ -43,7 +43,6 @@ #include #include #include -#include // for KdTree ////////////////////////////////////////////////////////////////////////////////////////////// pcl::modeler::NormalEstimationWorker::NormalEstimationWorker( @@ -55,6 +54,7 @@ pcl::modeler::NormalEstimationWorker::NormalEstimationWorker( , y_max_(std::numeric_limits::min()) , z_min_(std::numeric_limits::max()) , z_max_(std::numeric_limits::min()) +, search_radius_(nullptr) {} ////////////////////////////////////////////////////////////////////////////////////////////// @@ -70,14 +70,14 @@ pcl::modeler::NormalEstimationWorker::initParameters(CloudMeshItem* cloud_mesh_i Eigen::Vector4f min_pt, max_pt; pcl::getMinMax3D(*(cloud_mesh_item->getCloudMesh()->getCloud()), min_pt, max_pt); - x_min_ = std::min(static_cast(min_pt.x()), x_min_); - x_max_ = std::max(static_cast(max_pt.x()), x_max_); + x_min_ = std::min(double(min_pt.x()), x_min_); + x_max_ = std::max(double(max_pt.x()), x_max_); - y_min_ = std::min(static_cast(min_pt.y()), y_min_); - y_max_ = std::max(static_cast(max_pt.y()), y_max_); + y_min_ = std::min(double(min_pt.y()), y_min_); + y_max_ = std::max(double(max_pt.y()), y_max_); - z_min_ = std::min(static_cast(min_pt.z()), z_min_); - z_max_ = std::max(static_cast(max_pt.z()), z_max_); + z_min_ = std::min(double(min_pt.z()), z_min_); + z_max_ = std::max(double(max_pt.z()), z_max_); } ////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/apps/modeler/src/normals_actor_item.cpp b/apps/modeler/src/normals_actor_item.cpp index 08d97025d13..a594127dfc2 100644 --- a/apps/modeler/src/normals_actor_item.cpp +++ b/apps/modeler/src/normals_actor_item.cpp @@ -51,6 +51,8 @@ pcl::modeler::NormalsActorItem::NormalsActorItem( const vtkSmartPointer& render_window) : ChannelActorItem( parent, cloud_mesh, render_window, vtkSmartPointer::New(), "Normals") +, level_(10) +, scale_(0.1) {} ////////////////////////////////////////////////////////////////////////////////////////////// @@ -68,11 +70,11 @@ pcl::modeler::NormalsActorItem::createNormalLines() if (points->GetData() == nullptr) points->SetData(vtkSmartPointer::New()); - auto* data = dynamic_cast(points->GetData()); + vtkFloatArray* data = dynamic_cast(points->GetData()); data->SetNumberOfComponents(3); if (cloud->is_dense) { - auto nr_normals = static_cast((cloud->size() - 1) / level_ + 1); + vtkIdType nr_normals = static_cast((cloud->size() - 1) / level_ + 1); data->SetNumberOfValues(2 * 3 * nr_normals); for (vtkIdType i = 0, j = 0; j < nr_normals; j++, i = static_cast(j * level_)) { @@ -80,9 +82,9 @@ pcl::modeler::NormalsActorItem::createNormalLines() data->SetValue(2 * j * 3 + 0, p.x); data->SetValue(2 * j * 3 + 1, p.y); data->SetValue(2 * j * 3 + 2, p.z); - data->SetValue(2 * j * 3 + 3, static_cast(p.x + p.normal_x * scale_)); - data->SetValue(2 * j * 3 + 4, static_cast(p.y + p.normal_y * scale_)); - data->SetValue(2 * j * 3 + 5, static_cast(p.z + p.normal_z * scale_)); + data->SetValue(2 * j * 3 + 3, float(p.x + p.normal_x * scale_)); + data->SetValue(2 * j * 3 + 4, float(p.y + p.normal_y * scale_)); + data->SetValue(2 * j * 3 + 5, float(p.z + p.normal_z * scale_)); lines->InsertNextCell(2); lines->InsertCellPoint(2 * j); @@ -93,7 +95,7 @@ pcl::modeler::NormalsActorItem::createNormalLines() pcl::IndicesPtr indices(new pcl::Indices()); pcl::removeNaNFromPointCloud(*cloud, *indices); - auto nr_normals = static_cast((indices->size() - 1) / level_ + 1); + vtkIdType nr_normals = static_cast((indices->size() - 1) / level_ + 1); data->SetNumberOfValues(2 * 3 * nr_normals); for (vtkIdType i = 0, j = 0; j < nr_normals; j++, i = static_cast(j * level_)) { @@ -101,9 +103,9 @@ pcl::modeler::NormalsActorItem::createNormalLines() data->SetValue(2 * j * 3 + 0, p.x); data->SetValue(2 * j * 3 + 1, p.y); data->SetValue(2 * j * 3 + 2, p.z); - data->SetValue(2 * j * 3 + 3, static_cast(p.x + p.normal_x * scale_)); - data->SetValue(2 * j * 3 + 4, static_cast(p.y + p.normal_y * scale_)); - data->SetValue(2 * j * 3 + 5, static_cast(p.z + p.normal_z * scale_)); + data->SetValue(2 * j * 3 + 3, float(p.x + p.normal_x * scale_)); + data->SetValue(2 * j * 3 + 4, float(p.y + p.normal_y * scale_)); + data->SetValue(2 * j * 3 + 5, float(p.z + p.normal_z * scale_)); lines->InsertNextCell(2); lines->InsertCellPoint(2 * j); diff --git a/apps/modeler/src/parameter.cpp b/apps/modeler/src/parameter.cpp index 033fe2575c8..c7117d6d570 100755 --- a/apps/modeler/src/parameter.cpp +++ b/apps/modeler/src/parameter.cpp @@ -67,7 +67,7 @@ pcl::modeler::IntParameter::valueTip() QWidget* pcl::modeler::IntParameter::createEditor(QWidget* parent) { - auto* editor = new QSpinBox(parent); + QSpinBox* editor = new QSpinBox(parent); editor->setMinimum(low_); editor->setMaximum(high_); editor->setSingleStep(step_); @@ -79,7 +79,7 @@ pcl::modeler::IntParameter::createEditor(QWidget* parent) void pcl::modeler::IntParameter::setEditorData(QWidget* editor) { - auto* spinBox = dynamic_cast(editor); + QSpinBox* spinBox = static_cast(editor); spinBox->setAlignment(Qt::AlignHCenter); int value = int(*this); @@ -90,7 +90,7 @@ pcl::modeler::IntParameter::setEditorData(QWidget* editor) void pcl::modeler::IntParameter::getEditorData(QWidget* editor) { - auto* spinBox = dynamic_cast(editor); + QSpinBox* spinBox = static_cast(editor); int value = spinBox->text().toInt(); current_value_ = value; } @@ -116,7 +116,7 @@ pcl::modeler::BoolParameter::valueTip() QWidget* pcl::modeler::BoolParameter::createEditor(QWidget* parent) { - auto* editor = new QCheckBox(parent); + QCheckBox* editor = new QCheckBox(parent); return editor; } @@ -125,7 +125,7 @@ pcl::modeler::BoolParameter::createEditor(QWidget* parent) void pcl::modeler::BoolParameter::setEditorData(QWidget* editor) { - auto* checkBox = dynamic_cast(editor); + QCheckBox* checkBox = static_cast(editor); bool value = bool(*this); checkBox->setCheckState(value ? (Qt::Checked) : (Qt::Unchecked)); @@ -135,7 +135,7 @@ pcl::modeler::BoolParameter::setEditorData(QWidget* editor) void pcl::modeler::BoolParameter::getEditorData(QWidget* editor) { - auto* checkBox = dynamic_cast(editor); + QCheckBox* checkBox = static_cast(editor); bool value = (checkBox->checkState() == Qt::Checked); current_value_ = value; } @@ -161,7 +161,7 @@ pcl::modeler::DoubleParameter::valueTip() QWidget* pcl::modeler::DoubleParameter::createEditor(QWidget* parent) { - auto* editor = new QDoubleSpinBox(parent); + QDoubleSpinBox* editor = new QDoubleSpinBox(parent); editor->setMinimum(low_); editor->setMaximum(high_); editor->setSingleStep(step_); @@ -174,7 +174,7 @@ pcl::modeler::DoubleParameter::createEditor(QWidget* parent) void pcl::modeler::DoubleParameter::setEditorData(QWidget* editor) { - auto* spinBox = dynamic_cast(editor); + QDoubleSpinBox* spinBox = static_cast(editor); spinBox->setAlignment(Qt::AlignHCenter); double value = double(*this); @@ -185,7 +185,7 @@ pcl::modeler::DoubleParameter::setEditorData(QWidget* editor) void pcl::modeler::DoubleParameter::getEditorData(QWidget* editor) { - auto* spinBox = dynamic_cast(editor); + QDoubleSpinBox* spinBox = static_cast(editor); double value = spinBox->text().toDouble(); current_value_ = value; } @@ -211,7 +211,7 @@ pcl::modeler::ColorParameter::valueTip() QWidget* pcl::modeler::ColorParameter::createEditor(QWidget* parent) { - auto* editor = new QColorDialog(parent); + QColorDialog* editor = new QColorDialog(parent); return editor; } @@ -220,7 +220,7 @@ pcl::modeler::ColorParameter::createEditor(QWidget* parent) void pcl::modeler::ColorParameter::setEditorData(QWidget* editor) { - auto* color_dialog = dynamic_cast(editor); + QColorDialog* color_dialog = static_cast(editor); QColor value = QColor(*this); color_dialog->setCurrentColor(value); @@ -230,7 +230,7 @@ pcl::modeler::ColorParameter::setEditorData(QWidget* editor) void pcl::modeler::ColorParameter::getEditorData(QWidget* editor) { - auto* color_dialog = dynamic_cast(editor); + QColorDialog* color_dialog = static_cast(editor); QColor value = color_dialog->currentColor(); current_value_ = value; diff --git a/apps/modeler/src/parameter_dialog.cpp b/apps/modeler/src/parameter_dialog.cpp old mode 100644 new mode 100755 index 73a930bc555..dfa6c2156c5 --- a/apps/modeler/src/parameter_dialog.cpp +++ b/apps/modeler/src/parameter_dialog.cpp @@ -62,7 +62,7 @@ pcl::modeler::ParameterDialog::addParameter(pcl::modeler::Parameter* parameter) ////////////////////////////////////////////////////////////////////////////////////////////// pcl::modeler::ParameterDialog::ParameterDialog(const std::string& title, QWidget* parent) -: QDialog(parent) +: QDialog(parent), parameter_model_(nullptr) { setModal(false); setWindowTitle(QString(title.c_str()) + " Parameters"); @@ -72,8 +72,7 @@ pcl::modeler::ParameterDialog::ParameterDialog(const std::string& title, int pcl::modeler::ParameterDialog::exec() { - pcl::modeler::ParameterModel parameterModel( - static_cast(name_parameter_map_.size()), 2, this); + pcl::modeler::ParameterModel parameterModel(int(name_parameter_map_.size()), 2, this); parameter_model_ = ¶meterModel; QStringList headerLabels; @@ -86,12 +85,10 @@ pcl::modeler::ParameterDialog::exec() std::size_t currentRow = 0; for (const auto& name_parameter : name_parameter_map_) { - QModelIndex name = - parameterModel.index(static_cast(currentRow), 0, QModelIndex()); + QModelIndex name = parameterModel.index(int(currentRow), 0, QModelIndex()); parameterModel.setData(name, QVariant(name_parameter.first.c_str())); - QModelIndex value = - parameterModel.index(static_cast(currentRow), 1, QModelIndex()); + QModelIndex value = parameterModel.index(int(currentRow), 1, QModelIndex()); std::pair model_data = name_parameter.second->toModelData(); parameterModel.setData(value, model_data.first, model_data.second); @@ -112,9 +109,9 @@ pcl::modeler::ParameterDialog::exec() tableView.columnWidth(0) + tableView.columnWidth(1) + frameSize().width(); setMinimumWidth(totlen); - auto* pushButtonReset = new QPushButton("Reset", this); - auto* pushButtonApply = new QPushButton("Apply", this); - auto* pushButtonCancel = new QPushButton("Cancel", this); + QPushButton* pushButtonReset = new QPushButton("Reset", this); + QPushButton* pushButtonApply = new QPushButton("Apply", this); + QPushButton* pushButtonCancel = new QPushButton("Cancel", this); connect(pushButtonReset, SIGNAL(clicked()), this, SLOT(reset())); connect(pushButtonApply, SIGNAL(clicked()), this, SLOT(accept())); @@ -140,8 +137,7 @@ pcl::modeler::ParameterDialog::reset() for (auto& name_parameter : name_parameter_map_) { name_parameter.second->reset(); - QModelIndex value = - parameter_model_->index(static_cast(currentRow), 1, QModelIndex()); + QModelIndex value = parameter_model_->index(int(currentRow), 1, QModelIndex()); std::pair model_data = name_parameter.second->toModelData(); parameter_model_->setData(value, model_data.first, model_data.second); @@ -153,10 +149,10 @@ pcl::modeler::ParameterDialog::reset() pcl::modeler::Parameter* pcl::modeler::ParameterDelegate::getCurrentParameter(const QModelIndex& index) const { - auto currentParameter = parameter_map_.begin(); + std::map::iterator currentParameter = parameter_map_.begin(); std::size_t currentRow = 0; - while (currentRow < static_cast(index.row()) && + while (currentRow < (std::size_t)index.row() && currentParameter != parameter_map_.end()) { ++currentParameter; ++currentRow; diff --git a/apps/modeler/src/points_actor_item.cpp b/apps/modeler/src/points_actor_item.cpp index 141dd6ec08e..96711887ba4 100755 --- a/apps/modeler/src/points_actor_item.cpp +++ b/apps/modeler/src/points_actor_item.cpp @@ -83,7 +83,7 @@ pcl::modeler::PointsActorItem::initImpl() actor->SetMapper(mapper); actor->SetNumberOfCloudPoints( - static_cast(std::max(1, poly_data_->GetNumberOfPoints() / 10))); + int(std::max(1, poly_data_->GetNumberOfPoints() / 10))); actor->GetProperty()->SetInterpolationToFlat(); } diff --git a/apps/modeler/src/poisson_worker.cpp b/apps/modeler/src/poisson_worker.cpp index 7b434fbcc90..49b2e750497 100755 --- a/apps/modeler/src/poisson_worker.cpp +++ b/apps/modeler/src/poisson_worker.cpp @@ -46,6 +46,12 @@ pcl::modeler::PoissonReconstructionWorker::PoissonReconstructionWorker( const QList& cloud_mesh_items, QWidget* parent) : AbstractWorker(cloud_mesh_items, parent) +, depth_(nullptr) +, solver_divide_(nullptr) +, iso_divide_(nullptr) +, degree_(nullptr) +, scale_(nullptr) +, samples_per_node_(nullptr) {} ////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/apps/modeler/src/render_window.cpp b/apps/modeler/src/render_window.cpp index 888a113081f..b63629b6ba1 100755 --- a/apps/modeler/src/render_window.cpp +++ b/apps/modeler/src/render_window.cpp @@ -65,7 +65,7 @@ pcl::modeler::RenderWindow::RenderWindow(RenderWindowItem* render_window_item, ////////////////////////////////////////////////////////////////////////////////////////////// pcl::modeler::RenderWindow::~RenderWindow() { - auto* dock_widget = dynamic_cast(parent()); + DockWidget* dock_widget = dynamic_cast(parent()); if (dock_widget != nullptr) { MainWindow::getInstance().removeDockWidget(dock_widget); dock_widget->deleteLater(); @@ -112,7 +112,7 @@ pcl::modeler::RenderWindow::focusInEvent(QFocusEvent* event) void pcl::modeler::RenderWindow::setActive(bool flag) { - auto* dock_widget = dynamic_cast(parent()); + DockWidget* dock_widget = dynamic_cast(parent()); if (dock_widget != nullptr) dock_widget->setFocusBasedStyle(flag); } @@ -121,7 +121,7 @@ pcl::modeler::RenderWindow::setActive(bool flag) void pcl::modeler::RenderWindow::setTitle(const QString& title) { - auto* dock_widget = dynamic_cast(parent()); + DockWidget* dock_widget = dynamic_cast(parent()); if (dock_widget != nullptr) dock_widget->setWindowTitle(title); } diff --git a/apps/modeler/src/render_window_item.cpp b/apps/modeler/src/render_window_item.cpp index 70f8fc3c1b8..0b24410b341 100755 --- a/apps/modeler/src/render_window_item.cpp +++ b/apps/modeler/src/render_window_item.cpp @@ -59,7 +59,7 @@ pcl::modeler::RenderWindowItem::~RenderWindowItem() { render_window_->deleteLate bool pcl::modeler::RenderWindowItem::openPointCloud(const QString& filename) { - auto* cloud_mesh_item = new CloudMeshItem(this, filename.toStdString()); + CloudMeshItem* cloud_mesh_item = new CloudMeshItem(this, filename.toStdString()); addChild(cloud_mesh_item); if (!cloud_mesh_item->open()) { @@ -77,7 +77,7 @@ pcl::modeler::RenderWindowItem::openPointCloud(const QString& filename) pcl::modeler::CloudMeshItem* pcl::modeler::RenderWindowItem::addPointCloud(CloudMesh::PointCloudPtr cloud) { - auto* cloud_mesh_item = new CloudMeshItem(this, std::move(cloud)); + CloudMeshItem* cloud_mesh_item = new CloudMeshItem(this, std::move(cloud)); addChild(cloud_mesh_item); treeWidget()->setCurrentItem(cloud_mesh_item); diff --git a/apps/modeler/src/scene_tree.cpp b/apps/modeler/src/scene_tree.cpp index b5aebfbb7d4..69919d50418 100755 --- a/apps/modeler/src/scene_tree.cpp +++ b/apps/modeler/src/scene_tree.cpp @@ -103,7 +103,7 @@ pcl::modeler::SceneTree::selectedRenderWindowItems() const void pcl::modeler::SceneTree::contextMenuEvent(QContextMenuEvent* event) { - auto* item = dynamic_cast(currentItem()); + AbstractItem* item = dynamic_cast(currentItem()); item->showContextMenu(&(event->globalPos())); } @@ -111,7 +111,7 @@ pcl::modeler::SceneTree::contextMenuEvent(QContextMenuEvent* event) void pcl::modeler::SceneTree::slotOnItemDoubleClicked(QTreeWidgetItem* item) { - auto* abstract_item = dynamic_cast(item); + AbstractItem* abstract_item = dynamic_cast(item); abstract_item->showPropertyEditor(); } @@ -285,7 +285,7 @@ pcl::modeler::SceneTree::slotICPRegistration() AbstractWorker* worker = new ICPRegistrationWorker( result, selected_cloud_mesh_items, &MainWindow::getInstance()); - auto* thread_controller = new ThreadController(); + ThreadController* thread_controller = new ThreadController(); QList selected_render_window_items = selectedRenderWindowItems(); for (auto& selected_render_window_item : selected_render_window_items) { @@ -307,7 +307,7 @@ pcl::modeler::SceneTree::slotVoxelGridDownsampleFilter() QList selected_cloud_mesh_items = selectedTypeItems(); AbstractWorker* worker = new VoxelGridDownampleWorker(selected_cloud_mesh_items, &MainWindow::getInstance()); - auto* thread_controller = new ThreadController(); + ThreadController* thread_controller = new ThreadController(); connect(worker, SIGNAL(dataUpdated(CloudMeshItem*)), thread_controller, @@ -322,7 +322,7 @@ pcl::modeler::SceneTree::slotStatisticalOutlierRemovalFilter() QList selected_cloud_mesh_items = selectedTypeItems(); AbstractWorker* worker = new StatisticalOutlierRemovalWorker( selected_cloud_mesh_items, &MainWindow::getInstance()); - auto* thread_controller = new ThreadController(); + ThreadController* thread_controller = new ThreadController(); connect(worker, SIGNAL(dataUpdated(CloudMeshItem*)), thread_controller, @@ -337,7 +337,7 @@ pcl::modeler::SceneTree::slotEstimateNormal() QList selected_cloud_mesh_items = selectedTypeItems(); AbstractWorker* worker = new NormalEstimationWorker(selected_cloud_mesh_items, &MainWindow::getInstance()); - auto* thread_controller = new ThreadController(); + ThreadController* thread_controller = new ThreadController(); connect(worker, SIGNAL(dataUpdated(CloudMeshItem*)), thread_controller, @@ -352,7 +352,7 @@ pcl::modeler::SceneTree::slotPoissonReconstruction() QList selected_cloud_mesh_items = selectedTypeItems(); AbstractWorker* worker = new PoissonReconstructionWorker(selected_cloud_mesh_items, &MainWindow::getInstance()); - auto* thread_controller = new ThreadController(); + ThreadController* thread_controller = new ThreadController(); connect(worker, SIGNAL(dataUpdated(CloudMeshItem*)), thread_controller, @@ -398,7 +398,8 @@ void pcl::modeler::SceneTree::slotUpdateOnInsertOrRemove() { for (int i = 0, i_end = topLevelItemCount(); i < i_end; ++i) { - auto* render_window_item = dynamic_cast(topLevelItem(i)); + RenderWindowItem* render_window_item = + dynamic_cast(topLevelItem(i)); if (render_window_item == nullptr) continue; diff --git a/apps/modeler/src/statistical_outlier_removal_worker.cpp b/apps/modeler/src/statistical_outlier_removal_worker.cpp index 8839edba121..2d8272427f3 100755 --- a/apps/modeler/src/statistical_outlier_removal_worker.cpp +++ b/apps/modeler/src/statistical_outlier_removal_worker.cpp @@ -45,6 +45,8 @@ pcl::modeler::StatisticalOutlierRemovalWorker::StatisticalOutlierRemovalWorker( const QList& cloud_mesh_items, QWidget* parent) : AbstractWorker(cloud_mesh_items, parent) +, mean_k_(nullptr) +, stddev_mul_thresh_(nullptr) {} ////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/apps/modeler/src/surface_actor_item.cpp b/apps/modeler/src/surface_actor_item.cpp index 0c4442b5a3a..aa5aa233587 100755 --- a/apps/modeler/src/surface_actor_item.cpp +++ b/apps/modeler/src/surface_actor_item.cpp @@ -80,7 +80,7 @@ pcl::modeler::SurfaceActorItem::initImpl() actor->SetMapper(mapper); actor->SetNumberOfCloudPoints( - static_cast(std::max(1, poly_data_->GetNumberOfPoints() / 10))); + int(std::max(1, poly_data_->GetNumberOfPoints() / 10))); actor->GetProperty()->SetInterpolationToFlat(); actor->GetProperty()->SetRepresentationToSurface(); diff --git a/apps/modeler/src/thread_controller.cpp b/apps/modeler/src/thread_controller.cpp index 88cfbc44054..9d391b2df59 100755 --- a/apps/modeler/src/thread_controller.cpp +++ b/apps/modeler/src/thread_controller.cpp @@ -43,7 +43,7 @@ #include ////////////////////////////////////////////////////////////////////////////////////////////// -pcl::modeler::ThreadController::ThreadController() = default; +pcl::modeler::ThreadController::ThreadController() {} ////////////////////////////////////////////////////////////////////////////////////////////// pcl::modeler::ThreadController::~ThreadController() @@ -62,7 +62,7 @@ pcl::modeler::ThreadController::runWorker(AbstractWorker* worker) return false; } - auto* thread = new QThread; + QThread* thread = new QThread; connect(this, SIGNAL(prepared()), worker, SLOT(process())); diff --git a/apps/modeler/src/voxel_grid_downsample_worker.cpp b/apps/modeler/src/voxel_grid_downsample_worker.cpp index 7faf8597570..cf3ea73fb2a 100755 --- a/apps/modeler/src/voxel_grid_downsample_worker.cpp +++ b/apps/modeler/src/voxel_grid_downsample_worker.cpp @@ -52,6 +52,9 @@ pcl::modeler::VoxelGridDownampleWorker::VoxelGridDownampleWorker( , y_max_(std::numeric_limits::min()) , z_min_(std::numeric_limits::max()) , z_max_(std::numeric_limits::min()) +, leaf_size_x_(nullptr) +, leaf_size_y_(nullptr) +, leaf_size_z_(nullptr) {} ////////////////////////////////////////////////////////////////////////////////////////////// @@ -69,14 +72,14 @@ pcl::modeler::VoxelGridDownampleWorker::initParameters(CloudMeshItem* cloud_mesh Eigen::Vector4f min_pt, max_pt; pcl::getMinMax3D(*(cloud_mesh_item->getCloudMesh()->getCloud()), min_pt, max_pt); - x_min_ = std::min(static_cast(min_pt.x()), x_min_); - x_max_ = std::max(static_cast(max_pt.x()), x_max_); + x_min_ = std::min(double(min_pt.x()), x_min_); + x_max_ = std::max(double(max_pt.x()), x_max_); - y_min_ = std::min(static_cast(min_pt.y()), y_min_); - y_max_ = std::max(static_cast(max_pt.y()), y_max_); + y_min_ = std::min(double(min_pt.y()), y_min_); + y_max_ = std::max(double(max_pt.y()), y_max_); - z_min_ = std::min(static_cast(min_pt.z()), z_min_); - z_max_ = std::max(static_cast(max_pt.z()), z_max_); + z_min_ = std::min(double(min_pt.z()), z_min_); + z_max_ = std::max(double(max_pt.z()), z_max_); } ////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/apps/point_cloud_editor/CMakeLists.txt b/apps/point_cloud_editor/CMakeLists.txt index 6a355b1ece6..814c88eafcf 100644 --- a/apps/point_cloud_editor/CMakeLists.txt +++ b/apps/point_cloud_editor/CMakeLists.txt @@ -68,6 +68,11 @@ set(SRCS src/denoiseParameterForm.cpp ) +include_directories( + "${CMAKE_CURRENT_BINARY_DIR}" + "${CMAKE_CURRENT_SOURCE_DIR}/include" +) + set(EXE_NAME "pcl_${SUBSUBSYS_NAME}") PCL_ADD_EXECUTABLE( ${EXE_NAME} @@ -79,7 +84,6 @@ PCL_ADD_EXECUTABLE( ${INCS}) target_link_libraries("${EXE_NAME}" ${QTX}::Widgets ${QTX}::OpenGL ${OPENGL_LIBRARIES} ${BOOST_LIBRARIES} pcl_common pcl_io pcl_filters) -target_include_directories(${EXE_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include) if (${QTX} MATCHES "Qt6") target_link_libraries("${EXE_NAME}" ${QTX}::OpenGLWidgets) endif() diff --git a/apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/cloud.h b/apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/cloud.h index d9a834fe48d..0557d073803 100644 --- a/apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/cloud.h +++ b/apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/cloud.h @@ -41,22 +41,22 @@ #pragma once +#include #include #include -#include // for pcl::weak_ptr -#include +#include // for pcl::weak_ptr #ifdef OPENGL_IS_A_FRAMEWORK -#include -#include +# include +# include #else #ifdef _WIN32 // Need this to pull in APIENTRY, etc. #include "windows.h" #endif -#include -#include +# include +# include #endif /// @brief A wrapper which allows to use any implementation of cloud provided by @@ -75,400 +75,405 @@ // XXX - add functions for retrieving an unshifted Cloud3D // XXX - add functions for retrieving unshifted points by index // XXX - mark access functions below as returning shifted values -class Cloud : public Statistics { -public: - /// The type for shared pointer pointing to a selection buffer - using SelectionPtr = pcl::shared_ptr; - - /// The type for weak pointer pointing to a selection buffer - using SelectionWeakPtr = pcl::weak_ptr; - - /// @brief Default Constructor - Cloud(); - - /// @brief Copy Constructor - /// @details This constructor creates a copy of the passed cloud. The - /// values of the member variables of the passed cloud are deep copied. - /// @param copy The cloud object to be used to initialize this cloud object. - Cloud(const Cloud& copy); - - /// @brief Construct a cloud from a Cloud3D. - /// @details This constructor creates a cloud object with the passed - /// cloud object stored with the internal representation. The member - /// variables of this object are initialized but not set. - Cloud(const Cloud3D& cloud, bool register_stats = false); - - /// @brief Equal Operator - /// @details Deep copies all the state of the passed cloud to this cloud. - /// @param cloud The cloud object whose status to be copied to this object - /// @return A reference to this cloud containing the new values. - Cloud& - operator=(const Cloud& cloud); - - /// @brief Subscript Operator - /// @details This operator returns a reference to the point with the - /// passed index in this cloud object. - /// @pre The index passed is expected to be within the limits of the cloud. - /// For debugging this is currently checked by an assert. - /// @param index The index of the point to be returned. - /// @return A reference to the indexed point. - Point3D& - operator[](unsigned int index); - - /// @brief Subscript Operator - /// @details This operator returns a const reference to the point with the - /// passed index in this cloud object. - /// @pre The index passed is expected to be within the limits of the cloud. - /// For debugging this is currently checked by an assert. - /// @param index The index of the point to be returned. - /// @return A const reference to the indexed point. - const Point3D& - operator[](unsigned int index) const; - - /// @brief Returns the center of the point cloud - /// @param x The x coordinate of the center (computed as the average point). - /// @param y The y coordinate of the center (computed as the average point). - /// @param z The z coordinate of the center (computed as the average point). - inline void - getCenter(float& x, float& y, float& z) const - { - x = center_xyz_[X]; - y = center_xyz_[Y]; - z = center_xyz_[Z]; - } - - /// @brief Returns the scaling factor for the point cloud - /// @return The scaling factor - inline float - getScalingFactor() const - { - return (display_scale_); - } - - /// @brief Gets the transform matrix. - /// @details The returned matrix is used to transform the cloud for - /// rendering only and does not affect the values of the points stored. - /// @return A 1-D array representing (4 x 4) matrix in - /// using OpenGL's column-major format. - inline const float* - getMatrix() const - { - return (cloud_matrix_); - } - - /// @brief Sets the transform matrix for the cloud. - /// @details The passed matrix is used to transform the cloud for - /// rendering only and does not affect the values of the points stored. - /// @pre The passed pointer represents a matrix having valid memory of at - /// least MATRIX_SIZE elements. - /// @param matrix a 1-D array representing (4 x 4) matrix in - /// using OpenGL's column-major format. - void - loadMatrix(const float* matrix); - - /// @brief Right multiplies the cloud matrix with the passed matrix - /// @details The application of this matrix effectively transforms the - /// cloud from its current state. The passed matrix is used for display - /// only and does not affect the values of the points stored. - /// @pre The passed pointer represents a matrix having valid memory of at - /// least MATRIX_SIZE elements. - /// @param matrix a 1-D array representing (4 x 4) matrix in - /// using OpenGL's column-major format. - void - multMatrix(const float* matrix); - - /// @brief Sets the selection transform matrix to the one passed. - /// @details The selection matrix represents the local transformations - /// applied to the selected points. The matrix is used relative to the - /// cloud's state after the application of its own matrices which can be - /// modified by loadMatrix and multMatrix functions. - /// @pre The passed pointer represents a matrix having valid memory of at - /// least MATRIX_SIZE elements. - /// @param matrix a 1-D array representing (4 x 4) matrix in - /// using OpenGL's column-major format. - /// @sa loadMatrix multMatrix - void - setSelectionRotation(const float* matrix); - - void - setSelectionTranslation(float dx, float dy, float dz); - - /// @brief Sets the selected points. - /// @details The cloud object is responsible for its display. As we have - /// tried to adopt a lazy approach in the application of modifications to - /// the cloud, the cloud must be notified of the selected points. This is - /// required as the user may move the selected points and we do not wish for - /// the selected points to be drawn twice, once in the user-updated position - /// and another in the points original location. - /// @pre Assumes that the selection stores the selected indices of the - /// points sorted. - /// @param A pointer pointing to a selection object. - /// @remarks This has been implemented using a weak pointer to allow a lazy - /// update to occur. When a selection is destroyed we can switch to - /// a faster rendering mode; this also occurs if the selection object is - /// empty. - void - setSelection(const SelectionPtr& selection_ptr); - - /// @brief Sets the RGB values for coloring points in COLOR_BY_PURE mode. - /// @param r the value for red color - /// @param g the value for the green color - /// @param b the value for the blue color - void - setRGB(float r, float g, float b); - - /// @brief Sets the RGB values used for highlighting the selected points. - /// @param r the value for red color - /// @param g the value for the green color - /// @param b the value for the blue color - void - setHighlightColor(float r, float g, float b); - - /// @brief Renders the cloud and highlights any selected points. - /// @param disableHighlight Defaults to false. If true the selected points - /// will not be drawn. - /// @sa setColorRampAxis, setColorRamp - void - draw(bool disable_highlight = false) const; - - /// @brief Renders the cloud and highlights any selected points. - /// @details The colors of the non-selected points come from a 1D texture - /// which is implemented by a color ramp. - void - drawWithTexture() const; - - /// @brief Renders the cloud and highlights any selected points. - /// @details The colors of the non-selected points uses the native color - /// of the original points - /// @pre The cloud should be originally colored. - void - drawWithRGB() const; - - /// @brief Renders the cloud and highlights any selected points. - /// @details The non-selected points are in a single color - void - drawWithPureColor() const; - - /// @brief Renders the cloud with the color used for highlighting the - /// selected points. - void - drawWithHighlightColor() const; - - /// @brief Sets the axis along which the displayed points should have the - /// color ramp applied. - /// @param a The axis id describing which direction the ramp should be - /// applied. - inline void - setColorRampAxis(Axis a) - { - color_ramp_axis_ = a; - } - - /// @brief Enables/Disables the use of the color ramp in display. - /// @details The color ramp aids in the visualization of the displayed - /// points by varying the color according to a linear ramp along one of the - /// axes. - /// @param onOff True enables the use of the color ramp and false disables. - inline void - setColorRamp(bool on_off) - { - use_color_ramp_ = on_off; - } - - /// @brief Appends a new 3D point to the cloud. - /// @param point the new point to be added. - void - append(const Point3D& point); - - /// @brief Appends the points of the passed cloud to this cloud. - /// @param cloud the cloud to be appended to this cloud. - void - append(const Cloud& cloud); - - /// @brief Removes the points in selection from the cloud. - /// @details Each indexed point in the selection will be removed from this - /// container. - /// @pre The index of each point in the selection is expected to be within - /// the limits of the cloud. For debugging this is currently checked by an - /// assert. Also, it is expected that the selection indices are sorted. - /// @param selection a selection object which stores the indices of the - /// selected points. - /// @remarks This function requires the use of Selection::isSelected and its - /// complexity can vary based on the implementation of that function. - void - remove(const Selection& selection); - - /// @brief Gets the size of the cloud - inline unsigned int - size() const - { - return (cloud_.size()); - } - - /// @brief Sets the size of the cloud of this object to the passed new size - /// @details If the size is smaller than the current size, only the first - /// new_size points will be kept, the rest being dropped. If new_size is - /// larger than the current size, the new points required to fill the - /// extended region are created with its default constructor. - /// @param new_size the new size of the cloud. - void - resize(unsigned int new_size); - - /// @brief Removes all points from the cloud and resets the object - void - clear(); - - /// @brief Set the sizes used for rendering the unselected points. - /// @param size The size, in pixels, used for rendering the points. - void - setPointSize(int size); - - /// @brief Set the sizes used for rendering the selected points. - /// @param size The size, in pixels, used for rendering the points. - void - setHighlightPointSize(int size); - - /// @brief Compute the transformed coordinates of the indexed point in the - /// cloud according to the object transform. - /// @details This applies the object rotation and translation of the - /// indexed point according to the user transforms. - /// @param index The index of the point whose coordinates are - /// transformed. - /// @return The transformed point. - Point3D - getObjectSpacePoint(unsigned int index) const; - - /// @brief Compute the transformed coordinates of the indexed point in the - /// cloud to match the display. - /// @details To save on computation, the points in the display are not - /// transformed on the cpu side, instead the gpu is allowed to manipulate - /// them for display. This function performs the same manipulation and - /// returns the transformed point. - /// @param index The index of the point whose coordinates are - /// transformed according to the display. - /// @return The transformed point. - Point3D - getDisplaySpacePoint(unsigned int index) const; - - /// @brief Compute the transformed coordinates of the all the points in the - /// cloud to match the display. - /// @details To save on computation, the points in the display are not - /// transformed on the cpu side, instead the gpu is allowed to manipulate - /// them for display. This function performs the same manipulation and - /// returns the transformed points. - /// @param pts a vector used to store the points whose coordinates are - /// transformed. - void - getDisplaySpacePoints(Point3DVector& pts) const; - - /// @brief Returns a const reference to the internal representation of this - /// object. - const Cloud3D& - getInternalCloud() const; - - /// @brief Places the points in the copy buffer into the cloud according - /// to the indices in the selection. - void - restore(const CopyBuffer& copy_buffer, const Selection& selection); - - /// @brief Get statistics of the selected points in string. - std::string - getStat() const override; - - /// Default Point Size - static const float DEFAULT_POINT_DISPLAY_SIZE_; - /// Default Highlight Point Size - static const float DEFAULT_POINT_HIGHLIGHT_SIZE_; - /// Default Point Color - Red component - static const float DEFAULT_POINT_DISPLAY_COLOR_RED_; - /// Default Point Color - Green component - static const float DEFAULT_POINT_DISPLAY_COLOR_GREEN_; - /// Default Point Color - Blue component - static const float DEFAULT_POINT_DISPLAY_COLOR_BLUE_; - /// Default Point Highlight Color - Red component - static const float DEFAULT_POINT_HIGHLIGHT_COLOR_RED_; - /// Default Point Highlight Color - Green component - static const float DEFAULT_POINT_HIGHLIGHT_COLOR_GREEN_; - /// Default Point Highlight Color - Blue component - static const float DEFAULT_POINT_HIGHLIGHT_COLOR_BLUE_; - -private: - /// @brief Computes the point cloud related members. - /// @details The cloud keeps track of certain values related to the points - /// in the cloud. These include the minimum coordinates and the ranges in - /// the coordinate directions. - /// @pre Assumes that there is at least one dimension of the point cloud - /// that has non-zero range. - void - updateCloudMembers(); - - /// @brief Enable the texture used for rendering the cloud - void - enableTexture() const; - - /// @brief Disable the texture used for rendering the cloud - void - disableTexture() const; - - /// The internal representation of the cloud - Cloud3D cloud_; - - /// @brief A weak pointer pointing to the selection object. - /// @details This implementation uses the weak pointer to allow for a lazy - /// update of the cloud if the selection object is destroyed. - SelectionWeakPtr selection_wk_ptr_; - - /// Flag that indicates whether a color ramp should be used (true) or not - /// (false) when displaying the cloud - bool use_color_ramp_; - - /// The axis which the color ramp is to be applied when drawing the cloud - Axis color_ramp_axis_; - - /// A scale value used to normalize the display of clouds. This is simply - /// one over the maximum of the range in each coordinate direction - float display_scale_; - - /// The center coordinate values in the point cloud. This is used for - /// display. - float center_xyz_[XYZ_SIZE]; - - /// The minimum coordinate values in the point cloud. This is used for - /// display. - float min_xyz_[XYZ_SIZE]; - - /// The maximum coordinate values in the point cloud. This is used for - /// display. - float max_xyz_[XYZ_SIZE]; - - /// A (4x4) OpenGL transform matrix for rendering the cloud - float cloud_matrix_[MATRIX_SIZE]; - - /// A (4x4) OpenGL transform matrix specifying the relative transformations - /// that are applied to the selected points in the cloud when drawing them - /// as highlighted. - float select_matrix_[MATRIX_SIZE]; - - /// A vector of indices for every point in the cloud. This vector is used - /// when a selection is set and sorted such that the selected indices - /// appear first in the vector. This is used during display to allow for - /// separate indexed drawing of the selection and the point cloud. Note - /// that this vector is partitioned according to selected and not-selected. - IndexVector partitioned_indices_; - - /// The size used for rendering the unselected points in the cloud - float point_size_; - - /// The size used for rendering the selected points in the cloud - float selected_point_size_; - - /// The R, G, B values used for coloring each points when the current - /// color scheme is COLOR_BY_PURE. - float color_[RGB]; - - /// The R, G, B values used for highlighting the selected points. - float highlight_color_[RGB]; - - /// The translations on x, y, and z axis on the selected points. - float select_translate_x_, select_translate_y_, select_translate_z_; +class Cloud : public Statistics +{ + public: + /// The type for shared pointer pointing to a selection buffer + using SelectionPtr = pcl::shared_ptr; + + /// The type for weak pointer pointing to a selection buffer + using SelectionWeakPtr = pcl::weak_ptr; + + /// @brief Default Constructor + Cloud (); + + /// @brief Copy Constructor + /// @details This constructor creates a copy of the passed cloud. The + /// values of the member variables of the passed cloud are deep copied. + /// @param copy The cloud object to be used to initialize this cloud object. + Cloud (const Cloud& copy); + + /// @brief Construct a cloud from a Cloud3D. + /// @details This constructor creates a cloud object with the passed + /// cloud object stored with the internal representation. The member + /// variables of this object are initialized but not set. + Cloud (const Cloud3D& cloud, bool register_stats=false); + + /// @brief Equal Operator + /// @details Deep copies all the state of the passed cloud to this cloud. + /// @param cloud The cloud object whose status to be copied to this object + /// @return A reference to this cloud containing the new values. + Cloud& + operator= (const Cloud& cloud); + + /// @brief Subscript Operator + /// @details This operator returns a reference to the point with the + /// passed index in this cloud object. + /// @pre The index passed is expected to be within the limits of the cloud. + /// For debugging this is currently checked by an assert. + /// @param index The index of the point to be returned. + /// @return A reference to the indexed point. + Point3D& + operator[] (unsigned int index); + + /// @brief Subscript Operator + /// @details This operator returns a const reference to the point with the + /// passed index in this cloud object. + /// @pre The index passed is expected to be within the limits of the cloud. + /// For debugging this is currently checked by an assert. + /// @param index The index of the point to be returned. + /// @return A const reference to the indexed point. + const Point3D& + operator[] (unsigned int index) const; + + /// @brief Returns the center of the point cloud + /// @param x The x coordinate of the center (computed as the average point). + /// @param y The y coordinate of the center (computed as the average point). + /// @param z The z coordinate of the center (computed as the average point). + inline + void + getCenter (float &x, float &y, float &z) const + { + x = center_xyz_[X]; y = center_xyz_[Y]; z = center_xyz_[Z]; + } + + /// @brief Returns the scaling factor for the point cloud + /// @return The scaling factor + inline + float + getScalingFactor() const + { + return (display_scale_); + } + + /// @brief Gets the transform matrix. + /// @details The returned matrix is used to transform the cloud for + /// rendering only and does not affect the values of the points stored. + /// @return A 1-D array representing (4 x 4) matrix in + /// using OpenGL's column-major format. + inline + const float* + getMatrix () const + { + return (cloud_matrix_); + } + + /// @brief Sets the transform matrix for the cloud. + /// @details The passed matrix is used to transform the cloud for + /// rendering only and does not affect the values of the points stored. + /// @pre The passed pointer represents a matrix having valid memory of at + /// least MATRIX_SIZE elements. + /// @param matrix a 1-D array representing (4 x 4) matrix in + /// using OpenGL's column-major format. + void + loadMatrix (const float* matrix); + + /// @brief Right multiplies the cloud matrix with the passed matrix + /// @details The application of this matrix effectively transforms the + /// cloud from its current state. The passed matrix is used for display + /// only and does not affect the values of the points stored. + /// @pre The passed pointer represents a matrix having valid memory of at + /// least MATRIX_SIZE elements. + /// @param matrix a 1-D array representing (4 x 4) matrix in + /// using OpenGL's column-major format. + void + multMatrix (const float* matrix); + + /// @brief Sets the selection transform matrix to the one passed. + /// @details The selection matrix represents the local transformations + /// applied to the selected points. The matrix is used relative to the + /// cloud's state after the application of its own matrices which can be + /// modified by loadMatrix and multMatrix functions. + /// @pre The passed pointer represents a matrix having valid memory of at + /// least MATRIX_SIZE elements. + /// @param matrix a 1-D array representing (4 x 4) matrix in + /// using OpenGL's column-major format. + /// @sa loadMatrix multMatrix + void + setSelectionRotation (const float* matrix); + + void + setSelectionTranslation (float dx, float dy, float dz); + + /// @brief Sets the selected points. + /// @details The cloud object is responsible for its display. As we have + /// tried to adopt a lazy approach in the application of modifications to + /// the cloud, the cloud must be notified of the selected points. This is + /// required as the user may move the selected points and we do not wish for + /// the selected points to be drawn twice, once in the user-updated position + /// and another in the points original location. + /// @pre Assumes that the selection stores the selected indices of the + /// points sorted. + /// @param A pointer pointing to a selection object. + /// @remarks This has been implemented using a weak pointer to allow a lazy + /// update to occur. When a selection is destroyed we can switch to + /// a faster rendering mode; this also occurs if the selection object is + /// empty. + void + setSelection (const SelectionPtr& selection_ptr); + + /// @brief Sets the RGB values for coloring points in COLOR_BY_PURE mode. + /// @param r the value for red color + /// @param g the value for the green color + /// @param b the value for the blue color + void + setRGB (float r, float g, float b); + + /// @brief Sets the RGB values used for highlighting the selected points. + /// @param r the value for red color + /// @param g the value for the green color + /// @param b the value for the blue color + void + setHighlightColor (float r, float g, float b); + + /// @brief Renders the cloud and highlights any selected points. + /// @param disableHighlight Defaults to false. If true the selected points + /// will not be drawn. + /// @sa setColorRampAxis, setColorRamp + void + draw (bool disable_highlight = false) const; + + /// @brief Renders the cloud and highlights any selected points. + /// @details The colors of the non-selected points come from a 1D texture + /// which is implemented by a color ramp. + void + drawWithTexture () const; + + /// @brief Renders the cloud and highlights any selected points. + /// @details The colors of the non-selected points uses the native color + /// of the original points + /// @pre The cloud should be originally colored. + void + drawWithRGB () const; + + /// @brief Renders the cloud and highlights any selected points. + /// @details The non-selected points are in a single color + void + drawWithPureColor () const; + + /// @brief Renders the cloud with the color used for highlighting the + /// selected points. + void + drawWithHighlightColor () const; + + /// @brief Sets the axis along which the displayed points should have the + /// color ramp applied. + /// @param a The axis id describing which direction the ramp should be + /// applied. + inline + void + setColorRampAxis(Axis a) + { + color_ramp_axis_ = a; + } + + /// @brief Enables/Disables the use of the color ramp in display. + /// @details The color ramp aids in the visualization of the displayed + /// points by varying the color according to a linear ramp along one of the + /// axes. + /// @param onOff True enables the use of the color ramp and false disables. + inline + void + setColorRamp(bool on_off) + { + use_color_ramp_ = on_off; + } + + /// @brief Appends a new 3D point to the cloud. + /// @param point the new point to be added. + void + append (const Point3D& point); + + /// @brief Appends the points of the passed cloud to this cloud. + /// @param cloud the cloud to be appended to this cloud. + void + append (const Cloud& cloud); + + /// @brief Removes the points in selection from the cloud. + /// @details Each indexed point in the selection will be removed from this + /// container. + /// @pre The index of each point in the selection is expected to be within + /// the limits of the cloud. For debugging this is currently checked by an + /// assert. Also, it is expected that the selection indices are sorted. + /// @param selection a selection object which stores the indices of the + /// selected points. + /// @remarks This function requires the use of Selection::isSelected and its + /// complexity can vary based on the implementation of that function. + void + remove (const Selection& selection); + + /// @brief Gets the size of the cloud + inline + unsigned int + size () const + { + return (cloud_.size()); + } + + /// @brief Sets the size of the cloud of this object to the passed new size + /// @details If the size is smaller than the current size, only the first + /// new_size points will be kept, the rest being dropped. If new_size is + /// larger than the current size, the new points required to fill the + /// extended region are created with its default constructor. + /// @param new_size the new size of the cloud. + void + resize (unsigned int new_size); + + /// @brief Removes all points from the cloud and resets the object + void + clear (); + + /// @brief Set the sizes used for rendering the unselected points. + /// @param size The size, in pixels, used for rendering the points. + void + setPointSize (int size); + + /// @brief Set the sizes used for rendering the selected points. + /// @param size The size, in pixels, used for rendering the points. + void + setHighlightPointSize (int size); + + /// @brief Compute the transformed coordinates of the indexed point in the + /// cloud according to the object transform. + /// @details This applies the object rotation and translation of the + /// indexed point according to the user transforms. + /// @param index The index of the point whose coordinates are + /// transformed. + /// @return The transformed point. + Point3D + getObjectSpacePoint (unsigned int index) const; + + /// @brief Compute the transformed coordinates of the indexed point in the + /// cloud to match the display. + /// @details To save on computation, the points in the display are not + /// transformed on the cpu side, instead the gpu is allowed to manipulate + /// them for display. This function performs the same manipulation and + /// returns the transformed point. + /// @param index The index of the point whose coordinates are + /// transformed according to the display. + /// @return The transformed point. + Point3D + getDisplaySpacePoint (unsigned int index) const; + + /// @brief Compute the transformed coordinates of the all the points in the + /// cloud to match the display. + /// @details To save on computation, the points in the display are not + /// transformed on the cpu side, instead the gpu is allowed to manipulate + /// them for display. This function performs the same manipulation and + /// returns the transformed points. + /// @param pts a vector used to store the points whose coordinates are + /// transformed. + void + getDisplaySpacePoints (Point3DVector& pts) const; + + /// @brief Returns a const reference to the internal representation of this + /// object. + const Cloud3D& + getInternalCloud () const; + + /// @brief Places the points in the copy buffer into the cloud according + /// to the indices in the selection. + void + restore (const CopyBuffer& copy_buffer, const Selection& selection); + + /// @brief Get statistics of the selected points in string. + std::string + getStat () const override; + + /// Default Point Size + static const float DEFAULT_POINT_DISPLAY_SIZE_; + /// Default Highlight Point Size + static const float DEFAULT_POINT_HIGHLIGHT_SIZE_; + /// Default Point Color - Red component + static const float DEFAULT_POINT_DISPLAY_COLOR_RED_; + /// Default Point Color - Green component + static const float DEFAULT_POINT_DISPLAY_COLOR_GREEN_; + /// Default Point Color - Blue component + static const float DEFAULT_POINT_DISPLAY_COLOR_BLUE_; + /// Default Point Highlight Color - Red component + static const float DEFAULT_POINT_HIGHLIGHT_COLOR_RED_; + /// Default Point Highlight Color - Green component + static const float DEFAULT_POINT_HIGHLIGHT_COLOR_GREEN_; + /// Default Point Highlight Color - Blue component + static const float DEFAULT_POINT_HIGHLIGHT_COLOR_BLUE_; + + private: + /// @brief Computes the point cloud related members. + /// @details The cloud keeps track of certain values related to the points + /// in the cloud. These include the minimum coordinates and the ranges in + /// the coordinate directions. + /// @pre Assumes that there is at least one dimension of the point cloud + /// that has non-zero range. + void + updateCloudMembers (); + + /// @brief Enable the texture used for rendering the cloud + void + enableTexture () const; + + /// @brief Disable the texture used for rendering the cloud + void + disableTexture() const; + + /// The internal representation of the cloud + Cloud3D cloud_; + + /// @brief A weak pointer pointing to the selection object. + /// @details This implementation uses the weak pointer to allow for a lazy + /// update of the cloud if the selection object is destroyed. + SelectionWeakPtr selection_wk_ptr_; + + /// Flag that indicates whether a color ramp should be used (true) or not + /// (false) when displaying the cloud + bool use_color_ramp_; + + /// The axis which the color ramp is to be applied when drawing the cloud + Axis color_ramp_axis_; + + /// A scale value used to normalize the display of clouds. This is simply + /// one over the maximum of the range in each coordinate direction + float display_scale_; + + /// The center coordinate values in the point cloud. This is used for + /// display. + float center_xyz_[XYZ_SIZE]; + + /// The minimum coordinate values in the point cloud. This is used for + /// display. + float min_xyz_[XYZ_SIZE]; + + /// The maximum coordinate values in the point cloud. This is used for + /// display. + float max_xyz_[XYZ_SIZE]; + + /// A (4x4) OpenGL transform matrix for rendering the cloud + float cloud_matrix_[MATRIX_SIZE]; + + /// A (4x4) OpenGL transform matrix specifying the relative transformations + /// that are applied to the selected points in the cloud when drawing them + /// as highlighted. + float select_matrix_[MATRIX_SIZE]; + + /// A vector of indices for every point in the cloud. This vector is used + /// when a selection is set and sorted such that the selected indices + /// appear first in the vector. This is used during display to allow for + /// separate indexed drawing of the selection and the point cloud. Note + /// that this vector is partitioned according to selected and not-selected. + IndexVector partitioned_indices_; + + /// The size used for rendering the unselected points in the cloud + float point_size_; + + /// The size used for rendering the selected points in the cloud + float selected_point_size_; + + /// The R, G, B values used for coloring each points when the current + /// color scheme is COLOR_BY_PURE. + float color_[RGB]; + + /// The R, G, B values used for highlighting the selected points. + float highlight_color_[RGB]; + + /// The translations on x, y, and z axis on the selected points. + float select_translate_x_, select_translate_y_, select_translate_z_; }; diff --git a/apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/cloudEditorWidget.h b/apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/cloudEditorWidget.h index b800089b654..91ff49e32fe 100644 --- a/apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/cloudEditorWidget.h +++ b/apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/cloudEditorWidget.h @@ -40,285 +40,288 @@ #pragma once -#include +#include #include +#include #include -#include #include #include -#include // for pcl::shared_ptr + +#include // for pcl::shared_ptr #include -#include // for std::array #include class Selection; /// @brief class declaration for the widget for editing and viewing /// point clouds. -class CloudEditorWidget : public QOpenGLWidget { +class CloudEditorWidget : public QOpenGLWidget +{ Q_OBJECT -public: - /// The type for shared pointer pointing to a selection buffer - using SelectionPtr = pcl::shared_ptr; - - /// @brief Constructor - /// @param parent a pointer which points to the parent widget - CloudEditorWidget(QWidget* parent = nullptr); - - /// @brief Destructor - ~CloudEditorWidget() override; - - /// @brief Attempts to load the point cloud designated by the passed file - /// name. - /// @param filename The name of the point cloud file to be loaded. - /// @remarks throws if the passed file can not be loaded. - void - loadFile(const std::string& filename); - -public Q_SLOTS: - /// @brief Loads a new cloud. - void - load(); - - /// @brief Saves a cloud to a .pcd file. The current format is ASCII. - void - save(); - - /// @brief Toggles the blend mode used to render the non-selected points - void - toggleBlendMode(); - - /// @brief Switches to the view mode. - void - view(); - - /// @brief Enters click selection mode. - void - select1D(); - - /// @brief Enters 2D selection mode. - void - select2D(); - - /// @brief Enters 3D selection mode. - void - select3D(); - - /// @brief Inverts the current selection. - void - invertSelect(); - - /// @brief Cancels the current selection. - void - cancelSelect(); - - /// @brief Copies the selected points. - void - copy(); - - /// @brief Pastes the copied points to the cloud. - void - paste(); - - /// @brief Removes the selected points. - void - remove(); - - /// @brief Copies and then removes the selected points. - void - cut(); - - /// @brief Enters the mode where users are able to translate the selected - /// points. - void - transform(); - - /// @brief Denoises the current cloud. - void - denoise(); - - /// @brief Undoes last change. - void - undo(); - - /// @brief Increases the size of the unselected points. - void - increasePointSize(); - - /// @brief Decreases the size of the unselected points. - void - decreasePointSize(); - - /// @brief Increases the size of the selected points. - void - increaseSelectedPointSize(); - - /// @brief Decreases the size of the selected points. - void - decreaseSelectedPointSize(); - - /// @brief Sets the size of the unselected points. - void - setPointSize(int size); - - /// @brief Sets the size of the selected points. - void - setSelectedPointSize(int size); - - /// @brief Colors the unselected points by its native color. - void - colorByRGB(); - - /// @brief Colors the unselected points with a color ramp based on the X - /// values of the points - void - colorByX(); - - /// @brief Colors the unselected points with a color ramp based on the Y - /// values of the points - void - colorByY(); - - /// @brief Colors the unselected points with a color ramp based on the Z - /// values of the points - void - colorByZ(); - - /// @brief Colors the unselected points using an single color. - void - colorByPure(); - - /// @brief Turn on the dialog box showing the statistics of the cloud. - void - showStat(); - -protected: - /// initializes GL - void - initializeGL() override; - - /// the rendering function. - void - paintGL() override; - - /// resizes widget - void - resizeGL(int width, int height) override; - - /// mouse press control - void - mousePressEvent(QMouseEvent* event) override; - - /// mouse move control - void - mouseMoveEvent(QMouseEvent* event) override; - - /// mouse release control - void - mouseReleaseEvent(QMouseEvent* event) override; - - /// key press control - void - keyPressEvent(QKeyEvent* event) override; - -private: - /// @brief Attempts to load a pcd file - /// @param filename The name of the pcd file to be loaded. - /// @remarks throws if the passed file can not be loaded. - void - loadFilePCD(const std::string& filename); - - /// @brief Adds all of our file loader functions to the extension map - void - initFileLoadMap(); - - /// @brief Returns true if the cloud stored in a file is colored - /// @param fileName a reference to a string storing the path of a cloud - bool - isColored(const std::string& fileName) const; - - /// @brief swap the values of r and b in each point of the cloud. - void - swapRBValues(); - - /// @brief initializes the map between key press events and the - /// corresponding functors. - void - initKeyMap(); - - struct ExtCompare { + public: + /// The type for shared pointer pointing to a selection buffer + using SelectionPtr = pcl::shared_ptr; + + /// @brief Constructor + /// @param parent a pointer which points to the parent widget + CloudEditorWidget (QWidget *parent = nullptr); + + /// @brief Destructor + ~CloudEditorWidget () override; + + /// @brief Attempts to load the point cloud designated by the passed file + /// name. + /// @param filename The name of the point cloud file to be loaded. + /// @remarks throws if the passed file can not be loaded. + void + loadFile(const std::string &filename); + + public Q_SLOTS: + /// @brief Loads a new cloud. + void + load (); + + /// @brief Saves a cloud to a .pcd file. The current format is ASCII. + void + save (); + + /// @brief Toggles the blend mode used to render the non-selected points + void + toggleBlendMode (); + + /// @brief Switches to the view mode. + void + view (); + + /// @brief Enters click selection mode. + void + select1D (); + + /// @brief Enters 2D selection mode. + void + select2D (); + + /// @brief Enters 3D selection mode. + void + select3D (); + + /// @brief Inverts the current selection. + void + invertSelect (); + + /// @brief Cancels the current selection. + void + cancelSelect (); + + /// @brief Copies the selected points. + void + copy (); + + /// @brief Pastes the copied points to the cloud. + void + paste (); + + /// @brief Removes the selected points. + void + remove (); + + /// @brief Copies and then removes the selected points. + void + cut (); + + /// @brief Enters the mode where users are able to translate the selected + /// points. + void + transform (); + + /// @brief Denoises the current cloud. + void + denoise (); + + /// @brief Undoes last change. + void + undo (); + + /// @brief Increases the size of the unselected points. + void + increasePointSize (); + + /// @brief Decreases the size of the unselected points. + void + decreasePointSize (); + + /// @brief Increases the size of the selected points. + void + increaseSelectedPointSize (); + + /// @brief Decreases the size of the selected points. + void + decreaseSelectedPointSize (); + + /// @brief Sets the size of the unselected points. + void + setPointSize (int size); + + /// @brief Sets the size of the selected points. + void + setSelectedPointSize (int size); + + /// @brief Colors the unselected points by its native color. + void + colorByRGB (); + + /// @brief Colors the unselected points with a color ramp based on the X + /// values of the points + void + colorByX (); + + /// @brief Colors the unselected points with a color ramp based on the Y + /// values of the points + void + colorByY (); + + /// @brief Colors the unselected points with a color ramp based on the Z + /// values of the points + void + colorByZ (); + + /// @brief Colors the unselected points using an single color. + void + colorByPure (); + + /// @brief Turn on the dialog box showing the statistics of the cloud. + void + showStat (); + + protected: + /// initializes GL + void + initializeGL () override; + + /// the rendering function. + void + paintGL () override; + + /// resizes widget + void + resizeGL (int width, int height) override; + + /// mouse press control + void + mousePressEvent (QMouseEvent *event) override; + + /// mouse move control + void + mouseMoveEvent (QMouseEvent *event) override; + + /// mouse release control + void + mouseReleaseEvent (QMouseEvent *event) override; + + /// key press control + void + keyPressEvent (QKeyEvent *event) override; + + private: + + /// @brief Attempts to load a pcd file + /// @param filename The name of the pcd file to be loaded. + /// @remarks throws if the passed file can not be loaded. + void + loadFilePCD(const std::string &filename); + + /// @brief Adds all of our file loader functions to the extension map + void + initFileLoadMap(); + + /// @brief Returns true if the cloud stored in a file is colored + /// @param fileName a reference to a string storing the path of a cloud bool - operator()(std::string lhs, std::string rhs) const - { - stringToLower(lhs); - stringToLower(rhs); - return lhs.compare(rhs) < 0; - } - }; + isColored (const std::string &fileName) const; + + /// @brief swap the values of r and b in each point of the cloud. + void + swapRBValues (); - using FileLoadFunc = std::function; - using FileLoadMap = std::map; + /// @brief initializes the map between key press events and the + /// corresponding functors. + void + initKeyMap(); + + struct ExtCompare + { + bool + operator()(std::string lhs, std::string rhs) const + { + stringToLower(lhs); + stringToLower(rhs); + return lhs.compare(rhs) < 0; + } + }; - /// a map of file type extensions to loader functions. - FileLoadMap cloud_load_func_map_; + using FileLoadFunc = std::function; + using FileLoadMap = std::map; - /// a pointer to the cloud being edited. - CloudPtr cloud_ptr_; + /// a map of file type extensions to loader functions. + FileLoadMap cloud_load_func_map_; + + /// a pointer to the cloud being edited. + CloudPtr cloud_ptr_; - /// The display size, in pixels, of the cloud points - unsigned int point_size_{2u}; + /// The display size, in pixels, of the cloud points + unsigned int point_size_; - /// The display size, in pixels, of the selected cloud points - unsigned int selected_point_size_{4u}; + /// The display size, in pixels, of the selected cloud points + unsigned int selected_point_size_; - /// The transformation tool being used. Either a cloud transform tool or - /// a selection transform tool is activated at a time. - std::shared_ptr tool_ptr_; + /// The transformation tool being used. Either a cloud transform tool or + /// a selection transform tool is activated at a time. + std::shared_ptr tool_ptr_; - /// a pointer to the selection object - SelectionPtr selection_ptr_; + /// a pointer to the selection object + SelectionPtr selection_ptr_; - /// a pointer to the copy buffer object. - CopyBufferPtr copy_buffer_ptr_; + /// a pointer to the copy buffer object. + CopyBufferPtr copy_buffer_ptr_; - /// a pointer to the command queue object - CommandQueuePtr command_queue_ptr_; + /// a pointer to the command queue object + CommandQueuePtr command_queue_ptr_; - /// The camera field of view - double cam_fov_{60.0}; + /// The camera field of view + double cam_fov_; - /// The camera aspect ratio - double cam_aspect_{1.0}; + /// The camera aspect ratio + double cam_aspect_; - /// The camera near clipping plane - double cam_near_{0.0001}; + /// The camera near clipping plane + double cam_near_; - /// The camera far clipping plane - double cam_far_{100.0}; + /// The camera far clipping plane + double cam_far_; - /// @brief Initialize the texture used for rendering the cloud - void - initTexture(); + /// @brief Initialize the texture used for rendering the cloud + void + initTexture (); - /// The current scheme used for coloring the whole cloud - ColorScheme color_scheme_{COLOR_BY_PURE}; + /// The current scheme used for coloring the whole cloud + ColorScheme color_scheme_; - /// A flag indicates whether the cloud is initially colored or not. - bool is_colored_{false}; + /// A flag indicates whether the cloud is initially colored or not. + bool is_colored_; - using KeyMapFunc = std::function; + using KeyMapFunc = std::function; - /// map between pressed key and the corresponding functor - std::map key_map_; + /// map between pressed key and the corresponding functor + std::map key_map_; - /// a dialog displaying the statistics of the cloud editor - StatisticsDialog stat_dialog_; + /// a dialog displaying the statistics of the cloud editor + StatisticsDialog stat_dialog_; - /// the viewport, set by resizeGL - std::array viewport_; + /// the viewport, set by resizeGL + std::array viewport_; - /// the projection matrix, set by resizeGL - std::array projection_matrix_; + /// the projection matrix, set by resizeGL + std::array projection_matrix_; }; diff --git a/apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/cloudTransformTool.h b/apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/cloudTransformTool.h index c3bed348626..66ae1b482d1 100644 --- a/apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/cloudTransformTool.h +++ b/apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/cloudTransformTool.h @@ -40,104 +40,108 @@ #pragma once -#include #include +#include #include /// @brief The cloud transform tool computes the transform matrix from user's /// mouse operation. It then updates the cloud with the new transform matrices /// to make the cloud be rendered appropriately. -class CloudTransformTool : public ToolInterface { -public: - /// @brief Constructor - /// @param cloud_ptr a shared pointer pointing to the cloud object. - CloudTransformTool(CloudPtr cloud_ptr); - - /// @brief Destructor - ~CloudTransformTool() override; - - /// @brief Initialize the current transform with mouse screen coordinates - /// and key modifiers. - /// @param x the x value of the mouse screen coordinates. - /// @param y the y value of the mouse screen coordinates. - /// @param modifiers The keyboard modifiers. This function does not make - /// use of this parameter. - /// @param buttons The state of the mouse buttons. This function does not - /// make use of this parameter. - void - start(int x, int y, BitMask modifiers, BitMask buttons) override; - - /// @brief Updates the transform matrix of this object with mouse screen - /// coordinates and key modifiers. - /// @details When the LEFT mouse button is down the motion of the mouse is - /// used to compute various transforms for the cloud display. Depending on - /// the modifiers, the transformation matrix is computed correspondingly. - /// When shift is pressed, the motion of mouse indicates a scale. If - /// no key modifiers is pressed, the mouse move indicates a rotation. The - /// control key pans the display, and the alt key translates along the - /// z-axis. - /// @param x The x value of the mouse screen coordinates. - /// @param y The y value of the mouse screen coordinates. - /// @param modifiers the key modifier. SHIFT scales the point cloud - /// display. CONTROL pans the point cloud parallel to the view plane. ALT - /// moves the point cloud in/out along the z-axis (perpendicular to the - /// view plane). If no modifier is pressed then the cloud display is - /// rotated. - /// @param buttons The LEFT mouse button must be pressed for any transform - /// to be generated. All other buttons are ignored. - void - update(int x, int y, BitMask modifiers, BitMask buttons) override; - - /// @brief Updates the transform matrix of this object with mouse screen - /// coordinates and key modifiers. Then right multiplies the cloud_matrix_ - /// matrix of the cloud object with the transform matrix of this object. - /// @details This function is not required by this tool - void - end(int, int, BitMask, BitMask) override - {} - - /// @brief This function does nothing for this cloud transform tool. - void - draw() const override - {} - -private: - /// generate translate matrix for the xy plane - void - getTranslateMatrix(int dx, int dy, float* matrix); - - /// generate translate matrix for the z direction - void - getZTranslateMatrix(int dy, float* matrix); - - /// generate scale matrix - void - getScaleMatrix(int dy, float* matrix) const; - - /// the transform matrix to be used for updating the coordinates of all - /// the points in the cloud - float transform_matrix_[MATRIX_SIZE]; - - /// a shared pointer pointing to the cloud object. - CloudPtr cloud_ptr_; - - /// the trackball associated with this transform - TrackBall trackball_; - - /// last recorded mouse positions - int x_{0}, y_{0}; - - /// scaling factor used to control the speed which the display scales the - /// point cloud - float scale_factor_; - - /// scaling factor used to control the speed which the display translates - /// the point cloud - float translate_factor_; - - /// default scaling factor - static const float DEFAULT_SCALE_FACTOR_; - - /// default translation factor - static const float DEFAULT_TRANSLATE_FACTOR_; +class CloudTransformTool : public ToolInterface +{ + public: + /// @brief Constructor + /// @param cloud_ptr a shared pointer pointing to the cloud object. + CloudTransformTool (CloudPtr cloud_ptr); + + /// @brief Destructor + ~CloudTransformTool () override; + + /// @brief Initialize the current transform with mouse screen coordinates + /// and key modifiers. + /// @param x the x value of the mouse screen coordinates. + /// @param y the y value of the mouse screen coordinates. + /// @param modifiers The keyboard modifiers. This function does not make + /// use of this parameter. + /// @param buttons The state of the mouse buttons. This function does not + /// make use of this parameter. + void + start (int x, int y, BitMask modifiers, BitMask buttons) override; + + /// @brief Updates the transform matrix of this object with mouse screen + /// coordinates and key modifiers. + /// @details When the LEFT mouse button is down the motion of the mouse is + /// used to compute various transforms for the cloud display. Depending on + /// the modifiers, the transformation matrix is computed correspondingly. + /// When shift is pressed, the motion of mouse indicates a scale. If + /// no key modifiers is pressed, the mouse move indicates a rotation. The + /// control key pans the display, and the alt key translates along the + /// z-axis. + /// @param x The x value of the mouse screen coordinates. + /// @param y The y value of the mouse screen coordinates. + /// @param modifiers the key modifier. SHIFT scales the point cloud + /// display. CONTROL pans the point cloud parallel to the view plane. ALT + /// moves the point cloud in/out along the z-axis (perpendicular to the + /// view plane). If no modifier is pressed then the cloud display is + /// rotated. + /// @param buttons The LEFT mouse button must be pressed for any transform + /// to be generated. All other buttons are ignored. + void + update (int x, int y, BitMask modifiers, BitMask buttons) override; + + /// @brief Updates the transform matrix of this object with mouse screen + /// coordinates and key modifiers. Then right multiplies the cloud_matrix_ + /// matrix of the cloud object with the transform matrix of this object. + /// @details This function is not required by this tool + void + end (int, int, BitMask, BitMask) override + { + } + + /// @brief This function does nothing for this cloud transform tool. + void + draw() const override + { + } + + private: + + /// generate translate matrix for the xy plane + void + getTranslateMatrix (int dx, int dy, float* matrix); + + /// generate translate matrix for the z direction + void + getZTranslateMatrix (int dy, float* matrix); + + /// generate scale matrix + void + getScaleMatrix (int dy, float* matrix) const; + + /// the transform matrix to be used for updating the coordinates of all + /// the points in the cloud + float transform_matrix_[MATRIX_SIZE]; + + /// a shared pointer pointing to the cloud object. + CloudPtr cloud_ptr_; + + /// the trackball associated with this transform + TrackBall trackball_; + + /// last recorded mouse positions + int x_, y_; + + /// scaling factor used to control the speed which the display scales the + /// point cloud + float scale_factor_; + + /// scaling factor used to control the speed which the display translates + /// the point cloud + float translate_factor_; + + /// default scaling factor + static const float DEFAULT_SCALE_FACTOR_; + + /// default translation factor + static const float DEFAULT_TRANSLATE_FACTOR_; }; diff --git a/apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/command.h b/apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/command.h index a4fb100b4aa..ca4ef7fb128 100644 --- a/apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/command.h +++ b/apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/command.h @@ -47,48 +47,57 @@ /// @brief The abstract parent class of all the command classes. Commands are /// non-copyable. -class Command { -public: - /// @brief Destructor - virtual ~Command() = default; +class Command +{ + public: + /// @brief Destructor + virtual ~Command () + = default; -protected: - /// Allows command queues to be the only objects which are able to execute - /// commands. - friend class CommandQueue; + protected: + /// Allows command queues to be the only objects which are able to execute + /// commands. + friend class CommandQueue; - /// @brief The default constructor. - /// @details Derived commands are assumed to have undo by default. Each - /// is free to override this. - Command() = default; + /// @brief The default constructor. + /// @details Derived commands are assumed to have undo by default. Each + /// is free to override this. + Command () : has_undo_(true) + { + } - /// @brief Returns true if the command has an undo function. - inline bool - hasUndo() const - { - return (has_undo_); - } + /// @brief Returns true if the command has an undo function. + inline + bool + hasUndo () const + { + return (has_undo_); + } - /// @brief Executes the command. - virtual void - execute() = 0; + /// @brief Executes the command. + virtual + void + execute () = 0; - /// @brief Undos the command. - virtual void - undo() = 0; + /// @brief Undos the command. + virtual + void + undo () = 0; - /// @brief a flag indicates whether the command has an undo function. - bool has_undo_{true}; + /// @brief a flag indicates whether the command has an undo function. + bool has_undo_; -private: - /// @brief Copy Constructor - object is non-copyable - Command(const Command&) { assert(false); } + private: + /// @brief Copy Constructor - object is non-copyable + Command (const Command&) + { + assert(false); + } - /// @brief Equal Operator - object is non-copyable - Command& - operator=(const Command&) - { - assert(false); - return *this; - } + /// @brief Equal Operator - object is non-copyable + Command& + operator= (const Command&) + { + assert(false); return (*this); + } }; diff --git a/apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/commandQueue.h b/apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/commandQueue.h index 3ec5e670492..f69d9fa05b4 100644 --- a/apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/commandQueue.h +++ b/apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/commandQueue.h @@ -41,77 +41,80 @@ #pragma once -#include - #include #include +#include /// @brief A structure for managing commands /// @details A command queue object provides a dequeue of commands as well as /// operations to manipulate the commands in the queue. Operations include /// executing and undoing the commands in the queue. A command queue object /// is non-copyable. -class CommandQueue { -public: - /// @brief Default Constructor - /// @details Creates a command queue object and makes its depth limit - /// be the default value. - CommandQueue(); - - /// @brief Constructor - /// @details Create a command queue with specified depth limit. - /// @param max_size the value to be used to set the depth limit of this - /// object. - CommandQueue(unsigned int max_size); - - /// @brief Destructor - ~CommandQueue() = default; - - /// @brief Executes a command. If the command has an undo function, then - /// adds the command to the queue. - /// @param command_ptr a shared pointer pointing to a command object whose - /// execute function will be invoked by this object. - void - execute(const CommandPtr&); - - /// @brief Undoes the last command by popping the tail of the queue, invoke - /// the undo function of the command. - void - undo(); - - /// @brief Changes the command history limit. - /// @details If the passed size is smaller than the current size then the - /// oldest commands are removed (their undo functions are not called). - /// @param size The new maximum number of commands that may exist in this - /// queue for undo purposes. - /// @return The actual maximum size set. It may happen that the passed - /// value is too large and cannot be set. - unsigned int - setMaxSize(unsigned int size); - - /// @brief The default maximal size of the depth limit - static const unsigned int DEFAULT_MAX_SIZE_ = 200; - -private: - /// @brief Copy constructor - object is non-copyable - CommandQueue(const CommandQueue&) { assert(false); } - - /// @brief Equal operator - object is non-copyable - CommandQueue& - operator=(const CommandQueue&) - { - assert(false); - return *this; - } - - /// @brief Enforces the depth limit of the command queue. If the depth is - /// larger than the depth limit, a deque operation will be invoked. - void - enforceDequeLimit(); - - /// The internal representation of this object. - std::deque command_deque_; - - /// The depth limit of the command queue. - unsigned int depth_limit_; +class CommandQueue +{ + public: + /// @brief Default Constructor + /// @details Creates a command queue object and makes its depth limit + /// be the default value. + CommandQueue (); + + /// @brief Constructor + /// @details Create a command queue with specified depth limit. + /// @param max_size the value to be used to set the depth limit of this + /// object. + CommandQueue (unsigned int max_size); + + /// @brief Destructor + ~CommandQueue () + = default; + + /// @brief Executes a command. If the command has an undo function, then + /// adds the command to the queue. + /// @param command_ptr a shared pointer pointing to a command object whose + /// execute function will be invoked by this object. + void + execute (const CommandPtr&); + + /// @brief Undoes the last command by popping the tail of the queue, invoke + /// the undo function of the command. + void + undo (); + + /// @brief Changes the command history limit. + /// @details If the passed size is smaller than the current size then the + /// oldest commands are removed (their undo functions are not called). + /// @param size The new maximum number of commands that may exist in this + /// queue for undo purposes. + /// @return The actual maximum size set. It may happen that the passed + /// value is too large and cannot be set. + unsigned int + setMaxSize(unsigned int size); + + /// @brief The default maximal size of the depth limit + static const unsigned int DEFAULT_MAX_SIZE_ = 200; + + private: + /// @brief Copy constructor - object is non-copyable + CommandQueue(const CommandQueue&) + { + assert(false); + } + + /// @brief Equal operator - object is non-copyable + CommandQueue& + operator= (const CommandQueue&) + { + assert(false); return (*this); + } + + /// @brief Enforces the depth limit of the command queue. If the depth is + /// larger than the depth limit, a deque operation will be invoked. + void + enforceDequeLimit (); + + /// The internal representation of this object. + std::deque command_deque_; + + /// The depth limit of the command queue. + unsigned int depth_limit_; }; diff --git a/apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/common.h b/apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/common.h index 4a0884258f8..a90606aab5e 100644 --- a/apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/common.h +++ b/apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/common.h @@ -68,4 +68,4 @@ invertMatrix(const float* matrix, float* inverse); /// @brief Converts the passed string to lowercase in place /// @param s The string to be made lower. void -stringToLower(std::string& s); +stringToLower(std::string &s); diff --git a/apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/copyBuffer.h b/apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/copyBuffer.h index d5ab3504e9b..9adc2cac82b 100644 --- a/apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/copyBuffer.h +++ b/apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/copyBuffer.h @@ -40,57 +40,58 @@ #pragma once -#include #include +#include /// @brief a buffer holding the points being copied and a set of operations for /// manipulating the buffer. -class CopyBuffer : public Statistics { -public: - /// @brief Default Constructor - /// @details This creates an empty buffer - CopyBuffer(bool register_stats = false) - { - if (register_stats) - registerStats(); - } - - /// @brief Sets the points in the copy buffer. - /// @details The passed selection pointer is used to get specified points - /// from the stored cloud pointer and copy them into the internal buffer. - /// Any points that currently exist in this buffer are removed and replaced - /// with those passed. Note that this buffer is cleared prior to any - /// checking of the state of the passed parameters. - /// @param cloud_ptr a pointer to a cloud object whose points are to be - /// copied - /// @param selection a const reference to the selected points object - void - set(const ConstCloudPtr& cloud_ptr, const Selection& selection); - - /// @brief Returns the points stored in the internal buffer as a const Cloud - const Cloud& - get() const; +class CopyBuffer : public Statistics +{ + public: + /// @brief Default Constructor + /// @details This creates an empty buffer + CopyBuffer (bool register_stats=false) + { + if (register_stats) + registerStats(); + } - /// @brief Returns the points stored in the internal buffer as a Cloud - Cloud& - get(); + /// @brief Sets the points in the copy buffer. + /// @details The passed selection pointer is used to get specified points + /// from the stored cloud pointer and copy them into the internal buffer. + /// Any points that currently exist in this buffer are removed and replaced + /// with those passed. Note that this buffer is cleared prior to any + /// checking of the state of the passed parameters. + /// @param cloud_ptr a pointer to a cloud object whose points are to be + /// copied + /// @param selection a const reference to the selected points object + void + set (const ConstCloudPtr& cloud_ptr, const Selection& selection); - /// @brief Removes all the points from the copy buffer. - void - clean(); + /// @brief Returns the points stored in the internal buffer as a const Cloud + const Cloud& + get() const; - /// @brief Get the statistics of the copied points in string. - std::string - getStat() const override; + /// @brief Returns the points stored in the internal buffer as a Cloud + Cloud& + get(); + + /// @brief Removes all the points from the copy buffer. + void + clean (); + + /// @brief Get the statistics of the copied points in string. + std::string + getStat () const override; - /// @brief Returns true if the buffer is empty, false otherwise - bool - empty() const - { - return (buffer_.size() == 0); - } + /// @brief Returns true if the buffer is empty, false otherwise + bool + empty() const + { + return (buffer_.size() == 0); + } -private: - /// a cloud object holding all the copied points. - Cloud buffer_; + private: + /// a cloud object holding all the copied points. + Cloud buffer_; }; diff --git a/apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/copyCommand.h b/apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/copyCommand.h index 8c942087d93..2da976ab097 100644 --- a/apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/copyCommand.h +++ b/apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/copyCommand.h @@ -41,64 +41,65 @@ #pragma once #include -#include #include -#include // for pcl::shared_ptr +#include + +#include // for pcl::shared_ptr class Selection; -class CopyCommand : public Command { -public: - /// The type for shared pointer pointing to a constant selection buffer - using ConstSelectionPtr = pcl::shared_ptr; +class CopyCommand : public Command +{ + public: + /// The type for shared pointer pointing to a constant selection buffer + using ConstSelectionPtr = pcl::shared_ptr; - /// @brief Constructor - /// @param copy_buffer_ptr a shared pointer pointing to the copy buffer. - /// @param selection_ptr a shared pointer pointing to the selection object. - /// @param cloud_ptr a shared pointer pointing to the cloud object. - CopyCommand(CopyBufferPtr copy_buffer_ptr, - ConstSelectionPtr selection_ptr, - ConstCloudPtr cloud_ptr) - : copy_buffer_ptr_(std::move(copy_buffer_ptr)) - , selection_ptr_(std::move(selection_ptr)) - , cloud_ptr_(std::move(cloud_ptr)) - { - has_undo_ = false; - } + /// @brief Constructor + /// @param copy_buffer_ptr a shared pointer pointing to the copy buffer. + /// @param selection_ptr a shared pointer pointing to the selection object. + /// @param cloud_ptr a shared pointer pointing to the cloud object. + CopyCommand (CopyBufferPtr copy_buffer_ptr, + ConstSelectionPtr selection_ptr, + ConstCloudPtr cloud_ptr) + : copy_buffer_ptr_(std::move(copy_buffer_ptr)), selection_ptr_(std::move(selection_ptr)), + cloud_ptr_(std::move(cloud_ptr)) + { + has_undo_ = false; + } - /// @brief Copy constructor - commands are non-copyable - CopyCommand(const CopyCommand&) = delete; + /// @brief Copy constructor - commands are non-copyable + CopyCommand (const CopyCommand&) = delete; - /// @brief Equal operator - commands are non-copyable - CopyCommand& - operator=(const CopyCommand&) = delete; + /// @brief Equal operator - commands are non-copyable + CopyCommand& + operator= (const CopyCommand&) = delete; -protected: - /// @brief Copy the selected points into the copy buffer. - /// @pre Assumes the constructor was given appropriate pointers to the - /// required objects. - void - execute() override - { - if (!cloud_ptr_) - return; - copy_buffer_ptr_->set(cloud_ptr_, *selection_ptr_); - } + protected: + /// @brief Copy the selected points into the copy buffer. + /// @pre Assumes the constructor was given appropriate pointers to the + /// required objects. + void + execute () override + { + if (!cloud_ptr_) + return; + copy_buffer_ptr_ -> set(cloud_ptr_, *selection_ptr_); + } - /// @brief undo is not supported for this command. - void - undo() override - { - assert(false); - } + /// @brief undo is not supported for this command. + void + undo () override + { + assert(false); + } -private: - /// a pointer to the copy buffer. - CopyBufferPtr copy_buffer_ptr_; + private: + /// a pointer to the copy buffer. + CopyBufferPtr copy_buffer_ptr_; - /// a shared pointer pointing to the selection - ConstSelectionPtr selection_ptr_; + /// a shared pointer pointing to the selection + ConstSelectionPtr selection_ptr_; - /// a shared pointer pointing to the cloud - ConstCloudPtr cloud_ptr_; + /// a shared pointer pointing to the cloud + ConstCloudPtr cloud_ptr_; }; diff --git a/apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/cutCommand.h b/apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/cutCommand.h index 0e982cac5d6..6f1e0b81d88 100644 --- a/apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/cutCommand.h +++ b/apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/cutCommand.h @@ -41,61 +41,63 @@ #pragma once #include -#include #include +#include #include -#include // for pcl::shared_ptr - -class CutCommand : public Command { -public: - /// The type for shared pointer pointing to a selection buffer - using SelectionPtr = pcl::shared_ptr; - - /// @brief Constructor - /// @param copy_buffer_ptr a shared pointer pointing to the copy buffer. - /// @param selection_ptr a shared pointer pointing to the selection object. - /// @param cloud_ptr a shared pointer pointing to the cloud object. - CutCommand(CopyBufferPtr copy_buffer_ptr, - SelectionPtr selection_ptr, - const CloudPtr& cloud_ptr); - - /// @brief Copy constructor - commands are non-copyable - CutCommand(const CutCommand&) = delete; - - /// @brief Equal operator - commands are non-copyable - CutCommand& - operator=(const CutCommand&) = delete; - - /// @brief Destructor - ~CutCommand() override; - -protected: - /// @brief Moves the selected points to the copy buffer and removes them - /// from the cloud. - /// @pre Assumes the constructor was given appropriate pointers to the - /// required objects. - void - execute() override; - - /// @brief Returns the cut points to the cloud. This does not reconstruct - /// the original ordering of the point cloud. - void - undo() override; - -private: - /// A shared pointer pointing to the selection object. - SelectionPtr selection_ptr_; - - /// a pointer pointing to the cloud - CloudPtr cloud_ptr_; - - /// a pointer pointing to the copy buffer. - CopyBufferPtr copy_buffer_ptr_; - - /// a selection which backs up the index of the points cut in the - /// original cloud. - Selection cut_selection_; - - /// The copy buffer which backs up the points removed from the cloud. - CopyBuffer cut_cloud_buffer_; + +#include // for pcl::shared_ptr + +class CutCommand : public Command +{ + public: + /// The type for shared pointer pointing to a selection buffer + using SelectionPtr = pcl::shared_ptr; + + /// @brief Constructor + /// @param copy_buffer_ptr a shared pointer pointing to the copy buffer. + /// @param selection_ptr a shared pointer pointing to the selection object. + /// @param cloud_ptr a shared pointer pointing to the cloud object. + CutCommand (CopyBufferPtr copy_buffer_ptr, + SelectionPtr selection_ptr, + const CloudPtr& cloud_ptr); + + /// @brief Copy constructor - commands are non-copyable + CutCommand (const CutCommand&) = delete; + + /// @brief Equal operator - commands are non-copyable + CutCommand& + operator= (const CutCommand&) = delete; + + /// @brief Destructor + ~CutCommand () override; + + protected: + /// @brief Moves the selected points to the copy buffer and removes them + /// from the cloud. + /// @pre Assumes the constructor was given appropriate pointers to the + /// required objects. + void + execute () override; + + /// @brief Returns the cut points to the cloud. This does not reconstruct + /// the original ordering of the point cloud. + void + undo () override; + + private: + /// A shared pointer pointing to the selection object. + SelectionPtr selection_ptr_; + + /// a pointer pointing to the cloud + CloudPtr cloud_ptr_; + + /// a pointer pointing to the copy buffer. + CopyBufferPtr copy_buffer_ptr_; + + /// a selection which backs up the index of the points cut in the + /// original cloud. + Selection cut_selection_; + + /// The copy buffer which backs up the points removed from the cloud. + CopyBuffer cut_cloud_buffer_; }; diff --git a/apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/deleteCommand.h b/apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/deleteCommand.h index 7abde750480..25c22ac08a5 100644 --- a/apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/deleteCommand.h +++ b/apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/deleteCommand.h @@ -41,48 +41,50 @@ #pragma once #include -#include #include +#include #include -#include // for pcl::shared_ptr -class DeleteCommand : public Command { -public: - /// The type for shared pointer pointing to a selection buffer - using SelectionPtr = pcl::shared_ptr; +#include // for pcl::shared_ptr - /// @brief Constructor - /// @param selection_ptr A shared pointer pointing to the selection object. - /// @param cloud_ptr A shared pointer pointing to the cloud object. - DeleteCommand(SelectionPtr selection_ptr, const CloudPtr& cloud_ptr); +class DeleteCommand : public Command +{ + public: + /// The type for shared pointer pointing to a selection buffer + using SelectionPtr = pcl::shared_ptr; - /// @brief Copy constructor - commands are non-copyable - DeleteCommand(const DeleteCommand& c) = delete; + /// @brief Constructor + /// @param selection_ptr A shared pointer pointing to the selection object. + /// @param cloud_ptr A shared pointer pointing to the cloud object. + DeleteCommand (SelectionPtr selection_ptr, const CloudPtr& cloud_ptr); - /// @brief Equal operator - commands are non-copyable - DeleteCommand& - operator=(const DeleteCommand&) = delete; + /// @brief Copy constructor - commands are non-copyable + DeleteCommand (const DeleteCommand& c) = delete; -protected: - /// @brief Removes the selected points and maintains a backup for undo. - void - execute() override; + /// @brief Equal operator - commands are non-copyable + DeleteCommand& + operator= (const DeleteCommand&) = delete; - /// @brief Returns the deleted points to the cloud, Order is not preserved. - void - undo() override; + protected: + /// @brief Removes the selected points and maintains a backup for undo. + void + execute () override; + + /// @brief Returns the deleted points to the cloud, Order is not preserved. + void + undo () override; -private: - /// a pointer pointing to the cloud - CloudPtr cloud_ptr_; + private: + /// a pointer pointing to the cloud + CloudPtr cloud_ptr_; - /// A shared pointer pointing to the selection object. - SelectionPtr selection_ptr_; + /// A shared pointer pointing to the selection object. + SelectionPtr selection_ptr_; - /// a selection which backs up the index of the deleted points in the - /// original cloud. - Selection deleted_selection_; + /// a selection which backs up the index of the deleted points in the + /// original cloud. + Selection deleted_selection_; - /// a copy buffer which backs up the points deleted from the cloud. - CopyBuffer deleted_cloud_buffer_; + /// a copy buffer which backs up the points deleted from the cloud. + CopyBuffer deleted_cloud_buffer_; }; diff --git a/apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/denoiseCommand.h b/apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/denoiseCommand.h index e05f407a1a1..73a1cd11b63 100644 --- a/apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/denoiseCommand.h +++ b/apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/denoiseCommand.h @@ -43,12 +43,14 @@ #pragma once #include -#include #include #include -#include // for pcl::shared_ptr +#include + +#include // for pcl::shared_ptr -class DenoiseCommand : public Command { +class DenoiseCommand : public Command +{ public: /// The type for shared pointer pointing to a selection buffer using SelectionPtr = pcl::shared_ptr; @@ -58,32 +60,28 @@ class DenoiseCommand : public Command { /// @param cloud_ptr a shared pointer pointing to the cloud object. /// @param mean the number of points to use for mean distance estimation. /// @param threshold the standard deviation multiplier threshold - DenoiseCommand(SelectionPtr selection_ptr, - const CloudPtr& cloud_ptr, - float mean, - float threshold) - : selection_ptr_(std::move(selection_ptr)) - , cloud_ptr_(cloud_ptr) - , mean_(mean) - , threshold_(threshold) - , removed_indices_(cloud_ptr) - {} + DenoiseCommand (SelectionPtr selection_ptr, const CloudPtr& cloud_ptr, + float mean, float threshold) + : selection_ptr_(std::move(selection_ptr)), cloud_ptr_(cloud_ptr), mean_(mean), + threshold_(threshold), removed_indices_(cloud_ptr) + { + } /// @brief Copy constructor - commands are non-copyable - DenoiseCommand(const DenoiseCommand&) = delete; + DenoiseCommand (const DenoiseCommand&) = delete; /// @brief Equal operator - commands are non-copyable DenoiseCommand& - operator=(const DenoiseCommand&) = delete; + operator= (const DenoiseCommand&) = delete; protected: /// @brief Runs the denois algorithm to remove all the outliers. void - execute() override; + execute () override; /// @brief Adds the removed noisy points back to the cloud void - undo() override; + undo () override; private: /// A shared pointer pointing to the selection object of the widget diff --git a/apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/denoiseParameterForm.h b/apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/denoiseParameterForm.h index 72864b988c8..7cd7e3164fa 100644 --- a/apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/denoiseParameterForm.h +++ b/apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/denoiseParameterForm.h @@ -40,68 +40,73 @@ #pragma once +#include #include #include #include -#include #include +#include -class DenoiseParameterForm : public QDialog { +class DenoiseParameterForm : public QDialog +{ Q_OBJECT -public: - /// @brief Default Constructor - DenoiseParameterForm(); + public: + /// @brief Default Constructor + DenoiseParameterForm(); - /// @brief Destructor - ~DenoiseParameterForm() override; + /// @brief Destructor + ~DenoiseParameterForm () override; - /// @brief Returns the mean - inline float - getMeanK() const - { - return (mean_k_); - } + /// @brief Returns the mean + inline + float + getMeanK () const + { + return (mean_k_); + } - /// @brief Returns the standard deviation multiplier threshold - inline float - getStdDevThresh() const - { - return (std_dev_thresh_); - } + /// @brief Returns the standard deviation multiplier threshold + inline + float + getStdDevThresh () const + { + return (std_dev_thresh_); + } - /// @brief Checks whether the OK button was pressed. - inline bool - ok() const - { - return (ok_); - } + /// @brief Checks whether the OK button was pressed. + inline + bool + ok () const + { + return (ok_); + } -private Q_SLOTS: - /// @brief Accepts and stores the current user inputs, and turns off the - /// dialog box. - void - accept() override; + private Q_SLOTS: + /// @brief Accepts and stores the current user inputs, and turns off the + /// dialog box. + void + accept () override; - /// @brief Rejects the current inputs, and turns off the dialog box. - void - reject() override; + /// @brief Rejects the current inputs, and turns off the dialog box. + void + reject () override; -private: - /// The line for entering the mean - QLineEdit* mean_K_line_; - /// The line for entering the standard deviation multiplier threshold - QLineEdit* std_dev_mul_thresh_line_; - /// The button box. - QDialogButtonBox* button_box_; - /// The layout of the two input QLineEdit objects - QFormLayout* layout_; - /// The main layout for the dialog - QVBoxLayout* main_layout_; - /// The mean - float mean_k_; - /// The standard deviation multiplier threshold - float std_dev_thresh_; - /// The flag indicating whether the OK button was pressed - bool ok_{false}; + private: + /// The line for entering the mean + QLineEdit *mean_K_line_; + /// The line for entering the standard deviation multiplier threshold + QLineEdit *std_dev_mul_thresh_line_; + /// The button box. + QDialogButtonBox *button_box_; + /// The layout of the two input QLineEdit objects + QFormLayout *layout_; + /// The main layout for the dialog + QVBoxLayout* main_layout_; + /// The mean + float mean_k_; + /// The standard deviation multiplier threshold + float std_dev_thresh_; + /// The flag indicating whether the OK button was pressed + bool ok_; }; diff --git a/apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/localTypes.h b/apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/localTypes.h index 36e41250f6f..ed7fa8d76d2 100644 --- a/apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/localTypes.h +++ b/apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/localTypes.h @@ -39,11 +39,11 @@ #pragma once -#include #include +#include -#include #include +#include // Forward declaration for commonly used objects class Command; @@ -105,26 +105,44 @@ using CommandQueuePtr = std::shared_ptr; using BitMask = unsigned int; /// ID's for the key modifiers. -enum KeyModifier { +enum KeyModifier +{ NONE = 0x00000000, SHFT = 0x02000000, CTRL = 0x04000000, - ALT = 0x08000000 + ALT = 0x08000000 }; /// ID's for the mouse buttons. -enum MouseButton { NOBUTTON, LEFT, RIGHT }; +enum MouseButton +{ + NOBUTTON, + LEFT, + RIGHT +}; /// Indices for the coordinate axes /// It is assumed that the ColorScheme X,Y,Z match these values -enum Axis { X, Y, Z }; +enum Axis +{ + X, + Y, + Z +}; /// Indices for color components -enum Color { RED, GREEN, BLUE, RGB }; +enum Color +{ + RED, + GREEN, + BLUE, + RGB +}; /// Scheme used for coloring the whole cloud. /// It is assumed that the Axiz X,Y,Z match the COLOR_BY_[X,Y,Z] values -enum ColorScheme { +enum ColorScheme +{ COLOR_BY_X = 0, COLOR_BY_Y, COLOR_BY_Z, @@ -133,11 +151,14 @@ enum ColorScheme { }; /// Simple functor that produces sequential integers from an initial value -struct IncIndex { +struct IncIndex +{ unsigned int val_; - IncIndex(int v = 0) { val_ = v; } - unsigned int - operator()() + IncIndex(int v=0) + { + val_ = v; + } + unsigned int operator()() { return (val_++); } diff --git a/apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/mainWindow.h b/apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/mainWindow.h index f8aeb69a1bc..ded8c6b1c4f 100644 --- a/apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/mainWindow.h +++ b/apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/mainWindow.h @@ -42,201 +42,201 @@ #pragma once -#include - -#include +#include #include +#include +#include +#include +#include #include #include -#include -#include -#include -#include #include +#include // Forward declaration to prevent circular inclusion class CloudEditorWidget; /// @brief the class for point cloud editor -class MainWindow : public QMainWindow { - Q_OBJECT - -public: - /// @brief Constructor - MainWindow(); - - /// @brief Constructor - /// @param argc The number of c-strings to be expected in argv - /// @param argv An array of c-strings. The zero entry is expected to be - /// the name of the application. Any additional strings will be interpreted - /// as filenames designating point clouds to be loaded. - MainWindow(int argc, char** argv); - - /// @brief Destructor - ~MainWindow() override; +class MainWindow : public QMainWindow +{ + Q_OBJECT + + public: + /// @brief Constructor + MainWindow (); + + /// @brief Constructor + /// @param argc The number of c-strings to be expected in argv + /// @param argv An array of c-strings. The zero entry is expected to be + /// the name of the application. Any additional strings will be interpreted + /// as filenames designating point clouds to be loaded. + MainWindow (int argc, char **argv); - /// @brief Increase the value of the spinbox by 1. - void - increaseSpinBoxValue(); + /// @brief Destructor + ~MainWindow () override; - /// @brief Decrease the value of the spinbox by 1. - void - decreaseSpinBoxValue(); + /// @brief Increase the value of the spinbox by 1. + void + increaseSpinBoxValue (); - /// @brief Gets the value of the spinbox. - int - getSpinBoxValue(); + /// @brief Decrease the value of the spinbox by 1. + void + decreaseSpinBoxValue (); - /// @brief Increase the value of the selected pts size spinbox by 1. - void - increaseSelectedSpinBoxValue(); + /// @brief Gets the value of the spinbox. + int + getSpinBoxValue(); - /// @brief Decrease the value of the selected pts size spinbox by 1. - void - decreaseSelectedSpinBoxValue(); + /// @brief Increase the value of the selected pts size spinbox by 1. + void + increaseSelectedSpinBoxValue (); - /// @brief Gets the value of the selected pts size spinbox. - int - getSelectedSpinBoxValue(); + /// @brief Decrease the value of the selected pts size spinbox by 1. + void + decreaseSelectedSpinBoxValue (); -private Q_SLOTS: - void - about(); + /// @brief Gets the value of the selected pts size spinbox. + int + getSelectedSpinBoxValue (); - void - help(); + private Q_SLOTS: + void + about (); -private: - /// Initialization function. This handles the initialization of the widget, - /// menus, actions, etc. - void - initWindow(); + void + help (); - /// create actions which are connected to file menus - void - createActions(); + private: + /// Initialization function. This handles the initialization of the widget, + /// menus, actions, etc. + void + initWindow (); + + /// create actions which are connected to file menus + void + createActions (); - /// create menus such as file and help - void - createMenus(); + /// create menus such as file and help + void + createMenus (); - /// create buttons in the tool bar - void - createToolBars(); + /// create buttons in the tool bar + void + createToolBars (); - /// create spin boxes used in the tool bar. - void - createSpinBoxes(); + /// create spin boxes used in the tool bar. + void + createSpinBoxes (); - /// create sliders used in the tool bar. - void - createSliders(); + /// create sliders used in the tool bar. + void + createSliders (); - /// the cloud editor GL widget - CloudEditorWidget* cloud_editor_widget_; + /// the cloud editor GL widget + CloudEditorWidget *cloud_editor_widget_; - /// the action group for making actions checkable. - QActionGroup* action_group_; + /// the action group for making actions checkable. + QActionGroup* action_group_; - /// action for exit the cloud editor - QAction* exit_action_; + /// action for exit the cloud editor + QAction *exit_action_; - /// action for opening file - QAction* open_action_; + /// action for opening file + QAction *open_action_; - /// action for saving file - QAction* save_action_; + /// action for saving file + QAction *save_action_; - /// action for copying selected points - QAction* copy_action_; + /// action for copying selected points + QAction *copy_action_; - /// action for pasting copied points - QAction* paste_action_; + /// action for pasting copied points + QAction *paste_action_; - /// action for cutting selected points - QAction* cut_action_; + /// action for cutting selected points + QAction *cut_action_; - /// action for deleting selected points - QAction* delete_action_; + /// action for deleting selected points + QAction *delete_action_; - /// action for viewing the software information - QAction* about_action_; + /// action for viewing the software information + QAction *about_action_; - /// action for viewing the software use/control information - QAction* help_action_; + /// action for viewing the software use/control information + QAction *help_action_; - /// action for toggling the pseudo distance display - QAction* toggle_blend_action_; + /// action for toggling the pseudo distance display + QAction *toggle_blend_action_; - /// action for switching to view mode - QAction* view_action_; + /// action for switching to view mode + QAction *view_action_; - /// action for undo - QAction* undo_action_; + /// action for undo + QAction *undo_action_; - /// action for point selection - QAction* select_action_; + /// action for point selection + QAction *select_action_; - /// action for 2D point selection - QAction* select_2D_action_; + /// action for 2D point selection + QAction *select_2D_action_; - /// action for 3D point selection - // QAction *select_3D_action_; + /// action for 3D point selection + //QAction *select_3D_action_; - /// action for box edit - QAction* box_edit_action_; + /// action for box edit + QAction *box_edit_action_; - /// action for invert selection - QAction* invert_select_action_; + /// action for invert selection + QAction *invert_select_action_; - /// action for transforming the cloud - QAction* transform_action_; + /// action for transforming the cloud + QAction *transform_action_; - /// action for denoising the cloud - QAction* denoise_action_; + /// action for denoising the cloud + QAction *denoise_action_; - /// action for showing the statistics of the editor - QAction* show_stat_action_; + /// action for showing the statistics of the editor + QAction *show_stat_action_; - /// the file menu - QMenu* file_menu_; + /// the file menu + QMenu *file_menu_; - /// the menu for editing tools - QMenu* edit_menu_; + /// the menu for editing tools + QMenu *edit_menu_; - /// the menu for display options - QMenu* display_menu_; + /// the menu for display options + QMenu *display_menu_; - /// the menu for visualization tools - QMenu* view_menu_; + /// the menu for visualization tools + QMenu *view_menu_; - /// the menu for select tools - QMenu* select_menu_; + /// the menu for select tools + QMenu *select_menu_; - /// the menu for other algorithmic tools - QMenu* tool_menu_; + /// the menu for other algorithmic tools + QMenu *tool_menu_; - /// the help menu - QMenu* help_menu_; + /// the help menu + QMenu *help_menu_; - /// the spin box for adjusting point size. - QSpinBox* point_size_spin_box_; + /// the spin box for adjusting point size. + QSpinBox *point_size_spin_box_; - /// the spin box for adjusting the size of the selected point. - QSpinBox* selected_point_size_spin_box_; + /// the spin box for adjusting the size of the selected point. + QSpinBox *selected_point_size_spin_box_; - /// the tool bar containing all the cloud editing buttons. - QToolBar* edit_tool_bar_; + /// the tool bar containing all the cloud editing buttons. + QToolBar *edit_tool_bar_; - /// the tool bar containing all the visualization function buttons - QToolBar* view_tool_bar_; + /// the tool bar containing all the visualization function buttons + QToolBar *view_tool_bar_; - /// the width of the main window. - int window_width_; + /// the width of the main window. + int window_width_; - /// the height of the main window. - int window_height_; + /// the height of the main window. + int window_height_; - /// the slider used for adjusting moving speed. - QSlider* move_speed_slider_; + /// the slider used for adjusting moving speed. + QSlider *move_speed_slider_; }; diff --git a/apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/pasteCommand.h b/apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/pasteCommand.h index ebdad385fc6..787e6721dcd 100644 --- a/apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/pasteCommand.h +++ b/apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/pasteCommand.h @@ -42,53 +42,54 @@ #include #include -#include // for pcl::shared_ptr -class PasteCommand : public Command { -public: - /// The type for shared pointer pointing to a selection buffer - using SelectionPtr = pcl::shared_ptr; +#include // for pcl::shared_ptr - /// @brief Constructor - /// @param copy_buffer_ptr a shared pointer pointing to the copy buffer. - /// @param selection_ptr a shared pointer pointing to the selection object. - /// @param cloud_ptr a shared pointer pointing to the cloud object. - PasteCommand(ConstCopyBufferPtr copy_buffer_ptr, - SelectionPtr selection_ptr, - CloudPtr cloud_ptr); - // comment that the selection is updated (also resets the matrix in cloud) +class PasteCommand : public Command +{ + public: + /// The type for shared pointer pointing to a selection buffer + using SelectionPtr = pcl::shared_ptr; - /// @brief Copy constructor - commands are non-copyable - PasteCommand(const PasteCommand&) = delete; + /// @brief Constructor + /// @param copy_buffer_ptr a shared pointer pointing to the copy buffer. + /// @param selection_ptr a shared pointer pointing to the selection object. + /// @param cloud_ptr a shared pointer pointing to the cloud object. + PasteCommand (ConstCopyBufferPtr copy_buffer_ptr, + SelectionPtr selection_ptr, CloudPtr cloud_ptr); + // comment that the selection is updated (also resets the matrix in cloud) - /// @brief Equal operator - commands are non-copyable - PasteCommand& - operator=(const PasteCommand&) = delete; + /// @brief Copy constructor - commands are non-copyable + PasteCommand (const PasteCommand&) = delete; -protected: - /// @brief Appends the points in the copy buffer into the cloud. - /// @details After appending the points to the cloud, this function also - /// updates the selection object to point to the newly pasted points. This - /// also updates the selection object to point to the newly pasted points. - void - execute() override; + /// @brief Equal operator - commands are non-copyable + PasteCommand& + operator= (const PasteCommand&) = delete; + + protected: + /// @brief Appends the points in the copy buffer into the cloud. + /// @details After appending the points to the cloud, this function also + /// updates the selection object to point to the newly pasted points. This + /// also updates the selection object to point to the newly pasted points. + void + execute () override; - /// @brief Removes the points that were pasted to the cloud. - void - undo() override; + /// @brief Removes the points that were pasted to the cloud. + void + undo () override; -private: - /// a pointer pointing to the copy buffer. - ConstCopyBufferPtr copy_buffer_ptr_; + private: + /// a pointer pointing to the copy buffer. + ConstCopyBufferPtr copy_buffer_ptr_; - /// A shared pointer pointing to the selection object. - SelectionPtr selection_ptr_; + /// A shared pointer pointing to the selection object. + SelectionPtr selection_ptr_; - /// a pointer pointing to the cloud - CloudPtr cloud_ptr_; + /// a pointer pointing to the cloud + CloudPtr cloud_ptr_; - /// The size of the cloud before new points are pasted. This value is used - /// to mark the point where points were added to the cloud. In order to - /// support undo, one only has to resize the cloud using this value. - unsigned int prev_cloud_size_; + /// The size of the cloud before new points are pasted. This value is used + /// to mark the point where points were added to the cloud. In order to + /// support undo, one only has to resize the cloud using this value. + unsigned int prev_cloud_size_; }; diff --git a/apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/select1DTool.h b/apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/select1DTool.h index 4e3365e0896..ee34d7d7502 100644 --- a/apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/select1DTool.h +++ b/apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/select1DTool.h @@ -39,69 +39,78 @@ #pragma once -#include #include -#include // for pcl::shared_ptr +#include + +#include // for pcl::shared_ptr #include class Selection; -class Select1DTool : public ToolInterface { -public: - /// The type for shared pointer pointing to a selection buffer - using SelectionPtr = pcl::shared_ptr; - - /// @brief Constructor - /// @param selection_ptr a shared pointer pointing to the selection object. - /// @param cloud_ptr a shared pointer pointing to the cloud object. - Select1DTool(SelectionPtr selection_ptr, CloudPtr cloud_ptr); - - /// @brief Destructor - ~Select1DTool() override = default; +class Select1DTool : public ToolInterface +{ + public: + /// The type for shared pointer pointing to a selection buffer + using SelectionPtr = pcl::shared_ptr; - /// @brief Does nothing for 1D selection. - /// @sa end - void - start(int, int, BitMask, BitMask) override - {} + /// @brief Constructor + /// @param selection_ptr a shared pointer pointing to the selection object. + /// @param cloud_ptr a shared pointer pointing to the cloud object. + Select1DTool (SelectionPtr selection_ptr, CloudPtr cloud_ptr); - /// @brief Does nothing for 1D selection. - /// @sa end - void - update(int, int, BitMask, BitMask) override - {} + /// @brief Destructor + ~Select1DTool () override + = default; + + /// @brief Does nothing for 1D selection. + /// @sa end + void + start (int, int, BitMask, BitMask) override + { + } + + /// @brief Does nothing for 1D selection. + /// @sa end + void + update (int, int, BitMask, BitMask) override + { + } - /// @brief Select or deselect the point under the mouse using GL's selection - /// facility. - /// @details If shift is pressed when the selection is made, the selected - /// point is appended to the existing selection. If instead ctrl is pressed, - /// the selected point will be removed from the existing selection. If - /// neither shift nor ctrl is pressed when the selection is made then the - /// selected point, if any, will replace any current selection. Note that - /// the ctrl key may be evaluated as the command key in OSX. - /// @param x the x value of the mouse screen coordinates. - /// @param y the y value of the mouse screen coordinates. - /// @param modifiers the key modifier. SHIFT adds selected points to the - /// selection. CTRL removes points and if neither are pressed then a new - /// selection is made. - /// @param buttons The state of the mouse buttons. All interaction with - /// this tool requires the LEFT mouse button. All others are ignored. - void - end(int x, int y, BitMask modifiers, BitMask buttons) override; + /// @brief Select or deselect the point under the mouse using GL's selection + /// facility. + /// @details If shift is pressed when the selection is made, the selected + /// point is appended to the existing selection. If instead ctrl is pressed, + /// the selected point will be removed from the existing selection. If + /// neither shift nor ctrl is pressed when the selection is made then the + /// selected point, if any, will replace any current selection. Note that + /// the ctrl key may be evaluated as the command key in OSX. + /// @param x the x value of the mouse screen coordinates. + /// @param y the y value of the mouse screen coordinates. + /// @param modifiers the key modifier. SHIFT adds selected points to the + /// selection. CTRL removes points and if neither are pressed then a new + /// selection is made. + /// @param buttons The state of the mouse buttons. All interaction with + /// this tool requires the LEFT mouse button. All others are ignored. + void + end (int x, int y, BitMask modifiers, BitMask buttons) override; - /// @brief This function does nothing. - void - draw() const override - {} + /// @brief This function does nothing. + void + draw () const override + { + } -private: - /// @brief Default constructor - object is not default constructable - Select1DTool() { assert(false); } + private: + /// @brief Default constructor - object is not default constructable + Select1DTool() + { + assert(false); + } - /// a shared pointer pointing to the selection object - SelectionPtr selection_ptr_; + /// a shared pointer pointing to the selection object + SelectionPtr selection_ptr_; - /// a shared pointer pointing to the cloud object - CloudPtr cloud_ptr_; + /// a shared pointer pointing to the cloud object + CloudPtr cloud_ptr_; }; diff --git a/apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/select2DTool.h b/apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/select2DTool.h index b1936484f23..6243fcc65a6 100644 --- a/apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/select2DTool.h +++ b/apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/select2DTool.h @@ -40,118 +40,121 @@ #pragma once -#include +#include #include -#include // for pcl::shared_ptr +#include -#include +#include // for pcl::shared_ptr class Selection; -class Select2DTool : public ToolInterface { -public: - /// The type for shared pointer pointing to a selection buffer - using SelectionPtr = pcl::shared_ptr; - - /// @brief Constructor - /// @param selection_ptr a shared pointer pointing to the selection object. - /// @param cloud_ptr a shared pointer pointing to the cloud object. - /// @param get_viewport_and_projection_mat a function that can be used to get the - /// viewport and the projection matrix - Select2DTool(SelectionPtr selection_ptr, - CloudPtr cloud_ptr, - std::function get_viewport_and_projection_mat); - - /// @brief Destructor - ~Select2DTool() override; - - /// @brief Initializes the selection tool with the initial mouse screen - /// coordinates and key modifiers. The passed coordinates are used for - /// determining the coordinates of the upper left corner of the rubber band. - /// @param x the x value of the mouse screen coordinates. - /// @param y the y value of the mouse screen coordinates. - /// @param modifiers the key modifier. There are three possible values for - /// modifiers: 1. shift key, 2. ctrl key, 3. no modifier is pressed. Note - /// that the ctrl key may be evaluated as the command key in OSX. - void - start(int x, int y, BitMask modifiers, BitMask mouseButton) override; - - /// @brief Update the selection tool from the current mouse screen - /// coordinates and key modifiers. - /// @details Creates a 2D rubberband. The coordinates of the lower right - /// corner of the rubberband is computed from the passed coordinates. - /// @param x the x value of the mouse screen coordinates. - /// @param y the y value of the mouse screen coordinates. - /// @param modifiers the key modifier. - void - update(int x, int y, BitMask modifiers, BitMask mouseButton) override; - - /// @brief Update the coordinates of the lower right corner of the rubber - /// band and process the points in the rubber band. - /// @details The points which fall into the selection region are processed - /// according to the value of the modifier: If shift is pressed, the - /// selected points are appended to the existing selection. If ctrl is - /// pressed, the points will be removed from the existing selection - /// if they were elected previously, otherwise nothing happens. - /// @param x the x value of the mouse screen coordinates. - /// @param y the y value of the mouse screen coordinates. - /// @param modifiers the key modifier. - void - end(int x, int y, BitMask modifiers, BitMask mouseButton) override; - - /// @brief Checks whether a point is inside the selection region. - /// @param pt the point to be checked against the selection region. - /// @param project the projection matrix obtained from GL. - /// @param viewport the current viewport obtained from GL. - bool - isInSelectBox(const Point3D& pt, const GLfloat* project, const GLint* viewport) const; - - /// @brief Draws the rubber band as well as any highlighted points during - /// the 'update' phase (i.e. before the selection is made by a call to end). - void - draw() const override; - - /// The default size in pixels of the rubberband tool outline - static const float DEFAULT_TOOL_DISPLAY_SIZE_; - - /// The default color of the rubberband tool - red component - static const float DEFAULT_TOOL_DISPLAY_COLOR_RED_; - /// The default color of the rubberband tool - green component - static const float DEFAULT_TOOL_DISPLAY_COLOR_GREEN_; - /// The default color of the rubberband tool - blue component - static const float DEFAULT_TOOL_DISPLAY_COLOR_BLUE_; - -private: - /// @brief Default constructor - object is not default constructable - Select2DTool() { assert(false); } - - /// @brief draw the 2D selection rubber band. - /// @param viewport the viewport obtained from GL - void - drawRubberBand(GLint* viewport) const; - - /// @brief highlight all the points in the rubber band. - /// @detail draw the cloud using a stencil buffer. During this time, the - /// points that are highlighted will not be recorded by the selection object. - /// @param viewport the viewport obtained from GL - void - highlightPoints(GLint* viewport) const; - - /// a shared pointer pointing to the selection object - SelectionPtr selection_ptr_; - - /// a shared pointer pointing to the cloud object - CloudPtr cloud_ptr_; - - /// the original mouse screen coordinates - int origin_x_, origin_y_; - - /// the final mouse screen coordinates - int final_x_, final_y_; - - /// switch for selection box rendering - bool display_box_; - - /// function to get the viewport and the projection matrix (initialized by ctor) - std::function get_viewport_and_projection_mat_; +class Select2DTool : public ToolInterface +{ + public: + /// The type for shared pointer pointing to a selection buffer + using SelectionPtr = pcl::shared_ptr; + + /// @brief Constructor + /// @param selection_ptr a shared pointer pointing to the selection object. + /// @param cloud_ptr a shared pointer pointing to the cloud object. + /// @param get_viewport_and_projection_mat a function that can be used to get the viewport and the projection matrix + Select2DTool (SelectionPtr selection_ptr, CloudPtr cloud_ptr, std::function get_viewport_and_projection_mat); + + /// @brief Destructor + ~Select2DTool () override; + + /// @brief Initializes the selection tool with the initial mouse screen + /// coordinates and key modifiers. The passed coordinates are used for + /// determining the coordinates of the upper left corner of the rubber band. + /// @param x the x value of the mouse screen coordinates. + /// @param y the y value of the mouse screen coordinates. + /// @param modifiers the key modifier. There are three possible values for + /// modifiers: 1. shift key, 2. ctrl key, 3. no modifier is pressed. Note + /// that the ctrl key may be evaluated as the command key in OSX. + void + start (int x, int y, BitMask modifiers, BitMask mouseButton) override; + + /// @brief Update the selection tool from the current mouse screen + /// coordinates and key modifiers. + /// @details Creates a 2D rubberband. The coordinates of the lower right + /// corner of the rubberband is computed from the passed coordinates. + /// @param x the x value of the mouse screen coordinates. + /// @param y the y value of the mouse screen coordinates. + /// @param modifiers the key modifier. + void + update (int x, int y, BitMask modifiers, BitMask mouseButton) override; + + /// @brief Update the coordinates of the lower right corner of the rubber + /// band and process the points in the rubber band. + /// @details The points which fall into the selection region are processed + /// according to the value of the modifier: If shift is pressed, the + /// selected points are appended to the existing selection. If ctrl is + /// pressed, the points will be removed from the existing selection + /// if they were elected previously, otherwise nothing happens. + /// @param x the x value of the mouse screen coordinates. + /// @param y the y value of the mouse screen coordinates. + /// @param modifiers the key modifier. + void + end (int x, int y, BitMask modifiers, BitMask mouseButton) override; + + /// @brief Checks whether a point is inside the selection region. + /// @param pt the point to be checked against the selection region. + /// @param project the projection matrix obtained from GL. + /// @param viewport the current viewport obtained from GL. + bool + isInSelectBox (const Point3D& pt, const GLfloat* project, + const GLint* viewport) const; + + /// @brief Draws the rubber band as well as any highlighted points during + /// the 'update' phase (i.e. before the selection is made by a call to end). + void + draw () const override; + + /// The default size in pixels of the rubberband tool outline + static const float DEFAULT_TOOL_DISPLAY_SIZE_; + + /// The default color of the rubberband tool - red component + static const float DEFAULT_TOOL_DISPLAY_COLOR_RED_; + /// The default color of the rubberband tool - green component + static const float DEFAULT_TOOL_DISPLAY_COLOR_GREEN_; + /// The default color of the rubberband tool - blue component + static const float DEFAULT_TOOL_DISPLAY_COLOR_BLUE_; + + + private: + /// @brief Default constructor - object is not default constructable + Select2DTool() + { + assert(false); + } + + /// @brief draw the 2D selection rubber band. + /// @param viewport the viewport obtained from GL + void + drawRubberBand (GLint* viewport) const; + + /// @brief highlight all the points in the rubber band. + /// @detail draw the cloud using a stencil buffer. During this time, the + /// points that are highlighted will not be recorded by the selection object. + /// @param viewport the viewport obtained from GL + void + highlightPoints (GLint* viewport) const; + + /// a shared pointer pointing to the selection object + SelectionPtr selection_ptr_; + + /// a shared pointer pointing to the cloud object + CloudPtr cloud_ptr_; + + /// the original mouse screen coordinates + int origin_x_, origin_y_; + + /// the final mouse screen coordinates + int final_x_, final_y_; + + /// switch for selection box rendering + bool display_box_; + + /// function to get the viewport and the projection matrix (initialized by ctor) + std::function get_viewport_and_projection_mat_; }; diff --git a/apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/selection.h b/apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/selection.h index 7c11caf6712..d0e471517fe 100644 --- a/apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/selection.h +++ b/apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/selection.h @@ -40,148 +40,150 @@ #pragma once +#include #include #include -#include - /// @brief This class serves as a sort of mask for performing operations on a /// point cloud. It keeps track of the indices of identified/selected points /// and provides methods for accessing those indices and modifying them. -class Selection : public Statistics { -public: - /// @brief Constructor. - /// @param cloud_ptr A pointer to the const cloud object for which this - /// object is to maintain selections. - Selection(ConstCloudPtr cloud_ptr, bool register_stats = false) - : cloud_ptr_(std::move(cloud_ptr)) - { - if (register_stats) - registerStats(); - } - - /// @brief Copy constructor. - /// @param selection a const reference to a selection object whose - /// properties will be copied. - Selection(const Selection& selection) = default; - - /// @brief Equal operator - /// @param selection a const reference to a selection object whose - /// properties will be copied. - Selection& - operator=(const Selection& selection); - - /// @brief Adds the index of the selected point to the selection table. - /// @param index The index of the point that is selected. - /// @pre Assumes the passed index is valid with respect to the current - /// cloud. - void - addIndex(unsigned int index); - - /// @brief Removes the index of a point from the selection table. - /// @param index The index of the point to be removed from the table. - void - removeIndex(unsigned int index); - - /// @brief Adds a vector of indices of the selected points to the table. - /// @param indices A vector of indices of points to be added to the table. - /// @pre Assumes the passed index is valid with respect to the current - /// cloud. - void - addIndex(const IndexVector& indices); - - /// @brief Removes a vector of indices from the table - /// @param indices A vector of indices of points to be removed from the - /// table. - void - removeIndex(const IndexVector& indices); - - /// @brief Adds a range of consecutive indices into the selection table. - /// @param start the first index in the range. - /// @param num the total number of indices in the range. - /// @pre Assumes the passed index is valid with respect to the current - /// cloud. - void - addIndexRange(unsigned int start, unsigned int num); - - /// @brief Removes a range of consecutive indices into the selection table. - /// @param start the first index in the range. - /// @param num the total number of indices in the range. - void - removeIndexRange(unsigned int start, unsigned int num); - - /// @brief Removes all the indices from the selection table. - void - clear() - { - selected_indices_.clear(); - } - - using iterator = std::set::iterator; - using const_iterator = std::set::const_iterator; - - /// @brief Get the begin iterator of the selection. - const_iterator - begin() const - { - return (selected_indices_.begin()); - } - - /// @brief Get the end iterator of the selection. - const_iterator - end() const - { - return (selected_indices_.end()); - } - - using const_reverse_iterator = std::set::const_reverse_iterator; - - /// @brief Get the begin iterator of the selection. - const_reverse_iterator - rbegin() const - { - return (selected_indices_.rbegin()); - } - - /// @brief Get the end iterator of the selection. - const_reverse_iterator - rend() const - { - return (selected_indices_.rend()); - } - - /// @brief Returns true if the passed index is selected. - bool - isSelected(unsigned int index) const; - - /// @brief Returns true if no point is selected. - inline bool - empty() const - { - return (selected_indices_.empty()); - } - - /// @brief Returns the number of points in the selection - inline unsigned int - size() const - { - return (selected_indices_.size()); - } - - /// @brief Invert selection - /// @details Make the unselected points selected and deselect the previously - /// selected points. - void - invertSelect(); - - /// @brief Get the statistics of the selected points in string. - std::string - getStat() const override; - -private: - /// a pointer to the cloud - ConstCloudPtr cloud_ptr_; - - /// A set of unique indices that have been selected in the cloud. - std::set selected_indices_; +class Selection : public Statistics +{ + public: + /// @brief Constructor. + /// @param cloud_ptr A pointer to the const cloud object for which this + /// object is to maintain selections. + Selection (ConstCloudPtr cloud_ptr, bool register_stats=false) + : cloud_ptr_(std::move(cloud_ptr)) + { + if (register_stats) + registerStats(); + } + + /// @brief Copy constructor. + /// @param selection a const reference to a selection object whose + /// properties will be copied. + Selection (const Selection& selection) = default; + + /// @brief Equal operator + /// @param selection a const reference to a selection object whose + /// properties will be copied. + Selection& + operator= (const Selection& selection); + + /// @brief Adds the index of the selected point to the selection table. + /// @param index The index of the point that is selected. + /// @pre Assumes the passed index is valid with respect to the current + /// cloud. + void + addIndex (unsigned int index); + + /// @brief Removes the index of a point from the selection table. + /// @param index The index of the point to be removed from the table. + void + removeIndex (unsigned int index); + + /// @brief Adds a vector of indices of the selected points to the table. + /// @param indices A vector of indices of points to be added to the table. + /// @pre Assumes the passed index is valid with respect to the current + /// cloud. + void + addIndex (const IndexVector &indices); + + /// @brief Removes a vector of indices from the table + /// @param indices A vector of indices of points to be removed from the + /// table. + void + removeIndex (const IndexVector &indices); + + /// @brief Adds a range of consecutive indices into the selection table. + /// @param start the first index in the range. + /// @param num the total number of indices in the range. + /// @pre Assumes the passed index is valid with respect to the current + /// cloud. + void + addIndexRange (unsigned int start, unsigned int num); + + /// @brief Removes a range of consecutive indices into the selection table. + /// @param start the first index in the range. + /// @param num the total number of indices in the range. + void + removeIndexRange (unsigned int start, unsigned int num); + + /// @brief Removes all the indices from the selection table. + void + clear () + { + selected_indices_.clear(); + } + + using iterator = std::set::iterator; + using const_iterator = std::set::const_iterator; + + /// @brief Get the begin iterator of the selection. + const_iterator + begin () const + { + return (selected_indices_.begin()); + } + + /// @brief Get the end iterator of the selection. + const_iterator + end () const + { + return (selected_indices_.end()); + } + + using const_reverse_iterator = std::set::const_reverse_iterator; + + /// @brief Get the begin iterator of the selection. + const_reverse_iterator + rbegin () const + { + return (selected_indices_.rbegin()); + } + + /// @brief Get the end iterator of the selection. + const_reverse_iterator + rend () const + { + return (selected_indices_.rend()); + } + + /// @brief Returns true if the passed index is selected. + bool + isSelected (unsigned int index) const; + + /// @brief Returns true if no point is selected. + inline + bool + empty () const + { + return (selected_indices_.empty()); + } + + /// @brief Returns the number of points in the selection + inline + unsigned int + size () const + { + return (selected_indices_.size()); + } + + /// @brief Invert selection + /// @details Make the unselected points selected and deselect the previously + /// selected points. + void + invertSelect (); + + /// @brief Get the statistics of the selected points in string. + std::string + getStat () const override; + + private: + /// a pointer to the cloud + ConstCloudPtr cloud_ptr_; + + /// A set of unique indices that have been selected in the cloud. + std::set selected_indices_; }; diff --git a/apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/selectionTransformTool.h b/apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/selectionTransformTool.h index 8b7cb0b0a58..d555f007e54 100644 --- a/apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/selectionTransformTool.h +++ b/apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/selectionTransformTool.h @@ -39,10 +39,11 @@ #pragma once -#include #include +#include #include -#include // for pcl::shared_ptr + +#include // for pcl::shared_ptr class Selection; @@ -53,115 +54,116 @@ class Selection; /// points are not updated until the end of the mouse input. At the end of a /// mouse input (i.e. when the mouse button is released), a transform command is /// created to update the actual coordinates of the selected points. -class SelectionTransformTool : public ToolInterface { -public: - /// The type for shared pointer pointing to a constant selection buffer - using ConstSelectionPtr = pcl::shared_ptr; - - /// @brief Constructor - /// @param selection_ptr a shared pointer pointing to the selection object. - /// @param cloud_ptr a shared pointer pointing to the cloud object. - /// @param command_queue_ptr a shared pointer pointing to the command queue. - SelectionTransformTool(ConstSelectionPtr selection_ptr, - CloudPtr cloud_ptr, - CommandQueuePtr command_queue_ptr); - - /// @brief Destructor - ~SelectionTransformTool() override = default; - - /// @brief Initialize the transform tool with mouse screen coordinates - /// and key modifiers. - /// @param x the x value of the mouse screen coordinates. - /// @param y the y value of the mouse screen coordinates. - /// @param modifiers the key modifier. - void - start(int x, int y, BitMask modifiers, BitMask buttons) override; - - /// @brief Updates the transform matrix of this object with mouse screen - /// coordinates and key modifiers. Then the selection_matrix_ in the cloud - /// is further updated. - /// @details We first compute the changes between the initial and the current - /// mouse screen coordinates. Then depending on the passed modifiers, the - /// transformation matrix is computed correspondingly. If CONTROL is pressed - /// the selection will be translated (panned) parallel to the view plane. If - /// ALT is pressed the selection will be translated along the z-axis - /// perpendicular to the view plane. If no key modifiers is pressed the - /// selection will be rotated. - /// @param x the x value of the mouse screen coordinates. - /// @param y the y value of the mouse screen coordinates. - /// @param modifiers the key modifier. CONTROL pans the selection parallel - /// to the view plane. ALT moves the selection in/out along the z-axis - /// (perpendicular to the view plane). If no modifier is pressed then the - /// selection is rotated. - void - update(int x, int y, BitMask modifiers, BitMask buttons) override; - - /// @brief Update the transform matrix for the selected points using the - /// final position of the mouse. To finalize the transformation, we then - /// create a transform command which computes the new coordinates of the - /// selected points after transformation. - /// @param x the x value of the mouse screen coordinates. - /// @param y the y value of the mouse screen coordinates. - /// @param modifiers the key modifier. - void - end(int x, int y, BitMask modifiers, BitMask buttons) override; - - /// @brief This does not do anything. - void - draw() const override - {} - -private: - /// @brief Computes the modelview matrix for rotation. - /// @param dx the distance between the x coordinates of the starting and - /// ending cursor position. - /// @param dy the distance between the y coordinates of the starting and - /// ending cursor position. - /// @param rotation_matrix_a a 4x4 matrix following OpenGL's format - /// implementing rotation along x-axis. - /// @param rotation_matrix_b a 4x4 matrix following OpenGL's format - /// implementing rotation along y or z-axis, which depens on which the mouse - /// button that is being pressed during the rotation operation. - void - getRotateMatrix(int dx, - int dy, - float* rotation_matrix_a, - float* rotation_matrix_b, - BitMask buttons) const; - - /// @brief Computes the centroid of the selected points - void - findSelectionCenter(); - - /// a shared pointer pointing to the selection object - ConstSelectionPtr selection_ptr_; - - /// a shared pointer pointing to the cloud object - CloudPtr cloud_ptr_; - - /// a shared pointer pointing to the command queue of the widget. - CommandQueuePtr command_queue_ptr_; - - /// the trackball associated with this transform - TrackBall trackball_; - - /// last recorded mouse positions - int x_, y_; - - /// The centroid of the selected points. - float center_xyz_[XYZ_SIZE]; - - /// the transform matrix to be used for updating the coordinates of the - /// selected points in the cloud - float transform_matrix_[MATRIX_SIZE]; - - /// scaling factor used to control the speed which the display translates - /// the point cloud - float translate_factor_; - - /// default translation factor - static const float DEFAULT_TRANSLATE_FACTOR_; - - /// the copy of the modifiers passed in the start function. - BitMask modifiers_; +class SelectionTransformTool : public ToolInterface +{ + public: + /// The type for shared pointer pointing to a constant selection buffer + using ConstSelectionPtr = pcl::shared_ptr; + + /// @brief Constructor + /// @param selection_ptr a shared pointer pointing to the selection object. + /// @param cloud_ptr a shared pointer pointing to the cloud object. + /// @param command_queue_ptr a shared pointer pointing to the command queue. + SelectionTransformTool (ConstSelectionPtr selection_ptr, + CloudPtr cloud_ptr, + CommandQueuePtr command_queue_ptr); + + /// @brief Destructor + ~SelectionTransformTool () override + = default; + + /// @brief Initialize the transform tool with mouse screen coordinates + /// and key modifiers. + /// @param x the x value of the mouse screen coordinates. + /// @param y the y value of the mouse screen coordinates. + /// @param modifiers the key modifier. + void + start (int x, int y, BitMask modifiers, BitMask buttons) override; + + /// @brief Updates the transform matrix of this object with mouse screen + /// coordinates and key modifiers. Then the selection_matrix_ in the cloud + /// is further updated. + /// @details We first compute the changes between the initial and the current + /// mouse screen coordinates. Then depending on the passed modifiers, the + /// transformation matrix is computed correspondingly. If CONTROL is pressed + /// the selection will be translated (panned) parallel to the view plane. If + /// ALT is pressed the selection will be translated along the z-axis + /// perpendicular to the view plane. If no key modifiers is pressed the + /// selection will be rotated. + /// @param x the x value of the mouse screen coordinates. + /// @param y the y value of the mouse screen coordinates. + /// @param modifiers the key modifier. CONTROL pans the selection parallel + /// to the view plane. ALT moves the selection in/out along the z-axis + /// (perpendicular to the view plane). If no modifier is pressed then the + /// selection is rotated. + void + update (int x, int y, BitMask modifiers, BitMask buttons) override; + + /// @brief Update the transform matrix for the selected points using the + /// final position of the mouse. To finalize the transformation, we then + /// create a transform command which computes the new coordinates of the + /// selected points after transformation. + /// @param x the x value of the mouse screen coordinates. + /// @param y the y value of the mouse screen coordinates. + /// @param modifiers the key modifier. + void + end (int x, int y, BitMask modifiers, BitMask buttons) override; + + /// @brief This does not do anything. + void + draw () const override + { + } + + private: + /// @brief Computes the modelview matrix for rotation. + /// @param dx the distance between the x coordinates of the starting and + /// ending cursor position. + /// @param dy the distance between the y coordinates of the starting and + /// ending cursor position. + /// @param rotation_matrix_a a 4x4 matrix following OpenGL's format + /// implementing rotation along x-axis. + /// @param rotation_matrix_b a 4x4 matrix following OpenGL's format + /// implementing rotation along y or z-axis, which depens on which the mouse + /// button that is being pressed during the rotation operation. + void + getRotateMatrix (int dx, int dy, float* rotation_matrix_a, + float* rotation_matrix_b, BitMask buttons) const; + + /// @brief Computes the centroid of the selected points + void + findSelectionCenter (); + + /// a shared pointer pointing to the selection object + ConstSelectionPtr selection_ptr_; + + /// a shared pointer pointing to the cloud object + CloudPtr cloud_ptr_; + + /// a shared pointer pointing to the command queue of the widget. + CommandQueuePtr command_queue_ptr_; + + /// the trackball associated with this transform + TrackBall trackball_; + + /// last recorded mouse positions + int x_, y_; + + /// The centroid of the selected points. + float center_xyz_[XYZ_SIZE]; + + /// the transform matrix to be used for updating the coordinates of the + /// selected points in the cloud + float transform_matrix_[MATRIX_SIZE]; + + /// scaling factor used to control the speed which the display translates + /// the point cloud + float translate_factor_; + + /// default translation factor + static const float DEFAULT_TRANSLATE_FACTOR_; + + /// the copy of the modifiers passed in the start function. + BitMask modifiers_; + }; diff --git a/apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/statistics.h b/apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/statistics.h index 91d2cf7d7cc..80d3fc4744d 100644 --- a/apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/statistics.h +++ b/apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/statistics.h @@ -40,47 +40,55 @@ #pragma once -#include - -#include -#include #include +#include +#include +#include -class Statistics { -public: - /// @brief Destructor - virtual ~Statistics() = default; - - /// @brief Returns the strings of the statistics. - static std::string - getStats(); - - static void - clear(); - -protected: - /// @brief The default constructor. - Statistics() = default; +class Statistics +{ + public: + /// @brief Destructor + virtual ~Statistics () + = default; - /// @brief Copy Constructor - Statistics(const Statistics&) { assert(false); } + /// @brief Returns the strings of the statistics. + static + std::string + getStats(); + + static + void + clear(); + + protected: + /// @brief The default constructor. + Statistics () + = default; - /// @brief Equal Operator - virtual Statistics& - operator=(const Statistics&) - { - assert(false); - return *this; - } + /// @brief Copy Constructor + Statistics (const Statistics&) + { + assert(false); + } - /// @brief Returns the statistics in string. - virtual std::string - getStat() const = 0; + /// @brief Equal Operator + virtual + Statistics& + operator= (const Statistics&) + { + assert(false); return (*this); + } - /// @brief Register a statistics - void - registerStats(); + /// @brief Returns the statistics in string. + virtual + std::string + getStat () const = 0; -private: - static std::vector stat_vec_; + /// @brief Register a statistics + void + registerStats (); + + private: + static std::vector stat_vec_; }; diff --git a/apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/statisticsDialog.h b/apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/statisticsDialog.h index 2d7f0c7dbfe..59ee72f4098 100644 --- a/apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/statisticsDialog.h +++ b/apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/statisticsDialog.h @@ -40,40 +40,39 @@ #pragma once -#include - +#include #include #include #include -#include +#include #include +#include #include -#include +#include -class StatisticsDialog : public QDialog { +class StatisticsDialog : public QDialog +{ Q_OBJECT -public: - /// @brief Default Constructor - StatisticsDialog(QWidget* parent = nullptr); - /// @brief Destructor - ~StatisticsDialog() override; - -public Q_SLOTS: - /// @brief update the dialog box. - void - update(); - -private Q_SLOTS: - void - accept() override; - -private: - /// The button box. - QDialogButtonBox* button_box_; + public: + /// @brief Default Constructor + StatisticsDialog(QWidget *parent = nullptr); + /// @brief Destructor + ~StatisticsDialog () override; + + public Q_SLOTS: + /// @brief update the dialog box. + void update (); + + private Q_SLOTS: + void accept () override; + + private: + /// The button box. + QDialogButtonBox *button_box_; - QLabel* stat_label_; + QLabel *stat_label_; - /// A timer used for periodically update the statistics in the dialog. - QTimer timer_; + /// A timer used for periodically update the statistics in the dialog. + QTimer timer_; }; diff --git a/apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/toolInterface.h b/apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/toolInterface.h index 0beb4316147..38111acba28 100644 --- a/apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/toolInterface.h +++ b/apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/toolInterface.h @@ -46,67 +46,76 @@ #include /// @brief the parent class of all the select and the transform tool classes -class ToolInterface { -public: - /// @brief Destructor. - virtual ~ToolInterface() = default; +class ToolInterface +{ + public: + /// @brief Destructor. + virtual ~ToolInterface () + = default; - /// @brief set the initial state of the tool from the screen coordinates - /// of the mouse as well as the value of the modifier. - /// @param x the x coordinate of the mouse screen coordinates. - /// @param y the y coordinate of the mouse screen coordinates. - /// @param modifiers The keyboard modifiers. We use modifier to change the - /// behavior of a tool. Values of a modifier can be control key, alt key - /// shift key, or no key is pressed. See the subclasses of this class - /// for specific usages of the modifiers. - /// @param buttons The state of the mouse buttons - virtual void - start(int x, int y, BitMask modifiers, BitMask buttons) = 0; + /// @brief set the initial state of the tool from the screen coordinates + /// of the mouse as well as the value of the modifier. + /// @param x the x coordinate of the mouse screen coordinates. + /// @param y the y coordinate of the mouse screen coordinates. + /// @param modifiers The keyboard modifiers. We use modifier to change the + /// behavior of a tool. Values of a modifier can be control key, alt key + /// shift key, or no key is pressed. See the subclasses of this class + /// for specific usages of the modifiers. + /// @param buttons The state of the mouse buttons + virtual + void + start (int x, int y, BitMask modifiers, BitMask buttons) = 0; - /// @brief update the state of the tool from the screen coordinates - /// of the mouse as well as the value of the modifier. - /// @param x the x coordinate of the mouse screen coordinates. - /// @param y the y coordinate of the mouse screen coordinates. - /// @param modifiers The keyboard modifiers. We use modifier to change the - /// behavior of a tool. Values of a modifier can be control key, alt key - /// shift key, or no key is pressed. See the subclasses of this class - /// for specific usages of the modifiers. - /// @param buttons The state of the mouse buttons - virtual void - update(int x, int y, BitMask modifiers, BitMask buttons) = 0; + /// @brief update the state of the tool from the screen coordinates + /// of the mouse as well as the value of the modifier. + /// @param x the x coordinate of the mouse screen coordinates. + /// @param y the y coordinate of the mouse screen coordinates. + /// @param modifiers The keyboard modifiers. We use modifier to change the + /// behavior of a tool. Values of a modifier can be control key, alt key + /// shift key, or no key is pressed. See the subclasses of this class + /// for specific usages of the modifiers. + /// @param buttons The state of the mouse buttons + virtual + void + update (int x, int y, BitMask modifiers, BitMask buttons) = 0; - /// @brief set final state of the tool from the screen coordinates - /// of the mouse as well as the value of the modifier. Also performs the - /// corresponding functionalities of the tool. - /// @param x the x coordinate of the mouse screen coordinates. - /// @param y the y coordinate of the mouse screen coordinates. - /// @param modifiers The keyboard modifiers. We use modifier to change the - /// behavior of a tool. Values of a modifier can be control key, alt key - /// shift key, or no key is pressed. See the subclasses of this class - /// for specific usages of the modifiers. - /// @param buttons The state of the mouse buttons - virtual void - end(int x, int y, BitMask modifiers, BitMask buttons) = 0; + /// @brief set final state of the tool from the screen coordinates + /// of the mouse as well as the value of the modifier. Also performs the + /// corresponding functionalities of the tool. + /// @param x the x coordinate of the mouse screen coordinates. + /// @param y the y coordinate of the mouse screen coordinates. + /// @param modifiers The keyboard modifiers. We use modifier to change the + /// behavior of a tool. Values of a modifier can be control key, alt key + /// shift key, or no key is pressed. See the subclasses of this class + /// for specific usages of the modifiers. + /// @param buttons The state of the mouse buttons + virtual + void + end (int x, int y, BitMask modifiers, BitMask buttons) = 0; + + /// @brief a rendering facility used by a tool. For instance, if this tool + /// is a selection tool, this function draws highlighted points as well as + /// selection region, e.g., rubberband, box, etc. + virtual + void + draw () const = 0; + + protected: + /// @brief Default constructor + ToolInterface () + = default; - /// @brief a rendering facility used by a tool. For instance, if this tool - /// is a selection tool, this function draws highlighted points as well as - /// selection region, e.g., rubberband, box, etc. - virtual void - draw() const = 0; + private: + /// @brief Copy constructor - tools are non-copyable + ToolInterface (const ToolInterface&) + { + assert(false); + } -protected: - /// @brief Default constructor - ToolInterface() = default; - -private: - /// @brief Copy constructor - tools are non-copyable - ToolInterface(const ToolInterface&) { assert(false); } - - /// @brief Equal operator - tools are non-copyable - ToolInterface& - operator=(const ToolInterface&) - { - assert(false); - return *this; - } + /// @brief Equal operator - tools are non-copyable + ToolInterface& + operator= (const ToolInterface&) + { + assert(false); return (*this); + } }; diff --git a/apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/trackball.h b/apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/trackball.h index e06cbc5ca14..3856e84db7b 100644 --- a/apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/trackball.h +++ b/apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/trackball.h @@ -35,47 +35,42 @@ /// @file trackball.h /// @details Generic object for generating rotations given mouse input. This -/// class has been based on +/// class has been based on /// @author Matthew Hielsberg #pragma once -#include - #include +#include -class TrackBall { -public: - TrackBall(); - TrackBall(const TrackBall& copy); - ~TrackBall(); - - TrackBall& - operator=(const TrackBall& rhs); - - void - start(int s_x, int s_y); - - void - update(int s_x, int s_y); - - void - getRotationMatrix(float (&rot)[MATRIX_SIZE]); - - void - reset(); - -private: - void - getPointFromScreenPoint(int s_x, int s_y, float& x, float& y, float& z) const; - - /// the quaternion representing the current orientation of the trackball - boost::math::quaternion quat_; - - /// the original mouse screen coordinates converted to a 3d point - float origin_x_{0}, origin_y_{0}, origin_z_{0}; - - /// the radius of the trackball squared - float radius_sqr_; +class TrackBall +{ + public: + TrackBall(); + TrackBall(const TrackBall ©); + ~TrackBall(); + + TrackBall& operator=(const TrackBall &rhs); + + void start(int s_x, int s_y); + + void update(int s_x, int s_y); + + void getRotationMatrix(float (&rot)[MATRIX_SIZE]); + + void reset(); + + private: + + void getPointFromScreenPoint(int s_x, int s_y, float &x, float &y, float &z) const; + /// the quaternion representing the current orientation of the trackball + boost::math::quaternion quat_; + + /// the original mouse screen coordinates converted to a 3d point + float origin_x_, origin_y_, origin_z_; + + /// the radius of the trackball squared + float radius_sqr_; + }; // class TrackBall diff --git a/apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/transformCommand.h b/apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/transformCommand.h index cb2954838fc..5d79983853b 100644 --- a/apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/transformCommand.h +++ b/apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/transformCommand.h @@ -40,74 +40,73 @@ #pragma once -#include #include #include -#include // for pcl::shared_ptr +#include + +#include // for pcl::shared_ptr class Selection; -class TransformCommand : public Command { -public: - /// The type for shared pointer pointing to a constant selection buffer - using ConstSelectionPtr = pcl::shared_ptr; - - /// @brief Constructor - /// @param selection_ptr a shared pointer pointing to the selection object. - /// @param cloud_ptr a shared pointer pointing to the cloud object. - /// @param matrix a (4x4) transform matrix following OpenGL's format. - /// @pre Assumes the selection_ptr is valid, non-NULL. - TransformCommand(const ConstSelectionPtr& selection_ptr, - CloudPtr cloud_ptr, - const float* matrix, - float translate_x, - float translate_y, - float translate_z); - - /// @brief Copy constructor - object is not copy-constructable - TransformCommand(const TransformCommand&) = delete; - - /// @brief Equal operator - object is non-copyable - TransformCommand& - operator=(const TransformCommand&) = delete; - -protected: - // Transforms the coordinates of the selected points according to the transform - // matrix. - void - execute() override; - - // Restore the coordinates of the transformed points. - void - undo() override; - -private: - /// @brief Applies the transformation to the point values - /// @param sel_ptr A pointer to the selection object whose points are to be - /// transformed. - void - applyTransform(const ConstSelectionPtr& sel_ptr); - - /// pointers to constructor params - ConstSelectionPtr selection_ptr_; - - /// a pointer pointing to the cloud - CloudPtr cloud_ptr_; - - float translate_x_, translate_y_, translate_z_; - - /// An internal selection object used to perform undo - SelectionPtr internal_selection_ptr_; - - /// the transform matrix to be used to compute the new coordinates - /// of the selected points - float transform_matrix_[MATRIX_SIZE]; - - /// The transform matrix of the cloud used by this command - float cloud_matrix_[MATRIX_SIZE]; - /// The inverted transform matrix of the cloud used by this command - float cloud_matrix_inv_[MATRIX_SIZE]; - - /// The center of the cloud used by this command - float cloud_center_[XYZ_SIZE]; +class TransformCommand : public Command +{ + public: + /// The type for shared pointer pointing to a constant selection buffer + using ConstSelectionPtr = pcl::shared_ptr; + + /// @brief Constructor + /// @param selection_ptr a shared pointer pointing to the selection object. + /// @param cloud_ptr a shared pointer pointing to the cloud object. + /// @param matrix a (4x4) transform matrix following OpenGL's format. + /// @pre Assumes the selection_ptr is valid, non-NULL. + TransformCommand (const ConstSelectionPtr& selection_ptr, CloudPtr cloud_ptr, + const float* matrix, float translate_x, + float translate_y, float translate_z); + + /// @brief Copy constructor - object is not copy-constructable + TransformCommand (const TransformCommand&) = delete; + + /// @brief Equal operator - object is non-copyable + TransformCommand& + operator= (const TransformCommand&) = delete; + + protected: + // Transforms the coordinates of the selected points according to the transform + // matrix. + void + execute () override; + + // Restore the coordinates of the transformed points. + void + undo () override; + + private: + /// @brief Applies the transformation to the point values + /// @param sel_ptr A pointer to the selection object whose points are to be + /// transformed. + void + applyTransform(const ConstSelectionPtr& sel_ptr); + + /// pointers to constructor params + ConstSelectionPtr selection_ptr_; + + /// a pointer pointing to the cloud + CloudPtr cloud_ptr_; + + float translate_x_, translate_y_, translate_z_; + + /// An internal selection object used to perform undo + SelectionPtr internal_selection_ptr_; + + /// the transform matrix to be used to compute the new coordinates + /// of the selected points + float transform_matrix_[MATRIX_SIZE]; + + /// The transform matrix of the cloud used by this command + float cloud_matrix_[MATRIX_SIZE]; + /// The inverted transform matrix of the cloud used by this command + float cloud_matrix_inv_[MATRIX_SIZE]; + + /// The center of the cloud used by this command + float cloud_center_[XYZ_SIZE]; }; diff --git a/apps/point_cloud_editor/src/cloud.cpp b/apps/point_cloud_editor/src/cloud.cpp index 1e1aa63bb13..5a169e88458 100644 --- a/apps/point_cloud_editor/src/cloud.cpp +++ b/apps/point_cloud_editor/src/cloud.cpp @@ -137,7 +137,7 @@ Cloud::operator= (const Cloud &cloud) select_translate_x_ = cloud.select_translate_x_; select_translate_y_ = cloud.select_translate_y_; select_translate_z_ = cloud.select_translate_z_; - return *this; + return (*this); } Point3D& @@ -300,7 +300,7 @@ Cloud::draw (bool disable_highlight) const // draw the selected points glDrawElements(GL_POINTS, selection_ptr->size(), GL_UNSIGNED_INT, - partitioned_indices_.data()); + &(partitioned_indices_[0])); } } glPopMatrix(); diff --git a/apps/point_cloud_editor/src/cloudEditorWidget.cpp b/apps/point_cloud_editor/src/cloudEditorWidget.cpp index e3f4d225d51..f4cd6d4d03a 100644 --- a/apps/point_cloud_editor/src/cloudEditorWidget.cpp +++ b/apps/point_cloud_editor/src/cloudEditorWidget.cpp @@ -73,7 +73,10 @@ #include CloudEditorWidget::CloudEditorWidget (QWidget *parent) - : QOpenGLWidget(parent) + : QOpenGLWidget(parent), + point_size_(2.0f), selected_point_size_(4.0f), + cam_fov_(60.0), cam_aspect_(1.0), cam_near_(0.0001), cam_far_(100.0), + color_scheme_(COLOR_BY_PURE), is_colored_(false) { setFocusPolicy(Qt::StrongFocus); command_queue_ptr_ = CommandQueuePtr(new CommandQueue()); @@ -88,7 +91,7 @@ void CloudEditorWidget::loadFile(const std::string &filename) { std::string ext = filename.substr(filename.find_last_of('.')+1); - auto it = cloud_load_func_map_.find(ext); + FileLoadMap::iterator it = cloud_load_func_map_.find(ext); if (it != cloud_load_func_map_.end()) (it->second)(this, filename); else @@ -325,8 +328,8 @@ CloudEditorWidget::undo () void CloudEditorWidget::increasePointSize () { - (dynamic_cast( parentWidget())) -> increaseSpinBoxValue(); - point_size_ = (dynamic_cast( parentWidget())) -> getSpinBoxValue(); + ((MainWindow*) parentWidget()) -> increaseSpinBoxValue(); + point_size_ = ((MainWindow*) parentWidget()) -> getSpinBoxValue(); if (!cloud_ptr_) return; cloud_ptr_->setPointSize(point_size_); @@ -336,8 +339,8 @@ CloudEditorWidget::increasePointSize () void CloudEditorWidget::decreasePointSize () { - (dynamic_cast( parentWidget())) -> decreaseSpinBoxValue(); - point_size_ = (dynamic_cast( parentWidget())) -> getSpinBoxValue(); + ((MainWindow*) parentWidget()) -> decreaseSpinBoxValue(); + point_size_ = ((MainWindow*) parentWidget()) -> getSpinBoxValue(); if (!cloud_ptr_) return; cloud_ptr_->setPointSize(point_size_); @@ -347,9 +350,9 @@ CloudEditorWidget::decreasePointSize () void CloudEditorWidget::increaseSelectedPointSize () { - (dynamic_cast( parentWidget())) -> increaseSelectedSpinBoxValue(); + ((MainWindow*) parentWidget()) -> increaseSelectedSpinBoxValue(); selected_point_size_ = - (dynamic_cast( parentWidget())) -> getSelectedSpinBoxValue(); + ((MainWindow*) parentWidget()) -> getSelectedSpinBoxValue(); if (!cloud_ptr_) return; cloud_ptr_->setHighlightPointSize(selected_point_size_); @@ -359,9 +362,9 @@ CloudEditorWidget::increaseSelectedPointSize () void CloudEditorWidget::decreaseSelectedPointSize () { - (dynamic_cast( parentWidget())) -> decreaseSelectedSpinBoxValue(); + ((MainWindow*) parentWidget()) -> decreaseSelectedSpinBoxValue(); selected_point_size_ = - (dynamic_cast( parentWidget())) -> getSelectedSpinBoxValue(); + ((MainWindow*) parentWidget()) -> getSelectedSpinBoxValue(); if (!cloud_ptr_) return; cloud_ptr_->setHighlightPointSize(selected_point_size_); @@ -477,7 +480,7 @@ CloudEditorWidget::resizeGL (int width, int height) height = static_cast(height*ratio); glViewport(0, 0, width, height); viewport_ = {0, 0, width, height}; - cam_aspect_ = static_cast(width) / static_cast(height); + cam_aspect_ = double(width) / double(height); glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluPerspective(cam_fov_, cam_aspect_, cam_near_, cam_far_); @@ -492,11 +495,8 @@ CloudEditorWidget::mousePressEvent (QMouseEvent *event) auto ratio = this->devicePixelRatio(); if (!tool_ptr_) return; -#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) - tool_ptr_ -> start(event -> position().x()*ratio, event -> position().y()*ratio, event -> modifiers(), event -> buttons()); -#else - tool_ptr_ -> start(event -> x()*ratio, event -> y()*ratio, event -> modifiers(), event -> buttons()); -#endif + tool_ptr_ -> start(event -> x()*ratio, event -> y()*ratio, + event -> modifiers(), event -> buttons()); update(); } @@ -506,11 +506,8 @@ CloudEditorWidget::mouseMoveEvent (QMouseEvent *event) auto ratio = this->devicePixelRatio(); if (!tool_ptr_) return; -#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) - tool_ptr_ -> update(event -> position().x()*ratio, event -> position().y()*ratio, event -> modifiers(), event -> buttons()); -#else - tool_ptr_ -> update(event -> x()*ratio, event -> y()*ratio, event -> modifiers(), event -> buttons()); -#endif + tool_ptr_ -> update(event -> x()*ratio, event -> y()*ratio, + event -> modifiers(), event -> buttons()); update(); } @@ -520,11 +517,8 @@ CloudEditorWidget::mouseReleaseEvent (QMouseEvent *event) auto ratio = this->devicePixelRatio(); if (!tool_ptr_) return; -#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) - tool_ptr_ -> end(event -> position().x()*ratio, event -> position().y()*ratio, event -> modifiers(), event -> button()); -#else - tool_ptr_ -> end(event -> x()*ratio, event -> y()*ratio, event -> modifiers(), event -> button()); -#endif + tool_ptr_ -> end(event -> x()*ratio, event -> y()*ratio, + event -> modifiers(), event -> button()); update(); } @@ -532,7 +526,7 @@ void CloudEditorWidget::keyPressEvent (QKeyEvent *event) { int key = event->key() + static_cast(event->modifiers()); - auto it = key_map_.find(key); + std::map::iterator it = key_map_.find(key); if (it != key_map_.end()) { (it->second)(this); @@ -617,23 +611,23 @@ CloudEditorWidget::initKeyMap () key_map_[Qt::Key_3] = &CloudEditorWidget::colorByY; key_map_[Qt::Key_4] = &CloudEditorWidget::colorByZ; key_map_[Qt::Key_5] = &CloudEditorWidget::colorByRGB; - key_map_[Qt::Key_C + static_cast(Qt::ControlModifier)] = &CloudEditorWidget::copy; - key_map_[Qt::Key_X + static_cast(Qt::ControlModifier)] = &CloudEditorWidget::cut; - key_map_[Qt::Key_V + static_cast(Qt::ControlModifier)] = &CloudEditorWidget::paste; + key_map_[Qt::Key_C + (int) Qt::ControlModifier] = &CloudEditorWidget::copy; + key_map_[Qt::Key_X + (int) Qt::ControlModifier] = &CloudEditorWidget::cut; + key_map_[Qt::Key_V + (int) Qt::ControlModifier] = &CloudEditorWidget::paste; key_map_[Qt::Key_S] = &CloudEditorWidget::select2D; key_map_[Qt::Key_E] = &CloudEditorWidget::select1D; key_map_[Qt::Key_T] = &CloudEditorWidget::transform; key_map_[Qt::Key_V] = &CloudEditorWidget::view; key_map_[Qt::Key_Delete] = &CloudEditorWidget::remove; - key_map_[Qt::Key_Z + static_cast(Qt::ControlModifier)] = &CloudEditorWidget::undo; + key_map_[Qt::Key_Z + (int) Qt::ControlModifier] = &CloudEditorWidget::undo; key_map_[Qt::Key_Equal] = &CloudEditorWidget::increasePointSize; key_map_[Qt::Key_Plus] = &CloudEditorWidget::increasePointSize; key_map_[Qt::Key_Minus] = &CloudEditorWidget::decreasePointSize; - key_map_[Qt::Key_Equal + static_cast(Qt::ControlModifier)] = + key_map_[Qt::Key_Equal + (int) Qt::ControlModifier] = &CloudEditorWidget::increaseSelectedPointSize; - key_map_[Qt::Key_Plus + static_cast(Qt::ControlModifier)] = + key_map_[Qt::Key_Plus + (int) Qt::ControlModifier] = &CloudEditorWidget::increaseSelectedPointSize; - key_map_[Qt::Key_Minus + static_cast(Qt::ControlModifier)] = + key_map_[Qt::Key_Minus + (int) Qt::ControlModifier] = &CloudEditorWidget::decreaseSelectedPointSize; key_map_[Qt::Key_Escape] = &CloudEditorWidget::cancelSelect; } diff --git a/apps/point_cloud_editor/src/cloudTransformTool.cpp b/apps/point_cloud_editor/src/cloudTransformTool.cpp index 5f2ddba1110..4a875de5e94 100644 --- a/apps/point_cloud_editor/src/cloudTransformTool.cpp +++ b/apps/point_cloud_editor/src/cloudTransformTool.cpp @@ -46,7 +46,7 @@ const float CloudTransformTool::DEFAULT_TRANSLATE_FACTOR_ = 0.001f; CloudTransformTool::CloudTransformTool (CloudPtr cloud_ptr) - : cloud_ptr_(std::move(cloud_ptr)), scale_factor_(DEFAULT_SCALE_FACTOR_), + : cloud_ptr_(std::move(cloud_ptr)), x_(0), y_(0), scale_factor_(DEFAULT_SCALE_FACTOR_), translate_factor_(DEFAULT_TRANSLATE_FACTOR_) { setIdentity(transform_matrix_); @@ -99,15 +99,15 @@ CloudTransformTool::getTranslateMatrix (int dx, int dy, float* matrix) { setIdentity(matrix); float scale = 1.0f / cloud_ptr_-> getScalingFactor(); - matrix[12] = static_cast(dx) * translate_factor_ * scale; - matrix[13] = static_cast(-dy) * translate_factor_ * scale; + matrix[12] = float(dx) * translate_factor_ * scale; + matrix[13] = float(-dy) * translate_factor_ * scale; } void CloudTransformTool::getZTranslateMatrix (int dy, float* matrix) { setIdentity(matrix); - matrix[14] = static_cast(dy) * translate_factor_ / cloud_ptr_-> getScalingFactor(); + matrix[14] = float(dy) * translate_factor_ / cloud_ptr_-> getScalingFactor(); } void diff --git a/apps/point_cloud_editor/src/denoiseParameterForm.cpp b/apps/point_cloud_editor/src/denoiseParameterForm.cpp index 5655af5697f..13681dfdf33 100644 --- a/apps/point_cloud_editor/src/denoiseParameterForm.cpp +++ b/apps/point_cloud_editor/src/denoiseParameterForm.cpp @@ -40,7 +40,7 @@ #include -DenoiseParameterForm::DenoiseParameterForm () +DenoiseParameterForm::DenoiseParameterForm () : ok_(false) { mean_K_line_ = new QLineEdit; std_dev_mul_thresh_line_ = new QLineEdit; diff --git a/apps/point_cloud_editor/src/select1DTool.cpp b/apps/point_cloud_editor/src/select1DTool.cpp index 8a02a54b3ab..b60d7ee3509 100644 --- a/apps/point_cloud_editor/src/select1DTool.cpp +++ b/apps/point_cloud_editor/src/select1DTool.cpp @@ -74,7 +74,7 @@ Select1DTool::end (int x, int y, BitMask modifiers, BitMask buttons) GLint viewport[4]; glGetIntegerv(GL_VIEWPORT, viewport); IncIndex inc(1);// start the indexing from 1, since the clear color is 0 - auto *index_arr = new unsigned int[cloud_ptr_->size()]; + unsigned int *index_arr = new unsigned int[cloud_ptr_->size()]; std::generate_n(index_arr, cloud_ptr_->size(), inc); glPushClientAttrib(GL_CLIENT_VERTEX_ARRAY_BIT); diff --git a/apps/point_cloud_editor/src/selection.cpp b/apps/point_cloud_editor/src/selection.cpp index 1acace33c32..070452a5ec7 100644 --- a/apps/point_cloud_editor/src/selection.cpp +++ b/apps/point_cloud_editor/src/selection.cpp @@ -48,7 +48,7 @@ Selection::operator= (const Selection& selection) { cloud_ptr_ = selection.cloud_ptr_; selected_indices_ = selection.selected_indices_; - return *this; + return (*this); } void @@ -95,7 +95,7 @@ Selection::isSelected (unsigned int index) const { if (index >= cloud_ptr_->size()) return (false); - auto it = selected_indices_.find(index); + iterator it = selected_indices_.find(index); if (it != selected_indices_.end()) return (true); return (false); diff --git a/apps/point_cloud_editor/src/selectionTransformTool.cpp b/apps/point_cloud_editor/src/selectionTransformTool.cpp index df87cc8dee9..16698d4bc6f 100644 --- a/apps/point_cloud_editor/src/selectionTransformTool.cpp +++ b/apps/point_cloud_editor/src/selectionTransformTool.cpp @@ -91,8 +91,8 @@ SelectionTransformTool::update (int x, int y, BitMask, BitMask buttons) // selection motion is not applied directly (waits for end) // as such we can not update x and y immediately float scale = 1.0f / cloud_ptr_->getScalingFactor(); - cloud_ptr_->setSelectionTranslation (static_cast(dx) * translate_factor_ * scale, - static_cast(-dy) * translate_factor_ * scale, + cloud_ptr_->setSelectionTranslation ((float) dx * translate_factor_ * scale, + (float) -dy * translate_factor_ * scale, 0.0f); return; } @@ -103,7 +103,7 @@ SelectionTransformTool::update (int x, int y, BitMask, BitMask buttons) float scale = 1.0f / cloud_ptr_->getScalingFactor(); cloud_ptr_->setSelectionTranslation (0.0f, 0.0f, - static_cast(dy) * translate_factor_ * scale); + (float) dy * translate_factor_ * scale); return; } float transform[MATRIX_SIZE]; @@ -134,15 +134,15 @@ SelectionTransformTool::end (int x, int y, BitMask modifiers, BitMask buttons) if (modifiers_ & CTRL) { std::shared_ptr c(new TransformCommand(selection_ptr_, - cloud_ptr_, transform_matrix_, static_cast(dx) * translate_factor_ * scale, - static_cast(-dy) * translate_factor_ * scale, 0.0f)); + cloud_ptr_, transform_matrix_, (float) dx * translate_factor_ * scale, + (float) -dy * translate_factor_ * scale, 0.0f)); command_queue_ptr_->execute(c); } else if (modifiers_ & ALT) { std::shared_ptr c(new TransformCommand(selection_ptr_, cloud_ptr_, transform_matrix_, 0.0f, 0.0f, - static_cast(dy) * translate_factor_ * scale)); + (float) dy * translate_factor_ * scale)); command_queue_ptr_->execute(c); } else @@ -193,7 +193,7 @@ SelectionTransformTool::findSelectionCenter () return; float min_xyz[XYZ_SIZE] = {0.0f}; float max_xyz[XYZ_SIZE] = {0.0f}; - auto it = selection_ptr_->begin(); + Selection::const_iterator it = selection_ptr_->begin(); Point3D point_3d = cloud_ptr_->getObjectSpacePoint (*it); float *pt = &(point_3d.data[X]); std::copy(pt, pt + XYZ_SIZE, max_xyz); diff --git a/apps/point_cloud_editor/src/statisticsDialog.cpp b/apps/point_cloud_editor/src/statisticsDialog.cpp index 2cf6018b0a4..5d5edfe31ee 100644 --- a/apps/point_cloud_editor/src/statisticsDialog.cpp +++ b/apps/point_cloud_editor/src/statisticsDialog.cpp @@ -47,7 +47,7 @@ StatisticsDialog::StatisticsDialog(QWidget *) connect(button_box_, SIGNAL(accepted()), this, SLOT(accept())); stat_label_ = new QLabel(tr("")); - auto *main_layout_ = new QVBoxLayout; + QVBoxLayout *main_layout_ = new QVBoxLayout; main_layout_ -> addWidget(stat_label_); main_layout_ -> addWidget(button_box_); setLayout(main_layout_); diff --git a/apps/point_cloud_editor/src/trackball.cpp b/apps/point_cloud_editor/src/trackball.cpp index 49ddce00dd0..f95f7b085c8 100644 --- a/apps/point_cloud_editor/src/trackball.cpp +++ b/apps/point_cloud_editor/src/trackball.cpp @@ -42,7 +42,7 @@ #include #include -TrackBall::TrackBall() : quat_(1.0f) +TrackBall::TrackBall() : quat_(1.0f), origin_x_(0), origin_y_(0), origin_z_(0) { radius_sqr_ = (TRACKBALL_RADIUS_SCALE * static_cast(WINDOW_WIDTH)) * (TRACKBALL_RADIUS_SCALE * static_cast(WINDOW_WIDTH)); diff --git a/apps/src/convolve.cpp b/apps/src/convolve.cpp index a20448d7ba4..b236e609677 100644 --- a/apps/src/convolve.cpp +++ b/apps/src/convolve.cpp @@ -73,8 +73,8 @@ main(int argc, char** argv) Eigen::ArrayXf gaussian_kernel(5); gaussian_kernel << 1.f / 16, 1.f / 4, 3.f / 8, 1.f / 4, 1.f / 16; pcl::console::print_info("convolution kernel:"); - for (float i : gaussian_kernel) - pcl::console::print_info(" %f", i); + for (Eigen::Index i = 0; i < gaussian_kernel.size(); ++i) + pcl::console::print_info(" %f", gaussian_kernel[i]); pcl::console::print_info("\n"); if (argc < 3) { diff --git a/apps/src/dinast_grabber_example.cpp b/apps/src/dinast_grabber_example.cpp index cf9ce4aab96..4dc29b317b6 100644 --- a/apps/src/dinast_grabber_example.cpp +++ b/apps/src/dinast_grabber_example.cpp @@ -61,8 +61,8 @@ class DinastProcessor { static double last = pcl::getTime(); if (++count == 30) { double now = pcl::getTime(); - std::cout << "Average framerate: " << static_cast(count) / (now - last) - << " Hz" << std::endl; + std::cout << "Average framerate: " << double(count) / double(now - last) << " Hz" + << std::endl; count = 0; last = now; } diff --git a/apps/src/face_detection/filesystem_face_detection.cpp b/apps/src/face_detection/filesystem_face_detection.cpp index a13a49c752f..f69b8f94f73 100644 --- a/apps/src/face_detection/filesystem_face_detection.cpp +++ b/apps/src/face_detection/filesystem_face_detection.cpp @@ -98,7 +98,7 @@ run(pcl::RFFaceDetectorTrainer& fdrf, bool result = face_detection_apps_utils::readMatrixFromFile(pose_file, pose_mat); if (result) { - Eigen::Vector3f ea = pose_mat.topLeftCorner<3, 3>().eulerAngles(0, 1, 2); + Eigen::Vector3f ea = pose_mat.block<3, 3>(0, 0).eulerAngles(0, 1, 2); Eigen::Vector3f trans_vector = Eigen::Vector3f(pose_mat(0, 3), pose_mat(1, 3), pose_mat(2, 3)); std::cout << ea << std::endl; @@ -127,7 +127,7 @@ run(pcl::RFFaceDetectorTrainer& fdrf, Eigen::AngleAxisf(ea[1], Eigen::Vector3f::UnitY()) * Eigen::AngleAxisf(ea[2], Eigen::Vector3f::UnitZ()); - // matrixxx = pose_mat.topLeftCorner<3,3>(); + // matrixxx = pose_mat.block<3,3>(0,0); vec = matrixxx * vec; cylinder_coeff.values[3] = vec[0]; diff --git a/apps/src/face_detection/openni_frame_source.cpp b/apps/src/face_detection/openni_frame_source.cpp index 310cb50900b..10c3df3fdde 100644 --- a/apps/src/face_detection/openni_frame_source.cpp +++ b/apps/src/face_detection/openni_frame_source.cpp @@ -3,7 +3,8 @@ namespace OpenNIFrameSource { -OpenNIFrameSource::OpenNIFrameSource(const std::string& device_id) : grabber_(device_id) +OpenNIFrameSource::OpenNIFrameSource(const std::string& device_id) +: grabber_(device_id), frame_counter_(0), active_(true) { std::function frame_cb = [this](const PointCloudConstPtr& cloud) { onNewFrame(cloud); }; diff --git a/apps/src/feature_matching.cpp b/apps/src/feature_matching.cpp index 077eace391c..394ae3eef0d 100644 --- a/apps/src/feature_matching.cpp +++ b/apps/src/feature_matching.cpp @@ -140,9 +140,9 @@ class ICCVTutorial { pcl::CorrespondencesPtr correspondences_; Eigen::Matrix4f initial_transformation_matrix_; Eigen::Matrix4f transformation_matrix_; - bool show_source2target_{false}; - bool show_target2source_{false}; - bool show_correspondences{false}; + bool show_source2target_; + bool show_target2source_; + bool show_correspondences; }; template @@ -166,6 +166,9 @@ ICCVTutorial::ICCVTutorial( , source_features_(new pcl::PointCloud) , target_features_(new pcl::PointCloud) , correspondences_(new pcl::Correspondences) +, show_source2target_(false) +, show_target2source_(false) +, show_correspondences(false) { visualizer_.registerKeyboardCallback( &ICCVTutorial::keyboard_callback, *this, nullptr); @@ -339,7 +342,7 @@ ICCVTutorial::filterCorrespondences() std::vector> correspondences; for (std::size_t cIdx = 0; cIdx < source2target_.size(); ++cIdx) if (target2source_[source2target_[cIdx]] == static_cast(cIdx)) - correspondences.emplace_back(cIdx, source2target_[cIdx]); + correspondences.push_back(std::make_pair(cIdx, source2target_[cIdx])); correspondences_->resize(correspondences.size()); for (std::size_t cIdx = 0; cIdx < correspondences.size(); ++cIdx) { @@ -590,14 +593,16 @@ main(int argc, char** argv) pcl::Keypoint::Ptr keypoint_detector; if (keypoint_type == 1) { - auto* sift3D = new pcl::SIFTKeypoint; + pcl::SIFTKeypoint* sift3D = + new pcl::SIFTKeypoint; sift3D->setScales(0.01f, 3, 2); sift3D->setMinimumContrast(0.0); keypoint_detector.reset(sift3D); } else { - auto* harris3D = new pcl::HarrisKeypoint3D( - pcl::HarrisKeypoint3D::HARRIS); + pcl::HarrisKeypoint3D* harris3D = + new pcl::HarrisKeypoint3D( + pcl::HarrisKeypoint3D::HARRIS); harris3D->setNonMaxSupression(true); harris3D->setRadius(0.01f); harris3D->setRadiusSearch(0.01f); @@ -639,7 +644,8 @@ main(int argc, char** argv) pcl::PCLSurfaceBase::Ptr surface_reconstruction; if (surface_type == 1) { - auto* gp3 = new pcl::GreedyProjectionTriangulation; + pcl::GreedyProjectionTriangulation* gp3 = + new pcl::GreedyProjectionTriangulation; // Set the maximum distance between connected points (maximum edge length) gp3->setSearchRadius(0.025); @@ -681,7 +687,7 @@ main(int argc, char** argv) } break; case 2: { - auto* shot = + pcl::SHOTColorEstimationOMP* shot = new pcl::SHOTColorEstimationOMP; shot->setRadiusSearch(0.04); pcl::Feature::Ptr feature_extractor(shot); diff --git a/apps/src/grabcut_2d.cpp b/apps/src/grabcut_2d.cpp index 3c09facd399..02b3faec5f8 100644 --- a/apps/src/grabcut_2d.cpp +++ b/apps/src/grabcut_2d.cpp @@ -232,12 +232,12 @@ GrabCutHelper::display(int display_type) { switch (display_type) { case 0: - glDrawPixels(image_->width, image_->height, GL_RGB, GL_FLOAT, *image_->data()); + glDrawPixels(image_->width, image_->height, GL_RGB, GL_FLOAT, &((*image_)[0])); break; case 1: glDrawPixels( - gmm_image_->width, gmm_image_->height, GL_RGB, GL_FLOAT, *gmm_image_->data()); + gmm_image_->width, gmm_image_->height, GL_RGB, GL_FLOAT, &((*gmm_image_)[0])); break; case 2: @@ -245,7 +245,7 @@ GrabCutHelper::display(int display_type) n_links_image_->height, GL_LUMINANCE, GL_FLOAT, - *n_links_image_->data()); + &((*n_links_image_)[0])); break; case 3: @@ -253,7 +253,7 @@ GrabCutHelper::display(int display_type) t_links_image_->height, GL_RGB, GL_FLOAT, - *t_links_image_->data()); + &((*t_links_image_)[0])); break; default: @@ -270,7 +270,7 @@ GrabCutHelper::overlayAlpha() alpha_image_->height, GL_ALPHA, GL_FLOAT, - *alpha_image_->data()); + &((*alpha_image_)[0])); } /* GUI interface */ @@ -297,7 +297,7 @@ display() display_image->height, GL_RGB, GL_FLOAT, - *display_image->data()); + &((*display_image)[0])); else grabcut.display(display_type); diff --git a/apps/src/manual_registration/manual_registration.cpp b/apps/src/manual_registration/manual_registration.cpp index 16e9e3923fd..b7cf5d8a009 100644 --- a/apps/src/manual_registration/manual_registration.cpp +++ b/apps/src/manual_registration/manual_registration.cpp @@ -297,7 +297,7 @@ ManualRegistration::orthoChanged(int state) void ManualRegistration::applyTransformPressed() { - auto* diag = new PCLViewerDialog(this); + PCLViewerDialog* diag = new PCLViewerDialog(this); diag->setModal(true); diag->setGeometry(this->x(), this->y(), this->width(), this->height()); diag->setPointClouds(cloud_src_, cloud_dst_, Eigen::Affine3f(transform_)); diff --git a/apps/src/multiscale_feature_persistence_example.cpp b/apps/src/multiscale_feature_persistence_example.cpp index 4854347c0e2..a2bc67958d5 100644 --- a/apps/src/multiscale_feature_persistence_example.cpp +++ b/apps/src/multiscale_feature_persistence_example.cpp @@ -41,7 +41,6 @@ #include #include #include -#include // for KdTree #include #include diff --git a/apps/src/ni_agast.cpp b/apps/src/ni_agast.cpp index 9595e5bf557..6793e490d0a 100644 --- a/apps/src/ni_agast.cpp +++ b/apps/src/ni_agast.cpp @@ -67,6 +67,9 @@ class AGASTDemo { : cloud_viewer_("AGAST 2D Keypoints -- PointCloud") , grabber_(grabber) , image_viewer_("AGAST 2D Keypoints -- Image") + , bmax_(255) + , threshold_(30) + , detector_type_(0) {} ///////////////////////////////////////////////////////////////////////// @@ -126,7 +129,7 @@ class AGASTDemo { void keyboard_callback(const pcl::visualization::KeyboardEvent& event, void* cookie) { - auto* obj = static_cast(cookie); + AGASTDemo* obj = static_cast(cookie); if (event.getKeyCode()) { std::stringstream ss; @@ -286,8 +289,8 @@ class AGASTDemo { if (keypoints && !keypoints->empty()) { image_viewer_.removeLayer(getStrBool(keypts)); for (std::size_t i = 0; i < keypoints->size(); ++i) { - int u = static_cast((*keypoints)[i].u); - int v = static_cast((*keypoints)[i].v); + int u = int((*keypoints)[i].u); + int v = int((*keypoints)[i].v); image_viewer_.markPoint(u, v, visualization::red_color, @@ -327,9 +330,9 @@ class AGASTDemo { PointCloud::Ptr keypoints_; - double bmax_{255}; - double threshold_{30}; - int detector_type_{0}; + double bmax_; + double threshold_; + int detector_type_; private: boost::signals2::connection cloud_connection; diff --git a/apps/src/ni_brisk.cpp b/apps/src/ni_brisk.cpp index 2ad4645b8c8..274cdf5a8d6 100644 --- a/apps/src/ni_brisk.cpp +++ b/apps/src/ni_brisk.cpp @@ -107,8 +107,8 @@ class BRISKDemo { inline PointT bilinearInterpolation(const CloudConstPtr& cloud, float x, float y) { - int u = static_cast(x); - int v = static_cast(y); + int u = int(x); + int v = int(y); PointT pt; pt.x = pt.y = pt.z = 0; @@ -118,7 +118,7 @@ class BRISKDemo { const PointT& p3 = (*cloud)(u, v + 1); const PointT& p4 = (*cloud)(u + 1, v + 1); - float fx = x - static_cast(u), fy = y - static_cast(v); + float fx = x - float(u), fy = y - float(v); float fx1 = 1.0f - fx, fy1 = 1.0f - fy; float w1 = fx1 * fy1, w2 = fx * fy1, w3 = fx1 * fy, w4 = fx * fy; @@ -236,8 +236,8 @@ class BRISKDemo { image_viewer_.removeLayer(getStrBool(keypts)); for (std::size_t i = 0; i < keypoints->size(); ++i) { - int u = static_cast((*keypoints)[i].x); - int v = static_cast((*keypoints)[i].y); + int u = int((*keypoints)[i].x); + int v = int((*keypoints)[i].y); image_viewer_.markPoint(u, v, visualization::red_color, diff --git a/apps/src/ni_linemod.cpp b/apps/src/ni_linemod.cpp index a5532c8008c..52452ec0bd6 100644 --- a/apps/src/ni_linemod.cpp +++ b/apps/src/ni_linemod.cpp @@ -77,7 +77,10 @@ class NILinemod { bool added; NILinemod(Grabber& grabber) - : cloud_viewer_("PointCloud"), grabber_(grabber), image_viewer_("Image") + : cloud_viewer_("PointCloud") + , grabber_(grabber) + , image_viewer_("Image") + , first_frame_(true) { added = false; @@ -563,7 +566,7 @@ class NILinemod { private: boost::signals2::connection cloud_connection, image_connection; - bool first_frame_{true}; + bool first_frame_; // Segmentation pcl::Indices indices_fullset_; diff --git a/apps/src/ni_susan.cpp b/apps/src/ni_susan.cpp index b644f48cada..d67eb2568a7 100644 --- a/apps/src/ni_susan.cpp +++ b/apps/src/ni_susan.cpp @@ -144,9 +144,8 @@ class SUSANDemo { if (keypoints && !keypoints->empty()) { image_viewer_.removeLayer(getStrBool(keypts)); for (std::size_t i = 0; i < keypoints->size(); ++i) { - int u = static_cast((*keypoints)[i].label % cloud->width); - int v = - cloud->height - static_cast((*keypoints)[i].label / cloud->width); + int u = int((*keypoints)[i].label % cloud->width); + int v = cloud->height - int((*keypoints)[i].label / cloud->width); image_viewer_.markPoint(u, v, visualization::red_color, diff --git a/apps/src/openni_3d_concave_hull.cpp b/apps/src/openni_3d_concave_hull.cpp index 1e4642ee8a1..d4c0309704a 100644 --- a/apps/src/openni_3d_concave_hull.cpp +++ b/apps/src/openni_3d_concave_hull.cpp @@ -57,7 +57,7 @@ using namespace std::chrono_literals; static double last = pcl::getTime(); \ if (++count == 100) { \ double now = pcl::getTime(); \ - std::cout << "Average framerate(" << (_WHAT_) << "): " \ + std::cout << "Average framerate(" << _WHAT_ << "): " \ << double(count) / double(now - last) << " Hz" << std::endl; \ count = 0; \ last = now; \ @@ -204,7 +204,7 @@ main(int argc, char** argv) return 1; } - std::string device_id; + std::string device_id = ""; if (pcl::console::parse_argument(argc, argv, "-device_id", device_id) == -1 && argc > 1 && argv[1][0] != '-') device_id = argv[1]; diff --git a/apps/src/openni_3d_convex_hull.cpp b/apps/src/openni_3d_convex_hull.cpp index c976c4354c2..674ea43ead0 100644 --- a/apps/src/openni_3d_convex_hull.cpp +++ b/apps/src/openni_3d_convex_hull.cpp @@ -57,7 +57,7 @@ using namespace pcl::visualization; static double last = pcl::getTime(); \ if (++count == 100) { \ double now = pcl::getTime(); \ - std::cout << "Average framerate(" << (_WHAT_) << "): " \ + std::cout << "Average framerate(" << _WHAT_ << "): " \ << double(count) / double(now - last) << " Hz" << std::endl; \ count = 0; \ last = now; \ @@ -202,7 +202,7 @@ main(int argc, char** argv) return 1; } - std::string device_id; + std::string device_id = ""; if (pcl::console::parse_argument(argc, argv, "-device_id", device_id) == -1 && argc > 1 && argv[1][0] != '-') device_id = argv[1]; diff --git a/apps/src/openni_boundary_estimation.cpp b/apps/src/openni_boundary_estimation.cpp index 7c911b33b22..d0e45444d3a 100644 --- a/apps/src/openni_boundary_estimation.cpp +++ b/apps/src/openni_boundary_estimation.cpp @@ -42,7 +42,6 @@ #include #include #include -#include // for OrganizedNeighbor #include #include #include @@ -64,7 +63,7 @@ using ColorHandlerConstPtr = ColorHandler::ConstPtr; double now = pcl::getTime(); \ ++count; \ if (now - last >= 1.0) { \ - std::cout << "Average framerate(" << (_WHAT_) << "): " \ + std::cout << "Average framerate(" << _WHAT_ << "): " \ << double(count) / double(now - last) << " Hz" << std::endl; \ count = 0; \ last = now; \ @@ -220,7 +219,7 @@ main(int argc, char** argv) return 1; } - std::string device_id; + std::string device_id = ""; if (pcl::console::parse_argument(argc, argv, "-device_id", device_id) == -1 && argc > 1 && argv[1][0] != '-') device_id = argv[1]; diff --git a/apps/src/openni_fast_mesh.cpp b/apps/src/openni_fast_mesh.cpp index 828e7f0626a..e3701033940 100644 --- a/apps/src/openni_fast_mesh.cpp +++ b/apps/src/openni_fast_mesh.cpp @@ -56,7 +56,7 @@ using namespace std::chrono_literals; static double last = pcl::getTime(); \ if (++count == 100) { \ double now = pcl::getTime(); \ - std::cout << "Average framerate(" << (_WHAT_) << "): " \ + std::cout << "Average framerate(" << _WHAT_ << "): " \ << double(count) / double(now - last) << " Hz" << std::endl; \ count = 0; \ last = now; \ @@ -190,7 +190,7 @@ main(int argc, char** argv) return 1; } - std::string device_id; + std::string device_id = ""; if (pcl::console::parse_argument(argc, argv, "-device_id", device_id) == -1 && argc > 1 && argv[1][0] != '-') device_id = argv[1]; diff --git a/apps/src/openni_feature_persistence.cpp b/apps/src/openni_feature_persistence.cpp index 4eb6926f1ed..0b397bffd51 100644 --- a/apps/src/openni_feature_persistence.cpp +++ b/apps/src/openni_feature_persistence.cpp @@ -44,7 +44,6 @@ #include #include #include -#include // for KdTree #include #include #include @@ -62,7 +61,7 @@ using namespace std::chrono_literals; double now = pcl::getTime(); \ ++count; \ if (now - last >= 1.0) { \ - std::cout << "Average framerate(" << (_WHAT_) << "): " \ + std::cout << "Average framerate(" << _WHAT_ << "): " \ << double(count) / double(now - last) << " Hz" << std::endl; \ count = 0; \ last = now; \ @@ -285,7 +284,7 @@ main(int argc, char** argv) return 1; } - std::string device_id; + std::string device_id = ""; float subsampling_leaf_size = default_subsampling_leaf_size; double normal_search_radius = default_normal_search_radius; std::vector scales_vector_double = default_scales_vector; @@ -300,7 +299,7 @@ main(int argc, char** argv) argc, argv, "-normal_search_radius", normal_search_radius); pcl::console::parse_multiple_arguments(argc, argv, "-scales", scales_vector_double); for (std::size_t i = 0; i < scales_vector_double.size(); ++i) - scales_vector[i] = static_cast(scales_vector_double[i]); + scales_vector[i] = float(scales_vector_double[i]); pcl::console::parse_argument(argc, argv, "-persistence_alpha", alpha); ///////////////////////////////////////////////////////////////////// diff --git a/apps/src/openni_ii_normal_estimation.cpp b/apps/src/openni_ii_normal_estimation.cpp index d0f6fd516d2..942447f35b2 100644 --- a/apps/src/openni_ii_normal_estimation.cpp +++ b/apps/src/openni_ii_normal_estimation.cpp @@ -55,7 +55,7 @@ using namespace std::chrono_literals; double now = pcl::getTime(); \ ++count; \ if (now - last >= 1.0) { \ - std::cout << "Average framerate(" << (_WHAT_) << "): " \ + std::cout << "Average framerate(" << _WHAT_ << "): " \ << double(count) / double(now - last) << " Hz" << std::endl; \ count = 0; \ last = now; \ @@ -229,7 +229,7 @@ main(int argc, char** argv) return 1; } - std::string device_id; + std::string device_id = ""; if (pcl::console::parse_argument(argc, argv, "-device_id", device_id) == -1 && argc > 1 && argv[1][0] != '-') device_id = argv[1]; diff --git a/apps/src/openni_klt.cpp b/apps/src/openni_klt.cpp index 89e69d8073f..504d40dd665 100644 --- a/apps/src/openni_klt.cpp +++ b/apps/src/openni_klt.cpp @@ -56,7 +56,7 @@ double now = pcl::getTime(); \ ++count; \ if (now - last >= 1.0) { \ - std::cout << "Average framerate(" << (_WHAT_) << "): " \ + std::cout << "Average framerate(" << _WHAT_ << "): " \ << double(count) / double(now - last) << " Hz" << std::endl; \ count = 0; \ last = now; \ @@ -111,7 +111,9 @@ class OpenNIViewer { using Cloud = pcl::PointCloud; using CloudConstPtr = typename Cloud::ConstPtr; - OpenNIViewer(pcl::Grabber& grabber) : grabber_(grabber) {} + OpenNIViewer(pcl::Grabber& grabber) + : grabber_(grabber), rgb_data_(nullptr), rgb_data_size_(0), counter_(0) + {} void detect_keypoints(const CloudConstPtr& cloud) @@ -286,13 +288,13 @@ class OpenNIViewer { CloudConstPtr cloud_; openni_wrapper::Image::Ptr image_; - unsigned char* rgb_data_{nullptr}; - unsigned rgb_data_size_{0}; + unsigned char* rgb_data_; + unsigned rgb_data_size_; typename pcl::tracking::PyramidalKLTTracker::Ptr tracker_; pcl::PointCloud::ConstPtr keypoints_; pcl::PointIndicesConstPtr points_; pcl::shared_ptr> points_status_; - int counter_{0}; + int counter_; }; // Create the PCLVisualizer object diff --git a/apps/src/openni_mls_smoothing.cpp b/apps/src/openni_mls_smoothing.cpp index 3f96c705268..641c341c745 100644 --- a/apps/src/openni_mls_smoothing.cpp +++ b/apps/src/openni_mls_smoothing.cpp @@ -54,7 +54,7 @@ double now = pcl::getTime(); \ ++count; \ if (now - last >= 1.0) { \ - std::cout << "Average framerate(" << (_WHAT_) << "): " \ + std::cout << "Average framerate(" << _WHAT_ << "): " \ << double(count) / double(now - last) << " Hz" << std::endl; \ count = 0; \ last = now; \ @@ -221,7 +221,7 @@ main(int argc, char** argv) return 1; } - std::string device_id; + std::string device_id = ""; double search_radius = default_search_radius; double sqr_gauss_param = default_sqr_gauss_param; bool sqr_gauss_param_set = true; diff --git a/apps/src/openni_mobile_server.cpp b/apps/src/openni_mobile_server.cpp index d93e6cd5ad1..bf6778d1ff5 100644 --- a/apps/src/openni_mobile_server.cpp +++ b/apps/src/openni_mobile_server.cpp @@ -157,7 +157,7 @@ class PCLMobileServer { viewer_.showCloud(getLatestPointCloud()); - boost::asio::io_context io_service; + boost::asio::io_service io_service; tcp::endpoint endpoint(tcp::v4(), static_cast(port_)); tcp::acceptor acceptor(io_service, endpoint); tcp::socket socket(io_service); @@ -238,7 +238,7 @@ main(int argc, char** argv) return 1; } - std::string device_id; + std::string device_id = ""; int port = 11111; float leaf_x = 0.01f, leaf_y = 0.01f, leaf_z = 0.01f; diff --git a/apps/src/openni_octree_compression.cpp b/apps/src/openni_octree_compression.cpp index e8e2c0a8540..0a056054f34 100644 --- a/apps/src/openni_octree_compression.cpp +++ b/apps/src/openni_octree_compression.cpp @@ -108,7 +108,7 @@ char usage[] = "\n" double now = pcl::getTime(); \ ++count; \ if (now - last >= 1.0) { \ - std::cout << "Average framerate(" << (_WHAT_) << "): " \ + std::cout << "Average framerate(" << _WHAT_ << "): " \ << double(count) / double(now - last) << " Hz" << std::endl; \ count = 0; \ last = now; \ @@ -351,7 +351,7 @@ main(int argc, char** argv) // apply profile settings pointResolution = selectedProfile.pointResolution; - octreeResolution = static_cast(selectedProfile.octreeResolution); + octreeResolution = float(selectedProfile.octreeResolution); doVoxelGridDownDownSampling = selectedProfile.doVoxelGridDownSampling; iFrameRate = selectedProfile.iFrameRate; doColorEncoding = selectedProfile.doColorEncoding; @@ -415,7 +415,7 @@ main(int argc, char** argv) if (bEnDecode) { // ENCODING try { - boost::asio::io_context io_service; + boost::asio::io_service io_service; tcp::endpoint endpoint(tcp::v4(), 6666); tcp::acceptor acceptor(io_service, endpoint); @@ -423,7 +423,7 @@ main(int argc, char** argv) std::cout << "Waiting for connection.." << std::endl; - acceptor.accept(socketStream.rdbuf()->socket()); + acceptor.accept(*socketStream.rdbuf()); std::cout << "Connected!" << std::endl; diff --git a/apps/src/openni_organized_compression.cpp b/apps/src/openni_organized_compression.cpp index 75593da9b2f..c0448bde55d 100644 --- a/apps/src/openni_organized_compression.cpp +++ b/apps/src/openni_organized_compression.cpp @@ -92,7 +92,7 @@ char usage[] = "\n" double now = pcl::getTime(); \ ++count; \ if (now - last >= 1.0) { \ - std::cout << "Average framerate(" << (_WHAT_) << "): " \ + std::cout << "Average framerate(" << _WHAT_ << "): " \ << double(count) / double(now - last) << " Hz" << std::endl; \ count = 0; \ last = now; \ @@ -226,14 +226,14 @@ struct EventHelper { depth_image->fillDepthImageRaw( width, height, - disparity_data.data(), + &disparity_data[0], static_cast(width * sizeof(std::uint16_t))); if (image->getEncoding() != openni_wrapper::Image::RGB) { rgb_data.resize(width * height * 3); image->fillRGB(width, height, - rgb_data.data(), + &rgb_data[0], static_cast(width * sizeof(std::uint8_t) * 3)); } @@ -438,7 +438,7 @@ main(int argc, char** argv) if (bEnDecode) { // ENCODING try { - boost::asio::io_context io_service; + boost::asio::io_service io_service; tcp::endpoint endpoint(tcp::v4(), 6666); tcp::acceptor acceptor(io_service, endpoint); @@ -446,7 +446,7 @@ main(int argc, char** argv) std::cout << "Waiting for connection.." << std::endl; - acceptor.accept(socketStream.rdbuf()->socket()); + acceptor.accept(*socketStream.rdbuf()); std::cout << "Connected!" << std::endl; diff --git a/apps/src/openni_organized_edge_detection.cpp b/apps/src/openni_organized_edge_detection.cpp index 5b8b3c5e04f..0042f36ffcb 100644 --- a/apps/src/openni_organized_edge_detection.cpp +++ b/apps/src/openni_organized_edge_detection.cpp @@ -222,7 +222,7 @@ class OpenNIOrganizedEdgeDetection { ne.setInputCloud(cloud_.makeShared()); ne.compute(*normal_cloud); double normal_end = pcl::getTime(); - std::cout << "Normal Estimation took " << (normal_end - normal_start) + std::cout << "Normal Estimation took " << double(normal_end - normal_start) << std::endl; oed.setInputNormals(normal_cloud); @@ -234,12 +234,12 @@ class OpenNIOrganizedEdgeDetection { oed.compute(labels, label_indices); double oed_end = pcl::getTime(); - std::cout << "Edge Detection took " << (oed_end - oed_start) << std::endl; - std::cout << "Frame took " << (oed_end - normal_start) << std::endl; + std::cout << "Edge Detection took " << double(oed_end - oed_start) << std::endl; + std::cout << "Frame took " << double(oed_end - normal_start) << std::endl; // Make gray point cloud for (auto& point : cloud_.points) { - auto gray = static_cast((point.r + point.g + point.b) / 3); + std::uint8_t gray = std::uint8_t((point.r + point.g + point.b) / 3); point.r = point.g = point.b = gray; } @@ -325,7 +325,7 @@ main(int argc, char** argv) return 1; } - std::string device_id; + std::string device_id = ""; if (pcl::console::parse_argument(argc, argv, "-device_id", device_id) == -1 && argc > 1 && argv[1][0] != '-') device_id = argv[1]; diff --git a/apps/src/openni_organized_multi_plane_segmentation.cpp b/apps/src/openni_organized_multi_plane_segmentation.cpp index 2a1b3a58590..a587a7e2154 100644 --- a/apps/src/openni_organized_multi_plane_segmentation.cpp +++ b/apps/src/openni_organized_multi_plane_segmentation.cpp @@ -144,7 +144,7 @@ class OpenNIOrganizedMultiPlaneSegmentation { ne.setInputCloud(prev_cloud); ne.compute(*normal_cloud); double normal_end = pcl::getTime(); - std::cout << "Normal Estimation took " << (normal_end - normal_start) + std::cout << "Normal Estimation took " << double(normal_end - normal_start) << std::endl; double plane_extract_start = pcl::getTime(); @@ -153,8 +153,9 @@ class OpenNIOrganizedMultiPlaneSegmentation { mps.segmentAndRefine(regions); double plane_extract_end = pcl::getTime(); std::cout << "Plane extraction took " - << (plane_extract_end - plane_extract_start) << std::endl; - std::cout << "Frame took " << (plane_extract_end - normal_start) << std::endl; + << double(plane_extract_end - plane_extract_start) << std::endl; + std::cout << "Frame took " << double(plane_extract_end - normal_start) + << std::endl; pcl::PointCloud::Ptr cluster(new pcl::PointCloud); diff --git a/apps/src/openni_planar_convex_hull.cpp b/apps/src/openni_planar_convex_hull.cpp index ae3ae70a285..d42481a2caa 100644 --- a/apps/src/openni_planar_convex_hull.cpp +++ b/apps/src/openni_planar_convex_hull.cpp @@ -192,7 +192,7 @@ main(int argc, char** argv) return 1; } - std::string device_id; + std::string device_id = ""; double threshold = 0.05; if (pcl::console::parse_argument(argc, argv, "-device_id", device_id) == -1 && diff --git a/apps/src/openni_planar_segmentation.cpp b/apps/src/openni_planar_segmentation.cpp index a4920b9709b..d06d4fde3b0 100644 --- a/apps/src/openni_planar_segmentation.cpp +++ b/apps/src/openni_planar_segmentation.cpp @@ -185,7 +185,7 @@ main(int argc, char** argv) return 1; } - std::string device_id; + std::string device_id = ""; double threshold = 0.05; if (pcl::console::parse_argument(argc, argv, "-device_id", device_id) == -1 && diff --git a/apps/src/openni_shift_to_depth_conversion.cpp b/apps/src/openni_shift_to_depth_conversion.cpp index 00a842b8b2d..7de78e4f2eb 100644 --- a/apps/src/openni_shift_to_depth_conversion.cpp +++ b/apps/src/openni_shift_to_depth_conversion.cpp @@ -81,13 +81,13 @@ class SimpleOpenNIViewer { depth_image->fillDepthImageRaw( width, height, - raw_shift_data.data(), + &raw_shift_data[0], static_cast(width * sizeof(std::uint16_t))); // convert raw shift data to raw depth data raw_depth_data.resize(width * height); grabber_.convertShiftToDepth( - raw_shift_data.data(), raw_depth_data.data(), raw_shift_data.size()); + &raw_shift_data[0], &raw_depth_data[0], raw_shift_data.size()); // check for color data if (image->getEncoding() != openni_wrapper::Image::RGB) { @@ -95,7 +95,7 @@ class SimpleOpenNIViewer { rgb_data.resize(width * height * 3); image->fillRGB(width, height, - rgb_data.data(), + &rgb_data[0], static_cast(width * sizeof(std::uint8_t) * 3)); } diff --git a/apps/src/openni_tracking.cpp b/apps/src/openni_tracking.cpp index 3c0b6f8379c..174f889a19c 100644 --- a/apps/src/openni_tracking.cpp +++ b/apps/src/openni_tracking.cpp @@ -82,7 +82,7 @@ double end_time = pcl::getTime(); \ static unsigned count = 0; \ if (++count == 10) { \ - std::cout << "Average framerate(" << (_WHAT_) << "): " \ + std::cout << "Average framerate(" << _WHAT_ << "): " \ << double(count) / double(duration) << " Hz" << std::endl; \ count = 0; \ duration = 0.0; \ @@ -121,7 +121,9 @@ class OpenNISegmentTracking { bool use_fixed) : viewer_("PCL OpenNI Tracking Viewer") , device_id_(device_id) + , new_cloud_(false) , ne_(thread_nr) + , counter_(0) , use_convex_hull_(use_convex_hull) , visualize_non_downsample_(visualize_non_downsample) , visualize_particles_(visualize_particles) @@ -337,9 +339,7 @@ class OpenNISegmentTracking { FPS_CALC_BEGIN; double start = pcl::getTime(); pcl::VoxelGrid grid; - grid.setLeafSize(static_cast(leaf_size), - static_cast(leaf_size), - static_cast(leaf_size)); + grid.setLeafSize(float(leaf_size), float(leaf_size), float(leaf_size)); grid.setInputCloud(cloud); grid.filter(result); double end = pcl::getTime(); @@ -549,12 +549,11 @@ class OpenNISegmentTracking { double segment_distance = c[0] * c[0] + c[1] * c[1]; for (std::size_t i = 1; i < cluster_indices.size(); i++) { temp_cloud.reset(new Cloud); - extractSegmentCluster( - target_cloud, cluster_indices, static_cast(i), *temp_cloud); + extractSegmentCluster(target_cloud, cluster_indices, int(i), *temp_cloud); pcl::compute3DCentroid(*temp_cloud, c); double distance = c[0] * c[0] + c[1] * c[1]; if (distance < segment_distance) { - segment_index = static_cast(i); + segment_index = int(i); segment_distance = distance; } } @@ -631,10 +630,10 @@ class OpenNISegmentTracking { std::string device_id_; std::mutex mtx_; - bool new_cloud_{false}; + bool new_cloud_; pcl::NormalEstimationOMP ne_; // to store threadpool ParticleFilter::Ptr tracker_; - int counter_{0}; + int counter_; bool use_convex_hull_; bool visualize_non_downsample_; bool visualize_particles_; @@ -670,7 +669,7 @@ main(int argc, char** argv) return 1; } - std::string device_id; + std::string device_id = ""; bool use_convex_hull = true; bool visualize_non_downsample = false; bool visualize_particles = true; diff --git a/apps/src/openni_uniform_sampling.cpp b/apps/src/openni_uniform_sampling.cpp index a3f45fcc7c1..6167cdacb3c 100644 --- a/apps/src/openni_uniform_sampling.cpp +++ b/apps/src/openni_uniform_sampling.cpp @@ -55,7 +55,7 @@ using namespace std::chrono_literals; double now = pcl::getTime(); \ ++count; \ if (now - last >= 1.0) { \ - std::cout << "Average framerate(" << (_WHAT_) << "): " \ + std::cout << "Average framerate(" << _WHAT_ << "): " \ << double(count) / double(now - last) << " Hz" << std::endl; \ count = 0; \ last = now; \ @@ -188,7 +188,7 @@ main(int argc, char** argv) return 1; } - std::string device_id; + std::string device_id = ""; float leaf_res = 0.05f; if (pcl::console::parse_argument(argc, argv, "-device_id", device_id) == -1 && diff --git a/apps/src/openni_voxel_grid.cpp b/apps/src/openni_voxel_grid.cpp index cbac0039c6c..27749cbe325 100644 --- a/apps/src/openni_voxel_grid.cpp +++ b/apps/src/openni_voxel_grid.cpp @@ -52,7 +52,7 @@ double now = pcl::getTime(); \ ++count; \ if (now - last >= 1.0) { \ - std::cout << "Average framerate(" << (_WHAT_) << "): " \ + std::cout << "Average framerate(" << _WHAT_ << "): " \ << double(count) / double(now - last) << " Hz" << std::endl; \ count = 0; \ last = now; \ @@ -187,7 +187,7 @@ main(int argc, char** argv) return 1; } - std::string device_id; + std::string device_id = ""; float min_v = 0.0f, max_v = 5.0f; std::string field_name = "z"; float leaf_x = 0.01f, leaf_y = 0.01f, leaf_z = 0.01f; diff --git a/apps/src/organized_segmentation_demo.cpp b/apps/src/organized_segmentation_demo.cpp index f08bd3f275a..cbf81a72728 100644 --- a/apps/src/organized_segmentation_demo.cpp +++ b/apps/src/organized_segmentation_demo.cpp @@ -35,11 +35,11 @@ displayPlanarRegions( pcl::PointXYZ pt2 = pcl::PointXYZ(centroid[0] + (0.5f * model[0]), centroid[1] + (0.5f * model[1]), centroid[2] + (0.5f * model[2])); - sprintf(name, "normal_%d", static_cast(i)); + sprintf(name, "normal_%d", unsigned(i)); viewer->addArrow(pt2, pt1, 1.0, 0, 0, false, name); contour->points = regions[i].getContour(); - sprintf(name, "plane_%02d", static_cast(i)); + sprintf(name, "plane_%02d", int(i)); pcl::visualization::PointCloudColorHandlerCustom color( contour, red[i % 6], grn[i % 6], blu[i % 6]); if (!viewer->updatePointCloud(contour, color, name)) @@ -59,7 +59,7 @@ displayEuclideanClusters(const pcl::PointCloud::CloudVectorType& cluster unsigned char blu[6] = {0, 0, 255, 0, 255, 255}; for (std::size_t i = 0; i < clusters.size(); i++) { - sprintf(name, "cluster_%d", static_cast(i)); + sprintf(name, "cluster_%d", int(i)); pcl::PointCloud::ConstPtr cluster_cloud( new pcl::PointCloud(clusters[i])); pcl::visualization::PointCloudColorHandlerCustom color0( @@ -126,15 +126,15 @@ removePreviousDataFromScreen(std::size_t prev_models_size, { char name[1024]; for (std::size_t i = 0; i < prev_models_size; i++) { - sprintf(name, "normal_%d", static_cast(i)); + sprintf(name, "normal_%d", unsigned(i)); viewer->removeShape(name); - sprintf(name, "plane_%02d", static_cast(i)); + sprintf(name, "plane_%02d", int(i)); viewer->removePointCloud(name); } for (std::size_t i = 0; i < prev_clusters_size; i++) { - sprintf(name, "cluster_%d", static_cast(i)); + sprintf(name, "cluster_%d", int(i)); viewer->removePointCloud(name); } } @@ -173,7 +173,7 @@ comparePointToRegion(PointT& pt, pt_vec[0] = pt.x; pt_vec[1] = pt.y; pt_vec[2] = pt.z; - Eigen::Vector3f projected(pt_vec - mc * static_cast(ptp_dist)); + Eigen::Vector3f projected(pt_vec - mc * float(ptp_dist)); PointT projected_pt; projected_pt.x = projected[0]; projected_pt.y = projected[1]; @@ -370,7 +370,7 @@ OrganizedSegmentationDemo::cloud_cb(const CloudConstPtr& cloud) mps.segment(regions); } double mps_end = pcl::getTime(); - std::cout << "MPS+Refine took: " << (mps_end - mps_start) << std::endl; + std::cout << "MPS+Refine took: " << double(mps_end - mps_start) << std::endl; // Segment Objects pcl::PointCloud::CloudVectorType clusters; diff --git a/apps/src/pcd_organized_edge_detection.cpp b/apps/src/pcd_organized_edge_detection.cpp index 37a38b82d72..e1eb6f9af11 100644 --- a/apps/src/pcd_organized_edge_detection.cpp +++ b/apps/src/pcd_organized_edge_detection.cpp @@ -204,7 +204,7 @@ compute(const pcl::PCLPointCloud2::ConstPtr& input, // Make gray point clouds for (auto& point : cloud->points) { - auto gray = static_cast((point.r + point.g + point.b) / 3); + std::uint8_t gray = std::uint8_t((point.r + point.g + point.b) / 3); point.r = point.g = point.b = gray; } diff --git a/apps/src/pcd_organized_multi_plane_segmentation.cpp b/apps/src/pcd_organized_multi_plane_segmentation.cpp index 1f20c205a3f..82d4507034d 100644 --- a/apps/src/pcd_organized_multi_plane_segmentation.cpp +++ b/apps/src/pcd_organized_multi_plane_segmentation.cpp @@ -50,14 +50,19 @@ class PCDOrganizedMultiPlaneSegmentation { pcl::visualization::PCLVisualizer viewer; typename pcl::PointCloud::ConstPtr cloud; bool refine_; - float threshold_{0.02f}; - bool depth_dependent_{true}; - bool polygon_refinement_{false}; + float threshold_; + bool depth_dependent_; + bool polygon_refinement_; public: PCDOrganizedMultiPlaneSegmentation(typename pcl::PointCloud::ConstPtr cloud_, bool refine) - : viewer("Viewer"), cloud(cloud_), refine_(refine) + : viewer("Viewer") + , cloud(cloud_) + , refine_(refine) + , threshold_(0.02f) + , depth_dependent_(true) + , polygon_refinement_(false) { viewer.setBackgroundColor(0, 0, 0); viewer.addCoordinateSystem(1.0, "global"); @@ -138,7 +143,8 @@ class PCDOrganizedMultiPlaneSegmentation { ne.setInputCloud(cloud); ne.compute(*normal_cloud); double normal_end = pcl::getTime(); - std::cout << "Normal Estimation took " << (normal_end - normal_start) << std::endl; + std::cout << "Normal Estimation took " << double(normal_end - normal_start) + << std::endl; double plane_extract_start = pcl::getTime(); mps.setInputNormals(normal_cloud); @@ -148,9 +154,10 @@ class PCDOrganizedMultiPlaneSegmentation { else mps.segment(regions); double plane_extract_end = pcl::getTime(); - std::cout << "Plane extraction took " << (plane_extract_end - plane_extract_start) + std::cout << "Plane extraction took " + << double(plane_extract_end - plane_extract_start) << " with planar regions found: " << regions.size() << std::endl; - std::cout << "Frame took " << (plane_extract_end - normal_start) << std::endl; + std::cout << "Frame took " << double(plane_extract_end - normal_start) << std::endl; typename pcl::PointCloud::Ptr cluster(new pcl::PointCloud); diff --git a/apps/src/pcd_select_object_plane.cpp b/apps/src/pcd_select_object_plane.cpp index c0584037b6b..b7914d72668 100644 --- a/apps/src/pcd_select_object_plane.cpp +++ b/apps/src/pcd_select_object_plane.cpp @@ -70,7 +70,8 @@ using namespace std::chrono_literals; template class ObjectSelection { public: - ObjectSelection() : plane_comparator_(new EdgeAwarePlaneComparator) + ObjectSelection() + : plane_comparator_(new EdgeAwarePlaneComparator), rgb_data_() { // Set the parameters for planar segmentation plane_comparator_->setDistanceThreshold(0.01f, false); @@ -649,7 +650,7 @@ class ObjectSelection { // Segmentation typename EdgeAwarePlaneComparator::Ptr plane_comparator_; PointIndices::Ptr plane_indices_; - unsigned char* rgb_data_{}; + unsigned char* rgb_data_; std::vector distance_map_; // Results diff --git a/apps/src/pcd_video_player/pcd_video_player.cpp b/apps/src/pcd_video_player/pcd_video_player.cpp index f7402765f88..66c3d4fa104 100644 --- a/apps/src/pcd_video_player/pcd_video_player.cpp +++ b/apps/src/pcd_video_player/pcd_video_player.cpp @@ -224,8 +224,8 @@ PCDVideoPlayer::selectFilesButtonPressed() return; } - for (const auto& qt_pcd_file : qt_pcd_files) { - pcd_files_.push_back(qt_pcd_file.toStdString()); + for (int i = 0; i < qt_pcd_files.size(); i++) { + pcd_files_.push_back(qt_pcd_files.at(i).toStdString()); } current_frame_ = 0; diff --git a/apps/src/ppf_object_recognition.cpp b/apps/src/ppf_object_recognition.cpp index 4be5cb54f36..b12ac2a0f43 100644 --- a/apps/src/ppf_object_recognition.cpp +++ b/apps/src/ppf_object_recognition.cpp @@ -9,7 +9,6 @@ #include #include -#include #include using namespace pcl; @@ -114,7 +113,7 @@ main(int argc, char** argv) ppf_estimator.compute(*cloud_model_ppf); PPFHashMapSearch::Ptr hashmap_search( - new PPFHashMapSearch(12.0f / 180.0f * static_cast(M_PI), 0.05f)); + new PPFHashMapSearch(12.0f / 180.0f * float(M_PI), 0.05f)); hashmap_search->setInputFeatureCloud(cloud_model_ppf); hashmap_search_vector.push_back(hashmap_search); } @@ -130,8 +129,7 @@ main(int argc, char** argv) // set parameters for the PPF registration procedure ppf_registration.setSceneReferencePointSamplingRate(10); ppf_registration.setPositionClusteringThreshold(0.2f); - ppf_registration.setRotationClusteringThreshold(30.0f / 180.0f * - static_cast(M_PI)); + ppf_registration.setRotationClusteringThreshold(30.0f / 180.0f * float(M_PI)); ppf_registration.setSearchMethod(hashmap_search_vector[model_i]); ppf_registration.setInputSource(cloud_models_with_normals[model_i]); ppf_registration.setInputTarget(cloud_scene_input); diff --git a/apps/src/pyramid_surface_matching.cpp b/apps/src/pyramid_surface_matching.cpp index 310c740b850..b325b4473d9 100644 --- a/apps/src/pyramid_surface_matching.cpp +++ b/apps/src/pyramid_surface_matching.cpp @@ -3,7 +3,6 @@ #include #include #include -#include // for KdTree using namespace pcl; @@ -85,11 +84,10 @@ main(int argc, char** argv) PCL_INFO("Finished calculating the features ...\n"); std::vector> dim_range_input, dim_range_target; for (std::size_t i = 0; i < 3; ++i) - dim_range_input.emplace_back(static_cast(-M_PI), static_cast(M_PI)); + dim_range_input.emplace_back(float(-M_PI), float(M_PI)); dim_range_input.emplace_back(0.0f, 1.0f); for (std::size_t i = 0; i < 3; ++i) - dim_range_target.emplace_back(static_cast(-M_PI) * 10.0f, - static_cast(M_PI) * 10.0f); + dim_range_target.emplace_back(float(-M_PI) * 10.0f, float(M_PI) * 10.0f); dim_range_target.emplace_back(0.0f, 50.0f); PyramidFeatureHistogram::Ptr pyramid_a( diff --git a/apps/src/render_views_tesselated_sphere.cpp b/apps/src/render_views_tesselated_sphere.cpp index 1d9c2536a26..9f6ba71ef8c 100644 --- a/apps/src/render_views_tesselated_sphere.cpp +++ b/apps/src/render_views_tesselated_sphere.cpp @@ -122,9 +122,8 @@ pcl::apps::RenderViewsTesselatedSphere::generateViews() sphere->GetPoint(ptIds_com[1], p2_com); sphere->GetPoint(ptIds_com[2], p3_com); vtkTriangle::TriangleCenter(p1_com, p2_com, p3_com, center); - cam_positions[i] = Eigen::Vector3f(static_cast(center[0]), - static_cast(center[1]), - static_cast(center[2])); + cam_positions[i] = + Eigen::Vector3f(float(center[0]), float(center[1]), float(center[2])); i++; } } @@ -133,9 +132,8 @@ pcl::apps::RenderViewsTesselatedSphere::generateViews() for (vtkIdType i = 0; i < sphere->GetNumberOfPoints(); i++) { double cam_pos[3]; sphere->GetPoint(i, cam_pos); - cam_positions[i] = Eigen::Vector3f(static_cast(cam_pos[0]), - static_cast(cam_pos[1]), - static_cast(cam_pos[2])); + cam_positions[i] = + Eigen::Vector3f(float(cam_pos[0]), float(cam_pos[1]), float(cam_pos[2])); } } @@ -277,7 +275,7 @@ pcl::apps::RenderViewsTesselatedSphere::generateViews() for (int x = 0; x < 4; x++) for (int y = 0; y < 4; y++) backToRealScale_eigen(x, y) = - static_cast(backToRealScale->GetMatrix()->GetElement(x, y)); + float(backToRealScale->GetMatrix()->GetElement(x, y)); pcl::PointCloud::Ptr cloud(new pcl::PointCloud); cloud->points.resize(resolution_ * resolution_); @@ -382,12 +380,12 @@ pcl::apps::RenderViewsTesselatedSphere::generateViews() ids = vtkIdTypeArray::SafeDownCast(hdw_selection->GetNode(0)->GetSelectionList()); double visible_area = 0; for (vtkIdType sel_id = 0; sel_id < (ids->GetNumberOfTuples()); sel_id++) { - int id_mesh = static_cast(ids->GetValue(sel_id)); + int id_mesh = int(ids->GetValue(sel_id)); if (id_mesh >= polydata->GetNumberOfPolys()) continue; vtkCell* cell = polydata->GetCell(id_mesh); - auto* triangle = dynamic_cast(cell); + vtkTriangle* triangle = dynamic_cast(cell); double p0[3]; double p1[3]; double p2[3]; @@ -398,7 +396,7 @@ pcl::apps::RenderViewsTesselatedSphere::generateViews() visible_area += area; } - entropies_.push_back(static_cast(visible_area / totalArea)); + entropies_.push_back(float(visible_area / totalArea)); } // transform cloud to give camera coordinates instead of world coordinates! @@ -408,7 +406,7 @@ pcl::apps::RenderViewsTesselatedSphere::generateViews() for (int x = 0; x < 4; x++) for (int y = 0; y < 4; y++) - trans_view(x, y) = static_cast(view_transform->GetElement(x, y)); + trans_view(x, y) = float(view_transform->GetElement(x, y)); // NOTE: vtk view coordinate system is different than the standard camera // coordinates (z forward, y down, x right) thus, the flipping in y and z @@ -447,8 +445,7 @@ pcl::apps::RenderViewsTesselatedSphere::generateViews() for (int x = 0; x < 4; x++) for (int y = 0; y < 4; y++) - pose_view(x, y) = - static_cast(transOCtoCC->GetMatrix()->GetElement(x, y)); + pose_view(x, y) = float(transOCtoCC->GetMatrix()->GetElement(x, y)); poses_.push_back(pose_view); } diff --git a/apps/src/stereo_ground_segmentation.cpp b/apps/src/stereo_ground_segmentation.cpp old mode 100644 new mode 100755 index f2eaa0d9aa3..576705de5d6 --- a/apps/src/stereo_ground_segmentation.cpp +++ b/apps/src/stereo_ground_segmentation.cpp @@ -265,15 +265,16 @@ class HRCSSegmentation { for (const auto& region_index : region_indices) { if (region_index.indices.size() > 1000) { - for (int index : region_index.indices) { - pcl::PointXYZ ground_pt( - (*cloud)[index].x, (*cloud)[index].y, (*cloud)[index].z); + for (std::size_t j = 0; j < region_index.indices.size(); j++) { + pcl::PointXYZ ground_pt((*cloud)[region_index.indices[j]].x, + (*cloud)[region_index.indices[j]].y, + (*cloud)[region_index.indices[j]].z); ground_cloud->points.push_back(ground_pt); - (*ground_image)[index].g = - static_cast(((*cloud)[index].g + 255) / 2); - (*label_image)[index].r = 0; - (*label_image)[index].g = 255; - (*label_image)[index].b = 0; + (*ground_image)[region_index.indices[j]].g = static_cast( + ((*cloud)[region_index.indices[j]].g + 255) / 2); + (*label_image)[region_index.indices[j]].r = 0; + (*label_image)[region_index.indices[j]].g = 255; + (*label_image)[region_index.indices[j]].b = 0; } // Compute plane info @@ -345,19 +346,21 @@ class HRCSSegmentation { pcl::PointCloud extended_ground_cloud; for (const auto& region_index : region_indices) { if (region_index.indices.size() > 1000) { - for (int index : region_index.indices) { + for (std::size_t j = 0; j < region_index.indices.size(); j++) { // Check to see if it has already been labeled - if ((*ground_image)[index].g == (*ground_image)[index].b) { - pcl::PointXYZ ground_pt( - (*cloud)[index].x, (*cloud)[index].y, (*cloud)[index].z); + if ((*ground_image)[region_index.indices[j]].g == + (*ground_image)[region_index.indices[j]].b) { + pcl::PointXYZ ground_pt((*cloud)[region_index.indices[j]].x, + (*cloud)[region_index.indices[j]].y, + (*cloud)[region_index.indices[j]].z); ground_cloud->points.push_back(ground_pt); - (*ground_image)[index].r = - static_cast(((*cloud)[index].r + 255) / 2); - (*ground_image)[index].g = - static_cast(((*cloud)[index].g + 255) / 2); - (*label_image)[index].r = 128; - (*label_image)[index].g = 128; - (*label_image)[index].b = 0; + (*ground_image)[region_index.indices[j]].r = static_cast( + ((*cloud)[region_index.indices[j]].r + 255) / 2); + (*ground_image)[region_index.indices[j]].g = static_cast( + ((*cloud)[region_index.indices[j]].g + 255) / 2); + (*label_image)[region_index.indices[j]].r = 128; + (*label_image)[region_index.indices[j]].g = 128; + (*label_image)[region_index.indices[j]].b = 0; } } } @@ -422,11 +425,11 @@ class HRCSSegmentation { if ((ptp_dist > 0.5) && (ptp_dist < 3.0)) { - for (int index : euclidean_label_index.indices) { - (*ground_image)[index].r = 255; - (*label_image)[index].r = 255; - (*label_image)[index].g = 0; - (*label_image)[index].b = 0; + for (std::size_t j = 0; j < euclidean_label_index.indices.size(); j++) { + (*ground_image)[euclidean_label_index.indices[j]].r = 255; + (*label_image)[euclidean_label_index.indices[j]].r = 255; + (*label_image)[euclidean_label_index.indices[j]].g = 0; + (*label_image)[euclidean_label_index.indices[j]].b = 0; } } } diff --git a/apps/src/surfel_smoothing_test.cpp b/apps/src/surfel_smoothing_test.cpp index 3e9e2d63f75..7b88a3bae6d 100644 --- a/apps/src/surfel_smoothing_test.cpp +++ b/apps/src/surfel_smoothing_test.cpp @@ -1,6 +1,5 @@ #include #include -#include // for KdTree #include using namespace pcl;