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
|
||||
|
||||
using ClipperLib::ClipperOffset;
|
||||
using ClipperLib::jtMiter;
|
||||
using ClipperLib::jtSquare;
|
||||
using ClipperLib::etClosedPolygon;
|
||||
using ClipperLib::Paths;
|
||||
|
||||
|
@ -85,8 +85,8 @@ inline void offset(PolygonImpl& sh, TCoord<PointImpl> distance, const PolygonTag
|
|||
|
||||
try {
|
||||
ClipperOffset offs;
|
||||
offs.AddPath(sh.Contour, jtMiter, etClosedPolygon);
|
||||
offs.AddPaths(sh.Holes, jtMiter, etClosedPolygon);
|
||||
offs.AddPath(sh.Contour, jtSquare, etClosedPolygon);
|
||||
offs.AddPaths(sh.Holes, jtSquare, etClosedPolygon);
|
||||
offs.Execute(result, static_cast<double>(distance));
|
||||
} catch (ClipperLib::clipperException &) {
|
||||
throw GeometryException(GeomErr::OFFSET);
|
||||
|
|
|
@ -528,15 +528,12 @@ public:
|
|||
|
||||
static inline double overfit(const Box& bb, const Box& bin)
|
||||
{
|
||||
auto Bw = bin.width();
|
||||
auto Bh = bin.height();
|
||||
auto mBw = -Bw;
|
||||
auto mBh = -Bh;
|
||||
auto wdiff = double(bb.width()) + mBw;
|
||||
auto hdiff = double(bb.height()) + mBh;
|
||||
double diff = 0;
|
||||
if(wdiff > 0) diff += wdiff;
|
||||
if(hdiff > 0) diff += hdiff;
|
||||
auto wdiff = TCompute<RawShape>(bb.width()) - bin.width();
|
||||
auto hdiff = TCompute<RawShape>(bb.height()) - bin.height();
|
||||
double diff = .0;
|
||||
if(wdiff > 0) diff += double(wdiff);
|
||||
if(hdiff > 0) diff += double(hdiff);
|
||||
|
||||
return diff;
|
||||
}
|
||||
|
||||
|
|
|
@ -396,7 +396,10 @@ template<> std::function<double(const Item&)> AutoArranger<Box>::get_objfn()
|
|||
double score = std::get<0>(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;
|
||||
score += miss*miss;
|
||||
|
||||
|
|
Loading…
Reference in a new issue