curvature.h 10.6 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"

Pierre Kraemer's avatar
Pierre Kraemer committed
34 35 36 37
#include "OpenNL/linear_solver.h"
#include "OpenNL/sparse_matrix.h"
#include "OpenNL/full_vector.h"

38 39 40
#include <Eigen/Core>
#include <Eigen/Eigenvalues>

Pierre Kraemer's avatar
Pierre Kraemer committed
41 42 43 44 45 46
namespace CGoGN
{

namespace Algo
{

47 48 49
namespace Surface
{

Pierre Kraemer's avatar
Pierre Kraemer committed
50 51 52 53 54 55
namespace Geometry
{

typedef CPULinearSolverTraits< SparseMatrix<double>, FullVector<double> > CPUSolverTraits ;

template <typename PFP>
Pierre Kraemer's avatar
Pierre Kraemer committed
56
void computeCurvatureVertices_QuadraticFitting(
Pierre Kraemer's avatar
Pierre Kraemer committed
57
	typename PFP::MAP& map,
58 59 60 61 62 63
	const VertexAttribute<typename PFP::VEC3>& position,
	const VertexAttribute<typename PFP::VEC3>& normal,
	VertexAttribute<typename PFP::REAL>& kmax,
	VertexAttribute<typename PFP::REAL>& kmin,
	VertexAttribute<typename PFP::VEC3>& Kmax,
	VertexAttribute<typename PFP::VEC3>& Kmin,
Pierre Kraemer's avatar
Pierre Kraemer committed
64
	const FunctorSelect& select = allDarts) ;
Pierre Kraemer's avatar
Pierre Kraemer committed
65 66

template <typename PFP>
Pierre Kraemer's avatar
Pierre Kraemer committed
67
void computeCurvatureVertex_QuadraticFitting(
Pierre Kraemer's avatar
Pierre Kraemer committed
68 69
	typename PFP::MAP& map,
	Dart dart,
70 71 72 73 74 75
	const VertexAttribute<typename PFP::VEC3>& position,
	const VertexAttribute<typename PFP::VEC3>& normal,
	VertexAttribute<typename PFP::REAL>& kmax,
	VertexAttribute<typename PFP::REAL>& kmin,
	VertexAttribute<typename PFP::VEC3>& Kmax,
	VertexAttribute<typename PFP::VEC3>& Kmin) ;
Pierre Kraemer's avatar
Pierre Kraemer committed
76 77

template <typename PFP>
Pierre Kraemer's avatar
Pierre Kraemer committed
78
void vertexQuadraticFitting(
Pierre Kraemer's avatar
Pierre Kraemer committed
79 80 81
	typename PFP::MAP& map,
	Dart dart,
	typename PFP::MATRIX33& localFrame,
82 83
	const VertexAttribute<typename PFP::VEC3>& position,
	const VertexAttribute<typename PFP::VEC3>& normal,
Pierre Kraemer's avatar
Pierre Kraemer committed
84 85 86
	float& a, float& b, float& c, float& d, float& e) ;

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

template <typename PFP>
Pierre Kraemer's avatar
Pierre Kraemer committed
90
void quadraticFittingAddVertexNormal(typename PFP::VEC3& v, typename PFP::VEC3& n, typename PFP::VEC3& p, typename PFP::MATRIX33& localFrame, LinearSolver<CPUSolverTraits>& solver) ;
Pierre Kraemer's avatar
Pierre Kraemer committed
91 92 93 94 95 96 97 98 99 100 101
/*
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) ;
*/

102
/* normal cycles by [ACDLD03] : useful for parallel computing*/
Pierre Kraemer's avatar
Pierre Kraemer committed
103 104 105 106
template <typename PFP>
void computeCurvatureVertices_NormalCycles(
	typename PFP::MAP& map,
	typename PFP::REAL radius,
107 108 109 110 111 112 113 114
	const VertexAttribute<typename PFP::VEC3>& position,
	const VertexAttribute<typename PFP::VEC3>& normal,
	const EdgeAttribute<typename PFP::REAL>& edgeangle,
	VertexAttribute<typename PFP::REAL>& kmax,
	VertexAttribute<typename PFP::REAL>& kmin,
	VertexAttribute<typename PFP::VEC3>& Kmax,
	VertexAttribute<typename PFP::VEC3>& Kmin,
	VertexAttribute<typename PFP::VEC3>& Knormal,
115
	const FunctorSelect& select = allDarts, unsigned int thread=0) ;
Pierre Kraemer's avatar
Pierre Kraemer committed
116 117 118 119 120

template <typename PFP>
void computeCurvatureVertex_NormalCycles(
	typename PFP::MAP& map,
	Dart dart,
121
	typename PFP::REAL radius,
122 123 124 125 126 127 128
	const VertexAttribute<typename PFP::VEC3>& position,
	const VertexAttribute<typename PFP::VEC3>& normal,
	const EdgeAttribute<typename PFP::REAL>& edgeangle,
	VertexAttribute<typename PFP::REAL>& kmax,
	VertexAttribute<typename PFP::REAL>& kmin,
	VertexAttribute<typename PFP::VEC3>& Kmax,
	VertexAttribute<typename PFP::VEC3>& Kmin,
129
	VertexAttribute<typename PFP::VEC3>& Knormal, unsigned int thread=0) ;
Pierre Kraemer's avatar
Pierre Kraemer committed
130

131 132 133 134 135 136 137 138 139 140 141
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,
	const typename PFP::VEC3& normal,
	unsigned int thread=0) ;
Pierre Kraemer's avatar
Pierre Kraemer committed
142

Sauvage's avatar
Sauvage committed
143 144
template <typename PFP>
void normalCycles_SortTensor( Geom::Matrix<3,3,typename PFP::REAL> & tensor, unsigned int thread=0) ;
145

Sauvage's avatar
Sauvage committed
146 147 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 174 175 176 177 178
template <typename PFP>
void normalCycles_ProjectTensor( Geom::Matrix<3,3,typename PFP::REAL> & tensor, const typename PFP::VEC3& normal_vector, unsigned int thread=0) ;

template <typename PFP>
void computeCurvatureVertices_NormalCycles_Projected(
	typename PFP::MAP& map,
	typename PFP::REAL radius,
	const VertexAttribute<typename PFP::VEC3>& position,
	const VertexAttribute<typename PFP::VEC3>& normal,
	const EdgeAttribute<typename PFP::REAL>& edgeangle,
	VertexAttribute<typename PFP::REAL>& kmax,
	VertexAttribute<typename PFP::REAL>& kmin,
	VertexAttribute<typename PFP::VEC3>& Kmax,
	VertexAttribute<typename PFP::VEC3>& Kmin,
	VertexAttribute<typename PFP::VEC3>& Knormal,
	const FunctorSelect& select = allDarts, unsigned int thread=0) ;

template <typename PFP>
void computeCurvatureVertex_NormalCycles_Projected(
	typename PFP::MAP& map,
	Dart dart,
	typename PFP::REAL radius,
	const VertexAttribute<typename PFP::VEC3>& position,
	const VertexAttribute<typename PFP::VEC3>& normal,
	const EdgeAttribute<typename PFP::REAL>& edgeangle,
	VertexAttribute<typename PFP::REAL>& kmax,
	VertexAttribute<typename PFP::REAL>& kmin,
	VertexAttribute<typename PFP::VEC3>& Kmax,
	VertexAttribute<typename PFP::VEC3>& Kmin,
	VertexAttribute<typename PFP::VEC3>& Knormal, unsigned int thread=0) ;



179 180 181 182 183
/* normal cycles with collector as a parameter : not usable in parallel */

template <typename PFP>
void computeCurvatureVertices_NormalCycles(
	typename PFP::MAP& map,
184
	Algo::Surface::Selection::Collector<PFP> & neigh,
185 186 187 188 189 190 191 192 193 194 195 196 197 198
	const VertexAttribute<typename PFP::VEC3>& position,
	const VertexAttribute<typename PFP::VEC3>& normal,
	const EdgeAttribute<typename PFP::REAL>& edgeangle,
	VertexAttribute<typename PFP::REAL>& kmax,
	VertexAttribute<typename PFP::REAL>& kmin,
	VertexAttribute<typename PFP::VEC3>& Kmax,
	VertexAttribute<typename PFP::VEC3>& Kmin,
	VertexAttribute<typename PFP::VEC3>& Knormal,
	const FunctorSelect& select = allDarts, unsigned int thread=0) ;

template <typename PFP>
void computeCurvatureVertex_NormalCycles(
	typename PFP::MAP& map,
	Dart dart,
199
	Algo::Surface::Selection::Collector<PFP> & neigh,
200 201 202 203 204 205 206 207 208
	const VertexAttribute<typename PFP::VEC3>& position,
	const VertexAttribute<typename PFP::VEC3>& normal,
	const EdgeAttribute<typename PFP::REAL>& edgeangle,
	VertexAttribute<typename PFP::REAL>& kmax,
	VertexAttribute<typename PFP::REAL>& kmin,
	VertexAttribute<typename PFP::VEC3>& Kmax,
	VertexAttribute<typename PFP::VEC3>& Kmin,
	VertexAttribute<typename PFP::VEC3>& Knormal, unsigned int thread=0) ;

Sauvage's avatar
Sauvage committed
209 210 211
template <typename PFP>
void computeCurvatureVertices_NormalCycles_Projected(
	typename PFP::MAP& map,
212
	Algo::Surface::Selection::Collector<PFP> & neigh,
Sauvage's avatar
Sauvage committed
213 214 215 216 217 218 219 220 221 222 223 224 225 226
	const VertexAttribute<typename PFP::VEC3>& position,
	const VertexAttribute<typename PFP::VEC3>& normal,
	const EdgeAttribute<typename PFP::REAL>& edgeangle,
	VertexAttribute<typename PFP::REAL>& kmax,
	VertexAttribute<typename PFP::REAL>& kmin,
	VertexAttribute<typename PFP::VEC3>& Kmax,
	VertexAttribute<typename PFP::VEC3>& Kmin,
	VertexAttribute<typename PFP::VEC3>& Knormal,
	const FunctorSelect& select = allDarts, unsigned int thread=0) ;

template <typename PFP>
void computeCurvatureVertex_NormalCycles_Projected(
	typename PFP::MAP& map,
	Dart dart,
227
	Algo::Surface::Selection::Collector<PFP> & neigh,
Sauvage's avatar
Sauvage committed
228 229 230 231 232 233 234 235
	const VertexAttribute<typename PFP::VEC3>& position,
	const VertexAttribute<typename PFP::VEC3>& normal,
	const EdgeAttribute<typename PFP::REAL>& edgeangle,
	VertexAttribute<typename PFP::REAL>& kmax,
	VertexAttribute<typename PFP::REAL>& kmin,
	VertexAttribute<typename PFP::VEC3>& Kmax,
	VertexAttribute<typename PFP::VEC3>& Kmin,
	VertexAttribute<typename PFP::VEC3>& Knormal, unsigned int thread=0) ;
Sylvain Thery's avatar
Sylvain Thery committed
236

Pierre Kraemer's avatar
Pierre Kraemer committed
237

238 239 240 241 242 243 244 245 246 247 248 249 250 251
namespace Parallel
{
template <typename PFP>
void computeCurvatureVertices_NormalCycles(
	typename PFP::MAP& map,
	typename PFP::REAL radius,
	const VertexAttribute<typename PFP::VEC3>& position,
	const VertexAttribute<typename PFP::VEC3>& normal,
	const EdgeAttribute<typename PFP::REAL>& edgeangle,
	VertexAttribute<typename PFP::REAL>& kmax,
	VertexAttribute<typename PFP::REAL>& kmin,
	VertexAttribute<typename PFP::VEC3>& Kmax,
	VertexAttribute<typename PFP::VEC3>& Kmin,
	VertexAttribute<typename PFP::VEC3>& Knormal,
252
	const FunctorSelect& select = allDarts, unsigned int nbth = 0) ;
253

Sylvain Thery's avatar
Sylvain Thery committed
254 255 256 257 258 259 260 261 262
template <typename PFP>
void computeCurvatureVertices_QuadraticFitting(
	typename PFP::MAP& map,
	const VertexAttribute<typename PFP::VEC3>& position,
	const VertexAttribute<typename PFP::VEC3>& normal,
	VertexAttribute<typename PFP::REAL>& kmax,
	VertexAttribute<typename PFP::REAL>& kmin,
	VertexAttribute<typename PFP::VEC3>& Kmax,
	VertexAttribute<typename PFP::VEC3>& Kmin,
263
	const FunctorSelect& select = allDarts, unsigned int nbth=0);
Sylvain Thery's avatar
Sylvain Thery committed
264 265 266

} // namespace Parallel

267

Sylvain Thery's avatar
Sylvain Thery committed
268
} // namespace Geometry
269

270 271
}

Pierre Kraemer's avatar
Pierre Kraemer committed
272 273 274 275 276 277 278
} // namespace Algo

} // namespace CGoGN

#include "Algo/Geometry/curvature.hpp"

#endif