Rewrote Fill2.pm to C++, deleted Perl infills for good.

Removed dependency on Perl Math::PlanePath module.
Fixed compilation with Visual Studio and SLIC3R_DEBUG: Visual Studio older than 2015 does not support the prinf type specifier %zu. Use %Iu instead.
C++11 move semantics enabled.
This commit is contained in:
bubnikv 2016-11-02 10:47:00 +01:00
parent 3a31d37d35
commit 95ede7c4b8
49 changed files with 628 additions and 1803 deletions

View file

@ -69,7 +69,7 @@ inline Polygons to_polygons(const ExPolygons &src)
return polygons;
}
#if SLIC3R_CPPVER > 11
#if SLIC3R_CPPVER >= 11
inline Polygons to_polygons(ExPolygons &&src)
{
Polygons polygons;
@ -83,6 +83,37 @@ inline Polygons to_polygons(ExPolygons &&src)
}
#endif
// Count a nuber of polygons stored inside the vector of expolygons.
// Useful for allocating space for polygons when converting expolygons to polygons.
inline size_t number_polygons(const ExPolygons &expolys)
{
size_t n_polygons = 0;
for (ExPolygons::const_iterator it = expolys.begin(); it != expolys.end(); ++ it)
n_polygons += it->holes.size() + 1;
return n_polygons;
}
// Append a vector of ExPolygons at the end of another vector of polygons.
inline void polygons_append(Polygons &dst, const ExPolygons &src)
{
dst.reserve(dst.size() + number_polygons(src));
for (ExPolygons::const_iterator it = src.begin(); it != src.end(); ++ it) {
dst.push_back(it->contour);
dst.insert(dst.end(), it->holes.begin(), it->holes.end());
}
}
#if SLIC3R_CPPVER >= 11
inline void polygons_append(Polygons &dst, ExPolygons &&src)
{
dst.reserve(dst.size() + number_polygons(src));
for (ExPolygons::const_iterator it = expolys.begin(); it != expolys.end(); ++ it) {
dst.push_back(std::move(it->contour));
std::move(std::begin(it->contour), std::end(it->contour), std::back_inserter(dst));
}
}
#endif
extern BoundingBox get_extents(const ExPolygon &expolygon);
extern BoundingBox get_extents(const ExPolygons &expolygons);