| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127 |
- //=============================================================================
- //CBBoxInt32
- // 3D bounding box with int32 coordinates
- //
- //=============================================================================
- // (C) 2005 ATI Research, Inc., All rights reserved.
- //=============================================================================
- // Modified from original
- #include "CBBoxInt32.h"
- #define CP_MIN_INT32 0x80000000
- #define CP_MAX_INT32 0x7fffffff
- #define CP_MIN(a, b) (((a) < (b)) ? (a) : (b))
- #define CP_MAX(a, b) (((a) > (b)) ? (a) : (b))
- namespace ImageProcessingAtom
- {
- //--------------------------------------------------------------------------------------
- // CBBoxInt32
- //--------------------------------------------------------------------------------------
- CBBoxInt32::CBBoxInt32(void)
- {
- Clear();
- }
- //--------------------------------------------------------------------------------------
- // Text to see if CBBoxInt32 is empty or not
- //--------------------------------------------------------------------------------------
- bool CBBoxInt32::Empty(void)
- {
- if ((m_minCoord[0] > m_maxCoord[0]) ||
- (m_minCoord[1] > m_maxCoord[1]) ||
- (m_minCoord[2] > m_maxCoord[2]))
- {
- return true;
- }
- else
- {
- return false;
- }
- }
- //--------------------------------------------------------------------------------------
- // Clear bounding box extents
- //--------------------------------------------------------------------------------------
- void CBBoxInt32::Clear(void)
- {
- m_minCoord[0] = CP_MAX_INT32;
- m_minCoord[1] = CP_MAX_INT32;
- m_minCoord[2] = CP_MAX_INT32;
- m_maxCoord[0] = CP_MIN_INT32;
- m_maxCoord[1] = CP_MIN_INT32;
- m_maxCoord[2] = CP_MIN_INT32;
- }
- //--------------------------------------------------------------------------------------
- // Augment bounding box extents by specifying point to include in bounding box
- //--------------------------------------------------------------------------------------
- void CBBoxInt32::Augment(int32 aX, int32 aY, int32 aZ)
- {
- m_minCoord[0] = CP_MIN(m_minCoord[0], aX);
- m_minCoord[1] = CP_MIN(m_minCoord[1], aY);
- m_minCoord[2] = CP_MIN(m_minCoord[2], aZ);
- m_maxCoord[0] = CP_MAX(m_maxCoord[0], aX);
- m_maxCoord[1] = CP_MAX(m_maxCoord[1], aY);
- m_maxCoord[2] = CP_MAX(m_maxCoord[2], aZ);
- }
- //--------------------------------------------------------------------------------------
- // Augment bounding box extents by specifying x coordinate to include in bounding box
- //--------------------------------------------------------------------------------------
- void CBBoxInt32::AugmentX(int32 aX)
- {
- m_minCoord[0] = CP_MIN(m_minCoord[0], aX);
- m_maxCoord[0] = CP_MAX(m_maxCoord[0], aX);
- }
- //--------------------------------------------------------------------------------------
- // Augment bounding box extents by specifying x coordinate to include in bounding box
- //--------------------------------------------------------------------------------------
- void CBBoxInt32::AugmentY(int32 aY)
- {
- m_minCoord[1] = CP_MIN(m_minCoord[1], aY);
- m_maxCoord[1] = CP_MAX(m_maxCoord[1], aY);
- }
- //--------------------------------------------------------------------------------------
- // Augment bounding box extents by specifying x coordinate to include in bounding box
- //--------------------------------------------------------------------------------------
- void CBBoxInt32::AugmentZ(int32 aZ)
- {
- m_minCoord[2] = CP_MIN(m_minCoord[2], aZ);
- m_maxCoord[2] = CP_MAX(m_maxCoord[2], aZ);
- }
- //--------------------------------------------------------------------------------------
- // Clamp minimum values in bbox to be no larger than aX, aY, aZ
- //--------------------------------------------------------------------------------------
- void CBBoxInt32::ClampMin(int32 aX, int32 aY, int32 aZ)
- {
- m_minCoord[0] = CP_MAX(m_minCoord[0], aX);
- m_minCoord[1] = CP_MAX(m_minCoord[1], aY);
- m_minCoord[2] = CP_MAX(m_minCoord[2], aZ);
- }
- //--------------------------------------------------------------------------------------
- // Clamp maximum values in bbox to be no larger than aX, aY, aZ
- //--------------------------------------------------------------------------------------
- void CBBoxInt32::ClampMax(int32 aX, int32 aY, int32 aZ)
- {
- m_maxCoord[0] = CP_MIN(m_maxCoord[0], aX);
- m_maxCoord[1] = CP_MIN(m_maxCoord[1], aY);
- m_maxCoord[2] = CP_MIN(m_maxCoord[2], aZ);
- }
- } //namespace ImageProcessingAtom
|