00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #ifndef ColObj_H
00012 #define ColObj_H
00013 #if defined(__sgi) || defined(_WIN32)
00014 #pragma once
00015 #endif
00016
00017
00018
00019
00020
00021 #include <vector>
00022
00023 #include <OpenSG/OSGGeometry.h>
00024 #include <OpenSG/OSGGeoProperty.h>
00025
00026 #include <ColDopTree.h>
00027 #include <ColBoxtree.h>
00028 #include <ColConvexHull.h>
00029 #include <ColGridObj.h>
00030
00031 #include <col_import_export.h>
00032
00033
00034 namespace col {
00035
00036
00037
00038
00039
00040 class Matrix;
00041 class MatrixCell;
00042 class ColPair;
00043
00044
00045
00046
00047
00048
00049 class COL_EXPORTIMPORT ColObj
00050 {
00051
00052 friend class Matrix;
00053 friend class MatrixCell;
00054 friend class ColPair;
00055
00056 public:
00057
00058 ColObj();
00059 ColObj( osg::GeometryPtr &geom, osg::NodePtr &node,
00060 bool flexible, bool stationary,
00061 bool compute_hull, AlgoE algo, Grid *grid,
00062 bool show_hull = false, char *name = NULL );
00063 virtual ~ColObj() throw();
00064
00065 ColObj( const ColObj &source );
00066 void operator = ( const ColObj &source );
00067
00068 void updateBBox( void );
00069 bool bboxIntersects( ColObj* other );
00070 bool hasMoved( unsigned int global_cycle );
00071
00072 const char * getName( void ) const;
00073
00074 void setActive( bool active );
00075 bool isActive();
00076 void setFlexible( bool flexible );
00077 void setStationary( bool stationary );
00078
00079 static ColObj* find( vector<ColObj> *colobjs, osg::NodePtr obj );
00080
00081 void SetGridObj( Grid *grid );
00082 GridObj * GetGridObj( void );
00083 void updateGrid ( void );
00084
00085 protected:
00086
00088 bool m_active;
00089
00091 bool m_flexible;
00092
00094 bool m_stationary;
00095
00097 const DopTree *m_doptree;
00098
00100 const Boxtree *m_boxtree;
00101
00103 osg::NodePtr m_node;
00104
00106 osg::Matrix m_old_matr;
00107
00109 osg::Matrix m_curr_matr;
00110
00111 vector<const osg::MFPnt3f *> points;
00113 char *m_name;
00114
00119 int m_col_matr_idx;
00120
00124 bool m_has_moved;
00125 bool m_first_moved_check;
00126 unsigned int m_cycle;
00127
00129 ConvexHull m_hull;
00130
00131
00132 GridObj *m_gridobj;
00133
00134 };
00135
00136
00137
00138
00139
00140
00141
00142 class COL_EXPORTIMPORT ColPair
00143 {
00144
00145 public:
00146
00147 ColPair();
00148 ColPair( ColObj* p, ColObj* q );
00149 ColPair( const ColPair &source );
00150 void operator = ( const ColPair &source );
00151 virtual ~ColPair() throw();
00152
00153 ColObj* p( void ) const;
00154 ColObj* q( void ) const;
00155
00156 protected:
00157
00159 ColObj *m_p, *m_q;
00160
00161 };
00162
00163
00164
00165
00166
00167
00168
00169 class COL_EXPORTIMPORT MatrixCell
00170 {
00171 public:
00172
00173 MatrixCell( const ColObj *colobj1, const ColObj *colobj2 );
00174
00175 void addCallback( Callback *callback );
00176 void callCallbacks( void ) const;
00177
00178 bool check( bool use_hulls );
00179
00180 protected:
00181
00183 vector<Callback*> m_callback;
00184
00186 ColObj const * const m_colobj1;
00187 ColObj const * const m_colobj2;
00188
00190 LevelOfDetectionE m_level;
00191
00193 SepPlane m_sep_plane;
00194
00196 Data m_data;
00197
00199 bool m_allpolygons;
00200 };
00201
00202
00203
00204
00205
00206
00207
00208 class COL_EXPORTIMPORT Matrix
00209 {
00210 public:
00211
00212 Matrix( unsigned int numcolobjs = 50 );
00213
00214 void addObj( ColObj *obj );
00215 void addCallback( Callback *callback, vector<ColObj> *colobjs );
00216
00217 MatrixCell * getCell( const ColPair &pair ) const;
00218 MatrixCell * createCell( const ColObj *obj1, const ColObj *obj2 );
00219
00220 bool check( const ColPair &pair, bool use_hulls, AlgoE algo ) const;
00221 void callCallbacks( const ColPair &pair ) const;
00222
00223 bool isConsistent( vector<ColObj> *colobjs ) const;
00224
00225 protected:
00226
00228 typedef vector<MatrixCell*> m_Row;
00229
00231 vector<m_Row> m_m;
00232
00233 explicit Matrix( const Matrix &source );
00234 Matrix& operator = ( const Matrix &source );
00235
00236 };
00237
00238
00239 }
00240
00241 #endif
00242
00243