本文整理汇总了C++中CellSet类的典型用法代码示例。如果您正苦于以下问题:C++ CellSet类的具体用法?C++ CellSet怎么用?C++ CellSet使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CellSet类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: assert
int
GameBoard::NumNeighbours(const Cell& cell) {
BoundingBox searchBox;
if (cell.x == 0) {
searchBox._x = 0;
searchBox._width = 1;
} else {
searchBox._x = cell.x - 1;
searchBox._width = 2;
}
if (cell.y == 0) {
searchBox._y = 0;
searchBox._height = 1;
} else {
searchBox._y = cell.y - 1;
searchBox._height = 2;
}
CellSet neighbours;
_quadTree.FindPoints(searchBox, neighbours);
// The original cell is in the search box, so should
// be at least one. If a dead cell, we only look at
// dead cells next to alive ones so there should be at least one.
assert(neighbours.size() > 0);
return cell.isAlive ? neighbours.size() - 1 : neighbours.size();
}
示例2: connectedNodeSet
CellSet connectedNodeSet(const CellFilter& f, const Mesh& mesh)
{
CellSet cells = f.getCells(mesh);
int dim = cells.dimension();
if (dim==0) return cells;
Array<int> cellLID;
for (CellIterator i=cells.begin(); i!=cells.end(); i++)
{
cellLID.append(*i);
}
Array<int> nodes;
Array<int> fo;
mesh.getFacetLIDs(dim, cellLID, 0, nodes, fo);
Set<int> nodeSet;
for (int i=0; i<nodes.size(); i++)
{
nodeSet.put(nodes[i]);
}
return CellSet(mesh, 0, PointCell, nodeSet);
}
示例3:
void
GameBoard::MarkAlive(const CellSet& cells,
QuadTree& tree) {
tree.Clear();
for (CellSet::iterator it = cells.begin();
it != cells.end(); ++it) {
tree.Insert(*it);
}
}
示例4: getNetCells
//{{{ CellSet Cell::getNetCells()
CellSet Cell::getNetCells(const size_t &i) const {
CellSet cells;
if (i >= nets_.size())
return cells;
NetSet eqv = getEqvNets(i);
for (NetSet::iterator it = eqv.begin(); it != eqv.end(); ++it)
for (size_t i = 0; i < (*it)->getNPort(); ++i)
if ((*it)->getPort(i)->top_ != this)
cells.insert((*it)->getPort(i)->top_);
return cells;
} //}}}
示例5: _initialCells
GameBoard::GameBoard(const CellSet& points)
: _initialCells(points), _liveCells(points),
_quadTree(BoundingBox(0, 0, ULONG_MAX, ULONG_MAX)),
_changeQuadTree(BoundingBox(0, 0, ULONG_MAX, ULONG_MAX)),
_patternQuadTree(BoundingBox(0, 0, ULONG_MAX, ULONG_MAX))
{
for (CellSet::const_iterator it = points.begin();
it != points.end(); ++it) {
_quadTree.Insert(*it);
}
}
示例6: cellSetToLIDArray
RCP<Array<int> > cellSetToLIDArray(const CellSet& cs)
{
RCP<Array<int> > cellLID = rcp(new Array<int>());
for (CellIterator i=cs.begin(); i!=cs.end(); i++)
{
cellLID->append(*i);
}
return cellLID;
}
示例7: spatialBoundary
CellSet KeyFace::spatialBoundary() const
{
CellSet res;
for(int i=0; i<cycles_.size(); ++i)
{
CellSet cells = cycles_[i].cells();
res.unite(cells);
}
return res;
}
示例8: CellSet
CellSet EdgeCell::spatialBoundary() const
{
if(isClosed())
{
return CellSet();
}
else
{
CellSet left = startVertices();
CellSet right = endVertices();
left.unite(right);
return left;
}
}
示例9: processQueue
void
GameBoard::Update() {
CellSet nextLiveCells;
CellQueue processQueue(_liveCells);
while (!processQueue.Empty()) {
Cell& cell = processQueue.Front();
if (nextLiveCells.count(cell) == 0) {
// Add neighbours if necessary
if (cell.isAlive) {
// TODO: Check for dupes? Worth it?
if (cell.x < ULONG_MAX) {
processQueue.Push(Cell(cell.x+1, cell.y, false));
if (cell.y < ULONG_MAX) {
processQueue.Push(Cell(cell.x+1, cell.y+1, false));
}
if (cell.y > 0) {
processQueue.Push(Cell(cell.x+1, cell.y-1, false));
}
}
if (cell.y < ULONG_MAX) {
processQueue.Push(Cell(cell.x, cell.y+1, false));
}
if (cell.x > 0) {
processQueue.Push(Cell(cell.x-1, cell.y, false));
if (cell.y < ULONG_MAX) {
processQueue.Push(Cell(cell.x-1, cell.y+1, false));
}
if (cell.y > 0) {
processQueue.Push(Cell(cell.x-1, cell.y-1, false));
}
}
if (cell.y > 0) {
processQueue.Push(Cell(cell.x, cell.y-1, false));
}
}
int numNeighbours = NumNeighbours(cell);
if (numNeighbours == 3 || (cell.isAlive && numNeighbours == 2)) {
cell.isAlive = true;
nextLiveCells.insert(cell);
}
processQueue.Pop();
}
}
_liveCells = nextLiveCells;
MarkAlive(_liveCells, _quadTree);
}
示例10: findFirst
ZOrderedCells::Iterator ZOrderedCells::findFirst(const CellSet & cells)
{
Iterator it = begin();
for(; it != end(); ++it)
if(cells.contains(*it))
break;
return it;
}
示例11: findLast
ZOrderedCells::ReverseIterator ZOrderedCells::findLast(const CellSet & cells)
{
ReverseIterator it = rbegin();
for(; it != rend(); ++it)
if(cells.contains(*it))
break;
return it;
}
示例12: getPortCells
//{{{ CellSet Cell::getPortCells()
CellSet Cell::getPortCells(const size_t &i) const {
CellSet cells;
if (i >= ports_.size())
return cells;
Net *n = ports_[i]->inNet_;
if (!n)
return cells;
NetSet eqv = getEqvNets(n->id_);
for (NetSet::iterator it = eqv.begin() ; it != eqv.end(); ++it) {
Net *n = *it;
for (size_t i = 0; i < n->getNPort(); ++i) {
Port *p = n->getPort(i);
if (p->top_ != this)
cells.insert(p->top_);
}
}
return cells;
} //}}}
示例13: CalculateNeighbourCells
void CalculateNeighbourCells( Complex2D& G,
const CellSet & cell_set,
FacetMap & facet_map)
{
typedef typename CellSet::CellIterator SetCellIt;
typedef typename FacetMap::iterator MapIt;
typedef grid_types<Complex2D> gt;
typedef typename gt::Cell Cell;
typedef typename gt::FacetOnCellIterator FacetOnCellIt;
// typedef typename gt::CellOnCellIterator CellNeighbourIt;
friend_for_input gg(G); // gg == G + access to private routines
typedef vtuple_2d<Complex2D> vtuple;
SetCellIt c = cell_set.FirstCell();
for(c= cell_set.FirstCell(); !c.IsDone(); ++c){
Cell C(*c);
FacetOnCellIt f(C.FirstFacet());
for(; !f.IsDone();++f) {
vtuple facet(get_vertices(f));
MapIt nb;
if((nb = facet_map.find(facet)) != facet_map.end()){
// facet found: nb has already been visited
// do appropriate entries in the neighbourlists
// & remove facet from the map.
FacetOnCellIt NbIt((*nb).second);
gg.set_neighbour(f, NbIt.TheCell());
gg.set_neighbour(NbIt, f. TheCell());
//(int&)(*f._nb) = G.handle(NbIt.TheCell()); // replace with call to
//(int&)(*(NbIt._nb)) = G.handle(f.TheCell()); // internal fct of Complex2D
facet_map.erase(nb);
}
else // 1st time this facet is encountered: add it to map
facet_map[facet] = f ;
} // for(f=C.FirstNeighbour();...
} // for(c=FirstCell();...
// all remaining map entries are on the boundary of cell_set
// because they have been encountered exactly once.
}
示例14: shape
void
GameBoard::Draw(const ViewInfo& view,
sf::RenderTarget& texture,
bool running) const {
if (!running) {
for (int x = 0; x < view.GetHorizontalCells(); ++x) {
for (int y = 0; y < view.GetVerticalCells(); ++y) {
sf::RectangleShape shape(sf::Vector2f(view.cellSize, view.cellSize));
shape.setFillColor(BACKGROUND_COLOUR);
shape.setOutlineThickness(1);
shape.setOutlineColor(GRID_COLOUR);
shape.setPosition(x * view.cellSize, y * view.cellSize);
texture.draw(shape);
}
}
}
CellSet liveCells;
_quadTree.FindPoints(view.viewBox, liveCells);
for (CellSet::iterator it = liveCells.begin();
it != liveCells.end(); ++it) {
// If stopped, don't draw cells that are deleted
if (!running) {
CellSet::iterator changesIt = _changedCells.find(*it);
if (changesIt != _changedCells.end() && !changesIt->isAlive) {
continue;
}
}
it->Draw(view, texture, CELL_COLOUR);
}
if (!running) {
CellSet changedCells;
_changeQuadTree.FindPoints(view.viewBox, changedCells);
for (CellSet::iterator it = changedCells.begin();
it != changedCells.end(); ++it) {
it->Draw(view, texture, GRID_COLOUR);
}
CellSet patternCells;
_patternQuadTree.FindPoints(view.viewBox, patternCells);
for (CellSet::iterator it = patternCells.begin();
it != patternCells.end(); ++it) {
it->Draw(view, texture, GRID_COLOUR);
}
}
}
示例15: rcp
void AToCDensitySampler::init()
{
const CellFilter& domain = discSpace_.cellFilters(0);
elemWeightVec_ = DiscreteFunction::discFunc(elemWeights_)->getVector();
elemToVecIndexMap_ = rcp(new Array<int>(mesh_.numCells(dim_), -1));
Array<int>& a = *elemToVecIndexMap_;
CellSet cells = domain.getCells(mesh_);
Array<int> cellLID;
cellLID.reserve(mesh_.numCells(dim_));
for (CellIterator i=cells.begin(); i!=cells.end(); i++)
{
cellLID.append(*i);
}
const RCP<DOFMapBase>& dofMap = discSpace_.map();
Set<int> funcs = makeSet(0);
Array<Array<int> > dofs;
Array<int> nNodes;
dofMap->getDOFsForCellBatch(dim_, cellLID, funcs, dofs, nNodes,0);
const Array<int>& dofs0 = dofs[0];
for (int c=0; c<cellLID.size(); c++)
{
int vecIndex = dofs0[c];
int lid = cellLID[c];
a[lid] = vecIndex;
double vol = volume(mesh_, dim_, lid);
if (isAxisymmetric_)
{
Point xCell = mesh_.centroid(dim_, lid) - origin_;
double dPerp = ::sqrt(xCell*xCell - (xCell*axis_)*(xCell*axis_));
vol = vol * dPerp;
}
elemWeightVec_[vecIndex] = vol;
}
}