Commit 173f9adf authored by Max Lyon's avatar Max Lyon

Merge branch 'track-garbage' into 'master'

Track if garbage collection is necessary.

This is useful for precondition checks in client code.

PR includes the bugfix from !5

See merge request !6
parents 3d9ad9ab bc124508
Pipeline #2743 passed with stage
in 3 minutes and 34 seconds
......@@ -107,7 +107,10 @@ public:
virtual void collect_garbage()
{
if (TopologyKernel::fast_deletion_enabled()) {
if (!TopologyKernelT::needs_garbage_collection())
return;
if (TopologyKernelT::fast_deletion_enabled()) {
TopologyKernelT::collect_garbage();
vertices_.resize(TopologyKernel::n_vertices());
} else {
......
......@@ -64,7 +64,8 @@ TopologyKernel::TopologyKernel() :
e_bottom_up_(true),
f_bottom_up_(true),
deferred_deletion(true),
fast_deletion(true)
fast_deletion(true),
needs_garbage_collection_(false)
{
}
......@@ -719,7 +720,7 @@ CellIter TopologyKernel::delete_cell(const CellHandle& _h) {
*/
void TopologyKernel::collect_garbage()
{
if (!deferred_deletion_enabled())
if (!deferred_deletion_enabled() || !needs_garbage_collection_)
return; // nothing todo
deferred_deletion = false;
......@@ -754,6 +755,7 @@ void TopologyKernel::collect_garbage()
deferred_deletion = true;
needs_garbage_collection_ = false;
}
......@@ -920,6 +922,7 @@ VertexIter TopologyKernel::delete_vertex_core(const VertexHandle& _h) {
if (deferred_deletion_enabled())
{
needs_garbage_collection_ = true;
vertex_deleted_[h.idx()] = true;
// deleted_vertices_.push_back(h);
......@@ -1047,6 +1050,7 @@ EdgeIter TopologyKernel::delete_edge_core(const EdgeHandle& _h) {
if (deferred_deletion_enabled())
{
needs_garbage_collection_ = true;
edge_deleted_[h.idx()] = true;
// deleted_edges_.push_back(h);
......@@ -1231,6 +1235,7 @@ FaceIter TopologyKernel::delete_face_core(const FaceHandle& _h) {
if (deferred_deletion_enabled())
{
needs_garbage_collection_ = true;
face_deleted_[h.idx()] = true;
// deleted_faces_.push_back(h);
......@@ -1389,6 +1394,7 @@ CellIter TopologyKernel::delete_cell_core(const CellHandle& _h) {
if (deferred_deletion_enabled())
{
needs_garbage_collection_ = true;
cell_deleted_[h.idx()] = true;
// deleted_cells_.push_back(h);
// deleted_cells_set.insert(h);
......
......@@ -925,6 +925,10 @@ public:
return HalfFaceHandle(_h.idx() - 1);
}
bool inline needs_garbage_collection() const {
return needs_garbage_collection_;
}
protected:
// List of edges
......@@ -940,6 +944,7 @@ protected:
std::vector<bool> edge_deleted_;
std::vector<bool> face_deleted_;
std::vector<bool> cell_deleted_;
bool needs_garbage_collection_;
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment