Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
Thick Section Point Density
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
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
QIM
Tools
Thick Section Point Density
Commits
ecff0650
Commit
ecff0650
authored
3 years ago
by
hanste
Browse files
Options
Downloads
Patches
Plain Diff
Added files from local to remote
parent
b976e848
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tetrahedralize_triangles.py
+49
-0
49 additions, 0 deletions
tetrahedralize_triangles.py
with
49 additions
and
0 deletions
tetrahedralize_triangles.py
0 → 100644
+
49
−
0
View file @
ecff0650
import
numpy
as
np
def
fix_triangle_normals
(
V
,
F
):
for
i
in
range
(
len
(
F
)):
face
=
F
[
i
]
vertices
=
V
[
face
,:]
V1
=
np
.
pad
(
V
[
1
]
-
V
[
0
],
(
0
,
1
))
V2
=
np
.
pad
(
V
[
2
]
-
V
[
1
],
(
0
,
1
))
if
np
.
cross
(
V1
,
V2
)[
2
]
<
0
:
F
[
i
]
=
F
[
i
][::
-
1
]
return
F
def
check_vertex_ordering
(
V
):
return
np
.
dot
(
np
.
cross
(
V
[
1
]
-
V
[
0
],
V
[
2
]
-
V
[
0
]),
V
[
3
]
-
V
[
0
])
>
0
def
tetrahedralize
(
V_tri
,
F
,
z0
,
z1
):
if
z0
>
z1
:
z0
,
z1
=
z1
,
z0
F
=
fix_triangle_normals
(
V_tri
,
F
)
N
=
len
(
V_tri
)
V_tet
=
np
.
concatenate
([
np
.
pad
(
V_tri
,
((
0
,
0
),
(
0
,
1
)),
constant_values
=
z0
),
np
.
pad
(
V_tri
,
((
0
,
0
),
(
0
,
1
)),
constant_values
=
z1
)
])
T
=
[]
for
face
in
F
:
new_tet
=
[
face
[
0
],
face
[
1
],
face
[
2
],
face
[
0
]
+
N
]
while
not
check_vertex_ordering
(
V_tet
[
new_tet
]):
np
.
random
.
shuffle
(
new_tet
)
T
.
append
(
new_tet
)
new_tet
=
[
face
[
1
],
face
[
2
],
face
[
0
]
+
N
,
face
[
1
]
+
N
]
while
not
check_vertex_ordering
(
V_tet
[
new_tet
]):
np
.
random
.
shuffle
(
new_tet
)
T
.
append
(
new_tet
)
new_tet
=
[
face
[
2
],
face
[
0
]
+
N
,
face
[
1
]
+
N
,
face
[
2
]
+
N
]
while
not
check_vertex_ordering
(
V_tet
[
new_tet
]):
np
.
random
.
shuffle
(
new_tet
)
T
.
append
(
new_tet
)
return
V_tet
,
T
\ No newline at end of file
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