本文整理汇总了C++中Box2D::shift方法的典型用法代码示例。如果您正苦于以下问题:C++ Box2D::shift方法的具体用法?C++ Box2D::shift怎么用?C++ Box2D::shift使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Box2D
的用法示例。
在下文中一共展示了Box2D::shift方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: bulk
void LocalMultiBlockInfo2D::computePeriodicOverlaps (
SparseBlockStructure2D const& sparseBlock, plint blockId )
{
Box2D intersection; // Temporary variable.
std::vector<plint> neighbors; // Temporary variable.
SmartBulk2D bulk(sparseBlock, envelopeWidth, blockId);
for (plint dx=-1; dx<=+1; dx+=1) {
for (plint dy=-1; dy<=+1; dy+=1) {
if (dx!=0 || dy!=0) {
// The new block is shifted by the length of the full multi block in each space
// direction. Consequently, overlaps between the original multi block and the
// shifted new block are identified as periodic overlaps.
plint shiftX = dx*sparseBlock.getBoundingBox().getNx();
plint shiftY = dy*sparseBlock.getBoundingBox().getNy();
Box2D shiftedBulk(bulk.getBulk().shift(shiftX,shiftY));
Box2D shiftedEnvelope(bulk.computeEnvelope().shift(shiftX,shiftY));
// Speed optimization: perform following checks only if the shifted
// domain touches the bounding box.
Box2D dummyIntersection;
if (intersect(shiftedEnvelope, sparseBlock.getBoundingBox(), dummyIntersection)) {
neighbors.clear();
sparseBlock.findNeighbors(shiftedBulk, envelopeWidth, neighbors);
// Check overlap with each existing block in the neighborhood, including with the newly added one.
for (pluint iNeighbor=0; iNeighbor<neighbors.size(); ++iNeighbor) {
plint neighborId = neighbors[iNeighbor];
SmartBulk2D neighborBulk(sparseBlock, envelopeWidth, neighborId);
// Does the envelope of the shifted new block overlap with the bulk of a previous
// block? If yes, add an overlap, in which the previous block has the "original
// position", and the new block has the "overlap position".
if (intersect(neighborBulk.getBulk(), shiftedEnvelope, intersection)) {
PeriodicOverlap2D overlap (
Overlap2D(neighborId, blockId, intersection, shiftX, shiftY),
dx, dy );
periodicOverlaps.push_back(overlap);
periodicOverlapWithRemoteData.push_back(overlap);
}
// Does the bulk of the shifted new block overlap with the envelope of a previous
// block? If yes, add an overlap, in which the new block has the "original position",
// and the previous block has the "overlap position".
// If we are in the situation in which the newly added block is periodic with itself,
// this step must be skipped, because otherwise the overlap is counted twice.
if (!(neighborId==blockId) &&
intersect(shiftedBulk, neighborBulk.computeEnvelope(), intersection))
{
intersection = intersection.shift(-shiftX,-shiftY);
periodicOverlaps.push_back (
PeriodicOverlap2D (
Overlap2D(blockId, neighborId, intersection, -shiftX, -shiftY),
-dx, -dy ) );
}
}
}
}
}
}
}