Ported traverse_pt() to XS

This commit is contained in:
Alessandro Ranellucci 2013-11-23 23:21:59 +01:00
parent b47b8ee34f
commit a93c862338
9 changed files with 71 additions and 27 deletions

View file

@ -1,4 +1,5 @@
#include "Geometry.hpp"
#include "clipper.hpp"
#include <algorithm>
#include <map>
@ -80,4 +81,16 @@ chained_path(Points &points, std::vector<Points::size_type> &retval)
chained_path(points, retval, points.front());
}
/* retval and items must be different containers */
template<class T>
void
chained_path_items(Points &points, T &items, T &retval)
{
std::vector<Points::size_type> indices;
chained_path(points, indices);
for (std::vector<Points::size_type>::const_iterator it = indices.begin(); it != indices.end(); ++it)
retval.push_back(items[*it]);
}
template void chained_path_items(Points &points, ClipperLib::PolyNodes &items, ClipperLib::PolyNodes &retval);
} }