Skip to content

Commit de655b3

Browse files
authored
Move TetGen README mesh to src (#170)
1 parent 65e0d62 commit de655b3

File tree

4 files changed

+56
-66
lines changed

4 files changed

+56
-66
lines changed

src/Meshes.jl

Lines changed: 40 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
11
module Meshes
22

33
using Artifacts
4-
using Catlab, Catlab.CategoricalAlgebra
5-
using CombinatorialSpaces, CombinatorialSpaces.SimplicialSets
4+
using Catlab
5+
using CombinatorialSpaces
66
using FileIO
7+
using GeometryBasics: Mesh, MetaMesh, Point, Point2d, Point3d, QuadFace
78
using JSON
89
using LinearAlgebra: diagm
9-
using GeometryBasics: Point2d, Point3d, Point, QuadFace, Mesh
1010
using TetGen
1111

1212
export loadmesh, Icosphere, Rectangle_30x10, Torus_30x10, Point_Map,
13-
triangulated_grid, makeSphere, mirrored_mesh, parallelepiped
13+
triangulated_grid, makeSphere, mirrored_mesh, parallelepiped,
14+
tetgen_readme_mesh
1415

1516
abstract type AbstractMeshKey end
1617

@@ -416,9 +417,13 @@ Uses TetGen to generate turn a specificed parallelepiped to a tetrahedralized me
416417
Default TetGen command is "pQq1.414a0.1" and user desired cmds can be passed through the `tetcmd` kwarg.
417418
"""
418419
function parallelepiped(;lx::Real = 1.0, ly::Real = 1.0, lz::Real = 1.0, dx::Real = 0.0, dy::Real = 0.0, point_type = Point3d, tetcmd::String = "pQq1.414a0.1")
419-
points = point_type[(0.0, 0.0, 0.0), (dx, dy, lz), (0.0, ly, 0.0), (dx, ly+dy, lz), (lx, 0.0, 0.0), (lx+dx, dy, lz), (lx, ly, 0.0), (lx+dx, ly+dy, lz)]
420+
points = point_type[
421+
(0.0, 0.0, 0.0), (dx, dy, lz), (0.0, ly, 0.0), (dx, ly+dy, lz),
422+
(lx, 0.0, 0.0), (lx+dx, dy, lz), (lx, ly, 0.0), (lx+dx, ly+dy, lz)]
420423

421-
faces = QuadFace{Cint}[[1,2,4,3], [5,6,8,7], [1,2,6,5], [3,4,8,7], [1,3,7,5], [2,4,8,6]]
424+
faces = QuadFace{Cint}[
425+
[1,2,4,3], [5,6,8,7], [1,2,6,5],
426+
[3,4,8,7], [1,3,7,5], [2,4,8,6]]
422427

423428
tet_mesh = tetrahedralize(Mesh(points, faces), tetcmd)
424429

@@ -431,4 +436,33 @@ function parallelepiped(;lx::Real = 1.0, ly::Real = 1.0, lz::Real = 1.0, dx::Rea
431436
return s
432437
end
433438

439+
""" function tetgen_readme_mesh()
440+
441+
Create the mesh from the TetGen.jl/README.md as a delta set.
442+
443+
https://github.com/JuliaGeometry/TetGen.jl/blob/ea73adce3ea4dfa6062eb84b1eff05f3fcab60a5/README.md
444+
"""
445+
function tetgen_readme_mesh()
446+
points = Point{3, Float64}[
447+
(0.0, 0.0, 0.0), (2.0, 0.0, 0.0),
448+
(2.0, 2.0, 0.0), (0.0, 2.0, 0.0),
449+
(0.0, 0.0, 12.0), (2.0, 0.0, 12.0),
450+
(2.0, 2.0, 12.0), (0.0, 2.0, 12.0)]
451+
facets = QuadFace{Cint}[
452+
1:4, 5:8,
453+
[1,5,6,2],
454+
[2,6,7,3],
455+
[3, 7, 8, 4],
456+
[4, 8, 5, 1]]
457+
markers = Cint[-1, -2, 0, 0, 0, 0]
458+
msh = MetaMesh(points, facets; markers)
459+
tet_msh = tetrahedralize(msh, "Qvpq1.414a0.1")
460+
s = EmbeddedDeltaSet3D(tet_msh)
461+
orient!(s)
462+
s[:edge_orientation] = false
463+
s[:tri_orientation] = false
464+
s
434465
end
466+
467+
end
468+

test/DiscreteExteriorCalculus.jl

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ using LinearAlgebra: Diagonal, mul!, norm, dot, cross
1414
using SparseArrays
1515
using StaticArrays
1616
using Statistics: mean, median
17-
using TetGen
1817

1918
# 1D dual complex
2019
#################
@@ -1000,27 +999,7 @@ dZ = d0 * map(p -> p[3], s[:point])
1000999

10011000
# Test the 2-1 wedge product on a larger mesh.
10021001

1003-
# Create the mesh from the TetGen.jl/README.md.
1004-
# https://github.com/JuliaGeometry/TetGen.jl/blob/ea73adce3ea4dfa6062eb84b1eff05f3fcab60a5/README.md
1005-
function tetgen_readme_mesh()
1006-
points = Point{3, Float64}[
1007-
(0.0, 0.0, 0.0), (2.0, 0.0, 0.0),
1008-
(2.0, 2.0, 0.0), (0.0, 2.0, 0.0),
1009-
(0.0, 0.0, 12.0), (2.0, 0.0, 12.0),
1010-
(2.0, 2.0, 12.0), (0.0, 2.0, 12.0)]
1011-
facets = QuadFace{Cint}[
1012-
1:4, 5:8,
1013-
[1,5,6,2],
1014-
[2,6,7,3],
1015-
[3, 7, 8, 4],
1016-
[4, 8, 5, 1]]
1017-
markers = Cint[-1, -2, 0, 0, 0, 0]
1018-
mesh = MetaMesh(points, facets; markers)
1019-
mesh, tetrahedralize(mesh, "Qvpq1.414a0.1");
1020-
end
1021-
msh, tet_msh = tetgen_readme_mesh()
1022-
1023-
primal_s = EmbeddedDeltaSet3D(tet_msh)
1002+
primal_s = tetgen_readme_mesh()
10241003
s = EmbeddedDeltaDualComplex3D{Bool, Float64, Point3d}(primal_s)
10251004
subdivide_duals!(s, Barycenter())
10261005

test/MeshInterop.jl

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -51,23 +51,20 @@ sd_to_mesh = Mesh(sd)
5151
#---------------------
5252
# Create mesh from the TetGen.jl/README.md.
5353
# https://github.com/JuliaGeometry/TetGen.jl/blob/ea73adce3ea4dfa6062eb84b1eff05f3fcab60a5/README.md
54-
function tetgen_readme_mesh()
55-
points = Point{3, Float64}[
56-
(0.0, 0.0, 0.0), (2.0, 0.0, 0.0),
57-
(2.0, 2.0, 0.0), (0.0, 2.0, 0.0),
58-
(0.0, 0.0, 12.0), (2.0, 0.0, 12.0),
59-
(2.0, 2.0, 12.0), (0.0, 2.0, 12.0)]
60-
facets = QuadFace{Cint}[
61-
1:4, 5:8,
62-
[1,5,6,2],
63-
[2,6,7,3],
64-
[3, 7, 8, 4],
65-
[4, 8, 5, 1]]
66-
markers = Cint[-1, -2, 0, 0, 0, 0]
67-
mesh = GeometryBasics.MetaMesh(points, facets; markers)
68-
mesh, tetrahedralize(mesh, "Qvpq1.414a0.1");
69-
end
70-
msh, tet_msh = tetgen_readme_mesh()
54+
points = Point{3, Float64}[
55+
(0.0, 0.0, 0.0), (2.0, 0.0, 0.0),
56+
(2.0, 2.0, 0.0), (0.0, 2.0, 0.0),
57+
(0.0, 0.0, 12.0), (2.0, 0.0, 12.0),
58+
(2.0, 2.0, 12.0), (0.0, 2.0, 12.0)]
59+
facets = QuadFace{Cint}[
60+
1:4, 5:8,
61+
[1,5,6,2],
62+
[2,6,7,3],
63+
[3, 7, 8, 4],
64+
[4, 8, 5, 1]]
65+
markers = Cint[-1, -2, 0, 0, 0, 0]
66+
msh = GeometryBasics.MetaMesh(points, facets; markers)
67+
tet_msh = tetrahedralize(msh, "Qvpq1.414a0.1")
7168

7269
# Import.
7370
s = EmbeddedDeltaSet3D(tet_msh)

test/Operators.jl

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ using GeometryBasics: Point, QuadFace, MetaMesh
1212
using Random
1313
using StaticArrays: SVector
1414
using Statistics: mean, var, std
15-
using TetGen
1615

1716
Random.seed!(0)
1817

@@ -64,26 +63,7 @@ subdivide_duals!(rect, Barycenter());
6463

6564
flat_meshes = [tri_345()[2], tri_345_false()[2], right_scalene_unit_hypot()[2], grid_345()[2], tg, rect];
6665

67-
# Create mesh from the TetGen.jl/README.md.
68-
# https://github.com/JuliaGeometry/TetGen.jl/blob/ea73adce3ea4dfa6062eb84b1eff05f3fcab60a5/README.md
69-
function tetgen_readme_mesh()
70-
points = Point{3, Float64}[
71-
(0.0, 0.0, 0.0), (2.0, 0.0, 0.0),
72-
(2.0, 2.0, 0.0), (0.0, 2.0, 0.0),
73-
(0.0, 0.0, 12.0), (2.0, 0.0, 12.0),
74-
(2.0, 2.0, 12.0), (0.0, 2.0, 12.0)]
75-
facets = QuadFace{Cint}[
76-
1:4, 5:8,
77-
[1,5,6,2],
78-
[2,6,7,3],
79-
[3, 7, 8, 4],
80-
[4, 8, 5, 1]]
81-
markers = Cint[-1, -2, 0, 0, 0, 0]
82-
mesh = MetaMesh(points, facets; markers)
83-
mesh, tetrahedralize(mesh, "Qvpq1.414a0.1");
84-
end
85-
_, tet_msh = tetgen_readme_mesh()
86-
tet_msh = EmbeddedDeltaSet3D(tet_msh)
66+
tet_msh = tetgen_readme_mesh()
8767
tet_msh_sd = EmbeddedDeltaDualComplex3D{Bool, Float64, Point3d}(tet_msh)
8868
subdivide_duals!(tet_msh_sd, Circumcenter())
8969

0 commit comments

Comments
 (0)