00001 #ifndef Impala_Core_Geometry_InterestRectangleZ_h
00002 #define Impala_Core_Geometry_InterestRectangleZ_h
00003
00004 #include "Core/Geometry/InterestPoint.h"
00005 #include "Core/Geometry/Rectangle.h"
00006 #include "Util/StringParser.h"
00007
00008 namespace Impala
00009 {
00010 namespace Core
00011 {
00012 namespace Geometry
00013 {
00014
00017 class InterestRectangleZ : public InterestPoint, public Rectangle {
00018 public:
00019
00020
00021
00022 InterestRectangleZ() : InterestPoint(), Rectangle(0, 0, 0, 0)
00023 {
00024 }
00025
00026 InterestRectangleZ(Rectangle& rect)
00027 : InterestPoint(), Rectangle(rect)
00028 {
00029
00030
00031 mX = static_cast<int>(((mRight - mLeft) / 2.0 + mLeft) + 0.5);
00032 mY = static_cast<int>(((mBottom - mTop) / 2.0 + mTop) + 0.5);
00033 }
00034
00035 InterestRectangleZ(std::string& region, Real64 shiftX=0, Real64 shiftY=0) : InterestPoint()
00036 {
00037 if(region.substr(0, 6) != "<RECT ") {
00038 throw "Get your act together: <RECT should be the start!";
00039 }
00040 Util::StringParser sp(region);
00041 std::string temp = sp.GetString(' ');
00042 mLeft = sp.GetInt(' ') - shiftX;
00043 mTop = sp.GetInt(' ') - shiftY;
00044 mRight = sp.GetInt(' ') - shiftX;
00045 mBottom = sp.GetInt(' ') - shiftY;
00046
00047
00048 mX = static_cast<int>(((mRight - mLeft) / 2.0 + mLeft) + 0.5);
00049 mY = static_cast<int>(((mBottom - mTop) / 2.0 + mTop) + 0.5);
00050 }
00051
00052 void
00053 Update()
00054 {
00055 }
00056
00057 std::string
00058 geometryType()
00059 {
00060 return "RectangleZ";
00061 }
00062
00063 Rectangle
00064 GetRect()
00065 {
00066 return Rectangle(mLeft, mTop, mRight, mBottom);
00067 }
00068
00069 std::string
00070 Serialize(Real64 shiftX=0, Real64 shiftY=0)
00071 {
00072 std::ostringstream os;
00073 os << "<RECT " << mLeft+shiftX << " " << mTop+shiftY << " " << mRight+shiftX << " " << mBottom+shiftY << ">;";
00074 return os.str();
00075 }
00076 };
00077
00078 }
00079 }
00080 }
00081
00082 #endif