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

#include "Topology/generic/attribmap.h"
26

Pierre Kraemer's avatar
Pierre Kraemer committed
27 28 29
namespace CGoGN
{

30
void AttribMap::init()
Pierre Kraemer's avatar
Pierre Kraemer committed
31
{
32
	for(unsigned int orbit = 0; orbit < NB_ORBITS; ++orbit)
33
	{
34 35 36 37
		AttributeContainer& cont = m_attribs[orbit];
		for (unsigned int t = 0; t < m_nbThreads; ++t)
		{
			std::stringstream ss ;
38
			ss << "Mark_" << t ;
39 40 41 42 43
			AttributeMultiVector<Mark>* amvMark = cont.addAttribute<Mark>(ss.str()) ;
			for(unsigned int i = cont.begin(); i < cont.end(); cont.next(i))
				amvMark->operator[](i).clear() ;
			m_markTables[orbit][t] = amvMark ;
		}
44
	}
45

46
	for (unsigned int j = 0; j < NB_THREAD; ++j)
47
	{
48 49 50 51 52 53 54 55 56 57
		std::vector<CellMarkerGen*>& cmg = cellMarkers[j];
		for(unsigned int i = 0; i < cmg.size(); ++i)
		{
			CellMarkerGen* cm = cmg[i] ;
			cm->updateMarkVector(m_markTables[cm->getCell()][cm->getThread()]) ;
		}

		std::vector<DartMarkerGen*>& dmg = dartMarkers[j];
		for(unsigned int i = 0; i < dmg.size(); ++i)
		{
58 59
			DartMarkerGen* dm = dmg[i] ;
			dm->updateMarkVector(m_markTables[DART][dm->getThread()]) ;
60
		}
61
	}
62 63 64 65 66 67 68 69 70 71
}

AttribMap::AttribMap() : GenericMap()
{
	init() ;
}

void AttribMap::clear(bool removeAttrib)
{
	GenericMap::clear(removeAttrib) ;
Sylvain Thery's avatar
Sylvain Thery committed
72 73
	if (removeAttrib)
		init() ;
Pierre Kraemer's avatar
Pierre Kraemer committed
74 75
}

76 77 78 79 80
AttributeMultiVectorGen* AttribMap::getAttributeVectorGen(unsigned int orbit, const std::string& nameAttr)
{
	return m_attribs[orbit].getVirtualDataVector(nameAttr) ;
}

Pierre Kraemer's avatar
Pierre Kraemer committed
81
} // namespace CGoGN