ICF 3.0.5.47
Technical documentation of ICF Libraries
iimg::CScanlineMask Class Reference

Representation of a 2D-region as container of bitmap line scans. More...

#include <CScanlineMask.h>

Inheritance diagram for iimg::CScanlineMask:
Collaboration diagram for iimg::CScanlineMask:

Public Types

typedef i2d::CObject2dBase BaseClass
 
typedef QList< istd::CIntRangesRangesContainer
 
typedef std::vector< int > Scanlines
 
- Public Types inherited from i2d::IObject2d
enum  ChangeFlags { CF_OBJECT_POSITION = 0x6ba340 }
 
- Public Types inherited from istd::IChangeable
enum  ChangeFlags {
  CF_ICF_INTERNAL = 0 , CF_ALL_DATA , CF_ANY , CF_DESTROYING ,
  CF_DELEGATED , CF_NO_UNDO
}
 Data model change notification flags. More...
 
enum  SupportedOperations {
  SO_NONE = 0 , SO_OBSERVE = 1 << 0 , SO_COPY = 1 << 1 , SO_CLONE = 1 << 2 ,
  SO_COMPARE = 1 << 3 , SO_RESET = 1 << 4 , SO_CHANGE_LOCK = 1 << 5
}
 Flags for supported operations. More...
 
enum  CompatibilityMode { CM_STRICT , CM_WITHOUT_REFS , CM_WITH_REFS , CM_CONVERT }
 Control how relationship betweeen objects are interpreted. More...
 

Public Member Functions

 CScanlineMask ()
 
bool IsBitmapRegionEmpty () const
 Check if region is empty.
 
i2d::CRect GetBoundingRect () const
 Get rectangle containing all active pixels.
 
void ResetScanlines (const istd::CIntRange &verticalRange)
 Set this mask to empty set for some vertical range.
 
const istd::CIntRangesGetPixelRanges (int lineIndex) const
 Get the list of pixel ranges per given line.
 
void CreateFilled (const i2d::CRect &clipArea)
 Create filled 2D-region clipped to rectangle area.
 
bool CreateFromGeometry (const i2d::IObject2d &geometry, const i2d::CRect *clipAreaPtr=nullptr)
 Create 2D-region from some geometrical object.
 
void CreateFromCircle (const i2d::CCircle &circle, const i2d::CRect *clipAreaPtr=nullptr)
 Create 2D-region from circle.
 
void CreateFromRectangle (const i2d::CRectangle &rect, const i2d::CRect *clipAreaPtr=nullptr)
 Create 2D-region from rectangle.
 
void CreateFromAnnulus (const i2d::CAnnulus &annulus, const i2d::CRect *clipAreaPtr=nullptr)
 Create 2D-region from annulus.
 
void CreateFromPolygon (const i2d::CPolygon &polygon, const i2d::CRect *clipAreaPtr=nullptr)
 Create 2D-region from polygon.
 
void CreateFromTube (const i2d::CTubePolyline &tube, const i2d::CRect *clipAreaPtr=nullptr)
 Create 2D-region from tube.
 
void CreateFromBitmap (const iimg::IBitmap &bitmap, const i2d::CRect *clipAreaPtr=nullptr)
 Create 2D-region from a bitmap.
 
void GetInverted (const i2d::CRect &clipArea, CScanlineMask &result) const
 Get inverted mask.
 
void Invert (const i2d::CRect &clipArea)
 Invert mask on place.
 
CScanlineMask GetUnion (const CScanlineMask &mask) const
 Get union of two masks.
 
void GetUnion (const CScanlineMask &mask, CScanlineMask &result) const
 Get union of two masks.
 
void Union (const CScanlineMask &mask)
 Calculate union of this mask and the other one.
 
CScanlineMask GetIntersection (const CScanlineMask &mask) const
 Get intersection of two masks.
 
void GetIntersection (const CScanlineMask &mask, CScanlineMask &result) const
 Get intersection of two masks.
 
void Intersection (const CScanlineMask &mask)
 Calculate intersection of this mask and the other one.
 
CScanlineMask GetTranslated (int dx, int dy) const
 Calculate translated (moved) mask.
 
void GetTranslated (int dx, int dy, CScanlineMask &result) const
 Calculate translated (moved) mask.
 
void Translate (int dx, int dy)
 Translated (move) this mask.
 
void Erode (int leftValue, int rightValue, int topValue, int bottomValue)
 Calculate erosion of this range list with rectangle structured element.
 
void Dilate (int leftValue, int rightValue, int topValue, int bottomValue)
 Calculate dilatation of this range list with rectangle structured element.
 
i2d::CVector2d GetCenter () const override
 Returns center of this 2D-object.
 
void MoveCenterTo (const i2d::CVector2d &position) override
 Move object to position position.
 
i2d::CRectangle GetBoundingBox () const override
 Get bounding box of this shape.
 
bool IsEmpty () const override
 Return true if this image is empty.
 
void ResetImage () override
 Reset this image.
 
void ClearImage () override
 Cleat this image.
 
istd::CIndex2d GetImageSize () const override
 Get size of this raster image.
 
int GetComponentsCount () const override
 Get number of color components.
 
icmm::CVarColor GetColorAt (const istd::CIndex2d &position) const override
 Get color at specified pixel.
 
bool SetColorAt (const istd::CIndex2d &position, const icmm::CVarColor &color) override
 Set color at specified pixel.
 
bool Serialize (iser::IArchive &archive) override
 Load or store state of this object as a archive stream.
 
int GetSupportedOperations () const override
 Get set of flags for supported operations.
 
bool CopyFrom (const istd::IChangeable &object, CompatibilityMode mode=CM_WITHOUT_REFS) override
 Copy this object from another one.
 
bool ResetData (CompatibilityMode mode=CM_WITHOUT_REFS) override
 Reset data to its default state.
 
bool operator== (const CScanlineMask &mask) const
 
bool operator!= (const CScanlineMask &mask) const
 
- Public Member Functions inherited from i2d::CObject2dBase
 CObject2dBase ()
 
 CObject2dBase (const CObject2dBase &object2d)
 
 CObject2dBase (CObject2dBase &&object2d)
 
const ICalibration2dGetCalibration () const override
 Get access to transformation object, which transforms a local logical coordinate system to global one.
 
void SetCalibration (istd::TOptDelPtr< const ICalibration2d > &&calibrationPtr) override
 Set calibration of this object.
 
bool Transform (const ITransformation2d &transformation, ITransformation2d::ExactnessMode mode=ITransformation2d::EM_NONE, double *errorFactorPtr=nullptr) override
 Transform this object using some transformation.
 
bool InvTransform (const ITransformation2d &transformation, ITransformation2d::ExactnessMode mode=ITransformation2d::EM_NONE, double *errorFactorPtr=nullptr) override
 Do inverse transformation of this object.
 
bool GetTransformed (const ITransformation2d &transformation, IObject2d &result, ITransformation2d::ExactnessMode mode=ITransformation2d::EM_NONE, double *errorFactorPtr=nullptr) const override
 Calulate transformation of the object into second one.
 
bool GetInvTransformed (const ITransformation2d &transformation, IObject2d &result, ITransformation2d::ExactnessMode mode=ITransformation2d::EM_NONE, double *errorFactorPtr=nullptr) const override
 Calulate inverse transformation of the object into second one.
 
CObject2dBaseoperator= (const CObject2dBase &object2d)
 
CObject2dBaseoperator= (CObject2dBase &&object2d)
 
- Public Member Functions inherited from i2d::IObject2d
- Public Member Functions inherited from iser::IObject
virtual QByteArray GetFactoryId () const
 
- Public Member Functions inherited from iser::ISerializable
virtual quint32 GetMinimalVersion (int versionId) const
 Get minimal needed version to correct storing of this data.
 
- Public Member Functions inherited from istd::IChangeable
virtual bool IsEqual (const IChangeable &object) const
 Compare this object with another object.
 
virtual std::unique_ptr< IChangeableCloneMe (CompatibilityMode mode=CM_WITHOUT_REFS) const
 Make a copy of this object.
 
virtual QMutex * GetChangesLock () const
 Get mutex beeing locked during changes, if available.
 
virtual void BeginChanges (const ChangeSet &changeSet)
 Starts the change transaction.
 
virtual void EndChanges (const ChangeSet &changeSet)
 Ends the change transaction.
 
virtual void BeginChangeGroup (const ChangeSet &changeSet)
 Starts group of changes.
 
virtual void EndChangeGroup (const ChangeSet &changeSet)
 Ends group of changes.
 
- Public Member Functions inherited from i2d::ICalibration2dProvider
- Public Member Functions inherited from iimg::IRasterImage

Protected Member Functions

void EnsureBoundingBoxValid () const
 
void CalcBoundingBox () const
 
void InitFromBoundingBox (const i2d::CRectangle &objectBoundingBox, const i2d::CRect *clipAreaPtr)
 
template<typename PixelType >
void CalculateMaskFromBitmap (const iimg::IBitmap &bitmap, const i2d::CRect *clipAreaPtr=nullptr)
 
- Protected Member Functions inherited from istd::IChangeable
virtual void OnBeginChanges ()
 Callback function for begin change event.
 
virtual void OnEndChanges (const ChangeSet &changeSet)
 Callback function for end change event.
 

Additional Inherited Members

- Static Public Member Functions inherited from istd::IChangeable
static const ChangeSetGetNoChanges ()
 Get empty set of changes.
 
static const ChangeSetGetAnyChange ()
 Get anonymous change set.
 
static const ChangeSetGetAllChanges ()
 Get anonymous change set.
 
static const ChangeSetGetDelegatedChanges ()
 Get delegated change set.
 
- Static Protected Attributes inherited from i2d::CObject2dBase
static const ChangeSet s_objectMovedChange
 
static const ChangeSet s_objectModifiedChange
 

Detailed Description

Representation of a 2D-region as container of bitmap line scans.

Definition at line 34 of file CScanlineMask.h.

Member Typedef Documentation

◆ BaseClass

◆ RangesContainer

◆ Scanlines

Definition at line 41 of file CScanlineMask.h.

Constructor & Destructor Documentation

◆ CScanlineMask()

iimg::CScanlineMask::CScanlineMask ( )

Member Function Documentation

◆ CalcBoundingBox()

void iimg::CScanlineMask::CalcBoundingBox ( ) const
protected

Referenced by EnsureBoundingBoxValid().

◆ CalculateMaskFromBitmap()

◆ ClearImage()

void iimg::CScanlineMask::ClearImage ( )
overridevirtual

Cleat this image.

After this operation all the image pixels will be set to the default value (black by default).

Implements iimg::IRasterImage.

◆ CopyFrom()

bool iimg::CScanlineMask::CopyFrom ( const istd::IChangeable & object,
CompatibilityMode mode = CM_WITHOUT_REFS )
overridevirtual

Copy this object from another one.

Default implementation in istd::IChangeable does nothing. You may check, if this functionality is supported over GetSupportedOperations().

Reimplemented from i2d::CObject2dBase.

◆ CreateFilled()

void iimg::CScanlineMask::CreateFilled ( const i2d::CRect & clipArea)

Create filled 2D-region clipped to rectangle area.

Parameters
clipAreaclipping area.

◆ CreateFromAnnulus()

void iimg::CScanlineMask::CreateFromAnnulus ( const i2d::CAnnulus & annulus,
const i2d::CRect * clipAreaPtr = nullptr )

Create 2D-region from annulus.

Parameters
annulusannulus object.
clipAreaPtroptional clipping area.

◆ CreateFromBitmap()

void iimg::CScanlineMask::CreateFromBitmap ( const iimg::IBitmap & bitmap,
const i2d::CRect * clipAreaPtr = nullptr )

Create 2D-region from a bitmap.

Parameters
bitmapMask bitmap. Non-zero pixels of the image represent the object in the resulting mask.
clipAreaPtroptional clipping area.

◆ CreateFromCircle()

void iimg::CScanlineMask::CreateFromCircle ( const i2d::CCircle & circle,
const i2d::CRect * clipAreaPtr = nullptr )

Create 2D-region from circle.

Parameters
circlecircle object.
clipAreaPtroptional clipping area.

◆ CreateFromGeometry()

bool iimg::CScanlineMask::CreateFromGeometry ( const i2d::IObject2d & geometry,
const i2d::CRect * clipAreaPtr = nullptr )

Create 2D-region from some geometrical object.

Parameters
geometrysome geometrical object.
clipAreaPtroptional clipping area.

◆ CreateFromPolygon()

void iimg::CScanlineMask::CreateFromPolygon ( const i2d::CPolygon & polygon,
const i2d::CRect * clipAreaPtr = nullptr )

Create 2D-region from polygon.

Parameters
polygonpolygon object.
clipAreaPtroptional clipping area.

◆ CreateFromRectangle()

void iimg::CScanlineMask::CreateFromRectangle ( const i2d::CRectangle & rect,
const i2d::CRect * clipAreaPtr = nullptr )

Create 2D-region from rectangle.

Parameters
rectrectangle object.
clipAreaPtroptional clipping area.

◆ CreateFromTube()

void iimg::CScanlineMask::CreateFromTube ( const i2d::CTubePolyline & tube,
const i2d::CRect * clipAreaPtr = nullptr )

Create 2D-region from tube.

Parameters
tubetube object.
clipAreaPtroptional clipping area.

◆ Dilate()

void iimg::CScanlineMask::Dilate ( int leftValue,
int rightValue,
int topValue,
int bottomValue )

Calculate dilatation of this range list with rectangle structured element.

Result is stored in this object.

◆ EnsureBoundingBoxValid()

void iimg::CScanlineMask::EnsureBoundingBoxValid ( ) const
inlineprotected

Definition at line 253 of file CScanlineMask.h.

References CalcBoundingBox().

◆ Erode()

void iimg::CScanlineMask::Erode ( int leftValue,
int rightValue,
int topValue,
int bottomValue )

Calculate erosion of this range list with rectangle structured element.

Result is stored in this object.

◆ GetBoundingBox()

i2d::CRectangle iimg::CScanlineMask::GetBoundingBox ( ) const
overridevirtual

Get bounding box of this shape.

Please note, this bounding box is in logical units, the calibration will not be considered.

Implements i2d::IObject2d.

◆ GetBoundingRect()

i2d::CRect iimg::CScanlineMask::GetBoundingRect ( ) const

Get rectangle containing all active pixels.

If this mask is infinite, it returns i2d::CRect::GetInvalid() rectangle. Agains the method GetBoundingBox() from i2d::IObject2d it returns integer rectangle.

◆ GetCenter()

i2d::CVector2d iimg::CScanlineMask::GetCenter ( ) const
overridevirtual

Returns center of this 2D-object.

Implements i2d::IObject2d.

◆ GetColorAt()

icmm::CVarColor iimg::CScanlineMask::GetColorAt ( const istd::CIndex2d & position) const
overridevirtual

Get color at specified pixel.

Parameters
positionpixel position, must be inside of returned size.

Implements iimg::IRasterImage.

◆ GetComponentsCount()

int iimg::CScanlineMask::GetComponentsCount ( ) const
overridevirtual

Get number of color components.

Implements iimg::IRasterImage.

◆ GetImageSize()

istd::CIndex2d iimg::CScanlineMask::GetImageSize ( ) const
overridevirtual

Get size of this raster image.

Implements iimg::IRasterImage.

◆ GetIntersection() [1/2]

CScanlineMask iimg::CScanlineMask::GetIntersection ( const CScanlineMask & mask) const

Get intersection of two masks.

◆ GetIntersection() [2/2]

void iimg::CScanlineMask::GetIntersection ( const CScanlineMask & mask,
CScanlineMask & result ) const

Get intersection of two masks.

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ GetInverted()

void iimg::CScanlineMask::GetInverted ( const i2d::CRect & clipArea,
CScanlineMask & result ) const

Get inverted mask.

Parameters
clipAreaclipping area.
resultresult object, will be filled with inverted mask.

◆ GetPixelRanges()

const istd::CIntRanges * iimg::CScanlineMask::GetPixelRanges ( int lineIndex) const

Get the list of pixel ranges per given line.

◆ GetSupportedOperations()

int iimg::CScanlineMask::GetSupportedOperations ( ) const
overridevirtual

Get set of flags for supported operations.

See also
SupportedOperations

Reimplemented from istd::IChangeable.

◆ GetTranslated() [1/2]

CScanlineMask iimg::CScanlineMask::GetTranslated ( int dx,
int dy ) const

Calculate translated (moved) mask.

◆ GetTranslated() [2/2]

void iimg::CScanlineMask::GetTranslated ( int dx,
int dy,
CScanlineMask & result ) const

Calculate translated (moved) mask.

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ GetUnion() [1/2]

CScanlineMask iimg::CScanlineMask::GetUnion ( const CScanlineMask & mask) const

Get union of two masks.

◆ GetUnion() [2/2]

void iimg::CScanlineMask::GetUnion ( const CScanlineMask & mask,
CScanlineMask & result ) const

Get union of two masks.

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ InitFromBoundingBox()

void iimg::CScanlineMask::InitFromBoundingBox ( const i2d::CRectangle & objectBoundingBox,
const i2d::CRect * clipAreaPtr )
protected

Referenced by CalculateMaskFromBitmap().

◆ Intersection()

void iimg::CScanlineMask::Intersection ( const CScanlineMask & mask)

Calculate intersection of this mask and the other one.

Result is stored in this object.

◆ Invert()

void iimg::CScanlineMask::Invert ( const i2d::CRect & clipArea)

Invert mask on place.

Parameters
clipAreaclipping area.

◆ IsBitmapRegionEmpty()

bool iimg::CScanlineMask::IsBitmapRegionEmpty ( ) const

Check if region is empty.

◆ IsEmpty()

bool iimg::CScanlineMask::IsEmpty ( ) const
overridevirtual

Return true if this image is empty.

Implements iimg::IRasterImage.

◆ MoveCenterTo()

void iimg::CScanlineMask::MoveCenterTo ( const i2d::CVector2d & position)
overridevirtual

Move object to position position.

Implements i2d::IObject2d.

◆ operator!=()

bool iimg::CScanlineMask::operator!= ( const CScanlineMask & mask) const
inline

Definition at line 245 of file CScanlineMask.h.

References operator==().

◆ operator==()

bool iimg::CScanlineMask::operator== ( const CScanlineMask & mask) const

Referenced by operator!=().

◆ ResetData()

bool iimg::CScanlineMask::ResetData ( CompatibilityMode mode = CM_WITHOUT_REFS)
overridevirtual

Reset data to its default state.

Default implementation in istd::IChangeable does nothing. You may check, if this functionality is supported over GetSupportedOperations().

Returns
true if the operation was successful, and false otherwise.

Reimplemented from i2d::CObject2dBase.

◆ ResetImage()

void iimg::CScanlineMask::ResetImage ( )
overridevirtual

Reset this image.

After this operation image is set to initial state.

Implements iimg::IRasterImage.

Referenced by CalculateMaskFromBitmap().

◆ ResetScanlines()

void iimg::CScanlineMask::ResetScanlines ( const istd::CIntRange & verticalRange)

Set this mask to empty set for some vertical range.

◆ Serialize()

bool iimg::CScanlineMask::Serialize ( iser::IArchive & archive)
overridevirtual

Load or store state of this object as a archive stream.

Type of operation is depending on archive type.

See also
iser::IArchive

Implements iser::ISerializable.

◆ SetColorAt()

bool iimg::CScanlineMask::SetColorAt ( const istd::CIndex2d & position,
const icmm::CVarColor & color )
overridevirtual

Set color at specified pixel.

Parameters
positionpixel position, must be inside of returned size.
colorcolor of pixel will be set.
Returns
true, if pixel color was changed.

Implements iimg::IRasterImage.

◆ Translate()

void iimg::CScanlineMask::Translate ( int dx,
int dy )

Translated (move) this mask.

◆ Union()

void iimg::CScanlineMask::Union ( const CScanlineMask & mask)

Calculate union of this mask and the other one.

Result is stored in this object.


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

© Witold Gantzke and Kirill Lepskiy