Merge branch 'heap-tweaks' into 'master'
Tweaks to HeapT.hh, Additional member for ArrayKernel See merge request !27
This commit is contained in:
@@ -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);
|
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()
|
void ArrayKernel::clean()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|||||||
@@ -306,6 +306,14 @@ public:
|
|||||||
*/
|
*/
|
||||||
void clean();
|
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 ---
|
// --- number of items ---
|
||||||
size_t n_vertices() const { return vertices_.size(); }
|
size_t n_vertices() const { return vertices_.size(); }
|
||||||
size_t n_halfedges() const { return 2*edges_.size(); }
|
size_t n_halfedges() const { return 2*edges_.size(); }
|
||||||
|
|||||||
@@ -79,6 +79,9 @@
|
|||||||
#include "Config.hh"
|
#include "Config.hh"
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <OpenMesh/Core/System/omstream.hh>
|
#include <OpenMesh/Core/System/omstream.hh>
|
||||||
|
#if __cplusplus > 199711L || defined(__GXX_EXPERIMENTAL_CXX0X__)
|
||||||
|
#include <utility>
|
||||||
|
#endif
|
||||||
|
|
||||||
//== NAMESPACE ================================================================
|
//== NAMESPACE ================================================================
|
||||||
|
|
||||||
@@ -147,14 +150,28 @@ public:
|
|||||||
/// Constructor
|
/// Constructor
|
||||||
HeapT() : HeapVector() {}
|
HeapT() : HeapVector() {}
|
||||||
|
|
||||||
|
#if __cplusplus > 199711L || defined(__GXX_EXPERIMENTAL_CXX0X__)
|
||||||
|
/// Construct with a given \c HeapIterface.
|
||||||
|
HeapT(HeapInterface _interface)
|
||||||
|
: HeapVector(), interface_(std::move(_interface))
|
||||||
|
{}
|
||||||
|
#else
|
||||||
/// Construct with a given \c HeapIterface.
|
/// Construct with a given \c HeapIterface.
|
||||||
HeapT(const HeapInterface &_interface)
|
HeapT(const HeapInterface &_interface)
|
||||||
: HeapVector(), interface_(_interface)
|
: HeapVector(), interface_(_interface)
|
||||||
{}
|
{}
|
||||||
|
#endif
|
||||||
|
|
||||||
/// Destructor.
|
/// Destructor.
|
||||||
~HeapT(){};
|
~HeapT(){};
|
||||||
|
|
||||||
|
HeapInterface &getInterface() {
|
||||||
|
return interface_;
|
||||||
|
}
|
||||||
|
|
||||||
|
const HeapInterface &getInterface() const {
|
||||||
|
return interface_;
|
||||||
|
}
|
||||||
|
|
||||||
/// clear the heap
|
/// clear the heap
|
||||||
void clear() { HeapVector::clear(); }
|
void clear() { HeapVector::clear(); }
|
||||||
@@ -187,14 +204,14 @@ public:
|
|||||||
HeapEntry front() const
|
HeapEntry front() const
|
||||||
{
|
{
|
||||||
assert(!empty());
|
assert(!empty());
|
||||||
return entry(0);
|
return HeapVector::front();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// delete the first entry
|
/// delete the first entry
|
||||||
void pop_front()
|
void pop_front()
|
||||||
{
|
{
|
||||||
assert(!empty());
|
assert(!empty());
|
||||||
reset_heap_position(entry(0));
|
reset_heap_position(HeapVector::front());
|
||||||
if (size() > 1)
|
if (size() > 1)
|
||||||
{
|
{
|
||||||
entry(0, entry(size()-1));
|
entry(0, entry(size()-1));
|
||||||
@@ -338,9 +355,9 @@ void
|
|||||||
HeapT<HeapEntry, HeapInterface>::
|
HeapT<HeapEntry, HeapInterface>::
|
||||||
downheap(size_t _idx)
|
downheap(size_t _idx)
|
||||||
{
|
{
|
||||||
HeapEntry h = entry(_idx);
|
const HeapEntry h = entry(_idx);
|
||||||
size_t childIdx;
|
size_t childIdx;
|
||||||
size_t s = size();
|
const size_t s = size();
|
||||||
|
|
||||||
while(_idx < s)
|
while(_idx < s)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user