标签: boost-geometry

boost几何中的环和多边形有什么区别?

我对 Boost.Geometry 中的环和多边形感到困惑。

在文档中,没有图显示什么是环,什么是多边形。

谁能画一个图来解释两个概念之间的区别?

boost polygon boost-geometry

4
推荐指数
1
解决办法
1996
查看次数

Boost::geometry 如何将多边形添加到 multi_polygon

我想boost::geometry::model::multi_polygon通过boost::geometry::model::polygon在循环中添加s来创建一个。我已经查看了 boost 的示例和文档,但他们不清楚如何去做。这是我的代码

typedef boost::geometry::model::d2::point_xy<double> point_xy;
typedef boost::geometry::model::polygon<point_xy> polygon_type;
typedef boost::geometry::model::multi_polygon<polygon_type> multi_polygon_type;

    // Calculate centroid
    multi_polygon_type polygons;

    Q_FOREACH( QGraphicsItem* graphicsItem, allItemsInScene )
    {
        // Make a polygon for each graphics item
        polygon_type poly;

        // Find bounding box surrounding item and create boost compatible points from it
        QRectF boundingBox = graphicsItem->boundingRect();

        std::vector< point_xy > pointList; // Store points in vector so we can assign them to a polygon

        point_xy topLeft( boundingBox.topLeft().x(), boundingBox.topLeft().y() );
        pointList.push_back( topLeft );

        point_xy …
Run Code Online (Sandbox Code Playgroud)

c++ boost boost-geometry

4
推荐指数
1
解决办法
1976
查看次数

无法通过索引从 boost::geometry::index::rtree 中删除元素

我正在创建一个boost geometry rtree

从我创建的示例页面:

typedef bg::model::point<float, 2, bg::cs::cartesian> point;
typedef bg::model::box<point> box;
typedef std::pair<box, unsigned> value;
Run Code Online (Sandbox Code Playgroud)

我想向value树中添加元素:

bgi::rtree< value, bgi::quadratic<16> > rtree;
box b(point(2.0f, 2.0f), point(2.5f, 2.5f));
// insert new value
rtree.insert(std::make_pair(b, 2));
Run Code Online (Sandbox Code Playgroud)

现在我想知道是否可以通过知道box标识符(或者它的所有元素,如果可以设置更多具有相同 id 的元素)来删除元素。

我想要做的是删除我在上面添加的元素,例如调用以下内容:

rtree.remove(2); // why I can't do this?
Run Code Online (Sandbox Code Playgroud)

我怎样才能做到这一点?

c++ boost r-tree boost-geometry

4
推荐指数
1
解决办法
854
查看次数

提升多边形上的几何矩阵变换

是否有使用 Boost Geometry 对多边形(笛卡尔)进行矩阵变换的示例?我正在用简单的 std::vectors 定义矩阵。

另外,我只能找到 1 个matrix_transformers使用示例,ublas但对于简单的矩阵变换来说太复杂了。如果这是唯一的办法,虽然,我会坚持下去,但它会是巨大的,有其他的选择,广告做这个用std::vector的,而不是ublas::matrix

boost c++11 boost-geometry

4
推荐指数
1
解决办法
803
查看次数

使用boost库获取矩形/圆形交点

是否可以得到矩形 x 圆的交点boost?据我所知boost有一个交集函数:

template<typename Geometry1, typename Geometry2, typename GeometryOut>
bool intersection(Geometry1 const & geometry1, Geometry2 const & geometry2, GeometryOut & geometry_out)
Run Code Online (Sandbox Code Playgroud)

但我不知道如何构建圆形几何图形。我的意思是,我可以创建一个具有很多顶点的多边形,但这不是我正在寻找的表示形式

c++ boost boost-geometry

4
推荐指数
1
解决办法
2205
查看次数

Boost.Geometry:如何创建简单的多边形数组并将其保存为svg图像?

我看一下名为Boost Geometry的图书库, 我看一下它,但是看不到任何教程,至少有点图形化.所以我想知道是否有人可以帮助提供一个简单的教程来创建一些N随机的poligons(颜色大小和形式随机)并将tham保存为像SVG这样的矢量图像?

c++ svg boost vector boost-geometry

3
推荐指数
1
解决办法
3369
查看次数

在Boost几何C++库中我添加的点的顺序重要吗?

我是 boost 的新手,甚至是 boost-geometry 的新手,所以我的问题是...... boost-geometry 向多边形添加点的顺序重要吗?

例如:这一样吗?

// create a polygon
polygon p;
p.outer().push_back(point(0, 0));
p.outer().push_back(point(0, 10));
p.outer().push_back(point(10, 0));
p.outer().push_back(point(10, 10));

// create a polygon the same polygon?
polygon p;
p.outer().push_back(point(0, 0));
p.outer().push_back(point(0, 10));
p.outer().push_back(point(10, 10));
p.outer().push_back(point(10, 0));
Run Code Online (Sandbox Code Playgroud)

预先非常感谢您。

c++ boost boost-geometry

3
推荐指数
1
解决办法
2513
查看次数

我可以在boost :: geometry的多边形内存储其他信息吗?

我是boost :: geometry和C++的新手,在玩它时,我想到了以下问题:
是否可以直接在多边形内存储其他信息,例如包含颜色的std :: string或带有int的字符串一些身份证号码?

或者我必须用以下内容包装它:

MyPolygon {

  typedef boost::geometry::model::d2::point_xy<double> point_2d;
  typedef boost::geometry::model::polygon<point_2d> polygon_2d;

  polygon_2d poly;
  std::string color;
  int id;
  etc...

}
Run Code Online (Sandbox Code Playgroud)

谢谢!
ffranz

c++ geometry boost polygon boost-geometry

2
推荐指数
1
解决办法
207
查看次数

带增强的多边形相交

我正在尝试使用 Boost Polygon 库使两个多边形相交。我从 boost 网站提出的 custom_polygon 示例开始:

http://www.boost.org/doc/libs/1_59_0/libs/polygon/doc/gtl_custom_polygon.htm

在 test_polygon 函数中,我填充了两个多边形。我的问题是是否可以调用 poly1 和 poly2 的交集函数。如果我编译的话,我会得到一长串错误。

#include <boost/polygon/polygon.hpp>
#include <boost/geometry.hpp>
#include <boost/geometry/geometries/point_xy.hpp>

#include <list>


// My Point class
class MyPoint {
public:
    double x, y;
};

// MyPolygon as a list of MyPoint
typedef std::list<MyPoint> MyPolygon;



template <>
struct boost::polygon::geometry_concept<MyPoint> {
    typedef point_concept type;
};

template <>
struct boost::polygon::point_traits<MyPoint> {

    typedef double coordinate_type;

    static inline coordinate_type get(const MyPoint& point, boost::polygon::orientation_2d orient) {
        if (orient == boost::polygon::HORIZONTAL)
            return point.x;
        return point.y; …
Run Code Online (Sandbox Code Playgroud)

c++ boost polygon boost-geometry boost-polygon

2
推荐指数
1
解决办法
9787
查看次数

如何在C++中使用Boost库的Rtree?

我被要求编写一个函数,该函数接受“LatLon”作为输入(LatLon 是一个具有 2 个双精度数的类:纬度和经度)并返回距离该位置最近的交叉点的 ID(int)。我得到的函数可以返回任何交叉点的位置,也可以返回两个位置之间的距离。由于“性能测试”,我的导师建议我将所有交叉点的位置存储在 R 树中(来自 boost 库),这样可以更快地找到最近的交叉点,而不是迭代所有交叉点。然而,我刚刚学习 R 树是如何工作的,并且在如何创建 R 树方面遇到了困难。

问题是我在网上看到了几个他们创建 R 树的例子,但真正让我困惑的是他们在其中一个构造函数中只使用了两个参数,而不是四个。例如,他们使用:

bgi::rtree< value_t, bgi::quadratic<16> > rtree_;

其中 value_t 是一对 box 和 unsigned int,另一个参数是大小,但是如果我尝试这样做:

bgi::rtree<点,bgi::quadratic<16>>交集RTree;

其中 point 是一对 unsigned int 和 LatLon,编译器抱怨我没有使用正确的构造函数,并且它应该有四个参数而不是两个。

我在网上阅读过,发现我应该使用这个构造函数:

rtree(parameters_type const &、indexable_getter const &、value_equal const &、allocator_type const &)

但是,我不明白每个参数的描述,所以我不知道如何使用这个构造函数。那么,您能帮我了解该怎么做吗?如果可能的话,您能给我一个简短的例子吗?非常感谢。

这是 LatLon 类。它是只读的,所以我无法修改它:

class LatLon{

public:
LatLon(){}
explicit LatLon(float lat_, float lon_) : m_lat(lat_),m_lon(lon_){}

double lat() const { return m_lat; }
double lon() const { return m_lon; }

private:
float m_lat = std::numeric_limits<float>::quiet_NaN(); …
Run Code Online (Sandbox Code Playgroud)

c++ database boost r-tree boost-geometry

2
推荐指数
1
解决办法
5408
查看次数

标签 统计

boost ×10

boost-geometry ×10

c++ ×8

polygon ×3

r-tree ×2

boost-polygon ×1

c++11 ×1

database ×1

geometry ×1

svg ×1

vector ×1