From 0ea5fc66924303d1bf73ba283a383e2aadee02f2 Mon Sep 17 00:00:00 2001 From: neodarz Date: Sat, 11 Aug 2018 20:21:34 +0200 Subject: Initial commit --- docs/doxygen/nel/a02450.html | 1539 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 1539 insertions(+) create mode 100644 docs/doxygen/nel/a02450.html (limited to 'docs/doxygen/nel/a02450.html') diff --git a/docs/doxygen/nel/a02450.html b/docs/doxygen/nel/a02450.html new file mode 100644 index 00000000..cf457a47 --- /dev/null +++ b/docs/doxygen/nel/a02450.html @@ -0,0 +1,1539 @@ + + +NeL: NLPACS::CEdgeQuad class Reference + + + +
+

NLPACS::CEdgeQuad Class Reference

#include <edge_quad.h> +

+


Detailed Description

+a quadgrid of list of edge chain.
Author:
Benjamin Legros

+Nevrax France

+
Date:
2001
+ +

+ +

+Definition at line 61 of file edge_quad.h. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Public Member Functions

void build (const CExteriorMesh &em, const CGlobalRetriever &global, CCollisionSurfaceTemp &cst, uint32 thisInstance)
 build a chain quad, with a list of exterior Edges and the global retriever

 CEdgeQuad (const CEdgeQuad &o)
 Copy Constructor.

 CEdgeQuad ()
 Constructor.

void clear ()
 clear

const std::vector< CExteriorEdgeEntry > & getEdgeEntries () const
 Get the whole set of edge entries.

const CExteriorEdgeEntrygetEdgeEntry (uint entry) const
 Get a single edge entry.

CEdgeQuadoperator= (const CEdgeQuad &o)
 operator=.

void removeLinks ()
void removeLinks (sint32 instanceId)
sint selectEdges (CVector start, CVector end, CCollisionSurfaceTemp &cst) const
sint selectEdges (const NLMISC::CAABBox &bbox, CCollisionSurfaceTemp &cst) const
void serial (NLMISC::IStream &f)
 serial.

 ~CEdgeQuad ()
 Destructor.


Private Member Functions

void getGridBounds (sint32 &x0, sint32 &y0, sint32 &x1, sint32 &y1, const CVector &minP, const CVector &maxP) const

Private Attributes

std::vector< CExteriorEdgeEntry_EdgeEntries
 The real exterior edge entries.

uint32 _Height
 Height of the quadgrid.

std::vector< uint8 * > _Quad
uint8_QuadData
 Single memory block of CExteriorEdgeEntry chains.

uint32 _QuadDataLen
 size (in byte) of _QuadData.

uint32 _Width
 Width of the quadgrid.

sint32 _X
 Postion of the chainquad.

sint32 _Y
 Postion of the chainquad.


Static Private Attributes

const float _QuadElementSize = 4
+


Constructor & Destructor Documentation

+

+ + + + +
+ + + + + + + + + +
NLPACS::CEdgeQuad::CEdgeQuad  ) 
+
+ + + + + +
+   + + +

+Constructor. +

+ +

+Definition at line 44 of file edge_quad.cpp. +

+

00045 {
+00046         _QuadData= NULL;
+00047         _QuadDataLen= 0;
+00048 }
+
+

+ + + + +
+ + + + + + + + + + +
NLPACS::CEdgeQuad::CEdgeQuad const CEdgeQuad o  ) 
+
+ + + + + +
+   + + +

+Copy Constructor. +

+ +

+Definition at line 55 of file edge_quad.cpp. +

+

00056 {
+00057         _QuadData= NULL;
+00058         _QuadDataLen= 0;
+00059         *this= o;
+00060 }
+
+

+ + + + +
+ + + + + + + + + +
NLPACS::CEdgeQuad::~CEdgeQuad  ) 
+
+ + + + + +
+   + + +

+Destructor. +

+ +

+Definition at line 50 of file edge_quad.cpp. +

+References clear(). +

+

00051 {
+00052         clear();
+00053 }
+
+


Member Function Documentation

+

+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
void NLPACS::CEdgeQuad::build const CExteriorMesh em,
const CGlobalRetriever global,
CCollisionSurfaceTemp cst,
uint32  thisInstance
+
+ + + + + +
+   + + +

+build a chain quad, with a list of exterior Edges and the global retriever +

+ +

+Definition at line 130 of file edge_quad.cpp. +

+References _EdgeEntries, NLPACS::CCollisionSurfaceDesc::ContactSurface, NLPACS::CCollisionSurfaceDesc::ContactTime, NLMISC::CAABBox::extend(), NLPACS::CExteriorMesh::getEdges(), getGridBounds(), NLPACS::CGlobalRetriever::getInstance(), NLPACS::CExteriorMesh::getLink(), NLMISC::CAABBox::getMax(), NLMISC::CAABBox::getMin(), NLPACS::CRetrieverInstance::getOrigin(), NLPACS::UGlobalPosition::InstanceId, len, NLPACS::UGlobalPosition::LocalPosition, NLMISC::CVector::maxof(), NLMISC::CVector::minof(), nlerror, nlinfo, nlwarning, NLPACS::CGlobalRetriever::retrievePosition(), NLPACS::CSurfaceIdent::RetrieverInstanceId, NLMISC::CAABBox::setCenter(), sint, sint32, NLPACS::ULocalPosition::Surface, NLPACS::CSurfaceIdent::SurfaceId, NLPACS::TCollisionSurfaceDescVector, NLPACS::CGlobalRetriever::testCylinderMove(), uint, uint16, uint32, uint8, NLPACS::CGlobalRetriever::updateHeight(), x, NLMISC::CVector::x, y, and NLMISC::CVector::y. +

+Referenced by NLPACS::CRetrieverInstance::initEdgeQuad(). +

+

00134 {
+00135         const std::vector<CExteriorMesh::CEdge> &edges = em.getEdges();
+00136 
+00137         vector< list<uint16> >  tempQuad;
+00138         sint                                    i, j;
+00139 
+00140         // first, clear any pr-build.
+00141         contReset(_Quad);
+00142         delete [] _QuadData;
+00143         _QuadData= NULL;
+00144         _QuadDataLen= 0;
+00145 
+00146         // don't care about the origin of the instance
+00147         CVector origin = global.getInstance(thisInstance).getOrigin();
+00148 
+00149         // 0. Find BBox of the grid. Allocate grid.
+00150         //=========================================
+00151         bool            first=true;
+00152         CAABBox         chainquadBBox;
+00153         // run all chains.
+00154         for (i=0; i<(sint)edges.size()-1; i++)
+00155         {
+00156                 // enlarge bbox.
+00157                 if (first)
+00158                         first= false, chainquadBBox.setCenter(edges[i].Start);
+00159                 else
+00160                         chainquadBBox.extend(edges[i].Start);
+00161         }
+00162 
+00163         // compute X,Y,Width, Height.
+00164         _X= (sint32)floor(chainquadBBox.getMin().x / _QuadElementSize);
+00165         _Y= (sint32)floor(chainquadBBox.getMin().y / _QuadElementSize);
+00166         _Width= (sint32)ceil(chainquadBBox.getMax().x / _QuadElementSize) - _X;
+00167         _Height= (sint32)ceil(chainquadBBox.getMax().y / _QuadElementSize) - _Y;
+00168 
+00169         tempQuad.resize(_Width*_Height);
+00170         _Quad.resize(_Width*_Height, NULL);
+00171 
+00172 
+00173         // 1. For each edge, add them to the quadgrid.
+00174         //=========================================
+00175         // run all chains.
+00176         for (i=0; i<(sint)edges.size()-1; i++)
+00177         {
+00178                 if (edges[i].Link == -2)
+00179                         continue;
+00180 
+00181                 float           dnorm = (edges[i+1].Start-edges[i].Start).norm();
+00182                 uint            numStep = (uint)(dnorm/0.1f)+1;
+00183                 uint            step;
+00184 
+00185                 CVector         pbegin = edges[i].Start+origin,
+00186                                         pend = edges[i+1].Start+origin;
+00187 
+00188                 CVector         opbegin = edges[i].Start,
+00189                                         opend = edges[i+1].Start;
+00190 
+00191                 for (step=0; step<numStep; ++step)
+00192                 {
+00193                         float           lambda0 = (float)(step)/(float)(numStep);
+00194                         float           lambda1 = (float)(step+1)/(float)(numStep);
+00195                         CVector         p0 = pbegin*(1.0f-lambda0)+pend*(lambda0),
+00196                                                 p1 = pbegin*(1.0f-lambda1)+pend*(lambda1);
+00197                         CVector         op0 = opbegin*(1.0f-lambda0)+opend*(lambda0),
+00198                                                 op1 = opbegin*(1.0f-lambda1)+opend*(lambda1);
+00199                         CVector         s0, s1,
+00200                                                 mins, maxs;
+00201 
+00202                         uint            prevEdge = (i-1)%(edges.size()-1);
+00203                         bool            prio0 = (edges[i].Link!=-1) || (edges[prevEdge].Link!=-1);
+00204 
+00205                         UGlobalPosition gp0 = global.retrievePosition(p0);
+00206                         global.updateHeight(gp0);
+00207                         UGlobalPosition gp1 = global.retrievePosition(p1);
+00208                         global.updateHeight(gp1);
+00209 
+00210                         if (!prio0)
+00211                         {
+00212                                 swap(p0, p1);
+00213                                 swap(op0, op1);
+00214                                 swap(gp0, gp1);
+00215                         }
+00216 
+00217                         if (gp0.InstanceId == -1)
+00218                         {
+00219                                 swap(p0, p1);
+00220                                 swap(op0, op1);
+00221                                 swap(gp0, gp1);
+00222                         }
+00223                         
+00224                         const TCollisionSurfaceDescVector       *pcd = global.testCylinderMove(gp0, p1-p0, 0.01f, cst);
+00225 
+00226                         if (pcd == NULL)
+00227                         {
+00228 //                              nlwarning("in CEdgeQuad::build(): testCylinderMove() returned NULL");
+00229                                 continue;
+00230                         }
+00231 
+00232                         TCollisionSurfaceDescVector     cd = (*pcd);
+00233 
+00234                         if (edges[i].Link != -1 && cd.size() > 0)
+00235                         {
+00236                                 nlwarning ("In NLPACS::CEdgeQuad::build()");
+00237                                 nlwarning ("ERROR: exterior edge %d with interior link crosses some surfaces", i);
+00238                                 cd.clear ();
+00239                         }
+00240 
+00241                         // add start surface to the collision description
+00242                         CCollisionSurfaceDesc   stcd;
+00243                         stcd.ContactTime = 0.0f;
+00244                         stcd.ContactSurface.RetrieverInstanceId = gp0.InstanceId;
+00245                         stcd.ContactSurface.SurfaceId = gp0.LocalPosition.Surface;
+00246                         cd.insert(cd.begin(), stcd);
+00247 
+00248                         // get the surface, chain ...
+00249                         sint    edgeId = i;
+00250                         uint16  chainId;
+00251 
+00252                         CSurfaceIdent   interior;
+00253                         if (edges[i].Link == -1)
+00254                         {
+00255                                 interior.RetrieverInstanceId = -1;
+00256                                 interior.SurfaceId = -1;
+00257                                 chainId = 0xFFFF;
+00258                         }
+00259                         else
+00260                         {
+00261                                 interior.RetrieverInstanceId = thisInstance;
+00262                                 interior.SurfaceId = em.getLink(edges[i].Link).SurfaceId;
+00263                                 chainId = em.getLink(edges[i].Link).ChainId;
+00264                         }
+00265 
+00266 
+00267                         // add end point to the collision description
+00268                         stcd = cd.back();
+00269                         stcd.ContactTime = 1.0f;
+00270                         cd.push_back(stcd);
+00271 
+00272                         for (j=0; j<(sint)cd.size()-1; ++j)
+00273                         {
+00274                                 s0 = op0*(float)(1.0-cd[j].ContactTime) + op1*(float)(cd[j].ContactTime);
+00275                                 s1 = op0*(float)(1.0-cd[j+1].ContactTime) + op1*(float)(cd[j+1].ContactTime);
+00276 
+00277                                 mins.minof(s0, s1);
+00278                                 maxs.maxof(s0, s1);
+00279 
+00280                                 // PrecisionPb: extend a little this edge. This is important for special case like borders on zones.
+00281                                 if(mins.x-maxs.x==0)
+00282                                         mins.x-=0.001f, maxs.x+=0.001f;
+00283                                 if(mins.y-maxs.y==0)
+00284                                         mins.y-=0.001f, maxs.y+=0.001f;
+00285 
+00286                                 // get bounding coordinate of this edge in the quadgrid.
+00287                                 sint32  x0, y0, x1, y1;
+00288                                 sint    x, y;
+00289                                 getGridBounds(x0, y0, x1, y1, mins, maxs);
+00290 
+00291                                 CSurfaceIdent   exterior = cd[j].ContactSurface;
+00292 
+00293                                 uint    entry;
+00294                                 for (entry=0; entry<_EdgeEntries.size(); ++entry)
+00295                                 {
+00296                                         if (_EdgeEntries[entry].EdgeId == edgeId &&
+00297                                                 _EdgeEntries[entry].Exterior == exterior)
+00298                                         {
+00299                                                 if (_EdgeEntries[entry].ChainId != chainId ||
+00300                                                         _EdgeEntries[entry].Interior != interior)
+00301                                                 {
+00302                                                         nlwarning("In NLPACS::CEdgeQuad::build()");
+00303                                                         nlerror("exterior edge %d has different interior linkage", edgeId);
+00304                                                 }
+00305 
+00306                                                 break;
+00307                                         }
+00308                                 }
+00309 
+00310                                 // if this entry didn't exist before create a new one...
+00311                                 if (entry == _EdgeEntries.size())
+00312                                 {
+00313                                         _EdgeEntries.push_back(CExteriorEdgeEntry());
+00314                                         _EdgeEntries.back().EdgeId = edgeId;
+00315                                         _EdgeEntries.back().ChainId = chainId;
+00316                                         _EdgeEntries.back().Interior = interior;
+00317                                         _EdgeEntries.back().Exterior = exterior;
+00318                                 }
+00319 
+00320                                 // add this edge to all the quadnode it touches.
+00321                                 for(y=y0; y<y1; y++)
+00322                                 {
+00323                                         for(x=x0; x<x1; x++)
+00324                                         {
+00325                                                 // check we don't push this entry twice
+00326                                                 list<uint16>::iterator  it;
+00327                                                 for (it=tempQuad[y*_Width+x].begin(); it!=tempQuad[y*_Width+x].end(); ++it)
+00328                                                         if (entry == *it)
+00329                                                                 break;
+00330                                                 if (it == tempQuad[y*_Width+x].end())
+00331                                                         tempQuad[y*_Width+x].push_back(entry);
+00332                                         }
+00333                                 }
+00334                         }
+00335                 }
+00336 
+00337         }
+00338 
+00339         nlinfo("Built ExteriorEdgeQuad, linked following doors:");
+00340         for (i=0; i<(sint)_EdgeEntries.size(); ++i)
+00341         {
+00342                 if (edges[_EdgeEntries[i].EdgeId].Link != -1 && 
+00343                         (_EdgeEntries[i].Interior.RetrieverInstanceId == -1 || _EdgeEntries[i].Interior.SurfaceId == -1 ||
+00344                          _EdgeEntries[i].Exterior.RetrieverInstanceId == -1 || _EdgeEntries[i].Exterior.SurfaceId == -1))
+00345                 {
+00346                         nlwarning("In NLPACS::CEdgeQuad::build(): exterior door %d has corrupted link", i);
+00347                 }
+00348                 else if (edges[_EdgeEntries[i].EdgeId].Link != -1)
+00349                 {
+00350                         nlinfo("Inst=%d ExtEdge=%d IntInst=%d IntSurf=%d IntChain=%d ExtInst=%d ExtSurf=%d", thisInstance, _EdgeEntries[i].EdgeId,
+00351                                 _EdgeEntries[i].Interior.RetrieverInstanceId, _EdgeEntries[i].Interior.SurfaceId, _EdgeEntries[i].ChainId,
+00352                                 _EdgeEntries[i].Exterior.RetrieverInstanceId, _EdgeEntries[i].Exterior.SurfaceId);
+00353                 }
+00354         }
+00355 
+00356         // 2. Mem optimisation: Use only 1 block for ALL quads of the grid.
+00357         //=========================================
+00358         sint    memSize= 0;
+00359         // run all quads.
+00360         for(i=0;i<(sint)tempQuad.size();i++)
+00361         {
+00362                 list<uint16>    &quadNode= tempQuad[i];
+00363 
+00364                 if(!quadNode.empty())
+00365                 {
+00366                         // add an entry for Len.
+00367                         memSize+= sizeof(uint16);
+00368                         // add N entry of CEdgeChainEntry.
+00369                         memSize+= quadNode.size()*sizeof(uint16);
+00370                 }
+00371         }
+00372 
+00373         // allocate.
+00374         _QuadData= (uint8*)new uint8[memSize];
+00375         _QuadDataLen= memSize;
+00376 
+00377 
+00378         // 3. Fill _QuadData with lists.
+00379         //=========================================
+00380         uint8   *ptr= _QuadData;
+00381         for(i=0;i<(sint)tempQuad.size();i++)
+00382         {
+00383                 list<uint16>                    &srcQuadNode= tempQuad[i];
+00384                 list<uint16>::iterator  it;
+00385 
+00386                 if(!srcQuadNode.empty())
+00387                 {
+00388                         _Quad[i]= ptr;
+00389 
+00390                         // write len.
+00391                         uint16  len= srcQuadNode.size();
+00392                         *((uint16*)ptr)= len;
+00393                         ptr+= sizeof(uint16);
+00394 
+00395                         // add entries.
+00396                         it= srcQuadNode.begin();
+00397                         for(j=0; j<len; j++, it++)
+00398                         {
+00399                                 *((uint16 *)ptr)= *it;
+00400                                 ptr+= sizeof(uint16);
+00401                         }
+00402                 }
+00403         }
+00404 
+00405         // End.
+00406 }
+
+

+ + + + +
+ + + + + + + + + +
void NLPACS::CEdgeQuad::clear  ) 
+
+ + + + + +
+   + + +

+clear +

+ +

+Definition at line 100 of file edge_quad.cpp. +

+References _EdgeEntries. +

+Referenced by NLPACS::CRetrieverInstance::reset(), and ~CEdgeQuad(). +

+

00101 {
+00102         delete [] _QuadData;
+00103         _QuadData= NULL;
+00104         _QuadDataLen= 0;
+00105 
+00106         _Quad.clear();
+00107         _EdgeEntries.clear();
+00108         _Width = 0;
+00109         _Height = 0;
+00110         _X = 0;
+00111         _Y = 0;
+00112 }
+
+

+ + + + +
+ + + + + + + + + +
const std::vector<CExteriorEdgeEntry>& NLPACS::CEdgeQuad::getEdgeEntries  )  const [inline]
+
+ + + + + +
+   + + +

+Get the whole set of edge entries. +

+ +

+Definition at line 104 of file edge_quad.h. +

+References _EdgeEntries. +

+Referenced by NLPACS::CRetrieverInstance::linkEdgeQuad(). +

+

00104 { return _EdgeEntries; }
+
+

+ + + + +
+ + + + + + + + + + +
const CExteriorEdgeEntry& NLPACS::CEdgeQuad::getEdgeEntry uint  entry  )  const [inline]
+
+ + + + + +
+   + + +

+Get a single edge entry. +

+ +

+Definition at line 106 of file edge_quad.h. +

+References _EdgeEntries, and uint. +

+Referenced by NLPACS::CRetrieverInstance::testExteriorCollision(). +

+

00106 { return _EdgeEntries[entry]; }
+
+

+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
void NLPACS::CEdgeQuad::getGridBounds sint32 x0,
sint32 y0,
sint32 x1,
sint32 y1,
const CVector minP,
const CVector maxP
const [private]
+
+ + + + + +
+   + + +

+ +

+Definition at line 115 of file edge_quad.cpp. +

+References min, sint32, NLMISC::CVector::x, and NLMISC::CVector::y. +

+Referenced by build(), and selectEdges(). +

+

00116 {
+00117         x0= (sint32)floor(minP.x / _QuadElementSize) - _X;
+00118         y0= (sint32)floor(minP.y / _QuadElementSize) - _Y;
+00119         x1= (sint32) ceil(maxP.x / _QuadElementSize) - _X;
+00120         y1= (sint32) ceil(maxP.y / _QuadElementSize) - _Y;
+00121         x0= max(x0, (sint32)0);
+00122         y0= max(y0, (sint32)0);
+00123         x1= min(x1, (sint32)_Width);
+00124         y1= min(y1, (sint32)_Height);
+00125 }
+
+

+ + + + +
+ + + + + + + + + + +
CEdgeQuad & NLPACS::CEdgeQuad::operator= const CEdgeQuad o  ) 
+
+ + + + + +
+   + + +

+operator=. +

+ +

+Definition at line 62 of file edge_quad.cpp. +

+References _EdgeEntries, _Height, _Quad, _QuadData, _QuadDataLen, _Width, _X, _Y, sint, uint32, and uint8. +

+

00063 {
+00064         // Alloc good quaddata.
+00065         _QuadDataLen= o._QuadDataLen;
+00066         delete [] _QuadData;
+00067         if(_QuadDataLen>0)
+00068         {
+00069                 _QuadData= (uint8*)new uint8[_QuadDataLen];
+00070                 // copy contents.
+00071                 memcpy(_QuadData, o._QuadData, _QuadDataLen);
+00072         }
+00073         else
+00074                 _QuadData= NULL;
+00075 
+00076         // copy infos.
+00077         _Width= o._Width;
+00078         _Height= o._Height;
+00079         _X= o._X;
+00080         _Y= o._Y;
+00081         _EdgeEntries = o._EdgeEntries;
+00082 
+00083         // copy good pointers.
+00084         _Quad.clear();
+00085         _Quad.resize(o._Quad.size(), NULL);
+00086         for(sint i=0; i<(sint)_Quad.size(); i++)
+00087         {
+00088                 if(o._Quad[i])
+00089                 {
+00090                         uint32  off= (uint32)(o._Quad[i]-o._QuadData);
+00091                         _Quad[i]= _QuadData+off;
+00092                 }
+00093         }
+00094 
+00095 
+00096         return *this;
+00097 }
+
+

+ + + + +
+ + + + + + + + + +
void NLPACS::CEdgeQuad::removeLinks  )  [inline]
+
+ + + + + +
+   + + +

+ +

+Definition at line 127 of file edge_quad.h. +

+References _EdgeEntries, and uint. +

+

00128         {
+00129                 uint    i;
+00130                 for (i=0; i<_EdgeEntries.size(); ++i)
+00131                 {
+00132                         _EdgeEntries[i].Exterior.RetrieverInstanceId = -1;
+00133                         _EdgeEntries[i].Exterior.SurfaceId = -1;
+00134                 }
+00135         }
+
+

+ + + + +
+ + + + + + + + + + +
void NLPACS::CEdgeQuad::removeLinks sint32  instanceId  )  [inline]
+
+ + + + + +
+   + + +

+ +

+Definition at line 113 of file edge_quad.h. +

+References _EdgeEntries, sint32, and uint. +

+Referenced by NLPACS::CRetrieverInstance::resetLinks(). +

+

00114         {
+00115                 uint    i;
+00116                 for (i=0; i<_EdgeEntries.size(); ++i)
+00117                 {
+00118                         if (_EdgeEntries[i].Exterior.RetrieverInstanceId == instanceId)
+00119                         {
+00120                                 _EdgeEntries[i].Exterior.RetrieverInstanceId = -1;
+00121                                 _EdgeEntries[i].Exterior.SurfaceId = -1;
+00122                         }
+00123                 }
+00124         }
+
+

+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + +
sint NLPACS::CEdgeQuad::selectEdges CVector  start,
CVector  end,
CCollisionSurfaceTemp cst
const
+
+ + + + + +
+   + + +

+look in the quad to select a list of chain from a line. NB: The outpout do not contains any redundant edge. An edge appears only one time in the result.

Parameters:
+ + + + +
start the starting point of the selection segment.
end the ending point of the selection segment.
cst the array of CExteriorEdgeEntry to fill. contain also OChainLUT, an array for internal use. In: must be filled with 0xFFFF. Out: still filled with 0xFFFF.
+
+
Returns:
number of exterioredge found. stored in cst.ExteriorEdgeEntries (array cleared first).
+ +

+Definition at line 465 of file edge_quad.cpp. +

+References NLPACS::CCollisionSurfaceTemp::ExteriorEdgeIndexes, index, NLPACS::CCollisionSurfaceTemp::OChainLUT, sint, sint32, uint16, uint8, x, NLMISC::CVector::x, y, and NLMISC::CVector::y. +

+

00466 {
+00467         sint    nRes=0;
+00468         sint    i;
+00469         uint16  *indexLUT= cst.OChainLUT;
+00470 
+00471         // start: no edge found.
+00472         cst.ExteriorEdgeIndexes.clear();
+00473 
+00474         if (end.x < start.x)
+00475                 swap(start, end);
+00476 
+00477         float   minx = _X*_QuadElementSize,
+00478                         miny = _Y*_QuadElementSize,
+00479                         maxx = minx + _Width*_QuadElementSize,
+00480                         maxy = miny + _Height*_QuadElementSize;
+00481 
+00482         if (start.x > maxx || end.x < minx || start.y > maxy || end.y < miny)
+00483                 return nRes;
+00484 
+00485         if (start.x < minx)
+00486         {
+00487                 start.y = start.y+(end.y-start.y)*(minx-start.x)/(end.x-start.x);
+00488                 start.x = minx;
+00489         }
+00490 
+00491         if (start.y < miny)
+00492         {
+00493                 start.x = start.x+(end.x-start.x)*(miny-start.y)/(end.y-start.y);
+00494                 start.y = miny;
+00495         }
+00496 
+00497         if (end.x > maxx)
+00498         {
+00499                 end.y = start.y+(end.y-start.y)*(minx-start.x)/(end.x-start.x);
+00500                 end.x = maxx;
+00501         }
+00502 
+00503         if (end.y > maxy)
+00504         {
+00505                 end.x = start.x+(end.x-start.x)*(miny-start.y)/(end.y-start.y);
+00506                 end.y = maxy;
+00507         }
+00508 
+00509         sint32  x0, x1, ya, yb;
+00510         sint    x, y;
+00511         float   fx, fxa, fxb, fya, fyb;
+00512 
+00513         x0 = (sint32)floor(start.x / _QuadElementSize) - _X;
+00514         x1 = (sint32)ceil(end.x / _QuadElementSize) - _X;
+00515         fx = (x0+_X)*_QuadElementSize;
+00516 
+00517         for (x=x0; x<x1; ++x)
+00518         {
+00519                 fxa = (fx < start.x) ? start.x : fx;
+00520                 fxb = (fx+_QuadElementSize > end.x) ? end.x : fx+_QuadElementSize;
+00521 
+00522                 fya = start.y+(end.y-start.y)*(fxa-start.x)/(end.x-start.x);
+00523                 fyb = start.y+(end.y-start.y)*(fxb-start.x)/(end.x-start.x);
+00524 
+00525                 if (fya > fyb)
+00526                         swap (fya, fyb);
+00527 
+00528                 ya = (sint32)floor(fya / _QuadElementSize) - _Y;
+00529                 yb = (sint32)ceil(fyb / _QuadElementSize) - _Y;
+00530 
+00531                 fx += _QuadElementSize;
+00532 
+00533                 for (y=ya; y<yb; ++y)
+00534                 {
+00535                         uint8   *quadNode= _Quad[y*_Width+x];
+00536 
+00537                         // no edgechain entry??
+00538                         if(!quadNode)
+00539                                 continue;
+00540 
+00541                         // get edgechain entries
+00542                         sint    numExteriorEdgeIndexes= *((uint16 *)quadNode);
+00543                         quadNode+= sizeof(uint16);
+00544                         uint16  *ptrExteriorEdgeIndex = (uint16 *)quadNode;
+00545 
+00546                         // For each one, add it to the result list.
+00547                         for(i=0;i<numExteriorEdgeIndexes;i++)
+00548                         {
+00549                                 uint16  index = ptrExteriorEdgeIndex[i];
+00550 
+00551                                 // if ochain not yet inserted.
+00552                                 if(indexLUT[index]==0xFFFF)
+00553                                 {
+00554                                         // inc the list.
+00555                                         indexLUT[index]= nRes;
+00556                                         cst.ExteriorEdgeIndexes.push_back(ptrExteriorEdgeIndex[i]);
+00557                                         nRes++;
+00558                                 }
+00559                         }
+00560                 }
+00561         }
+00562 
+00563         // reset LUT to 0xFFFF for all ochains selected.
+00564         for(i=0;i<nRes;i++)
+00565                 indexLUT[cst.ExteriorEdgeIndexes[i]]= 0xFFFF;
+00566 
+00567         return nRes;
+00568 }
+
+

+ + + + +
+ + + + + + + + + + + + + + + + + + + +
sint NLPACS::CEdgeQuad::selectEdges const NLMISC::CAABBox bbox,
CCollisionSurfaceTemp cst
const
+
+ + + + + +
+   + + +

+look in the quad to select a list of chain from a bbox. NB: The outpout do not contains any redundant edge. An edge appears only one time in the result.

Parameters:
+ + + +
bbox the area of interest.
cst the array of CExteriorEdgeEntry to fill. contain also OChainLUT, an array for internal use. In: must be filled with 0xFFFF. Out: still filled with 0xFFFF.
+
+
Returns:
number of exterioredge found. stored in cst.ExteriorEdgeEntries (array cleared first).
+ +

+Definition at line 410 of file edge_quad.cpp. +

+References NLPACS::CCollisionSurfaceTemp::ExteriorEdgeIndexes, getGridBounds(), NLMISC::CAABBox::getMax(), NLMISC::CAABBox::getMin(), index, NLPACS::CCollisionSurfaceTemp::OChainLUT, sint, sint32, uint16, uint8, x, and y. +

+Referenced by NLPACS::CRetrieverInstance::testExteriorCollision(). +

+

00411 {
+00412         sint    nRes=0;
+00413         sint    i;
+00414         uint16  *indexLUT = cst.OChainLUT;
+00415 
+00416         // start: no edge found.
+00417         cst.ExteriorEdgeIndexes.clear();
+00418 
+00419         // get bounding coordinate of this bbox in the quadgrid.
+00420         sint32  x0, y0, x1, y1;
+00421         getGridBounds(x0, y0, x1, y1, bbox.getMin(), bbox.getMax());
+00422 
+00423 
+00424         // run all intersected quads.
+00425         for (sint y= y0; y<y1; y++)
+00426         {
+00427                 for (sint x= x0; x<x1; x++)
+00428                 {
+00429                         uint8   *quadNode= _Quad[y*_Width+x];
+00430 
+00431                         // no edgechain entry??
+00432                         if(!quadNode)
+00433                                 continue;
+00434 
+00435                         // get edgechain entries
+00436                         sint    numExteriorEdgeIndexes= *((uint16*)quadNode);
+00437                         quadNode+= sizeof(uint16);
+00438                         uint16  *ptrExteriorEdgeIndex= (uint16*)quadNode;
+00439 
+00440                         // For each one, add it to the result list.
+00441                         for (i=0;i<numExteriorEdgeIndexes;i++)
+00442                         {
+00443                                 uint16  index = ptrExteriorEdgeIndex[i];
+00444 
+00445                                 // if ochain not yet inserted.
+00446                                 if (indexLUT[index]==0xFFFF)
+00447                                 {
+00448                                         // inc the list.
+00449                                         indexLUT[index]= nRes;
+00450                                         cst.ExteriorEdgeIndexes.push_back(index);
+00451                                         nRes++;
+00452                                 }
+00453                         }
+00454                 }
+00455         }
+00456 
+00457 
+00458         // reset LUT to 0xFFFF for all ochains selected.
+00459         for(i=0;i<nRes;i++)
+00460                 indexLUT[cst.ExteriorEdgeIndexes[i]]= 0xFFFF;
+00461 
+00462         return nRes;
+00463 }
+
+

+ + + + +
+ + + + + + + + + + +
void NLPACS::CEdgeQuad::serial NLMISC::IStream f  ) 
+
+ + + + + +
+   + + +

+serial. +

+ +

+Definition at line 571 of file edge_quad.cpp. +

+References _EdgeEntries, NLMISC::IStream::isReading(), len, NLMISC::IStream::serial(), NLMISC::IStream::serialCont(), NLMISC::IStream::serialVersion(), uint, uint16, uint32, and uint8. +

+

00572 {
+00573         /*
+00574         Version 0:
+00575                 - base version.
+00576         */
+00577         (void)f.serialVersion(0);
+00578         uint    i;
+00579 
+00580         // serial basics.
+00581         f.serial(_X, _Y, _Width, _Height, _QuadDataLen);
+00582         f.serialCont(_EdgeEntries);
+00583 
+00584         // serial _QuadData.
+00585         if(f.isReading())
+00586         {
+00587                 delete [] _QuadData;
+00588                 if(_QuadDataLen>0)
+00589                         _QuadData= (uint8*)new uint8[_QuadDataLen];
+00590                 else
+00591                         _QuadData= NULL;
+00592         }
+00593         // Since we have only uint16 (see CEdgeChainEntry), serial them in a single block.
+00594         uint16  *ptrQData= (uint16*)_QuadData;
+00595         for(i=0;i<_QuadDataLen/2; i++, ptrQData++)
+00596         {
+00597                 f.serial(*ptrQData);
+00598         }
+00599 
+00600 
+00601         // serial _Quad.
+00602         std::vector<uint32>             offsets;
+00603         uint32          len;
+00604         uint32          val;
+00605         if(f.isReading())
+00606         {
+00607                 // len/resize.
+00608                 f.serial(len);
+00609                 offsets.resize(len);
+00610                 contReset(_Quad);
+00611                 _Quad.resize(len);
+00612 
+00613                 // read offsets -> ptrs.
+00614                 for(i=0; i<len; i++)
+00615                 {
+00616                         f.serial(val);
+00617                         if(val== 0xFFFFFFFF)
+00618                                 _Quad[i]= NULL;
+00619                         else
+00620                                 _Quad[i]= _QuadData+val;
+00621                 }
+00622         }
+00623         else
+00624         {
+00625                 // len/resize.
+00626                 len= _Quad.size();
+00627                 f.serial(len);
+00628 
+00629                 // write offsets.
+00630                 for(i=0; i<len; i++)
+00631                 {
+00632                         uint8   *ptr= _Quad[i];
+00633                         if(ptr==NULL)
+00634                                 val= 0xFFFFFFFF;
+00635                         else
+00636                                 val= (uint32)(ptr-_QuadData);
+00637                         f.serial(val);
+00638                 }
+00639         }
+00640 
+00641 }
+
+


Field Documentation

+

+ + + + +
+ + +
std::vector<CExteriorEdgeEntry> NLPACS::CEdgeQuad::_EdgeEntries [private] +
+
+ + + + + +
+   + + +

+The real exterior edge entries. +

+ +

+Definition at line 145 of file edge_quad.h. +

+Referenced by build(), clear(), getEdgeEntries(), getEdgeEntry(), operator=(), removeLinks(), and serial().

+

+ + + + +
+ + +
uint32 NLPACS::CEdgeQuad::_Height [private] +
+
+ + + + + +
+   + + +

+Height of the quadgrid. +

+ +

+Definition at line 149 of file edge_quad.h. +

+Referenced by operator=().

+

+ + + + +
+ + +
std::vector<uint8*> NLPACS::CEdgeQuad::_Quad [private] +
+
+ + + + + +
+   + + +

+W*H pointers on array of CExteriorEdgeEntry indexes. NULL if no edge in this quad. Each array is 1xuint16(LEN) + LEN*CExteriorEdgeEntryIndex(16 bits). +

+Definition at line 143 of file edge_quad.h. +

+Referenced by operator=().

+

+ + + + +
+ + +
uint8* NLPACS::CEdgeQuad::_QuadData [private] +
+
+ + + + + +
+   + + +

+Single memory block of CExteriorEdgeEntry chains. +

+ +

+Definition at line 153 of file edge_quad.h. +

+Referenced by operator=().

+

+ + + + +
+ + +
uint32 NLPACS::CEdgeQuad::_QuadDataLen [private] +
+
+ + + + + +
+   + + +

+size (in byte) of _QuadData. +

+ +

+Definition at line 155 of file edge_quad.h. +

+Referenced by operator=().

+

+ + + + +
+ + +
const float NLPACS::CEdgeQuad::_QuadElementSize = 4 [static, private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 40 of file edge_quad.cpp.

+

+ + + + +
+ + +
uint32 NLPACS::CEdgeQuad::_Width [private] +
+
+ + + + + +
+   + + +

+Width of the quadgrid. +

+ +

+Definition at line 147 of file edge_quad.h. +

+Referenced by operator=().

+

+ + + + +
+ + +
sint32 NLPACS::CEdgeQuad::_X [private] +
+
+ + + + + +
+   + + +

+Postion of the chainquad. +

+ +

+Definition at line 151 of file edge_quad.h. +

+Referenced by operator=().

+

+ + + + +
+ + +
sint32 NLPACS::CEdgeQuad::_Y [private] +
+
+ + + + + +
+   + + +

+Postion of the chainquad. +

+ +

+Definition at line 151 of file edge_quad.h. +

+Referenced by operator=().

+


The documentation for this class was generated from the following files: +
Generated on Tue Mar 16 14:12:46 2004 for NeL by + +doxygen +1.3.6
+ + -- cgit v1.2.1