void Gridder::find(at::real x, at::real y, at::real range, SegmentArray& results) const { results.clear(); int ix0 = (int) ((x - range - x0)/metersPerCell); int iy0 = (int) ((y - range - y0)/metersPerCell); int ix1 = (int) ((x + range - x0)/metersPerCell); int iy1 = (int) ((y + range - y0)/metersPerCell); for (int iy=iy0; iy<=iy1; ++iy) { for (int ix=ix0; ix<=ix1; ++ix) { if (ix >=0 && iy >=0 && ix < width && iy < height) { for (Segment* s = cells[sub2ind(ix,iy)]; s; s = s->nextGrid) { results.push_back(s); } } } } }
SegmentArray graph2SegArray(const Graph &graph, IntArray &pla, const bool *polygonEdge) { IntArray sortedEdgeLabels; graph.topologicalSort(sortedEdgeLabels); SegmentArray sOrder; for (int i = 0; i < sortedEdgeLabels.size(); i++) { if (polygonEdge[sortedEdgeLabels[i]]) sOrder.push_back(Segment(pla[2 * sortedEdgeLabels[i]], pla[2 * sortedEdgeLabels[i] + 1])); } int s = sOrder.size(); return sOrder; }