octree.h
Go to the documentation of this file.
00001 /******************************************************************************
00002  * \file
00003  *
00004  * $Id:$
00005  *
00006  * Copyright (C) Brno University of Technology (BUT)
00007  *
00008  * This file is part of software developed by dcgm-robotics@FIT group.
00009  *
00010  * Author: Jan Gorig (xgorig01@stud.fit.vutbr.cz)
00011  * Supervised by: Michal Spanel (spanel@fit.vutbr.cz)
00012  * Date: 12/04/2012
00013  *
00014  * This file is free software: you can redistribute it and/or modify
00015  * it under the terms of the GNU Lesser General Public License as published by
00016  * the Free Software Foundation, either version 3 of the License, or
00017  * (at your option) any later version.
00018  *
00019  * This file is distributed in the hope that it will be useful,
00020  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00021  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00022  * GNU Lesser General Public License for more details.
00023  *
00024  * You should have received a copy of the GNU Lesser General Public License
00025  * along with this file.  If not, see <http://www.gnu.org/licenses/>.
00026  */
00027 
00028 #pragma once
00029 #ifndef OBJTREE_OCTREE_H
00030 #define OBJTREE_OCTREE_H
00031 
00032 #include <map>
00033 #include <list>
00034 #include <set>
00035 #include <srs_env_model/but_server/objtree/box.h>
00036 
00037 namespace objtree
00038 {
00039 
00040 class Node;
00041 class Object;
00042 class Filter;
00043 
00048 class Octree
00049 {
00050 public:
00051     static const unsigned int DEFAULT_MAX_DEPTH = 4;
00052 
00053 private:
00054     Node *m_root;
00055     Box m_rootSize;
00056     unsigned int m_maxId;
00057     unsigned int m_maxDepth;    
00058     std::map<unsigned int, Object*> m_objects;
00059 
00060 public:
00061     Octree(unsigned int maxDepth = DEFAULT_MAX_DEPTH);
00062     Octree(const Box &rootSize, unsigned int maxDepth = DEFAULT_MAX_DEPTH);
00063     ~Octree();
00064 
00065     void clear();
00066 
00067     unsigned int insert(Object* object);
00068     unsigned int insertOnFit(Object* object);
00069     unsigned int insertOnInterfere(Object* object, Node *node, Box box, unsigned int depth = 0);
00070 
00071     unsigned int insertUpdate(Object* object);
00072     unsigned int insertUpdate2(Object* object);
00073     unsigned int insertUpdateOnInterfere(Object* object, Node *node, Box box, bool &inserted, unsigned int depth = 0);
00074 
00075     Object* getSimilarObject(const Object *object);
00076     Object* getSimilarObject(const Object *object, Node *node, Box box, unsigned int depth = 0);
00077     bool isPositionFree(float x, float y, float z);
00078 
00079     Node* root() const;
00080     unsigned int maxId() const;
00081     unsigned int count() const;
00082 
00083     const Object* object(unsigned int id) const;
00084     bool removeObject(unsigned int id);
00085 
00086     void nodes(std::list<Box> &nodesList, std::set<Object*> &objectList, const Filter *filter);
00087     void nodes(std::list<Box> &nodesList, std::set<Object*> &objectList, const Filter *filter, Box dim, Node *node);
00088     void objects(std::set<Object*> &objectList, const Filter *filter);
00089 
00090     const std::map<unsigned int, Object*>& objectsAll() const;
00091 };
00092 
00093 }
00094 
00095 #endif // OBJTREE_OCTREE_H


srs_env_model
Author(s): Vit Stancl (stancl@fit.vutbr.cz), Tomas Lokaj, Jan Gorig, Michal Spanel (spanel@fit.vutbr.cz)
autogenerated on Mon Oct 6 2014 08:05:05