mapCommon.hpp 18.5 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 32 33 34 35 36
/*******************************************************************************
* CGoGN: Combinatorial and Geometric modeling with Generic N-dimensional Maps  *
* version 0.1                                                                  *
* Copyright (C) 2009-2012, 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: http://cgogn.unistra.fr/                                           *
* Contact information: cgogn@unistra.fr                                        *
*                                                                              *
*******************************************************************************/

namespace CGoGN
{

/****************************************
 *           DARTS TRAVERSALS           *
 ****************************************/

template <typename MAP_IMPL>
template <unsigned int ORBIT, unsigned int INCIDENT>
unsigned int MapCommon<MAP_IMPL>::degree(Dart d) const
{
	assert(ORBIT != INCIDENT || !"degree does not manage adjacency counting") ;
Pierre Kraemer's avatar
Pierre Kraemer committed
37
	Traversor* t = TraversorFactory<MapCommon<MAP_IMPL> >::createIncident(*this, d, this->dimension(), ORBIT, INCIDENT) ;
Pierre Kraemer's avatar
Pierre Kraemer committed
38 39 40 41 42 43
	FunctorCount fcount ;
	t->applyFunctor(fcount) ;
	delete t ;
	return fcount.getNb() ;
}

Sylvain Thery's avatar
Sylvain Thery committed
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58

template <typename MAP_IMPL>
template <unsigned int ORBIT>
bool MapCommon<MAP_IMPL>::sameOrbit(Cell<ORBIT> c1, Cell<ORBIT> c2, unsigned int thread) const
{
	TraversorDartsOfOrbit< MapCommon<MAP_IMPL>, ORBIT> tradoo(*this,c1.dart,thread);
	for (Dart x= tradoo.begin(); x!=tradoo.end();x=tradoo.next())
	{
		if (x==c2.dart)
			return true;
	}
	return false;
}


Pierre Kraemer's avatar
Pierre Kraemer committed
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139
/****************************************
 *         EMBEDDING MANAGEMENT         *
 ****************************************/

template <typename MAP_IMPL>
template <unsigned int ORBIT>
inline unsigned int MapCommon<MAP_IMPL>::getEmbedding(Dart d) const
{
	assert(this->template isOrbitEmbedded<ORBIT>() || !"Invalid parameter: orbit not embedded");

	unsigned int d_index = this->dartIndex(d);

	if (ORBIT == DART)
		return d_index;

	return (*this->m_embeddings[ORBIT])[d_index] ;
}

template <typename MAP_IMPL>
template <unsigned int ORBIT>
void MapCommon<MAP_IMPL>::setDartEmbedding(Dart d, unsigned int emb)
{
	assert(this->template isOrbitEmbedded<ORBIT>() || !"Invalid parameter: orbit not embedded");

	unsigned int old = getEmbedding<ORBIT>(d);

	if (old == emb)	// if same emb
		return;		// nothing to do

	if (old != EMBNULL)	// if different
	{
		if(this->m_attribs[ORBIT].unrefLine(old))	// then unref the old emb
		{
			for (unsigned int t = 0; t < this->m_nbThreads; ++t)	// clear the markers if it was the
				(*this->m_markTables[ORBIT][t])[old].clear();		// last unref of the line
		}
	}

	if (emb != EMBNULL)
		this->m_attribs[ORBIT].refLine(emb);	// ref the new emb

	(*this->m_embeddings[ORBIT])[this->dartIndex(d)] = emb ; // finally affect the embedding to the dart
}

template <typename MAP_IMPL>
template <unsigned int ORBIT>
void MapCommon<MAP_IMPL>::initDartEmbedding(Dart d, unsigned int emb)
{
	assert(this->template isOrbitEmbedded<ORBIT>() || !"Invalid parameter: orbit not embedded");
	assert(getEmbedding<ORBIT>(d) == EMBNULL || !"initDartEmbedding called on already embedded dart");

	if(emb != EMBNULL)
		this->m_attribs[ORBIT].refLine(emb);	// ref the new emb
	(*this->m_embeddings[ORBIT])[this->dartIndex(d)] = emb ; // affect the embedding to the dart
}

template <typename MAP_IMPL>
template <unsigned int ORBIT>
inline void MapCommon<MAP_IMPL>::copyDartEmbedding(Dart dest, Dart src)
{
	assert(this->template isOrbitEmbedded<ORBIT>() || !"Invalid parameter: orbit not embedded");

	setDartEmbedding<ORBIT>(dest, getEmbedding<ORBIT>(src));
}

template <typename MAP_IMPL>
template <unsigned int ORBIT>
inline void MapCommon<MAP_IMPL>::setOrbitEmbedding(Dart d, unsigned int em)
{
	assert(this->template isOrbitEmbedded<ORBIT>() || !"Invalid parameter: orbit not embedded");

	FunctorSetEmb<MapCommon<MAP_IMPL>, ORBIT> fsetemb(*this, em);
	this->template foreach_dart_of_orbit<ORBIT>(d, fsetemb);
}

template <typename MAP_IMPL>
template <unsigned int ORBIT>
inline void MapCommon<MAP_IMPL>::initOrbitEmbedding(Dart d, unsigned int em)
{
	assert(this->template isOrbitEmbedded<ORBIT>() || !"Invalid parameter: orbit not embedded");

140 141
	FunctorInitEmb<MapCommon<MAP_IMPL>, ORBIT> finitemb(*this, em);
	this->template foreach_dart_of_orbit<ORBIT>(d, finitemb);
Pierre Kraemer's avatar
Pierre Kraemer committed
142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176
}

template <typename MAP_IMPL>
template <unsigned int ORBIT>
inline unsigned int MapCommon<MAP_IMPL>::setOrbitEmbeddingOnNewCell(Dart d)
{
	assert(this->template isOrbitEmbedded<ORBIT>() || !"Invalid parameter: orbit not embedded");

	unsigned int em = this->template newCell<ORBIT>();
	setOrbitEmbedding<ORBIT>(d, em);
	return em;
}

template <typename MAP_IMPL>
template <unsigned int ORBIT>
inline unsigned int MapCommon<MAP_IMPL>::initOrbitEmbeddingOnNewCell(Dart d)
{
	assert(this->template isOrbitEmbedded<ORBIT>() || !"Invalid parameter: orbit not embedded");

	unsigned int em = this->template newCell<ORBIT>();
	initOrbitEmbedding<ORBIT>(d, em);
	return em;
}

template <typename MAP_IMPL>
template <unsigned int ORBIT>
inline void MapCommon<MAP_IMPL>::copyCell(Dart d, Dart e)
{
	assert(this->template isOrbitEmbedded<ORBIT>() || !"Invalid parameter: orbit not embedded");
	unsigned int dE = getEmbedding<ORBIT>(d) ;
	unsigned int eE = getEmbedding<ORBIT>(e) ;
	if(eE != EMBNULL)	// if the source is NULL, nothing to copy
	{
		if(dE == EMBNULL)	// if the dest is NULL, create a new cell
			dE = setOrbitEmbeddingOnNewCell<ORBIT>(d) ;
Pierre Kraemer's avatar
Pierre Kraemer committed
177 178
		this->m_attribs[ORBIT].copyLine(dE, eE) ;	// copy the data
//		copyCell<ORBIT>(dE, eE);
Pierre Kraemer's avatar
Pierre Kraemer committed
179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228
	}
}

/**************************
 *  BOUNDARY MANAGEMENT   *
 **************************/

template <typename MAP_IMPL>
template <unsigned int DIM>
inline void MapCommon<MAP_IMPL>::boundaryMark(Dart d)
{
	this->m_markTables[DART][0]->operator[](this->dartIndex(d)).setMark(this->m_boundaryMarkers[DIM-2]);
}

template <typename MAP_IMPL>
template <unsigned int DIM>
inline void MapCommon<MAP_IMPL>::boundaryUnmark(Dart d)
{
	this->m_markTables[DART][0]->operator[](this->dartIndex(d)).unsetMark(this->m_boundaryMarkers[DIM-2]);
}

template <typename MAP_IMPL>
template <unsigned int ORBIT, unsigned int  DIM>
void MapCommon<MAP_IMPL>::boundaryMarkOrbit(Dart d)
{
	FunctorMark<MAP_IMPL> fm(*this, this->m_boundaryMarkers[DIM-2], this->m_markTables[DART][0]) ;
	this->template foreach_dart_of_orbit<ORBIT>(d, fm, 0) ;
}

template <typename MAP_IMPL>
template <unsigned int ORBIT, unsigned int DIM>
void MapCommon<MAP_IMPL>::boundaryUnmarkOrbit(Dart d)
{
	FunctorUnmark<MAP_IMPL> fm(*this, this->m_boundaryMarkers[DIM-2], this->m_markTables[DART][0]) ;
	this->template foreach_dart_of_orbit<ORBIT>(d, fm, 0) ;
}

template <typename MAP_IMPL>
template <unsigned int DIM>
inline bool MapCommon<MAP_IMPL>::isBoundaryMarked(Dart d) const
{
	return this->m_markTables[DART][0]->operator[](this->dartIndex(d)).testMark(this->m_boundaryMarkers[DIM-2]);
}

template <typename MAP_IMPL>
inline bool MapCommon<MAP_IMPL>::isBoundaryMarkedCurrent(Dart d) const
{
	return this->m_markTables[DART][0]->operator[](this->dartIndex(d)).testMark(this->m_boundaryMarkers[this->dimension()-2]);
}

Pierre Kraemer's avatar
Pierre Kraemer committed
229 230 231 232 233 234 235 236 237 238 239
template <typename MAP_IMPL>
inline bool MapCommon<MAP_IMPL>::isBoundaryMarked(unsigned int dim, Dart d) const
{
	switch(dim)
	{
		case 2 : return isBoundaryMarked<2>(d) ; break ;
		case 3 : return isBoundaryMarked<3>(d) ; break ;
		default : return false ; break ;
	}
}

Pierre Kraemer's avatar
Pierre Kraemer committed
240 241 242 243 244 245 246 247 248
template <typename MAP_IMPL>
template <unsigned int DIM>
void MapCommon<MAP_IMPL>::boundaryUnmarkAll()
{
	AttributeContainer& cont = this->m_attribs[DART] ;
	for (unsigned int i = cont.begin(); i != cont.end(); cont.next(i))
		this->m_markTables[DART][0]->operator[](i).unsetMark(this->m_boundaryMarkers[DIM-2]);
}

Pierre Kraemer's avatar
Pierre Kraemer committed
249 250 251 252 253 254 255 256 257 258
/****************************************
 *        ATTRIBUTES MANAGEMENT         *
 ****************************************/

template <typename MAP_IMPL>
template <typename T, unsigned int ORBIT>
inline AttributeHandler<T, ORBIT, MAP_IMPL> MapCommon<MAP_IMPL>::addAttribute(const std::string& nameAttr)
{
	if(!this->template isOrbitEmbedded<ORBIT>())
		this->template addEmbedding<ORBIT>() ;
259
	AttributeMultiVector<T>* amv = this->m_attribs[ORBIT].template addAttribute<T>(nameAttr) ;
Pierre Kraemer's avatar
Pierre Kraemer committed
260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326
	return AttributeHandler<T, ORBIT, MAP_IMPL>(this, amv) ;
}

template <typename MAP_IMPL>
template <typename T, unsigned int ORBIT>
inline bool MapCommon<MAP_IMPL>::removeAttribute(AttributeHandler<T, ORBIT, MAP_IMPL>& attr)
{
	assert(attr.isValid() || !"Invalid attribute handler") ;
	if(this->m_attribs[attr.getOrbit()].template removeAttribute<T>(attr.getIndex()))
	{
		AttributeMultiVectorGen* amv = attr.getDataVector();
		typedef std::multimap<AttributeMultiVectorGen*, AttributeHandlerGen*>::iterator IT ;
		std::pair<IT, IT> bounds = this->attributeHandlers.equal_range(amv) ;
		for(IT i = bounds.first; i != bounds.second; ++i)
			(*i).second->setInvalid() ;
		this->attributeHandlers.erase(bounds.first, bounds.second) ;
		return true ;
	}
	return false ;
}

template <typename MAP_IMPL>
template <typename T, unsigned int ORBIT>
inline AttributeHandler<T ,ORBIT, MAP_IMPL> MapCommon<MAP_IMPL>::getAttribute(const std::string& nameAttr)
{
	AttributeMultiVector<T>* amv = this->m_attribs[ORBIT].template getDataVector<T>(nameAttr) ;
	return AttributeHandler<T, ORBIT, MAP_IMPL>(this, amv) ;
}

template <typename MAP_IMPL>
template <typename T, unsigned int ORBIT>
inline AttributeHandler<T ,ORBIT, MAP_IMPL> MapCommon<MAP_IMPL>::checkAttribute(const std::string& nameAttr)
{
	AttributeHandler<T, ORBIT, MAP_IMPL> att = this->getAttribute<T,ORBIT>(nameAttr);
	if (!att.isValid())
		att = this->addAttribute<T, ORBIT>(nameAttr);
	return att;
}

template <typename MAP_IMPL>
template <typename T, unsigned int ORBIT>
inline bool MapCommon<MAP_IMPL>::swapAttributes(AttributeHandler<T, ORBIT, MAP_IMPL>& attr1, AttributeHandler<T, ORBIT, MAP_IMPL>& attr2)
{
	assert((attr1.isValid() && attr2.isValid()) || !"Invalid attribute handler") ;
//	assert(attr1.getOrbit() == attr2.getOrbit() || !"Cannot swap attributes of different orbits") ;
//	unsigned int orbit = attr1.getOrbit() ;
	unsigned int index1 = attr1.getIndex() ;
	unsigned int index2 = attr2.getIndex() ;
	if(index1 != index2)
		return this->m_attribs[ORBIT].swapAttributes(index1, index2) ;
	return false ;
}

template <typename MAP_IMPL>
template <typename T, unsigned int ORBIT>
inline bool MapCommon<MAP_IMPL>::copyAttribute(AttributeHandler<T, ORBIT, MAP_IMPL>& dst, AttributeHandler<T, ORBIT, MAP_IMPL>& src)
{
	assert((dst.isValid() && src.isValid()) || !"Invalid attribute handler") ;
//	unsigned int orbit = dst.getOrbit() ;
//	assert(orbit == src.getOrbit() || !"Cannot copy attributes of different orbits") ;
	unsigned int index_dst = dst.getIndex() ;
	unsigned int index_src = src.getIndex() ;
	if(index_dst != index_src)
		return this->m_attribs[ORBIT].copyAttribute(index_dst, index_src) ;
	return false ;
}

Pierre Kraemer's avatar
Pierre Kraemer committed
327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356
template <typename MAP_IMPL>
inline DartAttribute<Dart, MAP_IMPL> MapCommon<MAP_IMPL>::getInvolution(unsigned int i)
{
	return DartAttribute<Dart, MAP_IMPL>(this, this->getInvolutionAttribute(i));
}

template <typename MAP_IMPL>
inline DartAttribute<Dart, MAP_IMPL> MapCommon<MAP_IMPL>::getPermutation(unsigned int i)
{
	return DartAttribute<Dart, MAP_IMPL>(this, this->getPermutationAttribute(i));
}

template <typename MAP_IMPL>
inline DartAttribute<Dart, MAP_IMPL> MapCommon<MAP_IMPL>::getPermutationInv(unsigned int i)
{
	return DartAttribute<Dart, MAP_IMPL>(this, this->getPermutationInvAttribute(i));
}

/****************************************
 *     QUICK TRAVERSAL MANAGEMENT       *
 ****************************************/

template <typename MAP_IMPL>
template <unsigned int ORBIT>
inline void MapCommon<MAP_IMPL>::enableQuickTraversal()
{
	if(this->m_quickTraversal[ORBIT] == NULL)
	{
		if(!this->template isOrbitEmbedded<ORBIT>())
			this->template addEmbedding<ORBIT>() ;
357
		this->m_quickTraversal[ORBIT] = this->m_attribs[ORBIT].template addAttribute<Dart>("quick_traversal") ;
Pierre Kraemer's avatar
Pierre Kraemer committed
358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391
	}
	updateQuickTraversal<ORBIT>() ;
}

template <typename MAP_IMPL>
template <unsigned int ORBIT>
inline void MapCommon<MAP_IMPL>::updateQuickTraversal()
{
	assert(this->m_quickTraversal[ORBIT] != NULL || !"updateQuickTraversal on a disabled orbit") ;

	CellMarker<MapCommon<MAP_IMPL>, ORBIT> cm(*this) ;
	for(Dart d = this->begin(); d != this->end(); this->next(d))
	{
		if(!cm.isMarked(d))
		{
			cm.mark(d) ;
			(*this->m_quickTraversal[ORBIT])[getEmbedding<ORBIT>(d)] = d ;
		}
	}
}

template <typename MAP_IMPL>
template <unsigned int ORBIT>
inline const AttributeMultiVector<Dart>* MapCommon<MAP_IMPL>::getQuickTraversal() const
{
	return this->m_quickTraversal[ORBIT] ;
}

template <typename MAP_IMPL>
template <unsigned int ORBIT>
inline void MapCommon<MAP_IMPL>::disableQuickTraversal()
{
	if(this->m_quickTraversal[ORBIT] != NULL)
	{
392
		this->m_attribs[ORBIT].template removeAttribute<Dart>(this->m_quickTraversal[ORBIT]->getIndex()) ;
Pierre Kraemer's avatar
Pierre Kraemer committed
393 394 395 396 397 398 399 400 401 402 403 404 405
		this->m_quickTraversal[ORBIT] = NULL ;
	}
}

template <typename MAP_IMPL>
template <unsigned int ORBIT, unsigned int INCI>
inline void MapCommon<MAP_IMPL>::enableQuickIncidentTraversal()
{
	if(this->m_quickLocalIncidentTraversal[ORBIT][INCI] == NULL)
	{
		if(!this->template isOrbitEmbedded<ORBIT>())
			this->template addEmbedding<ORBIT>() ;
		std::stringstream ss;
406
		ss << "quickIncidentTraversal_" << INCI;
407
		this->m_quickLocalIncidentTraversal[ORBIT][INCI] = this->m_attribs[ORBIT].template addAttribute<NoTypeNameAttribute<std::vector<Dart> > >(ss.str()) ;
Pierre Kraemer's avatar
Pierre Kraemer committed
408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453
	}
	updateQuickIncidentTraversal<ORBIT,INCI>() ;
}

template <typename MAP_IMPL>
template <unsigned int ORBIT, unsigned int INCI>
inline void MapCommon<MAP_IMPL>::updateQuickIncidentTraversal()
{
	assert(this->m_quickLocalIncidentTraversal[ORBIT][INCI] != NULL || !"updateQuickTraversal on a disabled orbit") ;

	AttributeMultiVector<NoTypeNameAttribute<std::vector<Dart> > >* ptrVD = this->m_quickLocalIncidentTraversal[ORBIT][INCI];
	this->m_quickLocalIncidentTraversal[ORBIT][INCI] = NULL;

	std::vector<Dart> buffer;
	buffer.reserve(100);

	TraversorCell<MapCommon<MAP_IMPL>, ORBIT> tra_glob(*this);
	for (Dart d = tra_glob.begin(); d != tra_glob.end(); d = tra_glob.next())
	{
		buffer.clear();
		Traversor* tra_loc = TraversorFactory<MapCommon<MAP_IMPL> >::createIncident(*this, d, this->dimension(), ORBIT, INCI);
		for (Dart e = tra_loc->begin(); e != tra_loc->end(); e = tra_loc->next())
			buffer.push_back(e);
		delete tra_loc;
		buffer.push_back(NIL);
		std::vector<Dart>& vd = (*ptrVD)[getEmbedding<ORBIT>(d)];
		vd.reserve(buffer.size());
		vd.assign(buffer.begin(), buffer.end());
	}

	this->m_quickLocalIncidentTraversal[ORBIT][INCI] = ptrVD;
}

template <typename MAP_IMPL>
template <unsigned int ORBIT, unsigned int INCI>
inline const AttributeMultiVector<NoTypeNameAttribute<std::vector<Dart> > >* MapCommon<MAP_IMPL>::getQuickIncidentTraversal() const
{
	return this->m_quickLocalIncidentTraversal[ORBIT][INCI] ;
}

template <typename MAP_IMPL>
template <unsigned int ORBIT, unsigned int INCI>
inline void MapCommon<MAP_IMPL>::disableQuickIncidentTraversal()
{
	if(this->m_quickLocalIncidentTraversal[ORBIT][INCI] != NULL)
	{
454
		this->m_attribs[ORBIT].removeAttribute<Dart>(this->m_quickLocalIncidentTraversal[ORBIT][INCI]->getIndex()) ;
Pierre Kraemer's avatar
Pierre Kraemer committed
455 456 457 458 459 460 461 462 463 464 465 466 467
		this->m_quickLocalIncidentTraversal[ORBIT][INCI] = NULL ;
	}
}

template <typename MAP_IMPL>
template <unsigned int ORBIT, unsigned int ADJ>
inline void MapCommon<MAP_IMPL>::enableQuickAdjacentTraversal()
{
	if(this->m_quickLocalAdjacentTraversal[ORBIT][ADJ] == NULL)
	{
		if(!this->template isOrbitEmbedded<ORBIT>())
			this->template addEmbedding<ORBIT>() ;
		std::stringstream ss;
468
		ss << "quickAdjacentTraversal" << ADJ;
469
		this->m_quickLocalAdjacentTraversal[ORBIT][ADJ] = this->m_attribs[ORBIT].template addAttribute<NoTypeNameAttribute<std::vector<Dart> > >(ss.str()) ;
Pierre Kraemer's avatar
Pierre Kraemer committed
470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515
	}
	updateQuickAdjacentTraversal<ORBIT, ADJ>() ;
}

template <typename MAP_IMPL>
template <unsigned int ORBIT, unsigned int ADJ>
inline void MapCommon<MAP_IMPL>::updateQuickAdjacentTraversal()
{
	assert(this->m_quickLocalAdjacentTraversal[ORBIT][ADJ] != NULL || !"updateQuickTraversal on a disabled orbit") ;

	AttributeMultiVector<NoTypeNameAttribute<std::vector<Dart> > >* ptrVD = this->m_quickLocalAdjacentTraversal[ORBIT][ADJ];
	this->m_quickLocalAdjacentTraversal[ORBIT][ADJ] = NULL;

	std::vector<Dart> buffer;
	buffer.reserve(100);

	TraversorCell<MapCommon<MAP_IMPL>, ORBIT> tra_glob(*this);
	for (Dart d = tra_glob.begin(); d != tra_glob.end(); d = tra_glob.next())
	{
		buffer.clear();
		Traversor* tra_loc = TraversorFactory<MapCommon<MAP_IMPL> >::createAdjacent(*this, d, this->dimension(), ORBIT, ADJ);
		for (Dart e = tra_loc->begin(); e != tra_loc->end(); e = tra_loc->next())
			buffer.push_back(e);
		buffer.push_back(NIL);
		delete tra_loc;
		std::vector<Dart>& vd = (*ptrVD)[getEmbedding<ORBIT>(d)];
		vd.reserve(buffer.size());
		vd.assign(buffer.begin(),buffer.end());
	}

	this->m_quickLocalAdjacentTraversal[ORBIT][ADJ] = ptrVD;
}

template <typename MAP_IMPL>
template <unsigned int ORBIT, unsigned int ADJ>
inline const AttributeMultiVector<NoTypeNameAttribute<std::vector<Dart> > >* MapCommon<MAP_IMPL>::getQuickAdjacentTraversal() const
{
	return this->m_quickLocalAdjacentTraversal[ORBIT][ADJ] ;
}

template <typename MAP_IMPL>
template <unsigned int ORBIT, unsigned int ADJ>
inline void MapCommon<MAP_IMPL>::disableQuickAdjacentTraversal()
{
	if(this->m_quickLocalAdjacentTraversal[ORBIT][ADJ] != NULL)
	{
516
		this->m_attribs[ORBIT].template removeAttribute<Dart>(this->m_quickLocalAdjacentTraversal[ORBIT][ADJ]->getIndex()) ;
Pierre Kraemer's avatar
Pierre Kraemer committed
517 518 519 520
		this->m_quickLocalAdjacentTraversal[ORBIT][ADJ] = NULL ;
	}
}

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