Commit 15b9e2d5 authored by Sylvain Thery's avatar Sylvain Thery

MapBrowser instead of selector

parent 9e0a96cf
......@@ -175,21 +175,21 @@ bool OBJModel<PFP>::generateBrowsers(std::vector<MapBrowser*>& browsers)
if (m_groupNames.empty())
return false;
MapBrowserLinked<typename PFP::MAP>* MBLptr = new MapBrowserLinked<typename PFP::MAP>(m_map);
MapBrowserLinked* MBLptr = new MapBrowserLinked(m_map);
DartAttribute<Dart>& links = MBLptr->getLinkAttr();
browsers.push_back(MBLptr);
for (unsigned int i = 1; i<m_groupNames.size(); ++i)
{
MapBrowser* MBptr = new MapBrowserLinked<typename PFP::MAP>(m_map,links);
MapBrowser* MBptr = new MapBrowserLinked(m_map,links);
browsers.push_back(MBptr);
}
for (Dart d=m_map.begin(); d!=m_map.end(); m_map.next(d))
{
unsigned int g = m_groups[d] -1 ; // groups are name from 1
MapBrowserLinked<typename PFP::MAP>* mb = static_cast<MapBrowserLinked<typename PFP::MAP>*>(browsers[g]);
mb->push_back(d);
MapBrowserLinked* mb = static_cast<MapBrowserLinked*>(browsers[g]);
mb->pushBack(d);
}
return true;
}
......
......@@ -610,7 +610,6 @@ inline void GenericMap::realNext(Dart& d) const
}
else
{
m_attribs[DART].next(d.index) ;
}
}
......@@ -618,52 +617,74 @@ inline void GenericMap::realNext(Dart& d) const
inline Dart GenericMap::begin() const
{
if (m_isMultiRes)
{
unsigned int d = m_mrattribs.begin() ;
if(d != m_mrattribs.end())
{
while (getDartLevel(d) > m_mrCurrentLevel)
m_mrattribs.next(d) ;
}
return Dart::create(d) ;
}
if (m_currentBrowser != NULL)
return m_currentBrowser->begin();
return Dart::create(m_attribs[DART].begin()) ;
return GenericMap::realBegin();
}
inline Dart GenericMap::end() const
{
if (m_isMultiRes)
return Dart::create(m_mrattribs.end()) ;
if (m_currentBrowser != NULL)
return m_currentBrowser->end();
return Dart::create(m_attribs[DART].end()) ;
return GenericMap::realEnd();
}
inline void GenericMap::next(Dart& d) const
{
if (m_isMultiRes)
{
do
{
m_mrattribs.next(d.index) ;
} while (d.index != m_mrattribs.end() && getDartLevel(d) > m_mrCurrentLevel) ;
}
if (m_currentBrowser != NULL)
m_currentBrowser->next(d);
else
{
if (m_currentBrowser != NULL)
return m_currentBrowser->next(d);
else
m_attribs[DART].next(d.index) ;
}
}
realNext(d);
}
//inline Dart GenericMap::begin() const
//{
// if (m_isMultiRes)
// {
// unsigned int d = m_mrattribs.begin() ;
// if(d != m_mrattribs.end())
// {
// while (getDartLevel(d) > m_mrCurrentLevel)
// m_mrattribs.next(d) ;
// }
// return Dart::create(d) ;
// }
// if (m_currentBrowser != NULL)
// return m_currentBrowser->begin();
// return Dart::create(m_attribs[DART].begin()) ;
//}
//inline Dart GenericMap::end() const
//{
// if (m_isMultiRes)
// return Dart::create(m_mrattribs.end()) ;
// if (m_currentBrowser != NULL)
// return m_currentBrowser->end();
// return Dart::create(m_attribs[DART].end()) ;
//}
//inline void GenericMap::next(Dart& d) const
//{
// if (m_isMultiRes)
// {
// do
// {
// m_mrattribs.next(d.index) ;
// } while (d.index != m_mrattribs.end() && getDartLevel(d) > m_mrCurrentLevel) ;
// }
// else
// {
// if (m_currentBrowser != NULL)
// return m_currentBrowser->next(d);
// else
// m_attribs[DART].next(d.index) ;
// }
//}
template <unsigned int ORBIT>
bool GenericMap::foreach_dart_of_orbit(Dart d, FunctorType& f, unsigned int thread)
......
......@@ -42,29 +42,15 @@ class MapBrowserSelector : public MapBrowser
protected:
AttribMap& m_map ;
const FunctorSelect& m_selector ;
public:
MapBrowserSelector(AttribMap& m, const FunctorSelect& fs) :
m_map(m), m_selector(fs)
{}
inline Dart begin() const
{
return m_map.realBegin() ;
}
inline Dart end() const
{
return m_map.realEnd() ;
}
inline void next(Dart& d) const
{
do
{
m_map.realNext(d) ;
}
while ( (d != m_map.realEnd()) && !m_selector(d) ) ;
}
MapBrowserSelector(AttribMap& m, const FunctorSelect& fs);
Dart begin() const;
Dart end() const;
void next(Dart& d) const;
} ;
/**
......@@ -88,109 +74,40 @@ protected:
Dart m_end ;
public:
MapBrowserLinked(AttribMap& m) :
m_map(m), autoAttribute(true), m_first(NIL), m_end(NIL)
{
m_links = m.addAttribute<Dart, DART>("") ;
}
MapBrowserLinked(AttribMap& m, DartAttribute<Dart>& links) :
m_map(m), autoAttribute(false), m_links(links), m_first(NIL), m_end(NIL)
{
}
MapBrowserLinked(AttribMap& m);
MapBrowserLinked(AttribMap& m, DartAttribute<Dart>& links);
MapBrowserLinked(AttribMap& m, DartAttribute<Dart>& links, Dart first, Dart end) :
m_map(m), autoAttribute(false), m_links(links), m_first(first), m_end(end)
{
}
~MapBrowserLinked()
{
if (autoAttribute)
m_map.removeAttribute(m_links) ;
}
inline DartAttribute<Dart>& getLinkAttr()
{
return m_links;
}
MapBrowserLinked(AttribMap& m, DartAttribute<Dart>& links, Dart first, Dart end);
~MapBrowserLinked();
DartAttribute<Dart>& getLinkAttr();
inline void clear()
{
m_first = NIL ;
m_end = NIL ;
}
inline Dart begin() const
{
return m_first ;
}
inline Dart end() const
{
return NIL ;
}
inline void next(Dart& d) const
{
assert(d != NIL) ;
d = m_links[d] ;
}
void pushFront(Dart d)
{
assert(d != NIL) ;
m_links[d] = m_first ;
m_first = d ;
if (m_end == NIL) // empty list
m_end = d ;
}
void pushBack(Dart d)
{
assert(d != NIL) ;
m_links[d] = NIL ;
if (m_first == NIL) // empty list
{
m_first = d ;
m_end = d ;
}
else
{
m_links[m_end] = d ;
m_end = d ;
}
}
void popFront()
{
if (m_first == m_end) // one element or empty list
{
m_first = NIL ;
m_end = NIL ;
}
else m_first = m_links[m_first] ;
}
void addSelected(const FunctorSelect& fs)
{
for (Dart d = m_map.begin() ; d != m_map.end() ; m_map.next(d))
{
if (fs(d))
// pushFront(d) ;
pushBack(d); // better tot use push_back for memory access
}
}
void clear();
Dart begin() const;
Dart end() const;
void next(Dart& d) const;
void pushFront(Dart d);
void pushBack(Dart d);
void popFront();
void addSelected(const FunctorSelect& fs);
// operator() for use of foreach_cell
bool operator()(Dart d)
{
pushFront(d) ;
return false ;
}
bool operator()(Dart d);
void append(MapBrowserLinked& mbl);
} ;
} // namespace CGoGN
#include "mapBrowser.hpp"
#endif /* MAPBROWSER_H_ */
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