seantronsen / pvt

GNU General Public License v3.0
0 stars 0 forks source link

Feature: Integration with PyVista for 3D Mesh Graphics #41

Open seantrons opened 6 months ago

seantrons commented 6 months ago

Some preliminary work would be required to make using their API abstract and easier to use than it already is (maybe those simplifications wouldn't be need either?), but integrating with PyVista would be a great route to get a full-featured 3D analysis tool up and running quickly.

We explored the library recently for analysis of 3D data in an implementation external to this library and found the experience to be quite good. It offers many of the features that ParaView does on a somewhat simple to access script level. The libraries integration with Qt does leave a little bit to be desired though. The authors make a lot of assumptions about their user base and create windows automatically as part of the exposed API. So making it would on our end would require overriding a fair amount of the functionality implemented in their classes (or so it seems).

Track this issue if you're awaiting 3D analysis tools.

seantrons commented 6 months ago

I should also add that this addition would be an outright replacement for the 3D tools provided by PyQtGraph. Don't get me wrong, their 2D features are beyond excellent but mention in the documentation that the 3D features are experimental and under active development. Their implementation also requires a lot of hands on work for each graphic displayed (e.g. axes and grids are not automatically calculated or generated). With that portion of the project being less mature, I'm hesitant to do any major work in that area since the carpet could be pulled out from under us so to speak.

Additionally, I have little desire to write any OpenGL code in Python simply due to the performance constraints of code which executes in the Python layer. Rather, it's something that I may look into farther down the line once we integrate a lower level codebase (Rust or CPP) via the FFI for higher performance drawing functions and the like.

seantronsen commented 6 months ago

A basic feature set / integration is available as of: 4931166

However, I do have some notes after playing around with PyVista a little more. While the features provided by the library are outstanding, I do have some concerns about the performance of their implementation provided this is a tuning-focused data visualization library.

Let's start by reviewing the new demo for this integration: image

For the performance issue, I'd like to note that this sphere demo isn't computationally complex. The performance log for the compute component of the frame update operation shows that each frame on this demo could achieve a theoretical maximum of about 6500 FPS. The issue surfaces when viewing the logs for the render component, which stress an upper bound of about 144 FPS. See the image below:

image

Note that 144 FPS is well within the range of tolerance, but my concern stems from having yet to test the library against more complicated scenes. Should we expect this as the average render speed for any scene displayed using PyVista or do we need to carefully watch out for poor performance on more complicated multi-mesh scenes (or point cloud scenes).

To provide another performance reference, review the log output for the PyQtGraph OpenGL prototype below: image

It is another relatively simple scene containing only a Gaussian hill and some grid lines, but each component of the frame update achieves a limit of approximately 32,000 FPS.

Important: Neither of these demos should be considered true benchmarks, but these findings provide the justification for us to create our own and give these libraries a proper test drive with 3D data display.