多边形_90_数据和顶点的问题

时间:2019-01-11 08:17:55

标签: c++11 boost polygon boost-polygon

我创建了一个具有5个顶点的增强多边形,但是当我显示这些顶点或

#include <boost/polygon/polygon.hpp>
.
.
.

void displayPolygon(boost::polygon::polygon_90_data<int> const& polygon, std::string name)
{
    std::cout << std::endl << "polygon "  << name << std::endl;
    for (boost::polygon::polygon_90_data<int>::iterator_type it = polygon.begin(); it != polygon.end(); it++)
    {
        std::cout << (*it).x() << "/" << (*it).y() << "->";
    }
    std::cout << std::endl;
}
.
.
.
void testPolygon2()
{
    //typedef
    typedef boost::polygon::polygon_90_data<int> Polygon90Type;
    typedef std::vector<Polygon90Type> Polygon90Set;

    typedef boost::polygon::polygon_data<int> PolygonType;
    typedef std::vector<PolygonType> PolygonSet;
    typedef boost::polygon::point_data<int> PointType;
    typedef std::vector<PointType> PointSet;

    typedef boost::polygon::polygon_traits<Polygon90Type>::point_type Point;

    Polygon90Type polygon_1;

    Point pts_1[6] = { Point(0,0), Point(0,10), Point(5,12), Point(10,10), Point(10,0), Point(0,0)};

    polygon_1.set(pts_1, pts_1 + 6);
    std::cout << "polygon_1 area is " << boost::polygon::area(polygon_1) << std::endl;

    std::cout << std::endl << __LINE__ << " : 
    Polygon90Set polygonSet;

    polygonSet.push_back(polygon_1);
    //an attempt to see result of bloating with 0
    boost::polygon::bloat(polygonSet, 0, 0, 0, 0);

    std::cout << "nb polygon bloated " << polygonSet.size() << std::endl;
    for (auto polygon : polygonSet)
    {
        std::cout << std::endl << __LINE__ << "####################################" << std::endl;
        displayPolygon(polygon, "2 - after being bloated");

        std::cout << "area is " << boost::polygon::area(polygon) << std::endl;
    }
}

与创建的多边形不对应的区域。 该区域应为110,但显示为100? 顶点应为(0,0),(0,10),(5,12),(10,10),(10,0),但应为(0/10),(5/10),(5 / 10),(10/10),(10/0),(0/0)。似乎点(/ 5/12)被取消,并替换为点(5/10)。 我究竟做错了什么? 谢谢。

0 个答案:

没有答案
相关问题