Partial arrange starts to work again.
This commit is contained in:
parent
914bf63228
commit
87c5e9bbaa
4 changed files with 123 additions and 278 deletions
|
@ -875,6 +875,28 @@ inline _Box<TPoint<S>> boundingBox(const S& sh)
|
|||
return boundingBox(sh, Tag<S>() );
|
||||
}
|
||||
|
||||
template<class P> _Box<P> boundingBox(const _Box<P>& bb1, const _Box<P>& bb2 )
|
||||
{
|
||||
auto& pminc = bb1.minCorner();
|
||||
auto& pmaxc = bb1.maxCorner();
|
||||
auto& iminc = bb2.minCorner();
|
||||
auto& imaxc = bb2.maxCorner();
|
||||
P minc, maxc;
|
||||
|
||||
setX(minc, std::min(getX(pminc), getX(iminc)));
|
||||
setY(minc, std::min(getY(pminc), getY(iminc)));
|
||||
|
||||
setX(maxc, std::max(getX(pmaxc), getX(imaxc)));
|
||||
setY(maxc, std::max(getY(pmaxc), getY(imaxc)));
|
||||
return _Box<P>(minc, maxc);
|
||||
}
|
||||
|
||||
template<class S1, class S2>
|
||||
_Box<TPoint<S1>> boundingBox(const S1 &s1, const S2 &s2)
|
||||
{
|
||||
return boundingBox(boundingBox(s1), boundingBox(s2));
|
||||
}
|
||||
|
||||
template<class Box>
|
||||
inline double area(const Box& box, const BoxTag& )
|
||||
{
|
||||
|
@ -1060,8 +1082,8 @@ template<class TB, class TC>
|
|||
inline bool isInside(const TB& box, const TC& circ,
|
||||
const BoxTag&, const CircleTag&)
|
||||
{
|
||||
return isInside(box.minCorner(), circ, BoxTag(), CircleTag()) &&
|
||||
isInside(box.maxCorner(), circ, BoxTag(), CircleTag());
|
||||
return isInside(box.minCorner(), circ, PointTag(), CircleTag()) &&
|
||||
isInside(box.maxCorner(), circ, PointTag(), CircleTag());
|
||||
}
|
||||
|
||||
template<class TBGuest, class TBHost>
|
||||
|
|
|
@ -895,7 +895,10 @@ private:
|
|||
template<class TIter> inline void __execute(TIter from, TIter to)
|
||||
{
|
||||
if(min_obj_distance_ > 0) std::for_each(from, to, [this](Item& item) {
|
||||
item.addOffset(static_cast<Coord>(std::ceil(min_obj_distance_/2.0)));
|
||||
auto offs = min_obj_distance_;
|
||||
if (item.isFixed()) offs *= 0.99;
|
||||
|
||||
item.addOffset(static_cast<Coord>(std::ceil(offs/2.0)));
|
||||
});
|
||||
|
||||
selector_.template packItems<PlacementStrategy>(
|
||||
|
|
|
@ -801,7 +801,6 @@ private:
|
|||
// optimize
|
||||
config_.object_function = prev_func;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
struct Optimum {
|
||||
|
@ -816,29 +815,14 @@ private:
|
|||
|
||||
class Optimizer: public opt::TOptimizer<opt::Method::L_SUBPLEX> {
|
||||
public:
|
||||
Optimizer() {
|
||||
Optimizer(float accuracy = 1.f) {
|
||||
opt::StopCriteria stopcr;
|
||||
stopcr.max_iterations = 200;
|
||||
stopcr.max_iterations = unsigned(std::floor(1000 * accuracy));
|
||||
stopcr.relative_score_difference = 1e-20;
|
||||
this->stopcr_ = stopcr;
|
||||
}
|
||||
};
|
||||
|
||||
static Box boundingBox(const Box& pilebb, const Box& ibb ) {
|
||||
auto& pminc = pilebb.minCorner();
|
||||
auto& pmaxc = pilebb.maxCorner();
|
||||
auto& iminc = ibb.minCorner();
|
||||
auto& imaxc = ibb.maxCorner();
|
||||
Vertex minc, maxc;
|
||||
|
||||
setX(minc, std::min(getX(pminc), getX(iminc)));
|
||||
setY(minc, std::min(getY(pminc), getY(iminc)));
|
||||
|
||||
setX(maxc, std::max(getX(pmaxc), getX(imaxc)));
|
||||
setY(maxc, std::max(getY(pmaxc), getY(imaxc)));
|
||||
return Box(minc, maxc);
|
||||
}
|
||||
|
||||
using Edges = EdgeCache<RawShape>;
|
||||
|
||||
template<class Range = ConstItemRange<typename Base::DefaultIter>>
|
||||
|
@ -935,7 +919,7 @@ private:
|
|||
_objfunc = [norm, binbb, pbb, ins_check](const Item& item)
|
||||
{
|
||||
auto ibb = item.boundingBox();
|
||||
auto fullbb = boundingBox(pbb, ibb);
|
||||
auto fullbb = sl::boundingBox(pbb, ibb);
|
||||
|
||||
double score = pl::distance(ibb.center(),
|
||||
binbb.center());
|
||||
|
@ -1005,14 +989,15 @@ private:
|
|||
|
||||
auto& rofn = rawobjfunc;
|
||||
auto& nfpoint = getNfpPoint;
|
||||
float accuracy = config_.accuracy;
|
||||
|
||||
__parallel::enumerate(
|
||||
cache.corners().begin(),
|
||||
cache.corners().end(),
|
||||
[&results, &item, &rofn, &nfpoint, ch]
|
||||
[&results, &item, &rofn, &nfpoint, ch, accuracy]
|
||||
(double pos, size_t n)
|
||||
{
|
||||
Optimizer solver;
|
||||
Optimizer solver(accuracy);
|
||||
|
||||
Item itemcpy = item;
|
||||
auto contour_ofn = [&rofn, &nfpoint, ch, &itemcpy]
|
||||
|
@ -1059,10 +1044,10 @@ private:
|
|||
__parallel::enumerate(cache.corners(hidx).begin(),
|
||||
cache.corners(hidx).end(),
|
||||
[&results, &item, &nfpoint,
|
||||
&rofn, ch, hidx]
|
||||
&rofn, ch, hidx, accuracy]
|
||||
(double pos, size_t n)
|
||||
{
|
||||
Optimizer solver;
|
||||
Optimizer solver(accuracy);
|
||||
|
||||
Item itmcpy = item;
|
||||
auto hole_ofn =
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue