14 #include "Base/Math/MathTools.h"
15 #include "Base/DataStructures/Graph/GraphProcessor.h"
17 #include "Helpers/helpers.h"
28 m_nNumberNodes = pGraph->
getNodes()->size();
30 m_nWidth = (int)
sqrt(
float(m_nNumberNodes));
31 m_nHeight = m_nNumberNodes / m_nWidth + 1;
33 m_bUseLookup = bUseLookup;
39 m_pLookupTable->buildLookupTable(pGraph);
43 m_pMap =
new CFloatMatrix(m_nWidth, m_nHeight);
57 delete m_pLookupTable;
71 m_nWidth = pMap->columns;
72 m_nHeight = pMap->rows;
101 applyGaussian(nOperation, coord, fAmplitude, fVariance);
110 nNodeID = m_pLookupTable->getClosestNode(coord);
117 applyGaussian(nOperation, nNodeID, fAmplitude, fVariance);
123 vector<int> accomplished;
126 int nFirstNode = nNodeID;
127 TSphereCoord coord = m_pGraph->getNodes()->at(nFirstNode)->getPosition();
128 nodes.push_back(nFirstNode);
136 while (nodes.size() > 0)
139 int nCurrentNode = nodes.front();
141 accomplished.push_back(nCurrentNode);
144 cur_sc = m_pGraph->getNodes()->at(nCurrentNode)->getPosition();
146 float fAngle = Math3d::Angle(ref, cur);
149 if (fAngle > 2.0 * fVariance)
155 fIntensity = evaluateGaussian(fAngle, fAmplitude, fVariance);
161 m_pMap->data[nCurrentNode] = fIntensity;
165 m_pMap->data[nCurrentNode] += fIntensity;
169 m_pMap->data[nCurrentNode] *= fIntensity;
173 if (m_pMap->data[nCurrentNode] < fIntensity)
175 m_pMap->data[nCurrentNode] = fIntensity;
181 printf(
"Illegal operation\n");
186 vector<int>* pAdjacency = m_pGraph->getNodeAdjacency(nCurrentNode);
191 for (
int a = 0 ;
a < int(pAdjacency->size()) ;
a++)
193 nAdjNode = pAdjacency->at(
a);
196 bool bNewNode =
true;
198 for (
int c = 0 ;
c < int(accomplished.size()) ;
c++)
199 if (accomplished.at(
c) == nAdjNode)
204 list<int>::iterator iter = nodes.begin();
206 while (iter != nodes.end())
208 if (*iter == nAdjNode)
219 nodes.push_back(nAdjNode);
235 float CGraphMap::evaluateGaussian(
float fDist,
float fAmplitude,
float fVariance)
237 return exp(- (fDist / fVariance * 2.0f)) * fAmplitude;
240 void CGraphMap::toGraph()
244 for (
int n = 0 ; n < m_nNumberNodes ; n++)
246 fIntensity = m_pMap->data[n];
247 ((
CIntensityNode*) m_pGraph->getNodes()->at(n))->setIntensity(fIntensity);
251 void CGraphMap::toMap()
255 for (
int n = 0 ; n < m_nNumberNodes ; n++)
257 fIntensity = ((
CIntensityNode*) m_pGraph->getNodes()->at(n))->getIntensity();
258 m_pMap->data[n] = fIntensity;