本文整理匯總了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 ) );
}
}
}
}
}
}
}