Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Michiel Cottaar
fslpy
Commits
dbb01513
Commit
dbb01513
authored
Nov 09, 2019
by
Paul McCarthy
🚵
Browse files
BF: Make mesh.needsFixing a little more robust? To my knowledge there's no
methoed to do this which is both fast and foolproof
parent
1e9da99c
Changes
1
Hide whitespace changes
Inline
Side-by-side
fsl/data/mesh.py
View file @
dbb01513
...
...
@@ -758,15 +758,19 @@ def needsFixing(vertices, indices, fnormals, loBounds, hiBounds):
ivert
=
np
.
argmin
(
dists
)
vert
=
vertices
[
ivert
]
#
Pick a
triangle
that
# this vertex is in
and
#
ges its
face normal
itri
=
np
.
where
(
indices
==
ivert
)[
0
]
[
0
]
n
=
fnormals
[
itri
,
:]
#
Get all the
triangle
s
#
that
this vertex is in
#
and their
face normal
s
itri
s
=
np
.
where
(
indices
==
ivert
)[
0
]
n
orms
=
fnormals
[
itri
s
,
:]
#
Make sur
e the angle between
the
#
Calculat
e the angle between
each
# normal, and a vector from the
# vertex to the camera is positive
# If it isn't, we need to flip the
# triangle winding order.
return
np
.
dot
(
n
,
affine
.
normalise
(
camera
-
vert
))
<
0
# vertex to the camera. If more than
# 50% of the angles are negative
# (== more than 90 degrees == the
# face is facing away from the
# camera), assume that we need to
# flip the triangle winding order.
angles
=
np
.
dot
(
norms
,
affine
.
normalise
(
camera
-
vert
))
return
((
angles
>
0
).
sum
()
/
len
(
itris
))
<
0.5
Write
Preview
Supports
Markdown
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