GithubHelp home page GithubHelp logo

polyscope-py's People

Contributors

abhimadan avatar alecjacobson avatar marndorfer avatar nmwsharp avatar tmcarey avatar weshoke avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

polyscope-py's Issues

Selection Not Working With Meshes on OSX

After pip-installing the latest and running this code, the selection UI doesn't show up when clicking on the mesh. Everything works fine with the C++ library when I build that from source.

import polyscope as pscope

pscope.set_program_name("Demo")
pscope.init()

# create mesh

ps_mesh = pscope.register_surface_mesh("ps-mesh", mesh.vertices, mesh.faces)
if mesh.normals is not None:
    ps_mesh.add_vector_quantity("normals", mesh.normals, enabled=False)

if mesh.uvs is not None:
    ps_mesh.add_parameterization_quantity("uv", mesh.uvs, checker_size=3e-4, viz_style="checker", enabled=True)

if mesh.face_ids is not None:
    ps_mesh.add_scalar_quantity("face_ids", mesh.face_ids, defined_on="faces", enabled=True)

pscope.show()

mouse callbacks, picking and 3D pos of projected mouse click on mesh

First of all thank you @nmwsharp so much for this super beautiful visualization library cpp+python!
I wanted to ask how a few things which I fail to find the documentation for and I think might be implemented already -

  • How do I attach a callback to a mouse event?
  • How do I get the projection of my click on the mesh (3D coordinates)?
  • How do I get the picking info - like the face index? closest vertex?

I'm currently trying to assign vector constraints on specific faces through UI and these will be very helpful:)

Thank you so much again!

use add_color_quantity to texture on uv not working

Hi @nmwsharp !

Thanks for this amazing package!

    ps.init()
    fn = 'data/our_faces/face_lod0_with_uv.obj'

    mesh : Trimesh = trimesh.load(fn, process=False)
    verts = mesh.vertices
    faces = mesh.faces
    uv = mesh.visual.uv
    print("verts shape:", verts.shape, ',uv shape:', uv.shape)
    ps_mesh = ps.register_surface_mesh("my_mesh", verts, faces, color=(0.8, 0.8, 0.8), edge_width=0.8)

    ps_mesh.add_parameterization_quantity("my_uv", uv, defined_on='vertices', enabled=True)

    dims = (200, 200, 3)
    color_vals = np.random.randint(0, 255, size=dims)  # dummy placeholder image data
    color_vals = color_vals / 255.
    ps_mesh.add_color_quantity("my_img", color_vals,
                                defined_on='texture', param_name="my_uv",
                                enabled=True)

    ps.add_color_image_quantity("color_img", color_vals, enabled=True,
                                show_fullscreen=False, show_in_camera_billboard=False, transparency=0.5)

    ps.show()

the texture not working, the noise texture is expected on the surface of mesh, but it does NOT.
image

then I checked the uv by enable the my_uv(vertex parameterization), it looks ok. so the problem is not on UV.
image

Thanks.

some bugs in the volume mesh display

There may be some errors in the volume mesh display. The same mesh data I showed by pyvista was fine. The surface mesh function in polyscope-py is also fine.
image

Add all combination of view setter/getters

This is a common request from folks using Polyscope for research figures.

Make sure we have all combinations of get/set view matrix and get/set projection matrix & the respective params.

Maybe give better controls over window size too?

Also expose the get/set JSON string.

Also also make these nice and visible in the docs!

get/set all structure parameters as JSON string

I'm using PolyScope through its Python bindings in pygraphite. It would be interesting to be able to save PolyScope rendering parameters in the .graphite files that serialize the whole scene graph (they have a generic attribute mechanism to do that). Would it be possible to add a function to serialize / deserialize all structure parameters in a string in JSON format ?

Modifier Keys and full keymap from Dear ImGui

Hi @nmwsharp !

Thanks for this amazing package! I'm currently designing a tool that is using Polyscope and makes heavy use of keyboard controls. For that, it would be invaluable to have access to modifier keys as well as the full set of keys from the keyboard. However, currently in the Polyscope Python interface only a few keys are mapped (see

m.attr("ImGuiKey_Tab") = static_cast<int>(ImGuiKey_Tab);
and following) and the modifier keys, even though exposed in the map, can not be checked (GetMergedModFlags from ImGui is not exposed, neither is the io module to read io.KeyMods, if I'm not mistaken).

Is there currently a way to read modifier keys in Polyscope in Python that I'm missing? Would it be possible to expose access to the io module or another access function? Could we extend the list of mapped keys to cover the entire keyboard instead of the current selection?

Thanks a lot in advance!
Christoph

Getting polyscope parent window size/dimensions for callback

I'm creating custom UI elements since the default callback seems to only support a single additional window and also has a hardcoded name of "Command UI". In the C++ source, I noticed the windows are being docked by continually updating the current window heights of the parent window and adjusting the positions accordingly.

I'm trying to do this in the Python implementation with the imgui bindings, but the functions GetWindowHeight() and GetWindowWidth() seem to return completely static values when I call them within my callback, and do not change if I move/resize the parent window or the actual callback GUI element. It's unclear what it's doing. I'm seeing the same trouble with GetWindowContentRegionMax() and GetContentRegionMax().

Not sure if this is a ImGui specific question but it seems related to PolyScope. For that matter, it would be nice if the main polyscope instance could return the window sizing params for this purpose if the above bindings don't actually have the parent window context. Otherwise, I'm not sure how to get GUI elements to dock to different sides of the window, etc. It would also be nice if we could rename the default callback GUI, as well as enable/disable the Structure, Picker, and Polyscope GUI elements from Python like that can be done in C++. Additionally, further customization of those default elements would be highly appreciated since without it, users who want to customize the UI will have to turn off the boilerplate and re-write it which defeats the purpose in my opinion.

conda install not working (on my m1 mac)

conda install -c conda-forge polyscope

produces


Collecting package metadata (current_repodata.json): done
Solving environment: failed with initial frozen solve. Retrying with flexible solve.
Collecting package metadata (repodata.json): done
Solving environment: failed with initial frozen solve. Retrying with flexible solve.

PackagesNotFoundError: The following packages are not available from current channels:

  - polyscope

Current channels:

  - https://conda.anaconda.org/conda-forge/osx-arm64
  - https://conda.anaconda.org/conda-forge/noarch
  - https://repo.anaconda.com/pkgs/main/osx-arm64
  - https://repo.anaconda.com/pkgs/main/noarch
  - https://repo.anaconda.com/pkgs/r/osx-arm64
  - https://repo.anaconda.com/pkgs/r/noarch

To search for alternate channels that may provide the conda package you're
looking for, navigate to

    https://anaconda.org

and use the search bar at the top of the page.

I'm curious if it's related to being on an m1 mac.

FWIW, cloning this repo and building local worked fine.

Function to show/hide gizmo

It would be interesting to have a function to show/hide the gizmo associated with a structure programatically, from a Python script (did not find it but maybe I looked in the wrong place)

Add still-alive checks for structures

Right now the following code results in segfault:

import polyscope as ps
import numpy as np
ps.init()
cloud = ps.register_point_cloud("my cloud", np.random.rand(100,3))
ps.remove_point_cloud("my cloud")
cloud.add_scalar_quantity("my scalar", np.random.rand(100)) # boom!

(the same applies for all structures/quantities)

The solution is that add_scalar_quantity() should first check if the underlying point cloud still exists, and if not throw an informative Python error. There are a couple possible ways to implement this; we could check by name, or just set some flag in the python point cloud handle object.

default `name=` in `register_surface_mesh` ?

When using polyscope for a quick visualization I don't always have or care about a meaningful "name" for my mesh. Could there be a default?

If I understand correctly calling register_surface_mesh twice with the same name will overwrite the first call's data. So I guess there's a question whether a default would be default1, default2, etc. or just keep overwriting default. I kind of like overwriting default because avoiding that clearly gives the non-default name a sense of purpose.

Can't put two drop down menues in the same row

Hey there,

I seem to have difficulties putting 2 dropdown menues in the same row:

`import numpy as np
import pymeshlab
import polyscope as ps
import polyscope.imgui as psim

class PolyscopeGUI:

def __init__(self):


    self.ui_options = ["Laplacian smoothing operation", "option B", "option C"]
    self.ui_options_selected = self.ui_options[1]


    self.reconstruction_options = ["Screened Poisson Reconstruction", "APSS Marching cubes"]
    self.reconstruction_options_selected = self.reconstruction_options[0]

    ps.init()
    #ps.register_point_cloud('my point cloud', points)
    ps.set_user_callback(self.__callback)
    ps.show()


def __callback(self):
    '''This function is responsible for defining the actual GUI'''

    psim.PushItemWidth(250)
    smoothing_options = psim.BeginCombo("", self.ui_options_selected)
    if smoothing_options:
        for val in self.ui_options:
            _, selected = psim.Selectable(val, self.ui_options_selected==val)
            if selected:
                self.ui_options_selected = val
        psim.EndCombo()
    psim.PopItemWidth()




    psim.SameLine()
    psim.PushItemWidth(150)
    reconstruction_options = psim.BeginCombo("", self.reconstruction_options_selected)
    if reconstruction_options:
        for val in self.reconstruction_options:
            _, selected = psim.Selectable(val, self.reconstruction_options_selected==val)
            if selected:
                self.reconstruction_options_selected = val
        psim.EndCombo()
    psim.PopItemWidth()

def callback():
pass

def main():
poly = PolyscopeGUI()

if name == 'main':
main() `

I have no idea how to include the last few lines of code into the code block. But what happens is that the right drop down menu does not work at all unfortunately. Any Idea what could be wrong?

Adding ImGui For Custom Bindings

Here's my WIP on adding ImGui https://github.com/subscale/polyscope-py/blob/add-gui-features/src/cpp/imgui.cpp

I took the following approach:

  • use lower case snake_case for Python method names, so ImGui::TreeNodeEx becomes tree_node_ex
  • No "Python" wrapper for the PyBind11 bindings. Just use the PyBind11 bindings directly. In general, I wonder if the "pass thru" python functions shouldn't just be accessed directly
  • ImGui API argument types are mapped to Python types via PyBind11 such that native Python types can be used like arrays and tuples. I took this approach to avoid having to wrap things in Python so that native Python types would work.

float v[2] -> std::array<float, 2>

 m.def(
        "drag_float2",
        [](const char* label,
           const std::array<float, 2>& v,
           float v_speed,
           float v_min,
           float v_max,
           const char* format,
           float power) {
            auto v_ = v;
            auto clicked =
                ImGui::DragFloat2(label, v_.data(), v_speed, v_min, v_max, format, power);
            return std::make_tuple(clicked, v_);
        },
        py::arg("label"),
        py::arg("v"),
        py::arg("v_speed") = 1.0f,
        py::arg("v_min") = 0.0f,
        py::arg("v_max") = 0.0f,
        py::arg("format") = "%.3f",
        py::arg("power") = 1.0f);

ImVecN types are translated into std::tuple

Vec2T from_vec2(const ImVec2& v) { return std::make_tuple(v.x, v.y); }
Vec4T from_vec4(const ImVec4& v) { return std::make_tuple(v.x, v.y, v.z, v.w); }
m.def(
        "progress_bar",
        [](float fraction, const Vec2T& size_arg) {
            ImGui::ProgressBar(fraction, to_vec2(size_arg));
        },
        py::arg("fraction"),
        py::arg("size_arg") = std::make_tuple(-1.f, 0.f));

m.def("get_cursor_pos", []() { return from_vec2(ImGui::GetCursorPos()); });
  • Enums are modeled in an odd way, I need to fix it to use py::enum_

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.