33 #ifndef _FINRESDYN_PLOTCOVER_H_ 34 #define _FINRESDYN_PLOTCOVER_H_ 38 #include "chomp/system/textfile.h" 39 #include "chomp/bitmaps/bitmaps.h" 49 template <
class CoverType>
50 inline void plotCover (
const CoverType &cover,
const char *filename,
53 using namespace chomp::homology;
56 if (cover. dim () != 2)
57 throw "Trying to plot a cover of dimension other than 2.";
60 typedef typename CoverType::NumberType NumType;
63 NumType leftCorner [2];
64 cover. getLeftCorner (leftCorner);
67 NumType boxWidths [2];
68 cover. getBoxWidths (boxWidths);
75 int height = static_cast <
int> (boxWidths [1] / boxWidths [0] *
82 bmp. invertedpicture ();
83 const int pallength = 3;
84 int32 palette [pallength] = {0x000000, 0x7F7F7F, 0xFFFFFF};
85 bmp. create (filename, width, height, 4, pallength, palette);
88 NumType leftBounds [2];
89 NumType rightBounds [2];
95 for (
int n = 0; n < cover. size (); ++ n)
97 cover.
get (n, leftBounds, rightBounds);
98 for (
int i = 0; i < 2; ++ i)
100 left [i] =
static_cast<int> ((leftBounds [i] -
101 leftCorner [i]) / boxWidths [i] *
103 if (left [i] >= bmpSize [i])
104 left [i] = bmpSize [i] - 1;
105 right [i] =
static_cast<int> ((rightBounds [i] -
106 leftCorner [i]) / boxWidths [i] *
108 if (right [i] > bmpSize [i])
109 right [i] = bmpSize [i] - 1;
110 if (right [i] <= left [i])
111 right [i] = left [i] + 1;
114 for (
int x = left [0]; x < right [0]; ++ x)
116 for (
int y = left [1]; y < right [1]; ++ y)
119 if ((x == left [0]) ||
120 (x == right [0] - 1) ||
122 (y == right [1] - 1))
126 bmp. putpixel (x, y, color,
true);
134 #endif // _FINRESDYN_PLOTCOVER_H_ Various output streams for the program.
void plotCover(const CoverType &cover, const char *filename, int width)