| http://www.coin3d.org/ http://www.kongsberg.com/kogt/

Public Member Functions | Friends | List of all members
dimeBSPTree Class Reference

The dimeBSPTree class is a simple BSP tree implementation. More...

## Public Member Functions

| dimeBSPTree (const int maxnodepts=64, const int initsize=4)
| ~dimeBSPTree ()
int | numPoints () const
void | getPoint (const int idx, dimeVec3f &pt)
void * | getUserData (const int idx) const
void | setUserData (const int idx, void *const data)
int | addPoint (const dimeVec3f &pt, void *const userdata=NULL)
int | removePoint (const dimeVec3f &pt)
void | removePoint (const int idx)
int | findPoint (const dimeVec3f &pos) const
void | clear (const int initsize=4)
const dimeBox * | getBBox () const

## Friends

class | dime_bspnode

## Detailed Description

The dimeBSPTree class is a simple BSP tree implementation.

## Constructor & Destructor Documentation

## ◆ dimeBSPTree()

dimeBSPTree::dimeBSPTree | ( | const int | maxnodepts = `64`,
|  | const int | initsize = `4`
| ) |  |

Constructor. Will create an empty BSP tree with one node. maxnodepts is the maximume number of points in a BSP node. initsize is the initial size of the arrays that holds the coordinates and userdata.

## ◆ ~dimeBSPTree()

dimeBSPTree::~dimeBSPTree | ( |  | ) |

Destructor. Will free all memory used.

## Member Function Documentation

## ◆ addPoint()

int dimeBSPTree::addPoint | ( | const dimeVec3f & | pt,
|  | void *const | data = `NULL`
| ) |  |

Attempts to add a new point into the BSP tree. If a point with the same coordinates as pt already is in the tree, the index to that point will be returned. Otherwise, the point is appended at the end of the list of points, the userdata is set, and the new index is returned.

References dimeArray< T >::count().

Referenced by dxfLayerData::addLine(), dxfLayerData::addQuad(), and dxfLayerData::addTriangle().

## ◆ clear()

void dimeBSPTree::clear | ( | const int | initsize = `4` | ) |

Frees the memory used by the BSP tree. Do not use the BSP tree after this method has been called.

References dimeArray< T >::makeEmpty().

## ◆ findPoint()

int dimeBSPTree::findPoint | ( | const dimeVec3f & | pos | ) | const

Searches for a point with coordinates pos. Returns the index if found, -1 otherwise

## ◆ getBBox()

const dimeBox * dimeBSPTree::getBBox | ( |  | ) | const

Returns the bounding box for all points in the BSP tree.

## ◆ getPoint()

void dimeBSPTree::getPoint | ( | const int | idx,
|  | dimeVec3f & | pt
| ) |  |

Returns the coordinates for the point at index idx.

See also
  dimeBSPTree::numPoints()

References dimeArray< T >::count().

Referenced by dxfLayerData::writeWrl().

## ◆ getUserData()

void * dimeBSPTree::getUserData | ( | const int | idx | ) | const

Returns the user data for the point at index idx.

References dimeArray< T >::count().

## ◆ numPoints()

int dimeBSPTree::numPoints | ( |  | ) | const

Returns the number of points in the BSP tree.

References dimeArray< T >::count().

Referenced by dxfLayerData::writeWrl().

## ◆ removePoint() [1/2]

int dimeBSPTree::removePoint | ( | const dimeVec3f & | pt | ) |

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Referenced by removePoint().

## ◆ removePoint() [2/2]

void dimeBSPTree::removePoint | ( | const int | idx | ) |

Removes the point at index. The BSP tree will not be restructured, no matter how many points you remove.

References dimeArray< T >::count(), and removePoint().

## ◆ setUserData()

void dimeBSPTree::setUserData | ( | const int | idx,
|  | void *const | data
| ) |  |

Sets the user data for the point with index idx.

References dimeArray< T >::count().

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

- BSPTree.h
- BSPTree.cpp

Copyright © by Kongsberg Oil & Gas Technologies. All rights reserved.