Bridges-C++  3.1.1
Bridges(C++API)
Public Member Functions | Protected Member Functions | List of all members
bridges::datastructure::KdTreeElement< K, E > Class Template Reference

#include <KdTreeElement.h>

Inheritance diagram for bridges::datastructure::KdTreeElement< K, E >:
bridges::datastructure::BSTElement< K, E > bridges::datastructure::BinTreeElement< E > bridges::datastructure::TreeElement< E > bridges::datastructure::Element< E > bridges::datastructure::DataStructure

Detailed Description

template<typename K, typename E>
class bridges::datastructure::KdTreeElement< K, E >

This class can be used to create K-d Tree elements, derived from BSTElement. K-D trees can be thought of as the spatial equivalent binary search trees and operate on multiple dimensions (2D and 3D are most common). These trees serve as a representation of the underlying geometrically defined spaces. Specialized versions of these trees include quadtrees and octrees, which subdivide into equal sized quadrants octants at each level, respectively.

This class extends the BSTElement class by adding a dimension property. It also includes a thickness property for displaying the partitioning lines generated by the convex decomposition.

convenient to generate visual representation to allow for use in a binary search tree implementation.

See also
There is a tutorial about K-d Trees : http://bridgesuncc.github.io/tutorials/KdTree.html
 @param K that is the search key type - this is usually a number, integer
    or float
 @param E the application data type
Author
Kalpathi Subramanian
Date
6/18/15, 7/17/16

Public Member Functions

 KdTreeElement (const K &k, int dim, int th, const KdTreeElement *l, const KdTreeElement *r, const E &val=E(), const string &lab=string())
 
 KdTreeElement (const K &k, int dim, int th=0, const E &val=E(), const string &lab=string())
 
virtual const string getDStype () const override
 
int getDimension () const
 
void setDimension (const int &dim)
 
float getThickness () const
 
void setThickness (const float &th)
 
getPartitioner () const
 
void setPartitioner (const K &p)
 
virtual KdTreeElementgetLeft () override
 
virtual const KdTreeElementgetLeft () const override
 
void setLeft (KdTreeElement *l)
 
virtual KdTreeElementgetRight () override
 
virtual const KdTreeElementgetRight () const override
 
void setRight (KdTreeElement *r)
 
- Public Member Functions inherited from bridges::datastructure::BSTElement< K, E >
 BSTElement (const K &k, BSTElement *l, BSTElement *r, const E &val=E(), const string &lab=string())
 
 BSTElement (const K &k, const E &val=E(), const string &lab=string())
 
getKey () const
 
void setKey (const K &k)
 
void setLeft (BSTElement *l)
 
void setRight (BSTElement *r)
 
- Public Member Functions inherited from bridges::datastructure::BinTreeElement< E >
 BinTreeElement (BinTreeElement *l, BinTreeElement *r, const E &e=E(), const string &lab=string())
 
 BinTreeElement (const E &e=E(), const string &lab=string())
 
void setLeft (BinTreeElement *l)
 
void setRight (BinTreeElement *r)
 
- Public Member Functions inherited from bridges::datastructure::TreeElement< E >
 TreeElement (const E &e=E(), const string &lab=string())
 
vector< TreeElement * > & getChildren ()
 
const vector< TreeElement * > & getChildren () const
 
TreeElementgetChild (const int &n)
 
const TreeElementgetChild (const int &n) const
 
void addChild (TreeElement *child)
 
void setChild (const size_t &index, TreeElement *kid)
 
- Public Member Functions inherited from bridges::datastructure::Element< E >
 Element (const E &val=E(), const string &lab=string())
 
 Element (const Element &e)
 
Elementoperator= (const Element &e)
 
E & operator= (E const &e)
 
virtual ~Element ()
 
ElementVisualizergetVisualizer ()
 
const ElementVisualizergetVisualizer () const
 
LinkVisualizergetLinkVisualizer (const Element *el)
 
LinkVisualizergetLinkVisualizer (const Element *el) const
 
string const & getLabel () const
 
void setLabel (const string &lab)
 
E const & getValue () const
 
E & getValue ()
 
void setValue (const E &val)
 
void setSize (const double &sz)
 Sets size of the element. More...
 
double getSize () const
 
void setColor (const Color &col)
 Set the color of the Element. More...
 
void setColor (const string col)
 Set the color by name. More...
 
Color getColor () const
 Get the current color of the element. More...
 
void setOpacity (double opacity)
 
double getOpacity ()
 
void setShape (const Shape &shp)
 Set the shape of the element. More...
 
Shape getShape () const
 Returns the shape of the element. More...
 
void setLocation (const double &locX, const double &locY)
 
double getLocationX () const
 
double getLocationY () const
 
- Public Member Functions inherited from bridges::datastructure::DataStructure
virtual ~DataStructure ()=default
 

Protected Member Functions

virtual const string getElementRepresentation () const override
 

Additional Inherited Members

- Static Protected Member Functions inherited from bridges::datastructure::Element< E >
static const string getLinkRepresentation (const LinkVisualizer &lv, const string &src, const string &dest)
 
- Protected Attributes inherited from bridges::datastructure::BSTElement< K, E >
key = K()
 
- Protected Attributes inherited from bridges::datastructure::Element< E >
unordered_map< Element *, LinkVisualizerlinks
 

Constructor & Destructor Documentation

◆ KdTreeElement() [1/2]

template<typename K , typename E >
bridges::datastructure::KdTreeElement< K, E >::KdTreeElement ( const K &  k,
int  dim,
int  th,
const KdTreeElement< K, E > *  l,
const KdTreeElement< K, E > *  r,
const E &  val = E(),
const string &  lab = string() 
)
inline

Constructs a KdTreeElement with the provided value, label, key, left and right KdTree elements. The defaults will be used if not provided.

Parameters
kThe key for ordering
dimnumber of dimension to be partitioned
ththickness of the line showing the partition
lThe left KdTree Element
rThe right KdTree Element
valThe data to hold
labThe label to show

◆ KdTreeElement() [2/2]

template<typename K , typename E >
bridges::datastructure::KdTreeElement< K, E >::KdTreeElement ( const K &  k,
int  dim,
int  th = 0,
const E &  val = E(),
const string &  lab = string() 
)
inline

Constructs a KdTreeElement with the provided value, label, key, setting the left and right KdTreeElement to NULL. The defaults will be used if not provided.

Parameters
kThe key for ordering
dimnumber of dimensions being partitioned
ththickness of the line showing the partition
valThe data to hold
labThe label to show

Member Function Documentation

◆ getDimension()

template<typename K , typename E >
int bridges::datastructure::KdTreeElement< K, E >::getDimension ( ) const
inline

Get Dimension of the partition

Returns
return the partitioning of this node

◆ getDStype()

template<typename K , typename E >
virtual const string bridges::datastructure::KdTreeElement< K, E >::getDStype ( ) const
inlineoverridevirtual
Returns
the data structure type

Reimplemented from bridges::datastructure::BSTElement< K, E >.

◆ getElementRepresentation()

template<typename K , typename E >
virtual const string bridges::datastructure::KdTreeElement< K, E >::getElementRepresentation ( ) const
inlineoverrideprotectedvirtual

Gets the JSON representation of this element

Reimplemented from bridges::datastructure::BSTElement< K, E >.

◆ getLeft() [1/2]

template<typename K , typename E >
virtual KdTreeElement* bridges::datastructure::KdTreeElement< K, E >::getLeft ( )
inlineoverridevirtual

Get left child

Returns
The left child

Reimplemented from bridges::datastructure::BSTElement< K, E >.

◆ getLeft() [2/2]

template<typename K , typename E >
virtual const KdTreeElement* bridges::datastructure::KdTreeElement< K, E >::getLeft ( ) const
inlineoverridevirtual

Get left child - constant version

Returns
The left child

Reimplemented from bridges::datastructure::BSTElement< K, E >.

◆ getPartitioner()

template<typename K , typename E >
K bridges::datastructure::KdTreeElement< K, E >::getPartitioner ( ) const
inline

Get partitioner value

Returns
return the partitioner value

◆ getRight() [1/2]

template<typename K , typename E >
virtual KdTreeElement* bridges::datastructure::KdTreeElement< K, E >::getRight ( )
inlineoverridevirtual

Get right child

Returns
The right child

Reimplemented from bridges::datastructure::BSTElement< K, E >.

◆ getRight() [2/2]

template<typename K , typename E >
virtual const KdTreeElement* bridges::datastructure::KdTreeElement< K, E >::getRight ( ) const
inlineoverridevirtual

Constant version

Returns
The right child

Reimplemented from bridges::datastructure::BSTElement< K, E >.

◆ getThickness()

template<typename K , typename E >
float bridges::datastructure::KdTreeElement< K, E >::getThickness ( ) const
inline

Get thickness of the partition

Returns
return the partitioner thickness

◆ setDimension()

template<typename K , typename E >
void bridges::datastructure::KdTreeElement< K, E >::setDimension ( const int &  dim)
inline

Set partitioning dimension to "dim"

Parameters
dimThe partitioning dimension of this Kd tree element

◆ setLeft()

template<typename K , typename E >
void bridges::datastructure::KdTreeElement< K, E >::setLeft ( KdTreeElement< K, E > *  l)
inline

Sets left child to "l"

Parameters
lThe left child

◆ setPartitioner()

template<typename K , typename E >
void bridges::datastructure::KdTreeElement< K, E >::setPartitioner ( const K &  p)
inline

Set partitioning dimension to "dim"

Parameters
dimThe partitioning dimension of this Kd tree element

◆ setRight()

template<typename K , typename E >
void bridges::datastructure::KdTreeElement< K, E >::setRight ( KdTreeElement< K, E > *  r)
inline

Sets right to "r"

Parameters
rThe right BSTElement

◆ setThickness()

template<typename K , typename E >
void bridges::datastructure::KdTreeElement< K, E >::setThickness ( const float &  th)
inline

Set partitioning dimension to "dim"

Parameters
dimThe partitioning dimension of this Kd tree element

The documentation for this class was generated from the following file: