Skip to content
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions cmake/Modules/FindQhull.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@
# 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)
Comment thread
mvieth marked this conversation as resolved.
Outdated

if(QHULL_USE_STATIC)
set(QHULL_RELEASE_NAME qhullstatic)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should be changed to qhullstatic_r (and below qhullstatic_r_d)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed, thanks

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)
Comment thread
mvieth marked this conversation as resolved.
Outdated
endif()

find_file(QHULL_HEADER
Expand Down
4 changes: 2 additions & 2 deletions surface/include/pcl/surface/convex_hull.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,11 @@ namespace pcl
using PointCloudConstPtr = typename PointCloud::ConstPtr;

/** \brief Empty constructor. */
ConvexHull () : compute_area_ (false), total_area_ (0), total_volume_ (0), dimension_ (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 () {}
Expand Down
49 changes: 27 additions & 22 deletions surface/include/pcl/surface/impl/concave_hull.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -194,8 +194,13 @@ pcl::ConcaveHull<PointInT>::performReconstruction (PointCloud &alpha_shape, std:
points[i * dim_ + 2] = static_cast<coordT> (cloud_transformed[i].z);
}

qhT qh_qh;
qhT* qh = &qh_qh;
QHULL_LIB_CHECK
qh_zero(qh, errfile);

// Compute concave hull
exitcode = qh_new_qhull (dim_, static_cast<int> (cloud_transformed.size ()), points, ismalloc, flags, outfile, errfile);
exitcode = qh_new_qhull (qh, dim_, static_cast<int> (cloud_transformed.size ()), points, ismalloc, flags, outfile, errfile);

if (exitcode != 0)
{
Expand Down Expand Up @@ -227,16 +232,16 @@ pcl::ConcaveHull<PointInT>::performReconstruction (PointCloud &alpha_shape, std:
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;
int num_vertices = qh->num_vertices;
alpha_shape.resize (num_vertices);

vertexT *vertex;
Expand All @@ -253,11 +258,11 @@ pcl::ConcaveHull<PointInT>::performReconstruction (PointCloud &alpha_shape, std:
++max_vertex_id;
std::vector<int> 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);

Expand All @@ -283,29 +288,29 @@ pcl::ConcaveHull<PointInT>::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

Expand All @@ -322,7 +327,7 @@ pcl::ConcaveHull<PointInT>::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);
}
}
}
Expand Down Expand Up @@ -354,7 +359,7 @@ pcl::ConcaveHull<PointInT>::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])
{
Expand Down Expand Up @@ -383,7 +388,7 @@ pcl::ConcaveHull<PointInT>::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);

Expand All @@ -403,12 +408,12 @@ pcl::ConcaveHull<PointInT>::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_)
{
Expand Down Expand Up @@ -438,7 +443,7 @@ pcl::ConcaveHull<PointInT>::performReconstruction (PointCloud &alpha_shape, std:
std::vector<int> 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])
{
Expand Down Expand Up @@ -540,9 +545,9 @@ pcl::ConcaveHull<PointInT>::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);
Expand Down
60 changes: 36 additions & 24 deletions surface/include/pcl/surface/impl/convex_hull.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -180,40 +180,45 @@ pcl::ConvexHull<PointInT>::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 ());
}

qhT qh_qh;
qhT* qh = &qh_qh;
QHULL_LIB_CHECK
qh_zero(qh, errfile);

// Compute convex hull
int exitcode = qh_new_qhull (dimension, static_cast<int> (indices_->size ()), points, ismalloc, const_cast<char*> (flags), outfile, errfile);
int exitcode = qh_new_qhull (qh, dimension, static_cast<int> (indices_->size ()), points, ismalloc, const_cast<char*> (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.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;
}

// 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;
int num_vertices = qh->num_vertices;
hull.resize (num_vertices);
memset (&hull.points[0], hull.size (), sizeof (PointInT));

Expand All @@ -226,8 +231,8 @@ pcl::ConvexHull<PointInT>::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;
}

Expand Down Expand Up @@ -274,9 +279,9 @@ pcl::ConvexHull<PointInT>::performReconstruction2D (PointCloud &hull, std::vecto
polygons[0].vertices[j] = static_cast<unsigned int> (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;
Expand Down Expand Up @@ -320,12 +325,19 @@ pcl::ConvexHull<PointInT>::performReconstruction3D (
points[j + 2] = static_cast<coordT> ((*input_)[(*indices_)[i]].z);
}

static FILE* null = fopen("/dev/null", "w");
Comment thread
mvieth marked this conversation as resolved.
Outdated

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<int> (indices_->size ()), points, ismalloc, const_cast<char*> (flags), outfile, errfile);
int exitcode = qh_new_qhull (qh, dimension, static_cast<int> (indices_->size ()), points, ismalloc, const_cast<char*> (flags), outfile, errfile);
#ifdef HAVE_QHULL_2011
if (compute_area_)
{
qh_prepare_output();
qh_prepare_output(qh);
}
#endif

Expand All @@ -341,18 +353,18 @@ pcl::ConvexHull<PointInT>::performReconstruction3D (
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;
int num_vertices = qh->num_vertices;
hull.resize (num_vertices);

vertexT * vertex;
Expand All @@ -375,7 +387,7 @@ pcl::ConvexHull<PointInT>::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
Expand All @@ -384,8 +396,8 @@ pcl::ConvexHull<PointInT>::performReconstruction3D (

if (compute_area_)
{
total_area_ = qh totarea;
total_volume_ = qh totvol;
total_area_ = qh->totarea;
total_volume_ = qh->totvol;
}

if (fill_polygon_data)
Expand All @@ -400,16 +412,16 @@ pcl::ConvexHull<PointInT>::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;
Expand Down
16 changes: 8 additions & 8 deletions surface/include/pcl/surface/qhull.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,14 @@
extern "C"
{
#ifdef HAVE_QHULL_2011
Comment thread
mvieth marked this conversation as resolved.
Outdated
# 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"
Expand Down