9#if defined(TTK_ENABLE_QHULL) && defined(Qhull_FOUND)
11#include <libqhullcpp/Qhull.h>
13 std::vector<size_t> &res,
14 std::string &errMsg) {
15 size_t nbPoint = coords.size() / 2;
16 char qHullFooStr[1] =
"";
17 orgQhull::Qhull qhull;
19 qhull.runQhull(qHullFooStr, 2, nbPoint, coords.data(), qHullFooStr);
20 }
catch(orgQhull::QhullError &e) {
21 errMsg =
"Error with qHull module: " + std::string(e.what());
28 for(
const auto &u : qhull.vertexList()) {
29 const orgQhull::QhullPoint &qhullPt = u.point();
30 auto coordsCur = qhullPt.coordinates();
31 for(
size_t j = 0; j < coords.size() / 2; j++) {
32 if(fabs(coords[2 * j] - coordsCur[0])
33 + fabs(coords[2 * j + 1] - coordsCur[1])
41 if(res.size() != qhull.vertexList().size()) {
42 errMsg =
"Error : could not retrieve all vertices in the convex hull.";
50#include <boost/geometry.hpp>
51#include <boost/geometry/geometries/adapted/boost_tuple.hpp>
52#include <boost/geometry/geometries/polygon.hpp>
53namespace bg = boost::geometry;
54BOOST_GEOMETRY_REGISTER_BOOST_TUPLE_CS(cs::cartesian)
56using
Point = boost::tuple<
double,
double>;
61 std::vector<
size_t> &res,
62 std::
string &errMsg) {
65 size_t nbPoint = coords.size() / 2;
66 for(
size_t i = 0; i < nbPoint; i++) {
67 boost::geometry::append(
68 multiPoints,
Point(coords[2 * i], coords[2 * i + 1]));
71 boost::geometry::convex_hull(multiPoints, hull);
75 for(
const auto &boostPt : hull.outer()) {
76 double coordsCur[2] = {boostPt.get<0>(), boostPt.get<1>()};
77 for(
size_t j = 0; j < coords.size() / 2; j++) {
78 if(fabs(coords[2 * j] - coordsCur[0])
79 + fabs(coords[2 * j + 1] - coordsCur[1])
86 if(res.size() != hull.outer().size()) {
87 errMsg =
"Error : could not retrieve all vertices in the convex hull.";
bool computeConvexHull_aux(const std::vector< double > &coords, std::vector< size_t > &res, std::string &errMsg)
boost::geometry::model::multi_point< Point > Mpoints
boost::geometry::model::polygon< Point > Polygon
boost::tuple< double, double > Point
void setDebugMsgPrefix(const std::string &prefix)