Skip to content

Commit 0b53ccf

Browse files
committed
Fix bugs in docstrings
1 parent 8f248f6 commit 0b53ccf

7 files changed

Lines changed: 73 additions & 38 deletions

File tree

src/Mesh/Areas.jl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,15 @@ The area of the triangle.
1212
1313
# Example
1414
```jldoctest
15+
julia> import PlantGeomPrimitives as PG;
16+
1517
julia> v1 = Vec(0.0, 0.0, 0.0);
1618
1719
julia> v2 = Vec(1.0, 0.0, 0.0);
1820
1921
julia> v3 = Vec(0.0, 1.0, 0.0);
2022
21-
julia> area_triangle(v1, v2, v3);
23+
julia> PG.area_triangle(v1, v2, v3);
2224
```
2325
"""
2426
function area_triangle(v1::Vec{FT}, v2::Vec{FT}, v3::Vec{FT})::FT where {FT<:AbstractFloat}

src/Mesh/Edges.jl

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
"""
33
update_edges!(m::Mesh{FT}) where {FT<:AbstractFloat}
44
5-
Calculate the edges of a mesh and add them as properties.
6-
This function checks if the edges property exists, and if not, it creates it.
5+
Calculate the edges of a mesh and add them as properties.
6+
This function checks if the edges property exists, and if not, it creates it.
77
It then computes the edges for all vertices in the mesh.
88
99
# Arguments
@@ -14,11 +14,13 @@ Nothing. It modifies the mesh in place by adding the edges as a property.
1414
1515
# Example
1616
```jldoctest
17+
julia> import PlantGeomPrimitives as PG;
18+
1719
julia> vs = [Vec(0.0, 0.0, 0.0), Vec(1.0, 0.0, 0.0), Vec(0.0, 1.0, 0.0)];
1820
1921
julia> m = Mesh(vs);
2022
21-
julia> update_edges!(m);
23+
julia> PG.update_edges!(m);
2224
2325
julia> edges(m);
2426
```
@@ -48,7 +50,7 @@ end
4850
"""
4951
push_edges!(vs, m, i0)
5052
51-
Create the three edges stored as a vector of vectors from
53+
Create the three edges stored as a vector of vectors from
5254
the vertices `vs` starting at index `i0` and add them to the
5355
mesh's property.
5456
@@ -62,13 +64,15 @@ Nothing. It modifies the mesh in place by adding the edges.
6264
6365
# Example
6466
```jldoctest
67+
julia> import PlantGeomPrimitives as PG;
68+
6569
julia> vs = [Vec(0.0, 0.0, 0.0), Vec(1.0, 0.0, 0.0), Vec(0.0, 1.0, 0.0)];
6670
6771
julia> m = Mesh(vs);
6872
69-
julia> update_edges!(m);
73+
julia> PG.update_edges!(m);
7074
71-
julia> push_edges!(vs, m, 1);
75+
julia> PG.push_edges!(vs, m, 1);
7276
7377
julia> edges(m);
7478
```

src/Mesh/MeshIO.jl

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@ A `GeometryBasics.Mesh` object containing the vertices and faces of the mesh.
1515
1616
# Example
1717
```jldoctest
18+
julia> import PlantGeomPrimitives as PG;
19+
1820
julia> vs = [Vec(0.0, 0.0, 0.0), Vec(1.0, 0.0, 0.0), Vec(0.0, 1.0, 0.0)];
1921
2022
julia> m = Mesh(vs);
2123
22-
julia> gl_mesh = GLMesh(m);
23-
24-
julia> typeof(gl_mesh)
24+
julia> gl_mesh = PG.GLMesh(m);
2525
```
2626
"""
2727
function GLMesh(m::Mesh{FT}) where {FT<:AbstractFloat}
@@ -45,11 +45,13 @@ A `Mesh` object containing the vertices of the mesh.
4545
4646
# Example
4747
```jldoctest
48+
julia> import GeometryBasics as GB;
49+
4850
julia> m = GB.Mesh([GB.Point(0.0, 0.0, 0.0), GB.Point(1.0, 0.0, 0.0), GB.Point(0.0, 1.0, 0.0)], [GB.TriangleFace(1, 2, 3)]);
4951
5052
julia> mesh = Mesh(m);
5153
52-
julia> typeof(mesh)
54+
julia> typeof(mesh);
5355
```
5456
"""
5557
function Mesh(m::GB.Mesh)

src/Mesh/Normals.jl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,13 @@ Nothing. It modifies the mesh in place by adding the normals as a property.
1414
1515
# Example
1616
```jldoctest
17+
julia> import PlantGeomPrimitives as PG;
18+
1719
julia> vs = [Vec(0.0, 0.0, 0.0), Vec(1.0, 0.0, 0.0), Vec(0.0, 1.0, 0.0)];
1820
1921
julia> m = Mesh(vs);
2022
21-
julia> update_normals!(m);
23+
julia> PG.update_normals!(m);
2224
2325
julia> normals(m);
2426
```

src/Mesh/Properties.jl

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,17 @@ The modified `p1` dictionary with properties from `p2` added.
1515
1616
# Example
1717
```jldoctest
18+
julia> import PlantGeomPrimitives as PG;
19+
1820
julia> p1 = Dict{Symbol, AbstractVector}(:prop1 => [1.0, 2.0], :prop2 => [3.0, 4.0]);
1921
20-
julia> p2 = Dict{Symbol, AbstractVector}(:prop1 => [5.0, 6.0], :prop3 => [7.0, 8.0]);
22+
julia> p2 = Dict{Symbol, AbstractVector}(:prop1 => [5.0, 6.0], :prop2 => [7.0, 8.0]);
2123
22-
julia> merged_properties = add_properties!(p1, p2);
24+
julia> merged_properties = PG.add_properties!(p1, p2);
2325
2426
julia> merged_properties;
2527
```
26-
"""
28+
"""
2729
function add_properties!(p1::Dict{Symbol, AbstractVector}, p2::Dict{Symbol, AbstractVector})
2830
# Both are empty
2931
isempty(p1) && isempty(p2) && (return nothing)

src/Mesh/Slicer.jl

Lines changed: 40 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,16 @@ the mesh that contains the indices of the planes where each triangle lies.
1616
1717
# Example
1818
```jldoctest output=false
19-
julia> import ColorTypes: RGB
19+
julia> import ColorTypes: RGB;
2020
2121
julia> mesh = Rectangle(length = 1.0, width = 1.0);
2222
2323
julia> slice!(mesh, Y = collect(-0.25:0.25:0.5), Z = collect(0.25:0.25:1));
2424
2525
julia> add_property!(mesh, :colors, rand(RGB));
2626
27+
julia> using PlantViz;
28+
2729
julia> render(mesh, wireframe = true);
2830
```
2931
"""
@@ -126,9 +128,11 @@ A tuple containing:
126128
127129
# Example
128130
```jldoctest
131+
julia> import PlantGeomPrimitives as PG;
132+
129133
julia> m = Rectangle(length = 1.0, width = 1.0);
130134
131-
julia> check_intersection(m, 1, 2, 0.5, 1);
135+
julia> PG.check_intersection(m, 1, 2, 0.5, 1);
132136
```
133137
"""
134138
function check_intersection(m::Mesh, t::Integer, i::Integer, h::Real, j::Integer)
@@ -207,12 +211,14 @@ The next vertex index in the sequence (1, 2, or 3).
207211
208212
# Example
209213
```jldoctest
210-
julia> next(1);
211-
2
212-
julia> next(2);
213-
3
214-
julia> next(3);
215-
1
214+
julia> import PlantGeomPrimitives as PG;
215+
216+
julia> PG.next(1);
217+
218+
julia> PG.next(2);
219+
220+
julia> PG.next(3);
221+
216222
```
217223
"""
218224
next(i::Integer) = mod(i,3) + 1
@@ -238,10 +244,16 @@ A tuple containing the updated slice indices for the two new triangles created f
238244
239245
# Example
240246
```jldoctest
247+
julia> import PlantGeomPrimitives as PG;
248+
241249
julia> mesh = Rectangle(length = 1.0, width = 1.0);
242-
julia> update_edges!(mesh);
243-
julia> nverts_before = length(vertices(mesh))
244-
julia> one_triangle_intersection!(mesh, 1, 2, 0.5, 1, [1,1,1], 2, [1, -1, -1]);
250+
251+
julia> PG.update_edges!(mesh);
252+
253+
julia> nverts_before = length(vertices(mesh));
254+
255+
julia> PG.one_triangle_intersection!(mesh, 1, 2, 0.5, 1, [1,1,1], 2, [1, -1, -1]);
256+
245257
julia> nverts_after = length(vertices(mesh));
246258
```
247259
"""
@@ -288,20 +300,23 @@ Intersect a triangle with a plane, create two new triangles, and add them to the
288300
- `s`: The signs of the distances to the plane for each vertex.
289301
290302
# Returns
291-
A tuple containing the updated slice indices for the three new triangles created
303+
A tuple containing the updated slice indices for the three new triangles created
292304
from the intersection.
293305
294306
# Example
295307
```jldoctest
308+
julia> import PlantGeomPrimitives as PG;
309+
296310
julia> mesh = Rectangle(length = 1.0, width = 1.0);
297311
298-
julia> update_edges!(mesh);
312+
julia> PG.update_edges!(mesh);
299313
300-
julia> nverts_before = length(vertices(mesh))
314+
julia> nverts_before = length(vertices(mesh));
301315
302-
julia> two_triangle_intersections!(mesh, 1, 2, 0.5, 1, [1,1,1], 2, [1, -1, -1]);
316+
julia> PG.two_triangle_intersections!(mesh, 1, 2, 0.5, 1, [1,1,1], 2, [1, -1, -1]);
303317
304318
julia> nverts_after = length(vertices(mesh));
319+
305320
```
306321
"""
307322
function two_triangle_intersections!(mesh, t, i, h, vi, slindex, j, s)
@@ -356,13 +371,15 @@ The 3D coordinates of the intersection point.
356371
357372
# Example
358373
```jldoctest
374+
julia> import PlantGeomPrimitives as PG;
375+
359376
julia> vs = [Vec(0.0, 0.0, 0.0), Vec(1.0, 0.0, 0.0), Vec(0.0, 1.0, 0.0)];
360377
361378
julia> es = [vs[2] - vs[1], vs[3] - vs[2], vs[3] - vs[1]]; # Examples: intersect the triangle with the plane x = 0.5, using vertex 1 as the reference
362379
363-
julia> one_intersection_point(1, 0.5, 3, es, vs); # Intersection point between the plane and the edge opposite to vertex 1
380+
julia> PG.one_intersection_point(1, 0.5, 3, es, vs); # Intersection point between the plane and the edge opposite to vertex 1
364381
365-
julia> one_intersection_point(1, 0.5, 2, es, vs); # Intersection point between the plane and the edge opposite to vertex 2
382+
julia> PG.one_intersection_point(1, 0.5, 2, es, vs); # Intersection point between the plane and the edge opposite to vertex 2
366383
```
367384
"""
368385
function one_intersection_point(i, h, vi, es, vs)
@@ -398,21 +415,23 @@ A tuple containing the 3D coordinates of the two intersection points.
398415
399416
# Example
400417
```jldoctest
418+
julia> import PlantGeomPrimitives as PG;
419+
401420
julia> vs = [Vec(0.0, 0.0, 0.0), Vec(1.0, 0.0, 0.0), Vec(0.0, 1.0, 0.0)];
402421
403422
julia> es = [vs[2] - vs[1], vs[3] - vs[2], vs[1] - vs[3]]; # Examples: intersect the triangle with the plane x = 0.5, using vertex 1 as the reference
404423
405-
julia> two_intersection_points(1, 0.5, 3, es, vs); # Intersection points between the plane and the edges opposite to vertex 1
424+
julia> PG.two_intersection_points(1, 0.5, 3, es, vs); # Intersection points between the plane and the edges opposite to vertex 1
406425
407-
julia> two_intersection_points(1, 0.5, 2, es, vs); # Intersection points between the plane and the edges opposite to vertex 2
426+
julia> PG.two_intersection_points(1, 0.5, 2, es, vs); # Intersection points between the plane and the edges opposite to vertex 2
408427
```
409428
"""
410429
function two_intersection_points(i, h, vi, es, vs)
411430
@inbounds begin
412431
# Choose barycentric coordinate system
413432
vi == 1 && begin vr, e1, e2 = (vs[1], es[1], es[2]) end
414-
vi == 2 && begin vr, e1, e2 = (vs[2], .-es[3], .-es[1]) end
415-
vi == 3 && begin vr, e1, e2 = (vs[3], .-es[2] , es[3]) end
433+
vi == 2 && begin vr, e1, e2 = (vs[2], .-es[3], .-es[1]) end
434+
vi == 3 && begin vr, e1, e2 = (vs[3], .-es[2] , es[3]) end
416435
# Calculate the barycentric coordinate on each axis
417436
# and from that the 3D coordinate of intersection point
418437
d = (h - vr[i])/e1[i]

src/Mesh/Transformations.jl

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,21 +10,25 @@ In-place affine transfrmation of a mesh `m` using a transformation map `trans`.
1010
1111
# Arguments
1212
- `m`: The mesh to be transformed.
13-
- `trans`: The transformation map that defines the affine transformation to be
13+
- `trans`: The transformation map that defines the affine transformation to be
1414
applied to the mesh.
1515
1616
# Returns
1717
The transformed mesh `m` with updated vertices and normals.
1818
1919
# Example
2020
```jldoctest
21+
julia> import CoordinateTransformations as CT;
22+
23+
julia> import PlantGeomPrimitives as PG;
24+
2125
julia> m = Rectangle();
2226
2327
julia> vec = Vec(1.0, 2.0, 3.0);
2428
2529
julia> trans = CT.LinearMap(CT.SDiagonal(vec...));
2630
27-
julia> transform!(m, trans);
31+
julia> PG.transform!(m, trans);
2832
```
2933
"""
3034
function transform!(m::Mesh, trans::CT.AbstractAffineMap)

0 commit comments

Comments
 (0)