void FindContourSurface::finishAveraging() { ContourFindingBase::finishAveraging(); // And update the list of active grid points if( gbuffer>0 ) { std::vector<double> dx( ingrid->getGridSpacing() ); std::vector<double> point( ingrid->getDimension() ); std::vector<double> lpoint( mygrid->getDimension() ); std::vector<unsigned> neighbours; unsigned num_neighbours; std::vector<unsigned> ugrid_indices( ingrid->getDimension() ); std::vector<bool> active( ingrid->getNumberOfPoints(), false ); std::vector<unsigned> gbuffer_vec( ingrid->getDimension(), gbuffer ); for(unsigned i=0; i<mygrid->getNumberOfPoints(); ++i) { // Retrieve the coordinates of this grid point mygrid->getGridPointCoordinates( i, lpoint ); point[dir_n] = mygrid->getGridElement( i, 0 ); // 0.5*dx added here to prevent problems with flooring of grid points for(unsigned j=0; j<gdirs.size(); ++j) point[gdirs[j]]=lpoint[j] + 0.5*dx[gdirs[j]]; ingrid->getIndices( point, ugrid_indices ); // Now activate buffer region ingrid->getNeighbors( ugrid_indices, gbuffer_vec, num_neighbours, neighbours ); for(unsigned n=0; n<num_neighbours; ++n) active[ neighbours[n] ]=true; } ingrid->activateThesePoints( active ); } firsttime=false; }
lpoint GetCoord(int index){ if(recieved){ return pointers[index]; } return lpoint(-1,-1,-1); }
static void lineTwoStep(int x0, int y0, int x1, int y1) { int dy = y1 - y0; int dx = x1 - x0; int stepx, stepy; if (dy < 0) { dy = -dy; stepy = -1; } else { stepy = 1; } if (dx < 0) { dx = -dx; stepx = -1; } else { stepx = 1; } lpoint(x0,y0); if (dx == 0 && dy == 0) /* following algorithm won't work */ return; /* just the one dot */ lpoint(x1, y1); if (dx > dy) { int length = (dx - 1) >> 2; int extras = (dx - 1) & 3; int incr2 = (dy << 2) - (dx << 1); if (incr2 < 0) { int c = dy << 1; int incr1 = c << 1; int d = incr1 - dx; int i; for (i = 0; i < length; i++) { x0 += stepx; x1 -= stepx; if (d < 0) { /* Pattern: */ lpoint(x0, y0); lpoint(x0 += stepx, y0); /* x o o */ lpoint(x1, y1); lpoint(x1 -= stepx, y1); d += incr1; } else { if (d < c) { /* Pattern: */ lpoint(x0, y0); /* o */ lpoint(x0 += stepx, y0 += stepy); /* x o */ lpoint(x1, y1); lpoint(x1 -= stepx, y1 -= stepy); } else { lpoint(x0, y0 += stepy); /* Pattern: */ lpoint(x0 += stepx, y0); /* o o */ lpoint(x1, y1 -= stepy); /* x */ lpoint(x1 -= stepx, y1); } d += incr2; } } if (extras > 0) { if (d < 0) { lpoint(x0 += stepx, y0); if (extras > 1) lpoint(x0 += stepx, y0); if (extras > 2) lpoint(x1 -= stepx, y1); } else if (d < c) { lpoint(x0 += stepx, y0); if (extras > 1) lpoint(x0 += stepx, y0 += stepy); if (extras > 2) lpoint(x1 -= stepx, y1); } else { lpoint(x0 += stepx, y0 += stepy); if (extras > 1) lpoint(x0 += stepx, y0); if (extras > 2) lpoint(x1 -= stepx, y1 -= stepy); } } } else { int c = (dy - dx) << 1; int incr1 = c << 1; int d = incr1 + dx; int i; for (i = 0; i < length; i++) { x0 += stepx; x1 -= stepx; if (d > 0) { lpoint(x0, y0 += stepy); /* Pattern: */ lpoint(x0 += stepx, y0 += stepy); /* o */ lpoint(x1, y1 -= stepy); /* o */ lpoint(x1 -= stepx, y1 -= stepy); /* x */ d += incr1; } else { if (d < c) { lpoint(x0, y0); /* Pattern: */ lpoint(x0 += stepx, y0 += stepy); /* o */ lpoint(x1, y1); /* x o */ lpoint(x1 -= stepx, y1 -= stepy); } else { lpoint(x0, y0 += stepy); /* Pattern: */ lpoint(x0 += stepx, y0); /* o o */ lpoint(x1, y1 -= stepy); /* x */ lpoint(x1 -= stepx, y1); } d += incr2; } } if (extras > 0) { if (d > 0) { lpoint(x0 += stepx, y0 += stepy); if (extras > 1) lpoint(x0 += stepx, y0 += stepy); if (extras > 2) lpoint(x1 -= stepx, y1 -= stepy); } else if (d < c) { lpoint(x0 += stepx, y0); if (extras > 1) lpoint(x0 += stepx, y0 += stepy); if (extras > 2) lpoint(x1 -= stepx, y1); } else { lpoint(x0 += stepx, y0 += stepy); if (extras > 1) lpoint(x0 += stepx, y0); if (extras > 2) { if (d > c) lpoint(x1 -= stepx, y1 -= stepy); else lpoint(x1 -= stepx, y1); } } } } } else {