int findEnclosingCell(const Mesh& mesh, int cellDim, int initialGuessLID, const double* x) { std::queue<int> Q; Set<int> repeats; static Array<int> facets; Q.push(initialGuessLID); while (!Q.empty()) { int next = Q.front(); Q.pop(); if (repeats.contains(next)) continue; if (cellContainsPoint(mesh, cellDim, next, x, facets)) return next; repeats.put(next); std::list<int> neighbors; maximalNeighbors(mesh, cellDim, next, facets, neighbors); for (std::list<int>::const_iterator i=neighbors.begin(); i!=neighbors.end(); i++) { Q.push(*i); } } return -1; // no containing cell found }
/** * @brief Determines whether a Point is contained inside a Cell. * @details Queries each Surface inside the Cell to determine if the Point * is on the same side of the Surface. This Point is only inside * the Cell if it is on the same side of every Surface in the Cell. * @param coords a pointer to a localcoord */ bool Cell::cellContainsCoords(LocalCoords* coords) { return cellContainsPoint(coords->getPoint()); }