selector.h 3.43 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 26 27 28 29 30 31 32 33 34 35 36 37 38
* Contact information: cgogn@unistra.fr                                        *
*                                                                              *
*******************************************************************************/

#ifndef __SELECTOR_H__
#define __SELECTOR_H__

namespace CGoGN
{

namespace Algo
{

namespace Decimation
{

enum SelectorType
{
39
	S_MapOrder = 0,
Pierre Kraemer's avatar
Pierre Kraemer committed
40 41 42
	S_Random,
	S_EdgeLength,
	S_QEM,
43
	S_QEMml,
Pierre Kraemer's avatar
Pierre Kraemer committed
44 45
	S_MinDetail,
	S_Curvature,
46
	S_NormalArea,
47
	S_CurvatureTensor,
48
	S_ColorNaive,
49
	S_QEMextColor,
50
	S_Lightfield,
51
	// note: the following "h" prefix means that half-edges are prioritized instead of edges.
52 53
	S_hQEMextColor,
	S_hQEMml,
Kenneth Vanhoey's avatar
Kenneth Vanhoey committed
54 55
	S_hLightfield,
	S_hLightfieldExp
Pierre Kraemer's avatar
Pierre Kraemer committed
56 57 58
} ;

template <typename PFP> class ApproximatorGen ;
59
template <typename PFP, typename T, unsigned int ORBIT> class Approximator ;
Pierre Kraemer's avatar
Pierre Kraemer committed
60 61 62 63 64 65 66 67 68 69 70

template <typename PFP>
class EdgeSelector
{
public:
	typedef typename PFP::MAP MAP ;
	typedef typename PFP::VEC3 VEC3 ;
	typedef typename PFP::REAL REAL ;

protected:
	MAP& m_map ;
71
	VertexAttribute<typename PFP::VEC3>& m_position ;
Pierre Kraemer's avatar
Pierre Kraemer committed
72 73 74 75
	std::vector<ApproximatorGen<PFP>*>& m_approximators ;
	const FunctorSelect& m_select ;

public:
76
	EdgeSelector(MAP& m, VertexAttribute<typename PFP::VEC3>& pos, std::vector<ApproximatorGen<PFP>*>& approx, const FunctorSelect& select) :
Pierre Kraemer's avatar
Pierre Kraemer committed
77 78 79 80 81 82 83 84 85
		m_map(m), m_position(pos), m_approximators(approx), m_select(select)
	{}
	virtual ~EdgeSelector()
	{}
	virtual SelectorType getType() = 0 ;
	virtual bool init() = 0 ;
	virtual bool nextEdge(Dart& d) = 0 ;
	virtual void updateBeforeCollapse(Dart d) = 0 ;
	virtual void updateAfterCollapse(Dart d2, Dart dd2) = 0 ;
86
	virtual void updateWithoutCollapse() = 0;
87 88 89

	virtual void getEdgeErrors(EdgeAttribute<typename PFP::REAL> *errors)
	{
Kenneth Vanhoey's avatar
Kenneth Vanhoey committed
90
		std::cout << "WARNING:: getEdgeErrors was not overridden" << std::endl ;
91
	}
Pierre Kraemer's avatar
Pierre Kraemer committed
92 93 94 95 96 97 98 99 100
} ;

} // namespace Decimation

} // namespace Algo

} // namespace CGoGN

#endif