如何填充多边形在增强
How fill the polygon in boost?
我有这样的代码:
boost::几何::typedef模型:polygon<Point2,>多边形;
多边形边界;
我需要填充边界。我想这一定很容易,但我从来没有使用过boost,我也没有找到这方面的指导。我研究了许多例子,但它们没有包含必要的操作。我尝试使用项目umeshu https://github.com/vladimir-ch/umeshu/创建网格与良好的三角测量。我只需要知道如何填充初始数据
您想要的接口是:
//! This refers to the exterior ring of the polygon.
inline ring_type& outer() { return m_outer; }
//! This refers to a collection of rings which are holes inside the polygon.
inline inner_container_type & inners() { return m_inners; }
默认ring_type是一个std::vector,其中Point是你指定的模板参数(在你的例子中是Point2)
试题:
boundary.outer().push_back(Point2(x, y)); //This fills the exterior boundary with one point whose coordinates are x and y.
下面是一个完整的工作示例:
#include <boost/geometry.hpp>
#include <boost/geometry/geometries/point.hpp>
#include <boost/geometry/geometries/polygon.hpp>
#include <iostream>
namespace bg = boost::geometry;
int main(void)
{
typedef bg::model::point<double, 2, bg::cs::cartesian> point;
typedef bg::model::polygon<point> polygon;
//! create a polygon
polygon p;
p.outer().push_back(point(0., 0.));
p.outer().push_back(point(1., 0.));
p.outer().push_back(point(1., 2.));
p.outer().push_back(point(2., 3.));
p.outer().push_back(point(0., 4.));
//! display it
std::cout << "generated polygon:" << std::endl;
std::cout << bg::wkt<polygon>(p) << std::endl;
return 0;
}
输出:generated polygon:
POLYGON((0 0,1 0,1 2,2 3,0 4))
Press any key to continue . . .
相关文章:
- 无法将结构注册为增强几何体3D点
- 计算缩放多边形的比例,得到给定的多边形面积
- 将QGraphicsItem的移动区域限制在多边形区域内
- 增强基于 XML class_id的反序列化
- 增强精神解析器规则以检测语句中的特殊结尾
- C++ 使用增强正则表达式库时断言崩溃
- 如何使用增强::几何计算多边形的旋转固体体积?
- 在多边形内查找增强 rtree 元素
- 增强索引处的几何多边形插入点
- 增强多边形序列化:环
- 使用增强:多边形:get_rectangles
- 未能使用增强::几何体::模型::多边形
- 增强几何体:多边形和框的交集
- 相交线多边形增强几何体
- 使用增强:几何体翻转多边形
- 增强::几何体如何将多边形添加到多重多边形中
- 如何填充多边形在增强
- 多边形交叉与增强
- 使用增强几何体旋转多边形
- 创建多个增强::多边形的并集的最快方法是什么