This commit is contained in:
bubnikv 2019-09-27 18:23:36 +02:00
commit 85ea0396a4
5 changed files with 16 additions and 12 deletions

View File

@ -90,7 +90,7 @@ struct stl_neighbors {
struct stl_stats {
stl_stats() { memset(&header, 0, 81); }
char header[81] = "";
char header[81];
stl_type type = (stl_type)0;
uint32_t number_of_facets = 0;
stl_vertex max = stl_vertex::Zero();

View File

@ -100,7 +100,7 @@ add_library(libslic3r STATIC
Geometry.cpp
Geometry.hpp
Int128.hpp
KdTreeIndirect.hpp
KDTreeIndirect.hpp
Layer.cpp
Layer.hpp
LayerRegion.cpp

View File

@ -19,7 +19,10 @@ public:
static constexpr size_t NumDimensions = ANumDimensions;
using CoordinateFn = ACoordinateFn;
using CoordType = ACoordType;
static constexpr size_t npos = size_t(-1);
// Following could be static constexpr size_t, but that would not link in C++11
enum : size_t {
npos = size_t(-1)
};
KDTreeIndirect(CoordinateFn coordinate) : coordinate(coordinate) {}
KDTreeIndirect(CoordinateFn coordinate, std::vector<size_t> indices) : coordinate(coordinate) { this->build(std::move(indices)); }
@ -71,7 +74,7 @@ public:
template<typename Visitor>
void visit(Visitor &visitor) const
{
return m_nodes.empty() ? npos : visit_recursive(0, 0, visitor);
visit_recursive(0, 0, visitor);
}
CoordinateFn coordinate;

View File

@ -4,6 +4,7 @@
#undef assert
#endif
#include "clipper.hpp"
#include "ShortestPath.hpp"
#include "KDTreeIndirect.hpp"
#include "MutablePriorityQueue.hpp"
@ -72,7 +73,7 @@ std::vector<std::pair<size_t, bool>> chain_segments_greedy_constrained_reversals
{
// Just sort the end points so that the first point visited is closest to start_near.
out.emplace_back(0, start_near != nullptr &&
(end_point_func(0, true) - *start_near).cast<double>().squaredNorm() < (end_point_func(0, false) - *start_near).cast<double>().squaredNorm());
(end_point_func(0, true) - *start_near).template cast<double>().squaredNorm() < (end_point_func(0, false) - *start_near).template cast<double>().squaredNorm());
}
else
{
@ -93,8 +94,8 @@ std::vector<std::pair<size_t, bool>> chain_segments_greedy_constrained_reversals
std::vector<EndPoint> end_points;
end_points.reserve(num_segments * 2);
for (size_t i = 0; i < num_segments; ++ i) {
end_points.emplace_back(end_point_func(i, true ).cast<double>());
end_points.emplace_back(end_point_func(i, false).cast<double>());
end_points.emplace_back(end_point_func(i, true ).template cast<double>());
end_points.emplace_back(end_point_func(i, false).template cast<double>());
}
// Construct the closest point KD tree over end points of segments.
@ -163,7 +164,7 @@ std::vector<std::pair<size_t, bool>> chain_segments_greedy_constrained_reversals
EndPoint *first_point = nullptr;
size_t first_point_idx = std::numeric_limits<size_t>::max();
if (start_near != nullptr) {
size_t idx = find_closest_point(kdtree, start_near->cast<double>());
size_t idx = find_closest_point(kdtree, start_near->template cast<double>());
assert(idx < end_points.size());
first_point = &end_points[idx];
first_point->distance_out = 0.;
@ -405,7 +406,7 @@ std::vector<std::pair<size_t, bool>> chain_extrusion_entities(std::vector<Extrus
return out;
}
void reorder_extrusion_entities(std::vector<ExtrusionEntity*> &entities, std::vector<std::pair<size_t, bool>> &chain)
void reorder_extrusion_entities(std::vector<ExtrusionEntity*> &entities, const std::vector<std::pair<size_t, bool>> &chain)
{
assert(entities.size() == chain.size());
std::vector<ExtrusionEntity*> out;
@ -459,7 +460,7 @@ std::vector<size_t> chain_points(const Points &points, Point *start_near)
return out;
}
Polylines chain_polylines(Polylines &polylines, const Point *start_near)
Polylines chain_polylines(Polylines &&polylines, const Point *start_near)
{
auto segment_end_point = [&polylines](size_t idx, bool first_point) -> const Point& { return first_point ? polylines[idx].first_point() : polylines[idx].last_point(); };
std::vector<std::pair<size_t, bool>> ordered = chain_segments_greedy<Point, decltype(segment_end_point)>(segment_end_point, polylines.size(), start_near);

View File

@ -15,14 +15,14 @@ namespace Slic3r {
std::vector<size_t> chain_points(const Points &points, Point *start_near = nullptr);
std::vector<std::pair<size_t, bool>> chain_extrusion_entities(std::vector<ExtrusionEntity*> &entities, const Point *start_near = nullptr);
void reorder_extrusion_entities(std::vector<ExtrusionEntity*> &entities, std::vector<std::pair<size_t, bool>> &chain);
void reorder_extrusion_entities(std::vector<ExtrusionEntity*> &entities, const std::vector<std::pair<size_t, bool>> &chain);
void chain_and_reorder_extrusion_entities(std::vector<ExtrusionEntity*> &entities, const Point *start_near = nullptr);
std::vector<std::pair<size_t, bool>> chain_extrusion_paths(std::vector<ExtrusionPath> &extrusion_paths, const Point *start_near = nullptr);
void reorder_extrusion_paths(std::vector<ExtrusionPath> &extrusion_paths, std::vector<std::pair<size_t, bool>> &chain);
void chain_and_reorder_extrusion_paths(std::vector<ExtrusionPath> &extrusion_paths, const Point *start_near = nullptr);
Polylines chain_polylines(Polylines &src, const Point *start_near = nullptr);
Polylines chain_polylines(Polylines &&src, const Point *start_near = nullptr);
std::vector<ClipperLib::PolyNode*> chain_clipper_polynodes(const Points &points, const std::vector<ClipperLib::PolyNode*> &items);