Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Doubt] - Using BottomLeftConfig #25

Open
tslima opened this issue Sep 29, 2022 · 2 comments
Open

[Doubt] - Using BottomLeftConfig #25

tslima opened this issue Sep 29, 2022 · 2 comments

Comments

@tslima
Copy link

tslima commented Sep 29, 2022

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
Copy link
Author

tslima commented Oct 17, 2022

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

@jellespijker
Copy link
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants