mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-12 09:17:52 -06:00
Moved some math macros (sqr, lerp, clamp) to libslic3r.h
Added UNUSED macro to libslic3r.h, used it to reduce some compile warnings. Split the Int128 class from Clipper library to a separate file, extended Int128 with intrinsic types wherever possible for performance, added new geometric predicates. Added a draft of new FillRectilinear3, which should reduce overfill near the perimeters in the future.
This commit is contained in:
parent
3b51f64411
commit
a6ea01a23f
19 changed files with 2106 additions and 289 deletions
|
@ -9,11 +9,6 @@ struct Chaining
|
|||
size_t idx;
|
||||
};
|
||||
|
||||
#ifndef sqr
|
||||
template<typename T>
|
||||
inline T sqr(T x) { return x * x; }
|
||||
#endif /* sqr */
|
||||
|
||||
template<typename T>
|
||||
inline int nearest_point_index(const std::vector<Chaining> &pairs, const Point &start_near, bool no_reverse)
|
||||
{
|
||||
|
@ -49,11 +44,8 @@ inline int nearest_point_index(const std::vector<Chaining> &pairs, const Point &
|
|||
Polylines PolylineCollection::_chained_path_from(
|
||||
const Polylines &src,
|
||||
Point start_near,
|
||||
bool no_reverse
|
||||
#if SLIC3R_CPPVER >= 11
|
||||
, bool move_from_src
|
||||
#endif
|
||||
)
|
||||
bool no_reverse,
|
||||
bool move_from_src)
|
||||
{
|
||||
std::vector<Chaining> endpoints;
|
||||
endpoints.reserve(src.size());
|
||||
|
@ -70,15 +62,11 @@ Polylines PolylineCollection::_chained_path_from(
|
|||
// find nearest point
|
||||
int endpoint_index = nearest_point_index<double>(endpoints, start_near, no_reverse);
|
||||
assert(endpoint_index >= 0 && endpoint_index < endpoints.size() * 2);
|
||||
#if SLIC3R_CPPVER > 11
|
||||
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
|
||||
retval.push_back(src[endpoints[endpoint_index/2].idx]);
|
||||
#endif
|
||||
if (endpoint_index & 1)
|
||||
retval.back().reverse();
|
||||
endpoints.erase(endpoints.begin() + endpoint_index/2);
|
||||
|
@ -87,40 +75,6 @@ Polylines PolylineCollection::_chained_path_from(
|
|||
return retval;
|
||||
}
|
||||
|
||||
#if SLIC3R_CPPVER >= 11
|
||||
Polylines PolylineCollection::chained_path(Polylines &&src, bool no_reverse)
|
||||
{
|
||||
return (src.empty() || src.front().points.empty()) ?
|
||||
Polylines() :
|
||||
_chained_path_from(src, src.front().first_point(), no_reverse, true);
|
||||
}
|
||||
|
||||
Polylines PolylineCollection::chained_path_from(Polylines &&src, Point start_near, bool no_reverse)
|
||||
{
|
||||
return _chained_path_from(src, start_near, no_reverse, true);
|
||||
}
|
||||
#endif
|
||||
|
||||
Polylines PolylineCollection::chained_path(const Polylines &src, bool no_reverse)
|
||||
{
|
||||
return (src.empty() || src.front().points.empty()) ?
|
||||
Polylines() :
|
||||
_chained_path_from(src, src.front().first_point(), no_reverse
|
||||
#if SLIC3R_CPPVER >= 11
|
||||
, false
|
||||
#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)
|
||||
{
|
||||
if (polylines.empty()) CONFESS("leftmost_point() called on empty PolylineCollection");
|
||||
|
@ -134,10 +88,4 @@ Point PolylineCollection::leftmost_point(const Polylines &polylines)
|
|||
return p;
|
||||
}
|
||||
|
||||
void
|
||||
PolylineCollection::append(const Polylines &pp)
|
||||
{
|
||||
this->polylines.insert(this->polylines.end(), pp.begin(), pp.end());
|
||||
}
|
||||
|
||||
} // namespace Slic3r
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue