Skip to content
Closed
Show file tree
Hide file tree
Changes from all 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
38 changes: 29 additions & 9 deletions cmake/Modules/FindQhull.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -9,40 +9,49 @@
# If QHULL_USE_STATIC is specified then look for static libraries ONLY else
# look for shared ones

set(QHULL_MAJOR_VERSION 6)

if(QHULL_USE_STATIC)
set(QHULL_RELEASE_NAME qhullstatic)
set(QHULL_DEBUG_NAME qhullstatic_d)
set(QHULL_RELEASE_NAME qhullstatic_r qhullstatic)
set(QHULL_DEBUG_NAME qhullstatic_rd qhullstatic_d)
else(QHULL_USE_STATIC)
set(QHULL_RELEASE_NAME qhull_p qhull${QHULL_MAJOR_VERSION} qhull)
set(QHULL_DEBUG_NAME qhull_pd qhull${QHULL_MAJOR_VERSION}_d qhull_d${QHULL_MAJOR_VERSION} qhull_d)
set(QHULL_RELEASE_NAME qhull_r qhull_p qhull${QHULL_MAJOR_VERSION} qhull)
set(QHULL_DEBUG_NAME qhull_rd qhull_pd qhull${QHULL_MAJOR_VERSION}_d qhull_d${QHULL_MAJOR_VERSION} qhull_d)
endif(QHULL_USE_STATIC)

find_file(QHULL_HEADER
NAMES libqhull/libqhull.h qhull.h
NAMES libqhull_r/libqhull_r.h libqhull/libqhull.h qhull.h
HINTS "${QHULL_ROOT}" "$ENV{QHULL_ROOT}" "${QHULL_INCLUDE_DIR}"
PATHS "$ENV{PROGRAMFILES}/QHull" "$ENV{PROGRAMW6432}/QHull"
PATH_SUFFIXES qhull src/libqhull libqhull include)

set(QHULL_HEADER "${QHULL_HEADER}" CACHE INTERNAL "QHull header" FORCE )

set(HAVE_QHULL_2011 OFF)
set(HAVE_QHULL_2015 OFF)

if(QHULL_HEADER)
get_filename_component(qhull_header ${QHULL_HEADER} NAME_WE)
if("${qhull_header}" STREQUAL "qhull")
set(QHULL_MAJOR_VERSION 6)
set(HAVE_QHULL_2011 OFF)
set(HAVE_QHULL_2015 OFF)
get_filename_component(QHULL_INCLUDE_DIR ${QHULL_HEADER} PATH)
elseif("${qhull_header}" STREQUAL "libqhull")
set(QHULL_MAJOR_VERSION 6)
set(HAVE_QHULL_2011 ON)
set(HAVE_QHULL_2015 OFF)
get_filename_component(QHULL_INCLUDE_DIR ${QHULL_HEADER} PATH)
get_filename_component(QHULL_INCLUDE_DIR ${QHULL_INCLUDE_DIR} PATH)
elseif("${qhull_header}" STREQUAL "libqhull_r")
set(QHULL_MAJOR_VERSION 7)
set(HAVE_QHULL_2011 OFF)
set(HAVE_QHULL_2015 ON)
get_filename_component(QHULL_INCLUDE_DIR ${QHULL_HEADER} PATH)
get_filename_component(QHULL_INCLUDE_DIR ${QHULL_INCLUDE_DIR} PATH)
endif()
else(QHULL_HEADER)
set(QHULL_INCLUDE_DIR "QHULL_INCLUDE_DIR-NOTFOUND")
endif(QHULL_HEADER)

set(QHULL_INCLUDE_DIR "${QHULL_INCLUDE_DIR}" CACHE PATH "QHull include dir." FORCE)

find_library(QHULL_LIBRARY
NAMES ${QHULL_RELEASE_NAME}
HINTS "${QHULL_ROOT}" "$ENV{QHULL_ROOT}"
Expand All @@ -57,6 +66,17 @@ find_library(QHULL_LIBRARY_DEBUG
PATHS "$ENV{PROGRAMFILES}/QHull" "$ENV{PROGRAMW6432}/QHull"
PATH_SUFFIXES project build bin lib debug/lib)

if (QHULL_MAJOR_VERSION STREQUAL 7)
string(REGEX MATCH ".*r[d]?\\.so$" QHULLR_LIB_FOUND "${QHULL_LIBRARY_DEBUG}")
if("${QHULLR_LIB_FOUND}" STREQUAL "")
# Reentrant libraries cannot be found although headers are available.
# Use non-reentrant interface instead
set(QHULL_MAJOR_VERSION 6)
set(HAVE_QHULL_2011 ON)
set(HAVE_QHULL_2015 OFF)
endif()
endif()

if(NOT QHULL_LIBRARY_DEBUG)
set(QHULL_LIBRARY_DEBUG ${QHULL_LIBRARY})
endif(NOT QHULL_LIBRARY_DEBUG)
Expand Down
2 changes: 2 additions & 0 deletions pcl_config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@

#cmakedefine HAVE_QHULL_2011 1

#cmakedefine HAVE_QHULL_2015 1

#cmakedefine HAVE_CUDA 1

#cmakedefine HAVE_FZAPI 1
Expand Down
80 changes: 76 additions & 4 deletions surface/include/pcl/surface/impl/concave_hull.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,14 @@ pcl::ConcaveHull<PointInT>::performReconstruction (PointCloud &alpha_shape, std:
}

// Compute concave hull
#ifdef HAVE_QHULL_2015
qhT qh_qh;
qhT *qh= &qh_qh;
qh->qhmem.ferr = NULL;
exitcode = qh_new_qhull (qh, dim_, static_cast<int> (cloud_transformed.points.size ()), points, ismalloc, flags, outfile, errfile);
#else
exitcode = qh_new_qhull (dim_, static_cast<int> (cloud_transformed.points.size ()), points, ismalloc, flags, outfile, errfile);
#endif

if (exitcode != 0)
{
Expand Down Expand Up @@ -225,16 +232,25 @@ pcl::ConcaveHull<PointInT>::performReconstruction (PointCloud &alpha_shape, std:
alpha_shape.width = alpha_shape.height = 0;
polygons.resize (0);

qh_freeqhull (!qh_ALL);
int curlong, totlong;
#ifdef HAVE_QHULL_2015
qh_freeqhull (qh, !qh_ALL);
qh_memfreeshort (qh, &curlong, &totlong);
#else
qh_freeqhull (!qh_ALL);
qh_memfreeshort (&curlong, &totlong);
#endif

return;
}

#ifdef HAVE_QHULL_2015
qh_setvoronoi_all (qh);
int num_vertices = qh->num_vertices;
#else
qh_setvoronoi_all ();

int num_vertices = qh num_vertices;
#endif
alpha_shape.points.resize (num_vertices);

vertexT *vertex;
Expand All @@ -251,12 +267,20 @@ pcl::ConcaveHull<PointInT>::performReconstruction (PointCloud &alpha_shape, std:
++max_vertex_id;
std::vector<int> qhid_to_pcidx (max_vertex_id);

#ifdef HAVE_QHULL_2015
int num_facets = qh->num_facets;
#else
int num_facets = qh num_facets;
#endif
int dd = 0;

if (dim_ == 3)
{
#ifdef HAVE_QHULL_2015
setT *triangles_set = qh_settemp (qh, 4 * num_facets);
#else
setT *triangles_set = qh_settemp (4 * num_facets);
#endif
if (voronoi_centers_)
voronoi_centers_->points.resize (num_facets);

Expand All @@ -283,29 +307,48 @@ 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)
#ifdef HAVE_QHULL_2015
qh_makeridges (qh, facet);
facet->visitid = qh->visit_id;
#else
qh_makeridges (facet);
facet->good = true;
facet->visitid = qh visit_id;
#endif
facet->good = true;
ridgeT *ridge, **ridgep;
FOREACHridge_ (facet->ridges)
{
neighb = otherfacet_ (ridge, facet);
#ifdef HAVE_QHULL_2015
if ((neighb->visitid != qh->visit_id))
qh_setappend (qh, &triangles_set, ridge);
#else
if ((neighb->visitid != qh visit_id))
qh_setappend (&triangles_set, ridge);
#endif
}
}
else
{
// consider individual triangles from the tetrahedron...
facet->good = false;
#ifdef HAVE_QHULL_2015
facet->visitid = qh->visit_id;
qh_makeridges (qh, facet);
#else
facet->visitid = qh visit_id;
qh_makeridges (facet);
#endif
ridgeT *ridge, **ridgep;
FOREACHridge_ (facet->ridges)
{
facetT *neighb;
neighb = otherfacet_ (ridge, facet);
#ifdef HAVE_QHULL_2015
if ((neighb->visitid != qh->visit_id))
#else
if ((neighb->visitid != qh visit_id))
#endif
{
// check if individual triangle is good and add it to triangles_set

Expand All @@ -322,7 +365,11 @@ pcl::ConcaveHull<PointInT>::performReconstruction (PointCloud &alpha_shape, std:

double r = pcl::getCircumcircleRadius (a, b, c);
if (r <= alpha_)
#ifdef HAVE_QHULL_2015
qh_setappend (qh, &triangles_set, ridge);
#else
qh_setappend (&triangles_set, ridge);
#endif
}
}
}
Expand Down Expand Up @@ -354,7 +401,11 @@ pcl::ConcaveHull<PointInT>::performReconstruction (PointCloud &alpha_shape, std:
{
polygons[triangles].vertices.resize (3);
int vertex_n, vertex_i;
#ifdef HAVE_QHULL_2015
FOREACHvertex_i_ (qh, (*ridge).vertices) //3 vertices per ridge!
#else
FOREACHvertex_i_ ((*ridge).vertices) //3 vertices per ridge!
#endif
{
if (!added_vertices[vertex->id])
{
Expand Down Expand Up @@ -383,7 +434,11 @@ pcl::ConcaveHull<PointInT>::performReconstruction (PointCloud &alpha_shape, std:
{
// Compute the alpha complex for the set of points
// Filters the delaunay triangles
#ifdef HAVE_QHULL_2015
setT *edges_set = qh_settemp (qh, 3 * num_facets);
#else
setT *edges_set = qh_settemp (3 * num_facets);
#endif
if (voronoi_centers_)
voronoi_centers_->points.resize (num_facets);

Expand All @@ -402,12 +457,20 @@ pcl::ConcaveHull<PointInT>::performReconstruction (PointCloud &alpha_shape, std:
if (r <= alpha_)
{
pcl::Vertices facet_vertices; //TODO: is not used!!
#ifdef HAVE_QHULL_2015
qh_makeridges (qh, facet);
#else
qh_makeridges (facet);
#endif
facet->good = true;

ridgeT *ridge, **ridgep;
FOREACHridge_ (facet->ridges)
#ifdef HAVE_QHULL_2015
qh_setappend (qh, &edges_set, ridge);
#else
qh_setappend (&edges_set, ridge);
#endif

if (voronoi_centers_)
{
Expand Down Expand Up @@ -437,7 +500,11 @@ pcl::ConcaveHull<PointInT>::performReconstruction (PointCloud &alpha_shape, std:
std::vector<int> pcd_indices;
pcd_indices.resize (2);

#ifdef HAVE_QHULL_2015
FOREACHvertex_i_ (qh, (*ridge).vertices) //in 2-dim, 2 vertices per ridge!
#else
FOREACHvertex_i_ ((*ridge).vertices) //in 2-dim, 2 vertices per ridge!
#endif
{
if (!added_vertices[vertex->id])
{
Expand Down Expand Up @@ -540,9 +607,14 @@ pcl::ConcaveHull<PointInT>::performReconstruction (PointCloud &alpha_shape, std:
voronoi_centers_->points.resize (dd);
}

qh_freeqhull (!qh_ALL);
int curlong, totlong;
#ifdef HAVE_QHULL_2015
qh_freeqhull (qh, !qh_ALL);
qh_memfreeshort (qh, &curlong, &totlong);
#else
qh_freeqhull (!qh_ALL);
qh_memfreeshort (&curlong, &totlong);
#endif

Eigen::Affine3d transInverse = transform1.inverse ();
pcl::transformPointCloud (alpha_shape, alpha_shape, transInverse);
Expand Down
Loading