pynest2d icon indicating copy to clipboard operation
pynest2d copied to clipboard

[Doubt] - Using BottomLeftConfig

Open tslima opened this issue 2 years ago • 2 comments

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?

tslima avatar Sep 29 '22 12:09 tslima

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

tslima avatar Oct 17 '22 14:10 tslima

see instructions here how to create a Conan package https://github.com/Ultimaker/pynest2d#creating-a-new-pynest2d-conan-package

jellespijker avatar Oct 17 '22 19:10 jellespijker