Re-factored the Heap-Simplex ratio parameter. Now it is something that should be asked to the localmodification class.

This commit is contained in:
Paolo Cignoni 2008-07-10 09:44:09 +00:00
parent 6be78dcf70
commit b626643efb
2 changed files with 10 additions and 5 deletions

View File

@ -138,6 +138,13 @@ class LocalModification
/// perform initialization /// perform initialization
static void Init(MeshType &m, HeapType&); static void Init(MeshType &m, HeapType&);
/// An approximation of the size of the heap with respect of the number of simplex
/// of the mesh. When this number is exceeded a clear heap purging is performed.
/// so it is should be reasonably larger than the minimum expected size to avoid too frequent clear heap
/// For example for symmetric edge collapse a 5 is a good guess.
/// while for non symmetric edge collapse a larger number like 9 is a better choice
static float HeapSimplexRatio() {return 6.0f;} ;
virtual const char *Info(MeshType &) {return 0;} virtual const char *Info(MeshType &) {return 0;}
/// Update the heap as a consequence of this operation /// Update the heap as a consequence of this operation
virtual void UpdateHeap(HeapType&)=0; virtual void UpdateHeap(HeapType&)=0;
@ -334,10 +341,8 @@ void ClearHeap()
{ {
m.InitVertexIMark(); m.InitVertexIMark();
// This is a small hack. In case of non-simmertric collapses the average number of // The expected size of heap depends on the type of the local modification we are using..
// heap elements is almost the double of the symmetric case so the minium would be 6*face number > the default 5*facenumber; HeapSimplexRatio = LocalModificationType::HeapSimplexRatio();
// 9*fn is a good guess that avoid too frequent heap garbage collections.
if(!LocalModificationType::IsSymmetric()) HeapSimplexRatio=9;
LocalModificationType::Init(m,h); LocalModificationType::Init(m,h);
std::make_heap(h.begin(),h.end()); std::make_heap(h.begin(),h.end());

View File

@ -338,7 +338,7 @@ public:
} }
} }
} }
static float HeapSimplexRatio() {return IsSymmetric()?5.0f:9.0f;}
static bool IsSymmetric() {return Params().OptimalPlacement;} static bool IsSymmetric() {return Params().OptimalPlacement;}
static bool IsVertexStable() {return !Params().OptimalPlacement;} static bool IsVertexStable() {return !Params().OptimalPlacement;}
static void SetDefaultParams(){ static void SetDefaultParams(){