Commit 439c9150 authored by Sylvain Thery's avatar Sylvain Thery

more compacting functions

parent d66a6841
......@@ -189,6 +189,8 @@ public:
void saveBin(CGoGNostream& fs);
bool loadBin(CGoGNistream& fs);
unsigned int* getTableFree(unsigned int & nb) {nb =m_nbfree; return m_tableFree;}
};
} // namespace CGoGN
......
......@@ -431,14 +431,30 @@ public:
/**
* compact the map
* @warning the quickTraversals needs to be updated
* @param topoOnly compact only the topo ?
*/
void compact(bool topoOnly = false) ;
/**
* compact a container (and update embedding attribute of topo)
* @param orbit orbit of container to compact
* @param frag minimum fragmentation value for compacting (default value 1.0 mean always compact)s
*/
void compactOrbitContainer(unsigned int orbit, float frag=1.0);
/**
* @brief compact if containers are fragmented.
* @warning the quickTraversals needs to be updated
* @param frag if fragmentation (filling) of containers inferior to frag then compact
* @param topoOnly compact only the topo ?
*/
void compactIfNeeded(float frag, bool topoOnly = false) ;
/**
* test if containers are fragmented
* ~1.0 no need to compact
* ~0.0 need to compact
* ~1.0 (full filled) no need to compact
* ~0.0 (lots of holes) need to compact
*/
inline float fragmentation(unsigned int orbit);
......
......@@ -450,6 +450,50 @@ void GenericMap::compact(bool topoOnly)
}
}
void GenericMap::compactOrbitContainer(unsigned int orbit, float frag)
{
std::vector<unsigned int> oldnew;
if (isOrbitEmbedded(orbit) && (fragmentation(orbit)< frag))
{
m_attribs[orbit].compact(oldnew);
for (unsigned int i = m_attribs[DART].begin(); i != m_attribs[DART].end(); m_attribs[DART].next(i))
{
unsigned int& idx = m_embeddings[orbit]->operator[](i);
unsigned int jdx = oldnew[idx];
if (jdx != 0xffffffff)
idx = jdx;
}
}
}
void GenericMap::compactIfNeeded(float frag, bool topoOnly)
{
if (fragmentation(DART)< frag)
compactTopo();
if (topoOnly)
return;
std::vector<unsigned int> oldnew;
for (unsigned int orbit = 0; orbit < NB_ORBITS; ++orbit)
{
if ((orbit != DART) && (isOrbitEmbedded(orbit)) && (fragmentation(orbit)< frag))
{
m_attribs[orbit].compact(oldnew);
for (unsigned int i = m_attribs[DART].begin(); i != m_attribs[DART].end(); m_attribs[DART].next(i))
{
unsigned int& idx = m_embeddings[orbit]->operator[](i);
unsigned int jdx = oldnew[idx];
if (jdx != 0xffffffff)
idx = jdx;
}
}
}
}
void GenericMap::dumpCSV() const
{
......
Markdown is supported
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