home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 7 / Apprentice-Release7.iso / Source Code / C ++ / Applications / TimGA 1.2.1 / .cp / CCrossMemory.cp next >
Encoding:
Text File  |  1997-07-16  |  1.3 KB  |  52 lines  |  [TEXT/CWIE]

  1. // ===========================================================================
  2. //    CCrossMemory.cp            ©1996-97 Timo Eloranta        All rights reserved.
  3. // ===========================================================================
  4. //    This class, used by CGraphDrawing, was added to the application in the
  5. //    optimization phase to speed up the process of calculating edge crossings.
  6.  
  7. #include "CCrossMemory.h"
  8.  
  9. #include <UException.h>
  10.  
  11. // ---------------------------------------------------------------------------
  12. //        • CCrossMemory
  13. //
  14. //          Called by:    CGraphDrawing::AddCrossMemory
  15. // ---------------------------------------------------------------------------
  16. //    Constructor.
  17.  
  18. CCrossMemory::CCrossMemory( UInt16 inEdgeCount )
  19. {    
  20.     mEdgeCount    = inEdgeCount;
  21.     mCrossTotal    = 0;
  22.  
  23.     mSize        = (mEdgeCount * ( mEdgeCount - 1 )) / 2;
  24.     mByteSize    = mSize * sizeof(Boolean);
  25.     
  26.     mArray        = nil;
  27.     
  28. #if __POWERPC__
  29.     mArray    = new Boolean[ mSize ];
  30. #else // 68K
  31.     if ( mByteSize < 32768 )
  32.         mArray    = new Boolean[ mSize ];
  33. #endif
  34.     
  35.     ThrowIfNil_ (mArray);
  36. }
  37.  
  38. // ---------------------------------------------------------------------------
  39. //        • ~CCrossMemory
  40. //
  41. //          Called by:    CGraphDrawing::JunkCrossMemory
  42. // ---------------------------------------------------------------------------
  43. //    Destructor.
  44.  
  45. CCrossMemory::~CCrossMemory()
  46. {    
  47.     if ( mArray ) {
  48.         delete [] mArray;
  49.         mArray = nil;
  50.     }
  51. }
  52.