0
#include <iostream>
#include <boost/geometry.hpp>
#include <boost/geometry/geometries/register/point.hpp>
#include <boost/shared_ptr.hpp>
#include <boost/make_shared.hpp>
using namespace boost::geometry;
class CustomPoint{
public:
double X;
double Y;
};
using cpPtr = boost::shared_ptr<CustomPoint>;
namespace boost { namespace geometry { namespace traits {
BOOST_GEOMETRY_DETAIL_SPECIALIZE_POINT_TRAITS(cpPtr, 2, double, cs::cartesian)
template<> struct access<cpPtr, 0> {
static inline double get(cpPtr const& p) { return p->X; }
static inline void set(cpPtr& p, double const& value) { p->X = value; }
};
template<> struct access<cpPtr, 1> {
static inline double get(cpPtr const& p) { return p->Y; }
static inline void set(cpPtr& p, double const& value) { p->Y = value; }
};
}}}
int main()
{
std::vector<cpPtr> one,Two;
//init polys
std::vector< std::vector<cpPtr> > output;
boost::geometry::union_(one,two,output)
}
你好,我尝试了boost :: shared_ptr作为多边形。问题是当我做联合裁剪算法没有分配内存。任何人都知道这个解决方案?自动分配提升几何联盟