traversor2.hpp 15.3 KB
Newer Older
Pierre Kraemer's avatar
Pierre Kraemer committed
1 2 3
/*******************************************************************************
* CGoGN: Combinatorial and Geometric modeling with Generic N-dimensional Maps  *
* version 0.1                                                                  *
4
* Copyright (C) 2009-2012, IGG Team, LSIIT, University of Strasbourg           *
Pierre Kraemer's avatar
Pierre Kraemer committed
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
*                                                                              *
* 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.           *
*                                                                              *
20
* Web site: http://cgogn.unistra.fr/                                           *
Pierre Kraemer's avatar
Pierre Kraemer committed
21 22 23 24 25 26 27 28 29 30 31 32 33 34
* Contact information: cgogn@unistra.fr                                        *
*                                                                              *
*******************************************************************************/

namespace CGoGN
{

/*******************************************************************************
					VERTEX CENTERED TRAVERSALS
*******************************************************************************/

// Traversor2VE

template <typename MAP>
Sylvain Thery's avatar
Sylvain Thery committed
35
Traversor2VE<MAP>::Traversor2VE(const MAP& map, Dart dart) : m(map), start(dart),m_QLT(NULL)
Sylvain Thery's avatar
Sylvain Thery committed
36
{
Sylvain Thery's avatar
Sylvain Thery committed
37
	const AttributeMultiVector<NoTypeNameAttribute<std::vector<Dart> > >* quickTraversal = map.template getQuickIncidentTraversal<VERTEX,EDGE>() ;
Sylvain Thery's avatar
Sylvain Thery committed
38 39 40 41 42
	if (quickTraversal != NULL)
	{
		m_QLT  = &(quickTraversal->operator[](map.template getEmbedding<VERTEX>(dart)));
	}
}
Pierre Kraemer's avatar
Pierre Kraemer committed
43 44 45 46

template <typename MAP>
Dart Traversor2VE<MAP>::begin()
{
Sylvain Thery's avatar
Sylvain Thery committed
47 48 49 50 51 52
	if(m_QLT != NULL)
	{
		m_ItDarts = m_QLT->begin();
		return *m_ItDarts++;
	}

Pierre Kraemer's avatar
Pierre Kraemer committed
53 54 55 56 57 58 59 60 61 62 63 64 65
	current = start ;
	return current ;
}

template <typename MAP>
Dart Traversor2VE<MAP>::end()
{
	return NIL ;
}

template <typename MAP>
Dart Traversor2VE<MAP>::next()
{
Sylvain Thery's avatar
Sylvain Thery committed
66 67 68 69 70
	if(m_QLT != NULL)
	{
		return *m_ItDarts++;
	}

Pierre Kraemer's avatar
Pierre Kraemer committed
71 72
	if(current != NIL)
	{
Sylvain Thery's avatar
Sylvain Thery committed
73 74
//		current = m.alpha1(current) ;
		current = m.phi2(m.phi_1(current)) ;
Pierre Kraemer's avatar
Pierre Kraemer committed
75 76 77 78 79 80 81 82 83
		if(current == start)
			current = NIL ;
	}
	return current ;
}

// Traversor2VF

template <typename MAP>
Sylvain Thery's avatar
Sylvain Thery committed
84
Traversor2VF<MAP>::Traversor2VF(const MAP& map, Dart dart) : m(map), start(dart),m_QLT(NULL)
Pierre Kraemer's avatar
Pierre Kraemer committed
85
{
Sylvain Thery's avatar
Sylvain Thery committed
86
	const AttributeMultiVector<NoTypeNameAttribute<std::vector<Dart> > >* quickTraversal = map.template getQuickIncidentTraversal<VERTEX,FACE>() ;
Sylvain Thery's avatar
Sylvain Thery committed
87 88 89 90 91 92 93 94