How can I get the index of cell #8701
-
Hi, I am using CGAL to do a Delauney Tetrahedralisation, and trying to find the tetrehadron index of the tet contains a query point. How can I quickly get the Tetrahedron index using a Cell_Handle?, The only method I can think of is to use an iterator and a counter. but that means I need to do a search every time I am querying, which is very inefficient. Creating a hash table is not support for Tetrahedron nor Cell. Thank you for the help. an example code:
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
You could use https://doc.cgal.org/latest/Triangulation_3/classCGAL_1_1Triangulation__cell__base__with__info__3.html as cell base and store a unique IDs typedef Triangulation_data_structure_3<
Triangulation_vertex_base_3<K>,
Delaunay_triangulation_cell_base_3<
K, Triangulation_cell_base_with_info_3<unsigned int, K> >
typedef CGAL::Delaunay_triangulation_3<K, TDS> Delaunay;
[...]
Delaunay T(points.begin(), points.end());
for (Delaunay::Finite_cells_iterator it = Tet.finite_cells_begin(); it != Tet.finite_cells_end(); ++it) {
Cell_handle c = it;
c->info() = ...; // set up unique ID
}
[...]
Cell_handle queryPointHandle = T.locate(Point);
unsigned int cell_id = queryPointHandle->info(); If your triangulation is often modified and the cell IDs would be difficult to maintain manually, there is an undocumented tool called timestamps; see for example the cell base Cell_base_with_timestamp, and it'll set time-based unique IDs for cells automatically. Set it up similarly: typedef Triangulation_data_structure_3<
Triangulation_vertex_base_3<K>,
Cell_base_with_timestamp<Delaunay_triangulation_cell_base_3<K> >
[...]
for (Delaunay::Finite_cells_iterator it = Tet.finite_cells_begin(); it != Tet.finite_cells_end(); ++it) {
Cell_handle c = it;
std::size_t t = c->time_stamp(); // get unique ID
} |
Beta Was this translation helpful? Give feedback.
You could use https://doc.cgal.org/latest/Triangulation_3/classCGAL_1_1Triangulation__cell__base__with__info__3.html as cell base and store a unique IDs