Commit 6a50a13f authored by untereiner's avatar untereiner

Merge cgogn:~kraemer/CGoGN

parents 50ad264b 278bef22
......@@ -198,6 +198,11 @@ public:
*/
void addLevel() ;
/**
* add a resolution level and duplicate all darts (use only in MRMaps)
*/
void addLevelDuplicate() ;
/**
* get the insertion level of a dart (use only in MRMaps)
*/
......
......@@ -46,7 +46,7 @@ inline void GenericMap::setCurrentLevel(unsigned int l)
if(l < m_mrDarts.size())
m_mrCurrentLevel = l ;
else
CGoGNout << "setCurrentLevel : try to access inexisting resolution level" << CGoGNendl ;
CGoGNout << "setCurrentLevel : try to access nonexistent resolution level" << CGoGNendl ;
}
inline void GenericMap::pushLevel()
......@@ -86,10 +86,22 @@ inline Dart GenericMap::newDart()
{
unsigned int mrdi = m_mrattribs.insertLine() ;
m_mrLevels->operator[](mrdi) = m_mrCurrentLevel ;
for(unsigned int i = 0; i < m_mrCurrentLevel; ++i)
m_mrDarts[i]->operator[](mrdi) = MRNULL ;
for(unsigned int i = m_mrCurrentLevel; i < m_mrDarts.size(); ++i)
m_mrDarts[i]->operator[](mrdi) = di ;
m_mrDarts[m_mrCurrentLevel]->operator[](mrdi) = di ;
for(unsigned int i = m_mrCurrentLevel + 1; i < m_mrDarts.size(); ++i)
{
unsigned int dj = m_attribs[DART].insertLine();
for(unsigned int o = 0; o < NB_ORBITS; ++o)
{
if (m_embeddings[o])
(*m_embeddings[o])[dj] = EMBNULL ;
}
m_mrDarts[i]->operator[](mrdi) = dj ;
}
return Dart::create(mrdi) ;
}
return Dart::create(di) ;
......@@ -284,7 +296,7 @@ inline void GenericMap::next(Dart& d)
do
{
m_mrattribs.next(d.index) ;
} while ((d.index != m_mrattribs.end() ) && (getDartLevel(d.index) > m_mrCurrentLevel)) ;
} while (d.index != m_mrattribs.end() && getDartLevel(d) > m_mrCurrentLevel) ;
}
else
m_attribs[DART].next(d.index) ;
......
......@@ -31,189 +31,6 @@
namespace CGoGN
{
//
//template <typename MAP>
//class TraversorCell
//{
//private:
// MAP& m ;
// unsigned int m_orbit ;
// DartMarker* dmark ;
// CellMarker* cmark ;
// Dart current ;
// bool firstTraversal ;
// const FunctorSelect& m_good ;
//
//public:
// TraversorCell(MAP& map, unsigned int orbit, const FunctorSelect& good = allDarts, bool forceDartMarker = false, unsigned int thread = 0) :
// m(map), m_orbit(orbit), dmark(NULL), cmark(NULL), current(NIL), firstTraversal(true), m_good(good)
// {
// if(!forceDartMarker && map.isOrbitEmbedded(m_orbit))
// cmark = new CellMarker(map, m_orbit, thread) ;
// else
// dmark = new DartMarker(map, thread) ;
// }
//
// ~TraversorCell()
// {
// if(dmark)
// delete dmark ;
// else
// delete cmark ;
// }
//
// Dart begin()
// {
// if(!firstTraversal)
// {
// if(dmark)
// dmark->unmarkAll() ;
// else
// cmark->unmarkAll() ;
// }
//
// current = m.begin() ;
// while(current != m.end() && (m.isBoundaryMarked(current) || !m_good(current)))
// m.next(current) ;
//
// if(current == m.end())
// current = NIL ;
// else
// {
// if(dmark)
// dmark->markOrbit(m_orbit, current) ;
// else
// cmark->mark(current) ;
// }
//
// firstTraversal = false ;
// return current ;
// }
//
// Dart end() { return NIL ; }
//
// Dart next()
// {
// if(current != NIL)
// {
// bool ismarked ;
// if(dmark)
// ismarked = dmark->isMarked(current) ;
// else
// ismarked = cmark->isMarked(current) ;
//
// while(current != NIL && (ismarked || m.isBoundaryMarked(current) || !m_good(current)))
// {
// m.next(current) ;
// if(current == m.end())
// current = NIL ;
// else
// {
// if(dmark)
// ismarked = dmark->isMarked(current) ;
// else
// ismarked = cmark->isMarked(current) ;
// }
// }
//
// if(current != NIL)
// {
// if(dmark)
// dmark->markOrbit(m_orbit, current) ;
// else
// cmark->mark(current) ;
// }
// }
// return current ;
// }
//
// void mark(Dart d)
// {
// if(dmark)
// dmark->markOrbit(m_orbit, d) ;
// else
// cmark->mark(d) ;
// }
//} ;
//
//template <typename MAP>
//class TraversorV : public TraversorCell<MAP>
//{
//public:
// TraversorV(MAP& m, const FunctorSelect& good = allDarts, unsigned int thread = 0) : TraversorCell<MAP>(m, VERTEX, good, thread)
// {}
//};
//
//template <typename MAP>
//class TraversorE : public TraversorCell<MAP>
//{
//public:
// TraversorE(MAP& m, const FunctorSelect& good = allDarts, unsigned int thread = 0) : TraversorCell<MAP>(m, EDGE, good, thread)
// {}
//};
//
////template <typename MAP>
////class TraversorOF : public TraversorCell<MAP>
////{
////public:
//// TraversorOF(MAP& m, const FunctorSelect& good = allDarts, unsigned int thread = 0) : TraversorCell<MAP>(m, ORIENTED_FACE, good, thread)
//// {}
////};
//
//
//template <typename MAP>
//class TraversorF : public TraversorCell<MAP>
//{
//public:
// TraversorF(MAP& m, const FunctorSelect& good = allDarts, unsigned int thread = 0) : TraversorCell<MAP>(m, FACE, good, thread)
// {}
//};
//
//template <typename MAP>
//class TraversorW : public TraversorCell<MAP>
//{
//public:
// TraversorW(MAP& m, const FunctorSelect& good = allDarts, unsigned int thread = 0) : TraversorCell<MAP>(m, VOLUME, good, thread)
// {}
//};
//
//
//
//template <typename MAP>
//class TraversorDartsOfOrbit
//{
//private:
// std::vector<Dart>::iterator m_current;
// std::vector<Dart> m_vd;
//
//public:
// TraversorDartsOfOrbit(MAP& map, unsigned int orbit, Dart d, unsigned int thread = 0)
// {
// m_vd.reserve(16);
// FunctorStoreNotBoundary<MAP> fs(map,m_vd);
// map.foreach_dart_of_orbit(orbit, d, fs, thread);
// m_vd.push_back(NIL);
// m_current=m_vd.begin();
// }
//
// Dart begin()
// {
// m_current=m_vd.begin();
// return *m_current;
// }
//
// Dart end(){ return NIL;}
//
// Dart next()
// {
// if (*m_current != NIL)
// m_current++;
// return *m_current;
// }
//} ;
template <typename MAP>
class TraversorCell
......@@ -275,13 +92,12 @@ public:
};
template <typename MAP>
class TraversorDartsOfOrbit
{
private:
std::vector<Dart>::iterator m_current;
std::vector<Dart> m_vd;
std::vector<Dart>::iterator m_current ;
std::vector<Dart> m_vd ;
public:
TraversorDartsOfOrbit(MAP& map, unsigned int orbit, Dart d, unsigned int thread = 0) ;
......
......@@ -27,7 +27,7 @@ namespace CGoGN
template <typename MAP>
TraversorCell<MAP>::TraversorCell(MAP& map, unsigned int orbit, const FunctorSelect& good, bool forceDartMarker, unsigned int thread) :
m(map), m_orbit(orbit), dmark(NULL), cmark(NULL), current(NIL), firstTraversal(true), m_good(good)
m(map), m_orbit(orbit), dmark(NULL), cmark(NULL), current(NIL), firstTraversal(true), m_good(good)
{
if(!forceDartMarker && map.isOrbitEmbedded(m_orbit))
cmark = new CellMarker(map, m_orbit, thread) ;
......@@ -73,10 +73,11 @@ Dart TraversorCell<MAP>::begin()
return current ;
}
template <typename MAP>
Dart TraversorCell<MAP>::end() { return NIL ; }
Dart TraversorCell<MAP>::end()
{
return NIL ;
}
template <typename MAP>
Dart TraversorCell<MAP>::next()
......@@ -124,12 +125,11 @@ void TraversorCell<MAP>::mark(Dart d)
}
template <typename MAP>
TraversorDartsOfOrbit<MAP>::TraversorDartsOfOrbit(MAP& map, unsigned int orbit, Dart d, unsigned int thread)
{
m_vd.reserve(16);
FunctorStoreNotBoundary<MAP> fs(map,m_vd);
FunctorStoreNotBoundary<MAP> fs(map, m_vd);
map.foreach_dart_of_orbit(orbit, d, fs, thread);
m_vd.push_back(NIL);
}
......@@ -137,7 +137,7 @@ TraversorDartsOfOrbit<MAP>::TraversorDartsOfOrbit(MAP& map, unsigned int orbit,
template <typename MAP>
Dart TraversorDartsOfOrbit<MAP>::begin()
{
m_current=m_vd.begin();
m_current = m_vd.begin();
return *m_current;
}
......@@ -155,5 +155,4 @@ Dart TraversorDartsOfOrbit<MAP>::next()
return *m_current;
}
}
} // namespace CGoGN
......@@ -69,9 +69,21 @@ inline void Map1::update_topo_shortcuts()
inline Dart Map1::newDart()
{
Dart d = GenericMap::newDart() ;
unsigned int d_index = dartIndex(d);
unsigned int d_index = dartIndex(d) ;
(*m_phi1)[d_index] = d ;
(*m_phi_1)[d_index] = d ;
if(m_isMultiRes)
{
pushLevel() ;
for(unsigned int i = m_mrCurrentLevel + 1; i < m_mrDarts.size(); ++i)
{
setCurrentLevel(i) ;
unsigned int d_index = dartIndex(d) ;
(*m_phi1)[d_index] = d ;
(*m_phi_1)[d_index] = d ;
}
popLevel() ;
}
return d ;
}
......
......@@ -67,14 +67,22 @@ inline void Map2::update_topo_shortcuts()
inline Dart Map2::newDart()
{
Dart d = Map1::newDart() ;
// unsigned int d_index = dartIndex(d);
(*m_phi2)[dartIndex(d)] = d ;
if(m_isMultiRes)
{
pushLevel() ;
for(unsigned int i = m_mrCurrentLevel + 1; i < m_mrDarts.size(); ++i)
{
setCurrentLevel(i) ;
(*m_phi2)[dartIndex(d)] = d ;
}
popLevel() ;
}
return d ;
}
inline Dart Map2::phi2(Dart d)
{
// unsigned int d_index = dartIndex(d);
return (*m_phi2)[dartIndex(d)] ;
}
......@@ -139,8 +147,7 @@ inline void Map2::phi2unsew(Dart d)
unsigned int d_index = dartIndex(d);
Dart e = (*m_phi2)[d_index] ;
(*m_phi2)[d_index] = d ;
unsigned int e_index = dartIndex(e);
(*m_phi2)[e_index] = e ;
(*m_phi2)[dartIndex(e)] = e ;
}
/*! @name Topological Queries
......
......@@ -65,8 +65,17 @@ inline void Map3::update_topo_shortcuts()
inline Dart Map3::newDart()
{
Dart d = Map2::newDart() ;
unsigned int d_index = dartIndex(d);
(*m_phi3)[d_index] = d ;
(*m_phi3)[dartIndex(d)] = d ;
if(m_isMultiRes)
{
pushLevel() ;
for(unsigned int i = m_mrCurrentLevel + 1; i < m_mrDarts.size(); ++i)
{
setCurrentLevel(i) ;
(*m_phi3)[dartIndex(d)] = d ;
}
popLevel() ;
}
return d ;
}
......
......@@ -170,15 +170,27 @@ void GenericMap::clear(bool removeAttrib)
void GenericMap::addLevel()
{
unsigned int level = m_mrDarts.size() ;
unsigned int newLevel = m_mrDarts.size() ;
std::stringstream ss ;
ss << "MRdart_"<< level ;
ss << "MRdart_"<< newLevel ;
AttributeMultiVector<unsigned int>* amvMR = m_mrattribs.addAttribute<unsigned int>(ss.str()) ;
m_mrDarts.push_back(amvMR) ;
// copy the darts pointers of the previous level
if(m_mrDarts.size() > 1)
m_mrattribs.copyAttribute(amvMR->getIndex(), m_mrDarts[m_mrDarts.size() - 2]->getIndex()) ;
m_mrattribs.copyAttribute(amvMR->getIndex(), m_mrDarts[newLevel - 1]->getIndex()) ;
// duplicate all the darts in the new level
for(unsigned int i = m_mrattribs.begin(); i != m_mrattribs.end(); m_mrattribs.next(i))
{
unsigned int oldi = amvMR->operator[](i) ;
unsigned int newi = m_attribs[DART].insertLine() ;
m_attribs[DART].copyLine(newi, oldi) ;
amvMR->operator[](i) = newi ;
for(unsigned int t = 0; t < m_nbThreads; ++t)
m_markTables[DART][t]->operator[](newi).clear() ;
}
}
/****************************************
......@@ -206,7 +218,7 @@ void GenericMap::setDartEmbedding(unsigned int orbit, Dart d, unsigned int emb)
if (emb != EMBNULL)
m_attribs[orbit].refLine(emb);
// affect the embedding to the dart
(*m_embeddings[orbit])[d.index] = emb ;
(*m_embeddings[orbit])[dartIndex(d)] = emb ;
}
/****************************************
......@@ -785,17 +797,17 @@ void GenericMap::viewAttributesTables()
void GenericMap::boundaryMark(Dart d)
{
m_markTables[DART][0]->operator[](d.index).setMark(m_boundaryMarker);
m_markTables[DART][0]->operator[](dartIndex(d)).setMark(m_boundaryMarker);
}
void GenericMap::boundaryUnmark(Dart d)
{
m_markTables[DART][0]->operator[](d.index).unsetMark(m_boundaryMarker);
m_markTables[DART][0]->operator[](dartIndex(d)).unsetMark(m_boundaryMarker);
}
bool GenericMap::isBoundaryMarked(Dart d)
{
return m_markTables[DART][0]->operator[](d.index).testMark(m_boundaryMarker);
return m_markTables[DART][0]->operator[](dartIndex(d)).testMark(m_boundaryMarker);
}
void GenericMap::boundaryMarkOrbit(unsigned int orbit, Dart d)
......
This diff is collapsed.
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