filters_Primal.h 15.9 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
* Contact information: cgogn@unistra.fr                                        *
*                                                                              *
*******************************************************************************/

25 26
#ifndef __MR_FILTERS_PRIMAL__
#define __MR_FILTERS_PRIMAL__
27 28

#include <cmath>
untereiner's avatar
untereiner committed
29
//#include "Algo/Decimation/decimation.h"
Pierre Kraemer's avatar
Pierre Kraemer committed
30 31 32 33

namespace CGoGN
{

34
namespace Algo
Pierre Kraemer's avatar
Pierre Kraemer committed
35
{
36

37 38 39 40
namespace MR
{

class Filter
41
{
42
public:
43 44
	Filter() {}
	virtual ~Filter() {}
45
	virtual void operator() () = 0 ;
46 47
} ;

Pierre Kraemer's avatar
Pierre Kraemer committed
48 49 50 51 52
/*********************************************************************************
 *                           LOOP BASIC FUNCTIONS
 *********************************************************************************/

template <typename PFP>
53
typename PFP::VEC3 loopOddVertex(typename PFP::MAP& map, const VertexAttribute<typename PFP::VEC3>& position, Dart d1)
Pierre Kraemer's avatar
Pierre Kraemer committed
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72
{
	Dart d2 = map.phi2(d1) ;
	Dart d3 = map.phi_1(d1) ;
	Dart d4 = map.phi_1(d2) ;

	typename PFP::VEC3 p1 = position[d1] ;
	typename PFP::VEC3 p2 = position[d2] ;
	typename PFP::VEC3 p3 = position[d3] ;
	typename PFP::VEC3 p4 = position[d4] ;

	p1 *= 3.0 / 8.0 ;
	p2 *= 3.0 / 8.0 ;
	p3 *= 1.0 / 8.0 ;
	p4 *= 1.0 / 8.0 ;

	return p1 + p2 + p3 + p4 ;
}

template <typename PFP>
73
typename PFP::VEC3 loopEvenVertex(typename PFP::MAP& map, const VertexAttribute<typename PFP::VEC3>& position, Dart d)
Pierre Kraemer's avatar
Pierre Kraemer committed
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94
{
	map.incCurrentLevel() ;

	typename PFP::VEC3 np(0) ;
	unsigned int degree = 0 ;
	Traversor2VVaE<typename PFP::MAP> trav(map, d) ;
	for(Dart it = trav.begin(); it != trav.end(); it = trav.next())
	{
		++degree ;
		np += position[it] ;
	}

	map.decCurrentLevel() ;

	float mu = 3.0/8.0 + 1.0/4.0 * cos(2.0 * M_PI / degree) ;
	mu = (5.0/8.0 - (mu * mu)) / degree ;
	np *= 8.0/5.0 * mu ;

	return np ;
}

Pierre Kraemer's avatar
Pierre Kraemer committed
95
/*********************************************************************************
96
 *                           ANALYSIS FILTERS
Pierre Kraemer's avatar
Pierre Kraemer committed
97 98
 *********************************************************************************/

99
template <typename PFP>
100
class LoopOddAnalysisFilter : public Filter
Pierre Kraemer's avatar
Pierre Kraemer committed
101 102
{
protected:
103
	typename PFP::MAP& m_map ;
104
	VertexAttribute<typename PFP::VEC3>& m_position ;
Pierre Kraemer's avatar
Pierre Kraemer committed
105 106

public:
107
	LoopOddAnalysisFilter(typename PFP::MAP& m, VertexAttribute<typename PFP::VEC3>& p) : m_map(m), m_position(p)
108
	{}
Pierre Kraemer's avatar
Pierre Kraemer committed
109

110 111 112 113 114
	void operator() ()
	{
		TraversorE<typename PFP::MAP> trav(m_map) ;
		for (Dart d = trav.begin(); d != trav.end(); d = trav.next())
		{
Pierre Kraemer's avatar
Pierre Kraemer committed
115 116
			typename PFP::VEC3 p = loopOddVertex<PFP>(m_map, m_position, d) ;

117
			m_map.incCurrentLevel() ;
Pierre Kraemer's avatar
Pierre Kraemer committed
118

119
			Dart oddV = m_map.phi2(d) ;
Pierre Kraemer's avatar
Pierre Kraemer committed
120
			m_position[oddV] -= p ;
Pierre Kraemer's avatar
Pierre Kraemer committed
121

122 123 124
			m_map.decCurrentLevel() ;
		}
	}
Pierre Kraemer's avatar
Pierre Kraemer committed
125 126 127
} ;

template <typename PFP>
128
class LoopEvenAnalysisFilter : public Filter
Pierre Kraemer's avatar
Pierre Kraemer committed
129 130 131
{
protected:
	typename PFP::MAP& m_map ;
132
	VertexAttribute<typename PFP::VEC3>& m_position;
Pierre Kraemer's avatar
Pierre Kraemer committed
133 134

public:
135
	LoopEvenAnalysisFilter(typename PFP::MAP& m, VertexAttribute<typename PFP::VEC3>& p) : m_map(m), m_position(p)
Pierre Kraemer's avatar
Pierre Kraemer committed
136 137
	{}

138
	void operator() ()
Pierre Kraemer's avatar
Pierre Kraemer committed
139
	{
Pierre Kraemer's avatar
Pierre Kraemer committed
140 141 142 143 144 145 146 147 148 149
		TraversorV<typename PFP::MAP> trav(m_map) ;
		for (Dart d = trav.begin(); d != trav.end(); d = trav.next())
		{
			typename PFP::VEC3 p = loopEvenVertex<PFP>(m_map, m_position, d) ;
			m_position[d] -= p ;
		}
	}
} ;

template <typename PFP>
150
class LoopNormalisationAnalysisFilter : public Filter
Pierre Kraemer's avatar
Pierre Kraemer committed
151 152 153
{
protected:
	typename PFP::MAP& m_map ;
154
	VertexAttribute<typename PFP::VEC3>& m_position;
Pierre Kraemer's avatar
Pierre Kraemer committed
155 156

public:
157
	LoopNormalisationAnalysisFilter(typename PFP::MAP& m, VertexAttribute<typename PFP::VEC3>& p) : m_map(m), m_position(p)
Pierre Kraemer's avatar
Pierre Kraemer committed
158 159 160 161 162 163 164 165 166 167 168 169 170
	{}

	void operator() ()
	{
		TraversorV<typename PFP::MAP> trav(m_map) ;
		for (Dart d = trav.begin(); d != trav.end(); d = trav.next())
		{
			unsigned int degree = m_map.vertexDegree(d) ;
			float n = 3.0/8.0 + 1.0/4.0 * cos(2.0 * M_PI / degree) ;
			n = 8.0/5.0 * (n * n) ;

			m_position[d] /= n ;
		}
Pierre Kraemer's avatar
Pierre Kraemer committed
171 172 173
	}
} ;

174 175 176 177
/*********************************************************************************
 *                           SYNTHESIS FILTERS
 *********************************************************************************/

Pierre Kraemer's avatar
Pierre Kraemer committed
178
template <typename PFP>
179
class LoopOddSynthesisFilter : public Filter
Pierre Kraemer's avatar
Pierre Kraemer committed
180 181 182
{
protected:
	typename PFP::MAP& m_map ;
183
	VertexAttribute<typename PFP::VEC3>& m_position;
Pierre Kraemer's avatar
Pierre Kraemer committed
184 185

public:
186
	LoopOddSynthesisFilter(typename PFP::MAP& m, VertexAttribute<typename PFP::VEC3>& p) : m_map(m), m_position(p)
Pierre Kraemer's avatar
Pierre Kraemer committed
187 188
	{}

189
	void operator() ()
Pierre Kraemer's avatar
Pierre Kraemer committed
190
	{
191 192
		TraversorE<typename PFP::MAP> trav(m_map) ;
		for (Dart d = trav.begin(); d != trav.end(); d = trav.next())
Pierre Kraemer's avatar
Pierre Kraemer committed
193
		{
Pierre Kraemer's avatar
Pierre Kraemer committed
194
			typename PFP::VEC3 p = loopOddVertex<PFP>(m_map, m_position, d) ;
Pierre Kraemer's avatar
Pierre Kraemer committed
195

196
			m_map.incCurrentLevel() ;
Pierre Kraemer's avatar
Pierre Kraemer committed
197

198 199
			Dart oddV = m_map.phi2(d) ;
			m_position[oddV] += p ;
Pierre Kraemer's avatar
Pierre Kraemer committed
200

201 202
			m_map.decCurrentLevel() ;
		}
Pierre Kraemer's avatar
Pierre Kraemer committed
203
	}
Pierre Kraemer's avatar
Pierre Kraemer committed
204
} ;
205

Pierre Kraemer's avatar
Pierre Kraemer committed
206
template <typename PFP>
207
class LoopEvenSynthesisFilter : public Filter
Pierre Kraemer's avatar
Pierre Kraemer committed
208 209 210
{
protected:
	typename PFP::MAP& m_map ;
211
	VertexAttribute<typename PFP::VEC3>& m_position ;
Pierre Kraemer's avatar
Pierre Kraemer committed
212 213

public:
214
	LoopEvenSynthesisFilter(typename PFP::MAP& m, VertexAttribute<typename PFP::VEC3>& p) : m_map(m), m_position(p)
Pierre Kraemer's avatar
Pierre Kraemer committed
215 216
	{}

217
	void operator() ()
Pierre Kraemer's avatar
Pierre Kraemer committed
218
	{
Pierre Kraemer's avatar
Pierre Kraemer committed
219 220 221 222 223 224
		TraversorV<typename PFP::MAP> trav(m_map) ;
		for (Dart d = trav.begin(); d != trav.end(); d = trav.next())
		{
			typename PFP::VEC3 p = loopEvenVertex<PFP>(m_map, m_position, d) ;
			m_position[d] += p ;
		}
Pierre Kraemer's avatar
Pierre Kraemer committed
225 226
	}
} ;
227

Pierre Kraemer's avatar
Pierre Kraemer committed
228
template <typename PFP>
229
class LoopNormalisationSynthesisFilter : public Filter
Pierre Kraemer's avatar
Pierre Kraemer committed
230 231 232
{
protected:
	typename PFP::MAP& m_map ;
233
	VertexAttribute<typename PFP::VEC3>& m_position ;
Pierre Kraemer's avatar
Pierre Kraemer committed
234 235

public:
236
	LoopNormalisationSynthesisFilter(typename PFP::MAP& m, VertexAttribute<typename PFP::VEC3>& p) : m_map(m), m_position(p)
Pierre Kraemer's avatar
Pierre Kraemer committed
237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252
	{}

	void operator() ()
	{
		TraversorV<typename PFP::MAP> trav(m_map) ;
		for (Dart d = trav.begin(); d != trav.end(); d = trav.next())
		{
			unsigned int degree = m_map.vertexDegree(d) ;
			float n = 3.0/8.0 + 1.0/4.0 * cos(2.0 * M_PI / degree) ;
			n = 8.0/5.0 * (n * n) ;

			m_position[d] *= n ;
		}
	}
} ;

untereiner's avatar
untereiner committed
253 254 255 256 257 258 259 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
/*********************************************************************************
 *                           SYNTHESIS FILTERS
 *********************************************************************************/

/* Linear Interpolation
 *********************************************************************************/
template <typename PFP>
class LerpEdgeSynthesisFilter : public Filter
{
protected:
	typename PFP::MAP& m_map ;
	VertexAttribute<typename PFP::VEC3>& m_position ;

public:
	LerpEdgeSynthesisFilter(typename PFP::MAP& m, VertexAttribute<typename PFP::VEC3>& p) : m_map(m), m_position(p)
	{}

	void operator() ()
	{
		TraversorE<typename PFP::MAP> trav(m_map) ;
		for (Dart d = trav.begin(); d != trav.end(); d = trav.next())
		{
			typename PFP::VEC3 p = (m_position[d] + m_position[m_map.phi1(d)]) * typename PFP::REAL(0.5);

			m_map.incCurrentLevel() ;

			Dart midV = m_map.phi1(d) ;
			m_position[midV] = p ;

			m_map.decCurrentLevel() ;
		}
	}
} ;

template <typename PFP>
class LerpFaceSynthesisFilter : public Filter
{
protected:
	typename PFP::MAP& m_map ;
	VertexAttribute<typename PFP::VEC3>& m_position ;

public:
	LerpFaceSynthesisFilter(typename PFP::MAP& m, VertexAttribute<typename PFP::VEC3>& p) : m_map(m), m_position(p)
	{}

	void operator() ()
	{
		TraversorF<typename PFP::MAP> trav(m_map) ;
		for (Dart d = trav.begin(); d != trav.end(); d = trav.next())
		{
			typename PFP::VEC3 p = Algo::Geometry::faceCentroid<PFP>(m_map, d, m_position);

			m_map.incCurrentLevel() ;
			if(m_map.faceDegree(d) != 3)
			{
				Dart midF = m_map.phi1(m_map.phi1(d));
				m_position[midF] = p ;
			}
			m_map.decCurrentLevel() ;

		}
	}
} ;

/* SQRT(3)
 *********************************************************************************/

template <typename PFP>
class Sqrt3OddSynthesisFilter : public Filter
{
protected:
	typename PFP::MAP& m_map;
	VertexAttribute<typename PFP::VEC3>& m_position;
Pierre Kraemer's avatar
Pierre Kraemer committed
326

untereiner's avatar
untereiner 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
public:
	Sqrt3OddSynthesisFilter(typename PFP::MAP& m, VertexAttribute<typename PFP::VEC3>& p) : m_map(m), m_position(p)
	{}

	void operator() ()
	{
		TraversorF<typename PFP::MAP> trav(m_map);
		for(Dart d = trav.begin() ; d != trav.end() ; d = trav.next())
		{
			typename PFP::VEC3 p(0.0);

			p += m_position[d];
			p += m_position[m_map.phi1(d)];
			p += m_position[m_map.phi_1(d)];

			p /= 3.0;

			m_map.incCurrentLevel() ;
			Dart midF = m_map.phi1(d);
			m_position[midF] = p ;
			m_map.decCurrentLevel() ;
		}
	}
};
351 352 353


/*********************************************************************************
354
 *                           SUBDIVISION FUNCTORS
355 356 357 358 359 360 361
 *********************************************************************************/

template <typename PFP>
class PipoVertexVertexFunctor : public FunctorType
{
protected:
	typename PFP::MAP& m_map ;
362
	VertexAttribute<typename PFP::VEC3>& m_position ;
363 364

public:
365
	PipoVertexVertexFunctor(typename PFP::MAP& m, VertexAttribute<typename PFP::VEC3>& p) : m_map(m), m_position(p)
366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384
	{}

	bool operator() (Dart d)
	{
		m_map.decCurrentLevel() ;
		typename PFP::VEC3 p = m_position[d] ;
		m_map.incCurrentLevel() ;

		m_position[d] = p ;

		return false ;
	}
} ;

template <typename PFP>
class PipoEdgeVertexFunctor : public FunctorType
{
protected:
	typename PFP::MAP& m_map ;
385
	VertexAttribute<typename PFP::VEC3>& m_position ;
386 387

public:
388
	PipoEdgeVertexFunctor(typename PFP::MAP& m, VertexAttribute<typename PFP::VEC3>& p) : m_map(m), m_position(p)
389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410
	{}

	bool operator() (Dart d)
	{
		Dart d1 = m_map.phi2(d) ;

		m_map.decCurrentLevel() ;
		Dart d2 = m_map.phi2(d1) ;
		typename PFP::VEC3 p = (m_position[d1] + m_position[d2]) / 2.0 ;
		m_map.incCurrentLevel() ;

		m_position[d] = p ;

		return false ;
	}
} ;

template <typename PFP>
class PipoFaceVertexFunctor : public FunctorType
{
protected:
	typename PFP::MAP& m_map ;
411
	VertexAttribute<typename PFP::VEC3>& m_position ;
412 413

public:
414
	PipoFaceVertexFunctor(typename PFP::MAP& m, VertexAttribute<typename PFP::VEC3>& p) : m_map(m), m_position(p)
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
	{}

	bool operator() (Dart d)
	{
		Dart df = m_map.phi1(m_map.phi1(d)) ;

		m_map.decCurrentLevel() ;

		typename PFP::VEC3 p(0) ;
		unsigned int degree = 0 ;
		Traversor2FV<typename PFP::MAP> trav(m_map, df) ;
		for(Dart it = trav.begin(); it != trav.end(); it = trav.next())
		{
			++degree ;
			p += m_position[it] ;
		}
		p /= degree ;

		m_map.incCurrentLevel() ;

		m_position[d] = p ;

		return false ;
	}
} ;

template <typename PFP>
class LoopVertexVertexFunctor : public FunctorType
{
protected:
	typename PFP::MAP& m_map ;
446
	VertexAttribute<typename PFP::VEC3>& m_position ;
447 448

public:
449
	LoopVertexVertexFunctor(typename PFP::MAP& m, VertexAttribute<typename PFP::VEC3>& p) : m_map(m), m_position(p)
450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483
	{}

	bool operator() (Dart d)
	{
		m_map.decCurrentLevel() ;

		typename PFP::VEC3 np(0) ;
		unsigned int degree = 0 ;
		Traversor2VVaE<typename PFP::MAP> trav(m_map, d) ;
		for(Dart it = trav.begin(); it != trav.end(); it = trav.next())
		{
			++degree ;
			np += m_position[it] ;
		}
		float tmp = 3.0 + 2.0 * cos(2.0 * M_PI / degree) ;
		float beta = (5.0 / 8.0) - ( tmp * tmp / 64.0 ) ;
		np *= beta / degree ;

		typename PFP::VEC3 vp = m_position[d] ;
		vp *= 1.0 - beta ;

		m_map.incCurrentLevel() ;

		m_position[d] = np + vp ;

		return false ;
	}
} ;

template <typename PFP>
class LoopEdgeVertexFunctor : public FunctorType
{
protected:
	typename PFP::MAP& m_map ;
484
	VertexAttribute<typename PFP::VEC3>& m_position ;
485 486

public:
487
	LoopEdgeVertexFunctor(typename PFP::MAP& m, VertexAttribute<typename PFP::VEC3>& p) : m_map(m), m_position(p)
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 516 517 518 519 520 521 522
	{}

	bool operator() (Dart d)
	{
		Dart d1 = m_map.phi2(d) ;

		m_map.decCurrentLevel() ;

		Dart d2 = m_map.phi2(d1) ;
		Dart d3 = m_map.phi_1(d1) ;
		Dart d4 = m_map.phi_1(d2) ;

		typename PFP::VEC3 p1 = m_position[d1] ;
		typename PFP::VEC3 p2 = m_position[d2] ;
		typename PFP::VEC3 p3 = m_position[d3] ;
		typename PFP::VEC3 p4 = m_position[d4] ;

		p1 *= 3.0 / 8.0 ;
		p2 *= 3.0 / 8.0 ;
		p3 *= 1.0 / 8.0 ;
		p4 *= 1.0 / 8.0 ;

		m_map.incCurrentLevel() ;

		m_position[d] = p1 + p2 + p3 + p4 ;

		return false ;
	}
} ;

template <typename PFP>
class CCVertexVertexFunctor : public FunctorType
{
protected:
	typename PFP::MAP& m_map ;
523
	VertexAttribute<typename PFP::VEC3>& m_position ;
524 525

public:
526
	CCVertexVertexFunctor(typename PFP::MAP& m, VertexAttribute<typename PFP::VEC3>& p) : m_map(m), m_position(p)
527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574
	{}

	bool operator() (Dart d)
	{
		m_map.decCurrentLevel() ;

		typename PFP::VEC3 np1(0) ;
		typename PFP::VEC3 np2(0) ;
		unsigned int degree1 = 0 ;
		unsigned int degree2 = 0 ;
		Dart it = d ;
		do
		{
			++degree1 ;
			Dart dd = m_map.phi1(it) ;
			np1 += m_position[dd] ;
			Dart end = m_map.phi_1(it) ;
			dd = m_map.phi1(dd) ;
			do
			{
				++degree2 ;
				np2 += m_position[dd] ;
				dd = m_map.phi1(dd) ;
			} while(dd != end) ;
			it = m_map.alpha1(it) ;
		} while(it != d) ;

		float beta = 3.0 / (2.0 * degree1) ;
		float gamma = 1.0 / (4.0 * degree2) ;
		np1 *= beta / degree1 ;
		np2 *= gamma / degree2 ;

		typename PFP::VEC3 vp = m_position[d] ;
		vp *= 1.0 - beta - gamma ;

		m_map.incCurrentLevel() ;

		m_position[d] = np1 + np2 + vp ;

		return false ;
	}
} ;

template <typename PFP>
class CCEdgeVertexFunctor : public FunctorType
{
protected:
	typename PFP::MAP& m_map ;
575
	VertexAttribute<typename PFP::VEC3>& m_position ;
576 577

public:
578
	CCEdgeVertexFunctor(typename PFP::MAP& m, VertexAttribute<typename PFP::VEC3>& p) : m_map(m), m_position(p)
579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619
	{}

	bool operator() (Dart d)
	{
		Dart d1 = m_map.phi2(d) ;

		m_map.decCurrentLevel() ;

		Dart d2 = m_map.phi2(d1) ;
		Dart d3 = m_map.phi_1(d1) ;
		Dart d4 = m_map.phi_1(d2) ;
		Dart d5 = m_map.phi1(m_map.phi1(d1)) ;
		Dart d6 = m_map.phi1(m_map.phi1(d2)) ;

		typename PFP::VEC3 p1 = m_position[d1] ;
		typename PFP::VEC3 p2 = m_position[d2] ;
		typename PFP::VEC3 p3 = m_position[d3] ;
		typename PFP::VEC3 p4 = m_position[d4] ;
		typename PFP::VEC3 p5 = m_position[d5] ;
		typename PFP::VEC3 p6 = m_position[d6] ;

		p1 *= 3.0 / 8.0 ;
		p2 *= 3.0 / 8.0 ;
		p3 *= 1.0 / 16.0 ;
		p4 *= 1.0 / 16.0 ;
		p5 *= 1.0 / 16.0 ;
		p6 *= 1.0 / 16.0 ;

		m_map.incCurrentLevel() ;

		m_position[d] = p1 + p2 + p3 + p4 + p5 + p6 ;

		return false ;
	}
} ;

template <typename PFP>
class CCFaceVertexFunctor : public FunctorType
{
protected:
	typename PFP::MAP& m_map ;
620
	VertexAttribute<typename PFP::VEC3>& m_position ;
621 622

public:
623
	CCFaceVertexFunctor(typename PFP::MAP& m, VertexAttribute<typename PFP::VEC3>& p) : m_map(m), m_position(p)
624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647
	{}

	bool operator() (Dart d)
	{
		Dart df = m_map.phi1(m_map.phi1(d)) ;

		m_map.decCurrentLevel() ;

		typename PFP::VEC3 p(0) ;
		unsigned int degree = 0 ;
		Traversor2FV<typename PFP::MAP> trav(m_map, df) ;
		for(Dart it = trav.begin(); it != trav.end(); it = trav.next())
		{
			++degree ;
			p += m_position[it] ;
		}
		p /= degree ;

		m_map.incCurrentLevel() ;

		m_position[d] = p ;

		return false ;
	}
Pierre Kraemer's avatar
Pierre Kraemer committed
648 649
} ;

untereiner's avatar
untereiner committed
650

651
} // namespace MR
652

653
} // namespace Algo
654

Pierre Kraemer's avatar
Pierre Kraemer committed
655 656 657
} // namespace CGoGN

#endif
658