Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
fslpy
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Container Registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Michiel Cottaar
fslpy
Commits
dbb01513
Commit
dbb01513
authored
5 years ago
by
Paul McCarthy
Browse files
Options
Downloads
Patches
Plain Diff
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
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
fsl/data/mesh.py
+14
-10
14 additions, 10 deletions
fsl/data/mesh.py
with
14 additions
and
10 deletions
fsl/data/mesh.py
+
14
−
10
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
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment