mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-08-12 20:19:09 +08:00
Fix: Linux Warnings
This commit is contained in:
parent
2362532675
commit
381c9d8fb4
@ -85,7 +85,7 @@ std::optional<Slic3r::Line> LineUtils::crop_half_ray(const Line & half_ray,
|
||||
const Point ¢er,
|
||||
double radius)
|
||||
{
|
||||
auto segment = crop_ray(half_ray, center, radius);
|
||||
std::optional<Line> segment = crop_ray(half_ray, center, radius);
|
||||
if (!segment.has_value()) return {};
|
||||
Point dir = half_ray.b - half_ray.a;
|
||||
using fnc = std::function<bool(const Point &)>;
|
||||
@ -108,7 +108,7 @@ std::optional<Slic3r::Linef> LineUtils::crop_half_ray(const Linef & half_ray,
|
||||
const Point ¢er,
|
||||
double radius)
|
||||
{
|
||||
auto segment = crop_ray(half_ray, center, radius);
|
||||
std::optional<Linef> segment = crop_ray(half_ray, center, radius);
|
||||
if (!segment.has_value()) return {};
|
||||
Vec2d dir = half_ray.b - half_ray.a;
|
||||
using fnc = std::function<bool(const Vec2d &)>;
|
||||
@ -131,7 +131,7 @@ std::optional<Slic3r::Line> LineUtils::crop_line(const Line & line,
|
||||
const Point ¢er,
|
||||
double radius)
|
||||
{
|
||||
auto segment = crop_ray(line, center, radius);
|
||||
std::optional<Line> segment = crop_ray(line, center, radius);
|
||||
if (!segment.has_value()) return {};
|
||||
|
||||
Point dir = line.b - line.a;
|
||||
@ -151,8 +151,8 @@ std::optional<Slic3r::Line> LineUtils::crop_line(const Line & line,
|
||||
if (!use_a && !use_b) return {};
|
||||
if (use_a && use_b) return segment;
|
||||
bool same_dir = (use_x) ?
|
||||
((dir.x() > 0) == (segment->b.x() - segment->a.x()) > 0) :
|
||||
((dir.y() > 0) == (segment->b.y() - segment->a.y()) > 0) ;
|
||||
((dir.x() > 0) == ((segment->b.x() - segment->a.x()) > 0)) :
|
||||
((dir.y() > 0) == ((segment->b.y() - segment->a.y()) > 0)) ;
|
||||
if (use_a) {
|
||||
if (same_dir)
|
||||
return Line(segment->a, line.b);
|
||||
@ -170,7 +170,7 @@ std::optional<Slic3r::Linef> LineUtils::crop_line(const Linef & line,
|
||||
const Point ¢er,
|
||||
double radius)
|
||||
{
|
||||
auto segment = crop_ray(line, center, radius);
|
||||
std::optional<Linef> segment = crop_ray(line, center, radius);
|
||||
if (!segment.has_value()) return {};
|
||||
|
||||
Vec2d dir = line.b - line.a;
|
||||
@ -190,9 +190,9 @@ std::optional<Slic3r::Linef> LineUtils::crop_line(const Linef & line,
|
||||
if (!use_a && !use_b) return {};
|
||||
if (use_a && use_b) return segment;
|
||||
bool same_dir = (use_x) ? ((dir.x() > 0) ==
|
||||
(segment->b.x() - segment->a.x()) > 0) :
|
||||
((segment->b.x() - segment->a.x()) > 0)) :
|
||||
((dir.y() > 0) ==
|
||||
(segment->b.y() - segment->a.y()) > 0);
|
||||
((segment->b.y() - segment->a.y()) > 0));
|
||||
if (use_a) {
|
||||
if (same_dir)
|
||||
return Linef(segment->a, line.b);
|
||||
@ -351,12 +351,10 @@ Slic3r::BoundingBox LineUtils::create_bounding_box(const Lines &lines) {
|
||||
|
||||
std::map<size_t, size_t> LineUtils::create_line_connection_over_b(const Lines &lines)
|
||||
{
|
||||
static const size_t bad_index = -1;
|
||||
std::map<size_t, size_t> line_connection;
|
||||
auto inserts = [&](size_t i1, size_t i2) -> bool {
|
||||
const Line &l1 = lines[i1];
|
||||
const Line &l2 = lines[i2];
|
||||
bool is_connected = PointUtils::is_equal(l1.b, l2.a);
|
||||
if (!PointUtils::is_equal(l1.b, l2.a))
|
||||
return false;
|
||||
assert(line_connection.find(i1) == line_connection.end());
|
||||
|
@ -1,5 +1,11 @@
|
||||
#include "ParabolaUtils.hpp"
|
||||
#include "PointUtils.hpp"
|
||||
|
||||
// sampling parabola
|
||||
#include <libslic3r/Geometry.hpp>
|
||||
#include <libslic3r/VoronoiOffset.hpp>
|
||||
#include <libslic3r/VoronoiVisualUtils.hpp>
|
||||
|
||||
using namespace Slic3r::sla;
|
||||
|
||||
double ParabolaUtils::length(const ParabolaSegment ¶bola)
|
||||
@ -24,10 +30,6 @@ double ParabolaUtils::length(const ParabolaSegment ¶bola)
|
||||
(length_x1 + length_x2) : // interval is over zero
|
||||
fabs(length_x1 - length_x2); // interval is on same side of parabola
|
||||
}
|
||||
|
||||
#include <Libslic3r/Geometry.hpp>
|
||||
#include <Libslic3r/VoronoiOffset.hpp>
|
||||
#include <Libslic3r/VoronoiVisualUtils.hpp>
|
||||
double ParabolaUtils::length_by_sampling(
|
||||
const ParabolaSegment ¶bola,
|
||||
double discretization_step)
|
||||
|
@ -16,7 +16,7 @@ Slic3r::Polygon PolygonUtils::create_regular(size_t count_points,
|
||||
Points points;
|
||||
points.reserve(count_points);
|
||||
double increase_angle = 2 * M_PI / count_points;
|
||||
for (int i = 0; i < count_points; ++i) {
|
||||
for (size_t i = 0; i < count_points; ++i) {
|
||||
double angle = i * increase_angle;
|
||||
double x = cos(angle) * radius + center.x();
|
||||
assert(is_in_limits(x));
|
||||
|
@ -228,7 +228,7 @@ SupportIslandPoints SampleIslandUtils::sample_side_branch(
|
||||
result.push_back(
|
||||
create_point_on_path(reverse_path, side_distance, cfg.sample_config,
|
||||
SupportIslandPoint::Type::center_line_end));
|
||||
return std::move(result);
|
||||
return result;
|
||||
}
|
||||
// count of segment between points on main path
|
||||
size_t segment_count = static_cast<size_t>(
|
||||
@ -272,7 +272,7 @@ SupportIslandPoints SampleIslandUtils::sample_side_branch(
|
||||
//}
|
||||
//assert(fabs(distance - (sample_distance - cfg.side_distance)) < 1e-5);
|
||||
result.back()->type = SupportIslandPoint::Type::center_line_end;
|
||||
return std::move(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
SupportIslandPoints SampleIslandUtils::sample_side_branches(
|
||||
@ -299,7 +299,7 @@ SupportIslandPoints SampleIslandUtils::sample_side_branches(
|
||||
std::move_iterator(samples.end()));
|
||||
side_branches_cpy.pop();
|
||||
}
|
||||
return std::move(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
std::vector<std::set<const VoronoiGraph::Node *>> create_circles_sets(
|
||||
@ -434,7 +434,7 @@ SupportIslandPoints SampleIslandUtils::sample_center_line(
|
||||
if (path.circles.empty()) return result;
|
||||
sample_center_circles(path, cfg, result);
|
||||
|
||||
return std::move(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
void SampleIslandUtils::sample_center_circle_end(
|
||||
@ -782,7 +782,7 @@ SupportIslandPoints SampleIslandUtils::sample_expath(
|
||||
SupportIslandPoints result;
|
||||
result.push_back(create_middle_path_point(
|
||||
path, SupportIslandPoint::Type::one_center_point));
|
||||
return std::move(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
double max_width = VoronoiGraphUtils::get_max_width(path);
|
||||
@ -797,7 +797,7 @@ SupportIslandPoints SampleIslandUtils::sample_expath(
|
||||
centerLineConfiguration(path.side_branches, config);
|
||||
SupportIslandPoints samples = sample_center_line(path, centerLineConfiguration);
|
||||
samples.front()->type = SupportIslandPoint::Type::center_line_end2;
|
||||
return std::move(samples);
|
||||
return samples;
|
||||
}
|
||||
|
||||
// TODO: 3) Triangle of points
|
||||
|
@ -73,9 +73,9 @@ public:
|
||||
order_iterator order_end,
|
||||
value_iterator v)
|
||||
{
|
||||
typedef typename std::iterator_traits<value_iterator>::value_type value_t;
|
||||
typedef typename std::iterator_traits<order_iterator>::value_type index_t;
|
||||
typedef typename std::iterator_traits<order_iterator>::difference_type diff_t;
|
||||
using value_t = std::iterator_traits<value_iterator>::value_type;
|
||||
using index_t = std::iterator_traits<order_iterator>::value_type;
|
||||
using diff_t = std::iterator_traits<order_iterator>::difference_type;
|
||||
|
||||
diff_t remaining = order_end - 1 - order_begin;
|
||||
for (index_t s = index_t(), d; remaining > 0; ++s) {
|
||||
@ -104,21 +104,26 @@ public:
|
||||
order_iterator order_end,
|
||||
value_iterator v)
|
||||
{
|
||||
typedef typename std::iterator_traits<value_iterator>::value_type value_t;
|
||||
typedef typename std::iterator_traits<order_iterator>::value_type index_t;
|
||||
typedef typename std::iterator_traits<order_iterator>::difference_type diff_t;
|
||||
|
||||
using value_t = std::iterator_traits<value_iterator>::value_type;
|
||||
using index_t = std::iterator_traits<order_iterator>::value_type;
|
||||
using diff_t = std::iterator_traits<order_iterator>::difference_type;
|
||||
static const index_t done_index = static_cast<index_t>(-1);
|
||||
diff_t remaining = order_end - 1 - order_begin;
|
||||
// s = start sequence index
|
||||
for (index_t s = index_t(); remaining > 0; ++s) {
|
||||
// d = index1 for swap
|
||||
index_t d = order_begin[s];
|
||||
if (d == (diff_t) -1) continue;
|
||||
if (d == done_index) continue;
|
||||
--remaining;
|
||||
if (s == d) continue; // correct order
|
||||
value_t temp = v[s];
|
||||
for (index_t d2; d != s; d = d2) {
|
||||
do {
|
||||
std::swap(temp, v[d]);
|
||||
std::swap(order_begin[d], d2 = (diff_t) -1);
|
||||
index_t d2 = done_index;
|
||||
std::swap(order_begin[d], d2);
|
||||
d = d2;
|
||||
--remaining;
|
||||
}
|
||||
} while (d != s);
|
||||
v[s] = temp;
|
||||
}
|
||||
}
|
||||
|
@ -278,7 +278,7 @@ VoronoiGraph::Node *VoronoiGraphUtils::getNode(VoronoiGraph & graph,
|
||||
const Lines & lines)
|
||||
{
|
||||
std::map<const VD::vertex_type *, VoronoiGraph::Node> &data = graph.data;
|
||||
auto &mapItem = data.find(vertex);
|
||||
auto mapItem = data.find(vertex);
|
||||
// return when exists
|
||||
if (mapItem != data.end()) return &mapItem->second;
|
||||
|
||||
@ -291,9 +291,7 @@ VoronoiGraph::Node *VoronoiGraphUtils::getNode(VoronoiGraph & graph,
|
||||
Point point = to_point(vertex);
|
||||
double distance = line.distance_to(point);
|
||||
|
||||
auto &[iterator,
|
||||
success] = data.emplace(vertex,
|
||||
VoronoiGraph::Node(vertex, distance));
|
||||
auto [iterator, success] = data.emplace(vertex, VoronoiGraph::Node(vertex, distance));
|
||||
assert(success);
|
||||
return &iterator->second;
|
||||
}
|
||||
@ -502,9 +500,7 @@ VoronoiGraph VoronoiGraphUtils::create_skeleton(const VD &vd, const Lines &lines
|
||||
// assert(Voronoi::debug::verify_inside_outside_annotations(vd));
|
||||
|
||||
VoronoiGraph skeleton;
|
||||
const VD::edge_type *first_edge = &vd.edges().front();
|
||||
for (const VD::edge_type &edge : vd.edges()) {
|
||||
size_t edge_idx = &edge - first_edge;
|
||||
if (
|
||||
// Ignore secondary and unbounded edges, they shall never be part
|
||||
// of the skeleton.
|
||||
@ -964,18 +960,14 @@ std::pair<Slic3r::Point, Slic3r::Point> VoronoiGraphUtils::point_on_lines(
|
||||
|
||||
// TODO: solve point on parabola
|
||||
//assert(edge->is_linear());
|
||||
bool is_linear = edge->is_linear();
|
||||
|
||||
Point edge_point = create_edge_point(position);
|
||||
|
||||
auto point_on_line = [&](const VD::edge_type *edge) -> Point {
|
||||
assert(edge->is_finite());
|
||||
const VD::cell_type *cell = edge->cell();
|
||||
size_t line_index = cell->source_index();
|
||||
const Line &line = lines[line_index];
|
||||
using namespace boost::polygon;
|
||||
bool is_single_point = cell->source_category() ==
|
||||
SOURCE_CATEGORY_SINGLE_POINT;
|
||||
if (cell->source_category() == SOURCE_CATEGORY_SEGMENT_START_POINT) {
|
||||
return line.a;
|
||||
}
|
||||
|
@ -2326,17 +2326,17 @@ TEST_CASE("bad vertex cause overflow of data type precisin when use VD result",
|
||||
Vec2d vertex(vrtx->x(), vrtx->y());
|
||||
|
||||
double point_distance = (p1 - p2).norm();
|
||||
double half_point_distance = point_distance/2;
|
||||
[[maybe_unused]] double half_point_distance = point_distance / 2;
|
||||
|
||||
Linef line_from_middle(middle, middle + direction); // line between source points
|
||||
double distance_vertex = perp_distance(line_from_middle, vertex);
|
||||
double distance_p1 = perp_distance(line_from_middle, p1);
|
||||
double distance_p2 = perp_distance(line_from_middle, p2);
|
||||
[[maybe_unused]] double distance_p1 = perp_distance(line_from_middle, p1);
|
||||
[[maybe_unused]] double distance_p2 = perp_distance(line_from_middle, p2);
|
||||
|
||||
Linef line_from_vertex(vertex, vertex + direction);
|
||||
double distance_middle = perp_distance(line_from_vertex, middle);
|
||||
double distance_p1_ = perp_distance(line_from_vertex, p1);
|
||||
double distance_p2_ = perp_distance(line_from_vertex, p2);
|
||||
[[maybe_unused]] double distance_middle = perp_distance(line_from_vertex, middle);
|
||||
[[maybe_unused]] double distance_p1_ = perp_distance(line_from_vertex, p1);
|
||||
[[maybe_unused]] double distance_p2_ = perp_distance(line_from_vertex, p2);
|
||||
|
||||
double maximal_distance = 9e6;
|
||||
Vec2d vertex_direction = (vertex - middle);
|
||||
@ -2350,8 +2350,8 @@ TEST_CASE("bad vertex cause overflow of data type precisin when use VD result",
|
||||
Linef line_short(start_point, start_point + direction);
|
||||
double distance_short_vertex = perp_distance(line_short, vertex);
|
||||
double distance_short_middle = perp_distance(line_short, middle);
|
||||
double distance_p1_short = perp_distance(line_short, p1);
|
||||
double distance_p2_short = perp_distance(line_short, p2);
|
||||
[[maybe_unused]] double distance_p1_short = perp_distance(line_short, p1);
|
||||
[[maybe_unused]] double distance_p2_short = perp_distance(line_short, p2);
|
||||
|
||||
CHECK(distance_vertex < 10);
|
||||
//CHECK(distance_middle < 10); // This is bad
|
||||
|
@ -564,13 +564,14 @@ TEST_CASE("Small islands should be supported in center", "[SupGen], [VoronoiSkel
|
||||
ExPolygons islands = createTestIslands(size);
|
||||
|
||||
// TODO: remove next 4 lines, debug sharp triangle
|
||||
auto triangle = PolygonUtils::create_isosceles_triangle(8. * size, 40. * size);
|
||||
/*auto triangle = PolygonUtils::create_isosceles_triangle(8. * size, 40. * size);
|
||||
islands = {ExPolygon(triangle)};
|
||||
//auto test_island = create_tiny_wide_test_2(3 * size, 2 / 3. * size);
|
||||
//islands = {test_island};
|
||||
auto test_island = create_tiny_wide_test_2(3 * size, 2 / 3. * size);
|
||||
islands = {test_island};*/
|
||||
|
||||
for (ExPolygon &island : islands) {
|
||||
size_t debug_index = &island - &islands.front();
|
||||
// information for debug which island cause problem
|
||||
[[maybe_unused]] size_t debug_index = &island - &islands.front();
|
||||
auto points = test_island_sampling(island, cfg);
|
||||
double angle = 3.14 / 3; // cca 60 degree
|
||||
|
||||
@ -666,15 +667,13 @@ TEST_CASE("Compare sampling test", "[hide]")
|
||||
(sample_type == Sampling::old) ? sample_old :
|
||||
(sample_type == Sampling::filip) ? sample_filip :
|
||||
nullptr;
|
||||
|
||||
double size1 = 1e6;
|
||||
double size2 = 3e6;
|
||||
ExPolygons islands = createTestIslands(1e6);
|
||||
ExPolygons islands_big = createTestIslands(3e6);
|
||||
islands.insert(islands.end(), islands_big.begin(), islands_big.end());
|
||||
|
||||
for (ExPolygon &island : islands) {
|
||||
size_t debug_index = &island - &islands.front();
|
||||
// information for debug which island cause problem
|
||||
[[maybe_unused]] size_t debug_index = &island - &islands.front();
|
||||
auto samples = sample(island);
|
||||
#ifdef STORE_SAMPLE_INTO_SVG_FILES
|
||||
store_sample(samples, island);
|
||||
@ -689,6 +688,17 @@ TEST_CASE("Compare sampling test", "[hide]")
|
||||
}
|
||||
}
|
||||
|
||||
#include <libslic3r/SLA/SupportIslands/VectorUtils.hpp>
|
||||
TEST_CASE("Reorder destructive", "[hide]"){
|
||||
std::vector<int> data {0, 1, 3, 2, 4, 7, 6, 5, 8};
|
||||
std::vector<int> order{0, 1, 3, 2, 4, 7, 6, 5, 8};
|
||||
|
||||
VectorUtils::reorder_destructive(order.begin(), order.end(), data.begin());
|
||||
for (size_t i = 0; i < data.size() - 1;++i) {
|
||||
CHECK(data[i] < data[i + 1]);
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("Disable visualization", "[hide]")
|
||||
{
|
||||
CHECK(true);
|
||||
|
Loading…
x
Reference in New Issue
Block a user