00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #ifndef PL_SimplexSubdivision_h
00012 #define PL_SimplexSubdivision_h 1
00013
00014
00015
00016
00017
00018
00019
00020 #include "Planners\PL_OpenGL.h"
00021 #include "Planners\obsolete\PL_LinearCollision.h"
00022 #include <set>
00023
00024
00025 #pragma warning( disable : 4250 )
00026 #pragma warning( disable : 4786 )
00027
00028
00029
00030
00031
00032
00033
00034 class PL_SimplexSubdivision
00035 :
00036 public PL_LinearCollision,
00037 public PL_OpenGL
00038 {
00039
00040 public:
00041
00042 enum CollisionType
00043 {
00044 CT_FREE,
00045 CT_COLLISION,
00046 CT_MIXED,
00047 CT_UNKNOWN
00048 };
00049
00050 protected:
00051
00052 struct Node
00053 {
00054
00055 void AddNeighbor( const int node );
00056
00057
00058 Configuration Center() const;
00059
00060
00061 bool Contains( const Configuration& c ) const;
00062
00063
00064 bool ContainsCompletely( const Configuration& c ) const;
00065
00066
00067 void DrawExplicit() const;
00068
00069
00070 void GlColor() const;
00071
00072
00073 bool IsClean() const;
00074
00075
00076 void RemoveNeighbor( const int node );
00077
00078
00079 double Volume() const;
00080
00081 bool m_Alive;
00082 double m_DistanceFromStart;
00083 Configuration m_Min;
00084 Configuration m_Max;
00085 std::vector< int > m_NodesAdjacent;
00086 std::vector< CollisionType > m_LinkType;
00087 Configuration m_LocationOfCollision;
00088 };
00089
00090
00091
00092
00093 public:
00094
00095 PL_SimplexSubdivision();
00096
00097
00098 virtual ~PL_SimplexSubdivision();
00099
00100 virtual bool DrawExplicit () const;
00101
00102 virtual bool Plan ();
00103
00104
00105 double Volume( const int i ) const;
00106
00107
00108 protected:
00109
00110
00111
00112 void AddEdge( const int node0, const int node1 );
00113
00114
00115 int AddNode ( const Configuration& min, const Configuration& max );
00116
00117
00118 void AddSuspiciousNode( const int nodeNum );
00119
00120
00121 void AddToOpenList( const int nodeNum );
00122
00123
00124 CollisionType CollisionCheck( const int n0, const int n1 );
00125
00126
00127 void DeleteEdge( const int node0, const int node1 );
00128
00129
00130 void DeleteNode( const int nodeNum );
00131
00132
00133 void ConnectStartAndGoal();
00134
00135
00136 bool IsAdjacent( int node0, int node1 );
00137
00138
00139 bool SearchForGoal();
00140
00141
00142 void SubdivideLargestNode();
00143
00144
00145 void SubdivideNode( int nodeNum );
00146
00147
00148 std::vector< Node > m_Nodes;
00149
00150
00151 int m_NodeStart;
00152 int m_NodeGoal;
00153
00154 std::set< int > m_OpenList;
00155 std::set< int > m_ClosedList;
00156 struct ComparisonFunction
00157 {
00158 public:
00159 ComparisonFunction( const PL_SimplexSubdivision* planner );
00160 ComparisonFunction( const ComparisonFunction& right );
00161 bool operator()( const int a, const int b );
00162 const PL_SimplexSubdivision* m_Planner;
00163 };
00164 ComparisonFunction m_Compare;
00165 typedef std::set< int, ComparisonFunction > INTSET;
00166 INTSET m_SuspiciousNodesAndVolumes;
00167
00168
00169 private:
00170
00171
00172
00173
00174 private:
00175
00176
00177
00178
00179 };
00180
00181
00182
00183
00184
00185
00186
00187
00188
00189
00190 #endif