ColGrid.h

00001 //---------------------------------------------------------------------------
00002 //                              Grid
00003 //---------------------------------------------------------------------------
00004 //  Copyright (C):
00005 //---------------------------------------------------------------------------
00006 //CVSId: "@(#)$Id: ColGrid.h,v 1.3 2004/06/09 12:23:17 weller Exp $"
00007 
00008 
00009 #ifndef Grid_H
00010 #define Grid_H
00011 #if defined(__sgi) || defined(_WIN32)
00012 #pragma once
00013 #endif
00014 
00015 
00016 //---------------------------------------------------------------------------
00017 //  Includes
00018 //---------------------------------------------------------------------------
00019 
00020 #include <vector>
00021 #include <set>
00022 
00023 #include <ColGridCell.h>
00024 #include <ColGridObj.h>
00025 #include <col_import_export.h>
00026 
00027 
00028 //---------------------------------------------------------------------------
00029 //  Forward References
00030 //---------------------------------------------------------------------------
00031 
00032 namespace col {
00033     
00034 class ColPair;
00035 
00036 //---------------------------------------------------------------------------
00037 //  The Class
00038 //---------------------------------------------------------------------------
00039 
00040 class COL_EXPORTIMPORT Grid
00041 {
00042 
00043     friend class GridObj;
00044 
00045 public:
00046 
00047     Grid( unsigned int size[3], float  min[3], float  max[3] );
00048     virtual ~Grid();
00049 
00050     void            addObject( GridObj* gridObj );
00051     void            removeObject( GridObj* gridObj );
00052     GridCell*       getCellP( unsigned int x, unsigned int y, unsigned int z );
00053     void            getCollPairs( std::vector<ColPair> *collPairs, unsigned int *neighbors );
00054     unsigned int    getNrCollPairs();
00055 
00056 //---------------------------------------------------------------------------
00057 //  Protected Instance methods
00058 //---------------------------------------------------------------------------
00059 
00060 protected:
00061 
00062     unsigned int    calcIndex( unsigned int x, unsigned int y,
00063                                unsigned int z ) const;
00064     unsigned int    calcIndex( const float pos[3] ) const;
00065     void            calcIndex( const float pos[3],  unsigned int ind[3] ) const;
00066 
00067     void    deleteCells( void );
00068     void    deleteObjs( void );
00069 
00070 //---------------------------------------------------------------------------
00071 //  Instance variables
00072 //---------------------------------------------------------------------------
00073 
00074     GridCell**      m_cell;
00075     unsigned int    m_size[3], m_xySize;
00076     float           m_min[3]; 
00077     float           m_max[3]; 
00078     float           m_stepSize[3]; 
00079      
00080     std::set<GridObj*>  m_objects;
00081     unsigned int        m_collTestCycle;
00082     unsigned int        m_objTestCycle;
00083 
00084 //---------------------------------------------------------------------------
00085 //  Private Instance methods
00086 //---------------------------------------------------------------------------
00087 
00088 protected:
00089 
00090     // prohibit copy constructor (move to 'public' if you need one)
00091     explicit Grid( const Grid &source );
00092 
00093     // prohibit assignment
00094     Grid& operator = ( const Grid &source );
00095 
00096 };
00097 
00098 
00099 }   //namespace col 
00100 
00101 #endif /* Grid_H */
00102 

Generated on Tue Oct 16 18:12:21 2007 for CollDet by  doxygen 1.5.2