Advertisement
Guest User

Untitled

a guest
Mar 27th, 2017
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.65 KB | None | 0 0
  1. {
  2. "cells": [
  3. {
  4. "cell_type": "markdown",
  5. "metadata": {},
  6. "source": [
  7. "# Displaying VTK files using pythreejs"
  8. ]
  9. },
  10. {
  11. "cell_type": "code",
  12. "execution_count": 1,
  13. "metadata": {
  14. "collapsed": false
  15. },
  16. "outputs": [
  17. {
  18. "name": "stdout",
  19. "output_type": "stream",
  20. "text": [
  21. "Populating the interactive namespace from numpy and matplotlib\n"
  22. ]
  23. }
  24. ],
  25. "source": [
  26. "%pylab inline\n",
  27. "from IPython.display import display\n",
  28. "from pythreejs import *\n",
  29. "from mindboggle.mio.vtks import read_vtk"
  30. ]
  31. },
  32. {
  33. "cell_type": "code",
  34. "execution_count": 2,
  35. "metadata": {
  36. "collapsed": true
  37. },
  38. "outputs": [],
  39. "source": [
  40. "def displayVTK(vertices, faces):\n",
  41. " geom = FaceGeometry(vertices=np.asarray(points).ravel().tolist(), face3=np.asarray(faces).ravel().tolist())\n",
  42. " material=LambertMaterial(wireframe=False)\n",
  43. " mesh = Mesh(geometry=geom, material=material,position=[0, 0, 0])\n",
  44. "\n",
  45. " scene = Scene(children=[mesh, AmbientLight(color='#777777')])\n",
  46. "\n",
  47. " c = PerspectiveCamera(position=[0, 5, 5], up=[0, 0, 1],\n",
  48. " children=[DirectionalLight(color='white', \n",
  49. " position=[3, 5, 1], \n",
  50. " intensity=0.5)])\n",
  51. " renderer = Renderer(camera=c, \n",
  52. " scene=scene, \n",
  53. " controls=[OrbitControls(controlling=c)])\n",
  54. " display(renderer)"
  55. ]
  56. },
  57. {
  58. "cell_type": "code",
  59. "execution_count": 3,
  60. "metadata": {
  61. "collapsed": false
  62. },
  63. "outputs": [
  64. {
  65. "data": {
  66. "application/vnd.jupyter.widget-view+json": {
  67. "model_id": "b53e647711d2447ab9c3f2b90246ce62"
  68. }
  69. },
  70. "metadata": {},
  71. "output_type": "display_data"
  72. }
  73. ],
  74. "source": [
  75. "points, indices, lines, faces, scalars, scalar_names, npoints, _ = read_vtk(input_vtk=\"../../../../lh.pial.travel_depth.vtk\")\n",
  76. "displayVTK(points, faces)"
  77. ]
  78. },
  79. {
  80. "cell_type": "code",
  81. "execution_count": null,
  82. "metadata": {
  83. "collapsed": true
  84. },
  85. "outputs": [],
  86. "source": []
  87. }
  88. ],
  89. "metadata": {
  90. "kernelspec": {
  91. "display_name": "Python 3",
  92. "language": "python",
  93. "name": "python3"
  94. },
  95. "language_info": {
  96. "codemirror_mode": {
  97. "name": "ipython",
  98. "version": 3
  99. },
  100. "file_extension": ".py",
  101. "mimetype": "text/x-python",
  102. "name": "python",
  103. "nbconvert_exporter": "python",
  104. "pygments_lexer": "ipython3",
  105. "version": "3.5.2"
  106. }
  107. },
  108. "nbformat": 4,
  109. "nbformat_minor": 2
  110. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement