private Strip FindBestStrip() { //Allow to restore the cache (modified by ExtendTriToStrip) and implicitly reset the cache hit count CacheSimulator CacheBackup = m_Cache; Policy policy = new Policy(m_MinStripSize, Cache); while (m_Candidates.Count != 0) { uint Candidate = m_Candidates[m_Candidates.Count - 1]; m_Candidates.RemoveAt(m_Candidates.Count - 1); //Discard useless triangles from the candidate list if ((m_Triangles[Candidate].Marked) || (m_TriHeap[Candidate] == 0)) { continue; } //Try to extend the triangle in the 3 possible forward directions for (uint i = 0; i < 3; i++) { Strip Strip = ExtendToStrip(Candidate, (TriOrder)i); policy.Challenge(Strip, m_TriHeap[Strip.Start], m_Cache.HitCount); m_Cache = CacheBackup; } //Try to extend the triangle in the 6 possible backward directions if (m_BackwardSearch) { for (uint i = 0; i < 3; i++) { Strip Strip = BackExtendToStrip(Candidate, (TriOrder)i, false); if (Strip != null) { policy.Challenge(Strip, m_TriHeap[Strip.Start], m_Cache.HitCount); } m_Cache = CacheBackup; } for (uint i = 0; i < 3; i++) { Strip Strip = BackExtendToStrip(Candidate, (TriOrder)i, true); if (Strip != null) { policy.Challenge(Strip, m_TriHeap[Strip.Start], m_Cache.HitCount); } m_Cache = CacheBackup; } } } return(policy.BestStrip); }
public void Merge(CacheSimulator Backward, uint PossibleOverlap) { uint Overlap = Math.Min(PossibleOverlap, Size); for (uint i = 0; i < Overlap; ++i) { Push(Backward.m_Cache[i], true); } m_NbHits += Backward.m_NbHits; }
public TriStripper(uint[] TriIndices, ushort[] NodeIds, int[] ImpTable) { m_ImpTable = ImpTable; m_Nodes = NodeIds; m_Triangles = new GraphArray <Triangle>((uint)TriIndices.Length / 3); m_StripID = 0; m_FirstRun = true; m_PrimitivesVector = new List <Primitive>(); m_TriHeap = new HeapArray(CompareType.Less); m_Candidates = new List <uint>(); m_Cache = new CacheSimulator(); m_BackCache = new CacheSimulator(); SetCacheSize(); SetMinStripSize(); SetBackwardSearch(); SetPushCacheHits(); MakeConnectivityGraph(m_Triangles, TriIndices); }