Commit e8fa744a authored by Jan Möbius's avatar Jan Möbius
Browse files

Merge branch 'heap-tweaks' into 'master'

Tweaks to HeapT.hh, Additional member for ArrayKernel



See merge request !27
parents daa256e3 ec8936bf
Pipeline #106 passed with stage
......@@ -177,6 +177,16 @@ void ArrayKernel::garbage_collection(bool _v, bool _e, bool _f)
garbage_collection( empty_vh,empty_hh,empty_fh,_v, _e, _f);
}
void ArrayKernel::clean_keep_reservation()
{
vertices_.clear();
edges_.clear();
faces_.clear();
}
void ArrayKernel::clean()
{
......
......@@ -306,6 +306,14 @@ public:
*/
void clean();
/** \brief Reset the whole mesh
*
* This will remove all elements from the mesh but keeps the properties.
* In contrast to clean() the memory used for the elements will remain
* allocated.
*/
void clean_keep_reservation();
// --- number of items ---
size_t n_vertices() const { return vertices_.size(); }
size_t n_halfedges() const { return 2*edges_.size(); }
......
......@@ -79,6 +79,9 @@
#include "Config.hh"
#include <vector>
#include <OpenMesh/Core/System/omstream.hh>
#if __cplusplus > 199711L || defined(__GXX_EXPERIMENTAL_CXX0X__)
#include <utility>
#endif
//== NAMESPACE ================================================================
......@@ -147,14 +150,28 @@ public:
/// Constructor
HeapT() : HeapVector() {}
#if __cplusplus > 199711L || defined(__GXX_EXPERIMENTAL_CXX0X__)
/// Construct with a given \c HeapIterface.
HeapT(const HeapInterface& _interface)
HeapT(HeapInterface _interface)
: HeapVector(), interface_(std::move(_interface))
{}
#else
/// Construct with a given \c HeapIterface.
HeapT(const HeapInterface &_interface)
: HeapVector(), interface_(_interface)
{}
#endif
/// Destructor.
~HeapT(){};
HeapInterface &getInterface() {
return interface_;
}
const HeapInterface &getInterface() const {
return interface_;
}
/// clear the heap
void clear() { HeapVector::clear(); }
......@@ -187,14 +204,14 @@ public:
HeapEntry front() const
{
assert(!empty());
return entry(0);
return HeapVector::front();
}
/// delete the first entry
void pop_front()
{
assert(!empty());
reset_heap_position(entry(0));
reset_heap_position(HeapVector::front());
if (size() > 1)
{
entry(0, entry(size()-1));
......@@ -338,9 +355,9 @@ void
HeapT<HeapEntry, HeapInterface>::
downheap(size_t _idx)
{
HeapEntry h = entry(_idx);
const HeapEntry h = entry(_idx);
size_t childIdx;
size_t s = size();
const size_t s = size();
while(_idx < s)
{
......
Supports Markdown
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