Skip to content

Commit f124a22

Browse files
authored
Add documentation (#1)
* add short docs * fix docs * fix docs? * fix tests
1 parent 0aaf329 commit f124a22

File tree

14 files changed

+1748
-482
lines changed

14 files changed

+1748
-482
lines changed

.github/workflows/Documenter.yml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,19 +33,17 @@ jobs:
3333
runs-on: ubuntu-latest
3434
steps:
3535
- name: Checkout
36-
uses: actions/checkout@v4
36+
uses: actions/checkout@v5
3737
- name: Setup Julia
3838
uses: julia-actions/setup-julia@v2
3939
- name: Pull Julia cache
4040
uses: julia-actions/cache@v2
4141
- name: Install custom documentation dependencies
42-
run: julia --project=docs -e 'using Pkg; pkg"dev ."; Pkg.instantiate(); Pkg.precompile(); Pkg.status()'
42+
run: julia --project=docs -e 'using Pkg; Pkg.instantiate(); Pkg.precompile(); Pkg.status()'
4343
#- name: Creating new mds from src
4444
- name: Build and deploy
4545
env:
4646
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # For authentication with GitHub Actions token
4747
DOCUMENTER_KEY: ${{ secrets.DOCUMENTER_KEY }} # For authentication with SSH deploy key
48-
GKSwstype: "100"
4948
JULIA_DEBUG: "Documenter"
50-
DATADEPS_ALWAYS_ACCEPT: true
51-
run: julia --project=docs/ --color=yes docs/make.jl
49+
run: julia --project=docs/ --color=yes docs/make.jl

Project.toml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,9 @@ Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
1212
RandomNumbers = "e6cf234a-135c-5ec9-84dd-332b85af5143"
1313
StaticArrays = "90137ffa-7385-5640-81b9-e52037218182"
1414
Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"
15-
StructArrays = "09ab397b-f2b6-538f-b94a-2f83cf4a842a"
1615

1716
[compat]
1817
GeometryBasics = "0.5"
19-
RandomNumbers = "1.6.0"
18+
RandomNumbers = "1"
2019
StaticArrays = "1.9.7"
21-
Statistics = "1.11.1"
22-
StructArrays = "0.6.18"
20+
Statistics = "1"

docs/Project.toml

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,17 @@
11
[deps]
2-
BenchmarkTools = "6e4b80f9-dd63-53aa-95a3-0cdb28fa8baf"
2+
Bonito = "824d6782-a2ef-11e9-3a09-e5662e0c26f8"
33
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
4-
DocumenterVitepress = "4710194d-e776-4893-9690-8d956a29c365"
54
FileIO = "5789e2e9-d7fb-5bc7-8068-2c6fae9b9549"
65
GeometryBasics = "5c1252a2-5f33-56bf-86c9-59e7332b4326"
7-
ImageCore = "a09fc81d-aa75-5fe9-8630-4744c3626534"
8-
ImageShow = "4e3cecfd-b093-5904-9786-8bbb286a6a31"
96
KernelAbstractions = "63c18a36-062a-441e-b654-da1e3ab1ce7c"
10-
Literate = "98b081ad-f1c9-55d3-8b20-4c87d4299306"
117
Makie = "ee78f7c6-11fb-53f2-987a-cfe4a2b5a57a"
12-
Metal = "dde4c033-4e86-420c-a63e-0dd931031962"
13-
RayCaster = "afc56b53-c9a9-482a-a956-d1d800e05558"
8+
MeshIO = "7269a6da-0436-5bbc-96c2-40638cbb6118"
9+
RayCaster = "afc56b53-c9a9-482a-a956-d1d800e05559"
10+
WGLMakie = "276b4fcb-3e11-5398-bf8b-a0c2d153d008"
1411

1512
[compat]
1613
Documenter = "1.5"
17-
DocumenterVitepress = "0.1"
1814
FileIO = "1.16"
19-
GeometryBasics = "0.4"
20-
ImageCore = "0.10"
21-
Literate = "2.19"
15+
16+
[sources]
17+
RayCaster = {path = "../"}

docs/examples.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ begin
1717
bvh = RayCaster.BVHAccel([s1, s2, s3, s4, cat]);
1818
world_mesh = GeometryBasics.Mesh(bvh)
1919
f, ax, pl = Makie.mesh(world_mesh; color=:teal)
20-
display(f)
20+
center!(ax.scene)
2121
viewdir = normalize(ax.scene.camera.view_direction[])
2222
end
2323

@@ -35,7 +35,7 @@ begin
3535
viewfact_mesh = GeometryBasics.mesh(world_mesh, color=per_face_vf)
3636
pl = Makie.mesh(f[1, 2],
3737
viewfact_mesh, colormap=[:black, :red], axis=(; show_axis=false),
38-
shading=false, highclip=:red, lowclip=:black)
38+
shading=false, highclip=:red, lowclip=:black, colorscale=sqrt,)
3939

4040
# Centroid
4141
cax, pl = Makie.mesh(f[2, 1], world_mesh, color=(:blue, 0.5), axis=(; show_axis=false), transparency=true)
@@ -46,10 +46,10 @@ begin
4646
meshscatter!(cax, centroid, color=:red, markersize=0.05)
4747

4848
# Illum
49-
per_face = FaceView(100f0 .* (illum ./ areas), [GLTriangleFace(i) for i in 1:N])
50-
illum_mesh = GeometryBasics.mesh(world_mesh, color=per_face)
49+
pf = FaceView(100f0 .* (illum ./ areas), [GLTriangleFace(i) for i in 1:N])
50+
illum_mesh = GeometryBasics.mesh(world_mesh, color=pf)
5151

52-
Makie.mesh(f[2, 2], illum_mesh, colormap=[:black, :yellow], shading=false, axis=(; show_axis=false))
52+
Makie.mesh(f[2, 2], illum_mesh, colormap=[:black, :yellow], colorscale=sqrt, shading=false, axis=(; show_axis=false))
5353

5454
Label(f[0, 1], "Scene ($(length(bvh.primitives)) triangles)", tellwidth=false, fontsize=20)
5555
Label(f[0, 2], "Viewfactors", tellwidth=false, fontsize=20)

docs/make.jl

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,19 @@
11
using Documenter
2-
using DocumenterVitepress
32
using RayCaster
3+
using Bonito
44

5-
makedocs(; sitename = "RayCaster", authors = "Anton Smirnov, Simon Danisch and contributors",
5+
makedocs(;
66
modules = [RayCaster],
7-
checkdocs = :all,
8-
format = DocumenterVitepress.MarkdownVitepress(
9-
repo = "github.com/JuliaGeometry/RayCaster.jl", # this must be the full URL!
10-
devbranch = "master",
11-
devurl = "dev";
12-
),
13-
draft = false,
14-
source = "src",
15-
build = "build",
16-
warnonly = true,
7+
sitename = "RayCaster",
8+
clean = false,
9+
format=Documenter.HTML(prettyurls=false, size_threshold=300000),
10+
authors = "Anton Smirnov, Simon Danisch and contributors",
1711
pages = [
1812
"Home" => "index.md",
19-
"Get Started" => "get_started.md",
20-
"Shadows" => "shadows.md",
21-
"API" => "api.md",
2213
],
2314
)
2415

2516
deploydocs(;
2617
repo = "github.com/JuliaGeometry/RayCaster.jl",
27-
target = "build", # this is where Vitepress stores its output
28-
branch = "gh-pages",
29-
devbranch = "master",
3018
push_preview = true,
3119
)

docs/src/index.md

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
# RayCaster.jl
2+
3+
```@setup raycaster
4+
using Bonito
5+
Bonito.Page()
6+
```
7+
8+
```@example raycaster
9+
using RayCaster, GeometryBasics, LinearAlgebra
10+
using WGLMakie, FileIO
11+
12+
function LowSphere(radius, contact=Point3f(0); ntriangles=10)
13+
return Tesselation(Sphere(contact .+ Point3f(0, 0, radius), radius), ntriangles)
14+
end
15+
16+
ntriangles = 10
17+
s1 = LowSphere(0.5f0, Point3f(-0.5, 0.0, 0); ntriangles)
18+
s2 = LowSphere(0.3f0, Point3f(1, 0.5, 0); ntriangles)
19+
s3 = LowSphere(0.3f0, Point3f(-0.5, 1, 0); ntriangles)
20+
s4 = LowSphere(0.4f0, Point3f(0, 1.0, 0); ntriangles)
21+
l = 0.5
22+
floor = Rect3f(-l, -l, -0.01, 2l, 2l, 0.01)
23+
cat = load(Makie.assetpath("cat.obj"))
24+
bvh = RayCaster.BVHAccel([s1, s2, s3, s4, cat]);
25+
world_mesh = GeometryBasics.Mesh(bvh)
26+
f, ax, pl = Makie.mesh(world_mesh; color=:teal)
27+
center!(ax.scene)
28+
viewdir = normalize(ax.scene.camera.view_direction[])
29+
30+
@time "hitpoints" hitpoints, centroid = RayCaster.get_centroid(bvh, viewdir)
31+
@time "illum" illum = RayCaster.get_illumination(bvh, viewdir)
32+
@time "viewf_matrix" viewf_matrix = RayCaster.view_factors(bvh, rays_per_triangle=1000)
33+
viewfacts = map(i-> Float32(sum(view(viewf_matrix, :, i))), 1:length(bvh.primitives))
34+
world_mesh = GeometryBasics.Mesh(bvh)
35+
N = length(world_mesh.faces)
36+
areas = map(i-> area(world_mesh.position[world_mesh.faces[i]]), 1:N)
37+
# View factors
38+
f, ax, pl = mesh(world_mesh, color=:teal, figure=(; size=(800, 600)), axis=(; show_axis=false))
39+
per_face_vf = FaceView((viewfacts), [GLTriangleFace(i) for i in 1:N])
40+
viewfact_mesh = GeometryBasics.mesh(world_mesh, color=per_face_vf)
41+
pl = Makie.mesh(f[1, 2],
42+
viewfact_mesh, colormap=[:black, :red], axis=(; show_axis=false),
43+
shading=false, highclip=:red, lowclip=:black, colorscale=sqrt,)
44+
45+
# Centroid
46+
cax, pl = Makie.mesh(f[2, 1], world_mesh, color=(:blue, 0.5), axis=(; show_axis=false), transparency=true)
47+
48+
eyepos = cax.scene.camera.eyeposition[]
49+
depth = map(x-> norm(x .- eyepos), hitpoints)
50+
meshscatter!(cax, hitpoints, color=depth, colormap=[:gray, :black], markersize=0.01)
51+
meshscatter!(cax, centroid, color=:red, markersize=0.05)
52+
53+
# Illum
54+
pf = FaceView(100f0 .* (illum ./ areas), [GLTriangleFace(i) for i in 1:N])
55+
illum_mesh = GeometryBasics.mesh(world_mesh, color=pf)
56+
57+
Makie.mesh(f[2, 2], illum_mesh, colormap=[:black, :yellow], colorscale=sqrt, shading=false, axis=(; show_axis=false))
58+
59+
Label(f[0, 1], "Scene ($(length(bvh.primitives)) triangles)", tellwidth=false, fontsize=20)
60+
Label(f[0, 2], "Viewfactors", tellwidth=false, fontsize=20)
61+
Label(f[3, 1], "Centroid", tellwidth=false, fontsize=20)
62+
Label(f[3, 2], "Illumination", tellwidth=false, fontsize=20)
63+
64+
f
65+
```
66+
67+
## Overview
68+
69+
70+
```@autodocs
71+
Modules = [RayCaster]
72+
Order = [:module, :constant, :type, :function, :macro]
73+
Public = true
74+
Private = false
75+
```
76+
77+
## Private Functions
78+
79+
```@autodocs
80+
Modules = [RayCaster]
81+
Order = [:module, :constant, :type, :function, :macro]
82+
Public = false
83+
Private = true
84+
```

src/RayCaster.jl

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ module RayCaster
33
using GeometryBasics
44
using LinearAlgebra
55
using StaticArrays
6-
using StructArrays
76
using Atomix
87
using KernelAbstractions
98
import GeometryBasics as GB
@@ -49,5 +48,4 @@ include("bvh.jl")
4948
include("kernel-abstractions.jl")
5049
include("kernels.jl")
5150

52-
5351
end

src/bounds.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ end
3333

3434
function Base.length(b::Bounds2)::Int64
3535
δ = ceil.(b.p_max .- b.p_min .+ 1f0)
36-
u_int32(δ[1] * δ[2])
36+
UInt32(δ[1] * δ[2])
3737
end
3838

3939
function Base.iterate(

src/bvh.jl

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,6 @@ function BVHAccel(
107107
return BVHAccel(ordered_primitives, UInt8(max_prim), nodes)
108108
end
109109

110-
111-
112110
mutable struct BucketInfo
113111
count::UInt32
114112
bounds::Bounds3

src/shapes/sphere.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ function intersect(
162162
∂p∂u, ∂p∂v, ∂n∂u, ∂n∂v, reverse_normal
163163
)
164164
si = apply(s.core.object_to_world, si)
165-
true, shape_hit, sf
165+
true, shape_hit, si
166166
end
167167

168168
function intersect_p(

0 commit comments

Comments
 (0)