1 #ifndef UTILITY_EXTENSION_EXT_QHULL_H 2 #define UTILITY_EXTENSION_EXT_QHULL_H 6 #include <libqhullcpp/QhullHyperplane.h> 7 #include <libqhullcpp/QhullFacet.h> 8 #include <libqhullcpp/QhullVertexSet.h> 9 #include <libqhullcpp/QhullFacetSet.h> 10 #include <libqhullcpp/QhullFacetList.h> 11 #include <libqhullcpp/Qhull.h> 21 static Eigen::VectorXd getNormal(
const QhullHyperplane& qhullHyperplane)
23 int dimension = qhullHyperplane.dimension();
24 Eigen::VectorXd retNorm = Eigen::VectorXd::Zero(dimension);
25 const realT* c = qhullHyperplane.coordinates();
26 for (
int dimIdx = 0; dimIdx < dimension; ++dimIdx)
27 retNorm(dimIdx) = double(*c++);
35 static double getOffset(
const QhullHyperplane& qhullHyperplane) {
return qhullHyperplane.offset(); }
41 static std::vector<int> getVerticesIdx(
const QhullFacet& qhullFacet)
43 std::vector<int> retIndices;
44 retIndices.reserve(qhullFacet.vertices().size());
45 for (
const QhullVertex& qhullVertex : qhullFacet.vertices())
46 retIndices.emplace_back(qhullVertex.point().id());
54 static std::vector<irafhy::Point> getVertices(
const Qhull& qhull)
56 std::vector<irafhy::Point> retVertices;
57 retVertices.reserve(qhull.vertexCount());
58 for (
const QhullVertex& qhullVertex : qhull.vertexList())
59 retVertices.emplace_back(
irafhy::Point(qhullVertex.point().toStdVector()));
67 static std::vector<irafhy::Point> getVertices(
const QhullFacet& qhullFacet)
69 std::vector<irafhy::Point> retVertices;
70 retVertices.reserve(qhullFacet.vertices().size());
71 for (
const QhullVertex& qhullVertex : qhullFacet.vertices())
72 retVertices.emplace_back(
irafhy::Point(qhullVertex.point().toStdVector()));
80 static std::vector<irafhy::HalfSpace> getHalfSpaces(
const Qhull& qhull)
82 std::vector<irafhy::HalfSpace> retHalfSpaces;
83 retHalfSpaces.reserve(qhull.facetCount());
84 for (
const QhullFacet& qhullFacet : qhull.facetList())
85 retHalfSpaces.emplace_back(
86 irafhy::HalfSpace(getNormal(qhullFacet.hyperplane()), getOffset(qhullFacet.hyperplane())));
94 static std::vector<irafhy::HalfSpace> getHalfSpaces(
const QhullFacetSet& qhullFacetSet)
96 std::vector<irafhy::HalfSpace> retHalfSpaces;
97 retHalfSpaces.reserve(qhullFacetSet.size());
98 for (
const QhullFacet& qhullFacet : qhullFacetSet)
99 retHalfSpaces.emplace_back(
100 irafhy::HalfSpace(getNormal(qhullFacet.hyperplane()), getOffset(qhullFacet.hyperplane())));
101 return retHalfSpaces;
109 static bool contains(
const irafhy::Point& point,
const Qhull& qhull)
111 for (
const QhullFacet& qhullFacet : qhull.facetList())
113 Eigen::VectorXd normal = getNormal(qhullFacet.hyperplane());
114 double offset = getOffset(qhullFacet.hyperplane());
115 if (normal.dot(point.
coordinate()) + offset > 0)
121 #endif //UTILITY_EXTENSION_EXT_QHULL_H Definition: extQhull.hpp:14
Eigen::VectorXd coordinate() const
get the coordinate of the point
Definition: point.cpp:38
Definition: halfSpace.h:8