Classes | Public Types | Public Member Functions | Protected Attributes
alvar::Container3d< T > Class Template Reference

Generic container to store any information in 3D (features, photos, ...) More...

#include <Container3d.h>

List of all members.

Classes

class  Iterator
 Iterator for going through the items in Container3d in the specified order. More...

Public Types

typedef std::pair
< CvPoint3D32f, T > 
node_type
 node_type for storing data. 3D-position is paired with the data content.

Public Member Functions

void Add (const CvPoint3D32f &_pos, const T &_data)
 Add _data in the container and associate it with 3D position _pos.
Iterator begin ()
 Provides an iterator pointing to the beginning of the limited/sorted 3D content.
void Clear ()
 Clear the container.
Iterator end ()
 Provides an iterator pointing to the end of the limited/sorted 3D content.
void Erase (size_t index)
 Erase item in the container.
size_t GetIndex (Iterator &iter)
 Get absolute reference usable with operator[]() based on the iterator.
size_t GetIndex (T *p)
 Get absolute reference usable with operator[]() based on the content.
template<typename Test >
int Limit (Test test)
 Limit the search space with external limitation.
node_typeoperator[] (size_t index)
 Instead of Iterator we can use also absolute references for data with operator[]()
void ResetSearchSpace ()
 Reset the search space to contain whole data.
size_t size () const
 Get number of items that can be referenced using operator[]()
template<typename Compare >
int Sort (Compare comp)
 Sort using external Compare method.

Protected Attributes

std::vector< node_typedata
 the actual data in using node_type: pair<CvPoint3D32f, T>
std::vector< size_t > search_space
 Possibly limited set of indices for data in somehow "optimal" search order.

Detailed Description

template<class T>
class alvar::Container3d< T >

Generic container to store any information in 3D (features, photos, ...)

You can store any information in 3D using this container. Each element in the container has an unique id that it can be referenced with using operator[](). The indices are from 0 to size(). You can find specific index using GetIndex(Iterator &iter) or GetIndex(T *p) .

In addition the Container3d contains also a 'search space' that can be iterated through using begin() and end(). This 'search space' can be limited using Limit() , sorted using Sort() and reseted using ResetSearchSpace(). You specify what to limit/sort using specified functors. In ALVAR there exists functors Container3dLimitDist , Container3dSortSize and Container3dSortDist . But you can quite well make your own versions (see example below).

The implementation is optimized for a situation where there are a lot of searches between every time the search space is limited/ordered. This is the reason we use vector containers internally. The idea is that later we will improve the class by providing more ways for limiting and sorting the search space; for example Frustum culling.

Usage:

 template <class T>
 class Container3dSortX {
 protected:
        Container3d<T> &container;
 public:
        Container3dSortX(Container3d<T> &_container) : container(_container) {}
        bool operator()(size_t i1, size_t i2) const {
                return (container[i1].first.x < container[i2].first.x);
        }
 };
 template <class T>
 class Container3dLimitX {
 protected:
        int x_min, x_max;
        Container3d<T> &container;
 public:
        Container3dLimitX(Container3d<T> &_container, int _x_min, int _x_max) 
        : container(_container),x_min(_x_min),x_max(_x_max) {}
        bool operator()(size_t i1) const {
                if ((container[i1].first.x >= x_min) && (container[i1].first.x <= x_max)) return true;
                return false;
        }
 };
 
 ...
 Container3d<int> c3d;
 c3d.Add(CvPoint3D32f(0,0,0), 0);
 c3d.Add(CvPoint3D32f(5,0,0), 1);
 c3d.Add(CvPoint3D32f(0,5,0), 2);
 c3d.Add(CvPoint3D32f(0,0,5), 3);
 c3d.Add(CvPoint3D32f(0,0,500), 4);
 c3d.Add(CvPoint3D32f(500,0,0), 5);
 c3d.Add(CvPoint3D32f(1,0,0), 6);
 c3d.Add(CvPoint3D32f(0,0,1), 7);
 Container3dSortX<int> sortx(c3d);
 Container3dLimitX<int> limitx(c3d, -10, 10);
 Container3dLimitDist<int> limit_dist(c3d, cvPoint3D32f(0,0,0), 10.0);
 c3d.ResetSearchSpace();                // Search space: 0,1,2,3,4,5,6,7
 c3d.Sort(sortx);                       // Search space: 0,2,3,4,7,6,1,5
 c3d.Limit(limitx);                     // Search space: 0,2,3,4,7,6,1
 c3d.Limit(limit_dist);                 // Search space: 0,2,3,7,6,1
 Container3d<int>::Iterator iter;
 for (iter=c3d.begin(); iter != c3d.end(); ++iter) {
     cout<<" "<<iter->second;
 }

Definition at line 166 of file Container3d.h.


Member Typedef Documentation

template<class T>
typedef std::pair<CvPoint3D32f, T> alvar::Container3d< T >::node_type

node_type for storing data. 3D-position is paired with the data content.

Definition at line 170 of file Container3d.h.


Member Function Documentation

template<class T>
void alvar::Container3d< T >::Add ( const CvPoint3D32f &  _pos,
const T &  _data 
) [inline]

Add _data in the container and associate it with 3D position _pos.

Definition at line 179 of file Container3d.h.

template<class T>
Iterator alvar::Container3d< T >::begin ( ) [inline]

Provides an iterator pointing to the beginning of the limited/sorted 3D content.

Definition at line 248 of file Container3d.h.

template<class T>
void alvar::Container3d< T >::Clear ( ) [inline]

Clear the container.

Definition at line 184 of file Container3d.h.

template<class T>
Iterator alvar::Container3d< T >::end ( ) [inline]

Provides an iterator pointing to the end of the limited/sorted 3D content.

Definition at line 253 of file Container3d.h.

template<class T>
void alvar::Container3d< T >::Erase ( size_t  index) [inline]

Erase item in the container.

Definition at line 197 of file Container3d.h.

template<class T>
size_t alvar::Container3d< T >::GetIndex ( Iterator iter) [inline]

Get absolute reference usable with operator[]() based on the iterator.

Definition at line 261 of file Container3d.h.

template<class T>
size_t alvar::Container3d< T >::GetIndex ( T *  p) [inline]

Get absolute reference usable with operator[]() based on the content.

Definition at line 271 of file Container3d.h.

template<class T>
template<typename Test >
int alvar::Container3d< T >::Limit ( Test  test) [inline]

Limit the search space with external limitation.

Definition at line 213 of file Container3d.h.

template<class T>
node_type& alvar::Container3d< T >::operator[] ( size_t  index) [inline]

Instead of Iterator we can use also absolute references for data with operator[]()

Definition at line 266 of file Container3d.h.

template<class T>
void alvar::Container3d< T >::ResetSearchSpace ( ) [inline]

Reset the search space to contain whole data.

Definition at line 189 of file Container3d.h.

template<class T>
size_t alvar::Container3d< T >::size ( ) const [inline]

Get number of items that can be referenced using operator[]()

Definition at line 258 of file Container3d.h.

template<class T>
template<typename Compare >
int alvar::Container3d< T >::Sort ( Compare  comp) [inline]

Sort using external Compare method.

Definition at line 206 of file Container3d.h.


Member Data Documentation

template<class T>
std::vector<node_type> alvar::Container3d< T >::data [protected]

the actual data in using node_type: pair<CvPoint3D32f, T>

Definition at line 173 of file Container3d.h.

template<class T>
std::vector<size_t> alvar::Container3d< T >::search_space [protected]

Possibly limited set of indices for data in somehow "optimal" search order.

Definition at line 175 of file Container3d.h.


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


ar_track_alvar
Author(s): Scott Niekum
autogenerated on Sat Dec 28 2013 16:46:16