Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
AmpScan
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
Joshua Steer
AmpScan
Commits
8601eb82
Commit
8601eb82
authored
6 years ago
by
Joshua Steer
Browse files
Options
Downloads
Patches
Plain Diff
Functionality to fix normals through flipping
parent
a0a23105
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
AmpScan/core.py
+29
-1
29 additions, 1 deletion
AmpScan/core.py
with
29 additions
and
1 deletion
AmpScan/core.py
+
29
−
1
View file @
8601eb82
...
...
@@ -100,6 +100,7 @@ class AmpObject(trimMixin, smoothMixin, analyseMixin, visMixin):
if
unify
is
True
:
self
.
unifyVert
()
# Call function to calculate the edges array
# self.fixNorm()
if
struc
is
True
:
self
.
calcStruct
()
self
.
values
=
np
.
zeros
([
len
(
self
.
vert
)])
...
...
@@ -243,6 +244,18 @@ class AmpObject(trimMixin, smoothMixin, analyseMixin, visMixin):
mag
=
np
.
linalg
.
norm
(
norms
,
axis
=
1
)
self
.
norm
=
np
.
divide
(
norms
,
mag
[:,
None
])
def
fixNorm
(
self
):
r
"""
Fix normals of faces so they all face outwards
"""
fC
=
self
.
vert
[
self
.
faces
].
mean
(
axis
=
1
)
cent
=
self
.
vert
.
mean
(
axis
=
0
)
polarity
=
np
.
sum
(
self
.
norm
*
(
fC
-
cent
),
axis
=
1
)
<
0
if
polarity
.
mean
()
>
0.5
:
self
.
faces
[:,
[
1
,
2
]]
=
self
.
faces
[:,
[
2
,
1
]]
self
.
calcNorm
()
if
hasattr
(
self
,
'
vNorm
'
):
self
.
calcVNorm
()
def
calcVNorm
(
self
):
"""
Function to compute the vertex normals based upon the mean of the
...
...
@@ -372,7 +385,6 @@ class AmpObject(trimMixin, smoothMixin, analyseMixin, visMixin):
self
.
translate
(
T
)
@staticmethod
def
rotMatrix
(
rot
,
ang
=
'
rad
'
):
r
"""
...
...
@@ -406,3 +418,19 @@ class AmpObject(trimMixin, smoothMixin, analyseMixin, visMixin):
[
0
,
0
,
1
]])
R
=
np
.
dot
(
np
.
dot
(
Rz
,
Ry
),
Rx
)
return
R
def
flip
(
self
,
axis
=
1
):
r
"""
Flip the mesh in a plane
Parameters
----------
axis: int, default 1
The axis in which to flip the mesh
"""
self
.
vert
[:,
axis
]
*=
-
1.0
# Switch face order to normals face same direction
self
.
faces
[:,
[
1
,
2
]]
=
self
.
faces
[:,
[
2
,
1
]]
self
.
calcNorm
()
self
.
calcVNorm
()
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