Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
threevis
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
11
Issues
11
List
Boards
Labels
Service Desk
Milestones
Operations
Operations
Incidents
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
threevis
threevis
Commits
7d8ed414
Commit
7d8ed414
authored
Feb 01, 2018
by
Dario Seyb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
made PointAttribute much faster
parent
e05e5646
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
63 additions
and
72 deletions
+63
-72
examples/.ipynb_checkpoints/Untitled-checkpoint.ipynb
examples/.ipynb_checkpoints/Untitled-checkpoint.ipynb
+27
-33
examples/Untitled.ipynb
examples/Untitled.ipynb
+26
-32
meshvis/indexed_attribute.py
meshvis/indexed_attribute.py
+10
-7
No files found.
examples/.ipynb_checkpoints/Untitled-checkpoint.ipynb
View file @
7d8ed414
...
...
@@ -2,7 +2,7 @@
"cells": [
{
"cell_type": "code",
"execution_count":
2
,
"execution_count":
3
,
"metadata": {
"scrolled": false
},
...
...
@@ -10,7 +10,7 @@
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "
91d57b1f16a144659c45e17cc4163f4a
",
"model_id": "
4070011fb1214209bacf3ffd7b6a094d
",
"version_major": 2,
"version_minor": 0
},
...
...
@@ -30,49 +30,43 @@
"</p>\n"
],
"text/plain": [
"Renderer(background='#dddddd', camera=PerspectiveCamera(aspect=1.3333333333333333, 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=(3.0, 3.0, 3.0), 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.3333333333333333, 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=(3.0, 3.0, 3.0), quaternion=(0.0, 0.0, 0.0, 1.0), scale=(1.0, 1.0, 1.0), up=(0.0, 1.0, 0.0)))], 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.3333333333333333, 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=(3.0, 3.0, 3.0), 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(array=array([[0.
11732402, 0.6847934 , 0.6164344
],\n",
" [0.
11732402, 0.6847934 , 0.6164344
],\n",
" [0.
11732402, 0.6847934 , 0.6164344
],\n",
"Renderer(background='#dddddd', camera=PerspectiveCamera(aspect=1.3333333333333333, 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=(3.0, 3.0, 3.0), 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.3333333333333333, 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=(3.0, 3.0, 3.0), quaternion=(0.0, 0.0, 0.0, 1.0), scale=(1.0, 1.0, 1.0), up=(0.0, 1.0, 0.0)))], 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.3333333333333333, 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=(3.0, 3.0, 3.0), 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(array=array([[0.
7048854 , 0.19333012, 0.83984125
],\n",
" [0.
7048854 , 0.19333012, 0.83984125
],\n",
" [0.
7048854 , 0.19333012, 0.83984125
],\n",
" ...,\n",
" [0.
9562925 , 0.08487827, 0.7201913
],\n",
" [0.
9562925 , 0.08487827, 0.7201913
],\n",
" [0.
9562925 , 0.08487827, 0.7201913 ]], dtype=float32)), 'index': BufferAttribute(array=array([ 0, 1, 2, ..., 20457, 20458, 20459], dtype=uint16), normalized=False), 'normal': BufferAttribute(array=array([[ 0.20979331, 0.07998422, -0.9744687
],\n",
" [ 0.
20979331, 0.07998422, -0.9744687
],\n",
" [ 0.
20979331, 0.07998422, -0.9744687
],\n",
" [0.
8403377 , 0.21791874, 0.98012495
],\n",
" [0.
8403377 , 0.21791874, 0.98012495
],\n",
" [0.
8403377 , 0.21791874, 0.98012495]], dtype=float32)), 'index': BufferAttribute(array=array([ 0, 1, 2, ..., 20457, 20458, 20459], dtype=uint16), normalized=False), 'normal': BufferAttribute(array=array([[ 0.29923597, 0.209352 , -0.9309294
],\n",
" [ 0.
34789708, 0.10039929, -0.9321414
],\n",
" [ 0.
15907033, 0.06733694, -0.9849682
],\n",
" ...,\n",
" [-0.13
065 , 0.8949016 , -0.4267104
],\n",
" [-0.1
3065 , 0.8949016 , -0.4267104
],\n",
" [-0.1
3065 , 0.8949016 , -0.4267104
]], dtype=float32)), 'position': BufferAttribute(array=array([[-0.283628, 2.931106, -0.140772],\n",
" [-0.13
178219, 0.90176684, -0.41164303
],\n",
" [-0.1
2657353, 0.92504686, -0.35814443
],\n",
" [-0.1
2895663, 0.91968286, -0.37088218
]], dtype=float32)), 'position': BufferAttribute(array=array([[-0.283628, 2.931106, -0.140772],\n",
" [-0.22873 , 2.855558, -0.135154],\n",
" [-0.34671 , 2.856239, -0.160498],\n",
" ...,\n",
" [ 0.280426, 0.4863 , -0.003152],\n",
" [ 0.332014, 0.467158, -0.059092],\n",
" [ 0.216602, 0.471758, -0.014108]], dtype=float32), normalized=False)}), 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={'color': BufferAttribute(array=array([[0.
41086063, 0.10705473, 0.8429296
],\n",
" [0.
41086063, 0.10705473, 0.8429296
],\n",
" [0.2
5787306, 0.22192806, 0.9668249
],\n",
" [ 0.216602, 0.471758, -0.014108]], dtype=float32), normalized=False)}), 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={'color': BufferAttribute(array=array([[0.
8298772 , 0.3087851 , 0.42418373
],\n",
" [0.
8298772 , 0.3087851 , 0.42418373
],\n",
" [0.2
4034402, 0.9740283 , 0.01827334
],\n",
" ...,\n",
" [0.
19065575, 0.32614255, 0.4982505
],\n",
" [0.
67401946, 0.3399039 , 0.20301984
],\n",
" [0.
67401946, 0.3399039 , 0.20301984
]], dtype=float32)), 'index': BufferAttribute(array=array([ 0, 1, 2, ..., 20569, 20570, 20571], dtype=uint16), normalized=False), 'position': BufferAttribute(array=array([[-0.283628, 2.931106, -0.140772],\n",
" [0.
9811828 , 0.08381105, 0.98115414
],\n",
" [0.
06608333, 0.54907537, 0.93927246
],\n",
" [0.
06608333, 0.54907537, 0.93927246
]], dtype=float32)), 'index': BufferAttribute(array=array([ 0, 1, 2, ..., 20569, 20570, 20571], dtype=uint16), normalized=False), 'position': BufferAttribute(array=array([[-0.283628, 2.931106, -0.140772],\n",
" [-0.22873 , 2.855558, -0.135154],\n",
" [-0.22873 , 2.855558, -0.135154],\n",
" ...,\n",
" [ 0.157628, 0.430178, -0.130118],\n",
" [ 0.216602, 0.471758, -0.014108],\n",
" [ 0.332014, 0.467158, -0.059092]], dtype=float32), normalized=False)}), material=LineBasicMaterial(color=u'white', linewidth=3.0, 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={'color': BufferAttribute(array=array([[0.11732402, 0.6847934 , 0.6164344 ],\n",
" [0.11732402, 0.6847934 , 0.6164344 ],\n",
" [0.534379 , 0.6637605 , 0.7090333 ],\n",
" ...,\n",
" [0.3699593 , 0.6580512 , 0.21494888],\n",
" [0.9562925 , 0.08487827, 0.7201913 ],\n",
" [0.9562925 , 0.08487827, 0.7201913 ]], dtype=float32)), 'index': BufferAttribute(array=array([ 0, 1, 2, ..., 13637, 13638, 13639], dtype=uint16), normalized=False), 'position': BufferAttribute(array=array([[-0.286356 , 2.8809676 , -0.14547466],\n",
" [-0.26537666, 2.888966 , -0.24292153],\n",
" [-0.295662 , 2.8398848 , -0.15085067],\n",
" [ 0.332014, 0.467158, -0.059092]], dtype=float32), normalized=False)}), material=LineBasicMaterial(color=u'white', linewidth=3.0, 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, ..., 40917, 40918, 40919], dtype=uint16), normalized=False), 'position': BufferAttribute(array=array([[-0.283628 , 2.931106 , -0.140772 ],\n",
" [-0.26866618, 2.9415736 , -0.18731847],\n",
" [-0.22873 , 2.855558 , -0.135154 ],\n",
" ...,\n",
" [ 0.
2812651 , 0.5552246 , -0.09855373
],\n",
" [ 0.2
7634734, 0.475072 , -0.02545067
],\n",
" [ 0.2
6328233, 0.56456214, -0.06812171]], 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)), Points(geometry=BufferGeometry(attributes={'position': BufferAttribute(array=array([[-0.283628, 2.931106, -0.140772],\n",
" [ 0.
32568532, 0.51341033, -0.07699922
],\n",
" [ 0.2
16602 , 0.471758 , -0.014108
],\n",
" [ 0.2
1015416, 0.51774216, -0.03265211]], dtype=float32), normalized=False)}), 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)), Points(geometry=BufferGeometry(attributes={'position': BufferAttribute(array=array([[-0.283628, 2.931106, -0.140772],\n",
" [-0.22873 , 2.855558, -0.135154],\n",
" [-0.34671 , 2.856239, -0.160498],\n",
" ...,\n",
...
...
@@ -97,7 +91,7 @@
"vertices = m.points()\n",
"faces = m.face_vertex_indices()\n",
"\n",
"normals = meshvis.calculate
Face
Normals(m.points(), m.face_vertex_indices())\n",
"normals = meshvis.calculate
Point
Normals(m.points(), m.face_vertex_indices())\n",
"colors = meshvis.FaceAttribute(np.random.rand(len(faces), 3))\n",
"ctx.draw_faces(vertices, faces, \n",
" normals = normals,\n",
...
...
@@ -110,7 +104,7 @@
"\n",
"normal_vis_verts, normal_vis_edges = meshvis.calculateNormalEdges(m.points(), m.face_vertex_indices(), normals, 0.05)\n",
"\n",
"ctx.draw_edges(normal_vis_verts, normal_vis_edges
, colors = colors
)\n",
"ctx.draw_edges(normal_vis_verts, normal_vis_edges)\n",
"\n",
"ctx.draw_vertices(m.points(), point_size=4, colors='red')\n",
"\n",
...
...
examples/Untitled.ipynb
View file @
7d8ed414
...
...
@@ -10,7 +10,7 @@
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "
1558a7bf2c4f471cac251088180c3b17
",
"model_id": "
4070011fb1214209bacf3ffd7b6a094d
",
"version_major": 2,
"version_minor": 0
},
...
...
@@ -30,49 +30,43 @@
"</p>\n"
],
"text/plain": [
"Renderer(background='#dddddd', camera=PerspectiveCamera(aspect=1.3333333333333333, 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=(3.0, 3.0, 3.0), 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.3333333333333333, 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=(3.0, 3.0, 3.0), quaternion=(0.0, 0.0, 0.0, 1.0), scale=(1.0, 1.0, 1.0), up=(0.0, 1.0, 0.0)))], 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.3333333333333333, 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=(3.0, 3.0, 3.0), 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(array=array([[0.
4963839 , 0.88896775, 0.7816435
],\n",
" [0.
4963839 , 0.88896775, 0.7816435
],\n",
" [0.
4963839 , 0.88896775, 0.7816435
],\n",
"Renderer(background='#dddddd', camera=PerspectiveCamera(aspect=1.3333333333333333, 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=(3.0, 3.0, 3.0), 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.3333333333333333, 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=(3.0, 3.0, 3.0), quaternion=(0.0, 0.0, 0.0, 1.0), scale=(1.0, 1.0, 1.0), up=(0.0, 1.0, 0.0)))], 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.3333333333333333, 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=(3.0, 3.0, 3.0), 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(array=array([[0.
7048854 , 0.19333012, 0.83984125
],\n",
" [0.
7048854 , 0.19333012, 0.83984125
],\n",
" [0.
7048854 , 0.19333012, 0.83984125
],\n",
" ...,\n",
" [0.
5360408 , 0.36832646, 0.44506806
],\n",
" [0.
5360408 , 0.36832646, 0.44506806
],\n",
" [0.
5360408 , 0.36832646, 0.44506806]], dtype=float32)), 'index': BufferAttribute(array=array([ 0, 1, 2, ..., 20457, 20458, 20459], dtype=uint16), normalized=False), 'normal': BufferAttribute(array=array([[ 0.20979331, 0.07998422, -0.9744687
],\n",
" [ 0.
20979331, 0.07998422, -0.9744687
],\n",
" [ 0.
20979331, 0.07998422, -0.9744687
],\n",
" [0.
8403377 , 0.21791874, 0.98012495
],\n",
" [0.
8403377 , 0.21791874, 0.98012495
],\n",
" [0.
8403377 , 0.21791874, 0.98012495]], dtype=float32)), 'index': BufferAttribute(array=array([ 0, 1, 2, ..., 20457, 20458, 20459], dtype=uint16), normalized=False), 'normal': BufferAttribute(array=array([[ 0.29923597, 0.209352 , -0.9309294
],\n",
" [ 0.
34789708, 0.10039929, -0.9321414
],\n",
" [ 0.
15907033, 0.06733694, -0.9849682
],\n",
" ...,\n",
" [-0.13
065 , 0.8949016 , -0.4267104
],\n",
" [-0.1
3065 , 0.8949016 , -0.4267104
],\n",
" [-0.1
3065 , 0.8949016 , -0.4267104
]], dtype=float32)), 'position': BufferAttribute(array=array([[-0.283628, 2.931106, -0.140772],\n",
" [-0.13
178219, 0.90176684, -0.41164303
],\n",
" [-0.1
2657353, 0.92504686, -0.35814443
],\n",
" [-0.1
2895663, 0.91968286, -0.37088218
]], dtype=float32)), 'position': BufferAttribute(array=array([[-0.283628, 2.931106, -0.140772],\n",
" [-0.22873 , 2.855558, -0.135154],\n",
" [-0.34671 , 2.856239, -0.160498],\n",
" ...,\n",
" [ 0.280426, 0.4863 , -0.003152],\n",
" [ 0.332014, 0.467158, -0.059092],\n",
" [ 0.216602, 0.471758, -0.014108]], dtype=float32), normalized=False)}), 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={'color': BufferAttribute(array=array([[0.
5837198 , 0.72584784, 0.22937745
],\n",
" [0.
5837198 , 0.72584784, 0.22937745
],\n",
" [0.
11128911, 0.5174707 , 0.7444728
],\n",
" [ 0.216602, 0.471758, -0.014108]], dtype=float32), normalized=False)}), 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={'color': BufferAttribute(array=array([[0.
8298772 , 0.3087851 , 0.42418373
],\n",
" [0.
8298772 , 0.3087851 , 0.42418373
],\n",
" [0.
24034402, 0.9740283 , 0.01827334
],\n",
" ...,\n",
" [0.9
277531 , 0.6908932 , 0.48642585
],\n",
" [0.0
7398918, 0.08555599, 0.94079673
],\n",
" [0.0
7398918, 0.08555599, 0.94079673
]], dtype=float32)), 'index': BufferAttribute(array=array([ 0, 1, 2, ..., 20569, 20570, 20571], dtype=uint16), normalized=False), 'position': BufferAttribute(array=array([[-0.283628, 2.931106, -0.140772],\n",
" [0.9
811828 , 0.08381105, 0.98115414
],\n",
" [0.0
6608333, 0.54907537, 0.93927246
],\n",
" [0.0
6608333, 0.54907537, 0.93927246
]], dtype=float32)), 'index': BufferAttribute(array=array([ 0, 1, 2, ..., 20569, 20570, 20571], dtype=uint16), normalized=False), 'position': BufferAttribute(array=array([[-0.283628, 2.931106, -0.140772],\n",
" [-0.22873 , 2.855558, -0.135154],\n",
" [-0.22873 , 2.855558, -0.135154],\n",
" ...,\n",
" [ 0.157628, 0.430178, -0.130118],\n",
" [ 0.216602, 0.471758, -0.014108],\n",
" [ 0.332014, 0.467158, -0.059092]], dtype=float32), normalized=False)}), material=LineBasicMaterial(color=u'white', linewidth=3.0, 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={'
color': BufferAttribute(array=array([[0.4963839 , 0.88896775, 0.7816435
],\n",
" [
0.4963839 , 0.88896775, 0.7816435
],\n",
" [
0.78466433, 0.00725824, 0.5387747
],\n",
" [ 0.332014, 0.467158, -0.059092]], dtype=float32), normalized=False)}), material=LineBasicMaterial(color=u'white', linewidth=3.0, 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, ..., 40917, 40918, 40919], dtype=uint16), normalized=False), 'position': BufferAttribute(array=array([[-0.283628 , 2.931106 , -0.140772
],\n",
" [
-0.26866618, 2.9415736 , -0.18731847
],\n",
" [
-0.22873 , 2.855558 , -0.135154
],\n",
" ...,\n",
" [0.01393902, 0.95735204, 0.3766971 ],\n",
" [0.5360408 , 0.36832646, 0.44506806],\n",
" [0.5360408 , 0.36832646, 0.44506806]], dtype=float32)), 'index': BufferAttribute(array=array([ 0, 1, 2, ..., 13637, 13638, 13639], dtype=uint16), normalized=False), 'position': BufferAttribute(array=array([[-0.286356 , 2.8809676 , -0.14547466],\n",
" [-0.27586633, 2.8849669 , -0.1941981 ],\n",
" [-0.295662 , 2.8398848 , -0.15085067],\n",
" ...,\n",
" [ 0.2855232 , 0.50796396, -0.0827962 ],\n",
" [ 0.27634734, 0.475072 , -0.02545067],\n",
" [ 0.26981482, 0.51981705, -0.04678619]], 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)), Points(geometry=BufferGeometry(attributes={'position': BufferAttribute(array=array([[-0.283628, 2.931106, -0.140772],\n",
" [ 0.32568532, 0.51341033, -0.07699922],\n",
" [ 0.216602 , 0.471758 , -0.014108 ],\n",
" [ 0.21015416, 0.51774216, -0.03265211]], dtype=float32), normalized=False)}), 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)), Points(geometry=BufferGeometry(attributes={'position': BufferAttribute(array=array([[-0.283628, 2.931106, -0.140772],\n",
" [-0.22873 , 2.855558, -0.135154],\n",
" [-0.34671 , 2.856239, -0.160498],\n",
" ...,\n",
...
...
@@ -97,7 +91,7 @@
"vertices = m.points()\n",
"faces = m.face_vertex_indices()\n",
"\n",
"normals = meshvis.calculate
Face
Normals(m.points(), m.face_vertex_indices())\n",
"normals = meshvis.calculate
Point
Normals(m.points(), m.face_vertex_indices())\n",
"colors = meshvis.FaceAttribute(np.random.rand(len(faces), 3))\n",
"ctx.draw_faces(vertices, faces, \n",
" normals = normals,\n",
...
...
@@ -110,7 +104,7 @@
"\n",
"normal_vis_verts, normal_vis_edges = meshvis.calculateNormalEdges(m.points(), m.face_vertex_indices(), normals, 0.05)\n",
"\n",
"ctx.draw_edges(normal_vis_verts, normal_vis_edges
, colors = colors
)\n",
"ctx.draw_edges(normal_vis_verts, normal_vis_edges)\n",
"\n",
"ctx.draw_vertices(m.points(), point_size=4, colors='red')\n",
"\n",
...
...
meshvis/indexed_attribute.py
View file @
7d8ed414
...
...
@@ -64,15 +64,18 @@ class PointAttribute(IndexedAttribute):
def
resolve
(
self
,
face_indices
):
result
=
[]
vertex_to_face
=
dict
()
for
fidx
,
face
in
enumerate
(
face_indices
):
for
index_in_face
,
vidx
in
enumerate
(
face
):
if
vidx
not
in
vertex_to_face
:
vertex_to_face
[
vidx
]
=
[]
vertex_to_face
[
vidx
].
append
((
fidx
,
index_in_face
))
for
i
,
val
in
enumerate
(
self
.
values
):
idx
=
self
.
indices
[
i
]
# find all faces that contain the vertex
for
f_idx
,
face
in
enumerate
(
face_indices
):
# check if vertex is in face
idx_in_face
=
find
(
idx
,
face
)
# if yes, add value for vertex in that face
if
idx_in_face
is
not
None
:
result
.
append
((
f_idx
,
idx_in_face
,
val
))
if
idx
in
vertex_to_face
:
for
occurence
in
vertex_to_face
[
idx
]:
result
.
append
((
occurence
[
0
],
occurence
[
1
],
val
))
return
result
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment