selector.h 5.32 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-2013, IGG Team, ICube, 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
* Contact information: cgogn@unistra.fr                                        *
*                                                                              *
*******************************************************************************/

#ifndef __SELECTOR_H__
#define __SELECTOR_H__

namespace CGoGN
{

namespace Algo
{

34 35 36
namespace Surface
{

Pierre Kraemer's avatar
Pierre Kraemer committed
37 38 39 40 41
namespace Decimation
{

enum SelectorType
{
42 43
	// EDGE selectors
	// Topo criteria
44 45
	S_MapOrder = 0, /**< Prioritizes edges in topological order. Requires a geometry approximator. */
	S_Random = 1, /**< Prioritizes edges in random order. Requires a geometry approximator. */
46
	// Geom criteria
47 48 49 50 51 52 53
	S_EdgeLength = 2, /**< Prioritizes edges in increasing order of their lengths. Requires a geometry approximator. */
	S_QEM = 3, /**< Prioritizes by their quadric error metric (QEM) error [GH97]. Requires a geometry approximator. */
	S_QEMml = 4, /**< Prioritizes edges by their "memoryless" quadric error metric (QEM) error [Hop99]. Requires a geometry approximator. */
	S_MinDetail = 5, /**< Requires a geometry approximator. */
	S_Curvature = 6, /**< Requires a geometry approximator. */
	S_NormalArea = 7, /**< EXPERIMENTAL Prioritizes edges ranked by their normal times area measure [Sauvage]. Requires a geometry approximator. */
	S_CurvatureTensor = 8, /**< Requires a geometry approximator. */
54
	// Geom + color criteria
55 56 57
	S_ColorNaive = 9, /**< Prioritizes edges by a sum of the QEM measure on geometry and the L2 distance between RGB colors of both adjacent vertices.  Requires a geometry approximator. Requires a color approximator. */
	S_QEMextColor = 10, /**< Prioritizes edges by the quadric error metric (QEM) error extended in R^6 (x,y,z,R,G,B) [GH98].  Requires a geometry approximator. Requires a color approximator. */
	S_GeomColOptGrad = 11, /**< EXPERIMENTAL. Requires a geometry approximator. Requires a color approximator. */
58 59 60

	// HALF-EDGE selectors
	// Geom criteria
61
	S_hQEMml = 12, /**< Prioritizes half-edges according to the quadric error metric (QEM) of the considered collapse [Hop99]. Requires a geometry approximator. */
62
	// Geom + color criteria
63 64
	S_hQEMextColor = 13, /**< Prioritizes half-edges by the quadric error metric (QEM) error extended in R^6 (x,y,z,R,G,B) [GH98]. Requires a geometry approximator. Requires a color approximator. */
	S_hColorGradient = 14, /**< EXPERIMENTAL Prioritizes half-edges according to the sum of the quadric error metric (QEM) for geometry and the gradient color deviation metric of [Vanhoey,Sauvage]. Requires a geometry approximator. Requires a color approximator. */
65

66
	S_OTHER /**< Can be used for extensions. */
Pierre Kraemer's avatar
Pierre Kraemer committed
67 68 69
} ;

template <typename PFP> class ApproximatorGen ;
70
template <typename PFP, typename T, unsigned int ORBIT> class Approximator ;
Pierre Kraemer's avatar
Pierre Kraemer committed
71

72 73 74 75
/*!
 * \class Selector
 * \brief Generic class for selectors
 */
Pierre Kraemer's avatar
Pierre Kraemer committed
76
template <typename PFP>
77
class Selector
Pierre Kraemer's avatar
Pierre Kraemer committed
78 79 80 81 82 83 84 85
{
public:
	typedef typename PFP::MAP MAP ;
	typedef typename PFP::VEC3 VEC3 ;
	typedef typename PFP::REAL REAL ;

protected:
	MAP& m_map ;
86
	VertexAttribute<typename PFP::VEC3>& m_position ;
Pierre Kraemer's avatar
Pierre Kraemer committed
87 88 89
	std::vector<ApproximatorGen<PFP>*>& m_approximators ;

public:
90
	Selector(MAP& m, VertexAttribute<typename PFP::VEC3>& pos, std::vector<ApproximatorGen<PFP>*>& approx) :
91
		m_map(m), m_position(pos), m_approximators(approx)
Pierre Kraemer's avatar
Pierre Kraemer committed
92
	{}
93
	virtual ~Selector()
Pierre Kraemer's avatar
Pierre Kraemer committed
94 95 96
	{}
	virtual SelectorType getType() = 0 ;
	virtual bool init() = 0 ;
97
	virtual bool nextEdge(Dart& d) const = 0 ;
Pierre Kraemer's avatar
Pierre Kraemer committed
98 99
	virtual void updateBeforeCollapse(Dart d) = 0 ;
	virtual void updateAfterCollapse(Dart d2, Dart dd2) = 0 ;
100
	virtual void updateWithoutCollapse() = 0;
101

Sylvain Thery's avatar
Sylvain Thery committed
102
	virtual void getEdgeErrors(EdgeAttribute<typename PFP::REAL>* /*errors*/) const
103
	{
Kenneth Vanhoey's avatar
Kenneth Vanhoey committed
104
		std::cout << "WARNING:: getEdgeErrors was not overridden" << std::endl ;
105
	}
Pierre Kraemer's avatar
Pierre Kraemer committed
106 107 108 109
} ;

} // namespace Decimation

110
} // namespace Surface
111

Pierre Kraemer's avatar
Pierre Kraemer committed
112 113 114 115 116
} // namespace Algo

} // namespace CGoGN

#endif