{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Importing VTK data to be displayed as Mesh\n", "\n", "Additional requirements for this example: `vtk`\n", "\n", "We will also use K3D's bundled color maps." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import k3d\n", "import os\n", "import vtk\n", "\n", "from k3d.helpers import download\n", "\n", "filename = download(\"https://raw.githubusercontent.com/naucoin/VTKData/master/Data/Quadratic/CylinderQuadratic.vtk\")\n", "\n", "model_matrix = (\n", " 10.0, 0.0, 0.0, 0.0,\n", " 0.0, 10.0, 0.0, 0.0,\n", " 0.0, 0.0, 10.0, 0.0,\n", " 0.0, 0.0, 0.0, 1.0\n", ")\n", " \n", "reader = vtk.vtkUnstructuredGridReader()\n", "reader.SetFileName(filename)\n", "reader.Update()\n", "\n", "geometryFilter = vtk.vtkGeometryFilter()\n", "geometryFilter.SetInputData(reader.GetOutput())\n", "geometryFilter.Update()\n", "\n", "plot = k3d.plot()\n", "cylinder = k3d.vtk_poly_data(geometryFilter.GetOutput(), color_attribute=('pressure', -100, 7200), \n", " color_map=k3d.basic_color_maps.Jet, model_matrix=model_matrix)\n", "plot += cylinder\n", "plot.display()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "cylinder.color_map = k3d.matplotlib_color_maps.Blues" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "cylinder.color_map = k3d.paraview_color_maps.Rainbow_Desaturated" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.6.5" } }, "nbformat": 4, "nbformat_minor": 2 }