17 #include "Base/DataStructures/Graph/GraphProcessor.h"
18 #include "Base/Math/MathTools.h"
19 #include "Helpers/helpers.h"
30 m_nNumberNodes = pGraph->
getNodes()->size();
32 m_nWidth = (int)
sqrt(
float(m_nNumberNodes));
33 m_nHeight = m_nNumberNodes / m_nWidth + 1;
35 m_bUseLookup = bUseLookup;
41 m_pLookupTable->buildLookupTable(pGraph);
45 m_pMap =
new CFloatMatrix(m_nWidth, m_nHeight);
59 delete m_pLookupTable;
74 m_nWidth = pMap->columns;
75 m_nHeight = pMap->rows;
108 applyGaussian(nOperation, coord, fAmplitude, fVariance);
121 nNodeID = m_pLookupTable->getClosestNode(coord);
128 applyGaussian(nOperation, nNodeID, fAmplitude, fVariance);
135 vector<int> accomplished;
138 int nFirstNode = nNodeID;
139 TSphereCoord coord = m_pGraph->getNodes()->at(nFirstNode)->getPosition();
140 nodes.push_back(nFirstNode);
148 while (nodes.size() > 0)
151 int nCurrentNode = nodes.front();
153 accomplished.push_back(nCurrentNode);
156 cur_sc = m_pGraph->getNodes()->at(nCurrentNode)->getPosition();
158 float fAngle = Math3d::Angle(ref, cur);
161 if (fAngle > 2.0 * fVariance)
167 fIntensity = evaluateGaussian(fAngle, fAmplitude, fVariance);
173 m_pMap->data[nCurrentNode] = fIntensity;
177 m_pMap->data[nCurrentNode] += fIntensity;
181 m_pMap->data[nCurrentNode] *= fIntensity;
185 if (m_pMap->data[nCurrentNode] < fIntensity)
187 m_pMap->data[nCurrentNode] = fIntensity;
193 printf(
"Illegal operation\n");
198 vector<int>* pAdjacency = m_pGraph->getNodeAdjacency(nCurrentNode);
203 for (
int a = 0;
a < int(pAdjacency->size());
a++)
205 nAdjNode = pAdjacency->at(
a);
208 bool bNewNode =
true;
210 for (
int c = 0;
c < int(accomplished.size());
c++)
211 if (accomplished.at(
c) == nAdjNode)
216 list<int>::iterator iter = nodes.begin();
218 while (iter != nodes.end())
220 if (*iter == nAdjNode)
231 nodes.push_back(nAdjNode);
250 CGraphMap::evaluateGaussian(
float fDist,
float fAmplitude,
float fVariance)
252 return exp(-(fDist / fVariance * 2.0f)) * fAmplitude;
260 for (
int n = 0; n < m_nNumberNodes; n++)
262 fIntensity = m_pMap->data[n];
263 ((
CIntensityNode*)m_pGraph->getNodes()->at(n))->setIntensity(fIntensity);
272 for (
int n = 0; n < m_nNumberNodes; n++)
274 fIntensity = ((
CIntensityNode*)m_pGraph->getNodes()->at(n))->getIntensity();
275 m_pMap->data[n] = fIntensity;