API Reference

Exports

GeometryBasics.AbstractMeshType
AbstractMesh

An abstract mesh is a collection of Polytope elements (Simplices / Ngons). The connections are defined via faces(mesh), the coordinates of the elements are returned by coordinates(mesh). Arbitrary meta information can be attached per point or per face

source
GeometryBasics.CylinderType
Cylinder{N, T}

A Cylinder is a 2D rectangle or a 3D cylinder defined by its origin point, its extremity and a radius. origin, extremity and r, must be specified.

source
GeometryBasics.Cylinder2Type
Cylinder2{T}
Cylinder3{T}

A Cylinder2 or Cylinder3 is a 2D/3D cylinder defined by its origin point, its extremity and a radius. origin, extremity and r, must be specified.

source
GeometryBasics.FaceViewType
FaceView{Element, Point, Face, P, F}

FaceView enables to link one array of points via a face array, to generate one abstract array of elements. E.g., this becomes possible:

x = FaceView(rand(Point3f, 10), TriangleFace[(1, 2, 3), (2, 4, 5), ...])
x[1] isa Triangle == true
x isa AbstractVector{<: Triangle} == true
# This means we can use it as a mesh:
Mesh(x) # should just work!
# Can also be used for Points:

linestring = FaceView(points, LineFace[...])
Polygon(linestring)
source
GeometryBasics.HyperRectangleType
HyperRectangle{N, T}

A HyperRectangle is a generalization of a rectangle into N-dimensions. Formally it is the cartesian product of intervals, which is represented by the origin and widths fields, whose indices correspond to each of the N axes.

source
GeometryBasics.HyperSphereType
HyperSphere{N, T}

A HyperSphere is a generalization of a sphere into N-dimensions. A center and radius, r, must be specified.

source
GeometryBasics.LineStringType
LineString(points::AbstractVector{<: AbstractPoint}, skip = 1)

Creates a LineString from a vector of points. With skip == 1, the default, it will connect the line like this:

points = Point[a, b, c, d]
linestring = LineString(points)
@assert linestring == LineString([a => b, b => c, c => d])
source
GeometryBasics.LineStringType
LineString(points::AbstractVector{<: AbstractPoint}, indices::AbstractVector{<: Integer}, skip = 1)

Creates a LineString from a vector of points and an index list. With skip == 1, the default, it will connect the line like this:

points = Point[a, b, c, d]; faces = [1, 2, 3, 4]
linestring = LineString(points, faces)
@assert linestring == LineString([a => b, b => c, c => d])

To make a segmented line, set skip to 2

points = Point[a, b, c, d]; faces = [1, 2, 3, 4]
linestring = LineString(points, faces, 2)
@assert linestring == LineString([a => b, c => d])
source
GeometryBasics.MetaTType
MetaT(geometry, meta::NamedTuple)
MetaT(geometry; meta...)

Returns a MetaT that holds a geometry and its metadata

MetaT acts the same as Meta method. The difference lies in the fact that it is designed to handle geometries and metadata of different/heterogeneous types.

eg: While a Point MetaGeometry is a PointMeta, the MetaT representation is MetaT{Point} The downside being it's not subtyped to AbstractPoint like a PointMeta is.

Example:

julia> MetaT(Point(1, 2), city = "Mumbai")
MetaT{Point{2,Int64},(:city,),Tuple{String}}([1, 2], (city = "Mumbai",))
source
GeometryBasics.NormalUVMeshType
NormalUVMesh{Dim, T}

PlainMesh with normals and uv meta at each point. normalmesh.normals isa AbstractVector{Vec3f} normalmesh.uv isa AbstractVector{Vec2f}

source
GeometryBasics.NormalUVWMeshType
NormalUVWMesh{Dim, T}

PlainMesh with normals and uvw (texture coordinates in 3D) meta at each point. normalmesh.normals isa AbstractVector{Vec3f} normalmesh.uvw isa AbstractVector{Vec3f}

source
GeometryBasics.OffsetIntegerType
OffsetInteger{O, T}

OffsetInteger type mainly for indexing.

  • O - The offset relative to Julia arrays. This helps reduce copying when

communicating with 0-indexed systems such as OpenGL.

source
GeometryBasics.PolygonType
Polygon(exterior::AbstractVector{<:Point})
Polygon(exterior::AbstractVector{<:Point}, interiors::Vector{<:AbstractVector{<:AbstractPoint}})
source
GeometryBasics.PolytopeType

Geometry made of N connected points. Connected as one flat geometry, it makes a Ngon / Polygon. Connected as volume it will be a Simplex / Tri / Cube. Note That Polytope{N} where N == 3 denotes a Triangle both as a Simplex or Ngon.

source
GeometryBasics.RectType
const Rect{N,T} = HyperRectangle{N,T}

A rectangle in N dimensions, formally the cartesian product of intervals. See also HyperRectangle. Its aliases are

T(eltype)Float64Float32Int
N(dim)Rect{N,T}Rectd{N}Rectf{N}Recti{N}
2Rect2{T}Rect2dRect2fRect2i
3Rect3{T}Rect3dRect3fRect3i

There is an additional unexported alias RectT that simply reverses the order of type parameters: RectT{T,N} == Rect{N,T}.

source
GeometryBasics.RectMethod
Rect(vals::Number...)
Rect(vals::Number...)

Rect constructor for individually specified intervals. e.g. Rect(0,0,1,2) has origin == Vec(0,0) and width == Vec(1,2)

source
GeometryBasics.Rect2Type
const Rect{N,T} = HyperRectangle{N,T}

A rectangle in N dimensions, formally the cartesian product of intervals. See also HyperRectangle. Its aliases are

T(eltype)Float64Float32Int
N(dim)Rect{N,T}Rectd{N}Rectf{N}Recti{N}
2Rect2{T}Rect2dRect2fRect2i
3Rect3{T}Rect3dRect3fRect3i

There is an additional unexported alias RectT that simply reverses the order of type parameters: RectT{T,N} == Rect{N,T}.

source
GeometryBasics.Rect2dType
const Rect{N,T} = HyperRectangle{N,T}

A rectangle in N dimensions, formally the cartesian product of intervals. See also HyperRectangle. Its aliases are

T(eltype)Float64Float32Int
N(dim)Rect{N,T}Rectd{N}Rectf{N}Recti{N}
2Rect2{T}Rect2dRect2fRect2i
3Rect3{T}Rect3dRect3fRect3i

There is an additional unexported alias RectT that simply reverses the order of type parameters: RectT{T,N} == Rect{N,T}.

source
GeometryBasics.Rect2fType
const Rect{N,T} = HyperRectangle{N,T}

A rectangle in N dimensions, formally the cartesian product of intervals. See also HyperRectangle. Its aliases are

T(eltype)Float64Float32Int
N(dim)Rect{N,T}Rectd{N}Rectf{N}Recti{N}
2Rect2{T}Rect2dRect2fRect2i
3Rect3{T}Rect3dRect3fRect3i

There is an additional unexported alias RectT that simply reverses the order of type parameters: RectT{T,N} == Rect{N,T}.

source
GeometryBasics.Rect2iType
const Rect{N,T} = HyperRectangle{N,T}

A rectangle in N dimensions, formally the cartesian product of intervals. See also HyperRectangle. Its aliases are

T(eltype)Float64Float32Int
N(dim)Rect{N,T}Rectd{N}Rectf{N}Recti{N}
2Rect2{T}Rect2dRect2fRect2i
3Rect3{T}Rect3dRect3fRect3i

There is an additional unexported alias RectT that simply reverses the order of type parameters: RectT{T,N} == Rect{N,T}.

source
GeometryBasics.Rect3Type
const Rect{N,T} = HyperRectangle{N,T}

A rectangle in N dimensions, formally the cartesian product of intervals. See also HyperRectangle. Its aliases are

T(eltype)Float64Float32Int
N(dim)Rect{N,T}Rectd{N}Rectf{N}Recti{N}
2Rect2{T}Rect2dRect2fRect2i
3Rect3{T}Rect3dRect3fRect3i

There is an additional unexported alias RectT that simply reverses the order of type parameters: RectT{T,N} == Rect{N,T}.

source
GeometryBasics.Rect3dType
const Rect{N,T} = HyperRectangle{N,T}

A rectangle in N dimensions, formally the cartesian product of intervals. See also HyperRectangle. Its aliases are

T(eltype)Float64Float32Int
N(dim)Rect{N,T}Rectd{N}Rectf{N}Recti{N}
2Rect2{T}Rect2dRect2fRect2i
3Rect3{T}Rect3dRect3fRect3i

There is an additional unexported alias RectT that simply reverses the order of type parameters: RectT{T,N} == Rect{N,T}.

source
GeometryBasics.Rect3fType
const Rect{N,T} = HyperRectangle{N,T}

A rectangle in N dimensions, formally the cartesian product of intervals. See also HyperRectangle. Its aliases are

T(eltype)Float64Float32Int
N(dim)Rect{N,T}Rectd{N}Rectf{N}Recti{N}
2Rect2{T}Rect2dRect2fRect2i
3Rect3{T}Rect3dRect3fRect3i

There is an additional unexported alias RectT that simply reverses the order of type parameters: RectT{T,N} == Rect{N,T}.

source
GeometryBasics.Rect3iType
const Rect{N,T} = HyperRectangle{N,T}

A rectangle in N dimensions, formally the cartesian product of intervals. See also HyperRectangle. Its aliases are

T(eltype)Float64Float32Int
N(dim)Rect{N,T}Rectd{N}Rectf{N}Recti{N}
2Rect2{T}Rect2dRect2fRect2i
3Rect3{T}Rect3dRect3fRect3i

There is an additional unexported alias RectT that simply reverses the order of type parameters: RectT{T,N} == Rect{N,T}.

source
GeometryBasics.RectdType
const Rect{N,T} = HyperRectangle{N,T}

A rectangle in N dimensions, formally the cartesian product of intervals. See also HyperRectangle. Its aliases are

T(eltype)Float64Float32Int
N(dim)Rect{N,T}Rectd{N}Rectf{N}Recti{N}
2Rect2{T}Rect2dRect2fRect2i
3Rect3{T}Rect3dRect3fRect3i

There is an additional unexported alias RectT that simply reverses the order of type parameters: RectT{T,N} == Rect{N,T}.

source
GeometryBasics.RectfType
const Rect{N,T} = HyperRectangle{N,T}

A rectangle in N dimensions, formally the cartesian product of intervals. See also HyperRectangle. Its aliases are

T(eltype)Float64Float32Int
N(dim)Rect{N,T}Rectd{N}Rectf{N}Recti{N}
2Rect2{T}Rect2dRect2fRect2i
3Rect3{T}Rect3dRect3fRect3i

There is an additional unexported alias RectT that simply reverses the order of type parameters: RectT{T,N} == Rect{N,T}.

source
GeometryBasics.RectiType
const Rect{N,T} = HyperRectangle{N,T}

A rectangle in N dimensions, formally the cartesian product of intervals. See also HyperRectangle. Its aliases are

T(eltype)Float64Float32Int
N(dim)Rect{N,T}Rectd{N}Rectf{N}Recti{N}
2Rect2{T}Rect2dRect2fRect2i
3Rect3{T}Rect3dRect3fRect3i

There is an additional unexported alias RectT that simply reverses the order of type parameters: RectT{T,N} == Rect{N,T}.

source
GeometryBasics.SimplexType

A Simplex is a generalization of an N-dimensional tetrahedra and can be thought of as a minimal convex set containing the specified points.

  • A 0-simplex is a point.
  • A 1-simplex is a line segment.
  • A 2-simplex is a triangle.
  • A 3-simplex is a tetrahedron.

Note that this datatype is offset by one compared to the traditional mathematical terminology. So a one-simplex is represented as Simplex{2,T}. This is for a simpler implementation.

It applies to infinite dimensions. The structure of this type is designed to allow embedding in higher-order spaces by parameterizing on T.

source
GeometryBasics.TesselationType
Tesselation(primitive, nvertices)

For abstract geometries, when we generate a mesh from them, we need to decide how fine grained we want to mesh them. To transport this information to the various decompose methods, you can wrap it in the Tesselation object e.g. like this:

sphere = Sphere(Point3f(0), 1)
m1 = mesh(sphere) # uses a default value for tesselation
m2 = mesh(Tesselation(sphere, 64)) # uses 64 for tesselation
length(coordinates(m1)) != length(coordinates(m2))

For grid based tesselation, you can also use a tuple: ```julia rect = Rect2(0, 0, 1, 1) Tesselation(rect, (5, 5))

source
GeometryBasics.TupleViewType
TupleView{T, N, Skip, A}

TupleView, groups elements of an array as tuples. N is the dimension of the tuple, M tells how many elements to skip to the next tuple. By default TupleView{N} defaults to skip N items.

a few examples:


x = [1, 2, 3, 4, 5, 6]
TupleView{2, 1}(x):
> [(1, 2), (2, 3), (3, 4), (4, 5), (5, 6)]

TupleView{2}(x):
> [(1, 2), (3, 4), (5, 6)]

TupleView{2, 3}(x):
> [(1, 2), (4, 5)]

TupleView{3, 1}(x):
> [(1, 2, 3), (2, 3, 4), (3, 4, 5), (4, 5, 6)]

TupleView can be used together with reinterpret:

x = [1, 2, 3, 4]
y = reinterpret(Point{2, Int}, TupleView{2, 1}(x))
> [Point(1, 2), Point(2, 3), Point(3, 4)]
source
GeometryBasics.UVMeshType
UVMesh{Dim, T}

PlainMesh with texture coordinates meta at each point. uvmesh.uv isa AbstractVector{Vec2f}

source
GeometryBasics.areaMethod
area(contour::AbstractVector{AbstractPoint}})

Calculate the area of a polygon.

For 2D points, the oriented area is returned (negative when the points are oriented clockwise).

source
GeometryBasics.areaMethod
area(vertices::AbstractVector{AbstractPoint{3}}, faces::AbstractVector{TriangleFace})

Calculate the area of all triangles.

source
GeometryBasics.areaMethod
area(vertices::AbstractVector{AbstractPoint{3}}, face::TriangleFace)

Calculate the area of one triangle.

source
GeometryBasics.connectMethod
connect(points::AbstractVector{<: AbstractPoint}, P::Type{<: Polytope{N}}, skip::Int = N)

Creates a view that connects a number of points to a Polytope P. Between each polytope, skip elements are skipped untill the next starts. Example: ```julia x = connect(Point[(1, 2), (3, 4), (5, 6), (7, 8)], Line, 2) x == [Line(Point(1, 2), Point(3, 4)), Line(Point(5, 6), Point(7, 8))]

source
GeometryBasics.coordinatesMethod
coordinates(geometry)

Returns the edges/vertices/coordinates of a geometry. Is allowed to return lazy iterators! Use decompose(ConcretePointType, geometry) to get Vector{ConcretePointType} with ConcretePointType to be something like Point{3, Float32}.

source
GeometryBasics.decomposeMethod
decompose(facetype, contour::AbstractArray{<:AbstractPoint})

Triangulate a Polygon without hole.

Returns a Vector{facetype} defining indexes into contour.

source
GeometryBasics.facesMethod
faces(geometry)

Returns the face connections of a geometry. Is allowed to return lazy iterators! Use decompose(ConcreteFaceType, geometry) to get Vector{ConcreteFaceType} with ConcreteFaceType to be something like TriangleFace{Int}.

source
GeometryBasics.metafreeMethod
metafree(x::MetaT)
metafree(x::Array{MetaT})

Free the MetaT from metadata i.e. returns the geometry/array of geometries

source
GeometryBasics.normalsMethod
normals{VT,FD,FT,FO}(vertices::Vector{Point{3, VT}},
                    faces::Vector{Face{FD,FT,FO}},
                    NT = Normal{3, VT})

Compute all vertex normals.

source
GeometryBasics.split_intersectionsMethod
split_intersections(points::AbstractVector{AbstractPoint})

Splits polygon points into it's self intersecting parts. Only 1 intersection is handled right now.

source
GeometryBasics.volumeMethod
volume(mesh)

Calculate the signed volume of all tetrahedra. Be sure the orientation of your surface is right.

source
GeometryBasics.volumeMethod
volume(triangle)

Calculate the signed volume of one tetrahedron. Be sure the orientation of your surface is right.

source

Private

GeometryBasics.NgonType

Fixed Size Polygon, e.g.

  • N 1-2 : Illegal!
  • N = 3 : Triangle
  • N = 4 : Quadrilateral (or Quad, Or tetragon)
  • N = 5 : Pentagon
  • ...
source
GeometryBasics.RectTType
const Rect{N,T} = HyperRectangle{N,T}

A rectangle in N dimensions, formally the cartesian product of intervals. See also HyperRectangle. Its aliases are

T(eltype)Float64Float32Int
N(dim)Rect{N,T}Rectd{N}Rectf{N}Recti{N}
2Rect2{T}Rect2dRect2fRect2i
3Rect3{T}Rect3dRect3fRect3i

There is an additional unexported alias RectT that simply reverses the order of type parameters: RectT{T,N} == Rect{N,T}.

source
Base.:*Method
*(m::Mat, h::Rect)

Transform a Rect using a matrix. Maintains axis-align properties so a significantly larger Rect may be generated.

source
Base.inMethod
in(b1::Rect, b2::Rect)

Check if Rect b1 is contained in b2. This does not use strict inequality, so Rects may share faces and this will still return true.

source
Base.inMethod
in(pt::VecTypes, b1::Rect{N, T})

Check if a point is contained in a Rect. This will return true if the point is on a face of the Rect.

source
Base.inMethod
in(point, triangle)

Determine if a point is inside of a triangle.

source
Base.isemptyMethod
isempty(h::Rect)

Return true if any of the widths of h are negative.

source
GeometryBasics.MetaFreeMethod
MetaFree(::Type{T})

Returns the original type containing no metadata for T E.g:

MetaFree(PointMeta) == Point
source
GeometryBasics.attributesMethod
attributes(hasmeta)

Returns all attributes of meta as a Dict{Symbol, Any}. Needs to be overloaded, and returns empty dict for non overloaded types! Gets overloaded by default for all Meta types.

source
GeometryBasics.getcolumnsMethod
getcolumns(t, colnames::Symbol...)

Gets a column from any Array like (Table/AbstractArray). For AbstractVectors, a column will be the field names of the element type.

source
GeometryBasics.meshMethod
mesh(primitive::GeometryPrimitive;
     pointtype=Point, facetype=GLTriangle,
     uv=nothing, normaltype=nothing)

Creates a mesh from primitive.

Uses the element types from the keyword arguments to create the attributes. The attributes that have their type set to nothing are not added to the mesh. Note, that this can be an Int or Tuple{Int, Int}`, when the primitive is grid based. It also only losely correlates to the number of vertices, depending on the algorithm used. #TODO: find a better number here!

source
GeometryBasics.meshMethod
mesh(polygon::AbstractVector{P}; pointtype=P, facetype=GLTriangleFace,
     normaltype=nothing)

Create a mesh from a polygon given as a vector of points, using triangulation.

source