Commit c725b9a1 authored by Dario Seyb's avatar Dario Seyb

renamed function to make sure they're in snake_case

parent 87182865
......@@ -2,59 +2,9 @@
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"execution_count": null,
"metadata": {},
"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"
}
],
"outputs": [],
"source": [
"import threevis\n",
"import openmesh as om\n",
......@@ -67,17 +17,10 @@
"\n",
"\n",
"mesh = threevis.Mesh(vertices, faces, \n",
" normals = threevis.calculateFaceNormals(vertices, faces))\n",
" normals = threevis.calculate_face_normals(vertices, faces))\n",
"\n",
"threevis.display(mesh, show_bounds=True)\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
......@@ -95,8 +38,7 @@
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython2",
"version": "2.7"
"pygments_lexer": "ipython2"
}
},
"nbformat": 4,
......
......@@ -2,39 +2,9 @@
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"execution_count": null,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "9806ab94464a47778a64697f8e9ebb2c",
"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, clipShadows=True, clippingPlanes=(Plane(constant=0.05, normal=(1.0, 0.0, 0.0)),), color=u'#dddddd', emissiveMap=None, envMap=None, lightMap=None, map=None, polygonOffset=True, polygonOffsetFactor=0.5, polygonOffsetUnits=0.1, 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))), 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, clipShadows=True, clippingPlanes=(Plane(constant=0.05, normal=(1.0, 0.0, 0.0)),), color=u'#dddddd', emissiveMap=None, envMap=None, lightMap=None, map=None, polygonOffset=True, polygonOffsetFactor=0.5, polygonOffsetUnits=0.1, 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))), 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"
}
],
"outputs": [],
"source": [
"import threevis\n",
"import openmesh as om\n",
......@@ -47,13 +17,13 @@
"\n",
"\n",
"mesh = threevis.Mesh(vertices, faces, \n",
" normals = threevis.calculateFaceNormals(vertices, faces))\n",
" normals = threevis.calculate_face_normals(vertices, faces))\n",
"\n",
"ctx = threevis.Context()\n",
"ctx.draw(mesh, shading='flat', clipping_planes=[threevis.Plane((1.0, 0.0, 0.0) , 0.05)])\n",
"ctx.display()\n",
"\n",
"ctx.setCameraPosition([0.2, 0, 0])"
"ctx.set_camera_position([0.2, 0, 0])"
]
},
{
......@@ -79,8 +49,7 @@
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython2",
"version": "2.7"
"pygments_lexer": "ipython2"
}
},
"nbformat": 4,
......
......@@ -2,67 +2,9 @@
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"execution_count": null,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "b067fdbee6c140528b8413cf73022721",
"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=(15.0070282848566, 15.0070282848566, 15.0070282848566), 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=(15.0070282848566, 15.0070282848566, 15.0070282848566), 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.7533562409600962, 0.010526408874791504, 0.5149774284808086)), 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=(15.0070282848566, 15.0070282848566, 15.0070282848566), 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={'color': <BufferAttribute shape=(66L, 3L), dtype=float32>, 'index': <BufferAttribute shape=(66L,), dtype=uint32>, 'normal': <BufferAttribute shape=(66L, 3L), dtype=float32>, 'position': <BufferAttribute shape=(66L, 3L), dtype=float32>}), material=MeshLambertMaterial(alphaMap=None, aoMap=None, color=u'white', emissiveMap=None, envMap=None, lightMap=None, map=None, polygonOffset=True, polygonOffsetFactor=0.5, polygonOffsetUnits=0.1, specularMap=None, 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)), LineSegments(geometry=BufferGeometry(attributes={'index': BufferAttribute(array=array([ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,\n",
" 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33,\n",
" 34, 35, 36, 37, 38, 39, 40, 41], dtype=uint32), normalized=False), 'position': <BufferAttribute shape=(42L, 3L), dtype=float32>}), material=LineBasicMaterial(color=u'#000000', polygonOffset=True, polygonOffsetFactor=0.5, polygonOffsetUnits=0.1), quaternion=(0.0, 0.0, 0.0, 1.0), scale=(1.0, 1.0, 1.0), up=(0.0, 1.0, 0.0)), Points(geometry=BufferGeometry(attributes={'position': BufferAttribute(array=array([[-1. , -1. , 1.26039 ],\n",
" [-1. , 1. , 1.191139],\n",
" [-1. , -1. , -1. ],\n",
" [-1. , 1. , -1. ],\n",
" [ 1. , -1. , 1. ],\n",
" [ 1. , 1. , 1. ],\n",
" [ 1. , -1. , -1. ],\n",
" [ 1. , 1. , -1. ],\n",
" [-1. , 0. , 1.887504],\n",
" [ 2.246086, -1. , 1. ],\n",
" [ 2.246086, 1. , 1. ],\n",
" [ 2.246086, -1. , -1. ],\n",
" [ 2.246086, 1. , -1. ]], dtype=float32), normalized=False)}), material=PointsMaterial(color=u'#aaaaaa', map=None, polygonOffset=True, polygonOffsetFactor=0.5, polygonOffsetUnits=0.1, size=3.0, sizeAttenuation=False), 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={'index': <BufferAttribute shape=(84L,), dtype=uint32>, 'position': <BufferAttribute shape=(84L, 3L), dtype=float32>}), material=LineBasicMaterial(color=u'#000000'), quaternion=(0.0, 0.0, 0.0, 1.0), scale=(1.0, 1.0, 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=(15.0070282848566, 15.0070282848566, 15.0070282848566), 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={'color': <BufferAttribute shape=(66L, 3L), dtype=float32>, 'index': <BufferAttribute shape=(66L,), dtype=uint32>, 'normal': <BufferAttribute shape=(66L, 3L), dtype=float32>, 'position': <BufferAttribute shape=(66L, 3L), dtype=float32>}), material=MeshLambertMaterial(alphaMap=None, aoMap=None, color=u'white', emissiveMap=None, envMap=None, lightMap=None, map=None, polygonOffset=True, polygonOffsetFactor=0.5, polygonOffsetUnits=0.1, specularMap=None, 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)), LineSegments(geometry=BufferGeometry(attributes={'index': BufferAttribute(array=array([ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,\n",
" 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33,\n",
" 34, 35, 36, 37, 38, 39, 40, 41], dtype=uint32), normalized=False), 'position': <BufferAttribute shape=(42L, 3L), dtype=float32>}), material=LineBasicMaterial(color=u'#000000', polygonOffset=True, polygonOffsetFactor=0.5, polygonOffsetUnits=0.1), quaternion=(0.0, 0.0, 0.0, 1.0), scale=(1.0, 1.0, 1.0), up=(0.0, 1.0, 0.0)), Points(geometry=BufferGeometry(attributes={'position': BufferAttribute(array=array([[-1. , -1. , 1.26039 ],\n",
" [-1. , 1. , 1.191139],\n",
" [-1. , -1. , -1. ],\n",
" [-1. , 1. , -1. ],\n",
" [ 1. , -1. , 1. ],\n",
" [ 1. , 1. , 1. ],\n",
" [ 1. , -1. , -1. ],\n",
" [ 1. , 1. , -1. ],\n",
" [-1. , 0. , 1.887504],\n",
" [ 2.246086, -1. , 1. ],\n",
" [ 2.246086, 1. , 1. ],\n",
" [ 2.246086, -1. , -1. ],\n",
" [ 2.246086, 1. , -1. ]], dtype=float32), normalized=False)}), material=PointsMaterial(color=u'#aaaaaa', map=None, polygonOffset=True, polygonOffsetFactor=0.5, polygonOffsetUnits=0.1, size=3.0, sizeAttenuation=False), 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={'index': <BufferAttribute shape=(84L,), dtype=uint32>, 'position': <BufferAttribute shape=(84L, 3L), dtype=float32>}), material=LineBasicMaterial(color=u'#000000'), quaternion=(0.0, 0.0, 0.0, 1.0), scale=(1.0, 1.0, 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"
}
],
"outputs": [],
"source": [
"import threevis\n",
"import openmesh as om\n",
......@@ -76,10 +18,10 @@
"\n",
"mesh = threevis.Mesh(vertices, faces)\n",
"mesh.colors = threevis.FaceAttribute(np.random.rand(len(faces), 3))\n",
"mesh.normals = threevis.calculatePointNormals(vertices, faces)\n",
"mesh.normals = threevis.calculate_point_normals(vertices, faces)\n",
"\n",
"\n",
"normal_vis_verts, normal_vis_edges = threevis.calculateNormalEdges(vertices, faces, mesh.normals, 0.5)\n",
"normal_vis_verts, normal_vis_edges = threevis.calculate_normal_edges(vertices, faces, mesh.normals, 0.5)\n",
"\n",
"ctx = threevis.Context()\n",
"\n",
......@@ -107,8 +49,7 @@
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython2",
"version": "2.7"
"pygments_lexer": "ipython2"
}
},
"nbformat": 4,
......
This diff is collapsed.
......@@ -2,39 +2,9 @@
"cells": [
{
"cell_type": "code",
"execution_count": 2,
"execution_count": null,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "3d35adf5ccb54a9cb5f596a3dfcf44a0",
"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=(6.470225173816112, 6.470225173816112, 6.470225173816112), 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=(6.470225173816112, 6.470225173816112, 6.470225173816112), 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.0, 0.10843101143836975, 0.19004550576210022)), 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=(6.470225173816112, 6.470225173816112, 6.470225173816112), 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={'position': <BufferAttribute shape=(17568L, 3L), dtype=float32>, 'uv': <BufferAttribute shape=(17568L, 2L), dtype=float32>, 'normal': <BufferAttribute shape=(17568L, 3L), dtype=float32>, 'index': <BufferAttribute shape=(17568L,), dtype=uint32>}), material=MeshBasicMaterial(alphaMap=None, aoMap=None, color=u'#FFFFFF', envMap=None, lightMap=None, map=ImageTexture(imageUri=u'textures/spot_texture.png', repeat=(1.0, 1.0)), 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))), 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=(6.470225173816112, 6.470225173816112, 6.470225173816112), 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={'position': <BufferAttribute shape=(17568L, 3L), dtype=float32>, 'uv': <BufferAttribute shape=(17568L, 2L), dtype=float32>, 'normal': <BufferAttribute shape=(17568L, 3L), dtype=float32>, 'index': <BufferAttribute shape=(17568L,), dtype=uint32>}), material=MeshBasicMaterial(alphaMap=None, aoMap=None, color=u'#FFFFFF', envMap=None, lightMap=None, map=ImageTexture(imageUri=u'textures/spot_texture.png', repeat=(1.0, 1.0)), 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))), 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"
}
],
"outputs": [],
"source": [
"import threevis\n",
"import openmesh as om\n",
......@@ -48,7 +18,7 @@
"uvs = m.halfedge_texcoords2D()\n",
"\n",
"mesh = threevis.Mesh(vertices, faces, \n",
" normals = threevis.calculatePointNormals(vertices, faces),\n",
" normals = threevis.calculate_point_normals(vertices, faces),\n",
" uvs = threevis.HalfEdgeAttribute(uvs, m.halfedge_vertex_indices(), m.halfedge_face_indices()))\n",
"\n",
"texture = threevis.ImageTexture('textures/spot_texture.png')\n",
......@@ -72,8 +42,7 @@
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython2",
"version": "2.7"
"pygments_lexer": "ipython2"
}
},
"nbformat": 4,
......
......@@ -4,7 +4,7 @@ from ipywidgets import HTML, Text
from traitlets import link, dlink, Bool
from IPython.display import display
from .indexed_attribute import *
from .mesh_helper import calculateFaceNormals, calculatePointNormals
from .mesh_helper import calculate_face_normals, calculate_point_normals
from .mesh import *
class Context(object):
......@@ -41,7 +41,7 @@ class Context(object):
self.click_picker.observe(on_picked, names=['point'])
self.show_bounds = False
self.bounds_enabled = False
def draw(self, obj, shading='flat', z_offset=0.5, texture=None, point_size = 1, perspective = False, line_width = 1, clipping_planes = []):
"""
......@@ -244,22 +244,22 @@ class Context(object):
self.scene.add(mesh_obj)
return self
def setCameraPosition(self, position):
def set_camera_position(self, position):
self.camera.position = tuple(position)
def getCameraPosition(self):
def get_camera_position(self):
return self.camera.position
def showBounds(self):
self.show_bounds = True
def show_bounds(self):
self.bounds_enabled = True
return self
def hideBounds(self):
self.show_bounds = False
def hide_bounds(self):
self.bounds_enabled = False
return self
def setBounds(self, val):
self.show_bounds = val
def set_bounds(self, val):
self.bounds_enabled = val
return self
def draw_text(self, text, position=(0, 0, 0), color='white', size=100, height=1):
......@@ -281,7 +281,7 @@ class Context(object):
self.camera.position = tuple( np.array(self.camera.position) * distance * 5)
self.orbit_controls.target = tuple(center)
if self.show_bounds:
if self.bounds_enabled:
extends = self.maxCorner - self.minCorner
boxEdges = [self.minCorner,
self.minCorner + [extends[0], 0, 0],
......
......@@ -7,19 +7,19 @@ from .context import Context
def display_faces(vertices, face_indices, normals=None, colors=None, uvs=None,
shading='flat', z_offset=0.5, texture=None, width=600, height=400,
background_color = '#dddddd', clipping_planes = [], show_bounds = False):
Context(width, height, background_color).draw_faces(vertices, face_indices, normals, colors, uvs, shading, z_offset, texture, clipping_planes).setBounds(show_bounds).display()
Context(width, height, background_color).draw_faces(vertices, face_indices, normals, colors, uvs, shading, z_offset, texture, clipping_planes).set_bounds(show_bounds).display()
def display_edges(vertices, edge_indices=None, colors=None, uvs=None,
z_offset=0, texture=None, line_width=1, width=600, height=400,
background_color = '#dddddd', clipping_planes = [], show_bounds = False):
Context(width, height, background_color).draw_edges(vertices, edge_indices, colors, uvs, z_offset, texture, line_width, clipping_planes).setBounds(show_bounds).display()
Context(width, height, background_color).draw_edges(vertices, edge_indices, colors, uvs, z_offset, texture, line_width, clipping_planes).set_bounds(show_bounds).display()
def display_vertices(vertices, colors=None, uvs=None, point_size=1, z_offset=0, texture=None,
perspective=False, width=600, height=400,
background_color = '#dddddd', clipping_planes = [], show_bounds = False):
Context(width, height, background_color).draw_vertices(vertices, colors, uvs, point_size, z_offset, texture, perspective, clipping_planes).setBounds(show_bounds).display()
Context(width, height, background_color).draw_vertices(vertices, colors, uvs, point_size, z_offset, texture, perspective, clipping_planes).set_bounds(show_bounds).display()
def display(obj, shading='flat', point_size=1, z_offset=0, texture=None,
perspective=False, width=600, height=400,
background_color = '#dddddd', clipping_planes = [], show_bounds = False):
Context(width, height, background_color).draw(obj, shading= shading, point_size = point_size, z_offset= z_offset, texture = texture, perspective = perspective, clipping_planes = clipping_planes).setBounds(show_bounds).display()
\ No newline at end of file
Context(width, height, background_color).draw(obj, shading= shading, point_size = point_size, z_offset= z_offset, texture = texture, perspective = perspective, clipping_planes = clipping_planes).set_bounds(show_bounds).display()
\ No newline at end of file
import numpy as np
from .mesh_helper import calculateFaceNormals, calculatePointNormals
from .mesh_helper import calculate_face_normals, calculate_point_normals
class Mesh():
"""
......@@ -24,7 +24,7 @@ class Mesh():
def prepare_render(self):
if not self.normals:
self.calculateNormals()
self.calculate_normals()
self.triangulate()
......@@ -40,13 +40,13 @@ class Mesh():
self.uvs.face_remap = self.triangulate_face_to_attribute_face
self.uvs.halfedge_remap = self.attribute_face_vertex_to_triangulate_face_vertex
def calculateNormals(self, normal_element = 'face'):
def calculate_normals(self, normal_element = 'face'):
assert(normal_element is 'face' or normal_element is 'point')
if normal_element is 'face':
self.normals = calculateFaceNormals(self.vertices, self.face_indices)
self.normals = calculate_face_normals(self.vertices, self.face_indices)
else:
self.normals = calculatePointNormals(self.vertices, self.face_indices)
self.normals = calculate_point_normals(self.vertices, self.face_indices)
def triangulate(self):
if self.is_triangulated:
......
......@@ -2,7 +2,7 @@ from .indexed_attribute import FaceAttribute, PointAttribute, resolve_attributes
import numpy as np
def calculateNormalEdges(vertices, face_indices, normals, length):
def calculate_normal_edges(vertices, face_indices, normals, length):
resolved_normals = None
......@@ -32,7 +32,7 @@ def calculateNormalEdges(vertices, face_indices, normals, length):
return edge_vertices, edge_indices
def calculateFaceNormals(vertices, face_indices):
def calculate_face_normals(vertices, face_indices):
values = []
for face in face_indices:
# Assuming face is planar
......@@ -49,7 +49,7 @@ def calculateFaceNormals(vertices, face_indices):
return FaceAttribute(values)
def calculatePointNormals(vertices, face_indices):
def calculate_point_normals(vertices, face_indices):
normals = np.zeros_like(vertices)
counts = np.zeros(vertices.shape[0])
......
import openmesh as om
from pythreejs import *
from .immediate import *
from .immediate import display_faces
def display_openmesh(mesh):
display_faces(mesh.points(), mesh.face_vertex_indices())
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment