Coin: SbOctTree Class Reference

| Coin3D is Free Software, published under the BSD 3-clause license. | https://coin3d.github.io https://www.kongsberg.com/en/kogt/

SbOctTree Class Reference
Base Classes

The SbOctTree class defines a generic octree for fast geometry searches. More...

`#include <Inventor/SbOctTree.h>`

## Public Member Functions
| SbOctTree (const SbBox3f &bbox, const SbOctTreeFuncs &itemfuncs, const int maxitemspernode=64)
| ~SbOctTree ()
void | addItem (void *const item)
void | removeItem (void *const item)
void | findItems (const SbVec3f &pos, SbList< void * > &destarray, const SbBool removeduplicates=TRUE) const
void | findItems (const SbBox3f &box, SbList< void * > &destarray, const SbBool removeduplicates=TRUE) const
void | findItems (const SbSphere &sphere, SbList< void * > &destarray, const SbBool removeduplicates=TRUE) const
void | findItems (const SbPlane *const planes, const int numplanes, SbList< void * > &destarray, const SbBool removeduplicates=TRUE) const
const SbBox3f & | getBoundingBox (void) const
void | clear (void)
void | debugTree (FILE *fp)

## Detailed Description

The SbOctTree class defines a generic octree for fast geometry searches.

Be aware that this class is an extension for Coin, and it is not available in the original SGI Open Inventor v2.1 API.

## Constructor & Destructor Documentation

## ◆ SbOctTree()

SbOctTree::SbOctTree | ( | const SbBox3f & | bbox,
|  | const SbOctTreeFuncs & | itemfuncs,
|  | const int | maxitems = 64 )

Constructor.

## ◆ ~SbOctTree()

SbOctTree::~SbOctTree | ( |  | ) |

Destructor.

## Member Function Documentation

## ◆ addItem()

void SbOctTree::addItem | ( | void *const | item | ) |

Adds an item to this octree.

## ◆ removeItem()

void SbOctTree::removeItem | ( | void *const | item | ) |

Removes the item from the octree. The octree will not be modified/simplified even when all items are removed.

## ◆ findItems() [1/4]

void SbOctTree::findItems | ( | const SbVec3f & | pos,
|  | SbList< void * > & | destarray,
|  | const SbBool | removeduplicates = TRUE ) const

Finds all items which contains the point pos. Items are returned in destarray.

If removeduplicates is TRUE (the default), destarray will not contain duplicate items. This is not an optimized process, so if you're looking for speed you should set this to FALSE and do your own post processing of the array of returned items.

Note that if the Coin library has been built as a DLL under Microsoft Windows and you use this method from application code, you must make sure that both the Coin DLL and the application executable are using the same instance of a C Run-Time (CRT) library. Otherwise, you will get memory heap corruption upon deallocating the returned instances, eventually leading to mysterious crashes.

## ◆ findItems() [2/4]

void SbOctTree::findItems | ( | const SbBox3f & | box,
|  | SbList< void * > & | destarray,
|  | const SbBool | removeduplicates = TRUE ) const

Finds all items inside box. Items are returned in destarray.

If removeduplicates is TRUE (the default), destarray will not contain duplicate items. This is not an optimized process, so if you're looking for speed you should set this to FALSE and do your own post processing of the array of returned items.

Note that if the Coin library has been built as a DLL under Microsoft Windows and you use this method from application code, you must make sure that both the Coin DLL and the application executable are using the same instance of a C Run-Time (CRT) library. Otherwise, you will get memory heap corruption upon deallocating the returned instances, eventually leading to mysterious crashes.

## ◆ findItems() [3/4]

void SbOctTree::findItems | ( | const SbSphere & | sphere,
|  | SbList< void * > & | destarray,
|  | const SbBool | removeduplicates = TRUE ) const

Finds all items inside sphere. Items are returned in destarray.

If removeduplicates is TRUE (the default), destarray will not contain duplicate items. This is not an optimized process, so if you're looking for speed you should set this to FALSE and do your own post processing of the array of returned items.

Note that if the Coin library has been built as a DLL under Microsoft Windows and you use this method from application code, you must make sure that both the Coin DLL and the application executable are using the same instance of a C Run-Time (CRT) library. Otherwise, you will get memory heap corruption upon deallocating the returned instances, eventually leading to mysterious crashes.

## ◆ findItems() [4/4]

void SbOctTree::findItems | ( | const SbPlane *const | planes,
|  | const int | numplanes,
|  | SbList< void * > & | destarray,
|  | const SbBool | removeduplicates = TRUE ) const

Finds all items inside planes. The method SbPlane::isInHalfSpace() should be used, and only items which are (partially) inside all planes are returned. Items are returned in destarray.

If removeduplicates is TRUE (the default), destarray will not contain duplicate items. This is not an optimized process, so if you're looking for speed you should set this to FALSE and do your own post processing of the array of returned items.

Note that if the Coin library has been built as a DLL under Microsoft Windows and you use this method from application code, you must make sure that both the Coin DLL and the application executable are using the same instance of a C Run-Time (CRT) library. Otherwise, you will get memory heap corruption upon deallocating the returned instances, eventually leading to mysterious crashes.

## ◆ getBoundingBox()

const SbBox3f & SbOctTree::getBoundingBox | ( | void |  | ) | const

Returns a bounding box enclosing all the elements in the tree. This is just the same bounding box which was supplied to the constructor.

## ◆ clear()

void SbOctTree::clear | ( | void |  | ) |

Restores this octree to an empty octree. The bounding box will still be the same though.

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

- SbOctTree.h
- SbOctTree.cpp