Skip to content

Commit 8297b33

Browse files
authored
Merge pull request #50 from MakieOrg/la/iso_surfaces
La/iso surfaces
2 parents 1f8af47 + 86ea7fb commit 8297b33

File tree

7 files changed

+149
-2328
lines changed

7 files changed

+149
-2328
lines changed

.github/workflows/Deploy.yml

+19-50
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,26 @@
11
# Sample workflow for building and deploying a VitePress site to GitHub Pages
22
#
3-
name: Deploy VitePress site to Pages
3+
name: Documenter
44

55
on:
6-
# Runs on pushes targeting the `main` branch. Change this to `master` if you're
7-
# using the `master` branch as the default branch.
6+
# Runs on pushes targeting the `master` branch. Change this to `main` if you're
7+
# using the `main` branch as the default branch.
88
push:
9-
branches: [main]
9+
branches:
10+
- main
11+
tags: ['*']
1012
pull_request:
11-
branches: [main]
12-
types: [opened, synchronize, reopened]
1313

1414
# Allows you to run this workflow manually from the Actions tab
1515
workflow_dispatch:
1616

1717
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
1818
permissions:
19-
contents: read
19+
contents: write
2020
pages: write
2121
id-token: write
22-
22+
statuses: write
23+
2324
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
2425
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
2526
concurrency:
@@ -33,54 +34,22 @@ jobs:
3334
steps:
3435
- name: Checkout
3536
uses: actions/checkout@v4
36-
with:
37-
fetch-depth: 0 # Not needed if lastUpdated is not enabled
38-
# - uses: pnpm/action-setup@v2 # Uncomment this if you're using pnpm
39-
# - uses: oven-sh/setup-bun@v1 # Uncomment this if you're using Bun
40-
- name: Julia version
41-
uses: julia-actions/setup-julia@v1
42-
- name: Julia cache
43-
uses: julia-actions/cache@v1
44-
- name: Setup Node
45-
uses: actions/setup-node@v4
46-
with:
47-
node-version: 20
48-
cache: npm # or pnpm / yarn
49-
cache-dependency-path: 'package-lock.json' # this should be a package-lock.json file
50-
- name: Setup Pages
51-
uses: actions/configure-pages@v3
52-
- name: Install dependencies
53-
run: npm add -D vitepress # or pnpm install / yarn install / bun install
37+
- name: Setup Julia
38+
uses: julia-actions/setup-julia@v2
39+
- name: Pull Julia cache
40+
uses: julia-actions/cache@v2
5441
- name: Install documentation dependencies
5542
run: sudo apt-get update && sudo apt-get install -y xorg-dev mesa-utils xvfb libgl1 freeglut3-dev libxrandr-dev libxinerama-dev libxcursor-dev libxi-dev libxext-dev libcairo2-dev libfreetype6-dev libffi-dev libjpeg-dev libpng-dev libz-dev
56-
- name: Install documentation dependencies
43+
- name: Install custom documentation dependencies
5744
run: DISPLAY=:0 xvfb-run -s '-screen 0 1024x768x24' julia --project=docs -e 'using Pkg; Pkg.instantiate(); Pkg.precompile()'
58-
- name: generating examples md files
45+
- name: Build and deploy docs
5946
env:
47+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # For authentication with GitHub Actions token
48+
DOCUMENTER_KEY: ${{ secrets.DOCUMENTER_KEY }} # For authentication with SSH deploy key
49+
GKSwstype: "100" # for Plots.jl plots (if you have them)
6050
RASTERDATASOURCES_PATH: ".." # For downloading raster data
6151
JULIA_DEBUG: "Documenter"
6252
DATADEPS_ALWAYS_ACCEPT: true
6353
run: |
6454
julia --project=docs/ --color=yes docs/gen_mds.jl
65-
DISPLAY=:0 xvfb-run -s '-screen 0 1024x768x24' julia --project=docs/ --color=yes docs/make.jl
66-
- name: Build with VitePress
67-
run: |
68-
NODE_OPTIONS=--max-old-space-size=32768 npm run docs:build # or pnpm docs:build / yarn docs:build / bun run docs:build
69-
touch docs/docs_site/.documenter/.vitepress/dist/.nojekyll
70-
- name: Upload artifact
71-
uses: actions/upload-pages-artifact@v3
72-
with:
73-
path: docs/docs_site/.documenter/.vitepress/dist
74-
75-
# Deployment job
76-
deploy:
77-
environment:
78-
name: github-pages
79-
url: ${{ steps.deployment.outputs.page_url }}
80-
needs: build
81-
runs-on: ubuntu-latest
82-
name: Deploy
83-
steps:
84-
- name: Deploy to GitHub Pages
85-
id: deployment
86-
uses: actions/deploy-pages@v4
55+
DISPLAY=:0 xvfb-run -s '-screen 0 1024x768x24' julia --project=docs/ --color=yes docs/make.jl

docs/Project.toml

+1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ Lazy = "50d2b5c4-7a5e-59d5-8109-a42b560f39c0"
3232
Literate = "98b081ad-f1c9-55d3-8b20-4c87d4299306"
3333
Makie = "ee78f7c6-11fb-53f2-987a-cfe4a2b5a57a"
3434
MarketData = "945b72a4-3b13-509d-9b46-1525bb5c06de"
35+
Meshing = "e6723b4c-ebff-59f1-b4b7-d97aa5274f73"
3536
OnlineStats = "a15396b6-48d5-5d58-9928-6d29437db91e"
3637
PalmerPenguins = "8b842266-38fa-440a-9b57-31493939ab85"
3738
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"

docs/make.jl

+13-4
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,16 @@ makedocs(; sitename="BeautifulMakie", authors="Lazaro Alonso",
1010
clean=true,
1111
checkdocs=:all,
1212
format=DocumenterVitepress.MarkdownVitepress(;
13-
repo = "github.com/MakieOrg/BeautifulMakie",),
14-
draft=false,
15-
source="src", build=joinpath(@__DIR__, "docs_site/")
16-
)
13+
repo = "github.com/MakieOrg/BeautifulMakie"),
14+
draft = false,
15+
source = "src",
16+
build = "build",
17+
)
18+
19+
deploydocs(;
20+
repo = "github.com/MakieOrg/BeautifulMakie", # this must be the full URL!
21+
target = "build", # this is where Vitepress stores its output
22+
branch = "gh-pages",
23+
devbranch = "main",
24+
push_preview = true
25+
)

docs/package.json

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"scripts": {
3+
"docs:dev": "vitepress dev build/.documenter",
4+
"docs:build": "vitepress build build/.documenter",
5+
"docs:preview": "vitepress preview build/.documenter"
6+
},
7+
"devDependencies": {
8+
"markdown-it": "^14.1.0",
9+
"markdown-it-mathjax3": "^4.3.2",
10+
"vitepress-plugin-tabs": "^0.5.0",
11+
"vitest": "^1.6.0"
12+
},
13+
"dependencies": {
14+
"vitepress": "^1.1.4"
15+
}
16+
}

examples/3d/meshes/isosurfaces.jl

+100
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
# ## Isosurfaces
2+
3+
# ![](isosurfaces.png)
4+
5+
# by Ashton Bradley
6+
7+
using GLMakie
8+
using Meshing, GeometryBasics
9+
GLMakie.activate!()
10+
11+
isoval = 100
12+
algo = MarchingCubes(iso=isoval, insidepositive=false)
13+
14+
function show_isosurface(f,h,ξ; color=(:dodgerblue,0.5))
15+
s = [h(x,y,z) for x in ξ, y in ξ, z in ξ] .+ isoval
16+
mc = GeometryBasics.Mesh(s, algo)
17+
18+
return mesh(f, normal_mesh(mc); color,
19+
diffuse = Vec3f0(0.8),
20+
specular = Vec3f0(1.1),
21+
shininess = 30f0,
22+
backlight = 5f0,
23+
transparency=true,
24+
axis = (; show_axis = false)
25+
)
26+
end
27+
28+
# ### Torus
29+
30+
# isosurfaces for h(x,y,z)=0
31+
32+
torus(x,y,z; c=20, a=15) = ((hypot(x,y)-c)^2+z^2-a^2)
33+
34+
with_theme(theme_dark()) do
35+
ξ = -40:0.5:40
36+
37+
f = Figure(size=(900, 900))
38+
show_isosurface(f[1,1], torus, ξ; color = (:orangered, 0.5))
39+
f
40+
end
41+
42+
# ### Entzensberger star
43+
44+
estar(x,y,z) = 100*(x^2*y^2 + y^2*z^2 + x^2*z^2) - (1 - x^2 - y^2 - z^2)^3
45+
46+
with_theme(theme_dark()) do
47+
Xm = 1
48+
ξ = -Xm:0.01:Xm
49+
50+
f = Figure(size=(900, 900))
51+
show_isosurface(f[1,1], estar, ξ);
52+
f
53+
end
54+
55+
# ### Tetrahedron
56+
57+
tetra(x,y,z) = x^4 + 2*x^2*y^2 + 2*x^2*z^2 + y^4 + 2*y^2*z^2 + z^4 + 8*x*y*z - 10*x^2 - 10*y^2 - 10*z^2 + 20
58+
59+
with_theme(theme_dark()) do
60+
Xm = 10
61+
ξ = -Xm:0.05:Xm
62+
63+
f = Figure(size=(900, 900))
64+
show_isosurface(f[1,1], tetra, ξ; color = (:gold, 0.35));
65+
f
66+
end
67+
68+
# ### Decocube
69+
70+
deco(x,y,z; b=1,c=2.2,t=1.2) = ((x^2 + y^2 - c^2)^2 + (z - 1)^2*(z + 1)^2)*((y^2 + z^2 - c^2)^2 +
71+
(x - 1)^2*(x + 1)^2)*((z^2 + x^2 - c^2)^2 + (y - 1)^2*(y + 1)^2) -
72+
t*(1 + b*(x^2 + y^2 + z^2))
73+
74+
with_theme(theme_dark()) do
75+
Xm = 2.5
76+
ξ = -Xm:0.025:Xm
77+
78+
f = Figure(size=(900, 900))
79+
show_isosurface(f[1,1], deco, ξ; color = (:silver, 0.65));
80+
f
81+
end
82+
83+
# All together
84+
85+
with_theme(theme_dark()) do
86+
Xm = [1, 10, 2.5]
87+
88+
ξ1 = -40:0.5:40
89+
ξ2 = -Xm[1]:0.01:Xm[1]
90+
ξ3 = -Xm[2]:0.05:Xm[2]
91+
ξ4 = -Xm[3]:0.025:Xm[3]
92+
93+
f = Figure(size=(600, 600))
94+
show_isosurface(f[1,1], torus, ξ1; color = (:orangered, 0.5))
95+
show_isosurface(f[1,2], estar, ξ2);
96+
show_isosurface(f[2,1], tetra, ξ3; color = (:gold, 0.35));
97+
show_isosurface(f[2,2], deco, ξ4; color = (:silver, 0.65));
98+
f
99+
save("isosurfaces.png", f)
100+
end

0 commit comments

Comments
 (0)