Tekkotsu Homepage | Demos | Overview | Downloads | Dev. Resources | Reference | Credits |
SketchIndices.ccGo to the documentation of this file.00001 #include "SketchIndices.h" 00002 #include "Sketch.h" 00003 #include "SketchSpace.h" 00004 #include "visops.h" 00005 #include <algorithm> 00006 #include <iostream> 00007 #include <iterator> 00008 00009 namespace DualCoding { 00010 00011 const SketchIndices SketchIndices::operator[] (const Sketch<uint>& indirection) const { 00012 SketchIndices redir; 00013 for (CI it = table.begin(); it != table.end(); ++it) 00014 redir.table.insert(indirection[*it]); 00015 return redir; 00016 } 00017 00018 const SketchIndices 00019 SketchIndices::operator+ (const SketchIndices& other) const { 00020 SketchIndices result(*this); 00021 for (CI it = other.table.begin(); it != other.table.end(); ++it) 00022 result.table.insert(*it); 00023 return result; 00024 } 00025 00026 const SketchIndices SketchIndices::operator- (const SketchIndices& other) const { 00027 SketchIndices result(*this); 00028 for (CI o = other.table.begin(); o != other.table.end(); ++o) 00029 result.table.erase(*o); 00030 return result; 00031 } 00032 00033 std::ostream& operator<< (std::ostream& out, const SketchIndices &s) { 00034 typedef std::ostream_iterator<SketchIndices::SketchIndicesTable::value_type, char, 00035 std::char_traits<char> > ositer; 00036 std::copy(s.table.begin(), s.table.end(), ositer(std::cout," ")); 00037 return out; 00038 } 00039 00040 void SketchIndices::addIndices(const Sketch<bool>& im) 00041 { 00042 size_t length = im->getNumPixels(); 00043 for (size_t i = 0; i < length; i++) 00044 if ( im[i] ) 00045 table.insert(i); 00046 } 00047 00048 void SketchIndices::trimBounds(const SketchSpace &space) { 00049 SketchIndices result; 00050 for (SketchIndices::CI it = table.begin(); it != table.end(); ++it) 00051 if ( *it < space.getNumPixels() ) 00052 result.table.insert(*it); 00053 table = result.table; 00054 } 00055 00056 Sketch<bool> SketchIndices::getRendering(SketchSpace &space) const { 00057 Sketch<bool> result = visops::zeros(space); 00058 SketchIndices::CI it; 00059 for (it = table.begin(); it != table.end(); it++) 00060 result[*it] = true; 00061 return result; 00062 } 00063 00064 00065 } // namespace |
DualCoding 5.1CVS |
Generated Mon May 9 04:56:27 2016 by Doxygen 1.6.3 |