📄 maskvolume.h
字号:
// MaskVolume.h: interface for the RxMaskVolume class.////////////////////////////////////////////////////////////////////////#if !defined(_RX_MASK_VOLUME_H_)#define _RX_MASK_VOLUME_H_#if _MSC_VER > 1000#pragma once#endif // _MSC_VER > 1000class RxMaskVolume {protected: LPBYTE m_pbyMask; LPBYTE m_pbyMinMax2x2; LPBYTE m_pbyMinMax8x8; int m_iMaskSize; int m_iMinMaxSize2x2; int m_iMinMaxSize8x8; int m_iVolX2x2; int m_iVolY2x2; int m_iVolZ2x2; int m_iVolX8x8; int m_iVolY8x8; int m_iVolZ8x8;public: int m_iVolX, m_iVolY, m_iVolZ;public: RxMaskVolume(); virtual ~RxMaskVolume();public: inline void SetMask(const int& iOffset); inline void SetMask(const int& iVolX, const int& iVolY, const int& iVolZ); inline void ClearMask(const int& iOffset); inline void ClearMask(const int& iVolX, const int& iVolY, const int& iVolZ); inline unsigned char GetMask(const int& iOffset); inline unsigned char GetMask(const int& iVolX, const int& iVolY, const int& iVolZ); inline unsigned char GetMinMaxMask2x2(const int& iVolX, const int& iVolY, const int& iVolZ); inline unsigned char GetMinMaxMask8x8(const int& iVolX, const int& iVolY, const int& iVolZ); inline unsigned char * GetMaskPtr(const int & iVolZ); inline unsigned char * GetMaskPtr(const int & iVolZ, const int & iVolY); inline unsigned char * GetMaskPtr() {return m_pbyMask;} inline int GetMaskSizeInByte() {return m_iMaskSize;} inline void ResetMask(BYTE byFill = 0xFF); BOOL CreateMinMax(); BOOL CreateMaskVolume(int iVolX, int iVolY, int iVolZ, char chFill = 0); BOOL CreateNULLMask(int iVolX, int iVolY, int iVolZ); void DestroyMaskVolume(); RxMaskVolume operator = (const RxMaskVolume &maskSrc); void operator |= (const RxMaskVolume &maskSrc); void AssignMaskVolume(unsigned char* pbyNewMaskVol); BOOL CopyMaskVolume(const RxMaskVolume* pmvSrc);protected: inline BOOL SliceMinMax2x2(unsigned char *pMask, unsigned char *pSliceMinMax); inline BOOL SliceMinMax8x8(unsigned char *pMask, unsigned char *pSliceMinMax); BOOL CreateMinMax2x2(); BOOL CreateMinMax8x8();};void RxMaskVolume::ResetMask(BYTE byFill /* = 0xff */){ memset(m_pbyMask, byFill, m_iMaskSize);}inline void RxMaskVolume::SetMask(const int& iOffset){ int iQuotient, iRemainder; iQuotient = iOffset >> 3; iRemainder = iOffset & 0x07; m_pbyMask[iQuotient] = m_pbyMask[iQuotient] | (0x01 << (7 - iRemainder));}inline void RxMaskVolume::SetMask(const int& iVolX, const int& iVolY, const int& iVolZ){ int iQuotient, iRemainder, iOffset; iOffset = m_iVolX * m_iVolY * iVolZ + m_iVolX * iVolY + iVolX; iQuotient = iOffset >> 3; iRemainder = iOffset & 0x07; m_pbyMask[iQuotient] = m_pbyMask[iQuotient] | (0x01 << (7 - iRemainder));}inline void RxMaskVolume::ClearMask(const int& iOffset){ int iQuotient, iRemainder; iQuotient = iOffset >> 3; iRemainder = iOffset & 0x07; m_pbyMask[iQuotient] = m_pbyMask[iQuotient] & (~(0x01 << (7 - iRemainder)));}inline void RxMaskVolume::ClearMask(const int& iVolX, const int& iVolY, const int& iVolZ){ int iQuotient, iRemainder, iOffset; iOffset = m_iVolX * m_iVolY * iVolZ + m_iVolX * iVolY + iVolX; iQuotient = iOffset >> 3; iRemainder = iOffset & 0x07; m_pbyMask[iQuotient] = m_pbyMask[iQuotient] & (~(0x01 << (7 - iRemainder)));}inline unsigned char RxMaskVolume::GetMask(const int& iOffset){ int iQuotient, iRemainder; iQuotient = iOffset >> 3; iRemainder = iOffset & 0x07; return (m_pbyMask[iQuotient] >> (7 - iRemainder)) & 0x01;}inline unsigned char RxMaskVolume::GetMask(const int& iVolX, const int& iVolY, const int& iVolZ){ int iQuotient, iRemainder, iOffset; iOffset = m_iVolX * m_iVolY * iVolZ + m_iVolX * iVolY + iVolX; iQuotient = iOffset >> 3; iRemainder = iOffset & 0x07; return (m_pbyMask[iQuotient] >> (7 - iRemainder)) & 0x01;}inline unsigned char * RxMaskVolume::GetMaskPtr(const int & iVolZ){ int iQuotient, iOffset; iOffset = m_iVolX * m_iVolY * iVolZ; iQuotient = iOffset >> 3; return &(m_pbyMask[iQuotient]);}inline unsigned char * RxMaskVolume::GetMaskPtr(const int & iVolZ, const int & iVolY){ int iQuotient, iOffset; iOffset = m_iVolX * m_iVolY * iVolZ + m_iVolX * iVolY; iQuotient = iOffset >> 3; return &(m_pbyMask[iQuotient]);}inline unsigned char RxMaskVolume::GetMinMaxMask2x2(const int& iVolX, const int& iVolY, const int& iVolZ){ int iQuotient, iRemainder, iOffset; iOffset = m_iVolX2x2 * m_iVolY2x2 * (iVolZ >> 1) + m_iVolX2x2 * (iVolY >> 1) + (iVolX >> 1); iQuotient = iOffset >> 3; iRemainder = iOffset & 0x07; return (m_pbyMinMax2x2[iQuotient] >> (7 - iRemainder)) & 0x01;}inline unsigned char RxMaskVolume::GetMinMaxMask8x8(const int& iVolX, const int& iVolY, const int& iVolZ){ if(m_pbyMinMax8x8 == NULL) return 0; int iQuotient, iRemainder, iOffset; iOffset = m_iVolX8x8 * m_iVolY8x8 * (iVolZ >> 3) + m_iVolX8x8 * (iVolY >> 3) + (iVolX >> 3); iQuotient = iOffset >> 3; iRemainder = iOffset & 0x07; return (m_pbyMinMax8x8[iQuotient] >> (7 - iRemainder)) & 0x01;}#endif // !defined(_RX_MASK_VOLUME_H_)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -