Skip to content

Commit 1b09407

Browse files
authored
Merge pull request #18 from VirtualPlantLab/update_0.1.0
update primitives and raytraced forest to 0.1.0
2 parents 50926a7 + f09fb4a commit 1b09407

File tree

3 files changed

+69
-42
lines changed

3 files changed

+69
-42
lines changed

Project.toml

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,33 @@
11
name = "VPLDocs"
22
uuid = "19246b20-85cd-4f94-a989-28bb6828320f"
33
authors = ["Alejandro Morales Sierra <[email protected]> and contributors"]
4-
version = "0.0.7"
4+
version = "0.1.0"
55

66
[deps]
7+
Distributions = "31c24e10-a181-5473-b8eb-7969acd0382f"
78
Ecophys = "19467474-d12d-47c9-939f-3e50fbfd93ad"
9+
FastGaussQuadrature = "442a2c76-b920-505d-bb47-c5924d526838"
810
PlantGeomPrimitives = "7eef3cc5-4580-4ff0-8f6f-933507db6664"
911
PlantGeomTurtle = "7d6e2781-1c99-4c66-97ec-106669f3e96e"
1012
PlantGraphs = "615ad455-9aac-4340-9247-71ef610f781a"
1113
PlantRayTracer = "78485975-e4aa-407d-b3bb-ded5a4265d05"
1214
PlantSimEngine = "9a576370-710b-4269-adf9-4f603a9c6423"
1315
PlantViz = "358bd95d-d12c-439f-94b7-04b17e500c7f"
16+
Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"
1417
SkyDomes = "1838625c-7cf7-40c6-898b-904883e4b556"
1518
VirtualPlantLab = "b977ecfa-1b9a-418d-909d-4ebe565736ce"
1619

1720
[compat]
21+
Distributions = "0.25.120"
1822
Ecophys = "0.1.0"
19-
PlantGeomPrimitives = "0.0.5"
20-
PlantGeomTurtle = "0.0.6"
21-
PlantGraphs = "0.0.3"
22-
PlantRayTracer = "0.0.8"
23+
FastGaussQuadrature = "1.0.2"
24+
PlantGeomPrimitives = "0.1.0"
25+
PlantGeomTurtle = "0.1.0"
26+
PlantGraphs = "0.1.0"
27+
PlantRayTracer = "0.1.0"
2328
PlantSimEngine = "0.9"
24-
PlantViz = "0.0.8"
25-
SkyDomes = "0.1.8"
26-
VirtualPlantLab = "0.0.7"
29+
PlantViz = "0.1.0"
30+
Plots = "1.40.17"
31+
SkyDomes = "0.1.9"
32+
VirtualPlantLab = "0.1.0"
2733
julia = "1.11"

docs/src/manual/Geometry/Primitives.md

Lines changed: 46 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -39,94 +39,115 @@ to ensure that the transparency is enabled when rendering the mesh.
3939

4040
## Triangle
4141
```julia
42-
p = Triangle(length = 1.0, width = 1.0)
43-
render(p, wireframe = true, normals = true, color = RGBA(0,1,0,0.5), transparency = true)
42+
turtle = Turtle()
43+
p = Triangle!(turtle; length = 1.0, width = 1.0, colors = rand(RGBA))
44+
render(Mesh(turtle), wireframe = true)
4445
```
4546

4647
## Rectangle
4748
```julia
48-
p = Rectangle(length = 1.0, width = 1.0)
49-
render(p, wireframe = true, normals = true, color = RGBA(0,1,0,0.5), transparency = true)
49+
turtle = Turtle()
50+
p = Rectangle!(turtle; length = 1.0, width = 1.0, colors = rand(RGBA))
51+
render(Mesh(turtle), wireframe = true)
5052
```
5153

5254
## Trapezoid
5355
```julia
54-
p = Trapezoid(length = 1.0, width = 1.0, ratio = 0.5)
55-
render(p, wireframe = true, normals = true, color = RGBA(0,1,0,0.5), transparency = true)
56+
turtle = Turtle()
57+
p = Trapezoid!(turtle; length = 1.0, width = 1.0, ratio = 0.5, colors = rand(RGBA))
58+
render(Mesh(turtle), wireframe = true)
5659
```
5760

5861
## Ellipse
5962
```julia
60-
p = Ellipse(length = 1.0, width = 1.0, n = 30)
61-
render(p, wireframe = true, normals = true, color = RGBA(0,1,0,0.5), transparency = true)
63+
turtle = Turtle()
64+
p = Ellipse!(turtle; length = 1.0, width = 1.0, n = 30, colors = rand(RGBA))
65+
render(Mesh(turtle), wireframe = true)
6266
```
6367

6468
## Axis-aligned bounding box
6569
```julia
70+
turtle = Turtle()
6671
p = BBox(Vec(0.0, 0.0, 0.0), Vec(1.0, 1.0, 1.0))
67-
render(p, wireframe = true, normals = true, color = RGBA(0,1,0,0.5), transparency = true)
72+
Mesh!(turtle, p, colors = rand(RGBA))
73+
render(Mesh(turtle), wireframe = true)
6874
```
6975

7076
## Cube
7177

7278
Solid version
7379

7480
```julia
75-
p = SolidCube(length = 1.0, width = 1.0, height = 1.0)
76-
render(p, wireframe = true, normals = true, color = RGBA(0,1,0,0.5), transparency = true)
81+
turtle = Turtle()
82+
p = SolidCube!(turtle; length = 1.0, width = 1.0, height = 1.0, colors = rand(RGBA))
83+
render(Mesh(turtle), wireframe = true)
7784
```
7885

7986
Hollow version
8087

8188
```julia
82-
p = HollowCube(length = 1.0, width = 1.0, height = 1.0)
83-
render(p, wireframe = true, normals = true, color = RGBA(0,1,0,0.5), transparency = true)
89+
turtle = Turtle()
90+
p = HollowCube!(turtle; length = 1.0, width = 1.0, height = 1.0, colors = rand(RGBA))
91+
render(Mesh(turtle), wireframe = true)e)
8492
```
8593

94+
95+
## Primitives with (semi-)circular bases
96+
97+
The following primitive types share a parameter n, which is the number of triangles to discretize the cylinder into.
98+
The lower is number n, cicle base shape will be more rough (e.g., n = 20, base shape is a pentagon).
99+
The higher is number n, cicle base shape will be more smooth (e.g., n = 80, base shape is a circle).
100+
86101
## Cylinder
87102

88103
Solid version
89104

90105
```julia
91-
p = SolidCylinder(length = 1.0, width = 1.0, height = 1.0, n = 80)
92-
render(p, wireframe = true, normals = true, color = RGBA(0,1,0,0.5), transparency = true)
106+
turtle = Turtle()
107+
p = SolidCylinder!(turtle; length = 1.0, width = 1.0, height = 1.0, n = 80, colors = rand(RGBA))
108+
render(Mesh(turtle), wireframe = true)
93109
```
94110

95111
Hollow version
96112

97113
```julia
98-
p = HollowCylinder(length = 1.0, width = 1.0, height = 1.0, n = 40)
99-
render(p, wireframe = true, normals = true, color = RGBA(0,1,0,0.5), transparency = true)
114+
turtle = Turtle()
115+
p = HollowCylinder!(turtle; length = 1.0, width = 1.0, height = 1.0, n = 80, colors = rand(RGBA))
116+
render(Mesh(turtle), wireframe = true)
100117
```
101118

102119
## Frustum
103120

104121
Solid version
105122

106123
```julia
107-
p = SolidFrustum(length = 1.0, width = 1.0, height = 1.0, ratio = 0.5, n = 80)
108-
render(p, wireframe = true, normals = true, color = RGBA(0,1,0,0.5), transparency = true)
124+
turtle = Turtle()
125+
p = SolidFrustum!(turtle; length = 1.0, width = 1.0, height = 1.0, ratio = 0.5, n = 80, colors = rand(RGBA))
126+
render(Mesh(turtle), wireframe = true)
109127
```
110128

111129
Hollow version
112130

113131
```julia
114-
p = HollowFrustum(length = 1.0, width = 1.0, height = 1.0, ratio = 0.5, n = 40)
115-
render(p, wireframe = true, normals = true, color = RGBA(0,1,0,0.5), transparency = true)
132+
turtle = Turtle()
133+
p = HollowFrustum!(turtle; length = 1.0, width = 1.0, height = 1.0, ratio = 0.5, n = 80, colors = rand(RGBA))
134+
render(Mesh(turtle), wireframe = true)
116135
```
117136

118137
## Cone
119138

120139
Solid version
121140

122141
```julia
123-
p = SolidCone(length = 1.0, width = 1.0, height = 1.0, n = 40)
124-
render(p, wireframe = true, normals = true, color = RGBA(0,1,0,0.5), transparency = true)
142+
turtle = Turtle()
143+
p = SolidCone!(turtle; length = 1.0, width = 1.0, height = 1.0, n = 80, colors = rand(RGBA))
144+
render(Mesh(turtle), wireframe = true)
125145
```
126146

127147
Hollow version
128148

129149
```julia
130-
p = HollowCone(length = 1.0, width = 1.0, height = 1.0, n = 20)
131-
render(p, wireframe = true, normals = true, color = RGBA(0,1,0,0.5), transparency = true)
150+
turtle = Turtle()
151+
p = HollowCone!(turtle; length = 1.0, width = 1.0, height = 1.0, n = 80, colors = rand(RGBA))
152+
render(Mesh(turtle), wireframe = true)
132153
```

docs/src/tutorials/from_tree_forest/raytracedforest.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ function `sky()` (this last step requires the 3D scene as input in order to plac
247247
the light sources adequately).
248248

249249
```julia
250-
function create_sky(;scene, lat = 52.0*π/180.0, DOY = 182)
250+
function create_sky(;mesh, lat = 52.0*π/180.0, DOY = 182)
251251
# Fraction of the day and day length
252252
fs = collect(0.1:0.1:0.9)
253253
dec = declination(DOY)
@@ -264,7 +264,7 @@ function create_sky(;scene, lat = 52.0*π/180.0, DOY = 182)
264264
Idir_PAR = f_dir.*Idir
265265
Idif_PAR = f_dif.*Idif
266266
# Create the dome of diffuse light
267-
dome = sky(scene,
267+
dome = sky(mesh,
268268
Idir = 0.0, ## No direct solar radiation
269269
Idif = sum(Idir_PAR)/10*DL, ## Daily Diffuse solar radiation
270270
nrays_dif = 1_000_000, ## Total number of rays for diffuse solar radiation
@@ -274,7 +274,7 @@ function create_sky(;scene, lat = 52.0*π/180.0, DOY = 182)
274274
nphi = 12) ## Number of discretization steps in the azimuth angle
275275
# Add direct sources for different times of the day
276276
for I in Idir_PAR
277-
push!(dome, sky(scene, Idir = I/10*DL, nrays_dir = 100_000, Idif = 0.0)[1])
277+
push!(dome, sky(mesh, Idir = I/10*DL, nrays_dir = 100_000, Idif = 0.0)[1])
278278
end
279279
return dome
280280
end
@@ -299,10 +299,9 @@ for details). The acceleration structure allows speeding up the ray tracing
299299
by avoiding testing all rays against all objects in the scene.
300300

301301
```julia
302-
function create_raytracer(mesh, sources)
302+
function create_raytracer(acc_mesh, sources)
303303
settings = RTSettings(pkill = 0.9, maxiter = 4, nx = 5, ny = 5, parallel = true)
304-
RayTracer(mesh, sources, settings = settings, acceleration = BVH,
305-
rule = SAH{3}(5, 10));
304+
RayTracer(acc_mesh, sources, settings = settings);
306305
end
307306
```
308307

@@ -314,8 +313,9 @@ the `Material` objects (see `feed!()` above):
314313
```julia
315314
function run_raytracer!(forest; DOY = 182)
316315
mesh = create_scene(forest)
317-
sources = create_sky(mesh = mesh, DOY = DOY)
318-
rtobj = create_raytracer(mesh, sources)
316+
acc_mesh = accelerate(mesh, acceleration = BVH, rule = SAH{3}(5, 10))
317+
sources = create_sky(mesh = acc_mesh, DOY = DOY)
318+
rtobj = create_raytracer(acc_mesh, sources)
319319
trace!(rtobj)
320320
return nothing
321321
end
@@ -393,7 +393,7 @@ plot(0:1:50, x -> sink_strength(TreeTypes.Leaf(age = x), TreeTypes.treeparams())
393393
xlabel = "Age", ylabel = "Sink strength", label = "Leaf")
394394

395395
sink_strength(int) = pdf(int.sink, int.age)
396-
plot!(0:1:50, x -> sink_strength(TreeTypes.Leaf(age = x)), label = "Internode")
396+
plot!(0:1:50, x -> sink_strength(TreeTypes.Internode(age = x)), label = "Internode")
397397
```
398398

399399
Now we need a function that updates the biomass of the tree, allocates it to the

0 commit comments

Comments
 (0)