Hugintrunk
0.1
|
base class, which stores one mask polygon More...
#include <Mask.h>
Public Types | |
enum | MaskType { Mask_negative =0, Mask_positive =1, Mask_Stack_negative =2, Mask_Stack_positive =3, Mask_negative_lens =4 } |
enumeration with type of possible masks More... | |
Public Member Functions | |
MaskPolygon () | |
constructor More... | |
bool | isInside (const hugin_utils::FDiff2D p) const |
checks if given point is inside of the stored polygon More... | |
int | getWindingNumber (const hugin_utils::FDiff2D p) const |
returns the winding number of the polygon around point p More... | |
int | getTotalWindingNumber () const |
returns the total winding number of the polygon More... | |
MaskType | getMaskType () const |
returns mask type More... | |
void | setMaskType (const MaskType newType) |
sets mask type More... | |
bool | isPositive () const |
returns true, if mask type is positive More... | |
VectorPolygon | getMaskPolygon () const |
returns vector with coordinates of the polygon More... | |
void | setMaskPolygon (const VectorPolygon &newMask) |
set complete vector with all corrdinates of the polygon More... | |
unsigned int | getImgNr () const |
returns the associated image number, only used when loading a project, otherwise discarded More... | |
void | setImgNr (const unsigned int newImgNr) |
sets the associated image number, only used when loading a project, otherwise discarded More... | |
void | setInverted (const bool inverted) |
set mask to normal or inverted More... | |
bool | isInverted () const |
returns if mask is inverted More... | |
void | addPoint (const hugin_utils::FDiff2D p) |
adds point at the end to the polygon More... | |
void | insertPoint (const unsigned int index, const hugin_utils::FDiff2D p) |
insert point at the position index into the polygon More... | |
void | removePoint (const unsigned int index) |
removes point at the position index from the polygon More... | |
void | movePointTo (const unsigned int index, const hugin_utils::FDiff2D p) |
moves the point at position index to the new absolute position p More... | |
void | movePointBy (const unsigned int index, const hugin_utils::FDiff2D diff) |
relativ moves the point at position index by diff More... | |
void | scale (const double factorx, const double factory) |
scales all polygon coordinates by factorx for x position and factory for y position More... | |
void | scale (const double factor) |
scales x and y axis equally by factor More... | |
void | transformPolygon (const PTools::Transform &trans) |
transforms the polygon coordinates by the given transformation More... | |
bool | clipPolygon (const vigra::Rect2D rect) |
clips the polygon to the given rectangle More... | |
bool | clipPolygon (const hugin_utils::FDiff2D center, const double radius) |
clips the polygon to the circle with center and radius More... | |
void | rotate90 (bool clockwise, unsigned int maskWidth, unsigned int maskHeight) |
rotate the polygon by 90 degrees More... | |
void | subSample (const double max_distance) |
subsamples the polygon, so that the longest distance between 2 points is max_distance More... | |
unsigned int | FindPointNearPos (const hugin_utils::FDiff2D p, const double tol) const |
search a point which lies near the polygon line and return the index for inserting the new point More... | |
MaskPolygon & | operator= (const MaskPolygon &otherPoly) |
assign operator More... | |
const bool | operator== (const MaskPolygon &otherPoly) const |
comparision operator More... | |
bool | parsePolygonString (const std::string &polygonStr) |
parses the x and y positions from the given string More... | |
void | printPolygonLine (std::ostream &o, const unsigned int newImgNr) const |
writes the complete k line which describes the mask to the stream, using the given newImgNr for the i parameter More... | |
Private Member Functions | |
void | calcBoundingBox () |
calculates the bounding box of the polygon to speed up tests More... | |
Private Attributes | |
MaskType | m_maskType |
VectorPolygon | m_polygon |
unsigned int | m_imgNr |
bool | m_invert |
vigra::Rect2D | m_boundingBox |
base class, which stores one mask polygon
note: the mask handling (e.g. propagating of positive masks) happens in HuginBase::Panorama::updateMasks which is automatic called after a change to the panorama object by HuginBase::Panorama::changedFinished
void HuginBase::MaskPolygon::addPoint | ( | const hugin_utils::FDiff2D | p | ) |
adds point at the end to the polygon
Definition at line 109 of file Mask.cpp.
References calcBoundingBox(), and m_polygon.
Referenced by getTotalWindingNumber(), MaskImageCtrl::OnLeftMouseDown(), MaskImageCtrl::OnLeftMouseUp(), and subSample().
|
private |
calculates the bounding box of the polygon to speed up tests
Definition at line 206 of file Mask.cpp.
References m_boundingBox, and m_polygon.
Referenced by addPoint(), clipPolygon(), insertPoint(), movePointBy(), movePointTo(), parsePolygonString(), removePoint(), rotate90(), scale(), setMaskPolygon(), and transformPolygon().
bool HuginBase::MaskPolygon::clipPolygon | ( | const vigra::Rect2D | rect | ) |
clips the polygon to the given rectangle
Definition at line 325 of file Mask.cpp.
References calcBoundingBox(), HuginBase::clip_onPlane(), HuginBase::clipBottom, HuginBase::clipLeft, HuginBase::clipRight, HuginBase::clipTop, and m_polygon.
Referenced by HuginBase::Panorama::transferMask().
bool HuginBase::MaskPolygon::clipPolygon | ( | const hugin_utils::FDiff2D | center, |
const double | radius | ||
) |
clips the polygon to the circle with center and radius
Definition at line 447 of file Mask.cpp.
References HuginBase::angle_between(), calcBoundingBox(), HuginBase::clip_getIntersectionCircle(), HuginBase::clip_insideCircle(), DEBUG_ASSERT, HuginBase::generateArc(), and m_polygon.
unsigned int HuginBase::MaskPolygon::FindPointNearPos | ( | const hugin_utils::FDiff2D | p, |
const double | tol | ||
) | const |
search a point which lies near the polygon line and return the index for inserting the new point
Definition at line 559 of file Mask.cpp.
References m_polygon, hugin_utils::norm(), hugin_utils::sqr(), hugin_utils::TDiff2D< T >::x, and hugin_utils::TDiff2D< T >::y.
Referenced by MaskImageCtrl::OnLeftMouseDown().
|
inline |
returns the associated image number, only used when loading a project, otherwise discarded
Definition at line 85 of file Mask.h.
Referenced by operator=().
|
inline |
returns vector with coordinates of the polygon
Definition at line 81 of file Mask.h.
Referenced by MaskImageCtrl::DrawPolygon(), MaskImageCtrl::OnKeyUp(), MaskImageCtrl::OnLeftMouseDblClick(), MaskImageCtrl::OnLeftMouseDown(), MaskImageCtrl::OnLeftMouseUp(), MaskImageCtrl::OnMouseMove(), MaskImageCtrl::OnRightMouseDown(), MaskImageCtrl::OnRightMouseUp(), operator=(), operator==(), MaskImageCtrl::SelectPointsInsideMouseRect(), and HuginBase::Panorama::transferMask().
|
inline |
returns mask type
Definition at line 75 of file Mask.h.
Referenced by MaskImageCtrl::DrawPolygon(), operator=(), and operator==().
int HuginBase::MaskPolygon::getTotalWindingNumber | ( | ) | const |
returns the total winding number of the polygon
Definition at line 84 of file Mask.cpp.
References addPoint(), getWindingNumber(), and m_polygon.
Referenced by HuginBase::Panorama::transferMask().
int HuginBase::MaskPolygon::getWindingNumber | ( | const hugin_utils::FDiff2D | p | ) | const |
returns the winding number of the polygon around point p
Definition at line 53 of file Mask.cpp.
References m_polygon, hugin_utils::TDiff2D< T >::x, and hugin_utils::TDiff2D< T >::y.
Referenced by getTotalWindingNumber(), and isInside().
void HuginBase::MaskPolygon::insertPoint | ( | const unsigned int | index, |
const hugin_utils::FDiff2D | p | ||
) |
insert point at the position index into the polygon
Definition at line 115 of file Mask.cpp.
References calcBoundingBox(), and m_polygon.
Referenced by MaskImageCtrl::OnLeftMouseDown().
bool HuginBase::MaskPolygon::isInside | ( | const hugin_utils::FDiff2D | p | ) | const |
checks if given point is inside of the stored polygon
Definition at line 40 of file Mask.cpp.
References getWindingNumber(), m_boundingBox, m_invert, m_polygon, hugin_utils::TDiff2D< T >::x, and hugin_utils::TDiff2D< T >::y.
Referenced by MaskImageCtrl::OnRightMouseDown().
|
inline |
bool HuginBase::MaskPolygon::isPositive | ( | ) | const |
returns true, if mask type is positive
Definition at line 97 of file Mask.cpp.
References m_maskType, Mask_positive, and Mask_Stack_positive.
Referenced by HuginBase::Panorama::transferMask().
void HuginBase::MaskPolygon::movePointBy | ( | const unsigned int | index, |
const hugin_utils::FDiff2D | diff | ||
) |
relativ moves the point at position index by diff
Definition at line 144 of file Mask.cpp.
References calcBoundingBox(), m_polygon, hugin_utils::TDiff2D< T >::x, and hugin_utils::TDiff2D< T >::y.
Referenced by MaskImageCtrl::OnMouseMove().
void HuginBase::MaskPolygon::movePointTo | ( | const unsigned int | index, |
const hugin_utils::FDiff2D | p | ||
) |
moves the point at position index to the new absolute position p
Definition at line 134 of file Mask.cpp.
References calcBoundingBox(), m_polygon, hugin_utils::TDiff2D< T >::x, and hugin_utils::TDiff2D< T >::y.
Referenced by MaskImageCtrl::OnLeftMouseUp(), MaskImageCtrl::OnMouseMove(), and MaskImageCtrl::OnRightMouseUp().
MaskPolygon & HuginBase::MaskPolygon::operator= | ( | const MaskPolygon & | otherPoly | ) |
assign operator
Definition at line 588 of file Mask.cpp.
References getImgNr(), getMaskPolygon(), getMaskType(), isInverted(), setImgNr(), setInverted(), setMaskPolygon(), and setMaskType().
const bool HuginBase::MaskPolygon::operator== | ( | const MaskPolygon & | otherPoly | ) | const |
comparision operator
Definition at line 599 of file Mask.cpp.
References getMaskPolygon(), getMaskType(), m_maskType, and m_polygon.
bool HuginBase::MaskPolygon::parsePolygonString | ( | const std::string & | polygonStr | ) |
parses the x and y positions from the given string
Definition at line 604 of file Mask.cpp.
References calcBoundingBox(), and m_polygon.
Referenced by HuginBase::LoadMaskFromStream().
void HuginBase::MaskPolygon::printPolygonLine | ( | std::ostream & | o, |
const unsigned int | newImgNr | ||
) | const |
writes the complete k line which describes the mask to the stream, using the given newImgNr for the i parameter
Definition at line 626 of file Mask.cpp.
References m_maskType, and m_polygon.
Referenced by HuginBase::SaveMaskToStream().
void HuginBase::MaskPolygon::removePoint | ( | const unsigned int | index | ) |
removes point at the position index from the polygon
Definition at line 125 of file Mask.cpp.
References calcBoundingBox(), and m_polygon.
Referenced by MaskImageCtrl::OnKeyUp(), MaskImageCtrl::OnLeftMouseDblClick(), and MaskImageCtrl::OnRightMouseUp().
void HuginBase::MaskPolygon::rotate90 | ( | bool | clockwise, |
unsigned int | maskWidth, | ||
unsigned int | maskHeight | ||
) |
rotate the polygon by 90 degrees
Definition at line 539 of file Mask.cpp.
References calcBoundingBox(), m_polygon, hugin_utils::TDiff2D< T >::x, and hugin_utils::TDiff2D< T >::y.
void HuginBase::MaskPolygon::scale | ( | const double | factorx, |
const double | factory | ||
) |
scales all polygon coordinates by factorx for x position and factory for y position
Definition at line 154 of file Mask.cpp.
References calcBoundingBox(), and m_polygon.
|
inline |
|
inline |
sets the associated image number, only used when loading a project, otherwise discarded
Definition at line 87 of file Mask.h.
Referenced by HuginBase::LoadMaskFromStream(), operator=(), and HuginBase::Panorama::transferMask().
|
inline |
set mask to normal or inverted
Definition at line 89 of file Mask.h.
Referenced by operator=(), and HuginBase::Panorama::transferMask().
void HuginBase::MaskPolygon::setMaskPolygon | ( | const VectorPolygon & | newMask | ) |
set complete vector with all corrdinates of the polygon
Definition at line 103 of file Mask.cpp.
References calcBoundingBox(), and m_polygon.
Referenced by operator=().
|
inline |
sets mask type
Definition at line 77 of file Mask.h.
Referenced by HuginBase::LoadMaskFromStream(), operator=(), and HuginBase::Panorama::transferMask().
void HuginBase::MaskPolygon::subSample | ( | const double | max_distance | ) |
subsamples the polygon, so that the longest distance between 2 points is max_distance
Definition at line 179 of file Mask.cpp.
References addPoint(), m_polygon, and hugin_utils::norm().
Referenced by HuginBase::Panorama::transferMask().
void HuginBase::MaskPolygon::transformPolygon | ( | const PTools::Transform & | trans | ) |
transforms the polygon coordinates by the given transformation
Definition at line 164 of file Mask.cpp.
References calcBoundingBox(), m_polygon, and HuginBase::PTools::Transform::transformImgCoord().
Referenced by HuginBase::Panorama::transferMask().
|
private |
Definition at line 144 of file Mask.h.
Referenced by calcBoundingBox(), and isInside().
|
private |
Definition at line 143 of file Mask.h.
Referenced by isInside().
|
private |
Definition at line 140 of file Mask.h.
Referenced by isPositive(), operator==(), and printPolygonLine().
|
private |
Definition at line 141 of file Mask.h.
Referenced by addPoint(), calcBoundingBox(), clipPolygon(), FindPointNearPos(), getTotalWindingNumber(), getWindingNumber(), insertPoint(), isInside(), movePointBy(), movePointTo(), operator==(), parsePolygonString(), printPolygonLine(), removePoint(), rotate90(), scale(), setMaskPolygon(), subSample(), and transformPolygon().