[Geometry] Trouble with adapting geometric objects to Eigen to use convex_hull on multiple polygons

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[Geometry] Trouble with adapting geometric objects to Eigen to use convex_hull on multiple polygons

Boost - Users mailing list
Hello boost-community,
 
I hope this is the correct place to post this question:
 
So I am having trouble for a couple of days now with getting boost::geometry::convex_hull to accept my input. My programm has to compute the convex hull and afterwards the area their area of several objects which can be seen as simple polygons without holes. The rest of my code is based upon the linear Algebra library Eigen and especially I am using Eigen::Vector2d as my point-format.
 
To work with both Eigen and boost I tried using the registration-macros provided by boost/geometry/geometries/register. My include section looks like this at the moment:
 
#pragma once
#include <Eigen/Dense>
#include <boost/geometry.hpp>
#include <boost/geometry/geometries/register/point.hpp>
#include <boost/geometry/geometries/register/box.hpp>
#include <boost/geometry/geometries/register/ring.hpp>
#include <boost/geometry/geometries/register/linestring.hpp>
#include <boost/geometry/multi/geometries/register/multi_polygon.hpp>
#include <boost/geometry/geometries/multi_polygon.hpp>
 
 
BOOST_GEOMETRY_REGISTER_POINT_2D(Eigen::Vector2d, double, cs::cartesian, coeffRef(0), coeffRef(1))
BOOST_GEOMETRY_REGISTER_RING(std::vector<Eigen::Vector2d>)
 
//Some more irrelevant includes for this post...
 
 
This allows me to use the convex_hull, union_ and area methods provided by boost::geometry, for example in this code:
 
void Polygon::unionWithOther(const Polygon& other) {
        //BOOST:
        std::vector<std::vector<Eigen::Vector2d>> output;
        std::vector<Eigen::Vector2d> verticesSecond(other.getVerticesList());
        boost::geometry::correct(_vertices);
        boost::geometry::correct(verticesSecond);
        boost::geometry::union_(_vertices, verticesSecond, output);
        _vertices = output.at(0);
        _vertices.erase(_vertices.end());
}
 
which is inside a Polygon-data-structure used internally in my code computing the union of two polygons.
 
Later I would like to run following code:
 
std::vector<Molecule> molList({mol1, mol2});
std::vector<std::vector<Eigen::Vector2d>> polyList({mol1.getPositionsOfAllAtoms(), mol2.getPositionsOfAllAtoms()});
std::vector<Eigen::Vector2d> convexClusterHull;
 
boost::geometry::correct(polyList.at(0));
boost::geometry::correct(polyList.at(1));
 
//The compiler errors are induced by the following line:
boost::geometry::convex_hull(polyList, convexClusterHull);
double areaConvexClusterHull = boost::geometry::area(convexClusterHull);
 
 
This now throws several compiler errors, which I am having trouble to understand. The errors are:
 
/usr/include/boost/geometry/algorithms/not_implemented.hpp:69: error: no matching function for call to ‘assertion_failed<false>(mpl_::failed************ (boost::geometry::nyi::not_implemented_error<void, void, void>::THIS_OPERATION_IS_NOT_OR_NOT_YET_IMPLEMENTED::************)(mpl_::assert_::types<void, void, void, mpl_::na>))’
     BOOST_MPL_ASSERT_MSG
     ^~~~~~~~~~~~~~~~~~~~
/usr/include/boost/geometry/algorithms/is_empty.hpp:162: error: ‘apply’ is not a member of ‘boost::geometry::dispatch::is_empty<std::vector<std::vector<Eigen::Matrix<double, 2, 1> > >, void>’
         return dispatch::is_empty<Geometry>::apply(geometry);
                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~
/usr/include/boost/geometry/core/point_type.hpp:45: error: no matching function for call to ‘assertion_failed<false>(mpl_::failed************ (boost::geometry::traits::point_type<std::vector<std::vector<Eigen::Matrix<double, 2, 1> > > >::NOT_IMPLEMENTED_FOR_THIS_POINT_TYPE::************)(mpl_::assert_::types<std::vector<std::vector<Eigen::Matrix<double, 2, 1> > >, mpl_::na, mpl_::na, mpl_::na>))’
     BOOST_MPL_ASSERT_MSG
     ^~~~~~~~~~~~~~~~~~~~
/usr/include/boost/geometry/core/point_type.hpp:66: error: no type named ‘type’ in ‘struct boost::geometry::traits::point_type<std::vector<std::vector<Eigen::Matrix<double, 2, 1> > > >’
         >::type type;
                 ^~~~
/usr/include/boost/geometry/core/coordinate_dimension.hpp:122: error: no type named ‘type’ in ‘struct boost::geometry::dimension<const std::vector<std::vector<Eigen::Matrix<double, 2, 1> > > >’
     BOOST_STATIC_ASSERT(( static_cast<size_t>(dimension<G1>::type::value) == static_cast<size_t>(dimension<G2>::type::value) ));
     ^~~~~~~~~~~~~~~~~~~
 
 
I suppose this revers to wrongly used or missing registration-macros? But I cannot get behind what I can do to fix this.
 
To sum my question up: I have the problem that I need to compute the convex hull of several polygons (which should be possible refering to the boost-documentation) but for some reasons the boost::geometry::convex_hull algorithm does not accept my input and throws a compiler error.
 
I would be really greatful if someone has a suggestion for me how to fix this.
 
Best regards.
 
 
 
 

_______________________________________________
Boost-users mailing list
[hidden email]
https://lists.boost.org/mailman/listinfo.cgi/boost-users