-
Notifications
You must be signed in to change notification settings - Fork 4
/
demo_regiontrimesh.jl
118 lines (91 loc) · 2.94 KB
/
demo_regiontrimesh.jl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
using Comodo
using GLMakie
using GeometryBasics
#=
This demo shows the use of `hexbox` to generate a hexahedral mesh for a 3D box
domain.
=#
testCase = 5
if testCase == 1 # Batman curve
n = 120
V = batman(n; symmetric=true)
pointSpacing = pointspacingmean(V)
VT = (V,)
R = ([1],)
P = (pointSpacing)
elseif testCase == 2
n = 50
r = 2.0
V = circlepoints(r,n;dir=:acw)
pointSpacing = pointspacingmean(V)
VT = (V,)
R = ([1],)
P = (pointSpacing)
elseif testCase == 3
n = 100
r = 1.0
rFun(t) = r + 0.5.*sin(6*t)
V = circlepoints(rFun,n; dir=:acw)
V = evenly_sample(V, n)
pointSpacing = pointspacingmean(V)
VT = (V,)
R = ([1],)
P = (pointSpacing)
elseif testCase == 4
rFun1(t) = 12.0 + 3.0.*sin(5*t)
n1 = 120
V1 = circlepoints(rFun1,n1)
V1 = evenly_sample(V1,n1)
rFun2(t) = 10.0 + 2.0.*sin(5*t)
n2 = 100
V2 = circlepoints(rFun2,n2)
V2 = evenly_sample(V2,n2)
rFun3(t) = 2.0 + 0.5 *sin(5*t)
n3 = 50
Vp = circlepoints(rFun3,n3)
Vp = evenly_sample(Vp,n3)
V3 = [Point{3,Float64}(v[1],v[2]+6,v[3]) for v in Vp]
V4 = [Point{3,Float64}(v[1]-5,v[2]+1,v[3]) for v in Vp]
V5 = [Point{3,Float64}(v[1]+5,v[2]+1,v[3]) for v in Vp]
V6 = [Point{3,Float64}(v[1],v[2]-4,v[3]) for v in Vp]
VT = (V1,V2,V3,V4,V5,V6) # Curves
R = ([1,2],[2,3,4,5,6],[4],[5]) # Regions
P = (1,0.6,0.2,0.3) # Point spacings
elseif testCase == 5
n1 = 120
r1 = 20.0
V1 = circlepoints(r1,n1)
n2 = 100
r2 = 12.0
V2 = circlepoints(r2,n2)
V2 = [Point{3,Float64}(v[1]+6,v[2],v[3]) for v in V2]
n3 = 30
r3 = 4
V3 = circlepoints(r3,n3)
V3 = [Point{3,Float64}(v[1]-14,v[2],v[3]) for v in V3]
n4 = 50
r4 = 7
V4 = circlepoints(r4,n4)
V4 = [Point{3,Float64}(v[1]+9,v[2],v[3]) for v in V4]
n5 = 40
r5 = 3
V5 = circlepoints(r5,n5)
V5 = [Point{3,Float64}(v[1]-2,v[2],v[3]) for v in V5]
VT = (V1,V2,V3,V4,V5) # Curves
R = ([1,2,3],[2,4,5],[5]) # Regions
P = (1,0.75,0.5) # Point spacings
end
F,V,C = regiontrimesh(VT,R,P)
# Visualisation
fig = Figure(size=(1000,1000))
ax1 = Axis3(fig[1, 1],aspect = :data,title="Multi-region meshing",azimuth=-pi/2,elevation=pi/2)
# hp1 = lines!(ax1, V,linewidth=4,color=:blue)
# hp2 = scatter!(ax1, V,markersize=12,color=:black)
# hp3 = scatter!(ax1, Vg,markersize=8,color=d,colormap=:Spectral)
Fp,Vp = separate_vertices(F,V) # Give each face its own point set
Cp = simplex2vertexdata(Fp,C) # Convert face color data to vertex color data
hp4 = poly!(ax1,GeometryBasics.Mesh(Vp,Fp), strokewidth=1,color=Cp, strokecolor=:black, shading = FastShading, transparency=false,colormap=Makie.Categorical(Makie.Reverse(:Spectral)))
# hp2 = scatter!(ax1, V1[indKeep],markersize=25,color=:red)
# hp2 = scatter!(ax1, Vg[1:length(xRange)],markersize=15,color=:yellow)
# hp2 = scatter!(ax1, Vg[2],markersize=15,color=:orange)
fig