Table of Contents

Class OctTree<T>

Namespace
CADability
Assembly
CADability.dll

Generic class to provide fast access to IOctTreeInsertable implementing objects.

public class OctTree<T> where T : IOctTreeInsertable

Type Parameters

T

The generic type, must implement IOctTreeInsertable

Inheritance
OctTree<T>
Derived
Inherited Members

Constructors

OctTree()

public OctTree()

OctTree(BoundingCube, double, SplitTestFunction)

Constructs an octtree providing an initial size and a precision

public OctTree(BoundingCube ext, double precision, OctTree<T>.SplitTestFunction splitTest = null)

Parameters

ext BoundingCube

Initial size of the tree. Objects beeng added later may exceed this cube

precision double

Precision, used internally

splitTest OctTree<T>.SplitTestFunction

Criterion whether to split a node when an object is added to it, null: use the default criterion of SplitNode(Node<T>, T)

Fields

precision

The precision of this octtree

public double precision

Field Value

double

Properties

Extend

returns the extend of the root node.

public BoundingCube Extend { get; }

Property Value

BoundingCube

IsEmpty

Returns true if the tree is empty

public bool IsEmpty { get; }

Property Value

bool

Methods

AddMany(IEnumerable<T>)

public void AddMany(IEnumerable<T> objectsToAdd)

Parameters

objectsToAdd IEnumerable<T>

AddObject(T)

Add the provided object to the tree. This may split some nodes and cause calls to the method of other objects already in the tree.

public void AddObject(T objectToAdd)

Parameters

objectToAdd T

Object beeing added

AddObjectAsync(T)

public void AddObjectAsync(T objectToAdd)

Parameters

objectToAdd T

FindExactNode(BoundingCube)

Find the node which corresponds exactely to the provided boundingcube

public OctTree<T>.Node<T> FindExactNode(BoundingCube bc)

Parameters

bc BoundingCube

Returns

OctTree<T>.Node<T>

FindNode(GeoPoint)

Find the node containing the provided point.

public OctTree<T>.Node<T> FindNode(GeoPoint center)

Parameters

center GeoPoint

the point

Returns

OctTree<T>.Node<T>

the node or null if outside

GetAllObjects()

public T[] GetAllObjects()

Returns

T[]

GetNeighbourNodes(Node<T>, FilterNode)

Returns all neighbour nodes to the provided node. The result is sortet in a 2-dimensional array where the first index defines the side according to OctTree<T>.Side.

protected OctTree<T>.Node<T>[][] GetNeighbourNodes(OctTree<T>.Node<T> node, OctTree<T>.FilterNode filter)

Parameters

node OctTree<T>.Node<T>

The node which neighbours are requested

filter OctTree<T>.FilterNode

A optinal filter or null if unfiltered

Returns

Node<T>[][]

The neighbour nodes

GetNeighbours(Node<T>, Filter)

Returns all neighbours to the provided node. The result is sortet in a 2-dimensional array where the first index defines the side according to OctTree<T>.Side.

protected T[][] GetNeighbours(OctTree<T>.Node<T> node, OctTree<T>.Filter filter)

Parameters

node OctTree<T>.Node<T>

The node which neighbours are requested

filter OctTree<T>.Filter

A optinal filter or null if unfiltered

Returns

T[][]

The neighbours

GetNodesCloseTo(IOctTreeInsertable)

Returns all nodes close to the provided object.

protected OctTree<T>.Node<T>[] GetNodesCloseTo(IOctTreeInsertable closeToThis)

Parameters

closeToThis IOctTreeInsertable

Object for selection

Returns

Node<T>[]

All nodes interfering with the provided object

GetNodesFromBox(BoundingCube, FilterNode)

Returns all nodes of this tree that interfere with the provided box and pass the filter test.

public OctTree<T>.Node<T>[] GetNodesFromBox(BoundingCube box, OctTree<T>.FilterNode filter)

Parameters

box BoundingCube

Restricting box

filter OctTree<T>.FilterNode

Additional filter (may be null)

Returns

Node<T>[]

All nodes which match the criterion

GetObjectsCloseTo(IOctTreeInsertable)

Returns all objects that are close to the provided object.

public T[] GetObjectsCloseTo(IOctTreeInsertable closeToThis)

Parameters

closeToThis IOctTreeInsertable

Object which neighbours are searched

Returns

T[]

All objects close to closeToThis

GetObjectsFromBox(BoundingCube)

Returns all objects that interfere or are close to the provided box.

public T[] GetObjectsFromBox(BoundingCube box)

Parameters

box BoundingCube

Box for the selection

Returns

T[]

Array of all objects which match the criterion

GetObjectsFromBox(BoundingCube, Filter)

Returns all objects that interfere or are close to the provided box and accepted by the filter.

public T[] GetObjectsFromBox(BoundingCube box, OctTree<T>.Filter filter)

Parameters

box BoundingCube

Box specifying the selection

filter OctTree<T>.Filter

Filter restriction the result

Returns

T[]

Array of all objects which match the criterion

GetObjectsFromLine(GeoPoint, GeoVector, double)

Returns an array of objects which contains all objects that are close to the provided line. It may also contain some objects that have a greater distance than maxdist to the line.

public T[] GetObjectsFromLine(GeoPoint start, GeoVector dir, double maxdist)

Parameters

start GeoPoint

Starting point of the line

dir GeoVector

Direction of the line

maxdist double

Maximum distance to the line

Returns

T[]

Array of all objects which match the criterion

GetObjectsFromPlane(Plane)

Returns all objects that are close to the provided plane

public T[] GetObjectsFromPlane(Plane plane)

Parameters

plane Plane

Plane for selection

Returns

T[]

All objects close to the plane

GetObjectsFromPoint(GeoPoint)

Returns all objects that are close to the provided point.

public T[] GetObjectsFromPoint(GeoPoint p)

Parameters

p GeoPoint

Point for selection

Returns

T[]

Array of all objects which match the criterion

GetObjectsFromRect(Projection, BoundingRect, bool)

Returns an array of all objects that interfere with the provided rectangle in repect to the provided Projection. It may also contain some objects which don't interfere but are close to the rectangle, if onlyInside is false.

public T[] GetObjectsFromRect(Projection projection, BoundingRect rect, bool onlyInside)

Parameters

projection Projection

The projection

rect BoundingRect

The rectangle, usually from a selection

onlyInside bool

If true, only objects completely inside the rectangle are returned

Returns

T[]

Array of all objects which match the criterion

GetObjectsFromRect(PickArea, bool)

Returns an array of all objects that interfere with the provided Projection.PickArea area. If onlyInside is true only objects inside the frustum or box of the area are returned, otherwise there may also be objects that are aoutside this area.

public T[] GetObjectsFromRect(Projection.PickArea area, bool onlyInside)

Parameters

area Projection.PickArea

the frustum or box defining the selection

onlyInside bool

True to only return objects completely inside the area

Returns

T[]

Array of all objects which match the criterion

Initialize(BoundingCube, double)

public void Initialize(BoundingCube ext, double precision)

Parameters

ext BoundingCube
precision double

InitializePrecise(BoundingCube, double)

public void InitializePrecise(BoundingCube ext, double precision)

Parameters

ext BoundingCube
precision double

RemoveObject(T)

Remove object from the tree

public void RemoveObject(T objectToRemove)

Parameters

objectToRemove T

object to bee removed

SplitNode(Node<T>, T)

Criterion whether to split a node when it contains too many leaves. The default implemenation yield a dynamically balanced tree which allows more leaves in deeper nodes.

protected virtual bool SplitNode(OctTree<T>.Node<T> node, T objectToAdd)

Parameters

node OctTree<T>.Node<T>

The node beeing checked

objectToAdd T

The object beeing added

Returns

bool

true, if node should be splitted, false otherwise