/******************************************************************************* * CGoGN: Combinatorial and Geometric modeling with Generic N-dimensional Maps * * version 0.1 * * Copyright (C) 2009-2012, IGG Team, LSIIT, University of Strasbourg * * * * This library is free software; you can redistribute it and/or modify it * * under the terms of the GNU Lesser General Public License as published by the * * Free Software Foundation; either version 2.1 of the License, or (at your * * option) any later version. * * * * This library is distributed in the hope that it will be useful, but WITHOUT * * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * * for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this library; if not, write to the Free Software Foundation, * * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * * * * Web site: http://cgogn.unistra.fr/ * * Contact information: cgogn@unistra.fr * * * *******************************************************************************/ #ifndef __TRAVERSOR2_H__ #define __TRAVERSOR2_H__ #include "Topology/generic/dart.h" #include "Topology/generic/cells.h" #include "Topology/generic/traversor/iterTrav.h" namespace CGoGN { /******************************************************************************* VERTEX CENTERED TRAVERSALS *******************************************************************************/ // Traverse the edges incident to a given vertex template class Traversor2VE { private: const MAP& m ; Edge start ; Edge current ; const std::vector* m_QLT; std::vector::const_iterator m_ItDarts; public: Traversor2VE(const MAP& map, Vertex dart) ; inline Edge begin() ; inline Edge end() ; inline Edge next() ; typedef Edge IterType; typedef Vertex ParamType; typedef MAP MapType; } ; // Traverse the faces incident to a given vertex template class Traversor2VF { private: const MAP& m ; Face start ; Face current ; const std::vector* m_QLT; std::vector::const_iterator m_ItDarts; public: Traversor2VF(const MAP& map, Vertex dart) ; inline Face begin() ; inline Face end() ; inline Face next() ; typedef Face IterType; typedef Vertex ParamType; typedef MAP MapType; } ; // Traverse the vertices adjacent to a given vertex through sharing a common edge template class Traversor2VVaE { private: const MAP& m ; Vertex start ; Vertex current ; const std::vector* m_QLT; std::vector::const_iterator m_ItDarts; public: Traversor2VVaE(const MAP& map, Vertex dart) ; inline Vertex begin() ; inline Vertex end() ; inline Vertex next() ; typedef Vertex IterType; typedef Vertex ParamType; typedef MAP MapType; } ; // Traverse the vertices adjacent to a given vertex through sharing a common face template class Traversor2VVaF { private: const MAP& m ; Vertex start ; Vertex current ; Vertex stop ; const std::vector* m_QLT; std::vector::const_iterator m_ItDarts; public: Traversor2VVaF(const MAP& map, Vertex dart) ; inline Vertex begin() ; inline Vertex end() ; inline Vertex next() ; typedef Vertex IterType; typedef Vertex ParamType; typedef MAP MapType; } ; /******************************************************************************* EDGE CENTERED TRAVERSALS *******************************************************************************/ // Traverse the vertices incident to a given edge template class Traversor2EV { private: const MAP& m ; Vertex start ; Vertex current ; const std::vector* m_QLT; std::vector::const_iterator m_ItDarts; public: Traversor2EV(const MAP& map, Edge dart) ; inline Vertex begin() ; inline Vertex end() ; inline Vertex next() ; typedef Vertex IterType; typedef Edge ParamType; typedef MAP MapType; } ; // Traverse the faces incident to a given edge template class Traversor2EF { private: const MAP& m ; Face start ; Face current ; const std::vector* m_QLT; std::vector::const_iterator m_ItDarts; public: Traversor2EF(const MAP& map, Edge dart) ; inline Face begin() ; inline Face end() ; inline Face next() ; typedef Face IterType; typedef Edge ParamType; typedef MAP MapType; } ; // Traverse the edges adjacent to a given edge through sharing a common vertex template class Traversor2EEaV { private: const MAP& m ; Edge start ; Edge current ; Edge stop1, stop2 ; const std::vector* m_QLT; std::vector::const_iterator m_ItDarts; public: Traversor2EEaV(const MAP& map, Edge dart) ; inline Edge begin() ; inline Edge end() ; inline Edge next() ; typedef Edge IterType; typedef Edge ParamType; typedef MAP MapType; } ; // Traverse the edges adjacent to a given edge through sharing a common face template class Traversor2EEaF { private: const MAP& m ; Edge start ; Edge current ; Edge stop1, stop2 ; const std::vector* m_QLT; std::vector::const_iterator m_ItDarts; public: Traversor2EEaF(const MAP& map, Edge dart) ; inline Edge begin() ; inline Edge end() ; inline Edge next() ; typedef Edge IterType; typedef Edge ParamType; typedef MAP MapType; } ; /******************************************************************************* FACE CENTERED TRAVERSALS *******************************************************************************/ // Traverse the vertices incident to a given face template class Traversor2FV { private: const MAP& m ; Vertex start ; Vertex current ; const std::vector* m_QLT; std::vector::const_iterator m_ItDarts; public: Traversor2FV(const MAP& map, Face dart) ; inline Vertex begin() ; inline Vertex end() ; inline Vertex next() ; typedef Vertex IterType; typedef Face ParamType; typedef MAP MapType; } ; //// Traverse the edges incident to a given face (equivalent to vertices) //template //class Traversor2FE: public Traversor2FV //{ //public: // Traversor2FE(const MAP& map, Dart dart):Traversor2FV(map,dart){} //} ; // Traverse the vertices incident to a given face template class Traversor2FE { private: const MAP& m ; Edge start ; Edge current ; const std::vector* m_QLT; std::vector::const_iterator m_ItDarts; public: Traversor2FE(const MAP& map, Face dart) ; inline Edge begin() ; inline Edge end() ; inline Edge next() ; typedef Edge IterType; typedef Face ParamType; typedef MAP MapType; } ; // Traverse the faces adjacent to a given face through sharing a common vertex template class Traversor2FFaV { private: const MAP& m ; Face start ; Face current ; Face stop ; const std::vector* m_QLT; std::vector::const_iterator m_ItDarts; public: Traversor2FFaV(const MAP& map, Face dart) ; inline Face begin() ; inline Face end() ; inline Face next() ; typedef Face IterType; typedef Face ParamType; typedef MAP MapType; } ; // Traverse the faces adjacent to a given face through sharing a common edge // Warning mult-incidence is not managed (some faces can be send several times) template class Traversor2FFaE { private: const MAP& m ; Face start ; Face current ; const std::vector* m_QLT; std::vector::const_iterator m_ItDarts; public: Traversor2FFaE(const MAP& map, Face dart) ; inline Face begin() ; inline Face end() ; inline Face next() ; typedef Face IterType; typedef Face ParamType; typedef MAP MapType; } ; template class IncidentTrav2 { public: IncidentTrav2(const MAP&, Cell) {} }; template class IncidentTrav2 { public: Traversor2VE t; IncidentTrav2(const MAP& m, Vertex d):t(m,d) {} }; template class IncidentTrav2 { public: Traversor2VF t; IncidentTrav2(const MAP& m, Vertex d):t(m,d) {} }; template class IncidentTrav2 { public: Traversor2EV t; IncidentTrav2(const MAP& m, Edge d):t(m,d) {} }; template class IncidentTrav2 { public: Traversor2EF t; IncidentTrav2(const MAP& m, Edge d):t(m,d) {} }; template class IncidentTrav2 { public: Traversor2FV t; IncidentTrav2(const MAP& m, Face d):t(m,d) {} }; template class IncidentTrav2 { public: Traversor2FE t; IncidentTrav2(const MAP& m, Face d):t(m,d) {} }; template class AdjacentTrav2 { public: AdjacentTrav2(const MAP&, Cell) {} }; template class AdjacentTrav2 { public: Traversor2VVaE t; AdjacentTrav2(const MAP& m, Vertex d):t(m,d) {} }; template class AdjacentTrav2 { public: Traversor2VVaF t; AdjacentTrav2(const MAP& m, Vertex d):t(m,d) {} }; template class AdjacentTrav2 { public: Traversor2EEaV t; AdjacentTrav2(const MAP& m, Edge d):t(m,d) {} }; template class AdjacentTrav2 { public: Traversor2EEaF t; AdjacentTrav2(const MAP& m, Edge d):t(m,d) {} }; template class AdjacentTrav2 { public: Traversor2FFaV t; AdjacentTrav2(const MAP& m, Face d):t(m,d) {} }; template class AdjacentTrav2 { public: Traversor2FFaE t; AdjacentTrav2(const MAP& m, Face d):t(m,d) {} }; // foreach traversal function template inline void foreach_incident2(MAP& map, Cell c, FUNC f) { IncidentTrav2 trav(const_cast(map),c); for (Cell c = trav.t.begin(), e = trav.t.end(); c.dart != e.dart; c = trav.t.next()) f(c); } template inline void foreach_adjacent2(MAP& map, Cell c, FUNC f) { AdjacentTrav2 trav(const_cast(map),c); for (Cell c = trav.t.begin(), e = trav.t.end(); c.dart != e.dart; c = trav.t.next()) f(c); } /** * 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){} // 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 iterator(this,TRAV::begin()); // } // inline iterator end() // { // return iterator(this,TRAV::end()); // } //}; // functions that return the traversor+iterator // functions instead of typedef because function // allows the compiler to deduce template param template inline Iteratorize< Traversor2VE > edgesIncidentToVertex2(const MAP& m, Vertex c) { return Iteratorize< Traversor2VE >(m, c); } template inline Iteratorize< Traversor2VF > facesIncidentToVertex2(const MAP& m, Vertex c) { return Iteratorize< Traversor2VF >(m, c); } template inline Iteratorize< Traversor2EV > verticesIncidentToEdge2(const MAP& m, Edge c) { return Iteratorize< Traversor2EV >(m, c); } template inline Iteratorize< Traversor2EF > facesIncidentToEdge2(const MAP& m, Edge c) { return Iteratorize< Traversor2EF >(m, c); } template inline Iteratorize< Traversor2FV > verticesIncidentToFace2(const MAP& m, Face c) { return Iteratorize< Traversor2FV >(m, c); } template inline Iteratorize< Traversor2FE > edgesIncidentToFace2(const MAP& m, Face c) { return Iteratorize< Traversor2FE >(m, c); } template inline Iteratorize< Traversor2VVaE > verticesAdjacentByEdge2(const MAP& m, Vertex c) { return Iteratorize< Traversor2VVaE >(m, c); } template inline Iteratorize< Traversor2VVaF > verticesAdjacentByFace2(const MAP& m, Vertex c) { return Iteratorize< Traversor2VVaF >(m, c); } template inline Iteratorize< Traversor2EEaV > edgesAdjacentByVertex2(const MAP& m, Edge c) { return Iteratorize< Traversor2EEaV >(m, c); } template inline Iteratorize< Traversor2EEaF > edgesAdjacentByFace2(const MAP& m, Edge c) { return Iteratorize< Traversor2EEaF >(m, c); } template inline Iteratorize< Traversor2FFaV > facesAdjacentByVertex2(const MAP& m, Face c) { return Iteratorize< Traversor2FFaV >(m, c); } template inline Iteratorize< Traversor2FFaE > facesAdjacentByEdge2(const MAP& m, Face c) { return Iteratorize< Traversor2FFaE >(m, c); } } // namespace CGoGN #include "Topology/generic/traversor/traversor2.hpp" #endif