Skip to content

Commit

Permalink
Merge pull request #50 from MakieOrg/la/iso_surfaces
Browse files Browse the repository at this point in the history
La/iso surfaces
  • Loading branch information
lazarusA authored Jun 21, 2024
2 parents 1f8af47 + 86ea7fb commit 8297b33
Show file tree
Hide file tree
Showing 7 changed files with 149 additions and 2,328 deletions.
69 changes: 19 additions & 50 deletions .github/workflows/Deploy.yml
Original file line number Diff line number Diff line change
@@ -1,25 +1,26 @@
# Sample workflow for building and deploying a VitePress site to GitHub Pages
#
name: Deploy VitePress site to Pages
name: Documenter

on:
# Runs on pushes targeting the `main` branch. Change this to `master` if you're
# using the `master` branch as the default branch.
# Runs on pushes targeting the `master` branch. Change this to `main` if you're
# using the `main` branch as the default branch.
push:
branches: [main]
branches:
- main
tags: ['*']
pull_request:
branches: [main]
types: [opened, synchronize, reopened]

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

# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: read
contents: write
pages: write
id-token: write

statuses: write

# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
concurrency:
Expand All @@ -33,54 +34,22 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0 # Not needed if lastUpdated is not enabled
# - uses: pnpm/action-setup@v2 # Uncomment this if you're using pnpm
# - uses: oven-sh/setup-bun@v1 # Uncomment this if you're using Bun
- name: Julia version
uses: julia-actions/setup-julia@v1
- name: Julia cache
uses: julia-actions/cache@v1
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 20
cache: npm # or pnpm / yarn
cache-dependency-path: 'package-lock.json' # this should be a package-lock.json file
- name: Setup Pages
uses: actions/configure-pages@v3
- name: Install dependencies
run: npm add -D vitepress # or pnpm install / yarn install / bun install
- name: Setup Julia
uses: julia-actions/setup-julia@v2
- name: Pull Julia cache
uses: julia-actions/cache@v2
- name: Install documentation dependencies
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
- name: Install documentation dependencies
- name: Install custom documentation dependencies
run: DISPLAY=:0 xvfb-run -s '-screen 0 1024x768x24' julia --project=docs -e 'using Pkg; Pkg.instantiate(); Pkg.precompile()'
- name: generating examples md files
- name: Build and deploy docs
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # For authentication with GitHub Actions token
DOCUMENTER_KEY: ${{ secrets.DOCUMENTER_KEY }} # For authentication with SSH deploy key
GKSwstype: "100" # for Plots.jl plots (if you have them)
RASTERDATASOURCES_PATH: ".." # For downloading raster data
JULIA_DEBUG: "Documenter"
DATADEPS_ALWAYS_ACCEPT: true
run: |
julia --project=docs/ --color=yes docs/gen_mds.jl
DISPLAY=:0 xvfb-run -s '-screen 0 1024x768x24' julia --project=docs/ --color=yes docs/make.jl
- name: Build with VitePress
run: |
NODE_OPTIONS=--max-old-space-size=32768 npm run docs:build # or pnpm docs:build / yarn docs:build / bun run docs:build
touch docs/docs_site/.documenter/.vitepress/dist/.nojekyll
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: docs/docs_site/.documenter/.vitepress/dist

# Deployment job
deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
needs: build
runs-on: ubuntu-latest
name: Deploy
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
DISPLAY=:0 xvfb-run -s '-screen 0 1024x768x24' julia --project=docs/ --color=yes docs/make.jl
1 change: 1 addition & 0 deletions docs/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ Lazy = "50d2b5c4-7a5e-59d5-8109-a42b560f39c0"
Literate = "98b081ad-f1c9-55d3-8b20-4c87d4299306"
Makie = "ee78f7c6-11fb-53f2-987a-cfe4a2b5a57a"
MarketData = "945b72a4-3b13-509d-9b46-1525bb5c06de"
Meshing = "e6723b4c-ebff-59f1-b4b7-d97aa5274f73"
OnlineStats = "a15396b6-48d5-5d58-9928-6d29437db91e"
PalmerPenguins = "8b842266-38fa-440a-9b57-31493939ab85"
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
Expand Down
17 changes: 13 additions & 4 deletions docs/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,16 @@ makedocs(; sitename="BeautifulMakie", authors="Lazaro Alonso",
clean=true,
checkdocs=:all,
format=DocumenterVitepress.MarkdownVitepress(;
repo = "github.com/MakieOrg/BeautifulMakie",),
draft=false,
source="src", build=joinpath(@__DIR__, "docs_site/")
)
repo = "github.com/MakieOrg/BeautifulMakie"),
draft = false,
source = "src",
build = "build",
)

deploydocs(;
repo = "github.com/MakieOrg/BeautifulMakie", # this must be the full URL!
target = "build", # this is where Vitepress stores its output
branch = "gh-pages",
devbranch = "main",
push_preview = true
)
16 changes: 16 additions & 0 deletions docs/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"scripts": {
"docs:dev": "vitepress dev build/.documenter",
"docs:build": "vitepress build build/.documenter",
"docs:preview": "vitepress preview build/.documenter"
},
"devDependencies": {
"markdown-it": "^14.1.0",
"markdown-it-mathjax3": "^4.3.2",
"vitepress-plugin-tabs": "^0.5.0",
"vitest": "^1.6.0"
},
"dependencies": {
"vitepress": "^1.1.4"
}
}
100 changes: 100 additions & 0 deletions examples/3d/meshes/isosurfaces.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
# ## Isosurfaces

# ![](isosurfaces.png)

# by Ashton Bradley

using GLMakie
using Meshing, GeometryBasics
GLMakie.activate!()

isoval = 100
algo = MarchingCubes(iso=isoval, insidepositive=false)

function show_isosurface(f,h,ξ; color=(:dodgerblue,0.5))
s = [h(x,y,z) for x in ξ, y in ξ, z in ξ] .+ isoval
mc = GeometryBasics.Mesh(s, algo)

return mesh(f, normal_mesh(mc); color,
diffuse = Vec3f0(0.8),
specular = Vec3f0(1.1),
shininess = 30f0,
backlight = 5f0,
transparency=true,
axis = (; show_axis = false)
)
end

# ### Torus

# isosurfaces for h(x,y,z)=0

torus(x,y,z; c=20, a=15) = ((hypot(x,y)-c)^2+z^2-a^2)

with_theme(theme_dark()) do
ξ = -40:0.5:40

f = Figure(size=(900, 900))
show_isosurface(f[1,1], torus, ξ; color = (:orangered, 0.5))
f
end

# ### Entzensberger star

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

with_theme(theme_dark()) do
Xm = 1
ξ = -Xm:0.01:Xm

f = Figure(size=(900, 900))
show_isosurface(f[1,1], estar, ξ);
f
end

# ### Tetrahedron

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

with_theme(theme_dark()) do
Xm = 10
ξ = -Xm:0.05:Xm

f = Figure(size=(900, 900))
show_isosurface(f[1,1], tetra, ξ; color = (:gold, 0.35));
f
end

# ### Decocube

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 +
(x - 1)^2*(x + 1)^2)*((z^2 + x^2 - c^2)^2 + (y - 1)^2*(y + 1)^2) -
t*(1 + b*(x^2 + y^2 + z^2))

with_theme(theme_dark()) do
Xm = 2.5
ξ = -Xm:0.025:Xm

f = Figure(size=(900, 900))
show_isosurface(f[1,1], deco, ξ; color = (:silver, 0.65));
f
end

# All together

with_theme(theme_dark()) do
Xm = [1, 10, 2.5]

ξ1 = -40:0.5:40
ξ2 = -Xm[1]:0.01:Xm[1]
ξ3 = -Xm[2]:0.05:Xm[2]
ξ4 = -Xm[3]:0.025:Xm[3]

f = Figure(size=(600, 600))
show_isosurface(f[1,1], torus, ξ1; color = (:orangered, 0.5))
show_isosurface(f[1,2], estar, ξ2);
show_isosurface(f[2,1], tetra, ξ3; color = (:gold, 0.35));
show_isosurface(f[2,2], deco, ξ4; color = (:silver, 0.65));
f
save("isosurfaces.png", f)
end
Loading

0 comments on commit 8297b33

Please sign in to comment.