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_OBJECT_H 00030 #define OBJTREE_OBJECT_H 00031 00032 #include <list> 00033 #include <srs_env_model/but_server/objtree/box.h> 00034 #include <srs_env_model/but_server/objtree/history.h> 00035 00036 namespace objtree 00037 { 00038 00039 class Node; 00040 00045 class Object 00046 { 00047 public: 00048 enum Type 00049 { 00050 PLANE = 1, 00051 ALIGNED_BOUNDING_BOX = 2, 00052 GENERAL_BOUNDING_BOX = 3 00053 }; 00054 00055 private: 00056 std::list<Node*> m_inNodes; 00057 unsigned int m_id; 00058 00059 protected: 00060 Type m_type; 00061 #if HISTORY_ENABLED 00062 History *m_history; 00063 #endif 00064 00065 public: 00066 Object(); 00067 ~Object(); 00068 00069 virtual bool fitsIntoBox(const Box &box) const = 0; 00070 virtual bool interfereWithBox(const Box &box) const = 0; 00071 virtual bool isSimilar(const Object *object) const = 0; 00072 virtual bool isPointInside(float x, float y, float z) const = 0; 00073 00074 void setId(unsigned int id); 00075 unsigned int id() const; 00076 bool hasId() const; 00077 Type type() const; 00078 00079 void newNode(Node *node); 00080 void removeNode(Node *node); 00081 00082 unsigned int inNodesCount() const; 00083 00084 #if HISTORY_ENABLED 00085 00086 History *history() { return m_history; } 00088 void takeHistory(Object *object) 00089 { 00090 if(!object->m_history) 00091 { 00092 object->m_history = new History; 00093 } 00094 00095 object->updateHistory(); 00096 m_history = object->m_history; 00097 object->m_history = 0; 00098 } 00100 virtual void updateHistory() = 0; 00101 #endif 00102 }; 00103 00104 } 00105 00106 #endif // OBJTREE_OBJECT_H