yt-project / yt_idv

Interactive volume rendering for yt
Other
9 stars 6 forks source link

Add slice plotting functionality #12

Closed chrishavlin closed 3 years ago

chrishavlin commented 3 years ago

This adds a couple of mesh rendering data classes to allow 2d slices to be plotted in 3d. The basic approach is to generate a fixed resolution buffer from a YTSlice and build a uniform hexahedral mesh with the frb values as element-center values (which is then triangulated following MeshData). The slice thickness is small (but finite), calculated as a fraction of the cell spacing in the other axes. The new SliceData class handles all this for a single slice (see examples/amr_slices.py) while SliceDataComposite can concatenate multiple SliceData objects without re-generating the meshes so that the rendering will use a single colormap across the slices (see examples/amr_slices_composites.py).

Currently a draft PR because assembling the unstructured mesh is slow -- started with a brute force nested loop that needs to be improved (should be vectorizable, or maybe yt has some utility to help here...). The examples here take ~15 seconds per slice to generate the SliceData objects. Once generated and added to the rendering context, it's fast! (also haven't run any style checks yet...)

Here's a couple screen shots from the single slice example:

snap_0000 snap_0001

chrishavlin commented 3 years ago

Closing in favor of the better/simpler implementation in #14