Hugin trunk 0.1
Loading...
Searching...
No Matches
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
 
bool isInside (const hugin_utils::FDiff2D p) const
 checks if given point is inside of the stored polygon
 
int getWindingNumber (const hugin_utils::FDiff2D p) const
 returns the winding number of the polygon around point p
 
int getTotalWindingNumber () const
 returns the total winding number of the polygon
 
MaskType getMaskType () const
 returns mask type
 
void setMaskType (const MaskType newType)
 sets mask type
 
bool isPositive () const
 returns true, if mask type is positive
 
VectorPolygon getMaskPolygon () const
 returns vector with coordinates of the polygon
 
void setMaskPolygon (const VectorPolygon &newMask)
 set complete vector with all corrdinates of the polygon
 
unsigned int getImgNr () const
 returns the associated image number, only used when loading a project, otherwise discarded
 
void setImgNr (const unsigned int newImgNr)
 sets the associated image number, only used when loading a project, otherwise discarded
 
void setInverted (const bool inverted)
 set mask to normal or inverted
 
bool isInverted () const
 returns if mask is inverted
 
void addPoint (const hugin_utils::FDiff2D p)
 adds point at the end to the polygon
 
void insertPoint (const unsigned int index, const hugin_utils::FDiff2D p)
 insert point at the position index into the polygon
 
void removePoint (const unsigned int index)
 removes point at the position index from the polygon
 
void movePointTo (const unsigned int index, const hugin_utils::FDiff2D p)
 moves the point at position index to the new absolute position p
 
void movePointBy (const unsigned int index, const hugin_utils::FDiff2D diff)
 relativ moves the point at position index by diff
 
void scale (const double factorx, const double factory)
 scales all polygon coordinates by factorx for x position and factory for y position
 
void scale (const double factor)
 scales x and y axis equally by factor
 
void scale (const double factor, const hugin_utils::FDiff2D &p)
 scale x and y axis equally around the given point
 
void transformPolygon (const PTools::Transform &trans)
 transforms the polygon coordinates by the given transformation
 
bool clipPolygon (const vigra::Rect2D rect)
 clips the polygon to the given rectangle
 
bool clipPolygon (const hugin_utils::FDiff2D center, const double radius)
 clips the polygon to the circle with center and radius
 
void rotate90 (bool clockwise, unsigned int maskWidth, unsigned int maskHeight)
 rotate the polygon by 90 degrees
 
void subSample (const double max_distance)
 subsamples the polygon, so that the longest distance between 2 points is max_distance
 
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
 
MaskPolygonoperator= (const MaskPolygon &otherPoly)
 assign operator
 
const bool operator== (const MaskPolygon &otherPoly) const
 comparision operator
 
bool parsePolygonString (const std::string &polygonStr)
 parses the x and y positions from the given string
 
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
 
hugin_utils::FDiff2D getCenter () const
 return the center point of the polygon
 

Private Member Functions

void calcBoundingBox ()
 calculates the bounding box of the polygon to speed up tests
 

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

◆ MaskType

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

◆ MaskPolygon()

HuginBase::MaskPolygon::MaskPolygon ( )
inline

constructor

Definition at line 65 of file Mask.h.

Member Function Documentation

◆ addPoint()

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

◆ calcBoundingBox()

void HuginBase::MaskPolygon::calcBoundingBox ( )
private

calculates the bounding box of the polygon to speed up tests

Definition at line 212 of file Mask.cpp.

References m_boundingBox, m_polygon, and threshold().

Referenced by addPoint(), clipPolygon(), clipPolygon(), insertPoint(), movePointBy(), movePointTo(), parsePolygonString(), removePoint(), rotate90(), scale(), scale(), setMaskPolygon(), and transformPolygon().

◆ clipPolygon() [1/2]

bool HuginBase::MaskPolygon::clipPolygon ( const hugin_utils::FDiff2D  center,
const double  radius 
)

◆ clipPolygon() [2/2]

bool HuginBase::MaskPolygon::clipPolygon ( const vigra::Rect2D  rect)

clips the polygon to the given rectangle

Definition at line 330 of file Mask.cpp.

References calcBoundingBox(), HuginBase::clip_onPlane(), HuginBase::clipBottom, HuginBase::clipLeft, HuginBase::clipRight, HuginBase::clipTop, m_polygon, and threshold().

◆ FindPointNearPos()

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 564 of file Mask.cpp.

References m_polygon, hugin_utils::sqr(), threshold(), hugin_utils::TDiff2D< T >::x, and hugin_utils::TDiff2D< T >::y.

Referenced by MaskImageCtrl::OnLeftMouseDown().

◆ getCenter()

hugin_utils::FDiff2D HuginBase::MaskPolygon::getCenter ( ) const

return the center point of the polygon

Definition at line 645 of file Mask.cpp.

References m_polygon, and threshold().

Referenced by MaskImageCtrl::OnMouseWheel().

◆ getImgNr()

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.

◆ getMaskPolygon()

VectorPolygon HuginBase::MaskPolygon::getMaskPolygon ( ) const
inline

◆ getMaskType()

MaskType HuginBase::MaskPolygon::getMaskType ( ) const
inline

returns mask type

Definition at line 75 of file Mask.h.

◆ getTotalWindingNumber()

int HuginBase::MaskPolygon::getTotalWindingNumber ( ) const

returns the total winding number of the polygon

Definition at line 84 of file Mask.cpp.

References addPoint(), m_polygon, and threshold().

◆ getWindingNumber()

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, threshold(), hugin_utils::TDiff2D< T >::x, and hugin_utils::TDiff2D< T >::y.

Referenced by isInside().

◆ insertPoint()

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

◆ isInside()

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, threshold(), hugin_utils::TDiff2D< T >::x, and hugin_utils::TDiff2D< T >::y.

Referenced by MaskImageCtrl::OnMouseWheel(), and MaskImageCtrl::OnRightMouseDown().

◆ isInverted()

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

returns if mask is inverted

Definition at line 91 of file Mask.h.

◆ isPositive()

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

◆ movePointBy()

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 142 of file Mask.cpp.

References calcBoundingBox(), m_polygon, and threshold().

Referenced by MaskImageCtrl::OnMouseMove().

◆ movePointTo()

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 133 of file Mask.cpp.

References calcBoundingBox(), and m_polygon.

Referenced by MaskImageCtrl::OnLeftMouseUp(), MaskImageCtrl::OnMouseMove(), and MaskImageCtrl::OnRightMouseUp().

◆ operator=()

MaskPolygon & HuginBase::MaskPolygon::operator= ( const MaskPolygon otherPoly)

assign operator

Definition at line 593 of file Mask.cpp.

References setImgNr(), setInverted(), setMaskPolygon(), setMaskType(), and threshold().

◆ operator==()

const bool HuginBase::MaskPolygon::operator== ( const MaskPolygon otherPoly) const

comparision operator

Definition at line 604 of file Mask.cpp.

References m_maskType, m_polygon, and threshold().

◆ parsePolygonString()

bool HuginBase::MaskPolygon::parsePolygonString ( const std::string &  polygonStr)

parses the x and y positions from the given string

Definition at line 609 of file Mask.cpp.

References calcBoundingBox(), m_polygon, and threshold().

◆ printPolygonLine()

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 631 of file Mask.cpp.

References m_maskType, m_polygon, and threshold().

◆ removePoint()

void HuginBase::MaskPolygon::removePoint ( const unsigned int  index)

removes point at the position index from the polygon

Definition at line 124 of file Mask.cpp.

References calcBoundingBox(), and m_polygon.

Referenced by MaskImageCtrl::OnKeyUp(), MaskImageCtrl::OnLeftMouseDblClick(), and MaskImageCtrl::OnRightMouseUp().

◆ rotate90()

void HuginBase::MaskPolygon::rotate90 ( bool  clockwise,
unsigned int  maskWidth,
unsigned int  maskHeight 
)

rotate the polygon by 90 degrees

Definition at line 544 of file Mask.cpp.

References calcBoundingBox(), m_polygon, threshold(), hugin_utils::TDiff2D< T >::x, and hugin_utils::TDiff2D< T >::y.

◆ scale() [1/3]

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

◆ scale() [2/3]

void HuginBase::MaskPolygon::scale ( const double  factor,
const hugin_utils::FDiff2D p 
)

scale x and y axis equally around the given point

Definition at line 161 of file Mask.cpp.

References calcBoundingBox(), m_polygon, and threshold().

◆ scale() [3/3]

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 151 of file Mask.cpp.

References calcBoundingBox(), m_polygon, and threshold().

Referenced by MaskImageCtrl::OnMouseWheel().

◆ setImgNr()

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.

References threshold().

Referenced by HuginBase::LoadMaskFromStream(), HuginBase::PanoramaMemento::loadPTScript(), and operator=().

◆ setInverted()

void HuginBase::MaskPolygon::setInverted ( const bool  inverted)
inline

set mask to normal or inverted

Definition at line 89 of file Mask.h.

References threshold().

Referenced by operator=().

◆ setMaskPolygon()

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(), m_polygon, and threshold().

Referenced by operator=().

◆ setMaskType()

void HuginBase::MaskPolygon::setMaskType ( const MaskType  newType)
inline

sets mask type

Definition at line 77 of file Mask.h.

References threshold().

Referenced by operator=().

◆ subSample()

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 185 of file Mask.cpp.

References addPoint(), m_polygon, and threshold().

◆ transformPolygon()

void HuginBase::MaskPolygon::transformPolygon ( const PTools::Transform trans)

transforms the polygon coordinates by the given transformation

Definition at line 170 of file Mask.cpp.

References calcBoundingBox(), m_polygon, and threshold().

Member Data Documentation

◆ m_boundingBox

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

Definition at line 147 of file Mask.h.

Referenced by calcBoundingBox(), and isInside().

◆ m_imgNr

unsigned int HuginBase::MaskPolygon::m_imgNr
private

Definition at line 145 of file Mask.h.

◆ m_invert

bool HuginBase::MaskPolygon::m_invert
private

Definition at line 146 of file Mask.h.

Referenced by isInside().

◆ m_maskType

MaskType HuginBase::MaskPolygon::m_maskType
private

Definition at line 143 of file Mask.h.

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

◆ m_polygon

VectorPolygon HuginBase::MaskPolygon::m_polygon
private

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