Updates in the C++ infill code.
This commit is contained in:
@@ -87,7 +87,7 @@ static std::vector<Pointfs> makeNormalisedGrid(coordf_t z, size_t gridWidth, siz
|
||||
|
||||
// sawtooth wave function for range f($z) = [-$octagramGap .. $octagramGap]
|
||||
coordf_t a = std::sqrt(coordf_t(2.)); // period
|
||||
coordf_t wave = abs(fmod(z, a) - a/2.)/a*4. - 1.;
|
||||
coordf_t wave = fabs(fmod(z, a) - a/2.)/a*4. - 1.;
|
||||
coordf_t offset = wave * octagramGap;
|
||||
|
||||
std::vector<Pointfs> points;
|
||||
@@ -139,9 +139,14 @@ static Polylines makeGrid(coord_t z, coord_t gridSize, size_t gridWidth, size_t
|
||||
return result;
|
||||
}
|
||||
|
||||
Polylines Fill3DHoneycomb::fill_surface(const Surface *surface, const FillParams ¶ms)
|
||||
void Fill3DHoneycomb::_fill_surface_single(
|
||||
const FillParams ¶ms,
|
||||
unsigned int thickness_layers,
|
||||
const std::pair<float, Point> &direction,
|
||||
ExPolygon &expolygon,
|
||||
Polylines &polylines_out)
|
||||
{
|
||||
ExPolygon expolygon = surface->expolygon;
|
||||
// no rotation is supported for this infill pattern
|
||||
BoundingBox bb = expolygon.contour.bounding_box();
|
||||
Point size = bb.size();
|
||||
coord_t distance = coord_t(scale_(this->spacing) / params.density);
|
||||
@@ -149,9 +154,7 @@ Polylines Fill3DHoneycomb::fill_surface(const Surface *surface, const FillParams
|
||||
// align bounding box to a multiple of our honeycomb grid module
|
||||
// (a module is 2*$distance since one $distance half-module is
|
||||
// growing while the other $distance half-module is shrinking)
|
||||
bb.merge(Point(
|
||||
bb.min.x - (bb.min.x % (2*distance)),
|
||||
bb.min.y - (bb.min.y % (2*distance))));
|
||||
bb.merge(_align_to_grid(bb.min, Point(2*distance, 2*distance)));
|
||||
|
||||
// generate pattern
|
||||
Polylines polylines = makeGrid(
|
||||
@@ -159,7 +162,7 @@ Polylines Fill3DHoneycomb::fill_surface(const Surface *surface, const FillParams
|
||||
distance,
|
||||
ceil(size.x / distance) + 1,
|
||||
ceil(size.y / distance) + 1,
|
||||
((this->layer_id / surface->thickness_layers) % 2) + 1);
|
||||
((this->layer_id/thickness_layers) % 2) + 1);
|
||||
|
||||
// move pattern in place
|
||||
for (Polylines::iterator it = polylines.begin(); it != polylines.end(); ++ it)
|
||||
@@ -186,15 +189,11 @@ Polylines Fill3DHoneycomb::fill_surface(const Surface *surface, const FillParams
|
||||
polylines,
|
||||
#endif
|
||||
PolylineCollection::leftmost_point(polylines), false); // reverse allowed
|
||||
#if SLIC3R_CPPVER >= 11
|
||||
assert(polylines.empty());
|
||||
#else
|
||||
polylines.clear();
|
||||
#endif
|
||||
bool first = true;
|
||||
for (Polylines::iterator it_polyline = chained.begin(); it_polyline != chained.end(); ++ it_polyline) {
|
||||
if (! polylines.empty()) {
|
||||
if (! first) {
|
||||
// Try to connect the lines.
|
||||
Points &pts_end = polylines.back().points;
|
||||
Points &pts_end = polylines_out.back().points;
|
||||
const Point &first_point = it_polyline->points.front();
|
||||
const Point &last_point = pts_end.back();
|
||||
// TODO: we should also check that both points are on a fill_boundary to avoid
|
||||
@@ -208,16 +207,14 @@ Polylines Fill3DHoneycomb::fill_surface(const Surface *surface, const FillParams
|
||||
}
|
||||
// The lines cannot be connected.
|
||||
#if SLIC3R_CPPVER >= 11
|
||||
polylines.push_back(std::move(*it_polyline));
|
||||
polylines_out.push_back(std::move(*it_polyline));
|
||||
#else
|
||||
polylines.push_back(Polyline());
|
||||
std::swap(polylines.back(), *it_polyline);
|
||||
polylines_out.push_back(Polyline());
|
||||
std::swap(polylines_out.back(), *it_polyline);
|
||||
#endif
|
||||
first = false;
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: return ExtrusionLoop objects to get better chained paths
|
||||
return polylines;
|
||||
}
|
||||
|
||||
} // namespace Slic3r
|
||||
|
||||
Reference in New Issue
Block a user