/** * Constructs a new hex grid with a shape determined by the IsInsider shape. * * \param width * The with of the hex rectangle that will contain the grid. * * \param height * The height of the hex rectangle that will contain the grid. * * \param isInsideTest * A function that tests whether a given point is inside * the grid. This function should not rely on the points given to it to be limited * in any way by the specified with and height. * * \param gridPointTransform * Points returned by tis grid are transformed first with this delagate. * * \param inverseGridPointTransform * This must be the inverse of the gridPointTransform function. * Together, these functions make it possible to do things such as flip axes. * */ protected AbstractUniformGrid(int width, int height, Func <TPoint, bool> isInsideTest, Func <TPoint, TPoint> gridPointTransform, Func <TPoint, TPoint> inverseGridPointTransform, IEnumerable <TPoint> neighborDirections) { #if Trial DLLUtil.CheckTrial(); #elif EXPERIMENTAL ExperimentalUtil.CreateGUI(); #endif this.width = width; this.height = height; cells = new TCell[width, height]; contains = isInsideTest; SetGridPointTransforms(gridPointTransform, inverseGridPointTransform); //Copy the neighbors to prevent external and unexpected manipulation NeighborDirections = neighborDirections; //TODO: replace; this is just for now //InitNeighbors(); }
/** * Constructs a new hex grid with a shape determined by the IsInsider shape. * * \param width * The with of the hex rectangle that will contain the grid. * * \param height * The height of the hex rectangle that will contain the grid. * * \param isInsideTest * A function that tests whether a given point is inside * the grid. This function should not rely on the points given to it to be limited * in any way by the specified with and height. * * \param gridPointTransform * Points returned by tis grid are transformed first with this delagate. * * \param inverseGridPointTransform * This must be the inverse of the gridPointTransform function. * Together, these functions make it possible to do things such as flip axes. * */ protected AbstractUniformGrid(int width, int height, Func <TPoint, bool> isInsideTest, Func <TPoint, TPoint> gridPointTransform, Func <TPoint, TPoint> inverseGridPointTransform) { #if Trial DLLUtil.CheckTrial(); #elif EXPERIMENTAL ExperimentalUtil.CreateGUI(); #endif this.width = width; this.height = height; cells = new TCell[width, height]; contains = isInsideTest; SetGridPointTransforms(gridPointTransform, inverseGridPointTransform); //TODO: replace; this is just for now InitNeighbors(); }