Coupure prévue mardi 3 Août au matin pour maintenance du serveur. Nous faisons au mieux pour que celle-ci soit la plus brève possible.

map1.cpp 3.81 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-2011, 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.u-strasbg.fr/                                         *
Pierre Kraemer's avatar
Pierre Kraemer committed
21
22
23
24
25
26
27
28
29
* Contact information: cgogn@unistra.fr                                        *
*                                                                              *
*******************************************************************************/

#include "Topology/map/map1.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 Map1::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_phi1->operator [](i);
			Dart e = Dart(oldnew[d.index]);
			if (d != e)
				d = e;
		}
		{
			Dart& d = m_phi_1->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 Generator and Deletor
 *  To generate or delete faces in a 1-map
 *************************************************************************/

53
Dart Map1::newCycle(unsigned int nbEdges)
Pierre Kraemer's avatar
Pierre Kraemer committed
54
55
56
{
	assert(nbEdges > 0 || !"Cannot create a face with no edge") ;
	Dart d = newDart() ;			// Create the first edge
Pierre Kraemer's avatar
Pierre Kraemer committed
57
	for (unsigned int i = 1 ; i < nbEdges ; ++i)
58
		Map1::cutEdge(d) ;			// Subdivide nbEdges-1 times this edge
Pierre Kraemer's avatar
Pierre Kraemer committed
59
60
61
	return d ;
}

62
Dart Map1::newBoundaryCycle(unsigned int nbEdges)
Sylvain Thery's avatar
Sylvain Thery committed
63
64
65
66
67
{
	assert(nbEdges > 0 || !"Cannot create a face with no edge") ;
	Dart d = newDart() ;			// Create the first edge
	boundaryMark(d);
	for (unsigned int i = 1 ; i < nbEdges ; ++i)
68
		Map1::cutEdge(d) ;			// Subdivide nbEdges-1 times this edge
Sylvain Thery's avatar
Sylvain Thery committed
69
70
71
	return d ;
}

72
void Map1::deleteCycle(Dart d)
Pierre Kraemer's avatar
Pierre Kraemer committed
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
{
	Dart e = phi1(d) ;
	while (e != d)
	{
		Dart f = phi1(e) ;
		deleteDart(e) ;
		e = f ;
	}
	deleteDart(d) ;
}

/*! @name Topological Operators
 *  Topological operations on 1-maps
 *************************************************************************/

88
void Map1::reverseCycle(Dart d)
Pierre Kraemer's avatar
Pierre Kraemer committed
89
90
91
92
93
94
95
96
97
98
99
{
	Dart e = phi1(d) ;			// Dart e is the first edge of the new face
	if (e == d) return ;		// Only one edge: nothing to do
	if (phi1(e) == d) return ;	// Only two edges: nothing to do

	phi1unsew(d) ;				// Detach e from the face of d

	Dart dNext = phi1(d) ;		// While the face of d contains more than two edges
	while (dNext != d)
	{
		phi1unsew(d) ;			// Unsew the edge after d
100
		phi1sew(e, dNext) ;		// Sew it after e (thus in reverse order)
Pierre Kraemer's avatar
Pierre Kraemer committed
101
102
		dNext = phi1(d) ;
	}
103
	phi1sew(e, d) ;				// Sew the last edge
Pierre Kraemer's avatar
Pierre Kraemer committed
104
105
106
}

} // namespace CGoGN