#include <chain.h>
Nevrax France
Definition at line 107 of file chain.h.
Public Member Functions | |
void | computeMinMax () |
float | distance (const NLMISC::CVector &position) const |
uint16 | getIndexInParent () const |
Returns the index of the ochain within the parent chain. | |
float | getLength () const |
Returns the length of the chain. | |
const CVector2s & | getMax () const |
Returns the max vector of the chain. | |
const CVector2s & | getMin () const |
Returns the min vector of the chain. | |
uint16 | getParentId () const |
Returns the parent chain Id of this ordered chain. | |
const std::vector< CVector2s > & | getVertices () const |
Returns the vertices of the chain. | |
bool | isForward () const |
Returns true if the chain should be accessed forward within the parent CChain (see _Forward.). | |
const CVector2s & | operator[] (uint n) const |
void | pack (const COrderedChain3f &chain) |
void | serial (NLMISC::IStream &f) |
void | translate (const NLMISC::CVector &translation) |
void | traverse (sint from, sint to, bool forward, std::vector< CVector2s > &path) const |
Protected Attributes | |
bool | _Forward |
Set if the chain should be read forward within the parent CChain (for sequential access to vertices.). | |
uint16 | _IndexInParent |
The index of the ochain within the parent chain. | |
float | _Length |
The length of the chain. | |
CVector2s | _Max |
The min and max vertices of the chain. | |
CVector2s | _Min |
The min and max vertices of the chain. | |
uint16 | _ParentId |
The parent chain Id. | |
std::vector< CVector2s > | _Vertices |
The vertices of the chain, ordered following x growth. | |
Friends | |
class | CChain |
class | CRetrievableSurface |
|
Definition at line 178 of file chain.h. References _Max, _Min, NLPACS::CVector2s::minof(), and uint. Referenced by NLPACS::CChain::make().
|
|
Definition at line 115 of file chain.cpp. References len, NLMISC::CVector2f::norm(), uint, NLMISC::CVector2f::x, and NLMISC::CVector2f::y.
00116 { 00117 float minDist = 1.0e10f; 00118 uint i; 00119 CVector2f pos = CVector2f(position); 00120 00121 for (i=0; i+1<_Vertices.size(); ++i) 00122 { 00123 CVector2f a = _Vertices[i].unpack(), 00124 b = _Vertices[i+1].unpack(); 00125 00126 CVector2f d = (b-a); 00127 float len = d.norm(); 00128 d /= len; 00129 CVector2f n = CVector2f(d.y, -d.x); 00130 00131 float l = (pos-a)*d; 00132 float dist; 00133 00134 if (l < 0.0f) 00135 { 00136 dist = (pos-a).norm(); 00137 } 00138 else if (l > len) 00139 { 00140 dist = (pos-b).norm(); 00141 } 00142 else 00143 { 00144 dist = (float)fabs((pos-a)*n); 00145 } 00146 00147 if (dist < minDist) 00148 { 00149 minDist = dist; 00150 } 00151 } 00152 00153 return minDist; 00154 } |
|
Returns the index of the ochain within the parent chain.
Definition at line 142 of file chain.h. References uint16. Referenced by NLPACS::CGlobalRetriever::check(), and NLPACS::COrderedChain3f::unpack().
00142 { return _IndexInParent; } |
|
Returns the length of the chain.
Definition at line 145 of file chain.h. Referenced by NLPACS::CGlobalRetriever::findPath().
00145 { return _Length; } |
|
Returns the max vector of the chain.
Definition at line 154 of file chain.h. References _Max. Referenced by NLPACS::CLocalRetriever::retrieveAccuratePosition(), and NLPACS::CLocalRetriever::retrievePosition().
00154 { return _Max; }; |
|
Returns the min vector of the chain.
Definition at line 151 of file chain.h. References _Min. Referenced by NLPACS::CLocalRetriever::retrieveAccuratePosition(), and NLPACS::CLocalRetriever::retrievePosition().
00151 { return _Min; }; |
|
Returns the parent chain Id of this ordered chain.
Definition at line 139 of file chain.h. References uint16. Referenced by NLPACS::CGlobalRetriever::check(), NLPACS::CLocalRetriever::findPath(), NLPACS::CGlobalRetriever::getBorders(), NLPACS::CLocalRetriever::retrieveAccuratePosition(), NLPACS::CLocalRetriever::retrievePosition(), NLPACS::CLocalRetriever::testCollision(), and NLPACS::COrderedChain3f::unpack().
00139 { return _ParentId; } |
|
Returns the vertices of the chain.
Definition at line 133 of file chain.h. Referenced by NLPACS::CLocalRetriever::buildSurfacePolygons(), NLPACS::computeRetriever(), NLPACS::CLocalRetriever::dumpSurface(), NLPACS::CGlobalRetriever::findPath(), NLPACS::CLocalRetriever::insurePosition(), NLPACS::CLocalRetriever::retrieveAccuratePosition(), NLPACS::CLocalRetriever::retrievePosition(), NLPACS::CLocalRetriever::CIterator::setupIndex(), NLPACS::CLocalRetriever::testCollision(), and NLPACS::COrderedChain3f::unpack().
00133 { return _Vertices; } |
|
Returns true if the chain should be accessed forward within the parent CChain (see _Forward.).
Definition at line 136 of file chain.h. Referenced by NLPACS::CLocalRetriever::buildSurfacePolygons(), NLPACS::CLocalRetriever::insurePosition(), NLPACS::CLocalRetriever::retrieveAccuratePosition(), NLPACS::CLocalRetriever::retrievePosition(), NLPACS::CLocalRetriever::CIterator::setupIndex(), and NLPACS::COrderedChain3f::unpack().
00136 { return _Forward; } |
|
Definition at line 148 of file chain.h. References uint.
00148 { return _Vertices[n]; } |
|
Definition at line 161 of file chain.h. References _Max, _Min, NLPACS::COrderedChain3f::getIndexInParent(), NLPACS::COrderedChain3f::getParentId(), NLPACS::COrderedChain3f::getVertices(), NLPACS::COrderedChain3f::isForward(), NLPACS::CVector2s::maxof(), NLPACS::CVector2s::minof(), and uint. Referenced by NLPACS::CChain::make().
00162 { 00163 uint i; 00164 const std::vector<NLMISC::CVector> &vertices = chain.getVertices(); 00165 _Vertices.resize(vertices.size()); 00166 _Forward = chain.isForward(); 00167 _ParentId = chain.getParentId(); 00168 _IndexInParent = chain.getIndexInParent(); 00169 for (i=0; i<vertices.size(); ++i) 00170 { 00171 _Vertices[i] = CVector2s(vertices[i]); 00172 _Min.minof(_Min, _Vertices[i]); 00173 _Max.maxof(_Max, _Vertices[i]); 00174 } 00175 } |
|
Definition at line 158 of file chain.cpp. References _Max, _Min, NLMISC::IStream::isReading(), NLPACS::CVector2s::maxof(), NLMISC::IStream::serial(), NLMISC::IStream::serialCont(), NLMISC::IStream::serialVersion(), sint, and uint.
00159 { 00160 /* 00161 Version 0: 00162 - base version. 00163 Version 1: 00164 - added _Min and _Max vectors 00165 */ 00166 sint ver= f.serialVersion(1); 00167 00168 f.serialCont(_Vertices); 00169 f.serial(_Forward); 00170 f.serial(_ParentId); 00171 f.serial(_IndexInParent); 00172 f.serial(_Length); 00173 00174 if (ver >= 1) 00175 { 00176 f.serial(_Min, _Max); 00177 } 00178 else if (f.isReading() && !_Vertices.empty()) 00179 { 00180 uint i; 00181 _Max = _Min = _Vertices[0]; 00182 for (i=1; i<_Vertices.size(); ++i) 00183 { 00184 _Min.minof(_Min, _Vertices[i]); 00185 _Max.maxof(_Max, _Vertices[i]); 00186 } 00187 } 00188 } |
|
Definition at line 83 of file chain.cpp. References NLPACS::CVector2s::pack(), and uint.
|
|
Definition at line 93 of file chain.cpp.
00094 { 00095 sint i; 00096 if (forward) 00097 { 00098 if (from < 0) from = 0; 00099 if (to < 0) to = _Vertices.size()-1; 00100 00101 for (i=from+1; i<=to; ++i) 00102 path.push_back(_Vertices[i]); 00103 } 00104 else 00105 { 00106 if (from < 0) from = _Vertices.size()-2; 00107 if (to < 0) to = -1; 00108 00109 for (i=from; i>to; --i) 00110 path.push_back(_Vertices[i]); 00111 } 00112 } |
|
|
|
|
|
Set if the chain should be read forward within the parent CChain (for sequential access to vertices.).
|
|
The index of the ochain within the parent chain.
|
|
The length of the chain.
Definition at line 126 of file chain.h. Referenced by NLPACS::CChain::make(). |
|
The min and max vertices of the chain.
Definition at line 129 of file chain.h. Referenced by computeMinMax(), getMax(), pack(), and serial(). |
|
The min and max vertices of the chain.
Definition at line 129 of file chain.h. Referenced by computeMinMax(), getMin(), pack(), and serial(). |
|
The parent chain Id.
|
|
The vertices of the chain, ordered following x growth.
Definition at line 114 of file chain.h. Referenced by NLPACS::CChain::make(). |