#ifndef QUADTREE_H #define QUADTREE_H // A square, two-dimensional, black and white bitmap image // of size SxS, where S is a power of 2 and S >= 1. class QuadTree { public: QuadTree(); ~QuadTree(); // Copy constructor and assignment operator QuadTree( const QuadTree& q ); const QuadTree& operator=( const QuadTree& q ); // Reads in an image from stdin. // The image is assumed to be of appropriate format and to // be square with dimensions that are a power of 2. void readImage(); // Outputs the image to stdout. void writeImage() const; // Returns the width (which equals the height) of the square image. int getSize() const; // Returns number of nodes in the quadtree representation of the image, // including the root node. // If no image has been read in, this method returns 0. // If an image has been read in, this method returns a number >= 1. int getNumNodes() const; // Returns true if the pixel element at the given column and row is black. // Note that the (col,row) pair must be in the interval [0,S-1]x[0,S-1], // where S is the size of the image. // The element (0,0) is at the upper-left corner of the image. bool isBlack( int col, int row ) const; // Returns the total area covered by black pixel elements. int blackArea() const; // Returns the total area covered by white pixel elements. int whiteArea() const; // Makes every white element black, and every black element white. void invert(); // Rotates the image 90 degrees clockwise. // So, for example, if S is the size of the image, // this method will map pixels (0,0) and (S-1,0) to // (S-1,0) and (S-1,S-1), respectively. void rotate(); // The following two methods are for compositing (or "overlaying") // two images. The input images must be of the same size. // computeUnion() will return an image that has black pixels anywhere // either input image has a black pixel. // computeIntersection() will return an image that has black pixels only // where both input images have black pixels. static QuadTree computeUnion( const QuadTree& q1, const QuadTree& q2 ); static QuadTree computeIntersection( const QuadTree& q1, const QuadTree& q2 ); }; #endif /* QUADTREE_H */