stack3.h 938 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. #ifndef _STACK3_H_
  2. #define _STACK3_H_
  3. #include "matrix3.h"
  4. #define STACK_DEPTH 32 // default stack depth
  5. class Matrix3Stack {
  6. public:
  7. DllExport Matrix3Stack();
  8. DllExport Matrix3Stack(int depth);
  9. DllExport ~Matrix3Stack();
  10. BOOL replace(const Matrix3 &m)
  11. { stk[index] = m; return TRUE; }
  12. BOOL push(const Matrix3 &m)
  13. { stk[index++] = m; return index < maxDepth; }
  14. BOOL dup(void)
  15. { stk[index+1] = stk[index]; return ++index < maxDepth; }
  16. BOOL concat(const Matrix3 &m)
  17. { stk[index] = m * stk[index]; return TRUE; }
  18. Matrix3 & get(void)
  19. { return stk[index]; }
  20. Matrix3 & pop(void)
  21. { return stk[index--]; }
  22. BOOL remove(void)
  23. { return --index >= 0; }
  24. BOOL reset(void)
  25. { index = 0; stk[0].IdentityMatrix(); return TRUE; }
  26. private:
  27. int maxDepth;
  28. int index;
  29. Matrix3 * stk;
  30. };
  31. #endif // _STACK3_H_