Skip to content

Commit 3d264d0

Browse files
authored
Merge pull request #19 from asinghvi17/as/protodocs
Prototype docs
2 parents 1031be1 + 600ac7d commit 3d264d0

18 files changed

+217
-10
lines changed

docs/make.jl

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#! /usr/bin/env julia
2+
3+
using Documenter
4+
5+
using GeometryBasics
6+
7+
# Copy the README to serve as the homepage
8+
cp(joinpath(@__DIR__, "..", "README.md"), joinpath(@__DIR__, "src", "index.md"))
9+
10+
makedocs(
11+
format = Documenter.HTML(),
12+
sitename = "GeometryBasics.jl",
13+
pages = [
14+
"index.md",
15+
"primitives.md",
16+
"rectangles.md",
17+
"polygons.md",
18+
"meshes.md",
19+
"decomposition.md",
20+
"distancefields.md",
21+
"metadata.jl",
22+
"api.md",
23+
],
24+
modules = [GeometryTypes]
25+
)
26+
27+
deploydocs(
28+
repo = "github.com/JuliaGeometry/GeometryTypes.jl.git",
29+
push_preview = true
30+
)

docs/src/api.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# API Reference
2+
3+
## Exports
4+
5+
```@autodocs
6+
Modules = [GeometryBasics]
7+
Order = [:module, :constant, :type, :function, :macro]
8+
Public = true
9+
Private = false
10+
```
11+
12+
## Private
13+
14+
```@autodocs
15+
Modules = [GeometryBasics]
16+
Order = [:module, :constant, :type, :function, :macro]
17+
Public = false
18+
Private = true
19+
```

docs/src/decomposition.md

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# Decomposition
2+
3+
4+
## Displaying primitives
5+
6+
To display geometry primitives, they need to be decomposable.
7+
This can be done for any arbitrary primitive, by overloading the following interface:
8+
9+
```julia
10+
# Let's take SimpleRectangle as an example:
11+
# Below is a minimal set of decomposable attributes to build up a triangle mesh:
12+
isdecomposable(::Type{T}, ::Type{HR}) where {T<:Point, HR<:SimpleRectangle} = true
13+
isdecomposable(::Type{T}, ::Type{HR}) where {T<:Face, HR<:SimpleRectangle} = true
14+
15+
# This is an example implementation of `decompose` for points.
16+
function GeometryBasics.decompose(P::Type{Point{3, PT}}, r::SimpleRectangle, resolution=(2,2)) where PT
17+
w,h = resolution
18+
vec(
19+
PT[
20+
(x,y,0)
21+
for x in range(r.x, stop = r.x+r.w, length = w),
22+
y in range(r.y, stop = r.y+ r .h, length = h)
23+
]
24+
)
25+
end
26+
27+
function GeometryBasics.decompose(::Type{T}, r::SimpleRectangle, resolution=(2,2)) where T <: Face
28+
w,h = resolution
29+
Idx = LinearIndices(resolution)
30+
faces = vec([Face{4, Int}(
31+
Idx[i, j], Idx[i+1, j],
32+
Idx[i+1, j+1], Idx[i, j+1]
33+
) for i=1:(w-1), j=1:(h-1)]
34+
)
35+
decompose(T, faces)
36+
end
37+
```
38+
39+
With these methods defined, this constructor will magically work:
40+
41+
```julia
42+
rect = SimpleRectangle(0, 0, 1, 1)
43+
m = GLNormalMesh(rect)
44+
vertices(m) == decompose(Point3f0, rect)
45+
46+
faces(m) == decompose(GLTriangle, rect) # GLFace{3} == GLTriangle
47+
normals(m) # automatically calculated from mesh
48+
```
49+
50+
As you can see, the normals are automatically calculated only with the faces and points.
51+
You can overwrite that behavior by also defining decompose for the `Normal` type!

docs/src/distancefields.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Distance Fields

docs/src/implementation.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Implementation
2+
3+
In the backend, GeometryTypes relies on fixed-size arrays, specifically static vectors.
4+
5+
TODO add more here.

docs/src/meshes.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Meshes
2+
3+
## Types
4+
5+
```@docs
6+
AbstractMesh
7+
Mesh
8+
```
9+
10+
## How to create a mesh
11+
12+
### Meshing.jl

docs/src/metadata.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Metadata

docs/src/polygons.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Polygons

docs/src/primitives.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Primitives
2+
3+
## Points and Vectors
4+
5+
## Simplices
6+
7+
## Shapes
8+
9+
```@docs
10+
Circle
11+
Sphere
12+
Cylinder
13+
```
14+
15+
## Abstract types
16+
17+
```@docs
18+
GeometryPrimitive
19+
AbstractSimplex
20+
AbstractMesh
21+
AbstractDistanceField
22+
```

docs/src/rectangles.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Rectangles

0 commit comments

Comments
 (0)