Skip to content

Commit

Permalink
Updated docs, added boundary handling for tri and quad subdivision fu…
Browse files Browse the repository at this point in the history
…nctions
  • Loading branch information
Kevin-Mattheus-Moerman committed May 9, 2024
1 parent 5c254b2 commit d4d8d6f
Show file tree
Hide file tree
Showing 9 changed files with 615 additions and 145 deletions.
70 changes: 70 additions & 0 deletions docs/src/functions.md
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,66 @@ Comodo.geosphere
Comodo.hexbox
```

## `con_face_edge`
```@docs
Comodo.con_face_edge
```

## `con_edge_face`
```@docs
Comodo.con_edge_face
```

## `con_face_face`
```@docs
Comodo.con_face_face
```

## `con_face_face_v`
```@docs
Comodo.con_face_face_v
```

## `con_vertex_simplex`
```@docs
Comodo.con_vertex_simplex
```

## `con_vertex_face`
```@docs
Comodo.con_vertex_face
```

## `con_vertex_edge`
```@docs
Comodo.con_vertex_edge
```

## `con_edge_edge`
```@docs
Comodo.con_edge_edge
```

## `con_vertex_vertex_f`
```@docs
Comodo.con_vertex_vertex_f
```

## `con_vertex_vertex`
```@docs
Comodo.con_vertex_vertex
```

## `meshconnectivity`
```@docs
Comodo.meshconnectivity
```

## `mergevertices`
```@docs
Comodo.mergevertices
```

## `smoothmesh_laplacian`
```@docs
Comodo.smoothmesh_laplacian
Expand All @@ -221,6 +281,16 @@ Comodo.smoothmesh_laplacian
Comodo.smoothmesh_hc
```

## `quadplate`
```@docs
Comodo.quadplate
```

## `quadsphere`
```@docs
Comodo.quadsphere
```

## `loflinear`
```@docs
Comodo.loftlinear
Expand Down
28 changes: 18 additions & 10 deletions examples/demo_dualclad.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,17 @@ using GLMakie
using GeometryBasics
using FileIO
using StaticArrays
using Makie.Colors

c1 = RGBf(1.0, 0.30196078431372547, 0.023529411764705882)
c2 = RGBf(0.2235294117647059, 1.0, 0.0784313725490196)
c3 = RGBf(0.5803921568627451, 0.3411764705882353, 0.9215686274509803)

#=
This demo shows the use of the dualclag function.
=#

testCase = 2
testCase = 1
if testCase == 1
F,V = geosphere(2,1.0)
elseif testCase == 2
Expand Down Expand Up @@ -61,17 +66,20 @@ end


s = 0.5
con_type = :edge
con_type = :face
Fs,Fq,Vs = dualclad(F,V,s; connectivity=con_type)

# Rotate the coordinates
fig = Figure(size = (800,800))
ax = Axis3(fig[1, 1], aspect = :data)
# Visualisation
strokewidth =1

# hp1 = poly!(ax, GeometryBasics.Mesh(V,F), color=:blue,transparency=true,strokewidth=0.15,strokecolor=:black, shading = FastShading)
Vn = V-0.01*vertexnormal(F,V)

fig = Figure(size = (1200,1200))
ax = Axis3(fig[1, 1], aspect = :data)

hp2 = poly!(ax, GeometryBasics.Mesh(Vs,Fs), color=:white,transparency=false,strokewidth=0.15,strokecolor=:black, shading = FastShading)
hp3 = poly!(ax, GeometryBasics.Mesh(Vs,Fq), color=:white,transparency=false,strokewidth=0.15,strokecolor=:black, shading = FastShading)
hp1 = mesh!(ax, GeometryBasics.Mesh(Vn,F), color=c3,transparency=false, shading = FastShading)
hp2 = poly!(ax, GeometryBasics.Mesh(Vs,Fs), color=c1,transparency=false,strokewidth=strokewidth,strokecolor=:white, shading = FastShading)
hp3 = poly!(ax, GeometryBasics.Mesh(Vs,Fq), color=c2,transparency=false,strokewidth=strokewidth,strokecolor=:white, shading = FastShading)

# hp2 = mesh!(ax, GeometryBasics.Mesh(Vs,Fs), color=:white,transparency=false, shading = FastShading)
# hp3 = mesh!(ax, GeometryBasics.Mesh(Vs,Fq), color=:white,transparency=false, shading = FastShading)
Expand All @@ -90,8 +98,8 @@ end

set_close_to!(hSlider,0.5)

# fileName = comododir()*"/assets/temp/dualclad_anim_05.mp4"
# slider2anim(fig,hSlider,fileName; backforth=true, duration=3)
fileName = comododir()*"/assets/temp/dualclad_anim_06.mp4"
slider2anim(fig,hSlider,fileName; backforth=true, duration=6)

fig

Expand Down
4 changes: 2 additions & 2 deletions examples/demo_mergevertices.jl
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ poly!(ax2,M2,strokewidth=2,color=:white, shading = FastShading)

fig[2, :]=hSlider

fileName = comododir()*"/assets/img/mergevertices_anim.gif"
slider2anim(fig,hSlider,fileName; backforth=true, duration=2)
# fileName = comododir()*"/assets/temp/mergevertices_anim.mp4"
# slider2anim(fig,hSlider,fileName; backforth=true, duration=2)

fig
4 changes: 2 additions & 2 deletions examples/demo_regiontrimesh.jl
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,8 @@ ax1 = Axis3(fig[1, 1],aspect = :data,title="Multi-region meshing",azimuth=-pi/2,
# hp3 = scatter!(ax1, Vg,markersize=8,color=d,colormap=:Spectral)


Fp,Vp = separate_vertices(F,V)
Cp = simplex2vertexdata(Fp,C)
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)))


Expand Down
31 changes: 21 additions & 10 deletions examples/demo_scalesimplex.jl
Original file line number Diff line number Diff line change
Expand Up @@ -21,27 +21,36 @@ F = tofaces(faces(M))
V = topoints(coordinates(M))
F,V = mergevertices(F,V)

n = 1
F,V = subtri(F,V,n; method=:Loop)
# n = 1
# F,V = subtri(F,V,n; method=:Loop)

s = 0.5
Fs,Vs = scalesimplex(F,V,s)


## Visualisation
fig = Figure(size = (800,800))

strokewidth = 0.1
strokecolor = :white
# Create slightly inward offset version so the visualisation does not co-inside
Vn = V-0.01*vertexnormal(F,V)

fig = Figure(size = (1400,800))

ax1 = Axis3(fig[1, 1], aspect = :data,title="Single scale factor")
mesh!(ax1, GeometryBasics.Mesh(V,F), color=:white,transparency=false,shading = FastShading)
hp1 = poly!(ax1, GeometryBasics.Mesh(Vs,Fs), color=:green,transparency=false,strokewidth=1,strokecolor=:black,shading = FastShading)
mesh!(ax1, GeometryBasics.Mesh(Vn,F), color=:white,transparency=false,shading = FastShading)
hp1 = poly!(ax1, GeometryBasics.Mesh(Vs,Fs), color=:green,transparency=false,strokewidth=strokewidth,strokecolor=strokecolor,shading = FastShading)
# hp1 = mesh!(ax1, GeometryBasics.Mesh(Vs,Fs), color=:green,transparency=false,shading = FastShading)

ax2 = Axis3(fig[1, 2], aspect = :data,title="Per vertex scale factor")
mesh!(ax2, GeometryBasics.Mesh(V,F), color=:white,transparency=false,shading = FastShading)
hp2 = poly!(ax2, GeometryBasics.Mesh(Vs,Fs), color=:green,transparency=false,strokewidth=1,strokecolor=:black,shading = FastShading)
mesh!(ax2, GeometryBasics.Mesh(Vn,F), color=:white,transparency=false,shading = FastShading)
hp2 = poly!(ax2, GeometryBasics.Mesh(Vs,Fs), color=:green,transparency=false,strokewidth=strokewidth,strokecolor=strokecolor,shading = FastShading)
# hp2 = mesh!(ax1, GeometryBasics.Mesh(Vs,Fs), color=:green,transparency=false,shading = FastShading)

ax2 = Axis3(fig[1, 3], aspect = :data,title="Per face scale factor")
mesh!(ax2, GeometryBasics.Mesh(V,F), color=:white,transparency=false,shading = FastShading)
hp3 = poly!(ax2, GeometryBasics.Mesh(Vs,Fs), color=:green,transparency=false,strokewidth=1,strokecolor=:black,shading = FastShading)
ax3 = Axis3(fig[1, 3], aspect = :data,title="Per face scale factor")
mesh!(ax3, GeometryBasics.Mesh(Vn,F), color=:white,transparency=false,shading = FastShading)
hp3 = poly!(ax3, GeometryBasics.Mesh(Vs,Fs), color=:green,transparency=false,strokewidth=strokewidth,strokecolor=strokecolor,shading = FastShading)
# hp3 = mesh!(ax3, GeometryBasics.Mesh(Vs,Fs), color=:green,transparency=false,shading = FastShading)


stepRange = range(1.0,0.0,50)
Expand Down Expand Up @@ -75,6 +84,8 @@ set_close_to!(hSlider,0.5)
# fileName = comododir()*"/assets/temp/surface_mesh_smoothing_anim.mp4"
# slider2anim(fig,hSlider,fileName; backforth=true, duration=2)



fig


87 changes: 72 additions & 15 deletions examples/demo_subquad.jl
Original file line number Diff line number Diff line change
@@ -1,33 +1,90 @@
using Comodo
using GLMakie
using GeometryBasics
using LinearAlgebra

## Define example input
r = 0.5 #radius
M = platonicsolid(2,r) # Get an example quadrilateral mesh (for a cube in this case)
V = coordinates(M)
F = faces(M)
testCase = 2

## Define example input
if testCase == 1 # cube
r = 1.0 #radius
M = platonicsolid(2,r) # Get an example quadrilateral mesh (for a cube in this case)
V = coordinates(M)
F = faces(M)
elseif testCase == 2 # Extruded prism/cylinder with nc points
r = 1.0
nc = 3
Vc = circlepoints(r,nc;dir=:cw)
d = norm(Vc[1]-Vc[2])
n = normalizevector(Vec{3, Float64}(0.0,0.0,1.0))
s = 1
F,V = extrudecurve(Vc,d;s=s, n=n, num_steps=2, close_loop=true,face_type=:quad)
M = GeometryBasics.Mesh(V,F)
elseif testCase == 3 # Quadrangulated hemi-sphere
n = 1
r = 1.0
F,V = quadsphere(n,r)
VC = simplexcenter(F,V) # Finding triangle centre coordiantes
F = [F[i] for i in findall(map(v-> v[3]>0,VC))] # Remove some faces using z of central coordinates
F,V = remove_unused_vertices(F,V) # Cleanup/remove unused vertices after faces were removed
M = GeometryBasics.Mesh(V,F)
end
## Refine mesh using `subquad` and the default "linear" method
Fn1,Vn1=subquad(F,V,1) # Split once
Fn2,Vn2=subquad(F,V,2) # Split twice
Fn3,Vn3=subquad(F,V,3) # Split 3 times

Fn4,Vn4=subquad(F,V,1;method=:Catmull_Clark) # Split once
Fn5,Vn5=subquad(F,V,2;method=:Catmull_Clark) # Split twice
Fn6,Vn6=subquad(F,V,3;method=:Catmull_Clark) # Split 3 times

Fn7,Vn7=subquad(F,V,1; method=:Catmull_Clark, constrain_boundary=true) # Split once
Fn8,Vn8=subquad(F,V,2; method=:Catmull_Clark, constrain_boundary=true) # Split twice
Fn9,Vn9=subquad(F,V,3; method=:Catmull_Clark, constrain_boundary=true) # Split 3 times


## Visualization
strokewidth1 = 1
lineWidth = 4
fig = Figure(size=(1600,800))

ax1 = Axis3(fig[1, 1], aspect = :data, xlabel = "X", ylabel = "Y", zlabel = "Z", title = "Refined n=1")
wireframe!(ax1,M, linewidth=8,color=:red, overdraw=false)
poly!(ax1,GeometryBasics.Mesh(Vn1,Fn1), strokewidth=3,color=:white,shading=FastShading,transparency=false)

ax2 = Axis3(fig[1, 2], aspect = :data, xlabel = "X", ylabel = "Y", zlabel = "Z", title = "Refined n=2")
wireframe!(ax2,M, linewidth=8,color=:red, overdraw=false)
poly!(ax2,GeometryBasics.Mesh(Vn2,Fn2), strokewidth=3,color=:white,shading=FastShading,transparency=false)
ax1 = Axis3(fig[1, 1], aspect = :data, xlabel = "X", ylabel = "Y", zlabel = "Z", title = "Linear, n=1")
wireframe!(ax1,M, linewidth=lineWidth,color=:red, overdraw=false)
poly!(ax1,GeometryBasics.Mesh(Vn1,Fn1), strokewidth=strokewidth1,color=:white,shading=FastShading,transparency=false)

ax3 = Axis3(fig[1, 3], aspect = :data, xlabel = "X", ylabel = "Y", zlabel = "Z", title = "Refined n=3")
hp1 = wireframe!(ax3,M, linewidth=8,color=:red, overdraw=false)
hp2 = poly!(ax3,GeometryBasics.Mesh(Vn3,Fn3), strokewidth=3,color=:white,shading=FastShading,transparency=false)
ax2 = Axis3(fig[1, 2], aspect = :data, xlabel = "X", ylabel = "Y", zlabel = "Z", title = "Linearly, n=2")
wireframe!(ax2,M, linewidth=lineWidth,color=:red, overdraw=false)
poly!(ax2,GeometryBasics.Mesh(Vn2,Fn2), strokewidth=strokewidth1,color=:white,shading=FastShading,transparency=false)

ax3 = Axis3(fig[1, 3], aspect = :data, xlabel = "X", ylabel = "Y", zlabel = "Z", title = "Linearly, n=3")
hp1 = wireframe!(ax3,M, linewidth=lineWidth,color=:red, overdraw=false)
hp2 = poly!(ax3,GeometryBasics.Mesh(Vn3,Fn3), strokewidth=strokewidth1,color=:white,shading=FastShading,transparency=false)
Legend(fig[1, 4],[hp1,hp2],["Initial","Refined"])

ax4 = Axis3(fig[2, 1], aspect = :data, xlabel = "X", ylabel = "Y", zlabel = "Z", title = "Catmull_Clark, n=1")
wireframe!(ax4,M, linewidth=lineWidth,color=:red, overdraw=false)
poly!(ax4,GeometryBasics.Mesh(Vn4,Fn4), strokewidth=strokewidth1,color=:white,shading=FastShading,transparency=false)

ax5 = Axis3(fig[2, 2], aspect = :data, xlabel = "X", ylabel = "Y", zlabel = "Z", title = "Catmull_Clark, n=2")
wireframe!(ax5,M, linewidth=lineWidth,color=:red, overdraw=false)
poly!(ax5,GeometryBasics.Mesh(Vn5,Fn5), strokewidth=strokewidth1,color=:white,shading=FastShading,transparency=false)

ax6 = Axis3(fig[2, 3], aspect = :data, xlabel = "X", ylabel = "Y", zlabel = "Z", title = "Catmull_Clark, n=3")
hp1 = wireframe!(ax6,M, linewidth=lineWidth,color=:red, overdraw=false)
hp2 = poly!(ax6,GeometryBasics.Mesh(Vn6,Fn6), strokewidth=strokewidth1,color=:white,shading=FastShading,transparency=false)
Legend(fig[2, 4],[hp1,hp2],["Initial","Refined"])

ax4 = Axis3(fig[3, 1], aspect = :data, xlabel = "X", ylabel = "Y", zlabel = "Z", title = "Catmull_Clark, constrained boundary, n=1")
wireframe!(ax4,M, linewidth=lineWidth,color=:red, overdraw=false)
poly!(ax4,GeometryBasics.Mesh(Vn7,Fn7), strokewidth=strokewidth1,color=:white,shading=FastShading,transparency=false)

ax5 = Axis3(fig[3, 2], aspect = :data, xlabel = "X", ylabel = "Y", zlabel = "Z", title = "Catmull_Clark, constrained boundary, n=2")
wireframe!(ax5,M, linewidth=lineWidth,color=:red, overdraw=false)
poly!(ax5,GeometryBasics.Mesh(Vn8,Fn8), strokewidth=strokewidth1,color=:white,shading=FastShading,transparency=false)

ax6 = Axis3(fig[3, 3], aspect = :data, xlabel = "X", ylabel = "Y", zlabel = "Z", title = "Catmull_Clark, constrained boundary, n=3")
hp1 = wireframe!(ax6,M, linewidth=lineWidth,color=:red, overdraw=false)
hp2 = poly!(ax6,GeometryBasics.Mesh(Vn9,Fn9), strokewidth=strokewidth1,color=:white,shading=FastShading,transparency=false)
Legend(fig[3, 4],[hp1,hp2],["Initial","Refined"])

fig
Loading

0 comments on commit d4d8d6f

Please sign in to comment.