Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- {
- "cells": [
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "# Displaying VTK files using pythreejs"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 1,
- "metadata": {
- "collapsed": false
- },
- "outputs": [
- {
- "name": "stdout",
- "output_type": "stream",
- "text": [
- "Populating the interactive namespace from numpy and matplotlib\n"
- ]
- }
- ],
- "source": [
- "%pylab inline\n",
- "from IPython.display import display\n",
- "from pythreejs import *\n",
- "from mindboggle.mio.vtks import read_vtk"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 2,
- "metadata": {
- "collapsed": true
- },
- "outputs": [],
- "source": [
- "def displayVTK(vertices, faces):\n",
- " geom = FaceGeometry(vertices=np.asarray(points).ravel().tolist(), face3=np.asarray(faces).ravel().tolist())\n",
- " material=LambertMaterial(wireframe=False)\n",
- " mesh = Mesh(geometry=geom, material=material,position=[0, 0, 0])\n",
- "\n",
- " scene = Scene(children=[mesh, AmbientLight(color='#777777')])\n",
- "\n",
- " c = PerspectiveCamera(position=[0, 5, 5], up=[0, 0, 1],\n",
- " children=[DirectionalLight(color='white', \n",
- " position=[3, 5, 1], \n",
- " intensity=0.5)])\n",
- " renderer = Renderer(camera=c, \n",
- " scene=scene, \n",
- " controls=[OrbitControls(controlling=c)])\n",
- " display(renderer)"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 3,
- "metadata": {
- "collapsed": false
- },
- "outputs": [
- {
- "data": {
- "application/vnd.jupyter.widget-view+json": {
- "model_id": "b53e647711d2447ab9c3f2b90246ce62"
- }
- },
- "metadata": {},
- "output_type": "display_data"
- }
- ],
- "source": [
- "points, indices, lines, faces, scalars, scalar_names, npoints, _ = read_vtk(input_vtk=\"../../../../lh.pial.travel_depth.vtk\")\n",
- "displayVTK(points, faces)"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {
- "collapsed": true
- },
- "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.5.2"
- }
- },
- "nbformat": 4,
- "nbformat_minor": 2
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement