From 4a0003dcf28da58cc2cde4736263358646f0c52f Mon Sep 17 00:00:00 2001 From: Alexander Turkin Date: Thu, 10 Dec 2020 03:20:39 +0300 Subject: [PATCH 01/10] using reentrant qhull by default, qhull calls edits --- surface/include/pcl/surface/concave_hull.h | 2 +- surface/include/pcl/surface/convex_hull.h | 9 ++- .../include/pcl/surface/impl/concave_hull.hpp | 71 +++++++++-------- .../include/pcl/surface/impl/convex_hull.hpp | 76 +++++++++++-------- surface/include/pcl/surface/qhull.h | 16 ++-- 5 files changed, 98 insertions(+), 76 deletions(-) diff --git a/surface/include/pcl/surface/concave_hull.h b/surface/include/pcl/surface/concave_hull.h index c9640a6a194..b53fd7b9ed1 100644 --- a/surface/include/pcl/surface/concave_hull.h +++ b/surface/include/pcl/surface/concave_hull.h @@ -42,7 +42,7 @@ #include #ifdef HAVE_QHULL -#include // for MeshConstruction +#include namespace pcl { diff --git a/surface/include/pcl/surface/convex_hull.h b/surface/include/pcl/surface/convex_hull.h index d82bbf0b0ea..8c6062f2a8c 100644 --- a/surface/include/pcl/surface/convex_hull.h +++ b/surface/include/pcl/surface/convex_hull.h @@ -46,6 +46,7 @@ // PCL includes #include +#include #include namespace pcl @@ -88,11 +89,11 @@ namespace pcl using PointCloudConstPtr = typename PointCloud::ConstPtr; /** \brief Empty constructor. */ - ConvexHull () : compute_area_ (false), total_area_ (0), total_volume_ (0), dimension_ (0), - projection_angle_thresh_ (std::cos (0.174532925) ), qhull_flags ("qhull "), - x_axis_ (1.0, 0.0, 0.0), y_axis_ (0.0, 1.0, 0.0), z_axis_ (0.0, 0.0, 1.0) + ConvexHull() : compute_area_ (false), total_area_ (0), total_volume_ (0), dimension_ (0), + projection_angle_thresh_ (std::cos (0.174532925) ), qhull_flags ("qhull "), + x_axis_ (1.0, 0.0, 0.0), y_axis_ (0.0, 1.0, 0.0), z_axis_ (0.0, 0.0, 1.0) { - }; + } /** \brief Empty destructor */ ~ConvexHull () {} diff --git a/surface/include/pcl/surface/impl/concave_hull.hpp b/surface/include/pcl/surface/impl/concave_hull.hpp index 85f6811a294..1b4a4ad52e5 100644 --- a/surface/include/pcl/surface/impl/concave_hull.hpp +++ b/surface/include/pcl/surface/impl/concave_hull.hpp @@ -62,13 +62,13 @@ pcl::ConcaveHull::reconstruct (PointCloud &output) if (alpha_ <= 0) { PCL_ERROR ("[pcl::%s::reconstruct] Alpha parameter must be set to a positive number!\n", getClassName ().c_str ()); - output.clear (); + output.points.clear (); return; } if (!initCompute ()) { - output.clear (); + output.points.clear (); return; } @@ -91,13 +91,13 @@ pcl::ConcaveHull::reconstruct (PointCloud &output, std::vector::performReconstruction (PointCloud &alpha_shape, std: points[i * dim_ + 2] = static_cast (cloud_transformed[i].z); } + static FILE* null = fopen("/dev/null", "w"); + + qhT qh_qh; + qhT* qh = &qh_qh; + QHULL_LIB_CHECK + qh_zero(qh, null); + // Compute concave hull - exitcode = qh_new_qhull (dim_, static_cast (cloud_transformed.size ()), points, ismalloc, flags, outfile, errfile); + exitcode = qh_new_qhull (qh, dim_, static_cast (cloud_transformed.size ()), points, ismalloc, flags, outfile, errfile); if (exitcode != 0) { @@ -223,21 +230,21 @@ pcl::ConcaveHull::performReconstruction (PointCloud &alpha_shape, std: PCL_ERROR ("[pcl::%s::performReconstruction] ERROR: point cloud contains NaN values, consider running pcl::PassThrough filter first to remove NaNs!\n", getClassName ().c_str ()); } - alpha_shape.resize (0); + alpha_shape.points.resize (0); alpha_shape.width = alpha_shape.height = 0; polygons.resize (0); - qh_freeqhull (!qh_ALL); + qh_freeqhull (qh, !qh_ALL); int curlong, totlong; - qh_memfreeshort (&curlong, &totlong); + qh_memfreeshort (qh, &curlong, &totlong); return; } - qh_setvoronoi_all (); + qh_setvoronoi_all (qh); - int num_vertices = qh num_vertices; - alpha_shape.resize (num_vertices); + int num_vertices = qh->num_vertices; + alpha_shape.points.resize (num_vertices); vertexT *vertex; // Max vertex id @@ -253,11 +260,11 @@ pcl::ConcaveHull::performReconstruction (PointCloud &alpha_shape, std: ++max_vertex_id; std::vector qhid_to_pcidx (max_vertex_id); - int num_facets = qh num_facets; + int num_facets = qh->num_facets; if (dim_ == 3) { - setT *triangles_set = qh_settemp (4 * num_facets); + setT *triangles_set = qh_settemp (qh, 4 * num_facets); if (voronoi_centers_) voronoi_centers_->points.resize (num_facets); @@ -283,29 +290,29 @@ pcl::ConcaveHull::performReconstruction (PointCloud &alpha_shape, std: if (r <= alpha_) { // all triangles in tetrahedron are good, add them all to the alpha shape (triangles_set) - qh_makeridges (facet); + qh_makeridges (qh, facet); facet->good = true; - facet->visitid = qh visit_id; + facet->visitid = qh->visit_id; ridgeT *ridge, **ridgep; FOREACHridge_ (facet->ridges) { facetT *neighb = otherfacet_ (ridge, facet); - if ((neighb->visitid != qh visit_id)) - qh_setappend (&triangles_set, ridge); + if ((neighb->visitid != qh->visit_id)) + qh_setappend (qh, &triangles_set, ridge); } } else { // consider individual triangles from the tetrahedron... facet->good = false; - facet->visitid = qh visit_id; - qh_makeridges (facet); + facet->visitid = qh->visit_id; + qh_makeridges (qh, facet); ridgeT *ridge, **ridgep; FOREACHridge_ (facet->ridges) { facetT *neighb; neighb = otherfacet_ (ridge, facet); - if ((neighb->visitid != qh visit_id)) + if ((neighb->visitid != qh->visit_id)) { // check if individual triangle is good and add it to triangles_set @@ -322,7 +329,7 @@ pcl::ConcaveHull::performReconstruction (PointCloud &alpha_shape, std: double r = pcl::getCircumcircleRadius (a, b, c); if (r <= alpha_) - qh_setappend (&triangles_set, ridge); + qh_setappend (qh, &triangles_set, ridge); } } } @@ -354,7 +361,7 @@ pcl::ConcaveHull::performReconstruction (PointCloud &alpha_shape, std: { polygons[triangles].vertices.resize (3); int vertex_n, vertex_i; - FOREACHvertex_i_ ((*ridge).vertices) //3 vertices per ridge! + FOREACHvertex_i_ (qh, (*ridge).vertices) //3 vertices per ridge! { if (!added_vertices[vertex->id]) { @@ -375,7 +382,7 @@ pcl::ConcaveHull::performReconstruction (PointCloud &alpha_shape, std: } } - alpha_shape.resize (vertices); + alpha_shape.points.resize (vertices); alpha_shape.width = alpha_shape.size (); alpha_shape.height = 1; } @@ -383,7 +390,7 @@ pcl::ConcaveHull::performReconstruction (PointCloud &alpha_shape, std: { // Compute the alpha complex for the set of points // Filters the delaunay triangles - setT *edges_set = qh_settemp (3 * num_facets); + setT *edges_set = qh_settemp (qh, 3 * num_facets); if (voronoi_centers_) voronoi_centers_->points.resize (num_facets); @@ -403,12 +410,12 @@ pcl::ConcaveHull::performReconstruction (PointCloud &alpha_shape, std: if (r <= alpha_) { pcl::Vertices facet_vertices; //TODO: is not used!! - qh_makeridges (facet); + qh_makeridges (qh, facet); facet->good = true; ridgeT *ridge, **ridgep; FOREACHridge_ (facet->ridges) - qh_setappend (&edges_set, ridge); + qh_setappend (qh, &edges_set, ridge); if (voronoi_centers_) { @@ -438,7 +445,7 @@ pcl::ConcaveHull::performReconstruction (PointCloud &alpha_shape, std: std::vector pcd_indices; pcd_indices.resize (2); - FOREACHvertex_i_ ((*ridge).vertices) //in 2-dim, 2 vertices per ridge! + FOREACHvertex_i_ (qh, (*ridge).vertices) //in 2-dim, 2 vertices per ridge! { if (!added_vertices[vertex->id]) { @@ -469,10 +476,10 @@ pcl::ConcaveHull::performReconstruction (PointCloud &alpha_shape, std: } } - alpha_shape.resize (vertices); + alpha_shape.points.resize (vertices); PointCloud alpha_shape_sorted; - alpha_shape_sorted.resize (vertices); + alpha_shape_sorted.points.resize (vertices); // iterate over edges until they are empty! std::map >::iterator curr = edges.begin (); @@ -487,7 +494,7 @@ pcl::ConcaveHull::performReconstruction (PointCloud &alpha_shape, std: { alpha_shape_sorted[sorted_idx] = alpha_shape[(*curr).first]; // check where we can go from (*curr).first - for (const auto &i : (*curr).second) + for (const int &i : (*curr).second) { if (!used[i]) { @@ -540,9 +547,9 @@ pcl::ConcaveHull::performReconstruction (PointCloud &alpha_shape, std: voronoi_centers_->points.resize (dd); } - qh_freeqhull (!qh_ALL); + qh_freeqhull (qh, !qh_ALL); int curlong, totlong; - qh_memfreeshort (&curlong, &totlong); + qh_memfreeshort (qh, &curlong, &totlong); Eigen::Affine3d transInverse = transform1.inverse (); pcl::transformPointCloud (alpha_shape, alpha_shape, transInverse); diff --git a/surface/include/pcl/surface/impl/convex_hull.hpp b/surface/include/pcl/surface/impl/convex_hull.hpp index 3d911b7a0a4..acc08baf298 100644 --- a/surface/include/pcl/surface/impl/convex_hull.hpp +++ b/surface/include/pcl/surface/impl/convex_hull.hpp @@ -95,7 +95,7 @@ pcl::ConvexHull::performReconstruction2D (PointCloud &hull, std::vecto } pcl::PointCloud normal_calc_cloud; - normal_calc_cloud.resize (3); + normal_calc_cloud.points.resize (3); normal_calc_cloud[0] = p0; normal_calc_cloud[1] = p1; normal_calc_cloud[2] = p2; @@ -180,28 +180,35 @@ pcl::ConvexHull::performReconstruction2D (PointCloud &hull, std::vecto // This should only happen if we had invalid input PCL_ERROR ("[pcl::%s::performReconstruction2D] Invalid input!\n", getClassName ().c_str ()); } + + static FILE* null = fopen("/dev/null", "w"); + + qhT qh_qh; + qhT* qh = &qh_qh; + QHULL_LIB_CHECK + qh_zero(qh, null); // Compute convex hull - int exitcode = qh_new_qhull (dimension, static_cast (indices_->size ()), points, ismalloc, const_cast (flags), outfile, errfile); + int exitcode = qh_new_qhull (qh, dimension, static_cast (indices_->size ()), points, ismalloc, const_cast (flags), outfile, errfile); #ifdef HAVE_QHULL_2011 if (compute_area_) { - qh_prepare_output(); + qh_prepare_output(qh); } #endif // 0 if no error from qhull or it doesn't find any vertices - if (exitcode != 0 || qh num_vertices == 0) + if (exitcode != 0 || qh->num_vertices == 0) { PCL_ERROR ("[pcl::%s::performReconstrution2D] ERROR: qhull was unable to compute a convex hull for the given point cloud (%lu)!\n", getClassName ().c_str (), indices_->size ()); - hull.resize (0); + hull.points.resize (0); hull.width = hull.height = 0; polygons.resize (0); - qh_freeqhull (!qh_ALL); + qh_freeqhull (qh, !qh_ALL); int curlong, totlong; - qh_memfreeshort (&curlong, &totlong); + qh_memfreeshort (qh, &curlong, &totlong); return; } @@ -209,12 +216,12 @@ pcl::ConvexHull::performReconstruction2D (PointCloud &hull, std::vecto // Qhull returns the area in volume for 2D if (compute_area_) { - total_area_ = qh totvol; + total_area_ = qh->totvol; total_volume_ = 0.0; } - int num_vertices = qh num_vertices; - hull.resize (num_vertices); + int num_vertices = qh->num_vertices; + hull.points.resize (num_vertices); memset (&hull.points[0], hull.size (), sizeof (PointInT)); vertexT * vertex; @@ -226,8 +233,8 @@ pcl::ConvexHull::performReconstruction2D (PointCloud &hull, std::vecto FORALLvertices { - hull[i] = (*input_)[(*indices_)[qh_pointid (vertex->point)]]; - idx_points[i].first = qh_pointid (vertex->point); + hull[i] = (*input_)[(*indices_)[qh_pointid (qh, vertex->point)]]; + idx_points[i].first = qh_pointid (qh, vertex->point); ++i; } @@ -274,9 +281,9 @@ pcl::ConvexHull::performReconstruction2D (PointCloud &hull, std::vecto polygons[0].vertices[j] = static_cast (j); } - qh_freeqhull (!qh_ALL); + qh_freeqhull (qh, !qh_ALL); int curlong, totlong; - qh_memfreeshort (&curlong, &totlong); + qh_memfreeshort (qh, &curlong, &totlong); hull.width = hull.size (); hull.height = 1; @@ -320,12 +327,19 @@ pcl::ConvexHull::performReconstruction3D ( points[j + 2] = static_cast ((*input_)[(*indices_)[i]].z); } + static FILE* null = fopen("/dev/null", "w"); + + qhT qh_qh; + qhT* qh = &qh_qh; + QHULL_LIB_CHECK + qh_zero(qh, null); + // Compute convex hull - int exitcode = qh_new_qhull (dimension, static_cast (indices_->size ()), points, ismalloc, const_cast (flags), outfile, errfile); + int exitcode = qh_new_qhull (qh, dimension, static_cast (indices_->size ()), points, ismalloc, const_cast (flags), outfile, errfile); #ifdef HAVE_QHULL_2011 if (compute_area_) { - qh_prepare_output(); + qh_prepare_output(qh); } #endif @@ -337,23 +351,23 @@ pcl::ConvexHull::performReconstruction3D ( getClassName().c_str(), static_cast(input_->size())); - hull.resize (0); + hull.points.resize (0); hull.width = hull.height = 0; polygons.resize (0); - qh_freeqhull (!qh_ALL); + qh_freeqhull (qh, !qh_ALL); int curlong, totlong; - qh_memfreeshort (&curlong, &totlong); + qh_memfreeshort (qh, &curlong, &totlong); return; } - qh_triangulate (); + qh_triangulate (qh); - int num_facets = qh num_facets; + int num_facets = qh->num_facets; - int num_vertices = qh num_vertices; - hull.resize (num_vertices); + int num_vertices = qh->num_vertices; + hull.points.resize (num_vertices); vertexT * vertex; int i = 0; @@ -375,7 +389,7 @@ pcl::ConvexHull::performReconstruction3D ( FORALLvertices { // Add vertices to hull point_cloud and store index - hull_indices_.indices.push_back ((*indices_)[qh_pointid (vertex->point)]); + hull_indices_.indices.push_back ((*indices_)[qh_pointid (qh, vertex->point)]); hull[i] = (*input_)[hull_indices_.indices.back ()]; qhid_to_pcidx[vertex->id] = i; // map the vertex id of qhull to the point cloud index @@ -384,8 +398,8 @@ pcl::ConvexHull::performReconstruction3D ( if (compute_area_) { - total_area_ = qh totarea; - total_volume_ = qh totvol; + total_area_ = qh->totarea; + total_volume_ = qh->totvol; } if (fill_polygon_data) @@ -400,16 +414,16 @@ pcl::ConvexHull::performReconstruction3D ( // Needed by FOREACHvertex_i_ int vertex_n, vertex_i; - FOREACHvertex_i_ ((*facet).vertices) + FOREACHvertex_i_ (qh, (*facet).vertices) //facet_vertices.vertices.push_back (qhid_to_pcidx[vertex->id]); polygons[dd].vertices[vertex_i] = qhid_to_pcidx[vertex->id]; ++dd; } } // Deallocates memory (also the points) - qh_freeqhull (!qh_ALL); + qh_freeqhull (qh, !qh_ALL); int curlong, totlong; - qh_memfreeshort (&curlong, &totlong); + qh_memfreeshort (qh, &curlong, &totlong); hull.width = hull.size (); hull.height = 1; @@ -441,7 +455,7 @@ pcl::ConvexHull::reconstruct (PointCloud &points) points.header = input_->header; if (!initCompute () || input_->points.empty () || indices_->empty ()) { - points.clear (); + points.points.clear (); return; } @@ -484,7 +498,7 @@ pcl::ConvexHull::reconstruct (PointCloud &points, std::vectorheader; if (!initCompute () || input_->points.empty () || indices_->empty ()) { - points.clear (); + points.points.clear (); return; } diff --git a/surface/include/pcl/surface/qhull.h b/surface/include/pcl/surface/qhull.h index 39eee73e401..f119b2109a6 100644 --- a/surface/include/pcl/surface/qhull.h +++ b/surface/include/pcl/surface/qhull.h @@ -49,14 +49,14 @@ extern "C" { #ifdef HAVE_QHULL_2011 -# include "libqhull/libqhull.h" -# include "libqhull/mem.h" -# include "libqhull/qset.h" -# include "libqhull/geom.h" -# include "libqhull/merge.h" -# include "libqhull/poly.h" -# include "libqhull/io.h" -# include "libqhull/stat.h" +# include "libqhull_r/libqhull_r.h" +# include "libqhull_r/mem_r.h" +# include "libqhull_r/qset_r.h" +# include "libqhull_r/geom_r.h" +# include "libqhull_r/merge_r.h" +# include "libqhull_r/poly_r.h" +# include "libqhull_r/io_r.h" +# include "libqhull_r/stat_r.h" #else # include "qhull/qhull.h" # include "qhull/mem.h" From 33b093275f759e1dd9af0417ac1f3400cb09a81c Mon Sep 17 00:00:00 2001 From: Alexander Turkin Date: Thu, 10 Dec 2020 03:46:31 +0300 Subject: [PATCH 02/10] using reentrant qhull by default, qhull calls edits --- surface/include/pcl/surface/concave_hull.h | 2 +- surface/include/pcl/surface/convex_hull.h | 7 +++---- .../include/pcl/surface/impl/concave_hull.hpp | 20 +++++++++---------- .../include/pcl/surface/impl/convex_hull.hpp | 14 ++++++------- 4 files changed, 21 insertions(+), 22 deletions(-) diff --git a/surface/include/pcl/surface/concave_hull.h b/surface/include/pcl/surface/concave_hull.h index b53fd7b9ed1..c9640a6a194 100644 --- a/surface/include/pcl/surface/concave_hull.h +++ b/surface/include/pcl/surface/concave_hull.h @@ -42,7 +42,7 @@ #include #ifdef HAVE_QHULL -#include +#include // for MeshConstruction namespace pcl { diff --git a/surface/include/pcl/surface/convex_hull.h b/surface/include/pcl/surface/convex_hull.h index 8c6062f2a8c..917b42c412f 100644 --- a/surface/include/pcl/surface/convex_hull.h +++ b/surface/include/pcl/surface/convex_hull.h @@ -46,7 +46,6 @@ // PCL includes #include -#include #include namespace pcl @@ -89,9 +88,9 @@ namespace pcl using PointCloudConstPtr = typename PointCloud::ConstPtr; /** \brief Empty constructor. */ - ConvexHull() : compute_area_ (false), total_area_ (0), total_volume_ (0), dimension_ (0), - projection_angle_thresh_ (std::cos (0.174532925) ), qhull_flags ("qhull "), - x_axis_ (1.0, 0.0, 0.0), y_axis_ (0.0, 1.0, 0.0), z_axis_ (0.0, 0.0, 1.0) + ConvexHull () : compute_area_ (false), total_area_ (0), total_volume_ (0), dimension_ (0), + projection_angle_thresh_ (std::cos (0.174532925) ), qhull_flags ("qhull "), + x_axis_ (1.0, 0.0, 0.0), y_axis_ (0.0, 1.0, 0.0), z_axis_ (0.0, 0.0, 1.0) { } diff --git a/surface/include/pcl/surface/impl/concave_hull.hpp b/surface/include/pcl/surface/impl/concave_hull.hpp index 1b4a4ad52e5..a34673698b9 100644 --- a/surface/include/pcl/surface/impl/concave_hull.hpp +++ b/surface/include/pcl/surface/impl/concave_hull.hpp @@ -62,13 +62,13 @@ pcl::ConcaveHull::reconstruct (PointCloud &output) if (alpha_ <= 0) { PCL_ERROR ("[pcl::%s::reconstruct] Alpha parameter must be set to a positive number!\n", getClassName ().c_str ()); - output.points.clear (); + output.clear (); return; } if (!initCompute ()) { - output.points.clear (); + output.clear (); return; } @@ -91,13 +91,13 @@ pcl::ConcaveHull::reconstruct (PointCloud &output, std::vector::performReconstruction (PointCloud &alpha_shape, std: PCL_ERROR ("[pcl::%s::performReconstruction] ERROR: point cloud contains NaN values, consider running pcl::PassThrough filter first to remove NaNs!\n", getClassName ().c_str ()); } - alpha_shape.points.resize (0); + alpha_shape.resize (0); alpha_shape.width = alpha_shape.height = 0; polygons.resize (0); @@ -244,7 +244,7 @@ pcl::ConcaveHull::performReconstruction (PointCloud &alpha_shape, std: qh_setvoronoi_all (qh); int num_vertices = qh->num_vertices; - alpha_shape.points.resize (num_vertices); + alpha_shape.resize (num_vertices); vertexT *vertex; // Max vertex id @@ -382,7 +382,7 @@ pcl::ConcaveHull::performReconstruction (PointCloud &alpha_shape, std: } } - alpha_shape.points.resize (vertices); + alpha_shape.resize (vertices); alpha_shape.width = alpha_shape.size (); alpha_shape.height = 1; } @@ -476,10 +476,10 @@ pcl::ConcaveHull::performReconstruction (PointCloud &alpha_shape, std: } } - alpha_shape.points.resize (vertices); + alpha_shape.resize (vertices); PointCloud alpha_shape_sorted; - alpha_shape_sorted.points.resize (vertices); + alpha_shape_sorted.resize (vertices); // iterate over edges until they are empty! std::map >::iterator curr = edges.begin (); @@ -494,7 +494,7 @@ pcl::ConcaveHull::performReconstruction (PointCloud &alpha_shape, std: { alpha_shape_sorted[sorted_idx] = alpha_shape[(*curr).first]; // check where we can go from (*curr).first - for (const int &i : (*curr).second) + for (const auto &i : (*curr).second) { if (!used[i]) { diff --git a/surface/include/pcl/surface/impl/convex_hull.hpp b/surface/include/pcl/surface/impl/convex_hull.hpp index acc08baf298..67f7967c215 100644 --- a/surface/include/pcl/surface/impl/convex_hull.hpp +++ b/surface/include/pcl/surface/impl/convex_hull.hpp @@ -95,7 +95,7 @@ pcl::ConvexHull::performReconstruction2D (PointCloud &hull, std::vecto } pcl::PointCloud normal_calc_cloud; - normal_calc_cloud.points.resize (3); + normal_calc_cloud.resize (3); normal_calc_cloud[0] = p0; normal_calc_cloud[1] = p1; normal_calc_cloud[2] = p2; @@ -202,7 +202,7 @@ pcl::ConvexHull::performReconstruction2D (PointCloud &hull, std::vecto { PCL_ERROR ("[pcl::%s::performReconstrution2D] ERROR: qhull was unable to compute a convex hull for the given point cloud (%lu)!\n", getClassName ().c_str (), indices_->size ()); - hull.points.resize (0); + hull.resize (0); hull.width = hull.height = 0; polygons.resize (0); @@ -221,7 +221,7 @@ pcl::ConvexHull::performReconstruction2D (PointCloud &hull, std::vecto } int num_vertices = qh->num_vertices; - hull.points.resize (num_vertices); + hull.resize (num_vertices); memset (&hull.points[0], hull.size (), sizeof (PointInT)); vertexT * vertex; @@ -351,7 +351,7 @@ pcl::ConvexHull::performReconstruction3D ( getClassName().c_str(), static_cast(input_->size())); - hull.points.resize (0); + hull.resize (0); hull.width = hull.height = 0; polygons.resize (0); @@ -367,7 +367,7 @@ pcl::ConvexHull::performReconstruction3D ( int num_facets = qh->num_facets; int num_vertices = qh->num_vertices; - hull.points.resize (num_vertices); + hull.resize (num_vertices); vertexT * vertex; int i = 0; @@ -455,7 +455,7 @@ pcl::ConvexHull::reconstruct (PointCloud &points) points.header = input_->header; if (!initCompute () || input_->points.empty () || indices_->empty ()) { - points.points.clear (); + points.clear (); return; } @@ -498,7 +498,7 @@ pcl::ConvexHull::reconstruct (PointCloud &points, std::vectorheader; if (!initCompute () || input_->points.empty () || indices_->empty ()) { - points.points.clear (); + points.clear (); return; } From d7908b59795811afff1049f887fdc383138d566e Mon Sep 17 00:00:00 2001 From: Alexander Turkin Date: Thu, 10 Dec 2020 03:55:58 +0300 Subject: [PATCH 03/10] using reentrant qhull by default, qhull calls edits --- surface/include/pcl/surface/impl/concave_hull.hpp | 4 +--- surface/include/pcl/surface/impl/convex_hull.hpp | 4 +--- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/surface/include/pcl/surface/impl/concave_hull.hpp b/surface/include/pcl/surface/impl/concave_hull.hpp index a34673698b9..5319d6cf227 100644 --- a/surface/include/pcl/surface/impl/concave_hull.hpp +++ b/surface/include/pcl/surface/impl/concave_hull.hpp @@ -194,12 +194,10 @@ pcl::ConcaveHull::performReconstruction (PointCloud &alpha_shape, std: points[i * dim_ + 2] = static_cast (cloud_transformed[i].z); } - static FILE* null = fopen("/dev/null", "w"); - qhT qh_qh; qhT* qh = &qh_qh; QHULL_LIB_CHECK - qh_zero(qh, null); + qh_zero(qh, errfile); // Compute concave hull exitcode = qh_new_qhull (qh, dim_, static_cast (cloud_transformed.size ()), points, ismalloc, flags, outfile, errfile); diff --git a/surface/include/pcl/surface/impl/convex_hull.hpp b/surface/include/pcl/surface/impl/convex_hull.hpp index 67f7967c215..8eef0a5b920 100644 --- a/surface/include/pcl/surface/impl/convex_hull.hpp +++ b/surface/include/pcl/surface/impl/convex_hull.hpp @@ -181,12 +181,10 @@ pcl::ConvexHull::performReconstruction2D (PointCloud &hull, std::vecto PCL_ERROR ("[pcl::%s::performReconstruction2D] Invalid input!\n", getClassName ().c_str ()); } - static FILE* null = fopen("/dev/null", "w"); - qhT qh_qh; qhT* qh = &qh_qh; QHULL_LIB_CHECK - qh_zero(qh, null); + qh_zero(qh, errfile); // Compute convex hull int exitcode = qh_new_qhull (qh, dimension, static_cast (indices_->size ()), points, ismalloc, const_cast (flags), outfile, errfile); From 66749819bb56813475cb3f690aab475648384930 Mon Sep 17 00:00:00 2001 From: Alexander Turkin Date: Thu, 10 Dec 2020 05:01:46 +0300 Subject: [PATCH 04/10] cmake for qhull fix --- cmake/Modules/FindQhull.cmake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmake/Modules/FindQhull.cmake b/cmake/Modules/FindQhull.cmake index 7f3cf90dc11..f6504801da7 100644 --- a/cmake/Modules/FindQhull.cmake +++ b/cmake/Modules/FindQhull.cmake @@ -15,8 +15,8 @@ if(QHULL_USE_STATIC) set(QHULL_RELEASE_NAME qhullstatic) set(QHULL_DEBUG_NAME qhullstatic_d) else() - set(QHULL_RELEASE_NAME qhull_p qhull${QHULL_MAJOR_VERSION} qhull) - set(QHULL_DEBUG_NAME qhull_p_d qhull${QHULL_MAJOR_VERSION}_d qhull_d${QHULL_MAJOR_VERSION} qhull_d) + set(QHULL_RELEASE_NAME qhull_r qhull${QHULL_MAJOR_VERSION} qhull) + set(QHULL_DEBUG_NAME qhull_r_d qhull${QHULL_MAJOR_VERSION}_d qhull_d${QHULL_MAJOR_VERSION} qhull_d) endif() find_file(QHULL_HEADER From fe652528785c598f638cf3052b19ed46a6d539ce Mon Sep 17 00:00:00 2001 From: Alexander Turkin Date: Thu, 10 Dec 2020 05:53:04 +0300 Subject: [PATCH 05/10] cmake for qhull fix --- cmake/Modules/FindQhull.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/Modules/FindQhull.cmake b/cmake/Modules/FindQhull.cmake index f6504801da7..ff7cd4dd53d 100644 --- a/cmake/Modules/FindQhull.cmake +++ b/cmake/Modules/FindQhull.cmake @@ -9,7 +9,7 @@ # If QHULL_USE_STATIC is specified then look for static libraries ONLY else # look for shared ones -set(QHULL_MAJOR_VERSION 6) +set(QHULL_MAJOR_VERSION 8) if(QHULL_USE_STATIC) set(QHULL_RELEASE_NAME qhullstatic) From f8dd1f547fd7b9d3bbfd41c9e341f1a48b258152 Mon Sep 17 00:00:00 2001 From: Alexander Turkin Date: Tue, 16 Feb 2021 10:44:45 +0300 Subject: [PATCH 06/10] static libs made reentrant as well --- cmake/Modules/FindQhull.cmake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmake/Modules/FindQhull.cmake b/cmake/Modules/FindQhull.cmake index ff7cd4dd53d..93797c22715 100644 --- a/cmake/Modules/FindQhull.cmake +++ b/cmake/Modules/FindQhull.cmake @@ -12,8 +12,8 @@ set(QHULL_MAJOR_VERSION 8) if(QHULL_USE_STATIC) - set(QHULL_RELEASE_NAME qhullstatic) - set(QHULL_DEBUG_NAME qhullstatic_d) + set(QHULL_RELEASE_NAME qhullstatic_r) + set(QHULL_DEBUG_NAME qhullstatic_r_d) else() set(QHULL_RELEASE_NAME qhull_r qhull${QHULL_MAJOR_VERSION} qhull) set(QHULL_DEBUG_NAME qhull_r_d qhull${QHULL_MAJOR_VERSION}_d qhull_d${QHULL_MAJOR_VERSION} qhull_d) From 770485052326d719294a26a2deebc13e1aef1889 Mon Sep 17 00:00:00 2001 From: Alexander Turkin Date: Mon, 19 Apr 2021 23:34:54 +0300 Subject: [PATCH 07/10] turning surface tests on for 20.10 --- .ci/azure-pipelines/azure-pipelines.yaml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.ci/azure-pipelines/azure-pipelines.yaml b/.ci/azure-pipelines/azure-pipelines.yaml index 511e093a8ee..f65f912d021 100644 --- a/.ci/azure-pipelines/azure-pipelines.yaml +++ b/.ci/azure-pipelines/azure-pipelines.yaml @@ -38,8 +38,6 @@ stages: CC: gcc CXX: g++ BUILD_GPU: OFF - # surface is not ready for re-entrant QHull - CMAKE_ARGS: '-DBUILD_tests_surface=OFF' container: $[ variables['CONTAINER'] ] timeoutInMinutes: 0 variables: From 4f9c338f69caacd62e3a5c7a36202c5d70018325 Mon Sep 17 00:00:00 2001 From: Alexander Turkin Date: Sat, 8 May 2021 12:39:09 +0300 Subject: [PATCH 08/10] typos fixes, using errfile for qh_zero second param --- cmake/Modules/FindQhull.cmake | 4 ++-- surface/include/pcl/surface/impl/convex_hull.hpp | 4 +--- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/cmake/Modules/FindQhull.cmake b/cmake/Modules/FindQhull.cmake index 93797c22715..720f7fd6323 100644 --- a/cmake/Modules/FindQhull.cmake +++ b/cmake/Modules/FindQhull.cmake @@ -13,10 +13,10 @@ set(QHULL_MAJOR_VERSION 8) if(QHULL_USE_STATIC) set(QHULL_RELEASE_NAME qhullstatic_r) - set(QHULL_DEBUG_NAME qhullstatic_r_d) + set(QHULL_DEBUG_NAME qhullstatic_rd) else() set(QHULL_RELEASE_NAME qhull_r qhull${QHULL_MAJOR_VERSION} qhull) - set(QHULL_DEBUG_NAME qhull_r_d qhull${QHULL_MAJOR_VERSION}_d qhull_d${QHULL_MAJOR_VERSION} qhull_d) + set(QHULL_DEBUG_NAME qhull_rd qhull${QHULL_MAJOR_VERSION}_d qhull_d${QHULL_MAJOR_VERSION} qhull_d) endif() find_file(QHULL_HEADER diff --git a/surface/include/pcl/surface/impl/convex_hull.hpp b/surface/include/pcl/surface/impl/convex_hull.hpp index d42fa9df73e..31f316eae47 100644 --- a/surface/include/pcl/surface/impl/convex_hull.hpp +++ b/surface/include/pcl/surface/impl/convex_hull.hpp @@ -324,12 +324,10 @@ pcl::ConvexHull::performReconstruction3D ( points[j + 2] = static_cast ((*input_)[(*indices_)[i]].z); } - static FILE* null = fopen("/dev/null", "w"); - qhT qh_qh; qhT* qh = &qh_qh; QHULL_LIB_CHECK - qh_zero(qh, null); + qh_zero(qh, errfile); // Compute convex hull int exitcode = qh_new_qhull (qh, dimension, static_cast (indices_->size ()), points, ismalloc, const_cast (flags), outfile, errfile); From 211b111e5951e32546d603d441a86d056e36dd2b Mon Sep 17 00:00:00 2001 From: Alexander Turkin Date: Sat, 8 May 2021 12:41:51 +0300 Subject: [PATCH 09/10] removing HAVE_QHULL_2011 and assuming its always true --- cmake/Modules/FindQhull.cmake | 2 -- pcl_config.h.in | 2 -- .../include/pcl/surface/impl/convex_hull.hpp | 8 ------ surface/include/pcl/surface/qhull.h | 27 ++++++------------- 4 files changed, 8 insertions(+), 31 deletions(-) diff --git a/cmake/Modules/FindQhull.cmake b/cmake/Modules/FindQhull.cmake index 720f7fd6323..6427ffdae2e 100644 --- a/cmake/Modules/FindQhull.cmake +++ b/cmake/Modules/FindQhull.cmake @@ -30,10 +30,8 @@ set(QHULL_HEADER "${QHULL_HEADER}" CACHE INTERNAL "QHull header" FORCE ) if(QHULL_HEADER) get_filename_component(qhull_header ${QHULL_HEADER} NAME_WE) if("${qhull_header}" STREQUAL "qhull") - set(HAVE_QHULL_2011 OFF) get_filename_component(QHULL_INCLUDE_DIR ${QHULL_HEADER} PATH) elseif("${qhull_header}" STREQUAL "libqhull") - set(HAVE_QHULL_2011 ON) get_filename_component(QHULL_INCLUDE_DIR ${QHULL_HEADER} PATH) get_filename_component(QHULL_INCLUDE_DIR ${QHULL_INCLUDE_DIR} PATH) endif() diff --git a/pcl_config.h.in b/pcl_config.h.in index 3eccb95c975..e41128d2dc5 100644 --- a/pcl_config.h.in +++ b/pcl_config.h.in @@ -42,8 +42,6 @@ #cmakedefine HAVE_QHULL 1 -#cmakedefine HAVE_QHULL_2011 1 - #cmakedefine HAVE_CUDA 1 #cmakedefine HAVE_ENSENSO 1 diff --git a/surface/include/pcl/surface/impl/convex_hull.hpp b/surface/include/pcl/surface/impl/convex_hull.hpp index 31f316eae47..aa36cdd9efb 100644 --- a/surface/include/pcl/surface/impl/convex_hull.hpp +++ b/surface/include/pcl/surface/impl/convex_hull.hpp @@ -136,10 +136,8 @@ pcl::ConvexHull::performReconstruction2D (PointCloud &hull, std::vecto // output from qh_produce_output(), use NULL to skip qh_produce_output() FILE *outfile = nullptr; -#ifndef HAVE_QHULL_2011 if (compute_area_) outfile = stderr; -#endif // option flags for qhull, see qh_opt.htm const char* flags = qhull_flags.c_str (); @@ -188,12 +186,10 @@ pcl::ConvexHull::performReconstruction2D (PointCloud &hull, std::vecto // Compute convex hull int exitcode = qh_new_qhull (qh, dimension, static_cast (indices_->size ()), points, ismalloc, const_cast (flags), outfile, errfile); -#ifdef HAVE_QHULL_2011 if (compute_area_) { qh_prepare_output(qh); } -#endif // 0 if no error from qhull or it doesn't find any vertices if (exitcode != 0 || qh->num_vertices == 0) @@ -303,10 +299,8 @@ pcl::ConvexHull::performReconstruction3D ( // output from qh_produce_output(), use NULL to skip qh_produce_output() FILE *outfile = nullptr; -#ifndef HAVE_QHULL_2011 if (compute_area_) outfile = stderr; -#endif // option flags for qhull, see qh_opt.htm const char *flags = qhull_flags.c_str (); @@ -331,12 +325,10 @@ pcl::ConvexHull::performReconstruction3D ( // Compute convex hull int exitcode = qh_new_qhull (qh, dimension, static_cast (indices_->size ()), points, ismalloc, const_cast (flags), outfile, errfile); -#ifdef HAVE_QHULL_2011 if (compute_area_) { qh_prepare_output(qh); } -#endif // 0 if no error from qhull if (exitcode != 0) diff --git a/surface/include/pcl/surface/qhull.h b/surface/include/pcl/surface/qhull.h index f119b2109a6..da370497082 100644 --- a/surface/include/pcl/surface/qhull.h +++ b/surface/include/pcl/surface/qhull.h @@ -48,25 +48,14 @@ extern "C" { -#ifdef HAVE_QHULL_2011 -# include "libqhull_r/libqhull_r.h" -# include "libqhull_r/mem_r.h" -# include "libqhull_r/qset_r.h" -# include "libqhull_r/geom_r.h" -# include "libqhull_r/merge_r.h" -# include "libqhull_r/poly_r.h" -# include "libqhull_r/io_r.h" -# include "libqhull_r/stat_r.h" -#else -# include "qhull/qhull.h" -# include "qhull/mem.h" -# include "qhull/qset.h" -# include "qhull/geom.h" -# include "qhull/merge.h" -# include "qhull/poly.h" -# include "qhull/io.h" -# include "qhull/stat.h" -#endif +#include "libqhull_r/libqhull_r.h" +#include "libqhull_r/mem_r.h" +#include "libqhull_r/qset_r.h" +#include "libqhull_r/geom_r.h" +#include "libqhull_r/merge_r.h" +#include "libqhull_r/poly_r.h" +#include "libqhull_r/io_r.h" +#include "libqhull_r/stat_r.h" } #endif From 621242a0efff5326c955bf0a74ac9f6537acc144 Mon Sep 17 00:00:00 2001 From: Alexander Turkin Date: Sat, 8 May 2021 13:37:14 +0300 Subject: [PATCH 10/10] removing QHULL_MAJOR_VERSION --- cmake/Modules/FindQhull.cmake | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/cmake/Modules/FindQhull.cmake b/cmake/Modules/FindQhull.cmake index 6427ffdae2e..f9f628452b8 100644 --- a/cmake/Modules/FindQhull.cmake +++ b/cmake/Modules/FindQhull.cmake @@ -9,14 +9,12 @@ # If QHULL_USE_STATIC is specified then look for static libraries ONLY else # look for shared ones -set(QHULL_MAJOR_VERSION 8) - if(QHULL_USE_STATIC) set(QHULL_RELEASE_NAME qhullstatic_r) set(QHULL_DEBUG_NAME qhullstatic_rd) else() - set(QHULL_RELEASE_NAME qhull_r qhull${QHULL_MAJOR_VERSION} qhull) - set(QHULL_DEBUG_NAME qhull_rd qhull${QHULL_MAJOR_VERSION}_d qhull_d${QHULL_MAJOR_VERSION} qhull_d) + set(QHULL_RELEASE_NAME qhull_r qhull) + set(QHULL_DEBUG_NAME qhull_rd qhull_d) endif() find_file(QHULL_HEADER