Skip to content

Add documentation #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/Documenter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,4 @@ jobs:
GKSwstype: "100"
JULIA_DEBUG: "Documenter"
DATADEPS_ALWAYS_ACCEPT: true
run: julia --project=docs/ --color=yes docs/make.jl
run: julia --project=docs/ --color=yes docs/make.jl
2 changes: 0 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,9 @@ Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
RandomNumbers = "e6cf234a-135c-5ec9-84dd-332b85af5143"
StaticArrays = "90137ffa-7385-5640-81b9-e52037218182"
Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"
StructArrays = "09ab397b-f2b6-538f-b94a-2f83cf4a842a"

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

[compat]
Documenter = "1.5"
DocumenterVitepress = "0.1"
FileIO = "1.16"
GeometryBasics = "0.4"
ImageCore = "0.10"
Literate = "2.19"
10 changes: 5 additions & 5 deletions docs/examples.jl
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ begin
bvh = RayCaster.BVHAccel([s1, s2, s3, s4, cat]);
world_mesh = GeometryBasics.Mesh(bvh)
f, ax, pl = Makie.mesh(world_mesh; color=:teal)
display(f)
center!(ax.scene)
viewdir = normalize(ax.scene.camera.view_direction[])
end

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

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

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

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

Label(f[0, 1], "Scene ($(length(bvh.primitives)) triangles)", tellwidth=false, fontsize=20)
Label(f[0, 2], "Viewfactors", tellwidth=false, fontsize=20)
Expand Down
24 changes: 6 additions & 18 deletions docs/make.jl
Original file line number Diff line number Diff line change
@@ -1,31 +1,19 @@
using Documenter
using DocumenterVitepress
using RayCaster
using Bonito

makedocs(; sitename = "RayCaster", authors = "Anton Smirnov, Simon Danisch and contributors",
makedocs(;
modules = [RayCaster],
checkdocs = :all,
format = DocumenterVitepress.MarkdownVitepress(
repo = "github.com/JuliaGeometry/RayCaster.jl", # this must be the full URL!
devbranch = "master",
devurl = "dev";
),
draft = false,
source = "src",
build = "build",
warnonly = true,
sitename = "RayCaster",
clean = false,
format=Documenter.HTML(prettyurls=false, size_threshold=300000),
authors = "Anton Smirnov, Simon Danisch and contributors",
pages = [
"Home" => "index.md",
"Get Started" => "get_started.md",
"Shadows" => "shadows.md",
"API" => "api.md",
],
)

deploydocs(;
repo = "github.com/JuliaGeometry/RayCaster.jl",
target = "build", # this is where Vitepress stores its output
branch = "gh-pages",
devbranch = "master",
push_preview = true,
)
84 changes: 84 additions & 0 deletions docs/src/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
# RayCaster.jl

```@setup raycaster
using Bonito
Bonito.Page()
```

```@example raycaster
using RayCaster, GeometryBasics, LinearAlgebra
using WGLMakie, FileIO

function LowSphere(radius, contact=Point3f(0); ntriangles=10)
return Tesselation(Sphere(contact .+ Point3f(0, 0, radius), radius), ntriangles)
end

ntriangles = 10
s1 = LowSphere(0.5f0, Point3f(-0.5, 0.0, 0); ntriangles)
s2 = LowSphere(0.3f0, Point3f(1, 0.5, 0); ntriangles)
s3 = LowSphere(0.3f0, Point3f(-0.5, 1, 0); ntriangles)
s4 = LowSphere(0.4f0, Point3f(0, 1.0, 0); ntriangles)
l = 0.5
floor = Rect3f(-l, -l, -0.01, 2l, 2l, 0.01)
cat = load(Makie.assetpath("cat.obj"))
bvh = RayCaster.BVHAccel([s1, s2, s3, s4, cat]);
world_mesh = GeometryBasics.Mesh(bvh)
f, ax, pl = Makie.mesh(world_mesh; color=:teal)
center!(ax.scene)
viewdir = normalize(ax.scene.camera.view_direction[])

@time "hitpoints" hitpoints, centroid = RayCaster.get_centroid(bvh, viewdir)
@time "illum" illum = RayCaster.get_illumination(bvh, viewdir)
@time "viewf_matrix" viewf_matrix = RayCaster.view_factors(bvh, rays_per_triangle=1000)
viewfacts = map(i-> Float32(sum(view(viewf_matrix, :, i))), 1:length(bvh.primitives))
world_mesh = GeometryBasics.Mesh(bvh)
N = length(world_mesh.faces)
areas = map(i-> area(world_mesh.position[world_mesh.faces[i]]), 1:N)
# View factors
f, ax, pl = mesh(world_mesh, color=:teal, figure=(; size=(800, 600)), axis=(; show_axis=false))
per_face_vf = FaceView((viewfacts), [GLTriangleFace(i) for i in 1:N])
viewfact_mesh = GeometryBasics.mesh(world_mesh, color=per_face_vf)
pl = Makie.mesh(f[1, 2],
viewfact_mesh, colormap=[:black, :red], axis=(; show_axis=false),
shading=false, highclip=:red, lowclip=:black, colorscale=sqrt,)

# Centroid
cax, pl = Makie.mesh(f[2, 1], world_mesh, color=(:blue, 0.5), axis=(; show_axis=false), transparency=true)

eyepos = cax.scene.camera.eyeposition[]
depth = map(x-> norm(x .- eyepos), hitpoints)
meshscatter!(cax, hitpoints, color=depth, colormap=[:gray, :black], markersize=0.01)
meshscatter!(cax, centroid, color=:red, markersize=0.05)

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

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

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

f
```

## Overview


```@autodocs
Modules = [RayCaster]
Order = [:module, :constant, :type, :function, :macro]
Public = true
Private = false
```

## Private Functions

```@autodocs
Modules = [RayCaster]
Order = [:module, :constant, :type, :function, :macro]
Public = false
Private = true
```
2 changes: 0 additions & 2 deletions src/RayCaster.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ module RayCaster
using GeometryBasics
using LinearAlgebra
using StaticArrays
using StructArrays
using Atomix
using KernelAbstractions
import GeometryBasics as GB
Expand Down Expand Up @@ -49,5 +48,4 @@ include("bvh.jl")
include("kernel-abstractions.jl")
include("kernels.jl")


end
2 changes: 0 additions & 2 deletions src/bvh.jl
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,6 @@ function BVHAccel(
return BVHAccel(ordered_primitives, UInt8(max_prim), nodes)
end



mutable struct BucketInfo
count::UInt32
bounds::Bounds3
Expand Down
Loading