38 const Point3D &axisDir,
float distMax, vector<unsigned int> &histogram)
40 ASSERT(fabs(axisDir.
sqrMag() -1.0f) < sqrt(std::numeric_limits<float>::epsilon()));
41 ASSERT(!histogram.empty());
43 std::fill(histogram.begin(),histogram.end(),0);
51 float maxSqrDist = distMax*distMax;
54 vector<vector<unsigned int> > threadHistograms;
55 threadHistograms.resize(omp_get_num_threads());
56 for(
unsigned int ui=0;ui<threadHistograms.size();ui++)
58 threadHistograms[ui].resize(histogram.size(),0);
66 #pragma omp parallel for 67 for(
unsigned int ui=0; ui<pointList.size(); ui++)
73 vector<size_t> inSphereIdx;
75 sourcePoint=pointList[ui];
78 tree.
ptsInSphere(sourcePoint, distMax, inSphereIdx);
82 for(
size_t uj=0;uj<inSphereIdx.size();uj++)
88 sqrDist = nearPt.
sqrDist(sourcePoint);
94 if(sqrDist == 0.0f || sqrDist >= maxSqrDist)
101 distance=(nearPt-sourcePoint).dotProd(axisDir);
107 int offset=(int)(((0.5f*distance)/distMax+0.5f)*(
float)histogram.size());
108 if(offset < (
int)histogram.size() && offset >=0)
111 threadHistograms[omp_get_thread_num()][offset]++;
121 for(
unsigned int ui=0;ui<threadHistograms.size();ui++)
123 for(
unsigned int uj=0;uj<histogram.size();uj++)
124 histogram[uj]+=threadHistograms[ui][uj];
132 float distMax,
float dTheta,
float dPhi,
ProgressBar &p,
133 vector<vector<vector<unsigned int> > > &histogram)
135 ASSERT(!histogram.empty());
139 if(pointList.empty())
145 float maxSqrDist = distMax*distMax;
147 const size_t NUM_THETA=histogram.size();
148 const size_t NUM_PHI=histogram[0].size();
149 const size_t DIST_BINS=histogram[0][0].size();
152 unsigned int *hist =
new unsigned int[NUM_THETA*NUM_PHI*DIST_BINS];
153 memset(hist,0,NUM_THETA*NUM_PHI*DIST_BINS*
sizeof(
unsigned int));
156 for(
size_t ui=0;ui<NUM_THETA;ui++)
157 axisDir[ui] =
new Point3D[NUM_PHI];
160 for(
size_t ui=0; ui<NUM_THETA; ui++)
162 for(
size_t uj=0; uj<NUM_PHI; uj++)
164 float tmpPhi,tmpTheta;
175 ASSERT(fabs(acos(axisDir[ui][uj][2]) - tmpTheta) < 0.001);
184 #pragma omp parallel for schedule(dynamic) 185 for(
unsigned int uSrcPt=0; uSrcPt<pointList.size(); uSrcPt++)
188 sourcePoint=pointList[uSrcPt];
192 vector<size_t> inSphereIdx;
193 tree.
ptsInSphere(sourcePoint,distMax, inSphereIdx);
199 for(
size_t uPt=0; uPt<inSphereIdx.size(); uPt++)
206 sqrDist = nearPt.
sqrDist(sourcePoint);
214 if(sqrDist < maxSqrDist)
217 deltaPt=nearPt-sourcePoint;
219 for(
size_t ui=0; ui<NUM_THETA; ui++)
221 for(
size_t uj=0; uj<NUM_PHI; uj++)
228 distance=deltaPt.
dotProd(axisDir[ui][uj]);
231 offset=(int)(((0.5f*distance)/distMax+0.5f)*(float)DIST_BINS);
232 if(offset >=0 && offset < (
int)DIST_BINS)
235 hist[ui*DIST_BINS*NUM_PHI + uj*DIST_BINS+ offset]++;
243 if(!omp_get_thread_num())
245 p.
update((
float)uSrcPt/(
float)pointList.size()*100.0f);
248 for(
unsigned int ui=0;ui<histogram.size();ui++)
250 for(
unsigned int uj=0;uj<histogram[ui].size();uj++)
252 for(
unsigned int uk=0;uk<histogram[ui][uj].size();uk++)
254 histogram[ui][uj][uk]=hist[ui*DIST_BINS*NUM_PHI + uj*DIST_BINS+ uk];
262 for(
size_t ui=0;ui<NUM_THETA;ui++)
263 delete[] axisDir[ui];
float sqrDist(const Point3D &pt) const
Returns the square of distance to another Point3D.
unsigned int generate1DAxialDistHistSweep(const std::vector< Point3D > &pointList, K3DTreeExact &tree, float distMax, float dTheta, float dPhi, AtomProbe::ProgressBar &prog, std::vector< std::vector< std::vector< unsigned int > > > &histogram)
Generate a series of 1D distribution functions, one per pixel in a 2D grid of spherical coordinate di...
float sqrMag() const
Returns magnitude^2, taking this as a position vector.
A 3D point data class storage.
void setISOSpherical(float radius, float theta, float phi)
Assign the vector using spherical coordinates.
unsigned int generate1DAxialDistHist(const std::vector< Point3D > &pointList, K3DTreeExact &tree, const Point3D &axisDir, float distMax, std::vector< unsigned int > &histogram)
Generate a 1D axial distribution function,.
Helper class to define a bounding cube.
float dotProd(const Point3D &pt) const
Calculate the dot product of this and another point.
void update(unsigned int newProgress)
Draw the progress bar as needed, using the given progress value [0,100].
const Point3D & getPtRef(size_t index) const
void ptsInSphere(const Point3D &origin, float radius, std::vector< size_t > &pts) const
void setBounds(float xMin, float yMin, float zMin, float xMax, float yMax, float zMax)
Set the bounds by passing in minima and maxima of each dimension.