curvature.h 12.3 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 116 117 118 119
	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,
	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
120
	VertexAttribute<typename PFP::VEC3, typename PFP::MAP>& Knormal) ;
Pierre Kraemer's avatar
Pierre Kraemer committed
121 122 123 124

template <typename PFP>
void computeCurvatureVertex_NormalCycles(
	typename PFP::MAP& map,
Pierre Kraemer's avatar
Pierre Kraemer committed
125
	Vertex v,
126
	typename PFP::REAL radius,
127 128 129 130 131 132 133
	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,
	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
134
	VertexAttribute<typename PFP::VEC3, typename PFP::MAP>& Knormal) ;
Pierre Kraemer's avatar
Pierre Kraemer committed
135

136 137 138 139 140 141 142 143 144
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
145
	const typename PFP::VEC3& normal) ;
Pierre Kraemer's avatar
Pierre Kraemer committed
146

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

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

template <typename PFP>
void computeCurvatureVertices_NormalCycles_Projected(
	typename PFP::MAP& map,
	typename PFP::REAL radius,
160 161 162 163 164 165 166
	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,
	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
167
	VertexAttribute<typename PFP::VEC3, typename PFP::MAP>& Knormal) ;
Sauvage's avatar
Sauvage committed
168 169 170 171

template <typename PFP>
void computeCurvatureVertex_NormalCycles_Projected(
	typename PFP::MAP& map,
Pierre Kraemer's avatar
Pierre Kraemer committed
172
	Vertex v,
Sauvage's avatar
Sauvage committed
173
	typename PFP::REAL radius,
174 175 176 177 178 179 180
	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,
	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
181
	VertexAttribute<typename PFP::VEC3, typename PFP::MAP>& Knormal) ;
Sauvage's avatar
Sauvage committed
182

183 184 185 186 187
/* normal cycles with collector as a parameter : not usable in parallel */

template <typename PFP>
void computeCurvatureVertices_NormalCycles(
	typename PFP::MAP& map,
188
	Algo::Surface::Selection::Collector<PFP> & neigh,
189 190 191 192 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,
	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
196
	VertexAttribute<typename PFP::VEC3, typename PFP::MAP>& Knormal) ;
197 198 199

template <typename PFP>
void computeCurvatureVertex_NormalCycles(
Pierre Kraemer's avatar
Pierre Kraemer committed
200
	Vertex v,
201
	Algo::Surface::Selection::Collector<PFP> & neigh,
202 203 204 205 206 207 208
	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,
	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
209
	VertexAttribute<typename PFP::VEC3, typename PFP::MAP>& Knormal) ;
210

Sauvage's avatar
Sauvage committed
211 212 213
template <typename PFP>
void computeCurvatureVertices_NormalCycles_Projected(
	typename PFP::MAP& map,
214
	Algo::Surface::Selection::Collector<PFP> & neigh,
215 216 217 218 219 220 221
	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,
	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
222
	VertexAttribute<typename PFP::VEC3, typename PFP::MAP>& Knormal) ;
Sauvage's avatar
Sauvage committed
223 224 225

template <typename PFP>
void computeCurvatureVertex_NormalCycles_Projected(
Pierre Kraemer's avatar
Pierre Kraemer committed
226
	Vertex v,
227
	Algo::Surface::Selection::Collector<PFP> & neigh,
228 229 230 231 232 233 234
	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,
	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
235
	VertexAttribute<typename PFP::VEC3, typename PFP::MAP>& Knormal) ;
Sylvain Thery's avatar
Sylvain Thery committed
236

Pierre Kraemer's avatar
Pierre Kraemer committed
237

238 239
namespace Parallel
{
Pierre Kraemer's avatar
Pierre Kraemer committed
240

241 242 243 244
template <typename PFP>
void computeCurvatureVertices_NormalCycles(
	typename PFP::MAP& map,
	typename PFP::REAL radius,
245 246 247 248 249 250 251 252
	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,
	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) ;
253

Sylvain Thery's avatar
Sylvain Thery committed
254
template <typename PFP>
Sylvain Thery's avatar
Sylvain Thery committed
255
void computeCurvatureVertices_NormalCycles_Projected(
Sylvain Thery's avatar
Sylvain Thery committed
256
	typename PFP::MAP& map,
Sylvain Thery's avatar
Sylvain Thery committed
257
	typename PFP::REAL radius,
258 259 260 261 262 263 264 265
	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,
	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
266 267 268 269

template <typename PFP>
void computeCurvatureVertices_QuadraticFitting(
	typename PFP::MAP& map,
270 271 272 273 274 275
	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
276 277 278

} // namespace Parallel

279

Sylvain Thery's avatar
Sylvain Thery committed
280
} // namespace Geometry
281

Pierre Kraemer's avatar
Pierre Kraemer committed
282
} // namespace Surface
283

Pierre Kraemer's avatar
Pierre Kraemer committed
284 285 286 287 288 289 290
} // namespace Algo

} // namespace CGoGN

#include "Algo/Geometry/curvature.hpp"

#endif