KrisLibrary  1.0.0
Classes | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
Geometry::OctreeScalarField Class Reference

Stores a function f(x) on an octree grid. Allows for O(d) setting, sub O(d) testing of f(x) in range [a,b], O(d h) selection of nodes with values in range [a,b]. More...

#include <Octree.h>

Inheritance diagram for Geometry::OctreeScalarField:
Geometry::Octree

Classes

struct  Data
 

Public Member Functions

 OctreeScalarField (const AABB3D &bb, Real defaultValue=-Inf)
 
void Set (const Vector3 &pt, Real value, int id=-1)
 
Real Value (const Vector3 &pt) const
 Returns the value at the point.
 
bool ValueIn (const Vector3 &pt, Real valueMin, Real valueMax) const
 
bool ValueGreater (const Vector3 &pt, Real bound) const
 
bool ValueLess (const Vector3 &pt, Real bound) const
 Returns true if the value at point pt is less than bound.
 
void BoxLookupRange (const Vector3 &bmin, const Vector3 &bmax, Real valueMin, Real valueMax, vector< int > &nodeIndices, bool inclusive=true) const
 
void BoxLookupGreater (const Vector3 &bmin, const Vector3 &bmax, Real bound, vector< int > &nodeIndices) const
 
void BoxLookupLess (const Vector3 &bmin, const Vector3 &bmax, Real bound, vector< int > &nodeIndices) const
 
void Collapse (Real tolerance=0)
 
- Public Member Functions inherited from Geometry::Octree
 Octree (const AABB3D &bb)
 Creates a single-node octree with the given bounding box.
 
int NumNodes () const
 Returns the number of nodes in the octree.
 
int Size () const
 Returns the number of nodes in the octree.
 
bool IsLeaf (const OctreeNode &n) const
 Tests whether a node is a leaf.
 
int Depth (const OctreeNode &n) const
 Returns the depth of the node in the tree (root is depth 0)
 
int Index (const OctreeNode &n) const
 Returns the index of the node.
 
const OctreeNodeNode (int index) const
 Returns the node for a given index.
 
OctreeNodeNode (int index)
 Returns the node for a given index.
 
int MaxDepth () const
 Returns the maximum depth of the tree.
 
void SplitToDepth (int d)
 splits the Octree uniformly to the given depth d
 
void SplitToDepth (OctreeNode &n, int d)
 
OctreeNodeSplitToDepth (OctreeNode &n, const Vector3 &point, int d)
 
void SplitToResolution (const Vector3 &res)
 splits the Octree uniformly to the given resolution res
 
void SplitToResolution (OctreeNode &n, const Vector3 &res)
 
OctreeNodeSplitToResolution (OctreeNode &n, const Vector3 &point, const Vector3 &res)
 
int Child (const OctreeNode &n, const Vector3 &pt) const
 Returns the child index in which pt is located (0-7, not the node index)
 
void Range (const OctreeNode &n, int child, AABB3D &bbchild) const
 Returns the bounding box of a hypothetical child of n.
 
OctreeNodeLookup (const Vector3 &point)
 Finds the leaf node containing point or NULL if no such node exists.
 
OctreeNodeLookup (OctreeNode &root, const Vector3 &point)
 Same as above, but given a root node for searching.
 
OctreeNodeLookup (OctreeNode &root, const Vector3 &point, int depthMax)
 
void BoxLookup (const Vector3 &bmin, const Vector3 &bmax, vector< int > &nodeIndices) const
 
void BoxLookup (const Box3D &b, vector< int > &nodeIndices) const
 Returns the indices of all leaf nodes overlapping the 3D box b.
 
void BallLookup (const Vector3 &c, Real r, vector< int > &nodeIndices) const
 
void RayLookup (const Ray3D &ray, vector< int > &nodeindices) const
 Returns the sorted list of leaf nodes that intersect the ray.
 
void FattenedRayLookup (const Ray3D &ray, Real radius, vector< int > &nodeindices) const
 

Protected Member Functions

virtual int AddNode (int parent=-1)
 
virtual void DeleteNode (int id)
 
virtual void Split (int nodeindex)
 Splits the given node (once).
 
virtual void Join (int nodeindex)
 Joins the given node and all descendants.
 
- Protected Member Functions inherited from Geometry::Octree
void _RayLookup (int nodeindex, const Ray3D &ray, vector< int > &nodeindices) const
 
void _FattenedRayLookup (int nodeindex, const Ray3D &ray, Real radius, vector< int > &nodeindices) const
 

Protected Attributes

Real defaultValue
 
vector< Datadata
 
- Protected Attributes inherited from Geometry::Octree
vector< OctreeNodenodes
 
list< int > freeNodes
 

Detailed Description

Stores a function f(x) on an octree grid. Allows for O(d) setting, sub O(d) testing of f(x) in range [a,b], O(d h) selection of nodes with values in range [a,b].

Member Function Documentation

void OctreeScalarField::BoxLookupGreater ( const Vector3 bmin,
const Vector3 bmax,
Real  bound,
vector< int > &  nodeIndices 
) const

Returns all node indices that are contained within the bbox [bmin,bmax] AND whose values are > bound

void OctreeScalarField::BoxLookupLess ( const Vector3 bmin,
const Vector3 bmax,
Real  bound,
vector< int > &  nodeIndices 
) const

Returns all node indices that are contained within the bbox [bmin,bmax] AND whose values are < bound

void OctreeScalarField::BoxLookupRange ( const Vector3 bmin,
const Vector3 bmax,
Real  valueMin,
Real  valueMax,
vector< int > &  nodeIndices,
bool  inclusive = true 
) const

Returns all node indices that are contained within the bbox [bmin,bmax] AND whose values are within [valueMin,valueMax] (if inclusive=true) or (valueMin,valueMax) (if inclusive=false).

void OctreeScalarField::Collapse ( Real  tolerance = 0)

Collapses all nodes whose difference between min/max is less than tolerance

void OctreeScalarField::Set ( const Vector3 pt,
Real  value,
int  id = -1 
)

Sets the value at the leaf node associated with the point pt. To set the field to a given resolution, first call SplitToDepth(pt,d) or SplitToResolution(pt,res).

References Geometry::OctreeScalarField::Data::id, Geometry::OctreeScalarField::Data::value, and Geometry::OctreeScalarField::Data::valueMin.

bool OctreeScalarField::ValueGreater ( const Vector3 pt,
Real  bound 
) const

Returns true if the value at point pt is greater than bound (equivalent to Value(pt) > bound but potentially faster)

bool OctreeScalarField::ValueIn ( const Vector3 pt,
Real  valueMin,
Real  valueMax 
) const

Returns true if the value at point pt is in the range [valueMin,valueMax] (equivalent to valueMin <= Value(pt) <= valueMax but potentially faster)

References Geometry::OctreeScalarField::Data::value, and Geometry::OctreeScalarField::Data::valueMin.


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