Hugintrunk  0.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Types | Public Member Functions | Private Member Functions | Private Attributes | List of all members
HuginBase::MaskPolygon Class Reference

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...
 
MaskPolygonoperator= (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
 

Detailed Description

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

Definition at line 52 of file Mask.h.

Member Enumeration Documentation

enumeration with type of possible masks

Enumerator
Mask_negative 
Mask_positive 
Mask_Stack_negative 
Mask_Stack_positive 
Mask_negative_lens 

Definition at line 56 of file Mask.h.

Constructor & Destructor Documentation

HuginBase::MaskPolygon::MaskPolygon ( )
inline

constructor

Definition at line 65 of file Mask.h.

Member Function Documentation

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().

void HuginBase::MaskPolygon::calcBoundingBox ( )
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().

unsigned int HuginBase::MaskPolygon::getImgNr ( ) const
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=().

VectorPolygon HuginBase::MaskPolygon::getMaskPolygon ( ) const
inline
MaskType HuginBase::MaskPolygon::getMaskType ( ) const
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().

bool HuginBase::MaskPolygon::isInverted ( ) const
inline

returns if mask is inverted

Definition at line 91 of file Mask.h.

Referenced by operator=().

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.

void HuginBase::MaskPolygon::scale ( const double  factor)
inline

scales x and y axis equally by factor

Definition at line 107 of file Mask.h.

References scale().

Referenced by scale().

void HuginBase::MaskPolygon::setImgNr ( const unsigned int  newImgNr)
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().

void HuginBase::MaskPolygon::setInverted ( const bool  inverted)
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=().

void HuginBase::MaskPolygon::setMaskType ( const MaskType  newType)
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().

Member Data Documentation

vigra::Rect2D HuginBase::MaskPolygon::m_boundingBox
private

Definition at line 144 of file Mask.h.

Referenced by calcBoundingBox(), and isInside().

unsigned int HuginBase::MaskPolygon::m_imgNr
private

Definition at line 142 of file Mask.h.

bool HuginBase::MaskPolygon::m_invert
private

Definition at line 143 of file Mask.h.

Referenced by isInside().

MaskType HuginBase::MaskPolygon::m_maskType
private

Definition at line 140 of file Mask.h.

Referenced by isPositive(), operator==(), and printPolygonLine().

VectorPolygon HuginBase::MaskPolygon::m_polygon
private

The documentation for this class was generated from the following files: