mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-08-14 04:15:52 +08:00
Fix warnings:
../src/libslic3r/Emboss.cpp:858:13: warning: ‘Slic3r::EmbossStyle {anonymous}::create_style(const wstring&, const wstring&)’ defined but not used [-Wunused-function] ../src/libslic3r/Emboss.cpp:708:6: warning: ‘void {anonymous}::remove_small_islands(Slic3r::ExPolygons&, double)’ defined but not used [-Wunused-function] ../src/libslic3r/Emboss.cpp:497:6: warning: ‘void {anonymous}::visualize_heal(const string&, const ExPolygons&)’ defined but not used [-Wunused-function] ../src/libslic3r/Emboss.cpp:283:8: warning: ‘Slic3r::Points {anonymous}::collect_close_points(const ExPolygons&, double)’ defined but not used [-Wunused-function]
This commit is contained in:
parent
e2c35a213b
commit
226ab414d9
@ -43,6 +43,39 @@ using fontinfo_opt = std::optional<stbtt_fontinfo>;
|
|||||||
// Potentionaly useable for eliminate spike in layer
|
// Potentionaly useable for eliminate spike in layer
|
||||||
//#define REMOVE_SPIKES
|
//#define REMOVE_SPIKES
|
||||||
|
|
||||||
|
// function to remove useless islands and holes
|
||||||
|
// #define REMOVE_SMALL_ISLANDS
|
||||||
|
#ifdef REMOVE_SMALL_ISLANDS
|
||||||
|
namespace { void remove_small_islands(ExPolygons &shape, double minimal_area);}
|
||||||
|
#endif //REMOVE_SMALL_ISLANDS
|
||||||
|
|
||||||
|
//#define VISUALIZE_HEAL
|
||||||
|
#ifdef VISUALIZE_HEAL
|
||||||
|
namespace {
|
||||||
|
// for debug purpose only
|
||||||
|
// NOTE: check scale when store svg !!
|
||||||
|
#include "libslic3r/SVG.hpp" // for visualize_heal
|
||||||
|
static std::string visualize_heal_svg_filepath = "C:/data/temp/heal.svg";
|
||||||
|
void visualize_heal(const std::string &svg_filepath, const ExPolygons &expolygons)
|
||||||
|
{
|
||||||
|
Points pts = to_points(expolygons);
|
||||||
|
BoundingBox bb(pts);
|
||||||
|
// double svg_scale = SHAPE_SCALE / unscale<double>(1.);
|
||||||
|
// bb.scale(svg_scale);
|
||||||
|
SVG svg(svg_filepath, bb);
|
||||||
|
svg.draw(expolygons);
|
||||||
|
|
||||||
|
Points duplicits = collect_duplicates(pts);
|
||||||
|
int black_size = std::max(bb.size().x(), bb.size().y()) / 20;
|
||||||
|
svg.draw(duplicits, "black", black_size);
|
||||||
|
|
||||||
|
Slic3r::IntersectionsLines intersections_f = get_intersections(expolygons);
|
||||||
|
Points intersections = get_unique_intersections(intersections_f);
|
||||||
|
svg.draw(intersections, "red", black_size * 1.2);
|
||||||
|
}
|
||||||
|
} // namespace
|
||||||
|
#endif // VISUALIZE_HEAL
|
||||||
|
|
||||||
// do not expose out of this file stbtt_ data types
|
// do not expose out of this file stbtt_ data types
|
||||||
namespace{
|
namespace{
|
||||||
using Polygon = Slic3r::Polygon;
|
using Polygon = Slic3r::Polygon;
|
||||||
@ -54,8 +87,6 @@ std::optional<Glyph> get_glyph(const stbtt_fontinfo &font_info, int unicode_lett
|
|||||||
const Glyph* get_glyph(int unicode, const FontFile &font, const FontProp &font_prop,
|
const Glyph* get_glyph(int unicode, const FontFile &font, const FontProp &font_prop,
|
||||||
Glyphs &cache, fontinfo_opt &font_info_opt);
|
Glyphs &cache, fontinfo_opt &font_info_opt);
|
||||||
|
|
||||||
EmbossStyle create_style(const std::wstring &name, const std::wstring &path);
|
|
||||||
|
|
||||||
// scale and convert float to int coordinate
|
// scale and convert float to int coordinate
|
||||||
Point to_point(const stbtt__point &point);
|
Point to_point(const stbtt__point &point);
|
||||||
|
|
||||||
@ -66,17 +97,9 @@ void remove_bad(ExPolygons &expolygons);
|
|||||||
// Try to remove self intersection by subtracting rect 2x2 px
|
// Try to remove self intersection by subtracting rect 2x2 px
|
||||||
ExPolygon create_bounding_rect(const ExPolygons &shape);
|
ExPolygon create_bounding_rect(const ExPolygons &shape);
|
||||||
|
|
||||||
void remove_small_islands(ExPolygons &shape, double minimal_area);
|
|
||||||
|
|
||||||
// NOTE: expolygons can't contain same_neighbor
|
|
||||||
Points collect_close_points(const ExPolygons &expolygons, double distance = .6);
|
|
||||||
|
|
||||||
// Heal duplicates points and self intersections
|
// Heal duplicates points and self intersections
|
||||||
bool heal_dupl_inter(ExPolygons &shape, unsigned max_iteration);
|
bool heal_dupl_inter(ExPolygons &shape, unsigned max_iteration);
|
||||||
|
|
||||||
// for debug purpose
|
|
||||||
void visualize_heal(const std::string& svg_filepath, const ExPolygons &expolygons);
|
|
||||||
|
|
||||||
const Points pts_2x2({Point(0, 0), Point(1, 0), Point(1, 1), Point(0, 1)});
|
const Points pts_2x2({Point(0, 0), Point(1, 0), Point(1, 1), Point(0, 1)});
|
||||||
const Points pts_3x3({Point(-1, -1), Point(1, -1), Point(1, 1), Point(-1, 1)});
|
const Points pts_3x3({Point(-1, -1), Point(1, -1), Point(1, 1), Point(-1, 1)});
|
||||||
|
|
||||||
@ -279,56 +302,6 @@ void remove_bad(ExPolygons &expolygons) {
|
|||||||
for (ExPolygon &expolygon : expolygons)
|
for (ExPolygon &expolygon : expolygons)
|
||||||
remove_bad(expolygon.holes);
|
remove_bad(expolygon.holes);
|
||||||
}
|
}
|
||||||
|
|
||||||
Points collect_close_points(const ExPolygons &expolygons, double distance) {
|
|
||||||
if (expolygons.empty()) return {};
|
|
||||||
if (distance < 0.) return {};
|
|
||||||
|
|
||||||
// IMPROVE: use int(insted of double) lines and tree
|
|
||||||
const ExPolygonsIndices ids(expolygons);
|
|
||||||
const std::vector<Linef> lines = Slic3r::to_linesf(expolygons, ids.get_count());
|
|
||||||
AABBTreeIndirect::Tree<2, double> tree = AABBTreeLines::build_aabb_tree_over_indexed_lines(lines);
|
|
||||||
// Result close points
|
|
||||||
Points res;
|
|
||||||
size_t point_index = 0;
|
|
||||||
auto collect_close = [&res, &point_index, &lines, &tree, &distance, &ids, &expolygons](const Points &pts) {
|
|
||||||
for (const Point &p : pts) {
|
|
||||||
Vec2d p_d = p.cast<double>();
|
|
||||||
std::vector<size_t> close_lines = AABBTreeLines::all_lines_in_radius(lines, tree, p_d, distance);
|
|
||||||
for (size_t index : close_lines) {
|
|
||||||
// skip point neighbour lines indices
|
|
||||||
if (index == point_index) continue;
|
|
||||||
if (&p != &pts.front()) {
|
|
||||||
if (index == point_index - 1) continue;
|
|
||||||
} else if (index == (pts.size()-1)) continue;
|
|
||||||
|
|
||||||
// do not doubled side point of segment
|
|
||||||
const ExPolygonsIndex id = ids.cvt(index);
|
|
||||||
const ExPolygon &expoly = expolygons[id.expolygons_index];
|
|
||||||
const Polygon &poly = id.is_contour() ? expoly.contour : expoly.holes[id.hole_index()];
|
|
||||||
const Points &poly_pts = poly.points;
|
|
||||||
const Point &line_a = poly_pts[id.point_index];
|
|
||||||
const Point &line_b = (!ids.is_last_point(id)) ? poly_pts[id.point_index + 1] : poly_pts.front();
|
|
||||||
assert(line_a == lines[index].a.cast<int>());
|
|
||||||
assert(line_b == lines[index].b.cast<int>());
|
|
||||||
if (p == line_a || p == line_b) continue;
|
|
||||||
res.push_back(p);
|
|
||||||
}
|
|
||||||
++point_index;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
for (const ExPolygon &expoly : expolygons) {
|
|
||||||
collect_close(expoly.contour.points);
|
|
||||||
for (const Polygon &hole : expoly.holes)
|
|
||||||
collect_close(hole.points);
|
|
||||||
}
|
|
||||||
if (res.empty()) return {};
|
|
||||||
std::sort(res.begin(), res.end());
|
|
||||||
// only unique points
|
|
||||||
res.erase(std::unique(res.begin(), res.end()), res.end());
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
} // end namespace
|
} // end namespace
|
||||||
|
|
||||||
bool Emboss::divide_segments_for_close_point(ExPolygons &expolygons, double distance)
|
bool Emboss::divide_segments_for_close_point(ExPolygons &expolygons, double distance)
|
||||||
@ -471,7 +444,6 @@ bool Emboss::heal_expolygons(ExPolygons &shape, unsigned max_iteration)
|
|||||||
return ::heal_dupl_inter(shape, max_iteration);
|
return ::heal_dupl_inter(shape, max_iteration);
|
||||||
}
|
}
|
||||||
|
|
||||||
#include "libslic3r/SVG.hpp" // for visualize_heal
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
Points get_unique_intersections(const Slic3r::IntersectionsLines &intersections)
|
Points get_unique_intersections(const Slic3r::IntersectionsLines &intersections)
|
||||||
@ -494,24 +466,6 @@ Points get_unique_intersections(const Slic3r::IntersectionsLines &intersections)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void visualize_heal(const std::string &svg_filepath, const ExPolygons &expolygons)
|
|
||||||
{
|
|
||||||
Points pts = to_points(expolygons);
|
|
||||||
BoundingBox bb(pts);
|
|
||||||
// double svg_scale = SHAPE_SCALE / unscale<double>(1.);
|
|
||||||
// bb.scale(svg_scale);
|
|
||||||
SVG svg(svg_filepath, bb);
|
|
||||||
svg.draw(expolygons);
|
|
||||||
|
|
||||||
Points duplicits = collect_duplicates(pts);
|
|
||||||
int black_size = std::max(bb.size().x(), bb.size().y()) / 20;
|
|
||||||
svg.draw(duplicits, "black", black_size);
|
|
||||||
|
|
||||||
Slic3r::IntersectionsLines intersections_f = get_intersections(expolygons);
|
|
||||||
Points intersections = get_unique_intersections(intersections_f);
|
|
||||||
svg.draw(intersections, "red", black_size * 1.2);
|
|
||||||
}
|
|
||||||
|
|
||||||
Polygons get_holes_with_points(const Polygons &holes, const Points &points)
|
Polygons get_holes_with_points(const Polygons &holes, const Points &points)
|
||||||
{
|
{
|
||||||
Polygons result;
|
Polygons result;
|
||||||
@ -655,8 +609,11 @@ bool heal_dupl_inter(ExPolygons &shape, unsigned max_iteration)
|
|||||||
// healed in the last loop
|
// healed in the last loop
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// visualize_heal("C:/data/temp/heal.svg", shape);
|
#ifdef VISUALIZE_HEAL
|
||||||
|
visualize_heal(visualize_heal_svg_filepath, shape);
|
||||||
|
#endif // VISUALIZE_HEAL
|
||||||
|
|
||||||
assert(false); // Can not heal this shape
|
assert(false); // Can not heal this shape
|
||||||
// investigate how to heal better way
|
// investigate how to heal better way
|
||||||
|
|
||||||
@ -705,6 +662,7 @@ ExPolygon create_bounding_rect(const ExPolygons &shape) {
|
|||||||
return ExPolygon(rect, hole);
|
return ExPolygon(rect, hole);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef REMOVE_SMALL_ISLANDS
|
||||||
void remove_small_islands(ExPolygons &expolygons, double minimal_area) {
|
void remove_small_islands(ExPolygons &expolygons, double minimal_area) {
|
||||||
if (expolygons.empty())
|
if (expolygons.empty())
|
||||||
return;
|
return;
|
||||||
@ -722,6 +680,7 @@ void remove_small_islands(ExPolygons &expolygons, double minimal_area) {
|
|||||||
holes.erase(it, holes.end());
|
holes.erase(it, holes.end());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif // REMOVE_SMALL_ISLANDS
|
||||||
|
|
||||||
std::optional<Glyph> get_glyph(const stbtt_fontinfo &font_info, int unicode_letter, float flatness)
|
std::optional<Glyph> get_glyph(const stbtt_fontinfo &font_info, int unicode_letter, float flatness)
|
||||||
{
|
{
|
||||||
@ -855,12 +814,6 @@ const Glyph* get_glyph(
|
|||||||
return &it->second;
|
return &it->second;
|
||||||
}
|
}
|
||||||
|
|
||||||
EmbossStyle create_style(const std::wstring& name, const std::wstring& path) {
|
|
||||||
return { boost::nowide::narrow(name.c_str()),
|
|
||||||
boost::nowide::narrow(path.c_str()),
|
|
||||||
EmbossStyle::Type::file_path, FontProp() };
|
|
||||||
}
|
|
||||||
|
|
||||||
Point to_point(const stbtt__point &point) {
|
Point to_point(const stbtt__point &point) {
|
||||||
return Point(static_cast<int>(std::round(point.x / SHAPE_SCALE)),
|
return Point(static_cast<int>(std::round(point.x / SHAPE_SCALE)),
|
||||||
static_cast<int>(std::round(point.y / SHAPE_SCALE)));
|
static_cast<int>(std::round(point.y / SHAPE_SCALE)));
|
||||||
@ -874,6 +827,14 @@ Point to_point(const stbtt__point &point) {
|
|||||||
#include <windef.h>
|
#include <windef.h>
|
||||||
#include <WinUser.h>
|
#include <WinUser.h>
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
EmbossStyle create_style(const std::wstring& name, const std::wstring& path) {
|
||||||
|
return { boost::nowide::narrow(name.c_str()),
|
||||||
|
boost::nowide::narrow(path.c_str()),
|
||||||
|
EmbossStyle::Type::file_path, FontProp() };
|
||||||
|
}
|
||||||
|
} // namespace
|
||||||
|
|
||||||
// Get system font file path
|
// Get system font file path
|
||||||
std::optional<std::wstring> Emboss::get_font_path(const std::wstring &font_face_name)
|
std::optional<std::wstring> Emboss::get_font_path(const std::wstring &font_face_name)
|
||||||
{
|
{
|
||||||
|
@ -764,7 +764,7 @@ void draw_side_outline(const ExPolygons &shape, const std::array<unsigned char,
|
|||||||
|
|
||||||
// overlap color
|
// overlap color
|
||||||
auto draw = [&data, data_width, count_lines, get_offset, &color](int x, int y, float brightess) {
|
auto draw = [&data, data_width, count_lines, get_offset, &color](int x, int y, float brightess) {
|
||||||
if (x < 0 || y < 0 || x >= data_width || y >= count_lines)
|
if (x < 0 || y < 0 || static_cast<size_t>(x) >= data_width || y >= count_lines)
|
||||||
return; // out of image
|
return; // out of image
|
||||||
size_t offset = get_offset(x, y);
|
size_t offset = get_offset(x, y);
|
||||||
bool change_color = false;
|
bool change_color = false;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user