attribmap.cpp 3.41 KB
Newer Older
Pierre Kraemer's avatar
Pierre Kraemer committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
/*******************************************************************************
* CGoGN: Combinatorial and Geometric modeling with Generic N-dimensional Maps  *
* version 0.1                                                                  *
* Copyright (C) 2009, 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: https://iggservis.u-strasbg.fr/CGoGN/                              *
* Contact information: cgogn@unistra.fr                                        *
*                                                                              *
*******************************************************************************/

#include "Topology/generic/attribmap.h"

namespace CGoGN
{

AttribMap::AttribMap() : GenericMap()
{
32
	AttributeContainer& dartCont = m_attribs[DART_ORBIT] ;
33
	AttributeMultiVector<Mark>* amv = dartCont.addAttribute<Mark>("Mark") ;
34
	m_markerTables[DART_ORBIT][0] = amv ;
Pierre Kraemer's avatar
Pierre Kraemer committed
35
36
37
38
39
40
41
42
}

/****************************************
 *   EMBEDDING ATTRIBUTES MANAGEMENT    *
 ****************************************/

void AttribMap::addEmbedding(unsigned int orbit)
{
Pierre Kraemer's avatar
Pierre Kraemer committed
43
44
	assert(!isOrbitEmbedded(orbit) || !"Invalid parameter: orbit already embedded") ;

Pierre Kraemer's avatar
Pierre Kraemer committed
45
46
47
	std::ostringstream oss;
	oss << "EMB_" << orbit;

48
	AttributeContainer& dartCont = m_attribs[DART_ORBIT] ;
49
50
	AttributeMultiVector<unsigned int>* amv = dartCont.addAttribute<unsigned int>(oss.str()) ;
	m_embeddings[orbit] = amv ;
Pierre Kraemer's avatar
Pierre Kraemer committed
51
52
53

	// set new embedding to EMBNULL for all the darts of the map
	for(unsigned int i = dartCont.begin(); i < dartCont.end(); dartCont.next(i))
54
		amv->operator[](i) = EMBNULL ;
Sylvain Thery's avatar
Sylvain Thery committed
55

56
57
	AttributeContainer& cellCont = m_attribs[orbit];
	for (unsigned int t = 0; t < m_nbThreads; ++t)
Sylvain Thery's avatar
Sylvain Thery committed
58
	{
59
60
61
		std::stringstream ss ;
		ss << "Mark_"<< t ;
		AttributeMultiVector<Mark>* amvMark = cellCont.addAttribute<Mark>(ss.str()) ;
62
		m_markerTables[orbit][t] = amvMark ;
Sylvain Thery's avatar
Sylvain Thery committed
63
	}
Pierre Kraemer's avatar
Pierre Kraemer committed
64
65
66
67
68
69
70
71
}

/****************************************
 *               UTILITIES              *
 ****************************************/

unsigned int AttribMap::computeIndexCells(AttributeHandler<unsigned int>& idx)
{
72
	AttributeContainer& cont = m_attribs[idx.getOrbit()] ;
Pierre Kraemer's avatar
Pierre Kraemer committed
73
74
75
76
77
78
79
	unsigned int cpt = 0 ;
	for (unsigned int i = cont.begin(); i != cont.end(); cont.next(i))
		idx[i] = cpt++ ;
	return cpt ;
}

} // namespace CGoGN