Tekkotsu Homepage
Demos
Overview
Downloads
Dev. Resources
Reference
Credits

SketchIndices.h

Go to the documentation of this file.
00001 //-*-c++-*-
00002 #ifndef INCLUDED_SketchIndices_h
00003 #define INCLUDED_SketchIndices_h
00004 
00005 #include <iosfwd> // forward declaration for ostream
00006 #if (!defined(__GNUC__) || __GNUC__>=4)
00007 #  include <tr1/unordered_set>
00008 #else
00009 #  include <ext/hash_set>
00010 #endif
00011 
00012 #include "SketchTypes.h"
00013 
00014 namespace DualCoding {
00015 
00016 class SketchSpace;
00017 template<class T> class Sketch;
00018 
00019 //! Table of indices of sketch elements; parent of the Region class
00020 class SketchIndices {
00021  public:
00022 #if (!defined(__GNUC__) || __GNUC__>=4)
00023   typedef std::tr1::unordered_set<uint> SketchIndicesTable;
00024 #else
00025   typedef __gnu_cxx::hash_set<uint, __gnu_cxx::hash<uint>, std::equal_to<uint> > SketchIndicesTable;
00026 #endif
00027   typedef SketchIndicesTable::const_iterator CI;
00028 
00029   SketchIndicesTable table;
00030   
00031   //! Constructor
00032   SketchIndices() : table() {};
00033 
00034   //! Destructor
00035   virtual ~SketchIndices() {};
00036   
00037   //! Operator for indirection based on passed in Sketch.
00038   //! Returns a new SketchIndices based on applying the indirection.
00039   const SketchIndices operator[] (const Sketch<uint>& indirection) const;
00040   
00041   //! Returns the result of adding the elements of another SketchIndices
00042   //! to the current SketchIndices
00043   const SketchIndices operator+ (const SketchIndices& other) const;
00044   
00045   //! Returns the result of removing the elements of another SketchIndices
00046   //! from the current SketchIndices.
00047   //! This is much more computationally expensive than addition, so try
00048   //! to minimize usage by distribution law: x-y-z=x-(y+z)
00049   const SketchIndices operator- (const SketchIndices& other) const;
00050 
00051   //! Adds indices of non-zero pixels.
00052   void addIndices(const Sketch<bool>& im);
00053 
00054   //! Removes any indices from SketchIndices which are outside the bounds of the SketchSpace
00055   void trimBounds(const SketchSpace &space);
00056   
00057   //! Renders the indices as a Sketch<bool>
00058   Sketch<bool> getRendering(SketchSpace &space) const;
00059 
00060 };
00061 
00062 //! prints out SketchIndices for debugging
00063 std::ostream& operator<< (std::ostream& out, const SketchIndices &s);
00064 
00065 } // namespace
00066 
00067 #endif

DualCoding 5.1CVS
Generated Mon May 9 04:56:27 2016 by Doxygen 1.6.3