mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-05-15 15:58:08 +08:00
Copy and move variants of chained_path functions
This commit is contained in:
parent
381c88ce0c
commit
60ea0561ec
@ -46,14 +46,14 @@ inline int nearest_point_index(const std::vector<Chaining> &pairs, const Point &
|
|||||||
return idx;
|
return idx;
|
||||||
}
|
}
|
||||||
|
|
||||||
Polylines PolylineCollection::chained_path_from(
|
Polylines PolylineCollection::_chained_path_from(
|
||||||
#if SLIC3R_CPPVER >= 11
|
|
||||||
Polylines &&src,
|
|
||||||
#else
|
|
||||||
const Polylines &src,
|
const Polylines &src,
|
||||||
#endif
|
|
||||||
Point start_near,
|
Point start_near,
|
||||||
bool no_reverse)
|
bool no_reverse
|
||||||
|
#if SLIC3R_CPPVER >= 11
|
||||||
|
, bool move_from_src
|
||||||
|
#endif
|
||||||
|
)
|
||||||
{
|
{
|
||||||
std::vector<Chaining> endpoints;
|
std::vector<Chaining> endpoints;
|
||||||
endpoints.reserve(src.size());
|
endpoints.reserve(src.size());
|
||||||
@ -70,8 +70,12 @@ Polylines PolylineCollection::chained_path_from(
|
|||||||
// find nearest point
|
// find nearest point
|
||||||
int endpoint_index = nearest_point_index<double>(endpoints, start_near, no_reverse);
|
int endpoint_index = nearest_point_index<double>(endpoints, start_near, no_reverse);
|
||||||
assert(endpoint_index >= 0 && endpoint_index < endpoints.size() * 2);
|
assert(endpoint_index >= 0 && endpoint_index < endpoints.size() * 2);
|
||||||
#if SLIC3R_CPPVER >= 11
|
#if SLIC3R_CPPVER > 11
|
||||||
retval.push_back(std::move(src[endpoints[endpoint_index/2].idx]));
|
if (move_from_src) {
|
||||||
|
retval.push_back(std::move(src[endpoints[endpoint_index/2].idx]));
|
||||||
|
} else {
|
||||||
|
retval.push_back(src[endpoints[endpoint_index/2].idx]);
|
||||||
|
}
|
||||||
#else
|
#else
|
||||||
retval.push_back(src[endpoints[endpoint_index/2].idx]);
|
retval.push_back(src[endpoints[endpoint_index/2].idx]);
|
||||||
#endif
|
#endif
|
||||||
@ -86,28 +90,36 @@ Polylines PolylineCollection::chained_path_from(
|
|||||||
#if SLIC3R_CPPVER >= 11
|
#if SLIC3R_CPPVER >= 11
|
||||||
Polylines PolylineCollection::chained_path(Polylines &&src, bool no_reverse)
|
Polylines PolylineCollection::chained_path(Polylines &&src, bool no_reverse)
|
||||||
{
|
{
|
||||||
return (src.empty() || src.front().empty()) ?
|
return (src.empty() || src.front().points.empty()) ?
|
||||||
Polylines() :
|
Polylines() :
|
||||||
chained_path_from(std::move(src), src.front().first_point(), no_reverse);
|
_chained_path_from(src, src.front().first_point(), no_reverse, true);
|
||||||
}
|
}
|
||||||
Polylines PolylineCollection::chained_path_from(Polylines src, Point start_near, bool no_reverse)
|
|
||||||
|
Polylines PolylineCollection::chained_path_from(Polylines &&src, Point start_near, bool no_reverse)
|
||||||
{
|
{
|
||||||
return chained_path_from(std::move(src), start_near, no_reverse);
|
return _chained_path_from(src, start_near, no_reverse, true);
|
||||||
}
|
}
|
||||||
Polylines PolylineCollection::chained_path(Polylines src, bool no_reverse)
|
#endif
|
||||||
{
|
|
||||||
return (src.empty() || src.front().empty()) ?
|
|
||||||
Polylines() :
|
|
||||||
chained_path_from(std::move(src), src.front().first_point(), no_reverse);
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
Polylines PolylineCollection::chained_path(const Polylines &src, bool no_reverse)
|
Polylines PolylineCollection::chained_path(const Polylines &src, bool no_reverse)
|
||||||
{
|
{
|
||||||
return (src.empty() || src.front().points.empty()) ?
|
return (src.empty() || src.front().points.empty()) ?
|
||||||
Polylines() :
|
Polylines() :
|
||||||
chained_path_from(src, src.front().first_point(), no_reverse);
|
_chained_path_from(src, src.front().first_point(), no_reverse
|
||||||
}
|
#if SLIC3R_CPPVER >= 11
|
||||||
|
, false
|
||||||
#endif
|
#endif
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Polylines PolylineCollection::chained_path_from(const Polylines &src, Point start_near, bool no_reverse)
|
||||||
|
{
|
||||||
|
return _chained_path_from(src, start_near, no_reverse
|
||||||
|
#if SLIC3R_CPPVER >= 11
|
||||||
|
, false
|
||||||
|
#endif
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
Point PolylineCollection::leftmost_point(const Polylines &polylines)
|
Point PolylineCollection::leftmost_point(const Polylines &polylines)
|
||||||
{
|
{
|
||||||
|
@ -8,6 +8,15 @@ namespace Slic3r {
|
|||||||
|
|
||||||
class PolylineCollection
|
class PolylineCollection
|
||||||
{
|
{
|
||||||
|
static Polylines _chained_path_from(
|
||||||
|
const Polylines &src,
|
||||||
|
Point start_near,
|
||||||
|
bool no_reverse
|
||||||
|
#if SLIC3R_CPPVER >= 11
|
||||||
|
, bool move_from_src
|
||||||
|
#endif
|
||||||
|
);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Polylines polylines;
|
Polylines polylines;
|
||||||
void chained_path(PolylineCollection* retval, bool no_reverse = false) const
|
void chained_path(PolylineCollection* retval, bool no_reverse = false) const
|
||||||
@ -22,12 +31,9 @@ public:
|
|||||||
#if SLIC3R_CPPVER >= 11
|
#if SLIC3R_CPPVER >= 11
|
||||||
static Polylines chained_path(Polylines &&src, bool no_reverse = false);
|
static Polylines chained_path(Polylines &&src, bool no_reverse = false);
|
||||||
static Polylines chained_path_from(Polylines &&src, Point start_near, bool no_reverse = false);
|
static Polylines chained_path_from(Polylines &&src, Point start_near, bool no_reverse = false);
|
||||||
static Polylines chained_path(Polylines src, bool no_reverse = false);
|
|
||||||
static Polylines chained_path_from(Polylines src, Point start_near, bool no_reverse = false);
|
|
||||||
#else
|
|
||||||
static Polylines chained_path(const Polylines &src, bool no_reverse = false);
|
|
||||||
static Polylines chained_path_from(const Polylines &src, Point start_near, bool no_reverse = false);
|
|
||||||
#endif
|
#endif
|
||||||
|
static Polylines chained_path(const Polylines &src, bool no_reverse = false);
|
||||||
|
static Polylines chained_path_from(const Polylines &src, Point start_near, bool no_reverse = false);
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user