-
Notifications
You must be signed in to change notification settings - Fork 2
/
polydata.jl
49 lines (34 loc) · 1.16 KB
/
polydata.jl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
"""
PolyData
Defines cell types for polygonal datasets.
The following singleton types are defined:
- `PolyData.Verts` for vertices,
- `PolyData.Lines` for lines,
- `PolyData.Strips` for triangular strips,
- `PolyData.Polys` for polygons.
"""
module PolyData
import ..VTKCellTypes: nodes
abstract type CellType end
struct Verts <: CellType end
struct Lines <: CellType end
struct Strips <: CellType end
struct Polys <: CellType end
# All of these cell types can take any number of grid points.
# (This is for compatibility with VTKCellTypes for unstructured datasets.)
nodes(::CellType) = -1
number_attr(::Type{Verts}) = "NumberOfVerts"
number_attr(::Type{Lines}) = "NumberOfLines"
number_attr(::Type{Strips}) = "NumberOfStrips"
number_attr(::Type{Polys}) = "NumberOfPolys"
xml_node(::Type{Verts}) = "Verts"
xml_node(::Type{Lines}) = "Lines"
xml_node(::Type{Strips}) = "Strips"
xml_node(::Type{Polys}) = "Polys"
end
import .PolyData
export PolyData
const PolyCell{T} = MeshCell{T} where {T <: PolyData.CellType}
Base.eltype(::Type{T}) where {T <: PolyCell} = cell_type(T)
cell_type(::Type{<:PolyCell{T}}) where {T} = T
grid_type(::Type{<:PolyCell}) = VTKPolyData()