BoundsExample.ipynb 9.52 KB
Newer Older
Dario Seyb's avatar
Dario Seyb committed
1 2 3 4
{
 "cells": [
  {
   "cell_type": "code",
5
   "execution_count": 1,
Dario Seyb's avatar
Dario Seyb committed
6
   "metadata": {},
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
   "outputs": [
    {
     "data": {
      "application/vnd.jupyter.widget-view+json": {
       "model_id": "8ce65a6d94a04f459ce59cca1460668c",
       "version_major": 2,
       "version_minor": 0
      },
      "text/html": [
       "<p>Failed to display Jupyter Widget of type <code>Renderer</code>.</p>\n",
       "<p>\n",
       "  If you're reading this message in the Jupyter Notebook or JupyterLab Notebook, it may mean\n",
       "  that the widgets JavaScript is still loading. If this message persists, it\n",
       "  likely means that the widgets JavaScript library is either not installed or\n",
       "  not enabled. See the <a href=\"https://ipywidgets.readthedocs.io/en/stable/user_install.html\">Jupyter\n",
       "  Widgets Documentation</a> for setup instructions.\n",
       "</p>\n",
       "<p>\n",
       "  If you're reading this message in another frontend (for example, a static\n",
       "  rendering on GitHub or <a href=\"https://nbviewer.jupyter.org/\">NBViewer</a>),\n",
       "  it may mean that your frontend doesn't currently support widgets.\n",
       "</p>\n"
      ],
      "text/plain": [
       "Renderer(background='#dddddd', camera=PerspectiveCamera(aspect=1.5, children=(DirectionalLight(position=(-30.0, 50.0, 10.0), quaternion=(0.0, 0.0, 0.0, 1.0), scale=(1.0, 1.0, 1.0), up=(0.0, 1.0, 0.0)),), fov=20.0, position=(0.6234404316842783, 0.6234404316842783, 0.6234404316842783), quaternion=(0.0, 0.0, 0.0, 1.0), scale=(1.0, 1.0, 1.0), up=(0.0, 1.0, 0.0)), controls=[OrbitControls(controlling=PerspectiveCamera(aspect=1.5, children=(DirectionalLight(position=(-30.0, 50.0, 10.0), quaternion=(0.0, 0.0, 0.0, 1.0), scale=(1.0, 1.0, 1.0), up=(0.0, 1.0, 0.0)),), fov=20.0, position=(0.6234404316842783, 0.6234404316842783, 0.6234404316842783), quaternion=(0.0, 0.0, 0.0, 1.0), scale=(1.0, 1.0, 1.0), up=(0.0, 1.0, 0.0)), target=(-0.016800811514258385, 0.1101529560983181, -0.0014822650700807571)), Picker(controlling=Scene(background=u'#dddddd', children=(AmbientLight(color=u'#aaaaaa', quaternion=(0.0, 0.0, 0.0, 1.0), scale=(1.0, 1.0, 1.0), up=(0.0, 1.0, 0.0)), PerspectiveCamera(aspect=1.5, children=(DirectionalLight(position=(-30.0, 50.0, 10.0), quaternion=(0.0, 0.0, 0.0, 1.0), scale=(1.0, 1.0, 1.0), up=(0.0, 1.0, 0.0)),), fov=20.0, position=(0.6234404316842783, 0.6234404316842783, 0.6234404316842783), quaternion=(0.0, 0.0, 0.0, 1.0), scale=(1.0, 1.0, 1.0), up=(0.0, 1.0, 0.0)), Mesh(geometry=BufferGeometry(attributes={'index': <BufferAttribute shape=(14904L,), dtype=uint32>, 'normal': <BufferAttribute shape=(14904L, 3L), dtype=float32>, 'position': <BufferAttribute shape=(14904L, 3L), dtype=float32>}), material=MeshLambertMaterial(alphaMap=None, aoMap=None, color=u'#dddddd', emissiveMap=None, envMap=None, lightMap=None, map=None, specularMap=None), quaternion=(0.0, 0.0, 0.0, 1.0), scale=(1.0, 1.0, 1.0), up=(0.0, 1.0, 0.0)), LineSegments(geometry=BufferGeometry(attributes={'color': BufferAttribute(array=array([[1., 0., 0.],\n",
       "       [1., 0., 0.],\n",
       "       [0., 1., 0.],\n",
       "       [0., 1., 0.],\n",
       "       [0., 0., 1.],\n",
       "       [0., 0., 1.]], dtype=float32)), 'index': BufferAttribute(array=array([0, 1, 2, 3, 4, 5], dtype=uint32), normalized=False), 'position': BufferAttribute(array=array([[-0.09438042,  0.0333099 , -0.06167917],\n",
       "       [ 0.0607788 ,  0.0333099 , -0.06167917],\n",
       "       [-0.09438042,  0.0333099 , -0.06167917],\n",
       "       [-0.09438042,  0.18699601, -0.06167917],\n",
       "       [-0.09438042,  0.0333099 , -0.06167917],\n",
       "       [-0.09438042,  0.0333099 ,  0.05871464]], dtype=float32), normalized=False)}), material=LineBasicMaterial(color=u'white', vertexColors='VertexColors'), quaternion=(0.0, 0.0, 0.0, 1.0), scale=(1.0, 1.0, 1.0), up=(0.0, 1.0, 0.0)), Sprite(center=(0.5, 0.5), material=SpriteMaterial(map=TextTexture(color=u'black', repeat=(1.0, 1.0), size=100, string=u'[-0.094, 0.033, -0.062]')), position=(-0.09438042342662811, 0.017941287904977798, -0.0616791695356369), quaternion=(0.0, 0.0, 0.0, 1.0), scale=(0.1413912245631218, 0.1413912245631218, 1.0), up=(0.0, 1.0, 0.0)), Sprite(center=(0.5, 0.5), material=SpriteMaterial(map=TextTexture(color=u'black', repeat=(1.0, 1.0), size=100, string=u'0.155')), position=(0.02198899444192648, 0.033309899270534515, -0.0616791695356369), quaternion=(0.0, 0.0, 0.0, 1.0), scale=(0.03842152841389179, 0.03842152841389179, 1.0), up=(0.0, 1.0, 0.0)), Sprite(center=(0.5, 0.5), material=SpriteMaterial(map=TextTexture(color=u'black', repeat=(1.0, 1.0), size=100, string=u'0.154')), position=(-0.09438042342662811, 0.1485744845122099, -0.0616791695356369), quaternion=(0.0, 0.0, 0.0, 1.0), scale=(0.03842152841389179, 0.03842152841389179, 1.0), up=(0.0, 1.0, 0.0)), Sprite(center=(0.5, 0.5), material=SpriteMaterial(map=TextTexture(color=u'black', repeat=(1.0, 1.0), size=100, string=u'0.12')), position=(-0.09438042342662811, 0.033309899270534515, 0.028616187162697315), quaternion=(0.0, 0.0, 0.0, 1.0), scale=(0.030737222731113435, 0.030737222731113435, 1.0), up=(0.0, 1.0, 0.0))), fog=None, overrideMaterial=None, quaternion=(0.0, 0.0, 0.0, 1.0), scale=(1.0, 1.0, 1.0), up=(0.0, 1.0, 0.0)), event=u'dblclick', object=None)], localClippingEnabled=True, scene=Scene(background=u'#dddddd', children=(AmbientLight(color=u'#aaaaaa', quaternion=(0.0, 0.0, 0.0, 1.0), scale=(1.0, 1.0, 1.0), up=(0.0, 1.0, 0.0)), PerspectiveCamera(aspect=1.5, children=(DirectionalLight(position=(-30.0, 50.0, 10.0), quaternion=(0.0, 0.0, 0.0, 1.0), scale=(1.0, 1.0, 1.0), up=(0.0, 1.0, 0.0)),), fov=20.0, position=(0.6234404316842783, 0.6234404316842783, 0.6234404316842783), quaternion=(0.0, 0.0, 0.0, 1.0), scale=(1.0, 1.0, 1.0), up=(0.0, 1.0, 0.0)), Mesh(geometry=BufferGeometry(attributes={'index': <BufferAttribute shape=(14904L,), dtype=uint32>, 'normal': <BufferAttribute shape=(14904L, 3L), dtype=float32>, 'position': <BufferAttribute shape=(14904L, 3L), dtype=float32>}), material=MeshLambertMaterial(alphaMap=None, aoMap=None, color=u'#dddddd', emissiveMap=None, envMap=None, lightMap=None, map=None, specularMap=None), quaternion=(0.0, 0.0, 0.0, 1.0), scale=(1.0, 1.0, 1.0), up=(0.0, 1.0, 0.0)), LineSegments(geometry=BufferGeometry(attributes={'color': BufferAttribute(array=array([[1., 0., 0.],\n",
       "       [1., 0., 0.],\n",
       "       [0., 1., 0.],\n",
       "       [0., 1., 0.],\n",
       "       [0., 0., 1.],\n",
       "       [0., 0., 1.]], dtype=float32)), 'index': BufferAttribute(array=array([0, 1, 2, 3, 4, 5], dtype=uint32), normalized=False), 'position': BufferAttribute(array=array([[-0.09438042,  0.0333099 , -0.06167917],\n",
       "       [ 0.0607788 ,  0.0333099 , -0.06167917],\n",
       "       [-0.09438042,  0.0333099 , -0.06167917],\n",
       "       [-0.09438042,  0.18699601, -0.06167917],\n",
       "       [-0.09438042,  0.0333099 , -0.06167917],\n",
       "       [-0.09438042,  0.0333099 ,  0.05871464]], dtype=float32), normalized=False)}), material=LineBasicMaterial(color=u'white', vertexColors='VertexColors'), quaternion=(0.0, 0.0, 0.0, 1.0), scale=(1.0, 1.0, 1.0), up=(0.0, 1.0, 0.0)), Sprite(center=(0.5, 0.5), material=SpriteMaterial(map=TextTexture(color=u'black', repeat=(1.0, 1.0), size=100, string=u'[-0.094, 0.033, -0.062]')), position=(-0.09438042342662811, 0.017941287904977798, -0.0616791695356369), quaternion=(0.0, 0.0, 0.0, 1.0), scale=(0.1413912245631218, 0.1413912245631218, 1.0), up=(0.0, 1.0, 0.0)), Sprite(center=(0.5, 0.5), material=SpriteMaterial(map=TextTexture(color=u'black', repeat=(1.0, 1.0), size=100, string=u'0.155')), position=(0.02198899444192648, 0.033309899270534515, -0.0616791695356369), quaternion=(0.0, 0.0, 0.0, 1.0), scale=(0.03842152841389179, 0.03842152841389179, 1.0), up=(0.0, 1.0, 0.0)), Sprite(center=(0.5, 0.5), material=SpriteMaterial(map=TextTexture(color=u'black', repeat=(1.0, 1.0), size=100, string=u'0.154')), position=(-0.09438042342662811, 0.1485744845122099, -0.0616791695356369), quaternion=(0.0, 0.0, 0.0, 1.0), scale=(0.03842152841389179, 0.03842152841389179, 1.0), up=(0.0, 1.0, 0.0)), Sprite(center=(0.5, 0.5), material=SpriteMaterial(map=TextTexture(color=u'black', repeat=(1.0, 1.0), size=100, string=u'0.12')), position=(-0.09438042342662811, 0.033309899270534515, 0.028616187162697315), quaternion=(0.0, 0.0, 0.0, 1.0), scale=(0.030737222731113435, 0.030737222731113435, 1.0), up=(0.0, 1.0, 0.0))), fog=None, overrideMaterial=None, quaternion=(0.0, 0.0, 0.0, 1.0), scale=(1.0, 1.0, 1.0), up=(0.0, 1.0, 0.0)), shadowMap=WebGLShadowMap())"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
Dario Seyb's avatar
Dario Seyb committed
58
   "source": [
59
    "import threevis\n",
Dario Seyb's avatar
Dario Seyb committed
60 61 62
    "import openmesh as om\n",
    "import numpy as np\n",
    "\n",
63
    "m = om.read_polymesh('models/bunny.obj')\n",
Dario Seyb's avatar
Dario Seyb committed
64 65 66 67 68
    "\n",
    "vertices = m.points()\n",
    "faces = m.face_vertex_indices()\n",
    "\n",
    "\n",
69 70
    "mesh = threevis.Mesh(vertices, faces, \n",
    "                     normals = threevis.calculateFaceNormals(vertices, faces))\n",
Dario Seyb's avatar
Dario Seyb committed
71
    "\n",
72
    "threevis.display(mesh, show_bounds=True)\n"
Dario Seyb's avatar
Dario Seyb committed
73
   ]
74 75 76 77 78 79 80
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
Dario Seyb's avatar
Dario Seyb committed
81 82 83 84
  }
 ],
 "metadata": {
  "kernelspec": {
85
   "display_name": "Python 2",
Dario Seyb's avatar
Dario Seyb committed
86
   "language": "python",
87
   "name": "python2"
Dario Seyb's avatar
Dario Seyb committed
88 89 90 91
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
92
    "version": 2
Dario Seyb's avatar
Dario Seyb committed
93 94 95 96 97
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
98 99
   "pygments_lexer": "ipython2",
   "version": "2.7"
Dario Seyb's avatar
Dario Seyb committed
100 101 102 103 104
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}