From 9f90b980c843ac938aa907a82a44c5141f195939 Mon Sep 17 00:00:00 2001 From: Sylvain Thery Date: Fri, 1 Aug 2014 15:52:32 +0200 Subject: [PATCH] cleaning --- include/Topology/generic/traversor/iterTrav.h | 63 ++++++ .../Topology/generic/traversor/traversor2.h | 77 +++---- .../Topology/generic/traversor/traversor3.h | 206 +++++++++--------- 3 files changed, 210 insertions(+), 136 deletions(-) create mode 100644 include/Topology/generic/traversor/iterTrav.h diff --git a/include/Topology/generic/traversor/iterTrav.h b/include/Topology/generic/traversor/iterTrav.h new file mode 100644 index 00000000..e0dc0071 --- /dev/null +++ b/include/Topology/generic/traversor/iterTrav.h @@ -0,0 +1,63 @@ + +#ifndef __ITERATORIZE__ +#define __ITERATORIZE__ +/** + * template classs that add iterator to Traversor + * to allow the use of c++11 syntax for (auto d : v) + */ +template +class Iteratorize: public TRAV +{ +public: + typedef typename TRAV::MapType MAP; + typedef typename TRAV::IterType ITER; + typedef typename TRAV::ParamType PARAM; + + Iteratorize(const MAP& map, PARAM p): + TRAV(map,p),m_begin(this,TRAV::begin()),m_end(this,TRAV::end()) + {} + + + class iterator + { + Iteratorize* m_ptr; + ITER m_index; + + public: + + inline iterator(Iteratorize* p, ITER i): m_ptr(p),m_index(i){} + + inline iterator& operator++() + { + m_index = m_ptr->next(); + return *this; + } + + inline ITER& operator*() + { + return m_index; + } + + inline bool operator!=(const iterator& it) + { + return m_index.dart != it.m_index.dart; + } + + }; + + inline iterator begin() + { + return m_begin; + } + + inline iterator end() + { + return m_end; + } + +protected: + iterator m_begin; + iterator m_end; +}; + +#endif diff --git a/include/Topology/generic/traversor/traversor2.h b/include/Topology/generic/traversor/traversor2.h index 1a6adb2d..cce2f22a 100644 --- a/include/Topology/generic/traversor/traversor2.h +++ b/include/Topology/generic/traversor/traversor2.h @@ -27,6 +27,7 @@ #include "Topology/generic/dart.h" #include "Topology/generic/cells.h" +#include "Topology/generic/traversor/iterTrav.h" namespace CGoGN { @@ -466,55 +467,55 @@ inline void foreach_adjacent2(MAP& map, Cell c, FUNC f) * template classs that add iterator to Traversor * to allow the use of c++11 syntax for (auto d : v) */ -template -class Iteratorize: public TRAV -{ -public: - typedef typename TRAV::MapType MAP; - typedef typename TRAV::IterType ITER; - typedef typename TRAV::ParamType PARAM; +//template +//class Iteratorize: public TRAV +//{ +//public: +// typedef typename TRAV::MapType MAP; +// typedef typename TRAV::IterType ITER; +// typedef typename TRAV::ParamType PARAM; - Iteratorize(const MAP& map, PARAM p): - TRAV(map,p){} +// Iteratorize(const MAP& map, PARAM p): +// TRAV(map,p){} - class iterator - { - Iteratorize* m_ptr; - ITER m_index; +// class iterator +// { +// Iteratorize* m_ptr; +// ITER m_index; - public: +// public: - inline iterator(Iteratorize* p, ITER i): m_ptr(p),m_index(i){} +// inline iterator(Iteratorize* p, ITER i): m_ptr(p),m_index(i){} - inline iterator& operator++() - { - m_index = m_ptr->next(); - return *this; - } +// inline iterator& operator++() +// { +// m_index = m_ptr->next(); +// return *this; +// } - inline ITER& operator*() - { - return m_index; - } +// inline ITER& operator*() +// { +// return m_index; +// } - inline bool operator!=(const iterator& it) - { - return m_index.dart != it.m_index.dart; - } +// inline bool operator!=(const iterator& it) +// { +// return m_index.dart != it.m_index.dart; +// } - }; +// }; - inline iterator begin() - { - return iterator(this,TRAV::begin()); - } +// inline iterator begin() +// { +// return iterator(this,TRAV::begin()); +// } - inline iterator end() - { - return iterator(this,TRAV::end()); - } +// inline iterator end() +// { +// return iterator(this,TRAV::end()); +// } -}; +//}; // functions that return the traversor+iterator // functions instead of typedef because function diff --git a/include/Topology/generic/traversor/traversor3.h b/include/Topology/generic/traversor/traversor3.h index f6f52fc2..0168acd2 100644 --- a/include/Topology/generic/traversor/traversor3.h +++ b/include/Topology/generic/traversor/traversor3.h @@ -30,6 +30,7 @@ #include "Topology/generic/cellmarker.h" #include "Topology/generic/traversor/traversorCell.h" #include "Topology/generic/traversor/traversorDoO.h" +#include "Topology/generic/traversor/iterTrav.h" namespace CGoGN { @@ -88,7 +89,6 @@ public: m_dmark = tra.m_dmark; m_cmark = tra.m_cmark; m_current = tra.m_current; -// m_tradoo = std::move(tra.m_tradoo); } Cell begin() ; @@ -393,205 +393,215 @@ inline void foreach_adjacent3(MAP& map, Cell c, FUNC f, bool forceDartMar * template classs that add iterator to Traversor * to allow the use of c++11 syntax for (auto d : v) */ -template -class Iteratorize3: public TRAV -{ -public: - typedef typename TRAV::MapType MAP; - typedef typename TRAV::IterType ITER; - typedef typename TRAV::ParamType PARAM; - - Iteratorize3(const MAP& map, PARAM p): - TRAV(map,p){} - - - class iterator - { - Iteratorize3* m_ptr; - ITER m_index; - - public: - - inline iterator(Iteratorize3* p, ITER i): m_ptr(p),m_index(i){} - - inline iterator& operator++() - { - m_index = m_ptr->next(); - return *this; - } - - inline ITER& operator*() - { - return m_index; - } - - inline bool operator!=(const iterator& it) - { - return m_index.dart != it.m_index.dart; - } - - }; - - inline iterator begin() - { - return iterator(this,TRAV::begin()); - } - - inline iterator end() - { - return iterator(this,TRAV::end()); - } -}; +//template +//class Iteratorize3: public TRAV +//{ +//public: +// typedef typename TRAV::MapType MAP; +// typedef typename TRAV::IterType ITER; +// typedef typename TRAV::ParamType PARAM; + +// Iteratorize3(const MAP& map, PARAM p): +// TRAV(map,p),m_begin(this,TRAV::begin()),m_end(this,TRAV::end()) +// { +//// m_begin = this->begin(); +//// m_end = this->end(); +// } + + +// class iterator +// { +// Iteratorize3* m_ptr; +// ITER m_index; + +// public: + +// inline iterator(Iteratorize3* p, ITER i): m_ptr(p),m_index(i){} + +// inline iterator& operator++() +// { +// m_index = m_ptr->next(); +// return *this; +// } + +// inline ITER& operator*() +// { +// return m_index; +// } + +// inline bool operator!=(const iterator& it) +// { +// return m_index.dart != it.m_index.dart; +// } + +// }; + +// inline iterator begin() +// { +//// return iterator(this,TRAV::begin()); +// return m_begin; +// } + +// inline iterator end() +// { +//// return iterator(this,TRAV::end()); +// return m_end; +// } + +//protected: +// iterator m_begin; +// iterator m_end; +//}; // functions that return the traversor+iterator // functions instead of typedef because function // allows the compiler to deduce template param template -inline Iteratorize3< Traversor3VE > edgesIncidentToVertex3(const MAP& m, Vertex c) +inline Iteratorize< Traversor3VE > edgesIncidentToVertex3(const MAP& m, Vertex c) { - return Iteratorize3< Traversor3VE >(m, c); + return Iteratorize< Traversor3VE >(m, c); } template -inline Iteratorize3< Traversor3VF > facesIncidentToVertex3(const MAP& m, Vertex c) +inline Iteratorize< Traversor3VF > facesIncidentToVertex3(const MAP& m, Vertex c) { - return Iteratorize3< Traversor3VF >(m, c); + return Iteratorize< Traversor3VF >(m, c); } template -inline Iteratorize3< Traversor3VW > VolumesIncidentToVertex3(const MAP& m, Vertex c) +inline Iteratorize< Traversor3VW > VolumesIncidentToVertex3(const MAP& m, Vertex c) { - return Iteratorize3< Traversor3VW >(m, c); + return Iteratorize< Traversor3VW >(m, c); } template -inline Iteratorize3< Traversor3EV > verticesIncidentToEdge3(const MAP& m, Edge c) +inline Iteratorize< Traversor3EV > verticesIncidentToEdge3(const MAP& m, Edge c) { - return Iteratorize3< Traversor3EV >(m, c); + return Iteratorize< Traversor3EV >(m, c); } template -inline Iteratorize3< Traversor3EF > facesIncidentToEdge3(const MAP& m, Edge c) +inline Iteratorize< Traversor3EF > facesIncidentToEdge3(const MAP& m, Edge c) { - return Iteratorize3< Traversor3EF >(m, c); + return Iteratorize< Traversor3EF >(m, c); } template -inline Iteratorize3< Traversor3EW > volumesIncidentToEdge3(const MAP& m, Edge c) +inline Iteratorize< Traversor3EW > volumesIncidentToEdge3(const MAP& m, Edge c) { - return Iteratorize3< Traversor3EW >(m, c); + return Iteratorize< Traversor3EW >(m, c); } template -inline Iteratorize3< Traversor3FV > verticesIncidentToFace3(const MAP& m, Face c) +inline Iteratorize< Traversor3FV > verticesIncidentToFace3(const MAP& m, Face c) { - return Iteratorize3< Traversor3FV >(m, c); + return Iteratorize< Traversor3FV >(m, c); } template -inline Iteratorize3< Traversor3FE > edgesIncidentToFace3(const MAP& m, Face c) +inline Iteratorize< Traversor3FE > edgesIncidentToFace3(const MAP& m, Face c) { - return Iteratorize3< Traversor3FE >(m, c); + return Iteratorize< Traversor3FE >(m, c); } template -inline Iteratorize3< Traversor3FW > volumesIncidentToFace3(const MAP& m, Face c) +inline Iteratorize< Traversor3FW > volumesIncidentToFace3(const MAP& m, Face c) { - return Iteratorize3< Traversor3FW >(m, c); + return Iteratorize< Traversor3FW >(m, c); } template -inline Iteratorize3< Traversor3WV > verticesIncidentToVolume3(const MAP& m, Vol c) +inline Iteratorize< Traversor3WV > verticesIncidentToVolume3(const MAP& m, Vol c) { - return Iteratorize3< Traversor3WV >(m, c); + return Iteratorize< Traversor3WV >(m, c); } template -inline Iteratorize3< Traversor3WE > edgesIncidentToVolume3(const MAP& m, Vol c) +inline Iteratorize< Traversor3WE > edgesIncidentToVolume3(const MAP& m, Vol c) { - return Iteratorize3< Traversor3WE >(m, c); + return Iteratorize< Traversor3WE >(m, c); } template -inline Iteratorize3< Traversor3WF > facesIncidentToVolume3(const MAP& m, Vol c) +inline Iteratorize< Traversor3WF > facesIncidentToVolume3(const MAP& m, Vol c) { - return Iteratorize3< Traversor3WF >(m, c); + return Iteratorize< Traversor3WF >(m, c); } template -inline Iteratorize3< Traversor3VVaE > verticesAdjacentByEdge3(const MAP& m, Vertex c) +inline Iteratorize< Traversor3VVaE > verticesAdjacentByEdge3(const MAP& m, Vertex c) { - return Iteratorize3< Traversor3VVaE >(m, c); + return Iteratorize< Traversor3VVaE >(m, c); } template -inline Iteratorize3< Traversor3VVaF > verticesAdjacentByFace3(const MAP& m, Vertex c) +inline Iteratorize< Traversor3VVaF > verticesAdjacentByFace3(const MAP& m, Vertex c) { - return Iteratorize3< Traversor3VVaF >(m, c); + return Iteratorize< Traversor3VVaF >(m, c); } template -inline Iteratorize3< Traversor3VVaW > verticesAdjacentByVolume3(const MAP& m, Vertex c) +inline Iteratorize< Traversor3VVaW > verticesAdjacentByVolume3(const MAP& m, Vertex c) { - return Iteratorize3< Traversor3VVaW >(m, c); + return Iteratorize< Traversor3VVaW >(m, c); } template -inline Iteratorize3< Traversor3EEaV > edgesAdjacentByVertex3(const MAP& m, Edge c) +inline Iteratorize< Traversor3EEaV > edgesAdjacentByVertex3(const MAP& m, Edge c) { - return Iteratorize3< Traversor3EEaV >(m, c); + return Iteratorize< Traversor3EEaV >(m, c); } template -inline Iteratorize3< Traversor3EEaF > edgesAdjacentByFace3(const MAP& m, Edge c) +inline Iteratorize< Traversor3EEaF > edgesAdjacentByFace3(const MAP& m, Edge c) { - return Iteratorize3< Traversor3EEaF >(m, c); + return Iteratorize< Traversor3EEaF >(m, c); } template -inline Iteratorize3< Traversor3EEaW > edgesAdjacentByVolume3(const MAP& m, Edge c) +inline Iteratorize< Traversor3EEaW > edgesAdjacentByVolume3(const MAP& m, Edge c) { - return Iteratorize3< Traversor3EEaW >(m, c); + return Iteratorize< Traversor3EEaW >(m, c); } template -inline Iteratorize3< Traversor3FFaV > facesAdjacentByVertex3(const MAP& m, Face c) +inline Iteratorize< Traversor3FFaV > facesAdjacentByVertex3(const MAP& m, Face c) { - return Iteratorize3< Traversor3FFaV >(m, c); + return Iteratorize< Traversor3FFaV >(m, c); } template -inline Iteratorize3< Traversor3FFaE > facesAdjacentByEdge3(const MAP& m, Face c) +inline Iteratorize< Traversor3FFaE > facesAdjacentByEdge3(const MAP& m, Face c) { - return Iteratorize3< Traversor3FFaE >(m, c); + return Iteratorize< Traversor3FFaE >(m, c); } template -inline Iteratorize3< Traversor3FFaW > facesAdjacentByVolume3(const MAP& m, Face c) +inline Iteratorize< Traversor3FFaW > facesAdjacentByVolume3(const MAP& m, Face c) { - return Iteratorize3< Traversor3FFaW >(m, c); + return Iteratorize< Traversor3FFaW >(m, c); } template -inline Iteratorize3< Traversor3WWaV > volumesAdjacentByVertex3(const MAP& m, Vol c) +inline Iteratorize< Traversor3WWaV > volumesAdjacentByVertex3(const MAP& m, Vol c) { - return Iteratorize3< Traversor3WWaV >(m, c); + return Iteratorize< Traversor3WWaV >(m, c); } template -inline Iteratorize3< Traversor3WWaE > volumesAdjacentByEdge3(const MAP& m, Vol c) +inline Iteratorize< Traversor3WWaE > volumesAdjacentByEdge3(const MAP& m, Vol c) { - return Iteratorize3< Traversor3WWaE >(m, c); + return Iteratorize< Traversor3WWaE >(m, c); } template -inline Iteratorize3< Traversor3WWaF > volumesAdjacentByFace3(const MAP& m, Vol c) +inline Iteratorize< Traversor3WWaF > volumesAdjacentByFace3(const MAP& m, Vol c) { - return Iteratorize3< Traversor3WWaF >(m, c); + return Iteratorize< Traversor3WWaF >(m, c); } -- GitLab