/******************************************************************************* * 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" 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() ; } ; // 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() ; } ; // 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() ; } ; // 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() ; } ; /******************************************************************************* 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() ; } ; // 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() ; } ; // 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() ; } ; // 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() ; } ; /******************************************************************************* 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() ; } ; //// 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() ; } ; // 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() ; } ; // 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() ; } ; 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) {} }; 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); } } // namespace CGoGN #include "Topology/generic/traversor/traversor2.hpp" #endif