SpatialTree

Description

abstract class Tinman.Terrain.Util.SpatialTree
<TEntity val>
<TBounds val>
<TCoords val>
<TEntityTrait ref : ISpatialEntityTrait<TEntity, TBounds>>
<TBoundsTrait val : ISpatialBoundsTrait<TCoords, TBounds>>
<TDistanceTrait val : ISpatialDistanceTrait<TEntity, TCoords>>

Derived from

SpatialTreeBase<TBounds> abstract

Extended by

SpatialOctree abstract
SpatialQuadtree abstract

A generic tree data structure for storing spatial entities.

Public / Methods

Add


public method Add → (1)

entity in : TEntity

The entity to add.

Adds the given spatial entity to the tree.

Bounds​Grow


public method BoundsGrow → (1)

bounds in : TBounds

To bounds to cover.

Grows the tree until it contains the given bounds.

Clear


public method Clear → ()

Clears the tree.

Deserialize


public method Deserialize → (2)

data in : ISerializer

[not-null]
The serializer object.

entity in : ITypeSerializer<TEntity>

[not-null]
The type serializer for tree nodes.

Deserializes the tree nodes.

IOException

If an I/O error has occurred.

Distance

2 overloads


[Pure]
public abstract method Distance1 → (2)

coords in : TCoords

Coordinates of point.

nearest opt : float64 = Maths.MaxDouble

The maximum value to return.

returns → float64

The smallest distance.

Finds the smallest distance from the given point to any spatial entity in the tree.


[Pure]
public abstract method Distance2 → (4)

coords in : TCoords

Coordinates of point.

vertices out : Vec3I

Vertex indices that describe the location of the nearest spatial entity feature.

weights out : Vec3D

Location of the nearest spatial entity feature, given as relative weights (i.e. the weight sum is 1) of vertices out. The weights are sorted in descending order, i.e. Vec3D.X always holds the greatest weight and Vec3D.Z always holds the smallest weight.

nearest opt : float64 = Maths.MaxDouble

The maximum value to return.

returns → float64

The smallest distance.

Finds the smallest distance from the given point to any spatial entity in the tree.

Entities

2 overloads


public method Entities1 → (1)

node in : SpatialTreeNode<TBounds>

The spatial tree node.

returns → TEntity [ ]

The spatial entities in node in.

Returns the spatial entities in the given spatial tree node.


public method Entities2 → (2)

node in : SpatialTreeNode<TBounds>

The spatial tree node.

entities in : ICollector<TEntity>

[not-null]
The collector for spatial entities.

Collects the spatial entities in the given spatial tree node.

Entity​Grow


public method EntityGrow → (1)

capacity in : int64

The new capacity, in slots.

Grows the spatial entity slot storage.

Serialize


public method Serialize → (2)

data in : ISerializer

[not-null]
The serializer object.

entity in : ITypeSerializer<TEntity>

[not-null]
The type serializer for tree nodes.

Serializes the tree nodes.

IOException

If an I/O error has occurred.

Public / Attributes

Bounds


public attribute Bounds → (get)

value : TBounds

The root node bounds.

Returns the bounds of the root node.

Entity​Count


public attribute EntityCount → (get)

value : int32

[>=0]
The number of spatial entities in the tree.

Returns the number of spatial entities that are present in the tree nodes.

The entity count may be higher than the number of calls to Add, because the same spatial entity may be present in multiple tree nodes.

Node​Count


public attribute NodeCount → (get)

value : int32

[>=1]
The number of spatial tree nodes.

Returns the number of spatial tree nodes.

Root


public attribute Root → (get)

value : SpatialTreeNode<TBounds>

The root node.

Returns the root node of the tree.

Protected / Constructors

Spatial​Tree


protected constructor SpatialTree → (5)

childCount in : int32

[pow2]
The maximum number of children per tree node.

bounds in : TBounds

The initial spatial bounds.

boundsSerializer in : ITypeSerializer<TBounds>

[not-null]
The serializer for tree bounds.

entityTrait in : TEntityTrait

The entity trait.

distanceTrait in : TDistanceTrait

The distance trait.

Creates a new instance of SpatialTree.

Protected / Methods

Entity​Opposite


[Pure]
protected method EntityOpposite → (1)

in : int32

The spatial entity slot.

returns → bool

true if the entity represents a shared spatial feature, false if not.

Does the given spatial entity represent a shared spatial feature, for example an edge that is shared by two polygons?

Protected / Attributes

bounds


protected attribute bounds → (TBounds)

The tree bounds.

bounds​Trait


protected readonly attribute boundsTrait → (TBoundsTrait)

The spatial tree node bounds trait.

distance​Trait


protected readonly attribute distanceTrait → (TDistanceTrait)

The distance trait.

entity


protected attribute entity → (TEntity [ ])

The spatial entity slots.

entity​Next


protected attribute entityNext → (int32 [ ])

Next spatial entity slot.

node​Children


protected attribute nodeChildren → (int32 [ ])

Child pointers per tree node.

This array is indexed as follows:

children[idx * childCount + n] := n-th child

where idx is the tree node index and n is the child node ordinal.

node​First


protected attribute nodeFirst → (int32 [ ])

First spatial entity per tree node.

If a tree node idx has no spatial entities, nodeFirst[idx] will be -1. If nodeFirst[idx] is greater than or equal to zero, the node is a leaf.

node​Fixed


protected attribute nodeFixed → (int32 [ ])

First fixed spatial entity per tree node.

If a tree node idx has no fixed spatial entities, nodeFixed[idx] will be -1.

opposite


protected attribute opposite → (bool [ ])

Does the spatial entity represent both sides of a spatial feature?