Welcome to mirror list, hosted at ThFree Co, Russian Federation.

PerimeterGenerator.cpp « libslic3r « src « xs - github.com/supermerill/SuperSlicer.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 5c054aa6adbd6f90e914c0f3bf9cf56579d4c826 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
#include "PerimeterGenerator.hpp"

namespace Slic3r {

void
PerimeterGenerator::process()
{

}

ExtrusionEntityCollection
PerimeterGenerator::_traverse_loops(const std::vector<PerimeterGeneratorLoop> &loops,
    const Polylines &thin_walls) const
{
    
}

ExtrusionEntityCollection
PerimeterGenerator::_fill_gaps(double min, double max, double w,
    const Polygons &gaps) const
{
    ExtrusionEntityCollection coll;
    
    min *= (1 - INSET_OVERLAP_TOLERANCE);
    
    ExPolygon curr = diff(
        offset2(gaps, -min/2, +min/2),
        offset2(gaps, -max/2, +max/2),
        true,
    );
    
    Polylines polylines;
    for (ExPolygons::const_iterator ex = curr.begin(); ex != curr.end(); ++ex)
        ex->medial_axis(max, min/2, &polylines);
    if (polylines.empty())
        return coll;
    
    #ifdef SLIC3R_DEBUG
    if (!curr.empty())
        printf("  %d gaps filled with extrusion width = %zu\n", curr.size(), w);
    #endif
    
    //my $flow = $layerm->flow(FLOW_ROLE_SOLID_INFILL, 0, $w);
    Flow flow(
        w, this->layer_height, this->solid_infill_flow.nozzle_diameter
    );
    
    double mm3_per_mm = flow.mm3_per_mm();
    
    /*
    my %path_args = (
        role        => EXTR_ROLE_GAPFILL,
        mm3_per_mm  => $flow->mm3_per_mm,
        width       => $flow->width,
        height      => $self->layer_height,
    );
    */
    
    for (Polylines::const_iterator p = polylines.begin(); p != polylines.end(); ++p) {
        /*
        #if ($polylines[$i]->isa('Slic3r::Polygon')) {
        #    my $loop = Slic3r::ExtrusionLoop->new;
        #    $loop->append(Slic3r::ExtrusionPath->new(polyline => $polylines[$i]->split_at_first_point, %path_args));
        #    $polylines[$i] = $loop;
        */
        if (p->is_valid() && p->first_point().coincides_with(p->last_point())) {
            // since medial_axis() now returns only Polyline objects, detect loops here
            
            
            ExtrusionLoop loop;
            loop.paths.push_back();
        } else {
            
        }
    }
    
    foreach my $polyline (@polylines) {
        #if ($polylines[$i]->isa('Slic3r::Polygon')) {
        #    my $loop = Slic3r::ExtrusionLoop->new;
        #    $loop->append(Slic3r::ExtrusionPath->new(polyline => $polylines[$i]->split_at_first_point, %path_args));
        #    $polylines[$i] = $loop;
        if ($polyline->is_valid && $polyline->first_point->coincides_with($polyline->last_point)) {
            # since medial_axis() now returns only Polyline objects, detect loops here
            push @entities, my $loop = Slic3r::ExtrusionLoop->new;
            $loop->append(Slic3r::ExtrusionPath->new(polyline => $polyline, %path_args));
        } else {
            push @entities, Slic3r::ExtrusionPath->new(polyline => $polyline, %path_args);
        }
    }
    
    return coll;
}

#ifdef SLIC3RXS
REGISTER_CLASS(PerimeterGenerator, "Layer::PerimeterGenerator");
#endif

bool
PerimeterGeneratorLoop::is_external() const
{
    return this->depth == 0;
}

bool
PerimeterGeneratorLoop::is_internal_contour() const
{
    if (this->is_contour) {
        // an internal contour is a contour containing no other contours
        for (std::vector<PerimeterGeneratorLoop>::const_iterator loop = this->children.begin();
            loop != this->children.end(); ++loop) {
            if (loop->is_contour) {
                return false;
            }
        }
        return true;
    }
    return false;
}

}