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

#ifndef __GEOMETRY_APPROXIMATOR_H__
#define __GEOMETRY_APPROXIMATOR_H__

#include "Algo/Decimation/approximator.h"
Sauvage's avatar
Sauvage committed
29
#include <Eigen/Dense>
Pierre Kraemer's avatar
Pierre Kraemer committed
30
31
32
33
34
35
36
37
38
39
40

namespace CGoGN
{

namespace Algo
{

namespace Decimation
{

template <typename PFP>
41
class Approximator_QEM : public Approximator<PFP, typename PFP::VEC3, EDGE>
Pierre Kraemer's avatar
Pierre Kraemer committed
42
43
44
45
46
47
48
{
public:
	typedef typename PFP::MAP MAP ;
	typedef typename PFP::VEC3 VEC3 ;
	typedef typename PFP::REAL REAL ;

protected:
49
	VertexAttribute<Utils::Quadric<REAL> > m_quadric ;
Pierre Kraemer's avatar
Pierre Kraemer committed
50
51

public:
52
	Approximator_QEM(MAP& m, std::vector<VertexAttribute<VEC3>* > pos, Predictor<PFP, VEC3>* pred = NULL) :
53
		Approximator<PFP, VEC3, EDGE>(m, pos, pred)
54
55
56
	{
		assert(pos.size() > 0 || !"Approximator_QEM: attribute vector is empty") ;
	}
Pierre Kraemer's avatar
Pierre Kraemer committed
57
58
59
60
61
62
63
	~Approximator_QEM()
	{}
	ApproximatorType getType() const { return A_QEM ; }
	bool init() ;
	void approximate(Dart d) ;
} ;

Kenneth Vanhoey's avatar
Kenneth Vanhoey committed
64
template <typename PFP>
65
class Approximator_QEMhalfEdge : public Approximator<PFP, typename PFP::VEC3, DART>
Kenneth Vanhoey's avatar
Kenneth Vanhoey committed
66
67
68
69
70
71
72
{
public:
	typedef typename PFP::MAP MAP ;
	typedef typename PFP::VEC3 VEC3 ;
	typedef typename PFP::REAL REAL ;

protected:
73
	VertexAttribute<Utils::Quadric<REAL> > m_quadric ;
Kenneth Vanhoey's avatar
Kenneth Vanhoey committed
74
75

public:
76
	Approximator_QEMhalfEdge(MAP& m, std::vector<VertexAttribute<VEC3>* > pos, Predictor<PFP, VEC3>* pred = NULL) :
77
		Approximator<PFP, VEC3, DART>(m, pos, pred)
78
79
80
	{
		assert(pos.size() > 0 || !"Approximator_QEMhalfEdge: attribute vector is empty") ;
	}
Kenneth Vanhoey's avatar
Kenneth Vanhoey committed
81
	~Approximator_QEMhalfEdge()
Kenneth Vanhoey's avatar
Kenneth Vanhoey committed
82
	{}
83
	ApproximatorType getType() const { return A_hQEM ; }
Kenneth Vanhoey's avatar
Kenneth Vanhoey committed
84
85
86
87
	bool init() ;
	void approximate(Dart d) ;
} ;

Pierre Kraemer's avatar
Pierre Kraemer committed
88
template <typename PFP>
89
class Approximator_MidEdge : public Approximator<PFP, typename PFP::VEC3, EDGE>
Pierre Kraemer's avatar
Pierre Kraemer committed
90
91
92
93
94
95
{
public:
	typedef typename PFP::MAP MAP ;
	typedef typename PFP::VEC3 VEC3 ;
	typedef typename PFP::REAL REAL ;

96
	Approximator_MidEdge(MAP& m, std::vector<VertexAttribute<VEC3>* > pos, Predictor<PFP, VEC3>* pred = NULL) :
97
		Approximator<PFP, VEC3, EDGE>(m, pos, pred)
98
99
100
	{
		assert(pos.size() > 0 || !"Approximator_MidEdge: attribute vector is empty") ;
	}
Pierre Kraemer's avatar
Pierre Kraemer committed
101
102
103
104
105
106
107
108
	~Approximator_MidEdge()
	{}
	ApproximatorType getType() const { return A_MidEdge ; }
	bool init() ;
	void approximate(Dart d) ;
} ;

template <typename PFP>
109
class Approximator_HalfCollapse : public Approximator<PFP, typename PFP::VEC3, DART>
Pierre Kraemer's avatar
Pierre Kraemer committed
110
111
112
113
114
115
{
public:
	typedef typename PFP::MAP MAP ;
	typedef typename PFP::VEC3 VEC3 ;
	typedef typename PFP::REAL REAL ;

116
	Approximator_HalfCollapse(MAP& m, std::vector<VertexAttribute<VEC3>* > pos, Predictor<PFP, VEC3>* pred = NULL) :
117
		Approximator<PFP, VEC3, DART>(m, pos, pred)
118
119
120
	{
		assert(pos.size() > 0 || !"Approximator_HalfCollapse: attribute vector is empty") ;
	}
121
122
	~Approximator_HalfCollapse() {}

123
	ApproximatorType getType() const { return A_hHalfCollapse ; }
Pierre Kraemer's avatar
Pierre Kraemer committed
124
125
126
127
128
	bool init() ;
	void approximate(Dart d) ;
} ;

template <typename PFP>
129
class Approximator_CornerCutting : public Approximator<PFP, typename PFP::VEC3, EDGE>
Pierre Kraemer's avatar
Pierre Kraemer committed
130
131
132
133
134
135
{
public:
	typedef typename PFP::MAP MAP ;
	typedef typename PFP::VEC3 VEC3 ;
	typedef typename PFP::REAL REAL ;

136
	Approximator_CornerCutting(MAP& m, std::vector<VertexAttribute<VEC3>* > pos, Predictor<PFP, VEC3>* pred = NULL) :
137
		Approximator<PFP, VEC3, EDGE>(m, pos, pred)
138
139
140
	{
		assert(pos.size() > 0 || !"Approximator_CornerCutting: attribute vector is empty") ;
	}
Pierre Kraemer's avatar
Pierre Kraemer committed
141
142
143
144
145
146
147
	~Approximator_CornerCutting()
	{}
	ApproximatorType getType() const { return A_CornerCutting ; }
	bool init() ;
	void approximate(Dart d) ;
} ;

Sauvage's avatar
Sauvage committed
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
template <typename PFP>
class Approximator_NormalArea : public Approximator<PFP, typename PFP::VEC3, EDGE>
{
public:
	typedef typename PFP::MAP MAP ;
	typedef typename PFP::VEC3 VEC3 ;
	typedef typename PFP::REAL REAL ;

protected:
//	VertexAttribute<Utils::Quadric<REAL> > m_quadric ;
	EdgeAttribute<Geom::Matrix<3,3,REAL> > edgeMatrix ;

public:
	Approximator_NormalArea(MAP& m, std::vector<VertexAttribute<VEC3>* > pos, Predictor<PFP, VEC3>* pred = NULL) :
		Approximator<PFP, VEC3, EDGE>(m, pos, pred)
	{
		assert(pos.size() > 0 || !"Approximator_NormalArea: attribute vector is empty") ;
	}
	~Approximator_NormalArea()
	{}
	ApproximatorType getType() const { return A_NormalArea ; }
	bool init() ;
	void approximate(Dart d) ;
} ;


Pierre Kraemer's avatar
Pierre Kraemer committed
174
175
176
177
178
179
180
181
182
} //namespace Decimation

} //namespace Algo

} //namespace CGoGN

#include "Algo/Decimation/geometryApproximator.hpp"

#endif