Polyscope is a C++/Python viewer and user interface for 3D data such as meshes and point clouds

Related tags

Graphics polyscope
Overview

Polyscope's documentation is hosted at polyscope.run

To contribute, check out the instructions here.

Polyscope

actions status linux actions status macOS actions status windows PyPI

Polyscope is a C++/Python viewer and user interface for 3D data such as meshes and point clouds. It allows you to register your data and quickly generate informative and beautiful visualizations, either programmatically or via a dynamic GUI. Polyscope is designed to be lightweight---it does not "take ownership" over your entire program, and it is easy to integrate with existing codebases and popular libraries. The lofty objective of Polyscope is to offer a useful visual interface to your data via a single line of code.

Polyscope uses a paradigm of structures and quantities. A structure is a geometric object in the scene, such as a surface mesh or point cloud. A quantity is data associated with a structure, such as a scalar function or a vector field.

When any of these structures and quantities are registered, Polyscope displays them in an interactive 3D scene, handling boilerplate concerns such as toggling visibility, color-mapping data and adjusting maps, "picking" to click in the scene and query numerical quantities, etc.

C++:

addVertexScalarQuantity("my_scalar", scalarQuantity); polyscope::getSurfaceMesh("my mesh")->addFaceVectorQuantity("my_vector", vectorQuantity); // View the point cloud and mesh we just registered in the 3D UI polyscope::show();">
#include "polyscope/polyscope.h"
#include "polyscope/surface_mesh.h"

// Initialize polyscope
polyscope::init();

// Register a point cloud
// `points` is a Nx3 array-like container of points
polyscope::registerPointCloud("my points", points)

// Register a surface mesh structure
// `meshVerts` is a Vx3 array-like container of vertex positions
// `meshFaces` is a Fx3 array-like container of face indices  
polyscope::registerSurfaceMesh("my mesh", meshVerts, meshFaces);

// Add a scalar and a vector function defined on the mesh
// `scalarQuantity` is a length V array-like container of values
// `vectorQuantity` is an Fx3 array-like container of vectors per face
polyscope::getSurfaceMesh("my mesh")->addVertexScalarQuantity("my_scalar", scalarQuantity);
polyscope::getSurfaceMesh("my mesh")->addFaceVectorQuantity("my_vector", vectorQuantity);

// View the point cloud and mesh we just registered in the 3D UI
polyscope::show();

Python:

import polyscope as ps

# Initialize polyscope
ps.init()

### Register a point cloud
# `my_points` is a Nx3 numpy array
ps.register_point_cloud("my points", my_points)

### Register a mesh
# `verts` is a Nx3 numpy array of vertex positions
# `faces` is a Fx3 array of indices, or a nested list
ps.register_surface_mesh("my mesh", verts, faces, smooth_shade=True)

# Add a scalar function and a vector function defined on the mesh
# vertex_scalar is a length V numpy array of values
# face_vectors is an Fx3 array of vectors per face
ps.get_surface_mesh("my mesh").add_scalar_quantity("my_scalar", 
        vertex_scalar, defined_on='vertices', cmap='blues')
ps.get_surface_mesh("my mesh").add_vector_quantity("my_vector", 
        face_vectors, defined_on='faces', color=(0.2, 0.5, 0.5))

# View the point cloud and mesh we just registered in the 3D UI
ps.show()

Polyscope is designed to make your life easier. It is simple to build, and fewer than 10 lines of code should be sufficient to start visualizing. In C++, some template magic means Polyscope can probably accept the data types you're already using!


Author: Nicholas Sharp

If Polyscope contributes to an academic publication, cite it as:

@misc{polyscope,
  title = {Polyscope},
  author = {Nicholas Sharp and others},
  note = {www.polyscope.run},
  year = {2019}
}

Development of this software was funded in part by NSF Award 1717320, an NSF graduate research fellowship, and gifts from Adobe Research and Autodesk, Inc.

Comments
  • add callback func to allow ImGui Font setting.

    add callback func to allow ImGui Font setting.

    This PR tries to resolve issues described in: https://github.com/nmwsharp/polyscope/issues/133, https://github.com/nmwsharp/polyscope/issues/135.

    add a callback function to the render::engine and its derivatives to allow external ImGui font setting when using polyscope as a library.

    One issue that still exists is the globalFontAtlas variable cannot be set from the external function, though it looks that variable does not affect anything. But an additional step was added to make sure that variable is set after the font setting.

    opened by xarthurx 17
  • Ribbon not working for VertexIntrinsicVectorQuantity

    Ribbon not working for VertexIntrinsicVectorQuantity

    It looks like the ribbon shader has been disabled.. Checking/unchecking the "ribbon" checkbox in the interface does nothing (vectors are still displayed with the "arrow" geometry).

    opened by dcoeurjo 12
  • Add Backface Color option

    Add Backface Color option

    Resolves #52 Culling and identical rendering for backfaces was already implemented, previously the "different" option would just render a slightly darker version of the same material, I changed that to a color option that defaults to the inverse of the first material color.

    opened by tmcarey 11
  • polyscope in jupyter notebooks crashes python

    polyscope in jupyter notebooks crashes python

    Hi,

    I just tried polyscope within python on Windows using the ipython terminal, jupyter notebook and jupyter lab. In all cases, polyscope works well and is quite impressive. But when I try to close the polyscope window, it always crashes python. Are there any settings I can change to address this? I am assuming it is related to the opengl backend, yes?

    Cheers, Michael

    bug 
    opened by mhogg 9
  • point cloud not visible (python)

    point cloud not visible (python)

    I've tried the basic point cloud visualization example from the docs for python:

    import numpy as np
    import polyscope as ps
    ps.init()
    
    points = np.random.rand(100, 3)
    ps_cloud = ps.register_point_cloud("my points", points)
    ps.show()
    

    However, the window that is created looks like this. I've also tried to adjust the radius, but this doesn't change anything.

    On the console I get the following output:

    [polyscope] Backend: openGL3_glfw -- Loaded openGL version: 3.3 (Core Profile) Mesa 19.2.8
    

    I've installed via the conda command for python 3.6.

    bug 
    opened by elPistolero 9
  • add focus window method with some minor clang-format changes

    add focus window method with some minor clang-format changes

    When using Polyscope within Python on OSX, the window pops up behind the currently used windows and has to be focused in order to see it. Add and use a focusWindow method so that it shows at the front when the windows is created.

    • add a focusWindow method
    • use focusWindow when a window is created

    Also, there were some minor clang-format changes when editing these files. I figured they should be included since the changes were made based on the config .clang-format file in this repository.

    opened by weshoke 8
  • different behavior when being called for the second time [python]

    different behavior when being called for the second time [python]

    Hi,

    I wrote a minimal script to describe the issue I am experiencing. From a high level, if I iterate through a series of objects to render, some type of meta-data is stored, and the results are different depending on what order the objects are rendered in. Even though I set ps.set_use_prefs_file(False) and ps.set_always_redraw(True) for good measure, the results still vary.

    For example, below, I show how setting the 'z_up' direction once, and then setting it to 'y_up' will result in the same output. If you change the order, the outputs will be different than previously, but still each render is identical. Any clues as to why this is happening?

    import numpy as np
    
    
    import polyscope as ps
    ps.set_use_prefs_file(False)
    ps.set_always_redraw(True)
    ps.init()
    
    
    np.random.seed(1)
    points = np.random.rand(4, 3)
    vals = np.random.rand(4, 3)
    
    
    ps.set_up_dir('z_up')
    ps_cloud = ps.register_point_cloud('points', points, enabled=True, radius=0.08)
    ps_cloud.add_color_quantity("rand colors", vals, enabled=True)
    ps.set_navigation_style("planar")
    ps.screenshot(filename='/home/rana/code/sandbox/points_z.png')
    
    ps.set_up_dir('y_up')
    ps_cloud = ps.register_point_cloud('points', points, enabled=True, radius=0.08)
    ps_cloud.add_color_quantity("rand colors", vals, enabled=True)
    ps.set_navigation_style("planar")
    ps.screenshot(filename='/home/rana/code/sandbox/points_y.png')
    
    bug 
    opened by ranahanocka 8
  • Added Orthogonal View

    Added Orthogonal View

    Resolves #106 Addes a checkbox under Camera Parameters which swaps the perspective matrix with an orthogonal one. Also remaps scroll zoom to scale the camera bounds.

    opened by tmcarey 7
  • Adding the ability to use individual radii on point sets

    Adding the ability to use individual radii on point sets

    this is a quick hack to be able to use a scalar attribute on a point set to define the radii of the points. This was usefull to me to visualize sets of balls. In its current state it is not possible to use another scalar attribute for colors.

    image

    opened by nivoliev 6
  • OpenGL errors from `generateTextureBufferMultisample()` in WSL

    OpenGL errors from `generateTextureBufferMultisample()` in WSL

    It seems like some machines which claim to support openGL 3.3 core are erroring out on the multisample textures. Perhaps we accidentally used something which is not valid in core 3.3?

    bug 
    opened by nmwsharp 6
  • Update ImGui to v1.86

    Update ImGui to v1.86

    First of all, thanks for the great framework!

    I noticed that the version of the ImGui dependency is rather dated (April 2020) and incompatible with some awesome libraries like ImPlot (https://github.com/epezent/implot).

    So, this PR updates the ImGui submodule from v1.76 to v1.86.

    These are the "major" changes:

    1. ImGui backends are now located under imgui/backends instead of imgui/examples
    2. ImGuiCol_ModalWindowDarkening was renamed to ImGuiCol_ModalWindowDimBg
    3. The Columns API is deprecated but still functional in the file imgui_tables.cpp
    4. The power argument to ImGui::SliderFloat/ImGui::DragFloat has been replaced by a flags argument (see https://github.com/ocornut/imgui/issues/3361). I replaced all appearances of power > 1 with the flags ImGuiSliderFlags_Logarithmic | ImGuiSliderFlags_NoRoundToFormat, which I think results in natural behavior for the logarithmic sliders. Feel free to double check.

    All tests are passing on my machine.

    opened by mworchel 5
  • Support installation through CMake

    Support installation through CMake

    This change will ensure proper behavior is exhibited when the CMAKE_INSTALL_PREFIX is specified by the user during build configuration so that artifacts are installed to their desired location.

    opened by PierceLBrooks 0
  • Implement saving/loading of persistent values to configure multiple views

    Implement saving/loading of persistent values to configure multiple views

    Desired workflow: The user programmatically configures several "views" of their data, each of which corresponds to a different collection of settings (stuff which is enabled, etc). The user wants to quickly switch between these views without clicking a bunch.

    How to get there: We could get this fairly easily by leveraging the persistent value caches. Work items would be:

    • define a serialization format for persistent values (in-memory for now)
    • add a storeConfiguration() function or something, which saves the state of all persistent values to an internal list
    • add a loadConfiguration() function which restores persistent values
    • buttons in the GUI, etc

    This has significant overlap with things we would want to do regardless to enable serialization more broadly.

    enhancement 
    opened by nmwsharp 0
  • Doesn't work on Virtual Machine

    Doesn't work on Virtual Machine

    I'm trying to use Polyscope on a Virtual Machine (Ubuntu 22.04 running inside an Oracle Virtualbox on Windows 10) However on calling it from Jupyter-lab I get the following problem:

    Kernel Restarting

    The kernel for Documents/ROTATOR/geodesic/Barmesh-scratch.ipynb appears to have died. It will restart automatically. So I tried doing a simple test file to just load a mesh and open a Polyscope window to show it, running from command line I get this:

    (base) timbo@timbo-VirtualBox:~/Documents/ROTATOR/geodesic$ python3 test.py GLFW emitted error: GLX: Failed to create context: GLXBadFBConfig GLFW emitted error: Cannot set swap interval without a current OpenGL or OpenGL ES context Segmentation fault (core dumped) I guess it's some issue with the display being passed through the VM, any idea how to fix this?

    opened by trilbytim 1
  • drag-and-drop mechanism

    drag-and-drop mechanism

    Hi, I would like to have a "drap-n-drop to open file" feature and was wondering if this is sth that should be embedded into the viewer.

    On ImGui's page, I found this: https://github.com/ocornut/imgui/issues/2602

    But I'm not sure how this should be integrated into polyscope to be multi-platform compatibable.

    opened by xarthurx 0
  • More flexible animation control flow

    More flexible animation control flow

    Right now, the only way to implement an animation is via userCallback. However, this requires you to put your whole program control flow inside of the callback.

    We should offer another option where a user calls a function like polyscope::mainLoopIteration() within their own control flow. The user is responsible for calling it often enough to keep the UI responsive.

    enhancement 
    opened by nmwsharp 0
Releases(v1.3.0)
Owner
Nicholas Sharp
3D geometry researcher: computer graphics/vision, geometry processing, and 3D machine learning
Nicholas Sharp
C++ (with python bindings) library for easily reading/writing/manipulating common animation particle formats such as PDB, BGEO, PTC. See the discussion group @ http://groups.google.com/group/partio-discuss

Partio - A library for particle IO and manipulation This is the initial source code release of partio a tool we used for particle reading/writing. It

Walt Disney Animation Studios 412 Dec 29, 2022
Dear ImGui is a bloat-free graphical user interface library for C++

dear imgui (This library is available under a free and permissive license, but needs financial support to sustain its continued improvements. In addit

Douglas McCloskey 6 Oct 27, 2020
Legion Low Level Rendering Interface provides a graphics API agnostic rendering interface with minimal CPU overhead and low level access to verbose GPU operations.

Legion-LLRI Legion-LLRI, or “Legion Low Level Rendering Interface” is a rendering API that aims to provide a graphics API agnostic approach to graphic

Rythe Interactive 25 Dec 6, 2022
General purpose model viewer

Foxotron ASSIMP based general purpose model viewer ("turntable") created for the Revision 2021 3D Graphics Competition Usage Check the wiki for inform

null 56 Dec 30, 2022
an SVG image viewer for plan9

svg A native SVG file viewer for Plan9. When using the -9 command line flag, the image is dumped to standard output in plan9 image format. svg relies

phil9 15 Oct 21, 2021
A simple single point light shadow mapping with OpenGL 3.3 and C++

omni-directional-light-example Using OpenGL 3.3 with C++ Basically a single light map, no lighting model was used Usage Build the executable outside A

Mohammad Issawi 4 Feb 10, 2022
Simple OpenGL program to visualize point cloud.

Point Cloud Viewer Simple OpenGL program to visualize point cloud. The input data files should be plain text files. screenshot on Linux: screenshot on

Tang.Anke 3 May 31, 2022
Phyxed is a 2D physics engine with support for fixed point math.

Phyxed is a 2D physics engine with support for fixed point math.

Anders Elfgren 24 Oct 5, 2022
Vizzu is a free, open-source Javascript/C++ library for animated data visualizations and data stories.

Vizzu is a free, open-source Javascript/C++ library utilizing a generic dataviz engine that generates many types of charts and seamlessly animates between them

Vizzu 1.6k Jan 3, 2023
Spatial extrapolation algorithm: calculate the data of other regions through the data of known regions.

Spatial interpolation Author : csl E-Mail : [email protected] OverView Spatial interpolation is often used to convert the measured data of discrete po

null 1 Oct 18, 2021
A tiny uefi graphical user interfaces libaray......

TUGUI a tiny uefi graphical user interfaces libaray...... 1.最近动态 1.添加 数学相关基础库 齐次坐标 .... 2.图形学 变换 2D/3D .... 2. 编译运行 2.1 开发环境 编译工具链: g++-mingw-w64-x86-

UnknownBugs 4 Jan 12, 2022
Metal-cpp is a low-overhead C++ interface for Metal that helps developers add Metal functionality to graphics apps, games, and game engines that are written in C++.

About metal-cpp is a low overhead and header only C++ interface for Metal that helps developers add Metal functionality to graphics applications that

Бранимир Караџић 164 Dec 31, 2022
Verisilicon Tensor Interface Module for OpenVX

TIM-VX is a software integration module provided by VeriSilicon to facilitate deployment of Neural-Networks on OpenVX enabled ML accelerators. It serves as the backend binding for runtime frameworks such as Android NN, Tensorflow-Lite, MLIR, TVM and more.

VeriSilicon, INC. 174 Dec 12, 2022
NVRHI (NVIDIA Rendering Hardware Interface) is a library that implements a common abstraction layer over multiple graphics APIs

NVRHI Introduction NVRHI (NVIDIA Rendering Hardware Interface) is a library that implements a common abstraction layer over multiple graphics APIs (GA

NVIDIA GameWorks 445 Jan 3, 2023
A modern, feature-rich single header C++ interface system for GLFW

A modern, feature-rich single header C++ interface system for GLFW

Vortex 3 Dec 27, 2021
ANSI C library for NURBS, B-Splines, and Bézier curves with interfaces for C++, C#, D, Go, Java, Lua, Octave, PHP, Python, R, and Ruby.

TinySpline TinySpline is a small, yet powerful library for interpolating, transforming, and querying arbitrary NURBS, B-Splines, and Bézier curves. Th

Marcel Steinbeck 895 Dec 28, 2022
HARFANG®3D is an all-in-one 3D visualization library usable in C++, Python, Lua and Go.

HARFANG® 3D engine HARFANG®3D is an all-in-one 3D visualization library usable in C++, Python, Lua and Go. Table of contents About Features Screenshot

HARFANG® 3D 280 Jan 1, 2023
Python binding for Grasp Pose Generator (pyGPG)

Python binding for Grasp Pose Generator (pyGPG) Grasp Pose Generator is a cpp package that creat grasp candidates for 3D point clouds. This package bi

Hongzhuo Liang 11 Dec 16, 2022
⚡High-performance rendering for python

ZenGL ZenGL is a minimalist Python module providing exactly one way to render scenes with OpenGL. pip install zengl Documentation zengl on Github zen

Szabolcs Dombi 133 Dec 17, 2022