/* * NICE-Core - efficient algebra and computer vision methods * - libimage - An image/template for new NICE libraries * See file License for license information. */ #include "core/image/CrossT.h" #include "core/image/LineT.h" namespace NICE { // Constructors: // ------------- template CrossT

::CrossT(const Coord &_center, const unsigned int _halfWidth, bool _diagonal) : center(_center), halfWidth(_halfWidth), diagonal(_diagonal) { } template CrossT

::CrossT(const Coord &_center, const unsigned int _halfWidth, bool _diagonal, const ColorT

& _defaultColor) : Drawable

(_defaultColor), center(_center), halfWidth(_halfWidth), diagonal(_diagonal) { } template CrossT

::CrossT(const CrossT

& ex) : Drawable

(ex) { *this = ex; } // Operators: // ---------- template CrossT

& CrossT

::operator=(const CrossT

& ex) { center = ex.center; this->halfWidth = ex.halfWidth; this->defaultColor = ex.defaultColor; return *this; } template bool CrossT

::operator==(const CrossT

& ex) const { if(center == ex.center && this->halfWidth == ex.halfWidth && this->defaultColor == ex.defaultColor) return true; else return false; } template bool CrossT

::operator!=(const CrossT

& ex) const { return !(this->operator==(ex)); } // Methods: // -------- template void CrossT

::doDraw(ColorImageT

&image, const ColorT

& color) const { const int x = center.x; const int y = center.y; const int left = center.x - halfWidth; const int right = center.x + halfWidth; const int top = center.y - halfWidth; const int bottom = center.y + halfWidth; if (diagonal) { LineT

line1(Coord(left, top), Coord(right, bottom)); LineT

line2(Coord(left, bottom), Coord(right, top)); line1.draw(image, color); line2.draw(image, color); } else { LineT

line1(Coord(left, y), Coord(right, y)); LineT

line2(Coord(x, top), Coord(x, bottom)); line1.draw(image, color); line2.draw(image, color); } } template void CrossT

::doDraw(ImageT

&image, const P& gray) const { const int x = center.x; const int y = center.y; const int left = center.x - halfWidth; const int right = center.x + halfWidth; const int top = center.y - halfWidth; const int bottom = center.y + halfWidth; if (diagonal) { LineT

line1(Coord(left, top), Coord(right, bottom)); LineT

line2(Coord(left, bottom), Coord(right, top)); line1.draw(image, gray); line2.draw(image, gray); } else { LineT

line1(Coord(left, y), Coord(right, y)); LineT

line2(Coord(x, top), Coord(x, bottom)); line1.draw(image, gray); line2.draw(image, gray); } } // Destructor: // ----------- template CrossT

::~CrossT() { } }; // namespace NICE