mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-07-13 03:21:49 +08:00
Fixing some compiler warnings
This commit is contained in:
parent
8a297be74e
commit
dd79a2b832
@ -201,21 +201,11 @@ using namespace boost::polygon; // provides also high() and low()
|
|||||||
|
|
||||||
namespace Slic3r { namespace Geometry {
|
namespace Slic3r { namespace Geometry {
|
||||||
|
|
||||||
static bool sort_points(const Point& a, const Point& b)
|
|
||||||
{
|
|
||||||
return (a(0) < b(0)) || (a(0) == b(0) && a(1) < b(1));
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool sort_pointfs(const Vec3d& a, const Vec3d& b)
|
|
||||||
{
|
|
||||||
return (a(0) < b(0)) || (a(0) == b(0) && a(1) < b(1));
|
|
||||||
}
|
|
||||||
|
|
||||||
// This implementation is based on Andrew's monotone chain 2D convex hull algorithm
|
// This implementation is based on Andrew's monotone chain 2D convex hull algorithm
|
||||||
Polygon convex_hull(Points pts)
|
Polygon convex_hull(Points pts)
|
||||||
{
|
{
|
||||||
std::sort(pts.begin(), pts.end(), [](const Point& a, const Point& b) { return a(0) < b(0) || (a(0) == b(0) && a(1) < b(1)); });
|
std::sort(pts.begin(), pts.end(), [](const Point& a, const Point& b) { return a.x() < b.x() || (a.x() == b.x() && a.y() < b.y()); });
|
||||||
pts.erase(std::unique(pts.begin(), pts.end(), [](const Point& a, const Point& b) { return a(0) == b(0) && a(1) == b(1); }), pts.end());
|
pts.erase(std::unique(pts.begin(), pts.end(), [](const Point& a, const Point& b) { return a.x() == b.x() && a.y() == b.y(); }), pts.end());
|
||||||
|
|
||||||
Polygon hull;
|
Polygon hull;
|
||||||
int n = (int)pts.size();
|
int n = (int)pts.size();
|
||||||
@ -245,7 +235,7 @@ Pointf3s convex_hull(Pointf3s points)
|
|||||||
{
|
{
|
||||||
assert(points.size() >= 3);
|
assert(points.size() >= 3);
|
||||||
// sort input points
|
// sort input points
|
||||||
std::sort(points.begin(), points.end(), sort_pointfs);
|
std::sort(points.begin(), points.end(), [](const Vec3d &a, const Vec3d &b){ return a.x() < b.x() || (a.x() == b.x() && a.y() < b.y()); });
|
||||||
|
|
||||||
int n = points.size(), k = 0;
|
int n = points.size(), k = 0;
|
||||||
Pointf3s hull;
|
Pointf3s hull;
|
||||||
|
@ -301,12 +301,10 @@ static std::vector<std::vector<ExPolygons>> slices_to_regions(
|
|||||||
}
|
}
|
||||||
tbb::parallel_for(
|
tbb::parallel_for(
|
||||||
tbb::blocked_range<size_t>(0, zs_complex.size()),
|
tbb::blocked_range<size_t>(0, zs_complex.size()),
|
||||||
[&slices_by_region, &model_volumes, &print_object_regions, &zs_complex, &layer_ranges_regions_to_slices, clip_multipart_objects, &throw_on_cancel_callback]
|
[&slices_by_region, &print_object_regions, &zs_complex, &layer_ranges_regions_to_slices, clip_multipart_objects, &throw_on_cancel_callback]
|
||||||
(const tbb::blocked_range<size_t> &range) {
|
(const tbb::blocked_range<size_t> &range) {
|
||||||
const auto &z_idx_and_z = zs_complex[range.begin()];
|
float z = zs_complex[range.begin()].second;
|
||||||
size_t z_idx = z_idx_and_z.first;
|
auto it_layer_range = lower_bound_by_predicate(print_object_regions.layer_ranges.begin(), print_object_regions.layer_ranges.end(),
|
||||||
float z = z_idx_and_z.second;
|
|
||||||
auto it_layer_range = lower_bound_by_predicate(print_object_regions.layer_ranges.begin(), print_object_regions.layer_ranges.end(),
|
|
||||||
[z](const PrintObjectRegions::LayerRangeRegions &lr){ return lr.layer_height_range.second < z; });
|
[z](const PrintObjectRegions::LayerRangeRegions &lr){ return lr.layer_height_range.second < z; });
|
||||||
assert(it_layer_range != print_object_regions.layer_ranges.end() && it_layer_range->layer_height_range.first >= z && z <= it_layer_range->layer_height_range.second);
|
assert(it_layer_range != print_object_regions.layer_ranges.end() && it_layer_range->layer_height_range.first >= z && z <= it_layer_range->layer_height_range.second);
|
||||||
if (z == it_layer_range->layer_height_range.second)
|
if (z == it_layer_range->layer_height_range.second)
|
||||||
@ -350,7 +348,7 @@ static std::vector<std::vector<ExPolygons>> slices_to_regions(
|
|||||||
const PrintObjectRegions::VolumeRegion ®ion = layer_range.volume_regions[idx_region];
|
const PrintObjectRegions::VolumeRegion ®ion = layer_range.volume_regions[idx_region];
|
||||||
if (region.model_volume->is_modifier()) {
|
if (region.model_volume->is_modifier()) {
|
||||||
assert(region.parent > -1);
|
assert(region.parent > -1);
|
||||||
bool next_region_same_modifier = idx_region + 1 < temp_slices.size() && layer_range.volume_regions[idx_region + 1].model_volume == region.model_volume;
|
bool next_region_same_modifier = idx_region + 1 < int(temp_slices.size()) && layer_range.volume_regions[idx_region + 1].model_volume == region.model_volume;
|
||||||
if (next_region_same_modifier)
|
if (next_region_same_modifier)
|
||||||
temp_slices[idx_region + 1] = std::move(temp_slices[idx_region]);
|
temp_slices[idx_region + 1] = std::move(temp_slices[idx_region]);
|
||||||
RegionSlice &parent_slice = temp_slices[region.parent];
|
RegionSlice &parent_slice = temp_slices[region.parent];
|
||||||
@ -377,20 +375,20 @@ static std::vector<std::vector<ExPolygons>> slices_to_regions(
|
|||||||
// Remove the empty slices.
|
// Remove the empty slices.
|
||||||
temp_slices.erase(std::find_if(temp_slices.begin(), temp_slices.end(), [](const auto &slice) { return slice.empty(); }), temp_slices.end());
|
temp_slices.erase(std::find_if(temp_slices.begin(), temp_slices.end(), [](const auto &slice) { return slice.empty(); }), temp_slices.end());
|
||||||
// Merge slices and store them to the output.
|
// Merge slices and store them to the output.
|
||||||
for (int i = 0; i < temp_slices.size();) {
|
for (int i = 0; i < int(temp_slices.size());) {
|
||||||
// Find a range of temp_slices with the same region_id.
|
// Find a range of temp_slices with the same region_id.
|
||||||
int j = i;
|
int j = i;
|
||||||
bool merged = false;
|
bool merged = false;
|
||||||
ExPolygons &expolygons = temp_slices[i].expolygons;
|
ExPolygons &expolygons = temp_slices[i].expolygons;
|
||||||
for (++ j;
|
for (++ j;
|
||||||
j < temp_slices.size() &&
|
j < int(temp_slices.size()) &&
|
||||||
temp_slices[i].region_id == temp_slices[j].region_id &&
|
temp_slices[i].region_id == temp_slices[j].region_id &&
|
||||||
(clip_multipart_objects || temp_slices[i].volume_id == temp_slices[j].volume_id);
|
(clip_multipart_objects || temp_slices[i].volume_id == temp_slices[j].volume_id);
|
||||||
++ j)
|
++ j)
|
||||||
if (ExPolygons &expolygons2 = temp_slices[j].expolygons; ! expolygons2.empty())
|
if (ExPolygons &expolygons2 = temp_slices[j].expolygons; ! expolygons2.empty())
|
||||||
if (expolygons.empty())
|
if (expolygons.empty()) {
|
||||||
expolygons = std::move(expolygons2);
|
expolygons = std::move(expolygons2);
|
||||||
else {
|
} else {
|
||||||
append(expolygons, std::move(expolygons2));
|
append(expolygons, std::move(expolygons2));
|
||||||
merged = true;
|
merged = true;
|
||||||
}
|
}
|
||||||
@ -399,6 +397,7 @@ static std::vector<std::vector<ExPolygons>> slices_to_regions(
|
|||||||
slices_by_region[temp_slices[i].region_id][z_idx] = std::move(expolygons);
|
slices_by_region[temp_slices[i].region_id][z_idx] = std::move(expolygons);
|
||||||
i = j;
|
i = j;
|
||||||
}
|
}
|
||||||
|
throw_on_cancel_callback();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -547,8 +546,7 @@ void PrintObject::slice()
|
|||||||
void PrintObject::slice_volumes()
|
void PrintObject::slice_volumes()
|
||||||
{
|
{
|
||||||
BOOST_LOG_TRIVIAL(info) << "Slicing volumes..." << log_memory_info();
|
BOOST_LOG_TRIVIAL(info) << "Slicing volumes..." << log_memory_info();
|
||||||
const Print* print = this->print();
|
const Print *print = this->print();
|
||||||
const bool spiral_vase = print->config().spiral_vase;
|
|
||||||
const auto throw_on_cancel_callback = std::function<void()>([print](){ print->throw_if_canceled(); });
|
const auto throw_on_cancel_callback = std::function<void()>([print](){ print->throw_if_canceled(); });
|
||||||
|
|
||||||
// Clear old LayerRegions, allocate for new PrintRegions.
|
// Clear old LayerRegions, allocate for new PrintRegions.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user