gmap1.cpp 3.57 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
* Contact information: cgogn@unistra.fr                                        *
*                                                                              *
*******************************************************************************/

#include "Topology/gmap/gmap1.h"

namespace CGoGN
{

Pierre Kraemer's avatar
merges  
Pierre Kraemer committed
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
void GMap1::compactTopoRelations(const std::vector<unsigned int>& oldnew)
{
	for (unsigned int i = m_attribs[DART].begin(); i != m_attribs[DART].end(); m_attribs[DART].next(i))
	{
		{
			Dart& d = m_beta0->operator [](i);
			Dart e = Dart(oldnew[d.index]);
			if (d != e)
				d = e;
		}
		{
			Dart& d = m_beta1->operator [](i);
			Dart e = Dart(oldnew[d.index]);
			if (d != e)
				d = e;
		}
	}
}

Pierre Kraemer's avatar
Pierre Kraemer committed
49 50 51 52
/*! @name Constructors and Destructors
 *  To generate or delete faces in a 1-G-map
 *************************************************************************/

53
Dart GMap1::newCycle(unsigned int nbEdges)
Pierre Kraemer's avatar
Pierre Kraemer committed
54
{
55 56
	assert(nbEdges > 0 || !"Cannot create a face with no edge") ;

57 58 59
	Dart d0 =  GMap0::newEdge();	// create the first edge
	Dart dp = beta0(d0);			// store an extremity
	for (unsigned int i = 1; i < nbEdges; ++i)
Pierre Kraemer's avatar
Pierre Kraemer committed
60
	{
61
		Dart di = GMap0::newEdge();	// create the next edge
Pierre Kraemer's avatar
Pierre Kraemer committed
62
		beta1sew(dp,di);
63
		dp = beta0(di);	// change the preceding
Pierre Kraemer's avatar
Pierre Kraemer committed
64
	}
65 66 67 68
	beta1sew(dp,d0);	// sew the last with the first
	return d0;
}

69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87
//Dart GMap1::newBoundaryCycle(unsigned int nbEdges)
//{
//	assert(nbEdges > 0 || !"Cannot create a face with no edge") ;
//
//	Dart d0 =  GMap0::newEdge();	// create the first edge
//	boundaryMark2(d0);
//	boundaryMark2(beta0(d0));
//	Dart dp = beta0(d0);			// store an extremity
//	for (unsigned int i = 1; i < nbEdges; ++i)
//	{
//		Dart di = GMap0::newEdge();	// create the next edge
//		boundaryMark2(di);
//		boundaryMark2(beta0(di));
//		beta1sew(dp,di);
//		dp = beta0(di);	// change the preceding
//	}
//	beta1sew(dp,d0);	// sew the last with the first
//	return d0;
//}
Pierre Kraemer's avatar
Pierre Kraemer committed
88

89
void GMap1::deleteCycle(Dart d)
Pierre Kraemer's avatar
Pierre Kraemer committed
90
{
Thomas's avatar
Thomas committed
91
	Dart e = phi1(d);
Pierre Kraemer's avatar
Pierre Kraemer committed
92 93
	while (e != d)
	{
Thomas's avatar
Thomas committed
94 95 96
		Dart f = phi1(e);
		deleteEdge(e);
		e = f;
Pierre Kraemer's avatar
Pierre Kraemer committed
97
	}
Thomas's avatar
Thomas committed
98
	deleteEdge(d);
Pierre Kraemer's avatar
Pierre Kraemer committed
99 100 101
}

} // namespace CGoGN