Defined the +-* operators on Pointf.

Removed the deprecated VibrationLimit feature.
Added triangle infill.
The Prusa3D fork of Slic3r has been marked as "Slic3r Prusa Edition"
with menus pointing to the prusa3d/slic3r github release page
and Prusa3D drivers downloads page.
This commit is contained in:
bubnikv 2016-10-21 16:53:42 +02:00
parent 15d3e94a66
commit 1fb57e439e
25 changed files with 148 additions and 237 deletions

View file

@ -24,6 +24,7 @@ Fill* Fill::new_from_type(const InfillPattern type)
// case ipRectilinear: return new FillRectilinear();
case ipLine: return new FillLine();
case ipGrid: return new FillGrid2();
case ipTriangles: return new FillTriangles();
// case ipGrid: return new FillGrid();
case ipArchimedeanChords: return new FillArchimedeanChords();
case ipHilbertCurve: return new FillHilbertCurve();

View file

@ -1449,10 +1449,20 @@ Polylines FillGrid2::fill_surface(const Surface *surface, const FillParams &para
Polylines polylines_out;
if (! fill_surface_by_lines(surface, params, 0.f, polylines_out) ||
! fill_surface_by_lines(surface, params, float(M_PI / 2.), polylines_out)) {
printf("FillRectilinear2::fill_surface() failed to fill a region.\n");
printf("FillGrid2::fill_surface() failed to fill a region.\n");
}
return polylines_out;
}
Polylines FillTriangles::fill_surface(const Surface *surface, const FillParams &params)
{
Polylines polylines_out;
if (! fill_surface_by_lines(surface, params, 0.f, polylines_out) ||
! fill_surface_by_lines(surface, params, float(M_PI / 3.), polylines_out) ||
! fill_surface_by_lines(surface, params, float(2. * M_PI / 3.), polylines_out)) {
printf("FillTriangles::fill_surface() failed to fill a region.\n");
}
return polylines_out;
}
} // namespace Slic3r

View file

@ -35,6 +35,17 @@ protected:
virtual float _layer_angle(size_t idx) const { return 0.f; }
};
class FillTriangles : public FillRectilinear2
{
public:
virtual ~FillTriangles() {}
virtual Polylines fill_surface(const Surface *surface, const FillParams &params);
protected:
// The grid fill will keep the angle constant between the layers, see the implementation of Slic3r::Fill::Base.
virtual float _layer_angle(size_t idx) const { return 0.f; }
};
}; // namespace Slic3r
#endif // slic3r_FillRectilinear2_hpp_

View file

@ -343,9 +343,92 @@ linint(double value, double oldmin, double oldmax, double newmin, double newmax)
return (value - oldmin) * (newmax - newmin) / (oldmax - oldmin) + newmin;
}
Pointfs
arrange(size_t total_parts, Pointf part, coordf_t dist, const BoundingBoxf* bb)
#if 0
// Point with a weight, by which the points are sorted.
// If the points have the same weight, sort them lexicographically by their positions.
struct ArrangeItem {
ArrangeItem() {}
Pointf pos;
coordf_t weight;
bool operator<(const ArrangeItem &other) const {
return weight < other.weight ||
((weight == other.weight) && (pos.y < other.pos.y || (pos.y == other.pos.y && pos.x < other.pos.x)));
}
};
Pointfs arrange(size_t num_parts, const Pointf &part_size, coordf_t gap, const BoundingBoxf* bed_bounding_box)
{
// Use actual part size (the largest) plus separation distance (half on each side) in spacing algorithm.
const Pointf cell_size(part_size.x + gap, part_size.y + gap);
const BoundingBoxf bed_bbox = (bed_bounding_box != NULL && bed_bounding_box->defined) ?
*bed_bounding_box :
// Bogus bed size, large enough not to trigger the unsufficient bed size error.
BoundingBoxf(
Pointf(0, 0),
Pointf(cell_size.x * num_parts, cell_size.y * num_parts));
// This is how many cells we have available into which to put parts.
size_t cellw = size_t(floor((bed_bbox.size().x + gap) / cell_size.x));
size_t cellh = size_t(floor((bed_bbox.size().y + gap) / cell_size.y));
if (num_parts > cellw * cellh)
CONFESS("%zu parts won't fit in your print area!\n", num_parts);
// Get a bounding box of cellw x cellh cells, centered at the center of the bed.
Pointf cells_size(cellw * cell_size.x - gap, cellh * cell_size.y - gap);
Pointf cells_offset(bed_bbox.center() - 0.5 * cells_size);
BoundingBoxf cells_bb(cells_offset, cells_size + cells_offset);
// List of cells, sorted by distance from center.
std::vector<ArrangeItem> cellsorder(cellw * cellh, ArrangeItem());
for (size_t j = 0; j < cellh; ++ j) {
// Center of the jth row on the bed.
coordf_t cy = linint(j + 0.5, 0., double(cellh), cells_bb.min.y, cells_bb.max.y);
// Offset from the bed center.
coordf_t yd = cells_bb.center().y - cy;
for (size_t i = 0; i < cellw; ++ i) {
// Center of the ith column on the bed.
coordf_t cx = linint(i + 0.5, 0., double(cellw), cells_bb.min.x, cells_bb.max.x);
// Offset from the bed center.
coordf_t xd = cells_bb.center().x - cx;
// Cell with a distance from the bed center.
ArrangeItem &ci = cellsorder[j * cellw + i];
// Cell center
ci.pos.x = cx;
ci.pos.y = cy;
// Square distance of the cell center to the bed center.
ci.weight = xd * xd + yd * yd;
}
}
// Sort the cells lexicographically by their distances to the bed center and left to right / bttom to top.
std::sort(cellsorder.begin(), cellsorder.end());
cellsorder.erase(cellsorder.begin() + num_parts, cellsorder.end());
// Return the (left,top) corners of the cells.
Pointfs positions;
positions.reserve(num_parts);
for (std::vector<ArrangeItem>::const_iterator it = cellsorder.begin(); it != cellsorder.end(); ++ it)
positions.push_back(Pointf(it->pos.x - 0.5 * part_size.x, it->pos.y - 0.5 * part_size.y));
return positions;
}
#else
class ArrangeItem {
public:
Pointf pos;
size_t index_x, index_y;
coordf_t dist;
};
class ArrangeItemIndex {
public:
coordf_t index;
ArrangeItem item;
ArrangeItemIndex(coordf_t _index, ArrangeItem _item) : index(_index), item(_item) {};
};
Pointfs
arrange(size_t total_parts, const Pointf &part_size, coordf_t dist, const BoundingBoxf* bb)
{
Pointf part = part_size;
// use actual part size (the largest) plus separation distance (half on each side) in spacing algorithm
part.x += dist;
part.y += dist;
@ -463,6 +546,7 @@ arrange(size_t total_parts, Pointf part, coordf_t dist, const BoundingBoxf* bb)
return positions;
}
#endif
#ifdef SLIC3R_DEBUG
// The following code for the visualization of the boost Voronoi diagram is based on:

View file

@ -25,20 +25,8 @@ double rad2deg_dir(double angle);
double deg2rad(double angle);
void simplify_polygons(const Polygons &polygons, double tolerance, Polygons* retval);
class ArrangeItem {
public:
Pointf pos;
size_t index_x, index_y;
coordf_t dist;
};
class ArrangeItemIndex {
public:
coordf_t index;
ArrangeItem item;
ArrangeItemIndex(coordf_t _index, ArrangeItem _item) : index(_index), item(_item) {};
};
double linint(double value, double oldmin, double oldmax, double newmin, double newmax);
Pointfs arrange(size_t total_parts, Pointf part, coordf_t dist, const BoundingBoxf* bb);
Pointfs arrange(size_t num_parts, const Pointf &part_size, coordf_t gap, const BoundingBoxf* bed_bounding_box);
class MedialAxis {
public:

View file

@ -312,24 +312,6 @@ Point::vector_to(const Point &point) const
return Vector(point.x - this->x, point.y - this->y);
}
Point
operator+(const Point& point1, const Point& point2)
{
return Point(point1.x + point2.x, point1.y + point2.y);
}
Point
operator-(const Point& point1, const Point& point2)
{
return Point(point1.x - point2.x, point1.y - point2.y);
}
Point
operator*(double scalar, const Point& point2)
{
return Point(scalar * point2.x, scalar * point2.y);
}
std::ostream&
operator<<(std::ostream &stm, const Pointf &pointf)
{

View file

@ -66,9 +66,9 @@ class Point
Vector vector_to(const Point &point) const;
};
Point operator+(const Point& point1, const Point& point2);
Point operator-(const Point& point1, const Point& point2);
Point operator*(double scalar, const Point& point2);
inline Point operator+(const Point& point1, const Point& point2) { return Point(point1.x + point2.x, point1.y + point2.y); }
inline Point operator-(const Point& point1, const Point& point2) { return Point(point1.x - point2.x, point1.y - point2.y); }
inline Point operator*(double scalar, const Point& point2) { return Point(scalar * point2.x, scalar * point2.y); }
class Point3 : public Point
{
@ -102,6 +102,10 @@ class Pointf
Vectorf vector_to(const Pointf &point) const;
};
inline Pointf operator+(const Pointf& point1, const Pointf& point2) { return Pointf(point1.x + point2.x, point1.y + point2.y); }
inline Pointf operator-(const Pointf& point1, const Pointf& point2) { return Pointf(point1.x - point2.x, point1.y - point2.y); }
inline Pointf operator*(double scalar, const Pointf& point2) { return Pointf(scalar * point2.x, scalar * point2.y); }
class Pointf3 : public Pointf
{
public:

View file

@ -233,7 +233,6 @@ Print::invalidate_state_by_config_options(const std::vector<t_config_option_key>
|| *opt_key == "travel_speed"
|| *opt_key == "use_firmware_retraction"
|| *opt_key == "use_relative_e_distances"
|| *opt_key == "vibration_limit"
|| *opt_key == "wipe"
|| *opt_key == "z_offset"
|| *opt_key == "max_volumetric_extrusion_rate_slope_negative"

View file

@ -371,6 +371,7 @@ PrintConfigDef::PrintConfigDef()
def->enum_keys_map = ConfigOptionEnum<InfillPattern>::get_enum_values();
def->enum_values.push_back("rectilinear");
def->enum_values.push_back("grid");
def->enum_values.push_back("triangles");
def->enum_values.push_back("line");
def->enum_values.push_back("concentric");
def->enum_values.push_back("honeycomb");
@ -380,6 +381,7 @@ PrintConfigDef::PrintConfigDef()
def->enum_values.push_back("octagramspiral");
def->enum_labels.push_back("Rectilinear");
def->enum_labels.push_back("Grid");
def->enum_labels.push_back("Triangles");
def->enum_labels.push_back("Line");
def->enum_labels.push_back("Concentric");
def->enum_labels.push_back("Honeycomb");
@ -1325,14 +1327,6 @@ PrintConfigDef::PrintConfigDef()
def->cli = "use-volumetric-e!";
def->default_value = new ConfigOptionBool(false);
def = this->add("vibration_limit", coFloat);
def->label = "Vibration limit (deprecated)";
def->tooltip = "This experimental option will slow down those moves hitting the configured frequency limit. The purpose of limiting vibrations is to avoid mechanical resonance. Set zero to disable.";
def->sidetext = "Hz";
def->cli = "vibration-limit=f";
def->min = 0;
def->default_value = new ConfigOptionFloat(0);
def = this->add("wipe", coBools);
def->label = "Wipe while retracting";
def->tooltip = "This flag will move the nozzle while retracting to minimize the possible blob on leaky extruders.";

View file

@ -30,7 +30,7 @@ enum GCodeFlavor {
};
enum InfillPattern {
ipRectilinear, ipGrid, ipLine, ipConcentric, ipHoneycomb, ip3DHoneycomb,
ipRectilinear, ipGrid, ipTriangles, ipLine, ipConcentric, ipHoneycomb, ip3DHoneycomb,
ipHilbertCurve, ipArchimedeanChords, ipOctagramSpiral,
};
@ -58,6 +58,7 @@ template<> inline t_config_enum_values ConfigOptionEnum<InfillPattern>::get_enum
t_config_enum_values keys_map;
keys_map["rectilinear"] = ipRectilinear;
keys_map["grid"] = ipGrid;
keys_map["triangles"] = ipTriangles;
keys_map["line"] = ipLine;
keys_map["concentric"] = ipConcentric;
keys_map["honeycomb"] = ipHoneycomb;
@ -413,7 +414,6 @@ class PrintConfig : public GCodeConfig
ConfigOptionInt standby_temperature_delta;
ConfigOptionInts temperature;
ConfigOptionInt threads;
ConfigOptionFloat vibration_limit;
ConfigOptionBools wipe;
ConfigOptionFloat z_offset;
@ -470,7 +470,6 @@ class PrintConfig : public GCodeConfig
OPT_PTR(standby_temperature_delta);
OPT_PTR(temperature);
OPT_PTR(threads);
OPT_PTR(vibration_limit);
OPT_PTR(wipe);
OPT_PTR(z_offset);

View file

@ -9,6 +9,7 @@
#include <stdint.h>
#include <stdarg.h>
#define SLIC3R_FORK_NAME "Slic3r Prusa Edition"
#define SLIC3R_VERSION "1.3.0-dev"
//FIXME This epsilon value is used for many non-related purposes:

View file

@ -22,4 +22,10 @@ DEBUG_OUT_PATH_PREFIX()
RETVAL = newSVpv(SLIC3R_DEBUG_OUT_PATH_PREFIX, 0);
OUTPUT: RETVAL
SV*
FORK_NAME()
CODE:
RETVAL = newSVpv(SLIC3R_FORK_NAME, 0);
OUTPUT: RETVAL
%}