Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
threevis
threevis
Commits
3ff4f00f
Commit
3ff4f00f
authored
Feb 22, 2018
by
Dario Seyb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed normal edge calculation for non-tri faces
parent
70cd9627
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
57 additions
and
8 deletions
+57
-8
examples/.ipynb_checkpoints/MixedValenceTest-checkpoint.ipynb
...ples/.ipynb_checkpoints/MixedValenceTest-checkpoint.ipynb
+11
-2
examples/MixedValenceTest.ipynb
examples/MixedValenceTest.ipynb
+11
-2
examples/models/model_mixed_valence.obj
examples/models/model_mixed_valence.obj
+33
-0
meshvis/mesh_helper.py
meshvis/mesh_helper.py
+2
-4
No files found.
examples/.ipynb_checkpoints/MixedValenceTest-checkpoint.ipynb
View file @
3ff4f00f
...
...
@@ -11,7 +11,7 @@
"import numpy as np\n",
"\n",
"m = om.PolyMesh()\n",
"om.read_mesh(m, 'models/
spot_quadrangulated
.obj')\n",
"om.read_mesh(m, 'models/
model_mixed_valence
.obj')\n",
"\n",
"vertices = m.points()\n",
"faces = m.face_vertex_indices()\n",
...
...
@@ -19,8 +19,17 @@
"\n",
"mesh = meshvis.Mesh(vertices, faces)\n",
"mesh.colors = meshvis.FaceAttribute(np.random.rand(len(faces), 3))\n",
"mesh.normals = meshvis.calculateFaceNormals(vertices, faces)\n",
"\n",
"meshvis.Context().draw(mesh).draw(meshvis.EdgeList(vertices, edges)).draw(meshvis.PointList(vertices), point_size=5).display()\n",
"normal_vis_verts, normal_vis_edges = meshvis.calculateNormalEdges(vertices, faces, mesh.normals, 1)\n",
"\n",
"ctx = meshvis.Context()\n",
"\n",
"ctx.draw(mesh).draw(meshvis.EdgeList(vertices, edges)).draw(meshvis.PointList(vertices, colors='#aaaaaa'), point_size=3)\n",
"\n",
"ctx.draw_edges(normal_vis_verts, normal_vis_edges)\n",
"\n",
"ctx.display()\n",
"\n"
]
}
...
...
examples/MixedValenceTest.ipynb
View file @
3ff4f00f
...
...
@@ -11,7 +11,7 @@
"import numpy as np\n",
"\n",
"m = om.PolyMesh()\n",
"om.read_mesh(m, 'models/
spot_quadrangulated
.obj')\n",
"om.read_mesh(m, 'models/
model_mixed_valence
.obj')\n",
"\n",
"vertices = m.points()\n",
"faces = m.face_vertex_indices()\n",
...
...
@@ -19,8 +19,17 @@
"\n",
"mesh = meshvis.Mesh(vertices, faces)\n",
"mesh.colors = meshvis.FaceAttribute(np.random.rand(len(faces), 3))\n",
"mesh.normals = meshvis.calculateFaceNormals(vertices, faces)\n",
"\n",
"meshvis.Context().draw(mesh).draw(meshvis.EdgeList(vertices, edges)).draw(meshvis.PointList(vertices), point_size=5).display()\n",
"normal_vis_verts, normal_vis_edges = meshvis.calculateNormalEdges(vertices, faces, mesh.normals, 1)\n",
"\n",
"ctx = meshvis.Context()\n",
"\n",
"ctx.draw(mesh).draw(meshvis.EdgeList(vertices, edges)).draw(meshvis.PointList(vertices, colors='#aaaaaa'), point_size=3)\n",
"\n",
"ctx.draw_edges(normal_vis_verts, normal_vis_edges)\n",
"\n",
"ctx.display()\n",
"\n"
]
}
...
...
examples/models/model_mixed_valence.obj
0 → 100644
View file @
3ff4f00f
# Blender v2.79 (sub 0) OBJ File: ''
# www.blender.org
v -1.000000 -1.000000 1.260390
v -1.000000 1.000000 1.191139
v -1.000000 -1.000000 -1.000000
v -1.000000 1.000000 -1.000000
v 1.000000 -1.000000 1.000000
v 1.000000 1.000000 1.000000
v 1.000000 -1.000000 -1.000000
v 1.000000 1.000000 -1.000000
v -1.000000 0.000000 1.887504
v 2.246086 -1.000000 1.000000
v 2.246086 1.000000 1.000000
v 2.246086 -1.000000 -1.000000
v 2.246086 1.000000 -1.000000
vn -1.0000 0.0000 0.0000
vn 0.0000 0.0000 -1.0000
vn 0.0000 1.0000 0.0000
vn 0.2681 0.0167 0.9632
vn 0.0000 -1.0000 0.0000
vn 1.0000 0.0000 0.0000
vn 0.0000 0.0000 1.0000
s off
f 1//1 9//1 2//1 4//1 3//1
f 3//2 4//2 8//2 13//2 12//2 7//2
f 8//3 6//3 11//3 13//3
f 5//4 6//4 2//4 9//4 1//4
f 3//5 7//5 5//5 1//5
f 4//3 6//3 8//3
f 4//3 2//3 6//3
f 12//6 13//6 11//6 10//6
f 6//7 5//7 10//7 11//7
f 5//5 7//5 12//5 10//5
meshvis/mesh_helper.py
View file @
3ff4f00f
...
...
@@ -10,10 +10,8 @@ def calculateNormalEdges(vertices, face_indices, normals, length):
resolved_normals
=
normals
.
values
face_centers
=
[]
for
face
in
face_indices
:
v1
=
np
.
array
(
vertices
[
face
[
0
]])
v2
=
np
.
array
(
vertices
[
face
[
1
]])
v3
=
np
.
array
(
vertices
[
face
[
2
]])
face_centers
.
append
((
v1
+
v2
+
v3
)
/
3
)
face_vertices
=
vertices
[
face
]
face_centers
.
append
(
np
.
average
(
face_vertices
,
axis
=
0
,
weights
=
face
!=-
1
))
vertices
=
face_centers
else
:
resolved_normals
=
resolve_attributes
(
face_indices
,
[
normals
])[
0
]
...
...
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