当前位置: 首页>>代码示例>>C++>>正文


C++ Box2D::shift方法代码示例

本文整理汇总了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 ) );
                        }
                    }
                }
            }
        }
    }
}
开发者ID:Longlonc,项目名称:palabos,代码行数:57,代码来源:localMultiBlockInfo2D.cpp


注:本文中的Box2D::shift方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。