MASA-Core
Grid.hpp
Go to the documentation of this file.
00001 /*******************************************************************************
00002  *
00003  * Copyright (c) 2010-2015   Edans Sandes
00004  *
00005  * This file is part of MASA-Core.
00006  * 
00007  * MASA-Core is free software: you can redistribute it and/or modify
00008  * it under the terms of the GNU General Public License as published by
00009  * the Free Software Foundation, either version 3 of the License, or
00010  * (at your option) any later version.
00011  * 
00012  * MASA-Core is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  * GNU General Public License for more details.
00016  * 
00017  * You should have received a copy of the GNU General Public License
00018  * along with MASA-Core.  If not, see <http://www.gnu.org/licenses/>.
00019  *
00020  ******************************************************************************/
00021 
00022 class Grid;
00023 
00024 #ifndef GRID_HPP_
00025 #define GRID_HPP_
00026 
00027 #include <stdio.h>
00028 
00029 #include "Partition.hpp"
00030 
00031 class Grid {
00032 public:
00033         Grid(Partition partition);
00034         virtual ~Grid();
00035 
00036         void setBlockHeight(int blockHeight);
00037         void setBlockWidth(int blockWidth);
00038 
00039         void splitGridVertically(int count);
00040         void splitGridHorizontally(int count);
00041 
00042         void splitGridVertically(int count, int* splits);
00043         void splitGridHorizontally(int count, int* splits);
00044 
00045         void getBlockPosition(int bx, int by, int* i0, int* j0, int* i1=NULL, int* j1=NULL) const;
00046 
00047         void setMinBlockSize(int minBlockWidth, int minBlockHeight);
00048 
00049         void setAdjustment(int adjustment);
00050         int  getBlockAdjustment(int bx, int by) const;
00051 
00052         int getGridWidth() const;
00053         int getGridHeight() const;
00054 
00055         int getBlockWidth(int bx, int by) const;
00056         int getBlockHeight(int bx, int by) const;
00057 
00058         int getHeight() const;
00059         int getWidth() const;
00060 
00061         const int* getBlockSplitHorizontal() const;
00062         const int* getBlockSplitVertical() const;
00063 
00064 private:
00065         int  blockWidth;
00066         int  blockHeight;
00067         int  adjustment;
00068         int  minBlockWidth;
00069         int  minBlockHeight;
00070 
00071         /*
00072          * The split vectors will contains the start coordinates of each block.
00073          * The first element will always be 0 and the last element will have the
00074          * dimension size. Note that the vector must contain N+1 elements, so the
00075          * last element is blockSplitXXX[blockCountXXX].
00076          */
00077         int  blockCountHorizontal;
00078         int* blockSplitHorizontal;
00079         int  blockCountVertical;
00080         int* blockSplitVertical;
00081 
00082         int width;
00083         int height;
00084         Partition partition;
00085 
00086         void getBlockPositionH(int bx, int by, int* j0, int* j1) const;
00087         void getBlockPositionV(int bx, int by, int* i0, int* i1) const;
00088 
00089 };
00090 
00091 #endif /* GRID_HPP_ */