diff --git a/xs/src/libnest2d/cmake_modules/DownloadNLopt.cmake b/xs/src/libnest2d/cmake_modules/DownloadNLopt.cmake
index 814213b38..0f5392596 100644
--- a/xs/src/libnest2d/cmake_modules/DownloadNLopt.cmake
+++ b/xs/src/libnest2d/cmake_modules/DownloadNLopt.cmake
@@ -27,5 +27,6 @@ set(NLOPT_LINK_PYTHON OFF CACHE BOOL "" FORCE)
add_subdirectory(${nlopt_SOURCE_DIR} ${nlopt_BINARY_DIR})
set(NLopt_LIBS nlopt)
-set(NLopt_INCLUDE_DIR ${nlopt_BINARY_DIR})
+set(NLopt_INCLUDE_DIR ${nlopt_BINARY_DIR}
+ ${nlopt_BINARY_DIR}/src/api)
set(SHARED_LIBS_STATE ${SHARED_STATE})
\ No newline at end of file
diff --git a/xs/src/libslic3r/ModelArrange.hpp b/xs/src/libslic3r/ModelArrange.hpp
index 5f1717f71..baf31af4e 100644
--- a/xs/src/libslic3r/ModelArrange.hpp
+++ b/xs/src/libslic3r/ModelArrange.hpp
@@ -95,9 +95,9 @@ void toSVG(SVG& svg, const Model& model) {
std::tuple
objfunc(const PointImpl& bincenter,
- double bin_area,
+ double /*bin_area*/,
ShapeLike::Shapes& pile, // The currently arranged pile
- double pile_area,
+ double /*pile_area*/,
const Item &item,
double norm, // A norming factor for physical dimensions
std::vector& areacache
@@ -114,11 +114,14 @@ objfunc(const PointImpl& bincenter,
NfpPlacer::Pile bigs;
bigs.reserve(pile.size());
- int idx = 0;
if(pile.size() < areacache.size()) areacache.clear();
+
+ auto normarea = [norm](double area) { return std::sqrt(area)/norm; };
+
+ int idx = 0;
for(auto& p : pile) {
if(idx == areacache.size()) areacache.emplace_back(sl::area(p));
- if(std::sqrt(areacache[idx])/norm > BIG_ITEM_TRESHOLD)
+ if( normarea(areacache[idx]) > BIG_ITEM_TRESHOLD)
bigs.emplace_back(p);
idx++;
}
@@ -137,12 +140,13 @@ objfunc(const PointImpl& bincenter,
// The size indicator of the candidate item. This is not the area,
// but almost...
- auto itemnormarea = std::sqrt(ibb.width()*ibb.height())/norm;
// Will hold the resulting score
double score = 0;
- if(itemnormarea > BIG_ITEM_TRESHOLD) {
+ double item_normarea = normarea(item.area());
+
+ if(item_normarea > BIG_ITEM_TRESHOLD) {
// This branch is for the bigger items..
// Here we will use the closest point of the item bounding box to
// the already arranged pile. So not the bb center nor the a choosen
@@ -182,7 +186,7 @@ objfunc(const PointImpl& bincenter,
for(auto& p : pile) {
auto parea = areacache[idx];
- if(std::sqrt(parea)/norm > BIG_ITEM_TRESHOLD) {
+ if(normarea(areacache[idx]) > BIG_ITEM_TRESHOLD) {
auto chull = sl::convexHull(sl::Shapes{p, trsh});
auto carea = sl::area(chull);
@@ -197,7 +201,7 @@ objfunc(const PointImpl& bincenter,
auto C = 0.33;
score = C * dist + C * density + C * alignment_score;
- } else if(itemnormarea < BIG_ITEM_TRESHOLD && bigs.empty()) {
+ } else if( item_normarea < BIG_ITEM_TRESHOLD && bigs.empty()) {
// If there are no big items, only small, we should consider the
// density here as well to not get silly results
auto bindist = pl::distance(ibb.center(), bincenter) / norm;
@@ -230,7 +234,7 @@ void fillConfig(PConf& pcfg) {
// The accuracy of optimization.
// Goes from 0.0 to 1.0 and scales performance as well
- pcfg.accuracy = 0.4f;
+ pcfg.accuracy = 1.0f;
}
template