32 #ifndef COORD_HANDLER_H_
33 #define COORD_HANDLER_H_
35 #include <drain/image/CoordinatePolicy.h>
36 #include <drain/Log.h>
40 #include "drain/util/Flags.h"
41 #include "drain/util/Frame.h"
44 #include "ImageFrame.h"
45 #include "Direction.h"
108 xRange.set(handler.getXRange());
109 yRange.set(handler.getYRange());
110 area.set(handler.area);
138 setLimits(src.getWidth(), src.getHeight());
144 setLimits(area.getWidth(), area.getHeight());
150 void setLimits(
int xMin,
int yMin,
int xUpperLimit,
int yUpperLimit){
151 xRange.set(xMin, xUpperLimit - 1);
152 yRange.set(yMin, yUpperLimit - 1);
153 area.set(xUpperLimit, yUpperLimit);
158 setLimits(0, 0, xUpperLimit, yUpperLimit);
176 setPolicy(p.xUnderFlowPolicy, p.yUnderFlowPolicy, p.xOverFlowPolicy, p.yOverFlowPolicy);
180 void setPolicy(EdgePolicy::index_t xUnderFlowPolicy, EdgePolicy::index_t yUnderFlowPolicy, EdgePolicy::index_t xOverFlowPolicy, EdgePolicy::index_t yOverFlowPolicy);
210 result |= (this->*handleXUnderFlow)(x,y);
213 result |= (this->*handleXOverFlow)(x,y);
216 result |= (this->*handleYUnderFlow)(x,y);
218 if (y >= area.height)
219 result |= (this->*handleYOverFlow)(x,y);
297 x = x % area.width + area.width;
304 y = y % area.height + area.height;
337 x = 2*xRange.max - x;
343 y = 2*yRange.max - y;
354 x = xRange.min - x - 1;
355 y = (y + area.height/2) % area.height;
366 y = yRange.min - y - 1;
367 x = (x + area.width/2) % area.width;
373 x = 2*xRange.max - x + 1;
374 y = (y + area.height/2) % area.height;
380 y = 2*yRange.max - y + 1;
381 x = (x + area.width/2) % area.width;
402 std::ostream & operator<<(std::ostream & ostr,
const CoordinateHandler2D & handler);
Two-way mapping between strings and objects of template class T.
Definition: Dictionary.h:63
Definition: CoordinateHandler.h:77
bool validate(int &x, int &y) const
Handles the coordinate, returning true if the position is reversible.
Definition: CoordinateHandler.h:244
void setPolicy(EdgePolicy::index_t p)
Set the same policy in all the directions.
Definition: CoordinateHandler.h:184
CoordinateHandler2D(int xUpperLimit, int yUpperLimit, const CoordinatePolicy &policy=CoordinatePolicy())
Constructor.
Definition: CoordinateHandler.h:127
static const coord_overflow_t IRREVERSIBLE
Equal move in inverse direction would not result original position.
Definition: CoordinateHandler.h:90
coord_overflow_t polarXUnderFlow(int &x, int &y) const
Definition: CoordinateHandler.h:353
coord_overflow_t polarYUnderFlow(int &x, int &y) const
Definition: CoordinateHandler.h:365
coord_overflow_t handle(Point2D< int > &p) const
Calls handle(int &x,int &y)
Definition: CoordinateHandler.h:227
void setLimits(int xMin, int yMin, int xUpperLimit, int yUpperLimit)
Sets minimum values and outer upper limits for x and y.
Definition: CoordinateHandler.h:150
coord_overflow_t skipUndefined(int &x, int &y) const
Does nothing to the coordinates.
Definition: CoordinateHandler.h:266
virtual coord_overflow_t handle(int &x, int &y) const
Ensures the validity of the coordinates. If inside limits, arguments (x,y) remain intact and 0 is ret...
Definition: CoordinateHandler.h:205
CoordinateHandler2D(const drain::image::AreaGeometry &area=AreaGeometry(), const CoordinatePolicy &policy=CoordinatePolicy())
Default constructor.
Definition: CoordinateHandler.h:99
bool validate(Point2D< int > &p) const
Handles the coordinate, returning true if the position is reversible.
Definition: CoordinateHandler.h:238
void setPolicy(const CoordinatePolicy &p)
Assigns internal function pointers.
Definition: CoordinateHandler.h:175
void setLimits(int xUpperLimit, int yUpperLimit)
Sets outer upper limits for x and y.
Definition: CoordinateHandler.h:157
Policies for coordinate underflows and overflows.
Definition: CoordinatePolicy.h:106
Struct for image (excluding data)
Definition: ImageConf.h:333
Image with static geometry.
Definition: ImageFrame.h:67
const CoordinatePolicy & getCoordinatePolicy() const
Coord policy.
Definition: ImageLike.h:167
unsigned int coord_overflow_t
typedef drain::GlobalFlags<CoordinatePolicy> coord_overflow_flagger_t;
Definition: CoordinateHandler.h:75
Definition: DataSelector.cpp:1277
Definition: Direction.h:46