mirror of
https://git.mirrors.martin98.com/https://github.com/slic3r/Slic3r.git
synced 2025-08-02 06:10:40 +08:00
Finished infill implementation for SLAPrint
This commit is contained in:
parent
a02d5caa42
commit
a9609a6dd5
@ -738,7 +738,7 @@ use base qw(Wx::Dialog Class::Accessor);
|
|||||||
|
|
||||||
use List::Util qw(min);
|
use List::Util qw(min);
|
||||||
use Slic3r::Geometry qw(X Y unscale scale);
|
use Slic3r::Geometry qw(X Y unscale scale);
|
||||||
use Slic3r::Geometry::Clipper qw(intersection_pl);
|
use Slic3r::Geometry::Clipper qw(intersection_pl union_ex);
|
||||||
|
|
||||||
__PACKAGE__->mk_accessors(qw(config config2 scaling_factor bed_origin print layer_num));
|
__PACKAGE__->mk_accessors(qw(config config2 scaling_factor bed_origin print layer_num));
|
||||||
|
|
||||||
@ -879,10 +879,12 @@ sub _repaint {
|
|||||||
if ($self->print->layer_solid($self->layer_num)) {
|
if ($self->print->layer_solid($self->layer_num)) {
|
||||||
$self->_paint_expolygon($_, $dc) for @{$self->print->layer_slices($self->layer_num)};
|
$self->_paint_expolygon($_, $dc) for @{$self->print->layer_slices($self->layer_num)};
|
||||||
} else {
|
} else {
|
||||||
$self->_paint_expolygon($_, $dc) for @{$self->print->layer_solid_infill($self->layer_num)};
|
$self->_paint_expolygon($_, $dc) for
|
||||||
$self->_paint_polygon($_, $dc) for map @{$_->grow},
|
@{$self->print->layer_solid_infill($self->layer_num)},
|
||||||
@{$self->print->layer_perimeters($self->layer_num)},
|
@{$self->print->layer_perimeters($self->layer_num)};
|
||||||
@{$self->print->layer_infill($self->layer_num)};
|
|
||||||
|
$self->_paint_expolygon($_, $dc)
|
||||||
|
for @{union_ex($self->print->layer_infill($self->layer_num)->grow)};
|
||||||
}
|
}
|
||||||
|
|
||||||
# draw support material
|
# draw support material
|
||||||
|
@ -45,6 +45,14 @@ add_library(libslic3r STATIC
|
|||||||
${LIBDIR}/libslic3r/Extruder.cpp
|
${LIBDIR}/libslic3r/Extruder.cpp
|
||||||
${LIBDIR}/libslic3r/ExtrusionEntity.cpp
|
${LIBDIR}/libslic3r/ExtrusionEntity.cpp
|
||||||
${LIBDIR}/libslic3r/ExtrusionEntityCollection.cpp
|
${LIBDIR}/libslic3r/ExtrusionEntityCollection.cpp
|
||||||
|
${LIBDIR}/libslic3r/Fill/Fill.cpp
|
||||||
|
${LIBDIR}/libslic3r/Fill/Fill3DHoneycomb.cpp
|
||||||
|
${LIBDIR}/libslic3r/Fill/FillBase.cpp
|
||||||
|
${LIBDIR}/libslic3r/Fill/FillConcentric.cpp
|
||||||
|
${LIBDIR}/libslic3r/Fill/FillHoneycomb.cpp
|
||||||
|
${LIBDIR}/libslic3r/Fill/FillPlanePath.cpp
|
||||||
|
${LIBDIR}/libslic3r/Fill/FillRectilinear.cpp
|
||||||
|
${LIBDIR}/libslic3r/Fill/FillRectilinear2.cpp
|
||||||
${LIBDIR}/libslic3r/Flow.cpp
|
${LIBDIR}/libslic3r/Flow.cpp
|
||||||
${LIBDIR}/libslic3r/GCode.cpp
|
${LIBDIR}/libslic3r/GCode.cpp
|
||||||
${LIBDIR}/libslic3r/GCodeSender.cpp
|
${LIBDIR}/libslic3r/GCodeSender.cpp
|
||||||
|
@ -55,6 +55,12 @@ to_polygons(const ExPolygons &expolygons)
|
|||||||
return pp;
|
return pp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline ExPolygons
|
||||||
|
operator+(ExPolygons src1, const ExPolygons &src2) {
|
||||||
|
append_to(src1, src2);
|
||||||
|
return src1;
|
||||||
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// start Boost
|
// start Boost
|
||||||
|
@ -34,6 +34,12 @@ class ExPolygonCollection
|
|||||||
void append(const ExPolygons &expolygons);
|
void append(const ExPolygons &expolygons);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
inline ExPolygonCollection&
|
||||||
|
operator <<(ExPolygonCollection &coll, const ExPolygons &expolygons) {
|
||||||
|
coll.append(expolygons);
|
||||||
|
return coll;
|
||||||
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -29,7 +29,7 @@ FillConcentric::_fill_surface_single(
|
|||||||
Polygons last = loops;
|
Polygons last = loops;
|
||||||
while (!last.empty()) {
|
while (!last.empty()) {
|
||||||
last = offset2(last, -(distance + min_spacing/2), +min_spacing/2);
|
last = offset2(last, -(distance + min_spacing/2), +min_spacing/2);
|
||||||
loops.insert(loops.end(), last.begin(), last.end());
|
append_to(loops, last);
|
||||||
}
|
}
|
||||||
|
|
||||||
// generate paths from the outermost to the innermost, to avoid
|
// generate paths from the outermost to the innermost, to avoid
|
||||||
@ -37,7 +37,7 @@ FillConcentric::_fill_surface_single(
|
|||||||
loops = union_pt_chained(loops, false);
|
loops = union_pt_chained(loops, false);
|
||||||
|
|
||||||
// split paths using a nearest neighbor search
|
// split paths using a nearest neighbor search
|
||||||
size_t iPathFirst = polylines_out->size();
|
const size_t iPathFirst = polylines_out->size();
|
||||||
Point last_pos(0, 0);
|
Point last_pos(0, 0);
|
||||||
for (Polygons::const_iterator it_loop = loops.begin(); it_loop != loops.end(); ++ it_loop) {
|
for (Polygons::const_iterator it_loop = loops.begin(); it_loop != loops.end(); ++ it_loop) {
|
||||||
polylines_out->push_back(it_loop->split_at_index(last_pos.nearest_point_index(*it_loop)));
|
polylines_out->push_back(it_loop->split_at_index(last_pos.nearest_point_index(*it_loop)));
|
||||||
@ -47,7 +47,7 @@ FillConcentric::_fill_surface_single(
|
|||||||
// clip the paths to prevent the extruder from getting exactly on the first point of the loop
|
// clip the paths to prevent the extruder from getting exactly on the first point of the loop
|
||||||
// Keep valid paths only.
|
// Keep valid paths only.
|
||||||
size_t j = iPathFirst;
|
size_t j = iPathFirst;
|
||||||
for (size_t i = iPathFirst; i < polylines_out->size(); ++ i) {
|
for (size_t i = iPathFirst; i < polylines_out->size(); ++i) {
|
||||||
(*polylines_out)[i].clip_end(this->loop_clipping);
|
(*polylines_out)[i].clip_end(this->loop_clipping);
|
||||||
if ((*polylines_out)[i].is_valid()) {
|
if ((*polylines_out)[i].is_valid()) {
|
||||||
if (j < i)
|
if (j < i)
|
||||||
|
@ -79,6 +79,18 @@ Point operator+(const Point& point1, const Point& point2);
|
|||||||
Point operator-(const Point& point1, const Point& point2);
|
Point operator-(const Point& point1, const Point& point2);
|
||||||
Point operator*(double scalar, const Point& point2);
|
Point operator*(double scalar, const Point& point2);
|
||||||
|
|
||||||
|
inline Points&
|
||||||
|
operator+=(Points &dst, const Points &src) {
|
||||||
|
append_to(dst, src);
|
||||||
|
return dst;
|
||||||
|
};
|
||||||
|
|
||||||
|
inline Points&
|
||||||
|
operator+=(Points &dst, const Point &p) {
|
||||||
|
dst.push_back(p);
|
||||||
|
return dst;
|
||||||
|
};
|
||||||
|
|
||||||
class Point3 : public Point
|
class Point3 : public Point
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -48,6 +48,18 @@ class Polygon : public MultiPoint {
|
|||||||
Points convex_points(double angle = PI) const;
|
Points convex_points(double angle = PI) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
inline Polygons
|
||||||
|
operator+(Polygons src1, const Polygons &src2) {
|
||||||
|
append_to(src1, src2);
|
||||||
|
return src1;
|
||||||
|
};
|
||||||
|
|
||||||
|
inline Polygons&
|
||||||
|
operator+=(Polygons &dst, const Polygons &src2) {
|
||||||
|
append_to(dst, src2);
|
||||||
|
return dst;
|
||||||
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// start Boost
|
// start Boost
|
||||||
|
@ -94,7 +94,7 @@ SLAPrint::slice()
|
|||||||
const Polygons infill = offset(layer.slices, -scale_(shell_thickness));
|
const Polygons infill = offset(layer.slices, -scale_(shell_thickness));
|
||||||
|
|
||||||
// Generate solid infill.
|
// Generate solid infill.
|
||||||
layer.solid_infill.append(diff_ex(infill, internal, true));
|
layer.solid_infill << diff_ex(infill, internal, true);
|
||||||
|
|
||||||
// Generate internal infill.
|
// Generate internal infill.
|
||||||
{
|
{
|
||||||
@ -109,15 +109,10 @@ SLAPrint::slice()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Generate perimeter(s).
|
// Generate perimeter(s).
|
||||||
{
|
layer.perimeters << diff_ex(
|
||||||
const Polygons perimeters = offset(layer.slices, -scale_(shell_thickness)/2);
|
layer.slices,
|
||||||
for (Polygons::const_iterator it = perimeters.begin(); it != perimeters.end(); ++it) {
|
offset(layer.slices, -scale_(shell_thickness))
|
||||||
ExtrusionPath ep(erPerimeter);
|
);
|
||||||
ep.polyline = *it;
|
|
||||||
ep.width = shell_thickness;
|
|
||||||
layer.perimeters.append(ExtrusionLoop(ep));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -128,10 +123,8 @@ SLAPrint::slice()
|
|||||||
// flatten and merge all the overhangs
|
// flatten and merge all the overhangs
|
||||||
{
|
{
|
||||||
Polygons pp;
|
Polygons pp;
|
||||||
for (std::vector<Layer>::const_iterator it = this->layers.begin()+1; it != this->layers.end(); ++it) {
|
for (std::vector<Layer>::const_iterator it = this->layers.begin()+1; it != this->layers.end(); ++it)
|
||||||
Polygons oh = diff(it->slices, (it - 1)->slices);
|
pp += diff(it->slices, (it - 1)->slices);
|
||||||
pp.insert(pp.end(), oh.begin(), oh.end());
|
|
||||||
}
|
|
||||||
overhangs = union_ex(pp);
|
overhangs = union_ex(pp);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -188,8 +181,7 @@ SLAPrint::slice()
|
|||||||
// generate a solid raft if requested
|
// generate a solid raft if requested
|
||||||
// (do this after support material because we take support material shape into account)
|
// (do this after support material because we take support material shape into account)
|
||||||
if (this->config.raft_layers > 0) {
|
if (this->config.raft_layers > 0) {
|
||||||
ExPolygons raft = this->layers.front().slices;
|
ExPolygons raft = this->layers.front().slices + overhangs; // take support material into account
|
||||||
raft.insert(raft.end(), overhangs.begin(), overhangs.end()); // take support material into account
|
|
||||||
raft = offset_ex(raft, scale_(this->config.raft_offset));
|
raft = offset_ex(raft, scale_(this->config.raft_offset));
|
||||||
for (int i = this->config.raft_layers; i >= 1; --i) {
|
for (int i = this->config.raft_layers; i >= 1; --i) {
|
||||||
this->layers.insert(this->layers.begin(), Layer(0, first_lh + lh * (i-1)));
|
this->layers.insert(this->layers.begin(), Layer(0, first_lh + lh * (i-1)));
|
||||||
@ -235,9 +227,19 @@ SLAPrint::write_svg(const std::string &outputfile) const
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
// Perimeters.
|
||||||
|
for (ExPolygons::const_iterator it = layer.perimeters.expolygons.begin();
|
||||||
|
it != layer.perimeters.expolygons.end(); ++it) {
|
||||||
|
std::string pd = this->_SVG_path_d(*it);
|
||||||
|
|
||||||
|
fprintf(f,"\t\t<path d=\"%s\" style=\"fill: %s; stroke: %s; stroke-width: %s; fill-type: evenodd\" slic3r:type=\"perimeter\" />\n",
|
||||||
|
pd.c_str(), "white", "black", "0"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
// Solid infill.
|
// Solid infill.
|
||||||
const ExPolygons &solid_infill = layer.solid_infill.expolygons;
|
for (ExPolygons::const_iterator it = layer.solid_infill.expolygons.begin();
|
||||||
for (ExPolygons::const_iterator it = solid_infill.begin(); it != solid_infill.end(); ++it) {
|
it != layer.solid_infill.expolygons.end(); ++it) {
|
||||||
std::string pd = this->_SVG_path_d(*it);
|
std::string pd = this->_SVG_path_d(*it);
|
||||||
|
|
||||||
fprintf(f,"\t\t<path d=\"%s\" style=\"fill: %s; stroke: %s; stroke-width: %s; fill-type: evenodd\" slic3r:type=\"infill\" />\n",
|
fprintf(f,"\t\t<path d=\"%s\" style=\"fill: %s; stroke: %s; stroke-width: %s; fill-type: evenodd\" slic3r:type=\"infill\" />\n",
|
||||||
@ -245,10 +247,18 @@ SLAPrint::write_svg(const std::string &outputfile) const
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Generate perimeters.
|
// Internal infill.
|
||||||
for (ExtrusionEntitiesPtr::const_iterator it = layer.perimeters.entities.begin();
|
for (ExtrusionEntitiesPtr::const_iterator it = layer.infill.entities.begin();
|
||||||
it != layer.perimeters.entities.end(); ++it) {
|
it != layer.infill.entities.end(); ++it) {
|
||||||
//std::string pd = this->_SVG_path_d(it->polygon());
|
const ExPolygons infill = union_ex((*it)->grow());
|
||||||
|
|
||||||
|
for (ExPolygons::const_iterator e = infill.begin(); e != infill.end(); ++e) {
|
||||||
|
std::string pd = this->_SVG_path_d(*e);
|
||||||
|
|
||||||
|
fprintf(f,"\t\t<path d=\"%s\" style=\"fill: %s; stroke: %s; stroke-width: %s; fill-type: evenodd\" slic3r:type=\"infill\" />\n",
|
||||||
|
pd.c_str(), "white", "black", "0"
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@ class SLAPrint
|
|||||||
class Layer {
|
class Layer {
|
||||||
public:
|
public:
|
||||||
ExPolygonCollection slices;
|
ExPolygonCollection slices;
|
||||||
ExtrusionEntityCollection perimeters;
|
ExPolygonCollection perimeters;
|
||||||
ExtrusionEntityCollection infill;
|
ExtrusionEntityCollection infill;
|
||||||
ExPolygonCollection solid_infill;
|
ExPolygonCollection solid_infill;
|
||||||
float slice_z, print_z;
|
float slice_z, print_z;
|
||||||
|
@ -22,8 +22,8 @@
|
|||||||
%code%{ RETVAL = THIS->layers[i].slices; %};
|
%code%{ RETVAL = THIS->layers[i].slices; %};
|
||||||
ExPolygons layer_solid_infill(size_t i)
|
ExPolygons layer_solid_infill(size_t i)
|
||||||
%code%{ RETVAL = THIS->layers[i].solid_infill.expolygons; %};
|
%code%{ RETVAL = THIS->layers[i].solid_infill.expolygons; %};
|
||||||
Ref<ExtrusionEntityCollection> layer_perimeters(size_t i)
|
ExPolygons layer_perimeters(size_t i)
|
||||||
%code%{ RETVAL = &THIS->layers[i].perimeters; %};
|
%code%{ RETVAL = THIS->layers[i].perimeters; %};
|
||||||
Ref<ExtrusionEntityCollection> layer_infill(size_t i)
|
Ref<ExtrusionEntityCollection> layer_infill(size_t i)
|
||||||
%code%{ RETVAL = &THIS->layers[i].infill; %};
|
%code%{ RETVAL = &THIS->layers[i].infill; %};
|
||||||
bool layer_solid(size_t i)
|
bool layer_solid(size_t i)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user