ENH: Add rotation support for 3D Honeycomb, improve stability
jira: 6701 Change-Id: I0552f7a7f59d1476f081044411557c96036a2c70 (cherry picked from commit 646fa84d42b926fe9e127a60da9c395baf39fac1)
This commit is contained in:
parent
0142e0c358
commit
712b724d2a
|
@ -186,15 +186,18 @@ static Polylines makeGrid(coordf_t z, coordf_t gridSize, coordf_t boundWidth, co
|
||||||
// dont_adjust [avoid filling space evenly]
|
// dont_adjust [avoid filling space evenly]
|
||||||
// monotonic [fill strictly left to right]
|
// monotonic [fill strictly left to right]
|
||||||
// complete [complete each loop]
|
// complete [complete each loop]
|
||||||
|
|
||||||
void Fill3DHoneycomb::_fill_surface_single(
|
void Fill3DHoneycomb::_fill_surface_single(
|
||||||
const FillParams ¶ms,
|
const FillParams ¶ms,
|
||||||
unsigned int thickness_layers,
|
unsigned int thickness_layers,
|
||||||
const std::pair<float, Point> &direction,
|
const std::pair<float, Point> &direction,
|
||||||
ExPolygon expolygon,
|
ExPolygon expolygon,
|
||||||
Polylines &polylines_out)
|
Polylines &polylines_out)
|
||||||
{
|
{
|
||||||
// no rotation is supported for this infill pattern
|
// no rotation is supported for this infill pattern
|
||||||
|
// BBL: add support for rotation
|
||||||
|
auto infill_angle = float(this->angle);
|
||||||
|
if (std::abs(infill_angle) >= EPSILON) expolygon.rotate(-infill_angle);
|
||||||
BoundingBox bb = expolygon.contour.bounding_box();
|
BoundingBox bb = expolygon.contour.bounding_box();
|
||||||
|
|
||||||
// Note: with equally-scaled X/Y/Z, the pattern will create a vertically-stretched
|
// Note: with equally-scaled X/Y/Z, the pattern will create a vertically-stretched
|
||||||
|
@ -216,7 +219,7 @@ void Fill3DHoneycomb::_fill_surface_single(
|
||||||
// Z scale is adjusted to make the layer patterns consistent / symmetric
|
// Z scale is adjusted to make the layer patterns consistent / symmetric
|
||||||
// This means that the resultant infill won't be an ideal truncated octahedron,
|
// This means that the resultant infill won't be an ideal truncated octahedron,
|
||||||
// but it should look better than the equivalent quantised version
|
// but it should look better than the equivalent quantised version
|
||||||
|
|
||||||
coordf_t layerHeight = scale_(thickness_layers);
|
coordf_t layerHeight = scale_(thickness_layers);
|
||||||
// ceiling to an integer value of layers per Z
|
// ceiling to an integer value of layers per Z
|
||||||
// (with a little nudge in case it's close to perfect)
|
// (with a little nudge in case it's close to perfect)
|
||||||
|
@ -248,7 +251,7 @@ void Fill3DHoneycomb::_fill_surface_single(
|
||||||
// (a module is 2*$gridSize since one $gridSize half-module is
|
// (a module is 2*$gridSize since one $gridSize half-module is
|
||||||
// growing while the other $gridSize half-module is shrinking)
|
// growing while the other $gridSize half-module is shrinking)
|
||||||
bb.merge(align_to_grid(bb.min, Point(gridSize*4, gridSize*4)));
|
bb.merge(align_to_grid(bb.min, Point(gridSize*4, gridSize*4)));
|
||||||
|
|
||||||
// generate pattern
|
// generate pattern
|
||||||
Polylines polylines =
|
Polylines polylines =
|
||||||
makeGrid(
|
makeGrid(
|
||||||
|
@ -257,7 +260,7 @@ void Fill3DHoneycomb::_fill_surface_single(
|
||||||
bb.size()(0),
|
bb.size()(0),
|
||||||
bb.size()(1),
|
bb.size()(1),
|
||||||
!params.dont_adjust);
|
!params.dont_adjust);
|
||||||
|
|
||||||
// move pattern in place
|
// move pattern in place
|
||||||
for (Polyline &pl : polylines){
|
for (Polyline &pl : polylines){
|
||||||
pl.translate(bb.min);
|
pl.translate(bb.min);
|
||||||
|
@ -266,11 +269,21 @@ void Fill3DHoneycomb::_fill_surface_single(
|
||||||
// clip pattern to boundaries, chain the clipped polylines
|
// clip pattern to boundaries, chain the clipped polylines
|
||||||
polylines = intersection_pl(polylines, to_polygons(expolygon));
|
polylines = intersection_pl(polylines, to_polygons(expolygon));
|
||||||
|
|
||||||
// connect lines if needed
|
// copy from fliplines
|
||||||
if (params.dont_connect() || polylines.size() <= 1)
|
if (!polylines.empty()) {
|
||||||
|
int infill_start_idx = polylines_out.size(); // only rotate what belongs to us.
|
||||||
|
// connect lines
|
||||||
|
if (params.dont_connect() || polylines.size() <= 1)
|
||||||
append(polylines_out, chain_polylines(std::move(polylines)));
|
append(polylines_out, chain_polylines(std::move(polylines)));
|
||||||
else
|
else
|
||||||
this->connect_infill(std::move(polylines), expolygon, polylines_out, this->spacing, params);
|
this->connect_infill(std::move(polylines), expolygon, polylines_out, this->spacing, params);
|
||||||
|
|
||||||
|
// rotate back
|
||||||
|
if (std::abs(infill_angle) >= EPSILON) {
|
||||||
|
for (auto it = polylines_out.begin() + infill_start_idx; it != polylines_out.end(); ++it)
|
||||||
|
it->rotate(infill_angle);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Slic3r
|
} // namespace Slic3r
|
Loading…
Reference in New Issue