52 float x1 = container[i1].first.x-orig.x, x2 = container[i2].first.x-orig.x;
53 float y1 = container[i1].first.y-orig.y, y2 = container[i2].first.y-orig.y;
54 float z1 = container[i1].first.z-orig.z, z2 = container[i2].first.z-orig.z;
55 float d1 = x1*x1 + y1*y1 + z1*z1;
56 float d2 = x2*x2 + y2*y2 + z2*z2;
70 return (container[i1].second->
size() > container[i2].second->
size());
83 : container(_container),orig(_orig),dist_limit(_dist_limit) {}
85 float x = container[i].first.x-orig.x;
86 float y = container[i].first.y-orig.y;
87 float z = container[i].first.z-orig.z;
88 float d = x*x + y*y + z*z;
89 if (d <= dist_limit*dist_limit)
return true;
179 void Add(
const CvPoint3D32f& _pos,
const T& _data){
180 data.push_back(node_type(_pos, _data));
181 search_space.push_back(data.size()-1);
186 search_space.clear();
190 search_space.resize(data.size());
191 for (
size_t i=0; i<search_space.size(); i++)
198 typename std::vector<node_type>::iterator iter_d;
199 iter_d = data.begin();
200 for (
size_t i=0; i<index; i++) iter_d++;
205 template <
typename Compare>
207 stable_sort(search_space.begin(), search_space.end(), comp);
208 return search_space.size();
212 template <
typename Test>
214 std::vector<size_t>::iterator iter;
215 for (iter = search_space.begin(); iter != search_space.end();) {
217 iter = search_space.erase(iter);
222 return search_space.size();
231 class Iterator :
public std::iterator<std::forward_iterator_tag, node_type>
235 std::vector<size_t>::iterator
iter;
249 return Iterator(
this, search_space.begin());
254 return Iterator(
this, search_space.end());
258 size_t size()
const {
return data.size(); }
273 for (; i<data.size(); ++i)
275 if (data[i].second.get() == p)
break;
void Clear()
Clear the container.
TFSIMD_FORCE_INLINE Vector3 operator*(const Matrix3x3 &m, const Vector3 &v)
std::vector< node_type > data
the actual data in using node_type: pair<CvPoint3D32f, T>
Container3d< T > * container
Container3dLimitDist(Container3d< T > &_container, const CvPoint3D32f _orig, float _dist_limit)
Functor class for Container3d Sort() to sort the search base using distance to specified origin...
node_type & operator*() const
Container3d< T > & container
int Sort(Compare comp)
Sort using external Compare method.
bool operator!=(const Iterator &_m) const
std::vector< size_t > search_space
Possibly limited set of indices for data in somehow "optimal" search order.
size_t GetIndex(Iterator &iter)
Get absolute reference usable with operator[]() based on the iterator.
virtual Iterator & operator++()
Container3dSortDist(Container3d< T > &_container, const CvPoint3D32f _orig)
Functor class for Container3d Sort() to sort the search base using content size.
TFSIMD_FORCE_INLINE const tfScalar & y() const
Iterator end()
Provides an iterator pointing to the end of the limited/sorted 3D content.
Functor class for Container3d Limit() to limit the search space with distance.
Iterator begin()
Provides an iterator pointing to the beginning of the limited/sorted 3D content.
Container3d< T > & container
size_t GetIndex(T *p)
Get absolute reference usable with operator[]() based on the content.
std::vector< size_t >::iterator iter
TFSIMD_FORCE_INLINE const tfScalar & x() const
void Add(const CvPoint3D32f &_pos, const T &_data)
Add _data in the container and associate it with 3D position _pos.
node_type & operator[](size_t index)
Instead of Iterator we can use also absolute references for data with operator[]() ...
node_type * operator->() const
Iterator(Container3d< T > *_container, std::vector< size_t >::iterator _iter)
TFSIMD_FORCE_INLINE const tfScalar & z() const
void Erase(size_t index)
Erase item in the container.
Generic container to store any information in 3D (features, photos, ...)
bool operator()(size_t i1, size_t i2)
int Limit(Test test)
Limit the search space with external limitation.
Container3dSortSize(Container3d< T > &_container)
Iterator for going through the items in Container3d in the specified order.
bool operator==(const Iterator &_m) const
bool operator()(size_t i1, size_t i2)
bool operator()(size_t i) const
void ResetSearchSpace()
Reset the search space to contain whole data.
std::pair< CvPoint3D32f, T > node_type
node_type for storing data. 3D-position is paired with the data content.
Container3d< T > & container
size_t size() const
Get number of items that can be referenced using operator[]()