Skip to content

Commit 5a7d6e2

Browse files
authored
rename tesselation to tessellation (#227)
* tesselation -> tessellation * add deprecation notice
1 parent 159f118 commit 5a7d6e2

File tree

7 files changed

+54
-46
lines changed

7 files changed

+54
-46
lines changed

docs/src/primitives.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ r2 = Rect3f(Point3f(-1), Vec3f(2))
1919
r3 = Rect2i(0, 0, 1, 1)
2020
```
2121

22-
Rect2 supports normal and texture coordinate generation as well as tesselation.
23-
Without tesselation, the coordinates of 2D Rects are defined in anti-clockwise order.
24-
Rect3 supports normals and texture coordinates, but not tesselation.
22+
Rect2 supports normal and texture coordinate generation as well as tessellation.
23+
Without tessellation, the coordinates of 2D Rects are defined in anti-clockwise order.
24+
Rect3 supports normals and texture coordinates, but not tessellation.
2525

2626
Shorthands:
2727

@@ -44,7 +44,7 @@ s2 = Sphere(Point3f(0, 0, 1), 1)
4444
s3 = Circle(Point2d(0), 2.0)
4545
```
4646

47-
Circle and Sphere support normal and texture coordinate generation as well as tesselation.
47+
Circle and Sphere support normal and texture coordinate generation as well as tessellation.
4848
The coordinates of Circle are defined in anti-clockwise order.
4949

5050
#### Cylinder
@@ -55,7 +55,7 @@ A `Cylinder` is a 3D shape defined by two points and a radius.
5555
c = Cylinder(Point3f(-1, 0, 0), Point3f(0, 0, 1), 0.3f0) # start point, end point, radius
5656
```
5757

58-
Cylinder supports normals an Tesselation, but currently no texture coordinates.
58+
Cylinder supports normals an Tessellation, but currently no texture coordinates.
5959

6060
#### Pyramid
6161

@@ -67,18 +67,18 @@ It is defined by by the center point of the base, its height and its width.
6767
p = Pyramid(Point3f(0), 1f0, 0.3f0) # center, height, width
6868
```
6969

70-
Pyramid supports normals, but currently no texture coordinates or tesselation
70+
Pyramid supports normals, but currently no texture coordinates or tessellation
7171

72-
## Tesselation
72+
## Tessellation
7373

74-
In GeometryBasics `Tesselation` is a wrapper type for primitives which communicates
74+
In GeometryBasics `Tessellation` is a wrapper type for primitives which communicates
7575
how dense the mesh generated from one should be.
7676

77-
```@repl tesselation
78-
t = Tesselation(Cylinder(Point3f(0), Point3f(0,0,1), 0.2), 32) # 32 vertices for each circle
77+
```@repl tessellation
78+
t = Tessellation(Cylinder(Point3f(0), Point3f(0,0,1), 0.2), 32) # 32 vertices for each circle
7979
normal_mesh(t)
8080
81-
t = Tesselation(Rect2(Point2f(0), Vec2f(1)), (8, 6)) # 8 vertices in x direction by 6 in y direction
81+
t = Tessellation(Rect2(Point2f(0), Vec2f(1)), (8, 6)) # 8 vertices in x direction by 6 in y direction
8282
triangle_mesh(t)
8383
```
8484

@@ -89,8 +89,8 @@ This will also be enough to automatically generate normals for a 3D primitive an
8989
You can also implement functions to generate them directly with `normals(primitive)` and `texturecoordinates(primitive)`.
9090
Depending on your primitive this might be necessary to get the normals and uvs you want.
9191

92-
To be compatible with `Tesselation` all of the functions mentioned above should implement a second tesselation argument.
93-
This will be the second argument passed to the Tesselation constructor.
92+
To be compatible with `Tessellation` all of the functions mentioned above should implement a second tessellation argument.
93+
This will be the second argument passed to the Tessellation constructor.
9494
It's up to you to decide what makes sense here, though typically it's just an integer that more or less corresponds to the number of generated vertices.
9595

9696
#### Example

src/GeometryBasics.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ export decompose, coordinates, faces, normals, decompose_uv, decompose_normals,
4343
texturecoordinates, vertex_attributes
4444
export expand_faceviews
4545
export face_normals
46-
export Tesselation, Normal, UV, UVW
46+
export Tessellation, Normal, UV, UVW
4747
export AbstractMesh, Mesh, MetaMesh, FaceView
4848

4949

src/interfaces.jl

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -58,58 +58,60 @@ something like `Vec2f`.
5858
texturecoordinates(primitive, nvertices=nothing) = nothing
5959

6060
"""
61-
Tesselation(primitive, nvertices)
61+
Tessellation(primitive, nvertices)
6262
6363
When generating a mesh from an abstract geometry, we can typically generate it
6464
at different levels of detail, i.e. with different amounts of vertices. The
65-
`Tesselation` wrapper allows you to specify this level of detail. When generating
66-
a mesh from a tesselated geometry, the added information will be passed to
65+
`Tessellation` wrapper allows you to specify this level of detail. When generating
66+
a mesh from a tessellated geometry, the added information will be passed to
6767
`coordinates`, `faces`, etc.
6868
6969
```julia
7070
sphere = Sphere(Point3f(0), 1)
71-
m1 = mesh(sphere) # uses a default value for tesselation
72-
m2 = mesh(Tesselation(sphere, 64)) # uses 64 for tesselation
71+
m1 = mesh(sphere) # uses a default value for tessellation
72+
m2 = mesh(Tessellation(sphere, 64)) # uses 64 for tessellation
7373
length(coordinates(m1)) != length(coordinates(m2))
7474
```
7575
76-
For grid based tesselation, you can also use a tuple:
76+
For grid based tessellation, you can also use a tuple:
7777
7878
```julia
7979
rect = Rect2(0, 0, 1, 1)
80-
Tesselation(rect, (5, 5))
80+
Tessellation(rect, (5, 5))
8181
```
8282
"""
83-
struct Tesselation{Dim,T,Primitive,NGrid} <: AbstractGeometry{Dim, T}
83+
struct Tessellation{Dim,T,Primitive,NGrid} <: AbstractGeometry{Dim, T}
8484
primitive::Primitive
8585
nvertices::NTuple{NGrid,Int}
8686
end
8787

88-
function Tesselation(primitive::GeometryPrimitive{Dim,T},
88+
Base.@deprecate_binding Tesselation Tessellation
89+
90+
function Tessellation(primitive::GeometryPrimitive{Dim,T},
8991
nvertices::NTuple{N,<:Integer}) where {Dim,T,N}
90-
return Tesselation{Dim,T,typeof(primitive),N}(primitive, Int.(nvertices))
92+
return Tessellation{Dim,T,typeof(primitive),N}(primitive, Int.(nvertices))
9193
end
9294

93-
Tesselation(primitive, nvertices::Integer) = Tesselation(primitive, (nvertices,))
95+
Tessellation(primitive, nvertices::Integer) = Tessellation(primitive, (nvertices,))
9496

9597
# This is a bit lazy, I guess we should just refactor these methods
96-
# to directly work on Tesselation - but this way it's backward compatible and less
98+
# to directly work on Tessellation - but this way it's backward compatible and less
9799
# refactor work :D
98-
nvertices(tesselation::Tesselation) = tesselation.nvertices
99-
nvertices(tesselation::Tesselation{T,N,P,1}) where {T,N,P} = tesselation.nvertices[1]
100+
nvertices(tessellation::Tessellation) = tessellation.nvertices
101+
nvertices(tessellation::Tessellation{T,N,P,1}) where {T,N,P} = tessellation.nvertices[1]
100102

101-
function coordinates(tesselation::Tesselation)
102-
return coordinates(tesselation.primitive, nvertices(tesselation))
103+
function coordinates(tessellation::Tessellation)
104+
return coordinates(tessellation.primitive, nvertices(tessellation))
103105
end
104-
faces(tesselation::Tesselation) = faces(tesselation.primitive, nvertices(tesselation))
105-
normals(tesselation::Tesselation) = normals(tesselation.primitive, nvertices(tesselation))
106-
function texturecoordinates(tesselation::Tesselation)
107-
return texturecoordinates(tesselation.primitive, nvertices(tesselation))
106+
faces(tessellation::Tessellation) = faces(tessellation.primitive, nvertices(tessellation))
107+
normals(tessellation::Tessellation) = normals(tessellation.primitive, nvertices(tessellation))
108+
function texturecoordinates(tessellation::Tessellation)
109+
return texturecoordinates(tessellation.primitive, nvertices(tessellation))
108110
end
109111

110112
## Decompose methods
111113
# Dispatch type to make `decompose(UV{Vec2f}, primitive)` work
112-
# and to pass through tesselation information
114+
# and to pass through tessellation information
113115

114116
struct UV{T} end
115117
UV(::Type{T}) where {T} = UV{T}()

src/precompiles.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ using PrecompileTools: @setup_workload, @compile_workload
2727

2828
# Other primitives
2929
uv_normal_mesh(Rect2(0,0,1,1))
30-
uv_normal_mesh(Tesselation(Sphere(Point3f(0), 1f0), 3))
30+
uv_normal_mesh(Tessellation(Sphere(Point3f(0), 1f0), 3))
3131
uv_normal_mesh(Cylinder(Point3f(0), Point3f(0,0,1), 1f0))
3232
uv_normal_mesh(Pyramid(Point3f(0), 1f0, 1f0))
3333

test/geometrytypes.jl

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,16 +33,16 @@ using Test, GeometryBasics
3333
(4, 5, 6)
3434
]
3535

36-
@test decompose(Point3{Float64}, Tesselation(s, 8)) positions
36+
@test decompose(Point3{Float64}, Tessellation(s, 8)) positions
3737

3838
_faces = TriangleFace[
3939
(9, 2, 1), (9, 3, 2), (9, 4, 3), (9, 1, 4), (1, 2, 6), (1, 6, 5),
4040
(2, 3, 7), (2, 7, 6), (3, 4, 8), (3, 8, 7), (4, 1, 5), (4, 5, 8),
4141
(10, 5, 6), (10, 6, 7), (10, 7, 8), (10, 8, 5)]
4242

43-
@test _faces == decompose(TriangleFace{Int}, Tesselation(s, 8))
43+
@test _faces == decompose(TriangleFace{Int}, Tessellation(s, 8))
4444

45-
m = triangle_mesh(Tesselation(s, 8))
45+
m = triangle_mesh(Tessellation(s, 8))
4646
@test m === triangle_mesh(m)
4747
@test GeometryBasics.faces(m) == decompose(GLTriangleFace, _faces)
4848
@test GeometryBasics.coordinates(m) positions
@@ -69,7 +69,7 @@ using Test, GeometryBasics
6969
]
7070
)
7171

72-
@test ns == decompose_normals(Tesselation(s, 8))
72+
@test ns == decompose_normals(Tessellation(s, 8))
7373

7474
muv = uv_mesh(s)
7575
@test !hasproperty(muv, :uv) # not defined yet
@@ -168,7 +168,7 @@ end
168168
@testset "HyperSphere" begin
169169
sphere = Sphere{Float32}(Point3f(0), 1.0f0)
170170

171-
points = decompose(Point, Tesselation(sphere, 3))
171+
points = decompose(Point, Tessellation(sphere, 3))
172172
point_target = Point{3,Float32}[[0.0, 0.0, 1.0], [1.0, 0.0, 6.12323e-17],
173173
[1.22465e-16, 0.0, -1.0], [-0.0, 0.0, 1.0],
174174
[-1.0, 1.22465e-16, 6.12323e-17],
@@ -177,14 +177,14 @@ end
177177
[1.22465e-16, -2.99952e-32, -1.0]]
178178
@test points point_target
179179

180-
f = decompose(TriangleFace{Int}, Tesselation(sphere, 3))
180+
f = decompose(TriangleFace{Int}, Tessellation(sphere, 3))
181181
face_target = TriangleFace{Int}[[1, 2, 5], [1, 5, 4], [2, 3, 6], [2, 6, 5], [4, 5, 8],
182182
[4, 8, 7], [5, 6, 9], [5, 9, 8]]
183183
@test f == face_target
184184
circle = Circle(Point2f(0), 1.0f0)
185-
points = decompose(Point2f, Tesselation(circle, 20))
185+
points = decompose(Point2f, Tessellation(circle, 20))
186186
@test length(points) == 20
187-
tess_circle = Tesselation(circle, 32)
187+
tess_circle = Tessellation(circle, 32)
188188
mesh = triangle_mesh(tess_circle)
189189
@test decompose(Point2f, mesh) decompose(Point2f, tess_circle)
190190
end

test/polygons.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
end
77

88
rect = Rect2f(0, 0, 1, 1)
9-
hole = Tesselation(Circle(Point2f(0.5), 0.2), 8)
9+
hole = Tessellation(Circle(Point2f(0.5), 0.2), 8)
1010
poly2 = Polygon(decompose(Point2f, rect), [decompose(Point2f, hole)])
1111
poly1 = Polygon(rect, [hole])
1212
@test poly1 == poly2

test/runtests.jl

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ end
141141
mesh = Mesh(points, tfaces)
142142
meshuv = MetaMesh(points, tfaces; uv=uv)
143143
meshuvnormal = MetaMesh(points, tfaces; normal=ns, uv=uv)
144-
t = Tesselation(Rect2f(0, 0, 2, 2), (30, 30))
144+
t = Tessellation(Rect2f(0, 0, 2, 2), (30, 30))
145145

146146
m = GeometryBasics.mesh(t; pointtype=Point3f, facetype=QuadFace{Int})
147147
m2 = GeometryBasics.mesh(m, facetype=QuadFace{GLIndex})
@@ -310,6 +310,12 @@ end
310310
include("geointerface.jl")
311311
end
312312

313+
@testset "Deprecations" begin
314+
# https://github.com/JuliaLang/julia/issues/38780
315+
# @test_warn Tesselation(Rect2f(0, 0, 2, 2), 10)
316+
@test Tesselation(Rect2f(0, 0, 2, 2), 10) == Tessellation(Rect2f(0, 0, 2, 2), 10)
317+
end
318+
313319
include("polygons.jl")
314320

315321
using Aqua

0 commit comments

Comments
 (0)