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

#ifndef __ALGO_GEOMETRY_CURVATURE_H__
#define __ALGO_GEOMETRY_CURVATURE_H__

#include "Geometry/basic.h"

30 31
#include "Algo/Selection/collector.h"

32 33
#include "Utils/convertType.h"

34
#include "NL/nl.h"
Pierre Kraemer's avatar
Pierre Kraemer committed
35

36 37 38
#include <Eigen/Core>
#include <Eigen/Eigenvalues>

Pierre Kraemer's avatar
Pierre Kraemer committed
39 40 41 42 43 44
namespace CGoGN
{

namespace Algo
{

45 46 47
namespace Surface
{

Pierre Kraemer's avatar
Pierre Kraemer committed
48 49 50
namespace Geometry
{

51
//typedef CPULinearSolverTraits< SparseMatrix<double>, FullVector<double> > CPUSolverTraits ;
Pierre Kraemer's avatar
Pierre Kraemer committed
52 53

template <typename PFP>
Pierre Kraemer's avatar
Pierre Kraemer committed
54
void computeCurvatureVertices_QuadraticFitting(
Pierre Kraemer's avatar
Pierre Kraemer committed
55
	typename PFP::MAP& map,
56 57 58 59 60
	const VertexAttribute<typename PFP::VEC3, typename PFP::MAP>& position,
	const VertexAttribute<typename PFP::VEC3, typename PFP::MAP>& normal,
	VertexAttribute<typename PFP::REAL, typename PFP::MAP>& kmax,
	VertexAttribute<typename PFP::REAL, typename PFP::MAP>& kmin,
	VertexAttribute<typename PFP::VEC3, typename PFP::MAP>& Kmax,
Sylvain Thery's avatar
Sylvain Thery committed
61
	VertexAttribute<typename PFP::VEC3, typename PFP::MAP>& Kmin) ;
Pierre Kraemer's avatar
Pierre Kraemer committed
62 63

template <typename PFP>
Pierre Kraemer's avatar
Pierre Kraemer committed
64
void computeCurvatureVertex_QuadraticFitting(
Pierre Kraemer's avatar
Pierre Kraemer committed
65
	typename PFP::MAP& map,
Pierre Kraemer's avatar
Pierre Kraemer committed
66
	Vertex v,
67 68 69 70 71 72
	const VertexAttribute<typename PFP::VEC3, typename PFP::MAP>& position,
	const VertexAttribute<typename PFP::VEC3, typename PFP::MAP>& normal,
	VertexAttribute<typename PFP::REAL, typename PFP::MAP>& kmax,
	VertexAttribute<typename PFP::REAL, typename PFP::MAP>& kmin,
	VertexAttribute<typename PFP::VEC3, typename PFP::MAP>& Kmax,
	VertexAttribute<typename PFP::VEC3, typename PFP::MAP>& Kmin) ;
Pierre Kraemer's avatar
Pierre Kraemer committed
73 74

template <typename PFP>
Pierre Kraemer's avatar
Pierre Kraemer committed
75
void vertexQuadraticFitting(
Pierre Kraemer's avatar
Pierre Kraemer committed
76
	typename PFP::MAP& map,
Pierre Kraemer's avatar
Pierre Kraemer committed
77
	Vertex v,
Pierre Kraemer's avatar
Pierre Kraemer committed
78
	typename PFP::MATRIX33& localFrame,
79 80
	const VertexAttribute<typename PFP::VEC3, typename PFP::MAP>& position,
	const VertexAttribute<typename PFP::VEC3, typename PFP::MAP>& normal,
81
    typename PFP::REAL& a, typename PFP::REAL& b, typename PFP::REAL& c, typename PFP::REAL& d, typename PFP::REAL& e) ;
Pierre Kraemer's avatar
Pierre Kraemer committed
82 83

template <typename PFP>
Pierre Kraemer's avatar
Pierre Kraemer committed
84 85 86 87
void quadraticFittingAddVertexPos(
	typename PFP::VEC3& v,
	typename PFP::VEC3& p,
	typename PFP::MATRIX33& localFrame) ;
Pierre Kraemer's avatar
Pierre Kraemer committed
88 89

template <typename PFP>
Pierre Kraemer's avatar
Pierre Kraemer committed
90 91 92 93 94 95
void quadraticFittingAddVertexNormal(
	typename PFP::VEC3& v,
	typename PFP::VEC3& n,
	typename PFP::VEC3& p,
	typename PFP::MATRIX33& localFrame) ;

Pierre Kraemer's avatar
Pierre Kraemer committed
96 97 98 99 100 101 102 103 104 105 106
/*
template <typename PFP>
void vertexCubicFitting(Dart dart, typename PFP::VEC3& normal, float& a, float& b, float& c, float& d, float& e, float& f, float& g, float& h, float& i) ;

template <typename PFP>
void cubicFittingAddVertexPos(typename PFP::VEC3& v, typename PFP::VEC3& p, typename PFP::MATRIX33& localFrame) ;

template <typename PFP>
void cubicFittingAddVertexNormal(typename PFP::VEC3& v, typename PFP::VEC3& n, typename PFP::VEC3& p, typename PFP::MATRIX33& localFrame) ;
*/

Pierre Kraemer's avatar
Pierre Kraemer committed
107 108
/* normal cycles by [ACDLD03] : useful for parallel computing */

Pierre Kraemer's avatar
Pierre Kraemer committed
109 110 111 112
template <typename PFP>
void computeCurvatureVertices_NormalCycles(
	typename PFP::MAP& map,
	typename PFP::REAL radius,
113 114 115
	const VertexAttribute<typename PFP::VEC3, typename PFP::MAP>& position,
	const VertexAttribute<typename PFP::VEC3, typename PFP::MAP>& normal,
	const EdgeAttribute<typename PFP::REAL, typename PFP::MAP>& edgeangle,
116
	const EdgeAttribute<typename PFP::REAL, typename PFP::MAP>& edgearea,
117 118 119 120
	VertexAttribute<typename PFP::REAL, typename PFP::MAP>& kmax,
	VertexAttribute<typename PFP::REAL, typename PFP::MAP>& kmin,
	VertexAttribute<typename PFP::VEC3, typename PFP::MAP>& Kmax,
	VertexAttribute<typename PFP::VEC3, typename PFP::MAP>& Kmin,
Sylvain Thery's avatar
Sylvain Thery committed
121
	VertexAttribute<typename PFP::VEC3, typename PFP::MAP>& Knormal) ;
Pierre Kraemer's avatar
Pierre Kraemer committed
122 123 124 125

template <typename PFP>
void computeCurvatureVertex_NormalCycles(
	typename PFP::MAP& map,
Pierre Kraemer's avatar
Pierre Kraemer committed
126
	Vertex v,
127
	typename PFP::REAL radius,
128 129 130
	const VertexAttribute<typename PFP::VEC3, typename PFP::MAP>& position,
	const VertexAttribute<typename PFP::VEC3, typename PFP::MAP>& normal,
	const EdgeAttribute<typename PFP::REAL, typename PFP::MAP>& edgeangle,
131
	const EdgeAttribute<typename PFP::REAL, typename PFP::MAP>& edgearea,
132 133 134 135
	VertexAttribute<typename PFP::REAL, typename PFP::MAP>& kmax,
	VertexAttribute<typename PFP::REAL, typename PFP::MAP>& kmin,
	VertexAttribute<typename PFP::VEC3, typename PFP::MAP>& Kmax,
	VertexAttribute<typename PFP::VEC3, typename PFP::MAP>& Kmin,
Sylvain Thery's avatar
Sylvain Thery committed
136
	VertexAttribute<typename PFP::VEC3, typename PFP::MAP>& Knormal) ;
Pierre Kraemer's avatar
Pierre Kraemer committed
137

138 139 140 141 142 143 144 145 146
template <typename PFP>
void normalCycles_SortAndSetEigenComponents(
	const typename PFP::VEC3& e_val,
	const Geom::Matrix<3,3,typename PFP::REAL> & e_vec,
	typename PFP::REAL& kmax,
	typename PFP::REAL& kmin,
	typename PFP::VEC3& Kmax,
	typename PFP::VEC3& Kmin,
	typename PFP::VEC3& Knormal,
Sylvain Thery's avatar
Sylvain Thery committed
147
	const typename PFP::VEC3& normal) ;
Pierre Kraemer's avatar
Pierre Kraemer committed
148

Sauvage's avatar
Sauvage committed
149
template <typename PFP>
Pierre Kraemer's avatar
Pierre Kraemer committed
150
void normalCycles_SortTensor(
Sylvain Thery's avatar
Sylvain Thery committed
151
	Geom::Matrix<3,3,typename PFP::REAL>& tensor) ;
152

Sauvage's avatar
Sauvage committed
153
template <typename PFP>
Pierre Kraemer's avatar
Pierre Kraemer committed
154 155
void normalCycles_ProjectTensor(
	Geom::Matrix<3,3,typename PFP::REAL>& tensor,
Sylvain Thery's avatar
Sylvain Thery committed
156
	const typename PFP::VEC3& normal_vector) ;
Sauvage's avatar
Sauvage committed
157 158 159 160 161

template <typename PFP>
void computeCurvatureVertices_NormalCycles_Projected(
	typename PFP::MAP& map,
	typename PFP::REAL radius,
162 163 164
	const VertexAttribute<typename PFP::VEC3, typename PFP::MAP>& position,
	const VertexAttribute<typename PFP::VEC3, typename PFP::MAP>& normal,
	const EdgeAttribute<typename PFP::REAL, typename PFP::MAP>& edgeangle,
165
	const EdgeAttribute<typename PFP::REAL, typename PFP::MAP>& edgearea,
166 167 168 169
	VertexAttribute<typename PFP::REAL, typename PFP::MAP>& kmax,
	VertexAttribute<typename PFP::REAL, typename PFP::MAP>& kmin,
	VertexAttribute<typename PFP::VEC3, typename PFP::MAP>& Kmax,
	VertexAttribute<typename PFP::VEC3, typename PFP::MAP>& Kmin,
Sylvain Thery's avatar
Sylvain Thery committed
170
	VertexAttribute<typename PFP::VEC3, typename PFP::MAP>& Knormal) ;
Sauvage's avatar
Sauvage committed
171 172 173 174

template <typename PFP>
void computeCurvatureVertex_NormalCycles_Projected(
	typename PFP::MAP& map,
Pierre Kraemer's avatar
Pierre Kraemer committed
175
	Vertex v,
Sauvage's avatar
Sauvage committed
176
	typename PFP::REAL radius,
177 178 179
	const VertexAttribute<typename PFP::VEC3, typename PFP::MAP>& position,
	const VertexAttribute<typename PFP::VEC3, typename PFP::MAP>& normal,
	const EdgeAttribute<typename PFP::REAL, typename PFP::MAP>& edgeangle,
180
	const EdgeAttribute<typename PFP::REAL, typename PFP::MAP>& edgearea,
181 182 183 184
	VertexAttribute<typename PFP::REAL, typename PFP::MAP>& kmax,
	VertexAttribute<typename PFP::REAL, typename PFP::MAP>& kmin,
	VertexAttribute<typename PFP::VEC3, typename PFP::MAP>& Kmax,
	VertexAttribute<typename PFP::VEC3, typename PFP::MAP>& Kmin,
Sylvain Thery's avatar
Sylvain Thery committed
185
	VertexAttribute<typename PFP::VEC3, typename PFP::MAP>& Knormal) ;
Sauvage's avatar
Sauvage committed
186

187 188 189 190 191
/* normal cycles with collector as a parameter : not usable in parallel */

template <typename PFP>
void computeCurvatureVertices_NormalCycles(
	typename PFP::MAP& map,
192
	Algo::Surface::Selection::Collector<PFP> & neigh,
193 194 195
	const VertexAttribute<typename PFP::VEC3, typename PFP::MAP>& position,
	const VertexAttribute<typename PFP::VEC3, typename PFP::MAP>& normal,
	const EdgeAttribute<typename PFP::REAL, typename PFP::MAP>& edgeangle,
196
	const EdgeAttribute<typename PFP::REAL, typename PFP::MAP>& edgearea,
197 198 199 200
	VertexAttribute<typename PFP::REAL, typename PFP::MAP>& kmax,
	VertexAttribute<typename PFP::REAL, typename PFP::MAP>& kmin,
	VertexAttribute<typename PFP::VEC3, typename PFP::MAP>& Kmax,
	VertexAttribute<typename PFP::VEC3, typename PFP::MAP>& Kmin,
Sylvain Thery's avatar
Sylvain Thery committed
201
	VertexAttribute<typename PFP::VEC3, typename PFP::MAP>& Knormal) ;
202 203 204

template <typename PFP>
void computeCurvatureVertex_NormalCycles(
Pierre Kraemer's avatar
Pierre Kraemer committed
205
	Vertex v,
206
	Algo::Surface::Selection::Collector<PFP> & neigh,
207 208 209
	const VertexAttribute<typename PFP::VEC3, typename PFP::MAP>& position,
	const VertexAttribute<typename PFP::VEC3, typename PFP::MAP>& normal,
	const EdgeAttribute<typename PFP::REAL, typename PFP::MAP>& edgeangle,
210
	const EdgeAttribute<typename PFP::REAL, typename PFP::MAP>& edgearea,
211 212 213 214
	VertexAttribute<typename PFP::REAL, typename PFP::MAP>& kmax,
	VertexAttribute<typename PFP::REAL, typename PFP::MAP>& kmin,
	VertexAttribute<typename PFP::VEC3, typename PFP::MAP>& Kmax,
	VertexAttribute<typename PFP::VEC3, typename PFP::MAP>& Kmin,
Sylvain Thery's avatar
Sylvain Thery committed
215
	VertexAttribute<typename PFP::VEC3, typename PFP::MAP>& Knormal) ;
216

Sauvage's avatar
Sauvage committed
217 218 219
template <typename PFP>
void computeCurvatureVertices_NormalCycles_Projected(
	typename PFP::MAP& map,
220
	Algo::Surface::Selection::Collector<PFP> & neigh,
221 222 223
	const VertexAttribute<typename PFP::VEC3, typename PFP::MAP>& position,
	const VertexAttribute<typename PFP::VEC3, typename PFP::MAP>& normal,
	const EdgeAttribute<typename PFP::REAL, typename PFP::MAP>& edgeangle,
224
	const EdgeAttribute<typename PFP::REAL, typename PFP::MAP>& edgearea,
225 226 227 228
	VertexAttribute<typename PFP::REAL, typename PFP::MAP>& kmax,
	VertexAttribute<typename PFP::REAL, typename PFP::MAP>& kmin,
	VertexAttribute<typename PFP::VEC3, typename PFP::MAP>& Kmax,
	VertexAttribute<typename PFP::VEC3, typename PFP::MAP>& Kmin,
Sylvain Thery's avatar
Sylvain Thery committed
229
	VertexAttribute<typename PFP::VEC3, typename PFP::MAP>& Knormal) ;
Sauvage's avatar
Sauvage committed
230 231 232

template <typename PFP>
void computeCurvatureVertex_NormalCycles_Projected(
Pierre Kraemer's avatar
Pierre Kraemer committed
233
	Vertex v,
234
	Algo::Surface::Selection::Collector<PFP> & neigh,
235 236 237
	const VertexAttribute<typename PFP::VEC3, typename PFP::MAP>& position,
	const VertexAttribute<typename PFP::VEC3, typename PFP::MAP>& normal,
	const EdgeAttribute<typename PFP::REAL, typename PFP::MAP>& edgeangle,
238
	const EdgeAttribute<typename PFP::REAL, typename PFP::MAP>& edgearea,
239 240 241 242
	VertexAttribute<typename PFP::REAL, typename PFP::MAP>& kmax,
	VertexAttribute<typename PFP::REAL, typename PFP::MAP>& kmin,
	VertexAttribute<typename PFP::VEC3, typename PFP::MAP>& Kmax,
	VertexAttribute<typename PFP::VEC3, typename PFP::MAP>& Kmin,
Sylvain Thery's avatar
Sylvain Thery committed
243
	VertexAttribute<typename PFP::VEC3, typename PFP::MAP>& Knormal) ;
Sylvain Thery's avatar
Sylvain Thery committed
244

Pierre Kraemer's avatar
Pierre Kraemer committed
245

246 247
namespace Parallel
{
Pierre Kraemer's avatar
Pierre Kraemer committed
248

249 250 251 252
template <typename PFP>
void computeCurvatureVertices_NormalCycles(
	typename PFP::MAP& map,
	typename PFP::REAL radius,
253 254 255
	const VertexAttribute<typename PFP::VEC3, typename PFP::MAP>& position,
	const VertexAttribute<typename PFP::VEC3, typename PFP::MAP>& normal,
	const EdgeAttribute<typename PFP::REAL, typename PFP::MAP>& edgeangle,
256
	const EdgeAttribute<typename PFP::REAL, typename PFP::MAP>& edgearea,
257 258 259 260 261
	VertexAttribute<typename PFP::REAL, typename PFP::MAP>& kmax,
	VertexAttribute<typename PFP::REAL, typename PFP::MAP>& kmin,
	VertexAttribute<typename PFP::VEC3, typename PFP::MAP>& Kmax,
	VertexAttribute<typename PFP::VEC3, typename PFP::MAP>& Kmin,
	VertexAttribute<typename PFP::VEC3, typename PFP::MAP>& Knormal) ;
262

Sylvain Thery's avatar
Sylvain Thery committed
263
template <typename PFP>
Sylvain Thery's avatar
Sylvain Thery committed
264
void computeCurvatureVertices_NormalCycles_Projected(
Sylvain Thery's avatar
Sylvain Thery committed
265
	typename PFP::MAP& map,
Sylvain Thery's avatar
Sylvain Thery committed
266
	typename PFP::REAL radius,
267 268 269
	const VertexAttribute<typename PFP::VEC3, typename PFP::MAP>& position,
	const VertexAttribute<typename PFP::VEC3, typename PFP::MAP>& normal,
	const EdgeAttribute<typename PFP::REAL, typename PFP::MAP>& edgeangle,
270
	const EdgeAttribute<typename PFP::REAL, typename PFP::MAP>& edgearea,
271 272 273 274 275
	VertexAttribute<typename PFP::REAL, typename PFP::MAP>& kmax,
	VertexAttribute<typename PFP::REAL, typename PFP::MAP>& kmin,
	VertexAttribute<typename PFP::VEC3, typename PFP::MAP>& Kmax,
	VertexAttribute<typename PFP::VEC3, typename PFP::MAP>& Kmin,
	VertexAttribute<typename PFP::VEC3, typename PFP::MAP>& Knormal) ;
Sylvain Thery's avatar
Sylvain Thery committed
276 277 278 279

template <typename PFP>
void computeCurvatureVertices_QuadraticFitting(
	typename PFP::MAP& map,
280 281 282 283 284 285
	const VertexAttribute<typename PFP::VEC3, typename PFP::MAP>& position,
	const VertexAttribute<typename PFP::VEC3, typename PFP::MAP>& normal,
	VertexAttribute<typename PFP::REAL, typename PFP::MAP>& kmax,
	VertexAttribute<typename PFP::REAL, typename PFP::MAP>& kmin,
	VertexAttribute<typename PFP::VEC3, typename PFP::MAP>& Kmax,
	VertexAttribute<typename PFP::VEC3, typename PFP::MAP>& Kmin);
Sylvain Thery's avatar
Sylvain Thery committed
286 287 288

} // namespace Parallel

289

Sylvain Thery's avatar
Sylvain Thery committed
290
} // namespace Geometry
291

Pierre Kraemer's avatar
Pierre Kraemer committed
292
} // namespace Surface
293

Pierre Kraemer's avatar
Pierre Kraemer committed
294 295 296 297 298 299 300
} // namespace Algo

} // namespace CGoGN

#include "Algo/Geometry/curvature.hpp"

#endif