centroid.h 8.11 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 30 31 32 33 34 35
* Contact information: cgogn@unistra.fr                                        *
*                                                                              *
*******************************************************************************/

#ifndef __ALGO_GEOMETRY_CENTROID_H__
#define __ALGO_GEOMETRY_CENTROID_H__

#include "Geometry/basic.h"

namespace CGoGN
{

namespace Algo
{

36 37 38
namespace Surface
{

Pierre Kraemer's avatar
Pierre Kraemer committed
39 40 41 42 43 44 45 46
namespace Geometry
{

/**
* Compute volume centroid (generic version)
*  Pre: closed volume & embedded vertices
* Template param:
*  PFP:  as usual
47
*  V_ATT: attributes vector type  or cell type (VertexCell, FaceCell, ...)
Pierre Kraemer's avatar
Pierre Kraemer committed
48 49 50 51
* @param map the map
* @param d a dart of the face
* @param attributs the vector of attribute or cell
*/
52
template <typename PFP, typename V_ATT>
Sylvain Thery's avatar
Sylvain Thery committed
53
typename V_ATT::DATA_TYPE volumeCentroid(typename PFP::MAP& map, Vol d, const V_ATT& attributs);
54

55 56 57 58 59
/**
* Compute volume centroid weighted by edge length (generic version)
*  Pre: closed volume & embedded vertices
* Template param:
*  PFP:  as usual
60
*  V_ATT: attributes vector type  or cell type (VertexCell, FaceCell, ...)
61 62 63 64
* @param map the map
* @param d a dart of the face
* @param attributs the vector of attribute or cell
*/
65
template <typename PFP, typename V_ATT>
Sylvain Thery's avatar
Sylvain Thery committed
66
typename V_ATT::DATA_TYPE volumeCentroidELW(typename PFP::MAP& map, Vol d, const V_ATT& attributs);
67

Pierre Kraemer's avatar
Pierre Kraemer committed
68 69 70 71
/**
 * Compute face centroid (generic version)
 * Template param:
 *  PFP:  as usual
72
 *  V_ATT: attributes vector type  or cell type (VertexCell, FaceCell, ...)
Pierre Kraemer's avatar
Pierre Kraemer committed
73 74 75 76
 * @param map the map
 * @param d a dart of the face
 * @param attributs the vector of attribute or cell
 */
77
template <typename PFP, typename V_ATT>
78
typename V_ATT::DATA_TYPE faceCentroid(typename PFP::MAP& map, Face d, const V_ATT& attributs);
79

80 81 82 83
/**
 * Compute face centroid weighted by edge length (generic version)
 * Template param:
 *  PFP:  as usual
84
 *  V_ATT: attributes vector type  or cell type (VertexCell, FaceCell, ...)
85 86 87 88
 * @param map the map
 * @param d a dart of the face
 * @param attributs the vector of attribute or cell
 */
89
template <typename PFP, typename V_ATT>
90
typename V_ATT::DATA_TYPE faceCentroidELW(typename PFP::MAP& map, Face d, const V_ATT& attributs);
91

Pierre Kraemer's avatar
Pierre Kraemer committed
92 93 94 95
/**
 * Compute vertex neighbours centroid (generic version)
 * Template param:
 *  PFP:  as usual
96
 *  V_ATT: attributes vector type  or cell type (VertexCell, FaceCell, ...)
Pierre Kraemer's avatar
Pierre Kraemer committed
97 98 99 100
 * @param map the map
 * @param d a dart of the face
 * @param position the vector of attribute or cell
 */
101
template <typename PFP, typename V_ATT>
102
typename V_ATT::DATA_TYPE vertexNeighborhoodCentroid(typename PFP::MAP& map, Vertex d, const V_ATT& attributs);
Pierre Kraemer's avatar
Pierre Kraemer committed
103

104 105 106 107 108 109
/**
 * Compute centroid of all faces
 * @param map the map
 * @param position position vertex attribute
 * @param face_centroid centroid face attribute
 */
110
template <typename PFP, typename V_ATT, typename F_ATT>
Sylvain Thery's avatar
Sylvain Thery committed
111
void computeCentroidFaces(typename PFP::MAP& map, const V_ATT& position, F_ATT& face_centroid);
Pierre Kraemer's avatar
Pierre Kraemer committed
112

113 114 115 116 117 118
/**
 * Compute centroid of all faces (Edge Length Weighted)
 * @param map the map
 * @param position position vertex attribute
 * @param face_centroid centroid face attribute
 */
119
template <typename PFP, typename V_ATT, typename F_ATT>
Sylvain Thery's avatar
Sylvain Thery committed
120
void computeCentroidELWFaces(typename PFP::MAP& map, const V_ATT& position, F_ATT& face_centroid) ;
121

122 123 124 125 126 127
/**
 * Compute neighborhood centroid of all vertices
 * @param map the map
 * @param position position vertex attribute
 * @param vertex_centroid centroid vertex attribute
 */
128
template <typename PFP, typename V_ATT>
Sylvain Thery's avatar
Sylvain Thery committed
129
void computeNeighborhoodCentroidVertices(typename PFP::MAP& map, const V_ATT& position, V_ATT& vertex_centroid) ;
130

131 132 133

namespace Parallel
{
Pierre Kraemer's avatar
Pierre Kraemer committed
134

135 136 137 138 139 140
/**
 * Compute centroid of all faces
 * @param map the map
 * @param position position vertex attribute
 * @param face_centroid centroid face attribute
 */
141
template <typename PFP, typename V_ATT, typename F_ATT>
142
void computeCentroidFaces(typename PFP::MAP& map,
143
		const V_ATT& position, F_ATT& face_centroid) ;
144

145 146 147 148 149 150
/**
 * Compute centroid of all faces (Edge Length Weighted)
 * @param map the map
 * @param position position vertex attribute
 * @param face_centroid centroid face attribute
 */
151
template <typename PFP, typename V_ATT, typename F_ATT>
152
void computeCentroidELWFaces(typename PFP::MAP& map,
153
		const V_ATT& position, F_ATT& face_centroid) ;
154 155 156 157 158 159 160

/**
 * Compute neighborhood centroid of all vertices (in parallel)
 * @param map the map
 * @param position position vertex attribute
 * @param vertex_centroid centroid vertex attribute
 */
161
template <typename PFP, typename V_ATT>
162
void computeNeighborhoodCentroidVertices(typename PFP::MAP& map,
163
		const V_ATT& position, V_ATT& vertex_centroid) ;
Pierre Kraemer's avatar
Pierre Kraemer committed
164 165 166 167 168

} // namespace Parallel



169
} // namespace Geometry
Pierre Kraemer's avatar
Pierre Kraemer committed
170 171

} // namespace Surface
Pierre Kraemer's avatar
Pierre Kraemer committed
172

173
namespace Volume
174
{
Pierre Kraemer's avatar
Pierre Kraemer committed
175

176 177
namespace Geometry
{
Pierre Kraemer's avatar
Pierre Kraemer committed
178

179 180 181 182
/**
 * Compute vertex neighbours centroid in map of dimension 3(generic version)
 * Template param:
 *  PFP:  as usual
183
 *  V_ATT: attributes vector type  or cell type (VertexCell, FaceCell, ...)
184 185 186 187
 * @param map the map
 * @param d a dart of the face
 * @param position the vector of attribute or cell
 */
188
template <typename PFP, typename V_ATT>
Sylvain Thery's avatar
Sylvain Thery committed
189
typename V_ATT::DATA_TYPE vertexNeighborhoodCentroid(typename PFP::MAP& map, Vertex d, const V_ATT& attributs);
190

191 192 193 194 195 196
/**
 * compute centroid of all volumes
 * @param map the map
 * @param position vertex attribute of position
 * @param vol_centroid volume attribute where to store the centroids
 */
197
template <typename PFP, typename V_ATT, typename W_ATT>
Sylvain Thery's avatar
Sylvain Thery committed
198
void computeCentroidVolumes(typename PFP::MAP& map, const V_ATT& position, W_ATT& vol_centroid);
199 200

template <typename PFP, typename V_ATT, typename W_ATT>
Sylvain Thery's avatar
Sylvain Thery committed
201
void computeCentroidELWVolumes(typename PFP::MAP& map, const V_ATT& position, W_ATT& vol_centroid);
Pierre Kraemer's avatar
Pierre Kraemer committed
202

203 204 205 206 207 208
/**
 * compute centroid of all vertices
 * @param map the map
 * @param position vertex attribute of position
 * @param vertex_centroid vertex attribute to store the centroids
 */
209
template <typename PFP, typename V_ATT>
Sylvain Thery's avatar
Sylvain Thery committed
210
void computeNeighborhoodCentroidVertices(typename PFP::MAP& map, const V_ATT& position, V_ATT& vertex_centroid) ;
211 212


213 214
namespace Parallel
{
Pierre Kraemer's avatar
Pierre Kraemer committed
215

216
template <typename PFP, typename V_ATT, typename W_ATT>
217
void computeCentroidVolumes(typename PFP::MAP& map,
218
		const V_ATT& position, W_ATT& vol_centroid) ;
219

220

221 222
template <typename PFP, typename V_ATT, typename W_ATT>
void computeCentroidELWVolumes(typename PFP::MAP& map,
223
		const V_ATT& position, W_ATT& vol_centroid) ;
224

225
		
226
template <typename PFP, typename V_ATT>
227
void computeNeighborhoodCentroidVertices(typename PFP::MAP& map,
228
		const V_ATT& position, V_ATT& vertex_centroid) ;
Pierre Kraemer's avatar
Pierre Kraemer committed
229 230 231 232

} // namespace Parallel


Pierre Kraemer's avatar
Pierre Kraemer committed
233
} // namespace Geometry
Pierre Kraemer's avatar
Pierre Kraemer committed
234

untereiner's avatar
untereiner committed
235
} // namespace Volume
Pierre Kraemer's avatar
Pierre Kraemer committed
236 237 238 239 240 241 242 243

} // namespace Algo

} // namespace CGoGN

#include "Algo/Geometry/centroid.hpp"

#endif