@@ -10,7 +10,7 @@ Base.ndims(::AbstractGeometry{Dim}) where {Dim} = Dim
1010"""
1111 Polytope{Dim, T} <: AbstractGeometry{Dim, T}
1212
13- A Polytope is the generalization of a Polygon to higher dimensions, i.e. a
13+ A Polytope is the generalization of a Polygon to higher dimensions, i.e. a
1414geometric object consisting of flat faces.
1515
1616A `Polygon` and `Ngon` are both 2D `Polytope`s. A `Simplex` is the simplest
@@ -22,7 +22,7 @@ abstract type AbstractPolygon{Dim,T} <: Polytope{Dim,T} end
2222"""
2323 AbstractFace{N_indices, T} <: StaticVector{N_indices, T}
2424
25- Parent type for all face types. The standard face type is typically a
25+ Parent type for all face types. The standard face type is typically a
2626`GLTriangleFace = NgonFace{3, GLIndex}`.
2727"""
2828abstract type AbstractFace{N,T} <: StaticVector{N,T} end
@@ -109,7 +109,7 @@ Base.:(==)(f1::FT, f2::FT) where {FT <: AbstractFace{2}} = minmax(f1.data...) ==
109109Base. hash (f:: AbstractFace{2} , h:: UInt ) = hash (minmax (f. data... ), h)
110110
111111function Base.:(== )(f1:: FT , f2:: FT ) where {FT <: AbstractFace{3} }
112- return (f1. data == f2. data) || (f1. data == (f2[2 ], f2[3 ], f2[1 ])) ||
112+ return (f1. data == f2. data) || (f1. data == (f2[2 ], f2[3 ], f2[1 ])) ||
113113 (f1. data == (f2[3 ], f2[1 ], f2[2 ]))
114114end
115115function Base. hash (f:: AbstractFace{3} , h:: UInt )
@@ -347,6 +347,7 @@ struct LineString{Dim, T<:Real} <: AbstractGeometry{Dim, T}
347347 points:: Vector{Point{Dim, T}}
348348end
349349Base. length (ls:: LineString ) = length (coordinates (ls))
350+ Base.:(== )(a:: LineString , b:: LineString ) = a. points == b. points
350351coordinates (ls:: LineString ) = ls. points
351352
352353struct MultiLineString{Dim, T<: Real } <: AbstractGeometry{Dim, T}
@@ -382,7 +383,7 @@ Base.length(mpt::MultiPoint) = length(mpt.points)
382383"""
383384 FaceView(data, faces)
384385
385- A FaceView is an alternative to passing a vertex attribute directly to a mesh.
386+ A FaceView is an alternative to passing a vertex attribute directly to a mesh.
386387It bundles `data` with a new set of `faces` which may index that data differently
387388from the faces defined in a mesh. This can be useful to avoid duplication in `data`.
388389
@@ -395,7 +396,7 @@ per_face_normals = FaceView(
395396)
396397```
397398
398- If you need a mesh with strictly per-vertex data, e.g. for rendering, you can use
399+ If you need a mesh with strictly per-vertex data, e.g. for rendering, you can use
399400`expand_faceviews(mesh)` to convert every vertex attribute to be per-vertex. This
400401will duplicate data and reorder faces as needed.
401402
@@ -457,7 +458,7 @@ function verify(fs::AbstractVector{FT}, fv::FaceView, name = nothing) where {FT
457458 return true
458459end
459460
460- # Dodgy definitions... (since attributes can be FaceView or Array it's often
461+ # Dodgy definitions... (since attributes can be FaceView or Array it's often
461462# useful to treat a FaceView like the vertex data it contains)
462463Base. length (x:: FaceView ) = length (values (x))
463464# Base.iterate(x::FaceView) = iterate(values(x))
485486"""
486487 AbstractMesh
487488
488- An abstract mesh is a collection of Polytope elements (Simplices / Ngons). The
489- connections are defined via faces(mesh) and the coordinates of the elements are
489+ An abstract mesh is a collection of Polytope elements (Simplices / Ngons). The
490+ connections are defined via faces(mesh) and the coordinates of the elements are
490491returned by coordinates(mesh).
491492"""
492493abstract type AbstractMesh{Dim, T} <: AbstractGeometry{Dim, T} end
@@ -504,9 +505,9 @@ struct Mesh{...}
504505end
505506```
506507
507- A vertex typically carries multiple distinct pieces of data, e.g. a position,
508- a normal, a texture coordinate, etc. We call those pieces of data vertex
509- attributes. The `vertex_attributes` field contains the name and a collection
508+ A vertex typically carries multiple distinct pieces of data, e.g. a position,
509+ a normal, a texture coordinate, etc. We call those pieces of data vertex
510+ attributes. The `vertex_attributes` field contains the name and a collection
510511`<: AbstractVector` or `<: FaceView` for each attribute. The n-th element of that
511512collection is the value of the corresponding attribute for the n-th vertex.
512513
@@ -517,27 +518,27 @@ vertex_attributes[:normal] = [normal1, normal2, normal3, ...]
517518...
518519```
519520
520- A `NamedTuple` is used here to allow different meshes to carry different vertex
521- attributes while also keeping things type stable. The constructor enforces a
521+ A `NamedTuple` is used here to allow different meshes to carry different vertex
522+ attributes while also keeping things type stable. The constructor enforces a
522523few restrictions:
523524- The first attribute must be named `position` and must have a `Point{PositionDim, PositionType}` eltype.
524- - Each vertex attribute must refer to the same number of vertices. (All vertex attributes defined by
525+ - Each vertex attribute must refer to the same number of vertices. (All vertex attributes defined by
525526AbstractVector must match in length. For FaceViews, the number of faces needs to match.)
526527
527- See also: [`vertex_attributes`](@ref), [`coordinates`](@ref), [`normals`](@ref),
528- [`texturecoordinates`](@ref), [`decompose`](@ref), [`FaceView`](@ref),
528+ See also: [`vertex_attributes`](@ref), [`coordinates`](@ref), [`normals`](@ref),
529+ [`texturecoordinates`](@ref), [`decompose`](@ref), [`FaceView`](@ref),
529530[`expand_faceviews`](@ref)
530531
531- The `faces` field is a collection `<: AbstractVector{FaceType}` containing faces
532+ The `faces` field is a collection `<: AbstractVector{FaceType}` containing faces
532533that describe how vertices are connected. Typically these are `(GL)TriangleFace`s
533534or `QuadFace`s, but they can be any collection of vertex indices `<: AbstractFace`.
534535
535536See also: [`faces`](@ref), [`decompose`](@ref)
536537
537- The `views` field can be used to separate the mesh into mutliple submeshes. Each
538- submesh is described by a "view" into the `faces` vector, i.e. submesh n uses
539- `mesh.faces[mesh.views[n]]`. A `Mesh` can be constructed without `views`, which
540- results in an empty `views` vector.
538+ The `views` field can be used to separate the mesh into mutliple submeshes. Each
539+ submesh is described by a "view" into the `faces` vector, i.e. submesh n uses
540+ `mesh.faces[mesh.views[n]]`. A `Mesh` can be constructed without `views`, which
541+ results in an empty `views` vector.
541542
542543See also: [`merge`](@ref), [`split_mesh`](@ref)
543544"""
@@ -554,7 +555,7 @@ struct Mesh{
554555 views:: Vector{UnitRange{Int}}
555556
556557 function Mesh (
557- vertex_attributes:: NamedTuple{Names, VAT} ,
558+ vertex_attributes:: NamedTuple{Names, VAT} ,
558559 fs:: FVT ,
559560 views:: Vector{UnitRange{Int}} = UnitRange{Int}[]
560561 ) where {
@@ -625,7 +626,7 @@ texturecoordinates(mesh::Mesh) = hasproperty(mesh, :uv) ? mesh.uv : nothing
625626"""
626627 vertex_attributes(mesh::Mesh)
627628
628- Returns a dictionairy containing the vertex attributes of the given mesh.
629+ Returns a dictionairy containing the vertex attributes of the given mesh.
629630Mutating these will change the mesh.
630631"""
631632vertex_attributes (mesh:: Mesh ) = getfield (mesh, :vertex_attributes )
@@ -634,7 +635,7 @@ Base.getindex(mesh::Mesh, i::Integer) = mesh.position[mesh.faces[i]]
634635Base. length (mesh:: Mesh ) = length (mesh. faces)
635636
636637function Base.:(== )(a:: Mesh , b:: Mesh )
637- return (a. vertex_attributes == b. vertex_attributes) &&
638+ return (a. vertex_attributes == b. vertex_attributes) &&
638639 (faces (a) == faces (b)) && (a. views == b. views)
639640end
640641
@@ -654,17 +655,17 @@ end
654655
655656Constructs a mesh from the given arguments.
656657
657- If `positions` are given explicitly, they are merged with other vertex attributes
658+ If `positions` are given explicitly, they are merged with other vertex attributes
658659under the name `position`. Otherwise they must be part of `attributes`. If `faces`
659660are not given `attributes.position` must be a FaceView.
660661
661- Any other vertex attribute can be either an `AbstractVector` or a `FaceView`
662+ Any other vertex attribute can be either an `AbstractVector` or a `FaceView`
662663thereof. Every vertex attribute that is an `AbstractVector` must be sufficiently
663664large to be indexable by `mesh.faces`. Every vertex attribute that is a `FaceView`
664665must contain similar faces to `mesh.faces`, i.e. contain the same number of faces
665666and have faces of matching length.
666667
667- `views` can be defined optionally to implicitly split the mesh into multi
668+ `views` can be defined optionally to implicitly split the mesh into multi
668669sub-meshes. This is done by providing ranges for indexing faces which correspond
669670to the sub-meshes. By default this is left empty.
670671"""
@@ -673,7 +674,7 @@ function Mesh(faces::AbstractVector{<:AbstractFace}; views::Vector{UnitRange{Int
673674end
674675
675676function Mesh (points:: AbstractVector{Point{Dim, T}} ,
676- faces:: AbstractVector{<:AbstractFace} ;
677+ faces:: AbstractVector{<:AbstractFace} ;
677678 views = UnitRange{Int}[], kwargs... ) where {Dim, T}
678679 va = (position = points, kwargs... )
679680 return Mesh (va, faces, views)
@@ -716,13 +717,13 @@ Constructs a MetaMesh either from another `mesh` or by constructing another mesh
716717with the given `positions` and `faces`. Any keyword arguments given will be
717718stored in the `meta` field in `MetaMesh`.
718719
719- This struct is meant to be used for storage of non-vertex data. Any vertex
720- related data should be stored as a vertex attribute in `Mesh`. One example of such
720+ This struct is meant to be used for storage of non-vertex data. Any vertex
721+ related data should be stored as a vertex attribute in `Mesh`. One example of such
721722data is material data, which is defined per view in `mesh.views`, i.e. per submesh.
722723
723- The metadata added to the MetaMesh can be manipulated with Dict-like operations
724- (getindex, setindex!, get, delete, keys, etc). Vertex attributes can be accessed
725- via fields and the same getters as mesh. The mesh itself can be retrieved with
724+ The metadata added to the MetaMesh can be manipulated with Dict-like operations
725+ (getindex, setindex!, get, delete, keys, etc). Vertex attributes can be accessed
726+ via fields and the same getters as mesh. The mesh itself can be retrieved with
726727`Mesh(metamesh)`.
727728"""
728729function MetaMesh (mesh:: AbstractMesh ; kwargs... )
0 commit comments