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