SearchArray.H
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043 #ifndef PSYCHO_SEARCHARRAY_H_DEFINED
00044 #define PSYCHO_SEARCHARRAY_H_DEFINED
00045
00046 #include "Image/Image.H"
00047 #include "Image/Pixels.H"
00048 #include "Image/vec2.h"
00049 #include "Psycho/SearchItem.H"
00050 #include "rutz/arrays.h"
00051 #include "rutz/shared_ptr.h"
00052
00053 #include <string>
00054 #include <vector>
00055
00056 namespace rutz
00057 {
00058 class urand;
00059 }
00060
00061
00062
00063 class SearchArray
00064 {
00065 public:
00066 SearchArray(const Dims& dims = Dims(512, 512),
00067 double gridSpacing = 48.0,
00068 double minSpacing = 36.0,
00069 double margin = 0.0);
00070
00071 virtual ~SearchArray() throw();
00072
00073 void addElement(const rutz::shared_ptr<SearchItem>& e, bool displace = false) const;
00074 size_t numElements() const { return itsArray.size(); }
00075
00076 void replaceElementAtSamePos(size_t i, const rutz::shared_ptr<SearchItem>& e);
00077
00078 void generateBackground(SearchItemFactory& factory,
00079 const int diffusionCycles = 10,
00080 const bool doFinalFill = true,
00081 const int jitterIters = 1000,
00082 const bool doJitterForeground = false,
00083 const int backgSeed = 0) const;
00084
00085 Image<byte> getImage(const double lo = -1.0, const double hi = 1.0,
00086 const double bg = 0.0,
00087 bool doTagLast = false) const;
00088
00089 void pareBackground(const uint shrunkSize) const;
00090 void clear() const;
00091 void saveCoords(const std::string& filename) const;
00092 Rectangle itemBounds() const;
00093 private:
00094 SearchArray(const SearchArray&);
00095 SearchArray& operator=(const SearchArray&);
00096
00097 void doAddElement(const rutz::shared_ptr<SearchItem>& e, const bool toFront = false) const;
00098 bool tooClose(const geom::vec2<double>& v, int except) const;
00099 void backgHexGrid(SearchItemFactory& factory) const;
00100 void backgFill(SearchItemFactory& factory) const;
00101 void backgJitter(rutz::urand& urand, const int niter,
00102 const bool doJitterForeground) const;
00103 void doRemoveElement(const rutz::shared_ptr<SearchItem>& e) const;
00104 Dims itsDims;
00105 double itsGridSpacing;
00106 double itsMinSpacing;
00107 double itsFillResolution;
00108 double itsMargin;
00109
00110 mutable std::vector<rutz::shared_ptr<SearchItem> > itsArray;
00111
00112 bool itsDumpingFrames;
00113 unsigned int itsFrameDumpPeriod;
00114 };
00115
00116
00117
00118
00119
00120
00121
00122
00123 #endif // PSYCHO_SEARCHARRAY_H_DEFINED