node.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_NODE_H
00030 #define OBJTREE_NODE_H
00031 
00032 #include <cstdio>
00033 #include <list>
00034 #include <srs_env_model/but_server/objtree/object.h>
00035 
00036 namespace objtree
00037 {
00038 
00043 class Node
00044 {
00045 public:
00046     static const unsigned int CHILDREN = 8;
00047     static const unsigned int NEIGHBORS = 26;
00048 
00049 private:
00050     unsigned char m_place;
00051     Node* m_parent;
00052 
00053     /*
00054      * Neighbors ids (from top view)
00055      * Top part:  Middle part:  Bottom part:
00056      *  6  7  8     14 15 16      23 24 25
00057      *  3  4  5     12    13      20 21 22
00058      *  0  1  2      9 10 11      17 18 19
00059     */
00060     Node* m_neighbors[NEIGHBORS];
00061 
00062     /*
00063      * Node children ids (from top view)
00064      * Top part:  Bottom part:
00065      *   2  3         6  7
00066      *   0  1         4  5
00067      *
00068     */
00069     Node* m_children[CHILDREN];
00070     std::list<Object*> m_objects;
00071 
00072     static unsigned char reverseNeighborId(unsigned char dir);
00073     Node* parentNeighborChild(unsigned char parentNeighbor, unsigned char child);
00074     Node* computeNeighbor(unsigned char dir);
00075 
00076 public:
00077     Node(unsigned char place = 0, Node *parent = NULL);
00078     ~Node();
00079     Node* parent();
00080     Node* child(unsigned char place, bool createNew = false);
00081     Node* neighbor(unsigned char dir);
00082     const std::list<Object*>& objects() const;
00083     void add(Object* object);
00084     void removeObject(Object *object);
00085     void deleteIfEmpty();
00086 
00087     static Box& getChildBox(unsigned char place, Box &childBox, const Box &parentBox);
00088 };
00089 
00090 }
00091 
00092 #endif // OBJTREE_NODE_H


srs_env_model
Author(s): Vit Stancl (stancl@fit.vutbr.cz), Tomas Lokaj, Jan Gorig, Michal Spanel (spanel@fit.vutbr.cz)
autogenerated on Sun Jan 5 2014 11:50:48