mirror of
https://git.mirrors.martin98.com/https://github.com/slic3r/Slic3r.git
synced 2025-08-12 18:29:01 +08:00
continue some 2df72f entities pointer fix.
Should change them to unique_ptr/shared_ptr to stop worrying.
This commit is contained in:
parent
234b161550
commit
fa49d3b06e
@ -269,17 +269,18 @@ Fill::do_gap_fill(const ExPolygons& gapfill_areas, const FillParams& params, Ext
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
ExtrusionEntityCollection gap_fill = thin_variable_width(polylines_gapfill, erGapFill, params.flow, scale_t(params.config->get_computed_value("resolution_internal")));
|
ExtrusionEntitiesPtr gap_fill_entities = thin_variable_width(polylines_gapfill, erGapFill, params.flow, scale_t(params.config->get_computed_value("resolution_internal")));
|
||||||
//set role if needed
|
////set role if needed
|
||||||
/*if (params.role != erSolidInfill) {
|
//if (params.role != erSolidInfill) {
|
||||||
ExtrusionSetRole set_good_role(params.role);
|
// ExtrusionSetRole set_good_role(params.role);
|
||||||
gap_fill.visit(set_good_role);
|
// for(ExtrusionEntity *ptr : gap_fill_entities)
|
||||||
}*/
|
// ptr->visit(set_good_role);
|
||||||
|
//}
|
||||||
//move them into the collection
|
//move them into the collection
|
||||||
if (!gap_fill.entities().empty()) {
|
if (!gap_fill_entities.empty()) {
|
||||||
ExtrusionEntityCollection* coll_gapfill = new ExtrusionEntityCollection();
|
ExtrusionEntityCollection* coll_gapfill = new ExtrusionEntityCollection();
|
||||||
coll_gapfill->set_can_sort_reverse(!this->no_sort(), !this->no_sort());
|
coll_gapfill->set_can_sort_reverse(!this->no_sort(), !this->no_sort());
|
||||||
coll_gapfill->append(std::move(gap_fill.entities()));
|
coll_gapfill->append(std::move(gap_fill_entities));
|
||||||
coll_out.push_back(coll_gapfill);
|
coll_out.push_back(coll_gapfill);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -156,14 +156,17 @@ FillConcentricWGapFill::fill_surface_extrusion(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!polylines.empty() && !is_bridge(good_role)) {
|
if (!polylines.empty() && !is_bridge(good_role)) {
|
||||||
ExtrusionEntityCollection gap_fill = thin_variable_width(polylines, erGapFill, params.flow, scale_t(params.config->get_computed_value("resolution_internal")));
|
ExtrusionEntitiesPtr gap_fill_entities = thin_variable_width(polylines, erGapFill, params.flow, scale_t(params.config->get_computed_value("resolution_internal")));
|
||||||
|
if (!gap_fill_entities.empty()) {
|
||||||
//set role if needed
|
//set role if needed
|
||||||
if (good_role != erSolidInfill) {
|
if (good_role != erSolidInfill) {
|
||||||
ExtrusionSetRole set_good_role(good_role);
|
ExtrusionSetRole set_good_role(good_role);
|
||||||
gap_fill.visit(set_good_role);
|
for (ExtrusionEntity* ptr : gap_fill_entities)
|
||||||
|
ptr->visit(set_good_role);
|
||||||
}
|
}
|
||||||
//move them into the collection
|
//move them into the collection
|
||||||
coll_nosort->append(std::move(gap_fill.entities()));
|
coll_nosort->append(std::move(gap_fill_entities));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2064,7 +2064,7 @@ MedialAxis::build(ThickPolylines &polylines_out)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ExtrusionEntityCollection
|
ExtrusionEntitiesPtr
|
||||||
thin_variable_width(const ThickPolylines &polylines, ExtrusionRole role, Flow flow, coord_t resolution_internal)
|
thin_variable_width(const ThickPolylines &polylines, ExtrusionRole role, Flow flow, coord_t resolution_internal)
|
||||||
{
|
{
|
||||||
assert(resolution_internal > SCALED_EPSILON);
|
assert(resolution_internal > SCALED_EPSILON);
|
||||||
@ -2074,7 +2074,7 @@ thin_variable_width(const ThickPolylines &polylines, ExtrusionRole role, Flow fl
|
|||||||
// of segments, and any pruning shall be performed before we apply this tolerance
|
// of segments, and any pruning shall be performed before we apply this tolerance
|
||||||
const coord_t tolerance = flow.scaled_width() / 10;//scale_(0.05);
|
const coord_t tolerance = flow.scaled_width() / 10;//scale_(0.05);
|
||||||
|
|
||||||
ExtrusionEntityCollection coll;
|
ExtrusionEntitiesPtr coll;
|
||||||
for (const ThickPolyline &p : polylines) {
|
for (const ThickPolyline &p : polylines) {
|
||||||
ExtrusionPaths paths;
|
ExtrusionPaths paths;
|
||||||
ExtrusionPath path(role);
|
ExtrusionPath path(role);
|
||||||
@ -2227,23 +2227,23 @@ thin_variable_width(const ThickPolylines &polylines, ExtrusionRole role, Flow fl
|
|||||||
// Append paths to collection.
|
// Append paths to collection.
|
||||||
if (!paths.empty()) {
|
if (!paths.empty()) {
|
||||||
if (paths.front().first_point().coincides_with_epsilon(paths.back().last_point())) {
|
if (paths.front().first_point().coincides_with_epsilon(paths.back().last_point())) {
|
||||||
coll.append(ExtrusionLoop(paths));
|
coll.push_back(new ExtrusionLoop(std::move(paths)));
|
||||||
} else {
|
} else {
|
||||||
if (role == erThinWall){
|
if (role == erThinWall){
|
||||||
//thin walls : avoid to cut them, please.
|
//thin walls : avoid to cut them, please.
|
||||||
//also, keep the start, as the start should be already in a frontier where possible.
|
//also, keep the start, as the start should be already in a frontier where possible.
|
||||||
ExtrusionEntityCollection unsortable_coll(paths);
|
ExtrusionEntityCollection *unsortable_coll = new ExtrusionEntityCollection(std::move(paths));
|
||||||
unsortable_coll.set_can_sort_reverse(false, false);
|
unsortable_coll->set_can_sort_reverse(false, false);
|
||||||
coll.append(unsortable_coll);
|
coll.push_back(unsortable_coll);
|
||||||
} else {
|
} else {
|
||||||
if (paths.size() <= 1) {
|
if (paths.size() == 1) {
|
||||||
coll.append(paths);
|
coll.push_back(paths.front().clone_move());
|
||||||
} else {
|
} else {
|
||||||
ExtrusionEntityCollection unsortable_coll(paths);
|
ExtrusionEntityCollection *unsortable_coll = new ExtrusionEntityCollection(std::move(paths));
|
||||||
//gap fill : can reverse, but refrain from cutting them as it creates a mess.
|
//gap fill : can reverse, but refrain from cutting them as it creates a mess.
|
||||||
// I say that, but currently (false, true) does bad things.
|
// I say that, but currently (false, true) does bad things.
|
||||||
unsortable_coll.set_can_sort_reverse(false, true);
|
unsortable_coll->set_can_sort_reverse(false, true);
|
||||||
coll.append(unsortable_coll);
|
coll.push_back(unsortable_coll);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -114,8 +114,8 @@ class MedialAxis {
|
|||||||
void remove_bits(ThickPolylines& pp);
|
void remove_bits(ThickPolylines& pp);
|
||||||
};
|
};
|
||||||
|
|
||||||
/// create a ExtrusionEntityCollection from ThickPolylines, discretizing the variable width into little sections (of 4*SCALED_RESOLUTION length) where needed.
|
/// create a ExtrusionEntitiesPtr from ThickPolylines, discretizing the variable width into little sections (of 4*SCALED_RESOLUTION length) where needed. Please delete all ptr if not used.
|
||||||
ExtrusionEntityCollection thin_variable_width(const ThickPolylines &polylines, ExtrusionRole role, Flow flow, coord_t resolution_internal);
|
ExtrusionEntitiesPtr thin_variable_width(const ThickPolylines &polylines, ExtrusionRole role, Flow flow, coord_t resolution_internal);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -941,9 +941,11 @@ void PerimeterGenerator::process()
|
|||||||
if (this->object_config->thin_walls_merge) {
|
if (this->object_config->thin_walls_merge) {
|
||||||
_merge_thin_walls(peri_entities, thin_walls_thickpolys);
|
_merge_thin_walls(peri_entities, thin_walls_thickpolys);
|
||||||
} else {
|
} else {
|
||||||
ExtrusionEntityCollection tw = thin_variable_width
|
peri_entities.append(thin_variable_width(
|
||||||
(thin_walls_thickpolys, erThinWall, this->ext_perimeter_flow, std::max(ext_perimeter_width / 4, scale_t(this->print_config->resolution)));
|
thin_walls_thickpolys,
|
||||||
peri_entities.append(tw.entities());
|
erThinWall,
|
||||||
|
this->ext_perimeter_flow,
|
||||||
|
std::max(ext_perimeter_width / 4, scale_t(this->print_config->resolution))));
|
||||||
}
|
}
|
||||||
thin_walls_thickpolys.clear();
|
thin_walls_thickpolys.clear();
|
||||||
}
|
}
|
||||||
@ -1098,19 +1100,11 @@ void PerimeterGenerator::process()
|
|||||||
}
|
}
|
||||||
// create extrusion from lines
|
// create extrusion from lines
|
||||||
if (!polylines.empty()) {
|
if (!polylines.empty()) {
|
||||||
ExtrusionEntityCollection gap_fill = thin_variable_width(polylines,
|
this->gap_fill->append(thin_variable_width(
|
||||||
erGapFill, this->solid_infill_flow, scale_t(this->print_config->resolution_internal));
|
polylines,
|
||||||
|
erGapFill,
|
||||||
//{
|
this->solid_infill_flow,
|
||||||
// static int isaqsdsdfsdfqzfn = 0;
|
scale_t(this->print_config->resolution_internal)));
|
||||||
// std::stringstream stri;
|
|
||||||
// stri << this->layer->id() << "_gapfill_" << isaqsdsdfsdfqzfn++ << ".svg";
|
|
||||||
// SVG svg(stri.str());
|
|
||||||
// svg.draw((surface.expolygon), "grey");
|
|
||||||
// svg.draw(polylines, "blue");
|
|
||||||
// svg.Close();
|
|
||||||
//}
|
|
||||||
this->gap_fill->append(gap_fill.entities());
|
|
||||||
/* Make sure we don't infill narrow parts that are already gap-filled
|
/* Make sure we don't infill narrow parts that are already gap-filled
|
||||||
(we only consider this surface's gaps to reduce the diff() complexity).
|
(we only consider this surface's gaps to reduce the diff() complexity).
|
||||||
Growing actual extrusions ensures that gaps not filled by medial axis
|
Growing actual extrusions ensures that gaps not filled by medial axis
|
||||||
@ -1118,7 +1112,7 @@ void PerimeterGenerator::process()
|
|||||||
that medial axis skips but infill might join with other infill regions
|
that medial axis skips but infill might join with other infill regions
|
||||||
and use zigzag). */
|
and use zigzag). */
|
||||||
// get clean surface of gap
|
// get clean surface of gap
|
||||||
gap_srf = union_ex(offset(gap_fill.polygons_covered_by_width(float(SCALED_EPSILON) / 10), float(SCALED_EPSILON / 2)));
|
gap_srf = union_ex(offset(this->gap_fill->polygons_covered_by_width(float(SCALED_EPSILON) / 10), float(SCALED_EPSILON / 2)));
|
||||||
// intersection to ignore the bits of gapfill tha may be over infill, as it's epsilon and there may be some voids here anyway.
|
// intersection to ignore the bits of gapfill tha may be over infill, as it's epsilon and there may be some voids here anyway.
|
||||||
gap_srf = intersection_ex(gap_srf, gaps_ex);
|
gap_srf = intersection_ex(gap_srf, gaps_ex);
|
||||||
// the diff(last, gap) will be done after, as we have to keep the last un-gapped to avoid unneeded gap/infill offset
|
// the diff(last, gap) will be done after, as we have to keep the last un-gapped to avoid unneeded gap/infill offset
|
||||||
@ -1500,11 +1494,11 @@ ExtrusionEntityCollection PerimeterGenerator::_traverse_loops(
|
|||||||
|
|
||||||
// append thin walls to the nearest-neighbor search (only for first iteration)
|
// append thin walls to the nearest-neighbor search (only for first iteration)
|
||||||
if (!thin_walls.empty()) {
|
if (!thin_walls.empty()) {
|
||||||
ExtrusionEntityCollection tw = thin_variable_width(thin_walls, erThinWall, this->ext_perimeter_flow, std::max(ext_perimeter_flow.scaled_width() / 4, scale_t(this->print_config->resolution)));
|
ExtrusionEntitiesPtr tw = thin_variable_width(thin_walls, erThinWall, this->ext_perimeter_flow, std::max(ext_perimeter_flow.scaled_width() / 4, scale_t(this->print_config->resolution)));
|
||||||
coll.insert(coll.end(), tw.entities().begin(), tw.entities().end());
|
coll.insert(coll.end(), tw.begin(), tw.end());
|
||||||
|
//don't add again
|
||||||
thin_walls.clear();
|
thin_walls.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
// traverse children and build the final collection
|
// traverse children and build the final collection
|
||||||
Point zero_point(0, 0);
|
Point zero_point(0, 0);
|
||||||
//result is [idx, needReverse] ?
|
//result is [idx, needReverse] ?
|
||||||
@ -1571,6 +1565,7 @@ ExtrusionEntityCollection PerimeterGenerator::_traverse_loops(
|
|||||||
}
|
}
|
||||||
|
|
||||||
void PerimeterGenerator::_merge_thin_walls(ExtrusionEntityCollection &extrusions, ThickPolylines &thin_walls) const {
|
void PerimeterGenerator::_merge_thin_walls(ExtrusionEntityCollection &extrusions, ThickPolylines &thin_walls) const {
|
||||||
|
//TODO: find a way to avoid double copy (from EntityCollection to ChangeFlow to searcher.search_result.loop
|
||||||
class ChangeFlow : public ExtrusionVisitor {
|
class ChangeFlow : public ExtrusionVisitor {
|
||||||
public:
|
public:
|
||||||
float percent_extrusion;
|
float percent_extrusion;
|
||||||
@ -1578,7 +1573,7 @@ void PerimeterGenerator::_merge_thin_walls(ExtrusionEntityCollection &extrusions
|
|||||||
virtual void use(ExtrusionPath &path) override {
|
virtual void use(ExtrusionPath &path) override {
|
||||||
path.mm3_per_mm *= percent_extrusion;
|
path.mm3_per_mm *= percent_extrusion;
|
||||||
path.width *= percent_extrusion;
|
path.width *= percent_extrusion;
|
||||||
paths.emplace_back(std::move(path));
|
paths.push_back(path);
|
||||||
}
|
}
|
||||||
virtual void use(ExtrusionPath3D &path3D) override { /*shouldn't happen*/ }
|
virtual void use(ExtrusionPath3D &path3D) override { /*shouldn't happen*/ }
|
||||||
virtual void use(ExtrusionMultiPath &multipath) override { /*shouldn't happen*/ }
|
virtual void use(ExtrusionMultiPath &multipath) override { /*shouldn't happen*/ }
|
||||||
@ -1694,7 +1689,8 @@ void PerimeterGenerator::_merge_thin_walls(ExtrusionEntityCollection &extrusions
|
|||||||
searcher.search_result.loop->paths.insert(searcher.search_result.loop->paths.begin() + 1 + searcher.search_result.idx_path,
|
searcher.search_result.loop->paths.insert(searcher.search_result.loop->paths.begin() + 1 + searcher.search_result.idx_path,
|
||||||
ExtrusionPath(poly_after, *searcher.search_result.path));
|
ExtrusionPath(poly_after, *searcher.search_result.path));
|
||||||
//create thin wall path exttrusion
|
//create thin wall path exttrusion
|
||||||
ExtrusionEntityCollection tws = thin_variable_width({ tw }, erThinWall, this->ext_perimeter_flow, std::max(ext_perimeter_flow.scaled_width() / 4, scale_t(this->print_config->resolution)));
|
ExtrusionEntityCollection tws;
|
||||||
|
tws.append(thin_variable_width({ tw }, erThinWall, this->ext_perimeter_flow, std::max(ext_perimeter_flow.scaled_width() / 4, scale_t(this->print_config->resolution))));
|
||||||
ChangeFlow change_flow;
|
ChangeFlow change_flow;
|
||||||
if (tws.entities().size() == 1 && tws.entities()[0]->is_loop()) {
|
if (tws.entities().size() == 1 && tws.entities()[0]->is_loop()) {
|
||||||
//loop, just add it
|
//loop, just add it
|
||||||
@ -1708,9 +1704,9 @@ void PerimeterGenerator::_merge_thin_walls(ExtrusionEntityCollection &extrusions
|
|||||||
|
|
||||||
} else {
|
} else {
|
||||||
//first add the return path
|
//first add the return path
|
||||||
ExtrusionEntityCollection tws_second = tws;
|
//ExtrusionEntityCollection tws_second = tws; // this does a deep copy
|
||||||
change_flow.percent_extrusion = 0.1f;
|
change_flow.percent_extrusion = 0.1f;
|
||||||
change_flow.use(tws_second);
|
change_flow.use(tws); // tws_second); //does not need the deep copy if the change_flow copy the content instead of re-using it.
|
||||||
//force reverse
|
//force reverse
|
||||||
for (ExtrusionPath &path : change_flow.paths)
|
for (ExtrusionPath &path : change_flow.paths)
|
||||||
path.reverse();
|
path.reverse();
|
||||||
@ -1731,8 +1727,7 @@ void PerimeterGenerator::_merge_thin_walls(ExtrusionEntityCollection &extrusions
|
|||||||
}
|
}
|
||||||
|
|
||||||
//now add thinwalls that have no anchor (make them reversable)
|
//now add thinwalls that have no anchor (make them reversable)
|
||||||
ExtrusionEntityCollection tws = thin_variable_width(not_added, erThinWall, this->ext_perimeter_flow, std::max(ext_perimeter_flow.scaled_width() / 4, scale_t(this->print_config->resolution)));
|
extrusions.append(thin_variable_width(not_added, erThinWall, this->ext_perimeter_flow, std::max(ext_perimeter_flow.scaled_width() / 4, scale_t(this->print_config->resolution))));
|
||||||
extrusions.append(tws.entities());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PerimeterIntersectionPoint
|
PerimeterIntersectionPoint
|
||||||
|
Loading…
x
Reference in New Issue
Block a user