GrahamScan::GrahamScan(voro::voronoicell_neighbor& voro_cell, unsigned int cellID, double* partPos) { vector<double> vv; double x1[2], x2[2]; set<SPoint> pointset; //Iterate over the voro++ structure and produce unique points on the contour. voro_cell.vertices(partPos[3*(cellID-1)],partPos[3*(cellID-1)+1],partPos[3*(cellID-1)+2],vv); for (int ii = 0; ii < voro_cell.p; ii++) { for (int jj = 0; jj < voro_cell.nu[ii]; jj++) { int k = voro_cell.ed[ii][jj]; x1[0] = vv[3 * ii]; x1[1] = vv[3 * ii + 1]; x2[0] = vv[3 * k]; x2[1] = vv[3 * k + 1]; pointset.insert(SPoint(x1[1], x1[0], 0, 1)); pointset.insert(SPoint(x2[1], x2[0], 0, 1)); } } std::copy(pointset.begin(), pointset.end(), std::back_inserter(m_sortedPoints)); ComparisonFunctor comparator; comparator.compareReference = &(*pointset.begin()); vector<SPoint>::iterator start = m_sortedPoints.begin(); start++; sort(start, m_sortedPoints.end(), comparator); }
// initializes the receiver with information taken from the specified fully computed Voronoi cell void init(voro::voronoicell_neighbor& cell) { // copy basic geometric info double cx, cy, cz; cell.centroid(cx,cy,cz); _c = Vec(cx,cy,cz) + _r; _volume = cell.volume(); // get the minimal and maximal coordinates of the box enclosing the cell vector<double> coords; cell.vertices(_r.x(),_r.y(),_r.z(), coords); _xmin = DBL_MAX; _ymin = DBL_MAX; _zmin = DBL_MAX; _xmax = -DBL_MAX; _ymax = -DBL_MAX; _zmax = -DBL_MAX; int n = coords.size(); for (int i=0; i<n; i+=3) { _xmin = min(_xmin,coords[i]); _ymin = min(_ymin,coords[i+1]); _zmin = min(_zmin,coords[i+2]); _xmax = max(_xmax,coords[i]); _ymax = max(_ymax,coords[i+1]); _zmax = max(_zmax,coords[i+2]); } // copy a list of neighboring cell/particle ids cell.neighbors(_neighbors); }