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

FillRectilinear.hpp « Fill « libslic3r « src « xs - github.com/prusa3d/PrusaSlicer.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 1be85f755455575c6bb9c0c3b35c5b5bb57064f7 (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
#ifndef slic3r_FillRectilinear_hpp_
#define slic3r_FillRectilinear_hpp_

#include "../libslic3r.h"

#include "FillBase.hpp"

namespace Slic3r {

class Surface;

class FillRectilinear : public Fill
{
public:
    virtual Fill* clone() const { return new FillRectilinear(*this); };
    virtual ~FillRectilinear() {}

protected:
	virtual void _fill_surface_single(
	    const FillParams                &params, 
	    unsigned int                     thickness_layers,
	    const std::pair<float, Point>   &direction, 
	    ExPolygon                       &expolygon, 
	    Polylines                       &polylines_out);

	coord_t _min_spacing;
	coord_t _line_spacing;
	// distance threshold for allowing the horizontal infill lines to be connected into a continuous path
	coord_t _diagonal_distance;
	// only for line infill
	coord_t _line_oscillation;

	// Enabled for the grid infill, disabled for the rectilinear and line infill.
	virtual bool _horizontal_lines() const { return false; }

	virtual Line _line(int i, coord_t x, coord_t y_min, coord_t y_max) const 
		{ return Line(Point(x, y_min), Point(x, y_max)); }
	
	virtual bool _can_connect(coord_t dist_X, coord_t dist_Y) {
	    return dist_X <= this->_diagonal_distance
	        && dist_Y <= this->_diagonal_distance;
    }
};

class FillLine : public FillRectilinear
{
public:
    virtual ~FillLine() {}

protected:
	virtual Line _line(int i, coord_t x, coord_t y_min, coord_t y_max) const {
		coord_t osc = (i & 1) ? this->_line_oscillation : 0;
		return Line(Point(x - osc, y_min), Point(x + osc, y_max));
	}

	virtual bool _can_connect(coord_t dist_X, coord_t dist_Y)
	{
	    coord_t TOLERANCE = 10 * SCALED_EPSILON;
    	return (dist_X >= (this->_line_spacing - this->_line_oscillation) - TOLERANCE)
        	&& (dist_X <= (this->_line_spacing + this->_line_oscillation) + TOLERANCE)
        	&& (dist_Y <= this->_diagonal_distance);
    }
};

class FillGrid : public FillRectilinear
{
public:
    virtual ~FillGrid() {}

protected:
	// The grid fill will keep the angle constant between the layers, see the implementation of Slic3r::Fill.
    virtual float _layer_angle(size_t idx) const { return 0.f; }
	// Flag for Slic3r::Fill::Rectilinear to fill both directions.
	virtual bool _horizontal_lines() const { return true; }
};

}; // namespace Slic3r

#endif // slic3r_FillRectilinear_hpp_