1 #ifndef UTILITY_COMP_GEOMETRY_CONVEX_HULL_H 2 #define UTILITY_COMP_GEOMETRY_CONVEX_HULL_H 8 #include <libqhull_r/poly_r.h> 9 #include <libqhullcpp/Qhull.h> 10 #include <libqhullcpp/RboxPoints.h> 11 #include <libqhullcpp/QhullFacetList.h> 12 #include <libqhullcpp/QhullPoints.h> 13 #include <libqhullcpp/QhullError.h> 14 #include <libqhullcpp/QhullVertexSet.h> 15 #include <Eigen/Sparse> 81 std::vector<std::vector<Point>> facetVertices,
82 std::vector<std::vector<int>> facetVerticesIdx,
85 : pointConstraints_(pointConstraints)
86 , halfSpaceConstraints_(halfSpaceConstraints)
88 , facetVertices_(std::move(facetVertices))
89 , facetVerticesIdx_(std::move(facetVerticesIdx))
140 assert(!points.empty());
142 int dimension = points.front().dimension();
143 for (
const auto& point : points)
144 assert(dimension == point.dimension());
146 orgQhull::RboxPoints rboxPoints;
147 rboxPoints.setDimension(dimension);
148 std::vector<coordT> tempData;
149 for (
const Point& point : points)
151 for (
int dimIdx = 0; dimIdx <
dimension; ++dimIdx)
152 tempData.emplace_back(point[dimIdx]);
154 orgQhull::QhullPoints qhullPoints(
155 dimension, static_cast<countT>(points.size() *
dimension), tempData.data());
156 for (
const orgQhull::QhullPoint& qhullPoint : qhullPoints)
157 rboxPoints.append(qhullPoint);
159 orgQhull::Qhull qhull(rboxPoints,
"");
166 std::vector<std::vector<Point>> facetVertices;
168 std::vector<std::vector<int>> facetVerticesIdx;
169 for (
const orgQhull::QhullFacet& qhullFacet : qhull.facetList())
171 facetVertices.emplace_back(orgQhull::getVertices(qhullFacet));
172 facetVerticesIdx.emplace_back(orgQhull::getVerticesIdx(qhullFacet));
173 neighborHalfSpaces.emplace_back(orgQhull::getHalfSpaces(qhullFacet.neighborFacets()));
175 for (
auto& fIndex : facetVerticesIdx)
177 for (
int& pIndex : fIndex)
179 auto curIter = std::find(pointConstraints.begin(), pointConstraints.end(), points[pIndex]);
180 pIndex = std::distance(pointConstraints.begin(), curIter);
184 halfSpaceConstraints,
193 #endif //UTILITY_COMP_GEOMETRY_CONVEX_HULL_H std::vector< std::vector< Point > > facetVertices_
each facet's extreme vertices
Definition: convexHull.hpp:39
std::vector< HalfSpace > halfSpaceConstraints() const
get the half space constraints which define the convex hull
Definition: convexHull.hpp:102
std::vector< std::vector< HalfSpace > > neighborHalfSpaces_
each half space's neighbor half spaces
Definition: convexHull.hpp:35
Definition: convexHull.hpp:21
double volume_
volume of the convex hull
Definition: convexHull.hpp:47
convexConstraints(std::vector< Point > &pointConstraints, std::vector< HalfSpace > &halfSpaceConstraints, std::vector< std::vector< HalfSpace >> neighborHalfSpaces, std::vector< std::vector< Point >> facetVertices, std::vector< std::vector< int >> facetVerticesIdx, double volume, int dimension)
constructor with given information
Definition: convexHull.hpp:78
std::vector< HalfSpace > halfSpaceConstraints_
boundary half spaces which define the convex hull
Definition: convexHull.hpp:31
std::vector< std::vector< int > > facetVerticesIdx_
indexes of each facet's extreme vertices in whole convex hull extreme vertices
Definition: convexHull.hpp:43
std::vector< std::vector< Point > > faceVertices() const
get the vertices of each facet
Definition: convexHull.hpp:112
std::vector< std::vector< HalfSpace > > neighborHalfSpaces() const
get the vector storing each facet's neighbor facets
Definition: convexHull.hpp:107
Definition: condition.cpp:3
int dimension() const
get the dimension of the space which the convex hull in
Definition: convexHull.hpp:127
convexConstraints()=default
constructor
static convexConstraints constraints(const std::vector< Point > &points)
constructor of convex hull with given points
Definition: convexHull.hpp:138
int dimension_
dimension of the space which the convex hull in
Definition: convexHull.hpp:51
std::vector< std::vector< int > > faceVerticesIdx() const
get the indexes of each facet
Definition: convexHull.hpp:117
std::vector< Point > pointConstraints() const
get the extreme vertices which define the convex hull
Definition: convexHull.hpp:97
double volume() const
get the volume of the convex hull
Definition: convexHull.hpp:122
std::vector< Point > pointConstraints_
extreme vertices which define the convex hull
Definition: convexHull.hpp:27
Definition: convexHull.hpp:130