parent
9146ef2f61
commit
4be0e37963
3 changed files with 14 additions and 14 deletions
|
@ -77,7 +77,7 @@ inline void offset(PolygonImpl& sh, TCoord<PointImpl> distance, const PolygonTag
|
||||||
#define DISABLE_BOOST_OFFSET
|
#define DISABLE_BOOST_OFFSET
|
||||||
|
|
||||||
using ClipperLib::ClipperOffset;
|
using ClipperLib::ClipperOffset;
|
||||||
using ClipperLib::jtMiter;
|
using ClipperLib::jtSquare;
|
||||||
using ClipperLib::etClosedPolygon;
|
using ClipperLib::etClosedPolygon;
|
||||||
using ClipperLib::Paths;
|
using ClipperLib::Paths;
|
||||||
|
|
||||||
|
@ -85,8 +85,8 @@ inline void offset(PolygonImpl& sh, TCoord<PointImpl> distance, const PolygonTag
|
||||||
|
|
||||||
try {
|
try {
|
||||||
ClipperOffset offs;
|
ClipperOffset offs;
|
||||||
offs.AddPath(sh.Contour, jtMiter, etClosedPolygon);
|
offs.AddPath(sh.Contour, jtSquare, etClosedPolygon);
|
||||||
offs.AddPaths(sh.Holes, jtMiter, etClosedPolygon);
|
offs.AddPaths(sh.Holes, jtSquare, etClosedPolygon);
|
||||||
offs.Execute(result, static_cast<double>(distance));
|
offs.Execute(result, static_cast<double>(distance));
|
||||||
} catch (ClipperLib::clipperException &) {
|
} catch (ClipperLib::clipperException &) {
|
||||||
throw GeometryException(GeomErr::OFFSET);
|
throw GeometryException(GeomErr::OFFSET);
|
||||||
|
|
|
@ -528,15 +528,12 @@ public:
|
||||||
|
|
||||||
static inline double overfit(const Box& bb, const Box& bin)
|
static inline double overfit(const Box& bb, const Box& bin)
|
||||||
{
|
{
|
||||||
auto Bw = bin.width();
|
auto wdiff = TCompute<RawShape>(bb.width()) - bin.width();
|
||||||
auto Bh = bin.height();
|
auto hdiff = TCompute<RawShape>(bb.height()) - bin.height();
|
||||||
auto mBw = -Bw;
|
double diff = .0;
|
||||||
auto mBh = -Bh;
|
if(wdiff > 0) diff += double(wdiff);
|
||||||
auto wdiff = double(bb.width()) + mBw;
|
if(hdiff > 0) diff += double(hdiff);
|
||||||
auto hdiff = double(bb.height()) + mBh;
|
|
||||||
double diff = 0;
|
|
||||||
if(wdiff > 0) diff += wdiff;
|
|
||||||
if(hdiff > 0) diff += hdiff;
|
|
||||||
return diff;
|
return diff;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -396,11 +396,14 @@ template<> std::function<double(const Item&)> AutoArranger<Box>::get_objfn()
|
||||||
double score = std::get<0>(result);
|
double score = std::get<0>(result);
|
||||||
auto& fullbb = std::get<1>(result);
|
auto& fullbb = std::get<1>(result);
|
||||||
|
|
||||||
double miss = Placer::overfit(fullbb, m_bin);
|
auto bin = m_bin;
|
||||||
|
sl::offset(bin, -EPSILON * (m_bin.width() + m_bin.height()));
|
||||||
|
|
||||||
|
double miss = Placer::overfit(fullbb, bin);
|
||||||
miss = miss > 0? miss : 0;
|
miss = miss > 0? miss : 0;
|
||||||
score += miss*miss;
|
score += miss*miss;
|
||||||
|
|
||||||
return score;
|
return score;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue