edgeSelector.h 2.47 KB
Newer Older
1
2
3
4
5
6
#ifndef __EDGE_SELECTOR_VOLUMES_H__
#define __EDGE_SELECTOR_VOLUMES_H__

#include "Container/fakeAttribute.h"
#include "Algo/DecimationVolumes/selector.h"
#include "Algo/DecimationVolumes/operator.h"
7
8
#include "Utils/qem.h"
#include "Topology/generic/traversorCell.h"
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

namespace CGoGN
{

namespace Algo
{

namespace DecimationVolumes
{

/********************************************************************************
 *			 				Parent Edge Selector								*
 ********************************************************************************/
template <typename PFP>
class EdgeSelector : public Selector<PFP>
{
public:
	typedef typename PFP::MAP MAP ;
	typedef typename PFP::VEC3 VEC3 ;
	typedef typename PFP::REAL REAL;

protected:


public:
untereiner's avatar
untereiner committed
34
35
	EdgeSelector(MAP& m, VertexAttribute<typename PFP::VEC3>& pos, std::vector<ApproximatorGen<PFP>*>& approx, const FunctorSelect& select) :
		Selector<PFP>(m, pos, approx, select)
36
37
38
39
40
	{}

};

template <typename PFP>
41
class EdgeSelector_QEM : public EdgeSelector<PFP>
42
43
{
public:
44
45
	typedef typename PFP::MAP MAP;
	typedef typename PFP::VEC3 VEC3;
46
47
48
	typedef typename PFP::REAL REAL;

private:
49
50
51
52
53
54
	typedef struct
	{
		typename std::multimap<float, Dart>::iterator it;
		bool valid;
		static std::string CGoGNnameOfType() { return "QEMedgeInfo" ; }
	} QEMedgeInfo;
55

56
	typedef NoMathIOAttribute<QEMedgeInfo> EdgeInfo;
57

58
59
60
	EdgeAttribute<EdgeInfo> edgeInfo;
	VertexAttribute<Quadric<REAL> > quadric;
	Quadric<REAL> tmpQ;
61

62
63
	std::multimap<float, Dart> edges;
	typename std::multimap<float, Dart>::iterator cur;
64

65
	Approximator<PFP, typename PFP::VEC3>* m_positionApproximator;
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
	void initEdgeInfo(Dart d);
	void updateEdgeInfo(Dart d, bool recompute);
	void computeEdgeInfo(Dart d, EdgeInfo& einfo);

public:
	EdgeSelector_QEM(MAP& m, VertexAttribute<typename PFP::VEC3>& pos,
			std::vector<ApproximatorGen<PFP>* >& approx, const FunctorSelect& select) :
				EdgeSelector<PFP>(m, pos, approx, select)
	{
		edgeInfo = m.template addAttribute<EdgeInfo, EDGE>("edgeInfo");
		quadric = m.template addAttribute<Quadric<REAL>, VERTEX>("QEMquadric");
	}

	~EdgeSelector_QEM()
	{
		this->m_map.removeAttribute(quadric);
		this->m_map.removeAttribute(edgeInfo);
	}

	SelectorType getType() { return S_QEM; }
	bool init();
	Operator<PFP>* nextOperator();
	bool updateBeforeOperation(Operator<PFP>* op);
	void updateAfterOperation(Operator<PFP>* op);
	void finish() { }
92
93
};

94
95


96
97
98
99
100
101
102
103

} //end namespace DecimationVolumes

} //end namespace Algo

} //end namespace CGoGN


untereiner's avatar
untereiner committed
104
#include "Algo/DecimationVolumes/edgeSelector.hpp"
105
106

#endif