Data structures 点插入后CGAL-Delaunay三角剖分中Cell_句柄的安全使用

Data structures 点插入后CGAL-Delaunay三角剖分中Cell_句柄的安全使用,data-structures,cells,cgal,delaunay,Data Structures,Cells,Cgal,Delaunay,我计划写一个使用CGAL Delaunay三角剖分数据结构的算法。 基本上,我需要在三角剖分中插入一些点,保存对某些单元格的引用,然后进行其他插入 我想知道在三角剖分中插入新点后,如何存储对未失效单元的引用 在我看来,Cell_句柄只是指向内部结构的指针,所以由于内部容器的重新分配,存储它是危险的。另一方面,在三角剖分_3接口中,我看不到存储单元格_句柄索引的方法 typedef CGAL::Exact_predicates_inexact_constructions_kernel K; typ

我计划写一个使用CGAL Delaunay三角剖分数据结构的算法。 基本上,我需要在三角剖分中插入一些点,保存对某些单元格的引用,然后进行其他插入

我想知道在三角剖分中插入新点后,如何存储对未失效单元的引用

在我看来,Cell_句柄只是指向内部结构的指针,所以由于内部容器的重新分配,存储它是危险的。另一方面,在三角剖分_3接口中,我看不到存储单元格_句柄索引的方法

typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
typedef CGAL::Triangulation_vertex_base_3<K>             Vb;
typedef CGAL::Triangulation_hierarchy_vertex_base_3<Vb>  Vbh;
typedef CGAL::Triangulation_data_structure_3<Vbh>        Tds;
typedef CGAL::Delaunay_triangulation_3<K,Tds>            Dt;
typedef CGAL::Triangulation_hierarchy_3<Dt>              Dh;
typedef Dh::Vertex_iterator Vertex_iterator;
typedef Dh::Vertex_handle   Vertex_handle;
typedef Dh::Point           Point;

int main(){

   Dh T;
   for(int i = 0; i < 100; ++i)
      T.insert(Point(rand()%1000,rand()%1000,rand()%1000));

   assert( T.is_valid() );
   assert( T.number_of_vertices() == 100 );
   assert( T.dimension() == 3 );

   typedef Dh::Cell_iterator CellIterator;

   std::vector<Dh::Cell_handle> hnd;
   CellIterator itEnd = T.finite_cells_end();
   for(CellIterator it = T.finite_cells_begin(); it!=itEnd; ++it){
      const int dist = std::distance(T.cells_begin(),it);
      hnd.push_back(it);
   }

   const int newP(1000);
   for(int i = 0; i < newP; ++i)
      T.insert(Point(rand()%1000,rand()%1000,rand()%1000));

   int finiteC(0),infiniteC(0);
   for(int i = 0; i < hnd.size(); ++i){
      const int dist = std::distance(T.cells_begin(),hnd[i]);
      if(T.is_infinite(hnd[i]))
     ++infiniteC;
  else
     ++finiteC;
   }
   assert( T.is_valid() );
   return 0;
}
typedef CGAL::精确谓词\不精确构造\内核K;
typedef CGAL::三角剖分_顶点_底面_3 Vb;
typedef CGAL::三角剖分\层次\顶点\基础\ 3 Vbh;
typedef CGAL::三角测量数据结构Tds;
typedef CGAL::Delaunay_三角剖分_3 Dt;
typedef CGAL::三角剖分_层次_3 Dh;
typedef Dh::顶点迭代器顶点迭代器;
typedef Dh::顶点句柄顶点句柄;
typedef Dh::Point;
int main(){
Dh T;
对于(int i=0;i<100;++i)
插入(点(rand()%1000,rand()%1000,rand()%1000));
断言(T.is_valid());
断言(T.顶点数()=100);
断言(T.dimension()==3);
typedef Dh::Cell\u迭代器CellIterator;
std::载体hnd;
单元迭代器itEnd=T.有限单元;
for(CellIterator it=T.finite_cells_begin();it!=itEnd;++it){
const int dist=std::distance(T.cells_begin(),it);
hnd.推回(it);
}
常数int newP(1000);
对于(int i=0;i
这段代码系统性地崩溃了,但这对我来说真的很奇怪,如果我把newP改为10000,这段代码神奇地工作了


有人能给我解释一下如何处理这个问题吗?

因为在插入新点时,单元格可能会消失,所以您保存的句柄 我们不能保证指出你的期望

由于使用内部创建和删除内部容器中的单元的三角剖分层次结构,因此会发生崩溃。如果使用CGAL::Delaunay_三角剖分_3,则不会发生崩溃


对于您的问题,您应该存储四组顶点控制柄,并使用is\u cell函数(有文档记录)。

由于在插入新点时,单元可能会消失,因此您保存的控制柄 我们不能保证指出你的期望

由于使用内部创建和删除内部容器中的单元的三角剖分层次结构,因此会发生崩溃。如果使用CGAL::Delaunay_三角剖分_3,则不会发生崩溃


对于您的问题,您应该存储四组顶点句柄,并使用is\u单元函数(已记录)。

事实上,单元在插入时可能会消失。您还可以使用find_conflicts()函数查找要通过插入删除的单元格,以便更新与它们相关的任何内容。

事实上,单元格在插入时可能会消失。您还可以使用find_conflicts()函数查找要通过插入删除的单元格,以便更新与它们相关的任何内容。

崩溃发生在此行,i==79。“const int dist=std::distance(T.cells_begin(),hnd[i]);”我正在使用VS2012-Debug x64-MDdCrash在此行中出现,i==79。“const int dist=std::distance(T.cells_begin(),hnd[i]);”我使用的是VS2012-Debug x64-MDd