#!/usr/bin/env python
# coding: utf-8
# # Using OMF-VTK Interface
#
# This notebook demos how to load [OMF](https://omf.readthedocs.io/en/latest/) project files into `pyvista` data objects. These data objects are converted using the [`omfvista` Python package](https://github.com/OpenGeoVis/omfvista) and visualized using [`pyvista`](https://github.com/pyvista/pyvista).
#
# This requires:
#
# - `pip install omfvista`
#
# -----
#
# **For more examples like this notebook and to learn more about the supporting 3D visualization software used here, please head over to `pyvista`'s [example gallery](https://docs.pyvista.org/examples/index.html)**
#
#
# ### Author
#
# This notebook was created by [Bane Sullivan](http://banesullivan.com) - follow Bane on Twitter for more 3D viz examples like this:
#
# In[1]:
import omfvista
import pyvista as pv
# ## Open an OMF Project file
#
# The file given is a simple file from the [OMF Python package repository](https://github.com/gmggroup/omf/tree/master/assets). `omfvista` opens the project and returns all elements of the Project as a `pyvista.MultiBlock` data object that can be used for eay access and plotting.
# In[2]:
proj = omfvista.load_project("assets/test_file.omf")
proj
# ## Visualize the Project
# In[3]:
# view all of it in 3D
proj.plot(multi_colors=True)
# In[4]:
# Grab a few elements of interest and plot em up!
assay = proj["wolfpass_WP_assay"]
topo = proj["Topography"]
dacite = proj["Dacite"]
vol = proj["Block Model"]
# In[5]:
assay.set_active_scalars("DENSITY")
assay
# In[6]:
p = pv.Plotter()
p.add_mesh(assay.tube(radius=3))
p.add_mesh(topo, opacity=0.5)
p.show()
# Extract a subset of the volumetric model based on a scalar range
# In[7]:
# Threshold the volumetric data
thresh_vol = vol.threshold([1.09, 4.20])
thresh_vol
# In[8]:
# Create a plotting window
p = pv.Plotter()
# Add the bounds axis
p.show_bounds()
# p.add_bounding_box()
# Add our datasets
p.add_mesh(topo, opacity=0.5)
p.add_mesh(
dacite,
color="orange",
opacity=0.6,
)
p.add_mesh(thresh_vol, cmap="coolwarm", clim=vol.get_data_range())
# Add the assay logs: use a tube filter that varius the radius by an attribute
p.add_mesh(assay.tube(radius=3), cmap="viridis")
p.show()
# In[ ]: