3
0

CBBoxInt32.cpp 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. //=============================================================================
  2. //CBBoxInt32
  3. // 3D bounding box with int32 coordinates
  4. //
  5. //=============================================================================
  6. // (C) 2005 ATI Research, Inc., All rights reserved.
  7. //=============================================================================
  8. // Modified from original
  9. #include "CBBoxInt32.h"
  10. #define CP_MIN_INT32 0x80000000
  11. #define CP_MAX_INT32 0x7fffffff
  12. #define CP_MIN(a, b) (((a) < (b)) ? (a) : (b))
  13. #define CP_MAX(a, b) (((a) > (b)) ? (a) : (b))
  14. namespace ImageProcessingAtom
  15. {
  16. //--------------------------------------------------------------------------------------
  17. // CBBoxInt32
  18. //--------------------------------------------------------------------------------------
  19. CBBoxInt32::CBBoxInt32(void)
  20. {
  21. Clear();
  22. }
  23. //--------------------------------------------------------------------------------------
  24. // Text to see if CBBoxInt32 is empty or not
  25. //--------------------------------------------------------------------------------------
  26. bool CBBoxInt32::Empty(void)
  27. {
  28. if ((m_minCoord[0] > m_maxCoord[0]) ||
  29. (m_minCoord[1] > m_maxCoord[1]) ||
  30. (m_minCoord[2] > m_maxCoord[2]))
  31. {
  32. return true;
  33. }
  34. else
  35. {
  36. return false;
  37. }
  38. }
  39. //--------------------------------------------------------------------------------------
  40. // Clear bounding box extents
  41. //--------------------------------------------------------------------------------------
  42. void CBBoxInt32::Clear(void)
  43. {
  44. m_minCoord[0] = CP_MAX_INT32;
  45. m_minCoord[1] = CP_MAX_INT32;
  46. m_minCoord[2] = CP_MAX_INT32;
  47. m_maxCoord[0] = CP_MIN_INT32;
  48. m_maxCoord[1] = CP_MIN_INT32;
  49. m_maxCoord[2] = CP_MIN_INT32;
  50. }
  51. //--------------------------------------------------------------------------------------
  52. // Augment bounding box extents by specifying point to include in bounding box
  53. //--------------------------------------------------------------------------------------
  54. void CBBoxInt32::Augment(int32 aX, int32 aY, int32 aZ)
  55. {
  56. m_minCoord[0] = CP_MIN(m_minCoord[0], aX);
  57. m_minCoord[1] = CP_MIN(m_minCoord[1], aY);
  58. m_minCoord[2] = CP_MIN(m_minCoord[2], aZ);
  59. m_maxCoord[0] = CP_MAX(m_maxCoord[0], aX);
  60. m_maxCoord[1] = CP_MAX(m_maxCoord[1], aY);
  61. m_maxCoord[2] = CP_MAX(m_maxCoord[2], aZ);
  62. }
  63. //--------------------------------------------------------------------------------------
  64. // Augment bounding box extents by specifying x coordinate to include in bounding box
  65. //--------------------------------------------------------------------------------------
  66. void CBBoxInt32::AugmentX(int32 aX)
  67. {
  68. m_minCoord[0] = CP_MIN(m_minCoord[0], aX);
  69. m_maxCoord[0] = CP_MAX(m_maxCoord[0], aX);
  70. }
  71. //--------------------------------------------------------------------------------------
  72. // Augment bounding box extents by specifying x coordinate to include in bounding box
  73. //--------------------------------------------------------------------------------------
  74. void CBBoxInt32::AugmentY(int32 aY)
  75. {
  76. m_minCoord[1] = CP_MIN(m_minCoord[1], aY);
  77. m_maxCoord[1] = CP_MAX(m_maxCoord[1], aY);
  78. }
  79. //--------------------------------------------------------------------------------------
  80. // Augment bounding box extents by specifying x coordinate to include in bounding box
  81. //--------------------------------------------------------------------------------------
  82. void CBBoxInt32::AugmentZ(int32 aZ)
  83. {
  84. m_minCoord[2] = CP_MIN(m_minCoord[2], aZ);
  85. m_maxCoord[2] = CP_MAX(m_maxCoord[2], aZ);
  86. }
  87. //--------------------------------------------------------------------------------------
  88. // Clamp minimum values in bbox to be no larger than aX, aY, aZ
  89. //--------------------------------------------------------------------------------------
  90. void CBBoxInt32::ClampMin(int32 aX, int32 aY, int32 aZ)
  91. {
  92. m_minCoord[0] = CP_MAX(m_minCoord[0], aX);
  93. m_minCoord[1] = CP_MAX(m_minCoord[1], aY);
  94. m_minCoord[2] = CP_MAX(m_minCoord[2], aZ);
  95. }
  96. //--------------------------------------------------------------------------------------
  97. // Clamp maximum values in bbox to be no larger than aX, aY, aZ
  98. //--------------------------------------------------------------------------------------
  99. void CBBoxInt32::ClampMax(int32 aX, int32 aY, int32 aZ)
  100. {
  101. m_maxCoord[0] = CP_MIN(m_maxCoord[0], aX);
  102. m_maxCoord[1] = CP_MIN(m_maxCoord[1], aY);
  103. m_maxCoord[2] = CP_MIN(m_maxCoord[2], aZ);
  104. }
  105. } //namespace ImageProcessingAtom