Code Monkey home page Code Monkey logo

Comments (5)

mlivesu avatar mlivesu commented on May 27, 2024

Hi, CinoLib is meant to provide basic ingredients to build research oriented software prototypes. To this end, the functionalities you mention are not strictly contained in the library, but all the ingredients are available, so that you can implement them with a few lines of code. As a representative example, I am attaching at the bottom of this message a simple implementation of the mouse_click callback which would allow you to show/hide a selected element from a volumetric mesh such as the one shown in the picture above with CTRL+click and SHIFT+click. To try it out you can literally copy/paste such code in the library examples, and play it.

A few extra notes on this tool:

  • the {vert/edge/face/poly}_pick facilities are implemented in the most trivial possible way, so they run in O(n) with n being the number of elements. This is usually OK for user interaction and medium sized meshes. Should you need more speed, you can always use a cinolib::Octree and the ray intersection query, obtaining more accurate item selections at a much faster speed.

  • the selection of all the elements inside a box drawn in the canvas could be easily generated starting from my example. In that case you should implement the mouse_press/mouse_release callbacks for the generation of the wanted rectangular selection. The rest is not significantly different from the code I am sharing with you

Good luck!

gui.callback_mouse_press = [&](GLcanvas *c, QMouseEvent *e)
{
    if(e->modifiers() == Qt::ControlModifier)
    {
        vec3d p;
        vec2i click(e->x(), e->y());
        if (c->unproject(click, p))
        {
            uint pid = m.pick_poly(p);
            m.poly_data(pid).visible = false;
            m.updateGL();
            c->updateGL();
        }
    }
    else if(e->modifiers() == Qt::ShiftModifier)
    {
        vec3d p;
        vec2i click(e->x(), e->y());
        if(c->unproject(click, p))
        {
            uint fid = m.pick_face(p);
            for(uint pid : m.adj_f2p(fid)) m.poly_data(pid).visible = true;
            m.updateGL();
            c->updateGL();
        }
    }
};

from cinolib.

461353349 avatar 461353349 commented on May 27, 2024

I see!
Thank you very much!!!

from cinolib.

yvanblanchard avatar yvanblanchard commented on May 27, 2024

Hello @mlivesu

could you please give an up-to-date sampel code for doing this without Qt (but GLFW instead) ?
I tried this, but the 'visible' attribute is no longer available:

image

from cinolib.

yvanblanchard avatar yvanblanchard commented on May 27, 2024

I found this:
m.poly_data(pid).flags[HIDDEN] = false;
and it seems to work.

But I am now wondering how the CTRL key is supposed to work: it seems to set tets as visible when selecting a tet witH CTRL key, but I don't know how it could work..

from cinolib.

mlivesu avatar mlivesu commented on May 27, 2024

Hi, sorry for the late reply but I was on vacation :)

As you noticed some things have changed since my reply to this issue back in 2019. In the current version of cinolib manual selection facilities to show/hide elements have been incorporated in the VolumeMeshControls. More specifically, if you run the tetmesh viewer example and press the TAB key to show the side bar, you will notice that there is a menu item called Manual Digging. If you expand this, you can select an action between dig, undig, isolate. All these options are controlled with SHIFT + mouse click on a mesh element and serve to: hide an element (dig), show an element (undig) or to hide all the elements that are incident to a selected element (isolate).

I hope this will help you out!
Marco

from cinolib.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.