mirror of
https://git.mirrors.martin98.com/https://github.com/slic3r/Slic3r.git
synced 2025-08-12 13:19:02 +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
|
||||
|
||||
ExtrusionEntityCollection gap_fill = thin_variable_width(polylines_gapfill, erGapFill, params.flow, scale_t(params.config->get_computed_value("resolution_internal")));
|
||||
//set role if needed
|
||||
/*if (params.role != erSolidInfill) {
|
||||
ExtrusionSetRole set_good_role(params.role);
|
||||
gap_fill.visit(set_good_role);
|
||||
}*/
|
||||
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
|
||||
//if (params.role != erSolidInfill) {
|
||||
// ExtrusionSetRole set_good_role(params.role);
|
||||
// for(ExtrusionEntity *ptr : gap_fill_entities)
|
||||
// ptr->visit(set_good_role);
|
||||
//}
|
||||
//move them into the collection
|
||||
if (!gap_fill.entities().empty()) {
|
||||
if (!gap_fill_entities.empty()) {
|
||||
ExtrusionEntityCollection* coll_gapfill = new ExtrusionEntityCollection();
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
@ -156,14 +156,17 @@ FillConcentricWGapFill::fill_surface_extrusion(
|
||||
}
|
||||
}
|
||||
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")));
|
||||
//set role if needed
|
||||
if (good_role != erSolidInfill) {
|
||||
ExtrusionSetRole set_good_role(good_role);
|
||||
gap_fill.visit(set_good_role);
|
||||
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
|
||||
if (good_role != erSolidInfill) {
|
||||
ExtrusionSetRole set_good_role(good_role);
|
||||
for (ExtrusionEntity* ptr : gap_fill_entities)
|
||||
ptr->visit(set_good_role);
|
||||
}
|
||||
//move them into the collection
|
||||
coll_nosort->append(std::move(gap_fill_entities));
|
||||
}
|
||||
//move them into the collection
|
||||
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)
|
||||
{
|
||||
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
|
||||
const coord_t tolerance = flow.scaled_width() / 10;//scale_(0.05);
|
||||
|
||||
ExtrusionEntityCollection coll;
|
||||
ExtrusionEntitiesPtr coll;
|
||||
for (const ThickPolyline &p : polylines) {
|
||||
ExtrusionPaths paths;
|
||||
ExtrusionPath path(role);
|
||||
@ -2227,23 +2227,23 @@ thin_variable_width(const ThickPolylines &polylines, ExtrusionRole role, Flow fl
|
||||
// Append paths to collection.
|
||||
if (!paths.empty()) {
|
||||
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 {
|
||||
if (role == erThinWall){
|
||||
//thin walls : avoid to cut them, please.
|
||||
//also, keep the start, as the start should be already in a frontier where possible.
|
||||
ExtrusionEntityCollection unsortable_coll(paths);
|
||||
unsortable_coll.set_can_sort_reverse(false, false);
|
||||
coll.append(unsortable_coll);
|
||||
ExtrusionEntityCollection *unsortable_coll = new ExtrusionEntityCollection(std::move(paths));
|
||||
unsortable_coll->set_can_sort_reverse(false, false);
|
||||
coll.push_back(unsortable_coll);
|
||||
} else {
|
||||
if (paths.size() <= 1) {
|
||||
coll.append(paths);
|
||||
if (paths.size() == 1) {
|
||||
coll.push_back(paths.front().clone_move());
|
||||
} 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.
|
||||
// I say that, but currently (false, true) does bad things.
|
||||
unsortable_coll.set_can_sort_reverse(false, true);
|
||||
coll.append(unsortable_coll);
|
||||
unsortable_coll->set_can_sort_reverse(false, true);
|
||||
coll.push_back(unsortable_coll);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -114,8 +114,8 @@ class MedialAxis {
|
||||
void remove_bits(ThickPolylines& pp);
|
||||
};
|
||||
|
||||
/// create a ExtrusionEntityCollection from ThickPolylines, discretizing the variable width into little sections (of 4*SCALED_RESOLUTION length) where needed.
|
||||
ExtrusionEntityCollection thin_variable_width(const ThickPolylines &polylines, ExtrusionRole role, Flow flow, coord_t resolution_internal);
|
||||
/// 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.
|
||||
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) {
|
||||
_merge_thin_walls(peri_entities, thin_walls_thickpolys);
|
||||
} else {
|
||||
ExtrusionEntityCollection tw = thin_variable_width
|
||||
(thin_walls_thickpolys, erThinWall, this->ext_perimeter_flow, std::max(ext_perimeter_width / 4, scale_t(this->print_config->resolution)));
|
||||
peri_entities.append(tw.entities());
|
||||
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.clear();
|
||||
}
|
||||
@ -1098,19 +1100,11 @@ void PerimeterGenerator::process()
|
||||
}
|
||||
// create extrusion from lines
|
||||
if (!polylines.empty()) {
|
||||
ExtrusionEntityCollection gap_fill = thin_variable_width(polylines,
|
||||
erGapFill, this->solid_infill_flow, scale_t(this->print_config->resolution_internal));
|
||||
|
||||
//{
|
||||
// static int isaqsdsdfsdfqzfn = 0;
|
||||
// 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());
|
||||
this->gap_fill->append(thin_variable_width(
|
||||
polylines,
|
||||
erGapFill,
|
||||
this->solid_infill_flow,
|
||||
scale_t(this->print_config->resolution_internal)));
|
||||
/* 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).
|
||||
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
|
||||
and use zigzag). */
|
||||
// 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.
|
||||
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
|
||||
@ -1500,11 +1494,11 @@ ExtrusionEntityCollection PerimeterGenerator::_traverse_loops(
|
||||
|
||||
// append thin walls to the nearest-neighbor search (only for first iteration)
|
||||
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)));
|
||||
coll.insert(coll.end(), tw.entities().begin(), tw.entities().end());
|
||||
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.begin(), tw.end());
|
||||
//don't add again
|
||||
thin_walls.clear();
|
||||
}
|
||||
|
||||
// traverse children and build the final collection
|
||||
Point zero_point(0, 0);
|
||||
//result is [idx, needReverse] ?
|
||||
@ -1571,6 +1565,7 @@ ExtrusionEntityCollection PerimeterGenerator::_traverse_loops(
|
||||
}
|
||||
|
||||
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 {
|
||||
public:
|
||||
float percent_extrusion;
|
||||
@ -1578,7 +1573,7 @@ void PerimeterGenerator::_merge_thin_walls(ExtrusionEntityCollection &extrusions
|
||||
virtual void use(ExtrusionPath &path) override {
|
||||
path.mm3_per_mm *= 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(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,
|
||||
ExtrusionPath(poly_after, *searcher.search_result.path));
|
||||
//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;
|
||||
if (tws.entities().size() == 1 && tws.entities()[0]->is_loop()) {
|
||||
//loop, just add it
|
||||
@ -1708,9 +1704,9 @@ void PerimeterGenerator::_merge_thin_walls(ExtrusionEntityCollection &extrusions
|
||||
|
||||
} else {
|
||||
//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.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
|
||||
for (ExtrusionPath &path : change_flow.paths)
|
||||
path.reverse();
|
||||
@ -1731,8 +1727,7 @@ void PerimeterGenerator::_merge_thin_walls(ExtrusionEntityCollection &extrusions
|
||||
}
|
||||
|
||||
//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(tws.entities());
|
||||
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))));
|
||||
}
|
||||
|
||||
PerimeterIntersectionPoint
|
||||
|
Loading…
x
Reference in New Issue
Block a user