• Main Page
  • Related Pages
  • Classes
  • Files
  • File List

src/VertexObject.hh

00001 /*
00002  * Copyright Staffan Gimåker 2007-2010.
00003  *
00004  * ---
00005  *
00006  * This file is part of peekabot.
00007  *
00008  * peekabot is free software; you can redistribute it and/or modify
00009  * it under the terms of the GNU General Public License as published by
00010  * the Free Software Foundation; either version 3 of the License, or
00011  * (at your option) any later version.
00012  *
00013  * peekabot is distributed in the hope that it will be useful,
00014  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00015  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016  * GNU General Public License for more details.
00017  *
00018  * You should have received a copy of the GNU General Public License
00019  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
00020  */
00021 
00022 #ifndef PEEKABOT_VERTEX_OBJECT_HH_INCLUDED
00023 #define PEEKABOT_VERTEX_OBJECT_HH_INCLUDED
00024 
00025 
00026 #include <vector>
00027 #include <boost/cstdint.hpp>
00028 #include <boost/signals2.hpp>
00029 #include <Eigen/Core>
00030 
00031 #include "Types.hh"
00032 #include "XMLHandler.hh"
00033 #include "PropMap.hh"
00034 
00035 namespace peekabot
00036 {
00037     class ScopedHandler;
00038 
00039     class VertexObject
00040     {
00041     public:
00042         typedef std::vector<Eigen::Vector3f> Vertices;
00043         typedef std::vector<boost::uint8_t> VertexColors;
00044 
00045         VertexObject(boost::uint32_t multiple_of = 1) throw();
00046 
00050         VertexObject(ScopedHandler *handler, boost::uint32_t multiple_of = 1);
00051 
00052         virtual ~VertexObject() {}
00053 
00054         void set_vertices(const Vertices &vertices);
00055 
00056         void add_vertices(const Vertices &vertices);
00057 
00058         const Vertices &get_vertices() const throw();
00059 
00060         void set_colored_vertices(const Vertices &vertices, const VertexColors &colors);
00061 
00062         void add_colored_vertices(const Vertices &vertices, const VertexColors &colors);
00063 
00064         const VertexColors &get_vertex_colors() const;
00065 
00066         bool has_vertex_colors() const;
00067 
00068         std::size_t get_vertex_count() const throw();
00069 
00070         void set_overflow_policy(VertexOverflowPolicy policy);
00071 
00072         VertexOverflowPolicy get_overflow_policy() const;
00073 
00074         void set_max_vertices(boost::uint32_t n);
00075 
00076         boost::uint32_t get_max_vertices() const;
00077 
00080 
00081         typedef boost::signals2::signal<void ()> VerticesSetSignal;
00082 
00083         typedef boost::signals2::signal<void (
00084             const Vertices &new_vertices,
00085             const VertexColors *new_colors)> VerticesAddedSignal;
00086 
00087         typedef boost::signals2::signal<void ()> OverflowPolicySetSignal;
00088 
00089         typedef boost::signals2::signal<void ()> MaxVerticesSetSignal;
00090 
00091         inline VerticesSetSignal &vertices_set_signal() const
00092         {
00093             return m_vertices_set_signal;
00094         }
00095 
00096         inline VerticesAddedSignal &vertices_added_signal() const
00097         {
00098             return m_vertices_added_signal;
00099         }
00100 
00101         inline OverflowPolicySetSignal &overflow_policy_set_signal() const
00102         {
00103             return m_overflow_policy_set_signal;
00104         }
00105 
00106         inline MaxVerticesSetSignal &max_vertices_set_signal() const
00107         {
00108             return m_max_vertices_set_signal;
00109         }
00110 
00112 
00113     protected:
00114         virtual PropMap &get_prop_adapters();
00115 
00116     private:
00117         static void create_prop_adapters(PropMap &adapters);
00118 
00119         bool handle_overflow();
00120 
00123 
00124         void vertices_start_handler(
00125             boost::function<void (const std::string&, ScopedHandler*)> end_handler,
00126             const std::string tag_name,
00127             XMLHandler::AttributeMap & attributes,
00128             ScopedHandler* handler);
00129 
00130         void vertices_end_handler(
00131             const std::string &name, ScopedHandler *handler)
00132             throw(std::runtime_error, std::length_error);
00133 
00134 
00135         static void vertex_cdata_handler(
00136             const std::string &cdata,
00137             ScopedHandler *handler);
00138 
00139 
00140         static void vertex_start_handler(
00141             const std::string & tag_name,
00142             XMLHandler::AttributeMap &attributes,
00143             ScopedHandler *handler);
00144 
00146 
00147     private:
00148         const boost::uint32_t m_multiple_of;
00149 
00150         boost::uint32_t m_max_vertices;
00151         VertexOverflowPolicy m_overflow_policy;
00152 
00153         Vertices m_vertices;
00154         VertexColors m_vertex_colors;
00155 
00156         mutable VerticesSetSignal m_vertices_set_signal;
00157         mutable VerticesAddedSignal m_vertices_added_signal;
00158         mutable OverflowPolicySetSignal m_overflow_policy_set_signal;
00159         mutable MaxVerticesSetSignal m_max_vertices_set_signal;
00160     };
00161 }
00162 
00163 
00164 #endif // PEEKABOT_VERTEX_OBJECT_HH_INCLUDED

Generated on Sun Jan 30 2011 for peekabot by  doxygen 1.7.1