remove the handle

it is not needed as the id map is used to store handles
This commit is contained in:
Sébastien Loriot 2021-11-30 13:49:39 +01:00
parent f26de8e819
commit c61fdb831b
3 changed files with 18 additions and 27 deletions

View File

@ -335,7 +335,7 @@ operator()()
} else { } else {
(*u)->set_cost(*dist); (*u)->set_cost(*dist);
if(mpq->contains(*u)){ if(mpq->contains(*u)){
mpq->update(*u, true); mpq->update(*u);
} }
else{ else{
mpq->push(*u); mpq->push(*u);
@ -353,7 +353,7 @@ operator()()
} else { } else {
(*w)->set_cost(*dist); (*w)->set_cost(*dist);
if(mpq->contains(*w)){ if(mpq->contains(*w)){
mpq->update(*w, true); mpq->update(*w);
} }
else{ else{
mpq->push(*w); mpq->push(*w);

View File

@ -78,22 +78,17 @@ public:
typedef typename Heap::value_type value_type; typedef typename Heap::value_type value_type;
typedef typename Heap::size_type size_type; typedef typename Heap::size_type size_type;
typedef bool handle ;
public: public:
Modifiable_priority_queue( size_type largest_ID, Compare const& c = Compare(), ID const& id = ID() ) : mHeap(largest_ID,c,id) {} Modifiable_priority_queue( size_type largest_ID, Compare const& c = Compare(), ID const& id = ID() ) : mHeap(largest_ID,c,id) {}
handle push ( value_type const& v ) { mHeap.push(v) ; return handle(true) ; } void push ( value_type const& v ) { mHeap.push(v) ; }
handle update ( value_type const& v, handle h ) { mHeap.update(v); return h ; }
void update ( value_type const& v ) { mHeap.update(v); } void update ( value_type const& v ) { mHeap.update(v); }
handle erase ( value_type const& v, handle ) { mHeap.remove(v); return null_handle() ; } void erase ( value_type const& v ) { mHeap.remove(v); }
handle erase ( value_type const& v ) { mHeap.remove(v); return null_handle() ; }
value_type top() const { return mHeap.top() ; } value_type top() const { return mHeap.top(); }
void pop() { mHeap.pop(); } void pop() { mHeap.pop(); }
@ -121,8 +116,6 @@ public:
return v; return v;
} }
static handle null_handle() { return handle(false); }
private: private:
Heap mHeap ; Heap mHeap ;

View File

@ -174,27 +174,22 @@ public:
}; };
typedef Modifiable_priority_queue<halfedge_descriptor, Compare_cost, edge_id> PQ; typedef Modifiable_priority_queue<halfedge_descriptor, Compare_cost, edge_id> PQ;
typedef typename PQ::handle PQ_handle;
// An Edge_data is associated with EVERY _ edge in the mesh (collapsable or not). // An Edge_data is associated with EVERY _ edge in the mesh (collapsable or not).
// It relates the edge with the PQ-handle needed to update the priority queue // It contains the edge status wrt the priority queue
// It also relates the edge with a policy-based cache // It also relates the edge with a policy-based cache
class Edge_data struct Edge_data
{ {
public :
Edge_data() : m_PQ_h() {}
const Cost_type& cost() const { return m_cost; } const Cost_type& cost() const { return m_cost; }
Cost_type& cost() { return m_cost; } Cost_type& cost() { return m_cost; }
PQ_handle queue_handle() const { return m_PQ_h;} bool is_in_PQ() const { return m_is_in_PQ; }
bool is_in_PQ() const { return m_PQ_h != PQ::null_handle(); } void set_is_in_PQ() { m_is_in_PQ=true; }
void set_PQ_handle(PQ_handle h) { m_PQ_h = h; } void reset_in_queue_status() { m_is_in_PQ = false; }
void reset_queue_handle() { m_PQ_h = PQ::null_handle(); }
private: private:
Cost_type m_cost; Cost_type m_cost;
PQ_handle m_PQ_h; bool m_is_in_PQ = false;
}; };
typedef Edge_data* Edge_data_ptr; typedef Edge_data* Edge_data_ptr;
@ -301,7 +296,8 @@ private:
CGAL_expensive_assertion(!data.is_in_PQ()); CGAL_expensive_assertion(!data.is_in_PQ());
CGAL_expensive_assertion(!mPQ->contains(h)); CGAL_expensive_assertion(!mPQ->contains(h));
data.set_PQ_handle(mPQ->push(h)); mPQ->push(h);
data.set_is_in_PQ();
CGAL_expensive_assertion(data.is_in_PQ()); CGAL_expensive_assertion(data.is_in_PQ());
CGAL_expensive_assertion(mPQ->contains(h)); CGAL_expensive_assertion(mPQ->contains(h));
@ -313,7 +309,8 @@ private:
CGAL_expensive_assertion(data.is_in_PQ()); CGAL_expensive_assertion(data.is_in_PQ());
CGAL_expensive_assertion(mPQ->contains(h)); CGAL_expensive_assertion(mPQ->contains(h));
data.set_PQ_handle(mPQ->update(h, data.queue_handle())); mPQ->update(h);
data.set_is_in_PQ();
CGAL_assertion(data.is_in_PQ()); CGAL_assertion(data.is_in_PQ());
CGAL_expensive_assertion(mPQ->contains(h)); CGAL_expensive_assertion(mPQ->contains(h));
@ -325,7 +322,8 @@ private:
CGAL_expensive_assertion(data.is_in_PQ()); CGAL_expensive_assertion(data.is_in_PQ());
CGAL_expensive_assertion(mPQ->contains(h)); CGAL_expensive_assertion(mPQ->contains(h));
data.set_PQ_handle(mPQ->erase(h, data.queue_handle())); mPQ->erase(h);
data.reset_in_queue_status();
CGAL_expensive_assertion(!data.is_in_PQ()); CGAL_expensive_assertion(!data.is_in_PQ());
CGAL_expensive_assertion(!mPQ->contains(h)); CGAL_expensive_assertion(!mPQ->contains(h));
@ -339,7 +337,7 @@ private:
CGAL_assertion(is_primary_edge(*opt_h)); CGAL_assertion(is_primary_edge(*opt_h));
CGAL_expensive_assertion(get_data(*opt_h).is_in_PQ()); CGAL_expensive_assertion(get_data(*opt_h).is_in_PQ());
get_data(*opt_h).reset_queue_handle(); get_data(*opt_h).reset_in_queue_status();
CGAL_expensive_assertion(!get_data(*opt_h).is_in_PQ()); CGAL_expensive_assertion(!get_data(*opt_h).is_in_PQ());
CGAL_expensive_assertion(!mPQ->contains(*opt_h)); CGAL_expensive_assertion(!mPQ->contains(*opt_h));