Coin
4.0.3
Coin3D core library
|
The SbBSPTree class provides a binary space partitioning container. More...
#include <Inventor/SbBSPTree.h>
Public Member Functions | |
SbBSPTree (const int maxnodepts=64, const int initsize=4) | |
~SbBSPTree () | |
int | addPoint (const SbVec3f &pt, void *const userdata=NULL) |
void | clear (const int initsize=4) |
int | findClosest (const SbSphere &sphere, SbIntList &array) const |
int | findClosest (const SbSphere &sphere, SbList< int > &array) const |
int | findClosest (const SbVec3f &pos) const |
int | findPoint (const SbVec3f &pos) const |
void | findPoints (const SbSphere &sphere, SbIntList &array) const |
void | findPoints (const SbSphere &sphere, SbList< int > &array) const |
const SbBox3f & | getBBox () const |
SbVec3f | getPoint (const int idx) const |
void | getPoint (const int idx, SbVec3f &pt) const |
const SbVec3f * | getPointsArrayPtr () const |
void * | getUserData (const int idx) const |
int | numPoints () const |
void | removePoint (const int idx) |
int | removePoint (const SbVec3f &pt) |
void | setUserData (const int idx, void *const data) |
The SbBSPTree class provides a binary space partitioning container.
This class can be used to organize searches for 3D points or normals in a set in O(log(n)) time.
Note: SbBSPTree is an extension to the original Open Inventor API.
Constructor with maxnodepts specifying the maximum number of points in a node before it must be split, and initsize is the number of initially allocated points in the growable points array. If you know approximately the number of points which will be added to the tree, it will help the performance if you supply this in initsize.
SbBSPTree::~SbBSPTree | ( | ) |
Destructor. Frees used memory.
Adds a new point pt to the BSP tree, and returns the index to the new point. The user data for that point will be set to data.
If the point already exists in the BSP tree, the index to the old point will be returned. The user data for that point will not be changed.
Will return the index to the point closest to the center of sphere. Indices to all points inside the sphere is returned in arr. If no points can be found inside the sphere, -1 is returned.
WARNING: Please don't use this function. It can cause hard to find bugs on the Windows platform if your application is linked against a different CRT than your Coin DLL.
Use int findClosest(const SbSphere &sphere, SbIntList & arr) instead.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Will search the tree, and return the index to the point with coordinates matching pos. If no such point can be found, -1 is returned.
Will return indices to all points inside sphere.
WARNING: Please don't use this function. It can cause hard to find bugs on the Windows platform if your application is linked against a different CRT than your Coin DLL.
Use void findPoints(const SbSphere &sphere, SbIntList & array) instead.
Will return the bounding box of all points in the BSP tree.
Returns the point at index idx.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Returns a pointer to the array of points inserted into the BPS tree.
Returns the user data for the point at index idx.
int SbBSPTree::numPoints | ( | ) | const |
Returns the number of points in the BSP tree.
Removes the point at index idx.
Removes the point with coordinates pt, and returns the index to the removed point. -1 is returned if no point with those coordinates could be found.
Sets the user data for the point at index idx to data.