本文整理汇总了C++中Universe::findCell方法的典型用法代码示例。如果您正苦于以下问题:C++ Universe::findCell方法的具体用法?C++ Universe::findCell怎么用?C++ Universe::findCell使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Universe
的用法示例。
在下文中一共展示了Universe::findCell方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: findCell
/**
* @brief Finds the Cell for which a LocalCoords object resides.
* @details Finds the Cell that a LocalCoords object is located inside by
* checking each of this Universe's Cells. Returns NULL if the
* LocalCoords is not in any of the Cells.
* @param coords a pointer to the LocalCoords of interest
* @param universes a container of all of the Universes passed in by Geometry
* @return a pointer the Cell where the LocalCoords is located
*/
Cell* Universe::findCell(LocalCoords* coords,
std::map<int, Universe*> universes) {
Cell* return_cell = NULL;
std::map<int, Cell*>::iterator iter;
/* Sets the LocalCoord type to UNIV at this level */
coords->setType(UNIV);
/* Loop over all Cells in this Universe */
for (iter = _cells.begin(); iter != _cells.end(); ++iter) {
Cell* cell = iter->second;
if (cell->cellContainsCoords(coords)) {
/* Set the Cell on this level */
coords->setCell(cell->getId());
/* MATERIAL type Cell - lowest level, terminate search for Cell */
if (cell->getType() == MATERIAL) {
coords->setCell(cell->getId());
return_cell = cell;
return return_cell;
}
/* FILL type Cell - Cell contains a Universe at a lower level
* Update coords to next level and continue search */
else if (cell->getType() == FILL) {
LocalCoords* next_coords;
if (coords->getNext() == NULL)
next_coords = new LocalCoords(coords->getX(), coords->getY());
else
next_coords = coords->getNext();
CellFill* cell_fill = static_cast<CellFill*>(cell);
int universe_id = cell_fill->getUniverseFillId();
next_coords->setUniverse(universe_id);
Universe* univ = universes.at(universe_id);
coords->setCell(cell->getId());
coords->setNext(next_coords);
next_coords->setPrev(coords);
if (univ->getType() == SIMPLE)
return univ->findCell(next_coords, universes);
else
return static_cast<Lattice*>(univ)->findCell(next_coords, universes);
}
}
}
return return_cell;
}