data structures - Secure usage of Cell_handle in a CGAL Delaunay triangulation after point insertion -


i'm planning write algorithm use cgal delaunay triangulation data structure. need insert point triangulation, save reference cells, , make other insertion.

i'm wondering how can store reference cells not invalidated after insertion of new points in triangulation?

it's seems me cell_handle pointer internal structure, it's dangerous store due reallocation of internal container. in other hand can see no way in triangulation_3 interface store index cell_handle.

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 = 0; < 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 = 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 = 0; < newp; ++i)       t.insert(point(rand()%1000,rand()%1000,rand()%1000));     int finitec(0),infinitec(0);    for(int = 0; < 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; } 

this code systematically crash but, , strange me, if change newp 10000, code magically works.

can explain me how handle problem?

since cell can disappear during insertion of new point, handle have saved not guarantee point on expect.

you have crash because use triangulation hierarchy internally creates , remove cells in internal container. if use cgal::delaunay_triangulation_3, not have crash.

for problem, should store quadruplet of vertex_handles , use is_cell function (documented here).


Comments

Popular posts from this blog

Perl - how to grep a block of text from a file -

delphi - How to remove all the grips on a coolbar if I have several coolbands? -

javascript - Animating array of divs; only the final element is modified -