pynest2d
pynest2d copied to clipboard
[Doubt] - Using BottomLeftConfig
Hi everyone
If I want to use BottomLeftPlacer I need to chance pynest2d.sip and rebuild the package or there's another way?
Can someone provide a brief code to explain how to use other placers?
Ok, i did it in a clumsy way. Because the methods have the same signature I changed the name a little. Trying to decide wich method is less worst. Use a input flag or repeating the mehod body just using correct template inputs.
long bl_nest(std::vector<Item*> items, Box bin, long dist=1, BottomLeftConfig config = BottomLeftConfig());
%MethodCode
if (a2<=0){
a2=1;
}
//Pre-process items.
std::vector<Item> to_arrange;
to_arrange.reserve(a0->size());
for(Item* item : *a0)
{
to_arrange.push_back(*item);
}
//Pre-process config.
NestConfig<BottomLeftPlacer, FirstFitSelection> nest_config(*a3);
//NestConfig wraps a placer and selector config. Only with the default selector there is no config, so just the placer then.
std::vector<Item> out_arrange;
out_arrange.reserve(a0->size());
for(Item* item : *a0)
{
out_arrange.push_back(*item);
}
sipRes = nest<BottomLeftPlacer, FirstFitSelection>(to_arrange, *a1, a2, nest_config);
for(size_t i = 0; i < a0->size(); ++i)
{
*(a0->at(i)) = to_arrange[i];
}
%End
see instructions here how to create a Conan package https://github.com/Ultimaker/pynest2d#creating-a-new-pynest2d-conan-package