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


C++ MapSector::copy方法代码示例

本文整理汇总了C++中MapSector::copy方法的典型用法代码示例。如果您正苦于以下问题:C++ MapSector::copy方法的具体用法?C++ MapSector::copy怎么用?C++ MapSector::copy使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MapSector的用法示例。


在下文中一共展示了MapSector::copy方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: addLines

/* MapArchClipboardItem::addLines
 * Copies [lines] and all related map structures
 *******************************************************************/
void MapArchClipboardItem::addLines(vector<MapLine*> lines)
{
    // Get sectors and sides to copy
    vector<MapSector*> copy_sectors;
    vector<MapSide*> copy_sides;
    for (unsigned a = 0; a < lines.size(); a++)
    {
        MapSide* s1 = lines[a]->s1();
        MapSide* s2 = lines[a]->s2();

        // Front side
        if (s1)
        {
            copy_sides.push_back(s1);
            if (std::find(copy_sectors.begin(), copy_sectors.end(), s1->getSector()) == copy_sectors.end())
                copy_sectors.push_back(s1->getSector());
        }

        // Back side
        if (s2)
        {
            copy_sides.push_back(s2);
            if (std::find(copy_sectors.begin(), copy_sectors.end(), s2->getSector()) == copy_sectors.end())
                copy_sectors.push_back(s2->getSector());
        }
    }

    // Copy sectors
    for (unsigned a = 0; a < copy_sectors.size(); a++)
    {
        MapSector* copy = new MapSector(NULL);
        copy->copy(copy_sectors[a]);
        sectors.push_back(copy);
    }

    // Copy sides
    for (unsigned a = 0; a < copy_sides.size(); a++)
    {
        MapSide* copy = new MapSide();
        copy->copy(copy_sides[a]);

        // Set relative sector
        for (unsigned b = 0; b < copy_sectors.size(); b++)
        {
            if (copy_sides[a]->getSector() == copy_sectors[b])
            {
                copy->setSector(sectors[b]);
                break;
            }
        }

        sides.push_back(copy);
    }

    // Get vertices to copy (and determine midpoint)
    double min_x = 9999999;
    double max_x = -9999999;
    double min_y = 9999999;
    double max_y = -9999999;
    vector<MapVertex*> copy_verts;
    for (unsigned a = 0; a < lines.size(); a++)
    {
        MapVertex* v1 = lines[a]->v1();
        MapVertex* v2 = lines[a]->v2();

        // Add vertices to copy list
        if (std::find(copy_verts.begin(), copy_verts.end(), v1) == copy_verts.end())
            copy_verts.push_back(v1);
        if (std::find(copy_verts.begin(), copy_verts.end(), v2) == copy_verts.end())
            copy_verts.push_back(v2);

        // Update min/max
        if (v1->xPos() < min_x) min_x = v1->xPos();
        if (v1->xPos() > max_x) max_x = v1->xPos();
        if (v1->yPos() < min_y) min_y = v1->yPos();
        if (v1->yPos() > max_y) max_y = v1->yPos();
        if (v2->xPos() < min_x) min_x = v2->xPos();
        if (v2->xPos() > max_x) max_x = v2->xPos();
        if (v2->yPos() < min_y) min_y = v2->yPos();
        if (v2->yPos() > max_y) max_y = v2->yPos();
    }

    // Determine midpoint
    double mid_x = min_x + ((max_x - min_x) * 0.5);
    double mid_y = min_y + ((max_y - min_y) * 0.5);
    this->midpoint.set(mid_x, mid_y);

    // Copy vertices
    for (unsigned a = 0; a < copy_verts.size(); a++)
    {
        MapVertex* copy = new MapVertex(copy_verts[a]->xPos() - mid_x, copy_verts[a]->yPos() - mid_y);
        copy->copy(copy_verts[a]);
        vertices.push_back(copy);
    }

    // Copy lines
    for (unsigned a = 0; a < lines.size(); a++)
//.........这里部分代码省略.........
开发者ID:Blzut3,项目名称:SLADE,代码行数:101,代码来源:Clipboard.cpp


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