Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/148.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ rtree是可索引的断言_C++_Boost_R Tree_Boost Geometry - Fatal编程技术网

C++ rtree是可索引的断言

C++ rtree是可索引的断言,c++,boost,r-tree,boost-geometry,C++,Boost,R Tree,Boost Geometry,这是我的代码。我正在尝试为顶点类对象创建一个rtree树RTreeVertex class Entity { public: int num; public: Entity(int nr): num(nr){ } virtual ~Entity(){} bool operator==(const Entity& b) { return num == b.num; } }; class Vertex : public Entity { pu

这是我的代码。我正在尝试为顶点类对象创建一个rtree树RTreeVertex

class Entity {

public:
  int num;
public:
  Entity(int nr): num(nr){ }
  virtual ~Entity(){}
   bool operator==(const Entity& b)
   {
     return num == b.num;
   } 
};


class Vertex : public Entity {

public : 
  struct Coord{
  double X, Y, Z;  
  }Pos;

  Vertex(int num=0, double X=0., double Y=0., double Z=0.): Entity (num)
  {
    Pos.X = X;
    Pos.Y = Y;
    Pos.Z = Z;
  }
};
下面是我如何声明rtree的:

#include <boost/geometry/index/rtree.hpp>
namespace bgi = boost::geometry::index;
bgi::rtree< Vertex, bgi::linear<32> > RTreeVertex;
#包括
名称空间bgi=boost::geometry::index;
bgi::rtreeRTreeVertex;
但是我得到一个错误,说vertec是不可索引的


还有一个更普遍的问题:使用rtree存储与网格相关的数据是一个好主意吗

您必须向boost geometry注册您的point类。它为你的班级创造了一系列的特质。我测试了这个,它是有效的

    class Vertex : public Entity {

    public : 
            double X, Y, Z;  

        Vertex(int num=0, double x=0., double y=0., double z=0.): Entity (num)
        {
            X = x;
            Y = y;
            Z = z;
        }
    };

BOOST_GEOMETRY_REGISTER_POINT_3D( Vertex, double, bg::cs::cartesian, X, X, X );
#include <boost/geometry/index/rtree.hpp>
namespace bgi = boost::geometry::index;
bgi::rtree< Vertex, bgi::linear<32> > RTreeVertex;
你可以用你的结构来表示你的x,y,z

名称空间bg=boost::geometry


是我在上面使用的名称空间

感谢您的回复,我有一个线条和曲面类,它们也是从实体类派生的。如何将它们注册到boost geometry中?查看:boost\geometry\geometry\register注册类的所有宏都在其中,如果您想滚动自己的特性。
BOOST_GEOMETRY_REGISTER_POINT_3D( Vertex, double, bg::cs::cartesian, Pos.X, Pos.Y, Pos.Z );