mirror of
https://git.mirrors.martin98.com/https://github.com/slic3r/Slic3r.git
synced 2025-08-02 19:10:39 +08:00
Update 3D Honeycomb Infill to switch directions at squares rather than every line (#4049)
* Initial attempt at updated minimal-bridging honeycomb pattern * Revert, make incremental change of existing code
This commit is contained in:
parent
1190a74f4e
commit
54fe2e4145
@ -88,29 +88,25 @@ zip(const std::vector<coordf_t> &x, const std::vector<coordf_t> &y)
|
|||||||
static std::vector<Pointfs>
|
static std::vector<Pointfs>
|
||||||
makeNormalisedGrid(coordf_t z, size_t gridWidth, size_t gridHeight, size_t curveType)
|
makeNormalisedGrid(coordf_t z, size_t gridWidth, size_t gridHeight, size_t curveType)
|
||||||
{
|
{
|
||||||
// offset required to create a regular octagram
|
// sawtooth wave function
|
||||||
coordf_t octagramGap = coordf_t(0.5);
|
|
||||||
|
|
||||||
// sawtooth wave function for range f($z) = [-$octagramGap .. $octagramGap]
|
|
||||||
coordf_t a = std::sqrt(coordf_t(2.)); // period
|
coordf_t a = std::sqrt(coordf_t(2.)); // period
|
||||||
coordf_t wave = fabs(fmod(z, a) - a/2.)/a*4. - 1.;
|
coordf_t offset = fabs(fmod(z, a) - a/2.)/a*2. - 0.5;
|
||||||
coordf_t offset = wave * octagramGap;
|
bool printHoriz = (fabs(fmod(z, a)) / a*2. < 1);
|
||||||
|
|
||||||
std::vector<Pointfs> points;
|
std::vector<Pointfs> points;
|
||||||
if ((curveType & 1) != 0) {
|
if (printHoriz) {
|
||||||
for (size_t x = 0; x <= gridWidth; ++x) {
|
for (size_t x = 0; x <= gridWidth; ++x) {
|
||||||
points.push_back(Pointfs());
|
points.push_back(Pointfs());
|
||||||
Pointfs &newPoints = points.back();
|
Pointfs &newPoints = points.back();
|
||||||
newPoints = zip(
|
newPoints = zip(
|
||||||
perpendPoints(offset, x, gridHeight),
|
perpendPoints(offset, x, gridHeight),
|
||||||
colinearPoints(offset, 0, gridHeight));
|
colinearPoints(offset, 0, gridHeight));
|
||||||
// trim points to grid edges
|
// trim points to grid edges
|
||||||
trim(newPoints, coordf_t(0.), coordf_t(0.), coordf_t(gridWidth), coordf_t(gridHeight));
|
trim(newPoints, coordf_t(0.), coordf_t(0.), coordf_t(gridWidth), coordf_t(gridHeight));
|
||||||
if (x & 1)
|
if (x & 1)
|
||||||
std::reverse(newPoints.begin(), newPoints.end());
|
std::reverse(newPoints.begin(), newPoints.end());
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
if ((curveType & 2) != 0) {
|
|
||||||
for (size_t y = 0; y <= gridHeight; ++y) {
|
for (size_t y = 0; y <= gridHeight; ++y) {
|
||||||
points.push_back(Pointfs());
|
points.push_back(Pointfs());
|
||||||
Pointfs &newPoints = points.back();
|
Pointfs &newPoints = points.back();
|
||||||
@ -150,8 +146,8 @@ makeGrid(coord_t z, coord_t gridSize, size_t gridWidth, size_t gridHeight, size_
|
|||||||
void
|
void
|
||||||
Fill3DHoneycomb::_fill_surface_single(
|
Fill3DHoneycomb::_fill_surface_single(
|
||||||
unsigned int thickness_layers,
|
unsigned int thickness_layers,
|
||||||
const direction_t &direction,
|
const direction_t &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
|
||||||
@ -159,10 +155,10 @@ Fill3DHoneycomb::_fill_surface_single(
|
|||||||
const coord_t distance = coord_t(scale_(this->min_spacing) / this->density);
|
const coord_t distance = coord_t(scale_(this->min_spacing) / this->density);
|
||||||
|
|
||||||
// align bounding box to a multiple of our honeycomb grid module
|
// align bounding box to a multiple of our honeycomb grid module
|
||||||
// (a module is 2*$distance since one $distance half-module is
|
// (a module is 2*$distance since one $distance half-module is
|
||||||
// growing while the other $distance half-module is shrinking)
|
// growing while the other $distance half-module is shrinking)
|
||||||
bb.min.align_to_grid(Point(2*distance, 2*distance));
|
bb.min.align_to_grid(Point(2*distance, 2*distance));
|
||||||
|
|
||||||
// generate pattern
|
// generate pattern
|
||||||
Polylines polylines = makeGrid(
|
Polylines polylines = makeGrid(
|
||||||
scale_(this->z),
|
scale_(this->z),
|
||||||
@ -171,7 +167,7 @@ Fill3DHoneycomb::_fill_surface_single(
|
|||||||
ceil(bb.size().y / distance) + 1,
|
ceil(bb.size().y / distance) + 1,
|
||||||
((this->layer_id/thickness_layers) % 2) + 1
|
((this->layer_id/thickness_layers) % 2) + 1
|
||||||
);
|
);
|
||||||
|
|
||||||
// move pattern in place
|
// move pattern in place
|
||||||
for (Polylines::iterator it = polylines.begin(); it != polylines.end(); ++ it)
|
for (Polylines::iterator it = polylines.begin(); it != polylines.end(); ++ it)
|
||||||
it->translate(bb.min.x, bb.min.y);
|
it->translate(bb.min.x, bb.min.y);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user