Commit 4fa17a33 authored by Sylvain Thery's avatar Sylvain Thery

testing usage of foreach macros

parent b1c8dad3
...@@ -25,6 +25,8 @@ ...@@ -25,6 +25,8 @@
#ifndef __ALGO_GEOMETRY_AREA_H__ #ifndef __ALGO_GEOMETRY_AREA_H__
#define __ALGO_GEOMETRY_AREA_H__ #define __ALGO_GEOMETRY_AREA_H__
#include "Topology/generic/cells.h"
namespace CGoGN namespace CGoGN
{ {
...@@ -43,7 +45,7 @@ namespace Geometry ...@@ -43,7 +45,7 @@ namespace Geometry
//! @param position //! @param position
//! @return //! @return
template <typename PFP> template <typename PFP>
typename PFP::REAL triangleArea(typename PFP::MAP& map, Dart d, const VertexAttribute<typename PFP::VEC3, typename PFP::MAP::IMPL>& position) ; typename PFP::REAL triangleArea(typename PFP::MAP& map, Face f, const VertexAttribute<typename PFP::VEC3, typename PFP::MAP::IMPL>& position) ;
//! \brief Compute convex polygonal face area //! \brief Compute convex polygonal face area
//! @param map //! @param map
...@@ -51,7 +53,7 @@ typename PFP::REAL triangleArea(typename PFP::MAP& map, Dart d, const VertexAttr ...@@ -51,7 +53,7 @@ typename PFP::REAL triangleArea(typename PFP::MAP& map, Dart d, const VertexAttr
//! @param position //! @param position
//! @return //! @return
template <typename PFP> template <typename PFP>
typename PFP::REAL convexFaceArea(typename PFP::MAP& map, Dart d, const VertexAttribute<typename PFP::VEC3, typename PFP::MAP::IMPL>& position) ; typename PFP::REAL convexFaceArea(typename PFP::MAP& map, Face f, const VertexAttribute<typename PFP::VEC3, typename PFP::MAP::IMPL>& position) ;
//! \brief Compute the total area of a mesh by summing all face areas. //! \brief Compute the total area of a mesh by summing all face areas.
//! @param map //! @param map
...@@ -66,25 +68,25 @@ typename PFP::REAL totalArea(typename PFP::MAP& map, const VertexAttribute<typen ...@@ -66,25 +68,25 @@ typename PFP::REAL totalArea(typename PFP::MAP& map, const VertexAttribute<typen
//! @param position //! @param position
//! @return //! @return
template <typename PFP> template <typename PFP>
typename PFP::REAL vertexOneRingArea(typename PFP::MAP& map, Dart d, const VertexAttribute<typename PFP::VEC3, typename PFP::MAP::IMPL>& position) ; typename PFP::REAL vertexOneRingArea(typename PFP::MAP& map, Vertex v, const VertexAttribute<typename PFP::VEC3, typename PFP::MAP::IMPL>& position) ;
template <typename PFP> template <typename PFP>
typename PFP::REAL vertexBarycentricArea(typename PFP::MAP& map, Dart d, const VertexAttribute<typename PFP::VEC3, typename PFP::MAP::IMPL>& position) ; typename PFP::REAL vertexBarycentricArea(typename PFP::MAP& map, Vertex v, const VertexAttribute<typename PFP::VEC3, typename PFP::MAP::IMPL>& position) ;
template <typename PFP> template <typename PFP>
typename PFP::REAL vertexVoronoiArea(typename PFP::MAP& map, Dart d, const VertexAttribute<typename PFP::VEC3, typename PFP::MAP::IMPL>& position) ; typename PFP::REAL vertexVoronoiArea(typename PFP::MAP& map, Vertex v, const VertexAttribute<typename PFP::VEC3, typename PFP::MAP::IMPL>& position) ;
template <typename PFP> template <typename PFP>
void computeAreaFaces(typename PFP::MAP& map, const VertexAttribute<typename PFP::VEC3, typename PFP::MAP::IMPL>& position, FaceAttribute<typename PFP::REAL, typename PFP::MAP::IMPL>& face_area) ; void computeAreaFaces(typename PFP::MAP& map, const VertexAttribute<typename PFP::VEC3, typename PFP::MAP::IMPL>& position, FaceAttribute<typename PFP::REAL, typename PFP::MAP::IMPL>& face_area, unsigned int thread = 0) ;
template <typename PFP> template <typename PFP>
void computeOneRingAreaVertices(typename PFP::MAP& map, const VertexAttribute<typename PFP::VEC3, typename PFP::MAP::IMPL>& position, VertexAttribute<typename PFP::REAL, typename PFP::MAP::IMPL>& vertex_area) ; void computeOneRingAreaVertices(typename PFP::MAP& map, const VertexAttribute<typename PFP::VEC3, typename PFP::MAP::IMPL>& position, VertexAttribute<typename PFP::REAL, typename PFP::MAP::IMPL>& vertex_area, unsigned int thread = 0) ;
template <typename PFP> template <typename PFP>
void computeBarycentricAreaVertices(typename PFP::MAP& map, const VertexAttribute<typename PFP::VEC3, typename PFP::MAP::IMPL>& position, VertexAttribute<typename PFP::REAL, typename PFP::MAP::IMPL>& vertex_area) ; void computeBarycentricAreaVertices(typename PFP::MAP& map, const VertexAttribute<typename PFP::VEC3, typename PFP::MAP::IMPL>& position, VertexAttribute<typename PFP::REAL, typename PFP::MAP::IMPL>& vertex_area, unsigned int thread = 0) ;
template <typename PFP> template <typename PFP>
void computeVoronoiAreaVertices(typename PFP::MAP& map, const VertexAttribute<typename PFP::VEC3, typename PFP::MAP::IMPL>& position, VertexAttribute<typename PFP::REAL, typename PFP::MAP::IMPL>& vertex_area) ; void computeVoronoiAreaVertices(typename PFP::MAP& map, const VertexAttribute<typename PFP::VEC3, typename PFP::MAP::IMPL>& position, VertexAttribute<typename PFP::REAL, typename PFP::MAP::IMPL>& vertex_area, unsigned int thread = 0) ;
} // namespace Geometry } // namespace Geometry
......
...@@ -24,8 +24,11 @@ ...@@ -24,8 +24,11 @@
#include "Geometry/basic.h" #include "Geometry/basic.h"
#include "Algo/Geometry/centroid.h" #include "Algo/Geometry/centroid.h"
#include "Topology/generic/traversorCell.h"
#include "Topology/generic/traversor2.h" //#include "Topology/generic/traversorCell.h"
//#include "Topology/generic/traversor2.h"
#include "Topology/generic/cells.h"
#include "Topology/generic/autoAttributeHandler.h"
namespace CGoGN namespace CGoGN
{ {
...@@ -40,7 +43,7 @@ namespace Geometry ...@@ -40,7 +43,7 @@ namespace Geometry
{ {
template <typename PFP> template <typename PFP>
typename PFP::REAL triangleArea(typename PFP::MAP& map, Dart d, const VertexAttribute<typename PFP::VEC3, typename PFP::MAP::IMPL>& position) typename PFP::REAL triangleArea(typename PFP::MAP& map, Face d, const VertexAttribute<typename PFP::VEC3, typename PFP::MAP::IMPL>& position)
{ {
typename PFP::VEC3 p1 = position[d] ; typename PFP::VEC3 p1 = position[d] ;
typename PFP::VEC3 p2 = position[map.phi1(d)] ; typename PFP::VEC3 p2 = position[map.phi1(d)] ;
...@@ -50,7 +53,7 @@ typename PFP::REAL triangleArea(typename PFP::MAP& map, Dart d, const VertexAttr ...@@ -50,7 +53,7 @@ typename PFP::REAL triangleArea(typename PFP::MAP& map, Dart d, const VertexAttr
} }
template <typename PFP> template <typename PFP>
typename PFP::REAL convexFaceArea(typename PFP::MAP& map, Dart d, const VertexAttribute<typename PFP::VEC3, typename PFP::MAP::IMPL>& position) typename PFP::REAL convexFaceArea(typename PFP::MAP& map, Face d, const VertexAttribute<typename PFP::VEC3, typename PFP::MAP::IMPL>& position)
{ {
typedef typename PFP::VEC3 VEC3 ; typedef typename PFP::VEC3 VEC3 ;
...@@ -75,38 +78,48 @@ template <typename PFP> ...@@ -75,38 +78,48 @@ template <typename PFP>
typename PFP::REAL totalArea(typename PFP::MAP& map, const VertexAttribute<typename PFP::VEC3, typename PFP::MAP::IMPL>& position, unsigned int thread) typename PFP::REAL totalArea(typename PFP::MAP& map, const VertexAttribute<typename PFP::VEC3, typename PFP::MAP::IMPL>& position, unsigned int thread)
{ {
typename PFP::REAL area(0) ; typename PFP::REAL area(0) ;
TraversorF<typename PFP::MAP> t(map) ;
for(Dart d = t.begin(); d != t.end(); d = t.next()) // TraversorF<typename PFP::MAP> t(map) ;
area += convexFaceArea<PFP>(map, d, position) ; // for(Dart d = t.begin(); d != t.end(); d = t.next())
// area += convexFaceArea<PFP>(map, d, position) ;
foreachCellMT(FACE,f,typename PFP::MAP,map,thread)
area += convexFaceArea<PFP>(map, f, position);
return area ; return area ;
} }
template <typename PFP> template <typename PFP>
typename PFP::REAL vertexOneRingArea(typename PFP::MAP& map, Dart d, const VertexAttribute<typename PFP::VEC3, typename PFP::MAP::IMPL>& position) typename PFP::REAL vertexOneRingArea(typename PFP::MAP& map, Vertex d, const VertexAttribute<typename PFP::VEC3, typename PFP::MAP::IMPL>& position)
{ {
typename PFP::REAL area(0) ; typename PFP::REAL area(0) ;
Traversor2VF<typename PFP::MAP> t(map, d) ; // Traversor2VF<typename PFP::MAP> t(map, d) ;
for(Dart it = t.begin(); it != t.end(); it = t.next()) // for(Dart it = t.begin(); it != t.end(); it = t.next())
area += convexFaceArea<PFP>(map, it, position) ; foreachIncident2(VERTEX,d,FACE,f, typename PFP::MAP, map)
area += convexFaceArea<PFP>(map,f, position) ;
return area ; return area ;
} }
template <typename PFP> template <typename PFP>
typename PFP::REAL vertexBarycentricArea(typename PFP::MAP& map, Dart d, const VertexAttribute<typename PFP::VEC3, typename PFP::MAP::IMPL>& position) typename PFP::REAL vertexBarycentricArea(typename PFP::MAP& map, Vertex d, const VertexAttribute<typename PFP::VEC3, typename PFP::MAP::IMPL>& position)
{ {
typename PFP::REAL area(0) ; typename PFP::REAL area(0) ;
Traversor2VF<typename PFP::MAP> t(map, d) ; // Traversor2VF<typename PFP::MAP> t(map, d) ;
for(Dart it = t.begin(); it != t.end(); it = t.next()) // for(Dart it = t.begin(); it != t.end(); it = t.next())
area += convexFaceArea<PFP>(map, it, position) / 3 ; // area += convexFaceArea<PFP>(map, it, position) / 3 ;
foreachIncident2(VERTEX,d,FACE,f, typename PFP::MAP, map)
area += convexFaceArea<PFP>(map, f, position) / 3 ;
return area ; return area ;
} }
template <typename PFP> template <typename PFP>
typename PFP::REAL vertexVoronoiArea(typename PFP::MAP& map, Dart d, const VertexAttribute<typename PFP::VEC3, typename PFP::MAP::IMPL>& position) typename PFP::REAL vertexVoronoiArea(typename PFP::MAP& map, Vertex d, const VertexAttribute<typename PFP::VEC3, typename PFP::MAP::IMPL>& position)
{ {
typename PFP::REAL area(0) ; typename PFP::REAL area(0) ;
Traversor2VF<typename PFP::MAP> t(map, d) ; // Traversor2VF<typename PFP::MAP> t(map, d) ;
for(Dart it = t.begin(); it != t.end(); it = t.next()) // for(Dart it = t.begin(); it != t.end(); it = t.next())
foreachIncident2(VERTEX,d,FACE,it, typename PFP::MAP, map)
{ {
const typename PFP::VEC3& p1 = position[it] ; const typename PFP::VEC3& p1 = position[it] ;
const typename PFP::VEC3& p2 = position[map.phi1(it)] ; const typename PFP::VEC3& p2 = position[map.phi1(it)] ;
...@@ -130,34 +143,51 @@ typename PFP::REAL vertexVoronoiArea(typename PFP::MAP& map, Dart d, const Verte ...@@ -130,34 +143,51 @@ typename PFP::REAL vertexVoronoiArea(typename PFP::MAP& map, Dart d, const Verte
} }
template <typename PFP> template <typename PFP>
void computeAreaFaces(typename PFP::MAP& map, const VertexAttribute<typename PFP::VEC3, typename PFP::MAP::IMPL>& position, FaceAttribute<typename PFP::REAL, typename PFP::MAP::IMPL>& face_area) void computeAreaFaces(typename PFP::MAP& map, const VertexAttribute<typename PFP::VEC3, typename PFP::MAP::IMPL>& position, FaceAttribute<typename PFP::REAL, typename PFP::MAP::IMPL>& face_area, unsigned int thread)
{ {
TraversorF<typename PFP::MAP> t(map) ; // TraversorF<typename PFP::MAP> t(map) ;
for(Dart d = t.begin(); d != t.end(); d = t.next()) // for(Dart d = t.begin(); d != t.end(); d = t.next())
face_area[d] = convexFaceArea<PFP>(map, d, position) ; // face_area[d] = convexFaceArea<PFP>(map, d, position) ;
foreachCellMT(FACE,f,typename PFP::MAP,map,thread)
face_area[f] = convexFaceArea<PFP>(map, f, position) ;
} }
template <typename PFP> template <typename PFP>
void computeOneRingAreaVertices(typename PFP::MAP& map, const VertexAttribute<typename PFP::VEC3, typename PFP::MAP::IMPL>& position, VertexAttribute<typename PFP::REAL, typename PFP::MAP::IMPL>& vertex_area) void computeOneRingAreaVertices(typename PFP::MAP& map, const VertexAttribute<typename PFP::VEC3, typename PFP::MAP::IMPL>& position, VertexAttribute<typename PFP::REAL, typename PFP::MAP::IMPL>& vertex_area, unsigned int thread)
{ {
TraversorV<typename PFP::MAP> t(map) ; // TraversorV<typename PFP::MAP> t(map) ;
for(Dart d = t.begin(); d != t.end(); d = t.next()) // for(Dart d = t.begin(); d != t.end(); d = t.next())
vertex_area[d] = vertexOneRingArea<PFP>(map, d, position) ;
// foreachCell(VERTEX,d,typename PFP::MAP,map,thread)
// vertex_area[d] = vertexOneRingArea<PFP>(map, d, position) ;
FaceAutoAttribute<typename PFP::REAL,typename PFP::MAP::IMPL> areas(map);
computeAreaFaces<PFP>(map,position,areas);
foreachCellMT(VERTEX,v,typename PFP::MAP,map,thread)
{
vertex_area[v] = typename PFP::REAL(0);
foreachIncident2(VERTEX,v,FACE,f, typename PFP::MAP, map)
vertex_area[v] += areas[f];
}
} }
template <typename PFP> template <typename PFP>
void computeBarycentricAreaVertices(typename PFP::MAP& map, const VertexAttribute<typename PFP::VEC3, typename PFP::MAP::IMPL>& position, VertexAttribute<typename PFP::REAL, typename PFP::MAP::IMPL>& vertex_area) void computeBarycentricAreaVertices(typename PFP::MAP& map, const VertexAttribute<typename PFP::VEC3, typename PFP::MAP::IMPL>& position, VertexAttribute<typename PFP::REAL, typename PFP::MAP::IMPL>& vertex_area, unsigned int thread)
{ {
TraversorV<typename PFP::MAP> t(map) ; // TraversorV<typename PFP::MAP> t(map) ;
for(Dart d = t.begin(); d != t.end(); d = t.next()) // for(Dart d = t.begin(); d != t.end(); d = t.next())
foreachCellMT(VERTEX,d,typename PFP::MAP,map,thread)
vertex_area[d] = vertexBarycentricArea<PFP>(map, d, position) ; vertex_area[d] = vertexBarycentricArea<PFP>(map, d, position) ;
} }
template <typename PFP> template <typename PFP>
void computeVoronoiAreaVertices(typename PFP::MAP& map, const VertexAttribute<typename PFP::VEC3, typename PFP::MAP::IMPL>& position, VertexAttribute<typename PFP::REAL, typename PFP::MAP::IMPL>& vertex_area) void computeVoronoiAreaVertices(typename PFP::MAP& map, const VertexAttribute<typename PFP::VEC3, typename PFP::MAP::IMPL>& position, VertexAttribute<typename PFP::REAL, typename PFP::MAP::IMPL>& vertex_area, unsigned int thread)
{ {
TraversorV<typename PFP::MAP> t(map) ; // TraversorV<typename PFP::MAP> t(map) ;
for(Dart d = t.begin(); d != t.end(); d = t.next()) // for(Dart d = t.begin(); d != t.end(); d = t.next())
foreachCellMT(VERTEX,d,typename PFP::MAP,map,thread)
vertex_area[d] = vertexVoronoiArea<PFP>(map, d, position) ; vertex_area[d] = vertexVoronoiArea<PFP>(map, d, position) ;
} }
......
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
#define __ALGO_GEOMETRY_CENTROID_H__ #define __ALGO_GEOMETRY_CENTROID_H__
#include "Geometry/basic.h" #include "Geometry/basic.h"
#include "Topology/generic/cells.h"
namespace CGoGN namespace CGoGN
{ {
...@@ -50,7 +51,7 @@ namespace Geometry ...@@ -50,7 +51,7 @@ namespace Geometry
* @param attributs the vector of attribute or cell * @param attributs the vector of attribute or cell
*/ */
template <typename PFP, typename V_ATT> template <typename PFP, typename V_ATT>
typename V_ATT::DATA_TYPE volumeCentroid(typename PFP::MAP& map, Dart d, const V_ATT& attributs, unsigned int thread = 0); typename V_ATT::DATA_TYPE volumeCentroid(typename PFP::MAP& map, Vol d, const V_ATT& attributs, unsigned int thread = 0);
/** /**
* Compute volume centroid weighted by edge length (generic version) * Compute volume centroid weighted by edge length (generic version)
...@@ -63,7 +64,7 @@ typename V_ATT::DATA_TYPE volumeCentroid(typename PFP::MAP& map, Dart d, const V ...@@ -63,7 +64,7 @@ typename V_ATT::DATA_TYPE volumeCentroid(typename PFP::MAP& map, Dart d, const V
* @param attributs the vector of attribute or cell * @param attributs the vector of attribute or cell
*/ */
template <typename PFP, typename V_ATT> template <typename PFP, typename V_ATT>
typename V_ATT::DATA_TYPE volumeCentroidELW(typename PFP::MAP& map, Dart d, const V_ATT& attributs, unsigned int thread = 0); typename V_ATT::DATA_TYPE volumeCentroidELW(typename PFP::MAP& map, Vol d, const V_ATT& attributs, unsigned int thread = 0);
/** /**
* Compute face centroid (generic version) * Compute face centroid (generic version)
...@@ -75,7 +76,7 @@ typename V_ATT::DATA_TYPE volumeCentroidELW(typename PFP::MAP& map, Dart d, cons ...@@ -75,7 +76,7 @@ typename V_ATT::DATA_TYPE volumeCentroidELW(typename PFP::MAP& map, Dart d, cons
* @param attributs the vector of attribute or cell * @param attributs the vector of attribute or cell
*/ */
template <typename PFP, typename V_ATT> template <typename PFP, typename V_ATT>
typename V_ATT::DATA_TYPE faceCentroid(typename PFP::MAP& map, Dart d, const V_ATT& attributs); typename V_ATT::DATA_TYPE faceCentroid(typename PFP::MAP& map, Face d, const V_ATT& attributs);
/** /**
* Compute face centroid weighted by edge length (generic version) * Compute face centroid weighted by edge length (generic version)
...@@ -87,7 +88,7 @@ typename V_ATT::DATA_TYPE faceCentroid(typename PFP::MAP& map, Dart d, const V_A ...@@ -87,7 +88,7 @@ typename V_ATT::DATA_TYPE faceCentroid(typename PFP::MAP& map, Dart d, const V_A
* @param attributs the vector of attribute or cell * @param attributs the vector of attribute or cell
*/ */
template <typename PFP, typename V_ATT> template <typename PFP, typename V_ATT>
typename V_ATT::DATA_TYPE faceCentroidELW(typename PFP::MAP& map, Dart d, const V_ATT& attributs); typename V_ATT::DATA_TYPE faceCentroidELW(typename PFP::MAP& map, Face d, const V_ATT& attributs);
/** /**
* Compute vertex neighbours centroid (generic version) * Compute vertex neighbours centroid (generic version)
...@@ -99,7 +100,7 @@ typename V_ATT::DATA_TYPE faceCentroidELW(typename PFP::MAP& map, Dart d, const ...@@ -99,7 +100,7 @@ typename V_ATT::DATA_TYPE faceCentroidELW(typename PFP::MAP& map, Dart d, const
* @param position the vector of attribute or cell * @param position the vector of attribute or cell
*/ */
template <typename PFP, typename V_ATT> template <typename PFP, typename V_ATT>
typename V_ATT::DATA_TYPE vertexNeighborhoodCentroid(typename PFP::MAP& map, Dart d, const V_ATT& attributs); typename V_ATT::DATA_TYPE vertexNeighborhoodCentroid(typename PFP::MAP& map, Vertex d, const V_ATT& attributs);
/** /**
* Compute centroid of all faces * Compute centroid of all faces
...@@ -195,7 +196,7 @@ namespace Geometry ...@@ -195,7 +196,7 @@ namespace Geometry
* @param position the vector of attribute or cell * @param position the vector of attribute or cell
*/ */
template <typename PFP, typename V_ATT> template <typename PFP, typename V_ATT>
typename V_ATT::DATA_TYPE vertexNeighborhoodCentroid(typename PFP::MAP& map, Dart d, const V_ATT& attributs); typename V_ATT::DATA_TYPE vertexNeighborhoodCentroid(typename PFP::MAP& map, Vertex d, const V_ATT& attributs, unsigned int thread = 0);
/** /**
* compute centroid of all volumes * compute centroid of all volumes
......
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
#include "Topology/generic/traversorCell.h" #include "Topology/generic/traversorCell.h"
#include "Topology/generic/traversor3.h" #include "Topology/generic/traversor3.h"
#include "Algo/Parallel/parallel_foreach.h" #include "Algo/Parallel/parallel_foreach.h"
#include "Topology/generic/cells.h"
namespace CGoGN namespace CGoGN
{ {
...@@ -42,14 +43,20 @@ namespace Geometry ...@@ -42,14 +43,20 @@ namespace Geometry
{ {
template <typename PFP, typename V_ATT> template <typename PFP, typename V_ATT>
typename V_ATT::DATA_TYPE volumeCentroid(typename PFP::MAP& map, Dart d, const V_ATT& attributs, unsigned int thread) typename V_ATT::DATA_TYPE volumeCentroid(typename PFP::MAP& map, Vol d, const V_ATT& attributs, unsigned int thread)
{ {
typename V_ATT::DATA_TYPE center(0.0); typename V_ATT::DATA_TYPE center(0.0);
unsigned int count = 0 ; unsigned int count = 0 ;
Traversor3WV<typename PFP::MAP> tra(map,d,false,thread); // Traversor3WV<typename PFP::MAP> tra(map,d,false,thread);
for (Dart d = tra.begin(); d != tra.end(); d = tra.next()) // for (Dart d = tra.begin(); d != tra.end(); d = tra.next())
// {
// center += attributs[d];
// ++count;
// }
foreachIncident3MT(VOLUME,d,VERTEX,e,typename PFP::MAP,map,thread)
{ {
center += attributs[d]; center += attributs[e];
++count; ++count;
} }
...@@ -58,14 +65,16 @@ typename V_ATT::DATA_TYPE volumeCentroid(typename PFP::MAP& map, Dart d, const V ...@@ -58,14 +65,16 @@ typename V_ATT::DATA_TYPE volumeCentroid(typename PFP::MAP& map, Dart d, const V
} }
template <typename PFP, typename V_ATT> template <typename PFP, typename V_ATT>
typename V_ATT::DATA_TYPE volumeCentroidELW(typename PFP::MAP& map, Dart d, const V_ATT& attributs, unsigned int thread) typename V_ATT::DATA_TYPE volumeCentroidELW(typename PFP::MAP& map, Vol d, const V_ATT& attributs, unsigned int thread)
{ {
typedef typename V_ATT::DATA_TYPE EMB; typedef typename V_ATT::DATA_TYPE EMB;
EMB center(0.0); EMB center(0.0);
double count=0.0; double count=0.0;
Traversor3WE<typename PFP::MAP> t(map, d,false,thread) ; // Traversor3WE<typename PFP::MAP> t(map, d,false,thread) ;
for(Dart it = t.begin(); it != t.end();it = t.next()) // for(Dart it = t.begin(); it != t.end();it = t.next())
foreachIncident3MT(VOLUME,d,EDGE,it,typename PFP::MAP,map,thread)
{ {
EMB e1 = attributs[it]; EMB e1 = attributs[it];
EMB e2 = attributs[map.phi1(it)]; EMB e2 = attributs[map.phi1(it)];
...@@ -78,12 +87,14 @@ typename V_ATT::DATA_TYPE volumeCentroidELW(typename PFP::MAP& map, Dart d, cons ...@@ -78,12 +87,14 @@ typename V_ATT::DATA_TYPE volumeCentroidELW(typename PFP::MAP& map, Dart d, cons
} }
template <typename PFP, typename V_ATT> template <typename PFP, typename V_ATT>
typename V_ATT::DATA_TYPE faceCentroid(typename PFP::MAP& map, Dart d, const V_ATT& attributs) typename V_ATT::DATA_TYPE faceCentroid(typename PFP::MAP& map, Face d, const V_ATT& attributs)
{ {
typename V_ATT::DATA_TYPE center(0.0); typename V_ATT::DATA_TYPE center(0.0);
unsigned int count = 0 ; unsigned int count = 0 ;
Traversor2FV<typename PFP::MAP> t(map, d) ;
for(Dart it = t.begin(); it != t.end(); it = t.next()) // Traversor2FV<typename PFP::MAP> t(map, d) ;
// for(Dart it = t.begin(); it != t.end(); it = t.next())
foreachIncident2(FACE,d,VERTEX,it,typename PFP::MAP,map)
{ {
center += attributs[it]; center += attributs[it];
++count ; ++count ;
...@@ -93,14 +104,16 @@ typename V_ATT::DATA_TYPE faceCentroid(typename PFP::MAP& map, Dart d, const V_A ...@@ -93,14 +104,16 @@ typename V_ATT::DATA_TYPE faceCentroid(typename PFP::MAP& map, Dart d, const V_A
} }
template <typename PFP, typename V_ATT> template <typename PFP, typename V_ATT>
typename V_ATT::DATA_TYPE faceCentroidELW(typename PFP::MAP& map, Dart d, const V_ATT& attributs) typename V_ATT::DATA_TYPE faceCentroidELW(typename PFP::MAP& map, Face d, const V_ATT& attributs)
{ {
typedef typename V_ATT::DATA_TYPE EMB; typedef typename V_ATT::DATA_TYPE EMB;
EMB center(0.0); EMB center(0.0);
double count=0.0; double count=0.0;
Traversor2FE<typename PFP::MAP> t(map, d) ;
for(Dart it = t.begin(); it != t.end(); it = t.next()) // Traversor2FE<typename PFP::MAP> t(map, d) ;
// for(Dart it = t.begin(); it != t.end(); it = t.next())
foreachIncident2(FACE,d,EDGE,it,typename PFP::MAP,map)
{ {
EMB e1 = attributs[it]; EMB e1 = attributs[it];
EMB e2 = attributs[map.phi1(it)]; EMB e2 = attributs[map.phi1(it)];
...@@ -113,13 +126,14 @@ typename V_ATT::DATA_TYPE faceCentroidELW(typename PFP::MAP& map, Dart d, const ...@@ -113,13 +126,14 @@ typename V_ATT::DATA_TYPE faceCentroidELW(typename PFP::MAP& map, Dart d, const
} }
template <typename PFP, typename V_ATT> template <typename PFP, typename V_ATT>
typename V_ATT::DATA_TYPE vertexNeighborhoodCentroid(typename PFP::MAP& map, Dart d, const V_ATT& attributs) typename V_ATT::DATA_TYPE vertexNeighborhoodCentroid(typename PFP::MAP& map, Vertex d, const V_ATT& attributs)
{ {
typename V_ATT::DATA_TYPE center(0.0); typename V_ATT::DATA_TYPE center(0.0);
unsigned int count = 0 ; unsigned int count = 0 ;
Traversor2VVaE<typename PFP::MAP> t(map, d) ; // Traversor2VVaE<typename PFP::MAP> t(map, d) ;
for(Dart it = t.begin(); it != t.end(); it = t.next()) // for(Dart it = t.begin(); it != t.end(); it = t.next())
foreachAdjacent2(VERTEX,EDGE,d,it,typename PFP::MAP,map)
{ {
center += attributs[it]; center += attributs[it];
++count ; ++count ;
...@@ -131,24 +145,27 @@ typename V_ATT::DATA_TYPE vertexNeighborhoodCentroid(typename PFP::MAP& map, Dar ...@@ -131,24 +145,27 @@ typename V_ATT::DATA_TYPE vertexNeighborhoodCentroid(typename PFP::MAP& map, Dar
template <typename PFP, typename V_ATT, typename F_ATT> template <typename PFP, typename V_ATT, typename F_ATT>
void computeCentroidFaces(typename PFP::MAP& map, const V_ATT& position, F_ATT& face_centroid, unsigned int thread) void computeCentroidFaces(typename PFP::MAP& map, const V_ATT& position, F_ATT& face_centroid, unsigned int thread)
{ {
TraversorF<typename PFP::MAP> t(map,thread) ; // TraversorF<typename PFP::MAP> t(map,thread) ;
for(Dart d = t.begin(); d != t.end(); d = t.next()) // for(Dart d = t.begin(); d != t.end(); d = t.next())
foreachCellMT(FACE,d,typename PFP::MAP,map ,thread)
face_centroid[d] = faceCentroid<PFP,V_ATT>(map, d, position) ; face_centroid[d] = faceCentroid<PFP,V_ATT>(map, d, position) ;
} }
template <typename PFP, typename V_ATT, typename F_ATT> template <typename PFP, typename V_ATT, typename F_ATT>
void computeCentroidELWFaces(typename PFP::MAP& map, const V_ATT& position, F_ATT& face_centroid, unsigned int thread) void computeCentroidELWFaces(typename PFP::MAP& map, const V_ATT& position, F_ATT& face_centroid, unsigned int thread)
{ {
TraversorF<typename PFP::MAP> t(map,thread) ; // TraversorF<typename PFP::MAP> t(map,thread) ;
for(Dart d = t.begin(); d != t.end(); d = t.next()) // for(Dart d = t.begin(); d != t.end(); d = t.next())
foreachCellMT(FACE,d,typename PFP::MAP,map ,thread)
face_centroid[d] = faceCentroidELW<PFP,V_ATT>(map, d, position) ; face_centroid[d] = faceCentroidELW<PFP,V_ATT>(map, d, position) ;
} }
template <typename PFP, typename V_ATT> template <typename PFP, typename V_ATT>
void computeNeighborhoodCentroidVertices(typename PFP::MAP& map, const V_ATT& position, V_ATT& vertex_centroid, unsigned int thread) void computeNeighborhoodCentroidVertices(typename PFP::MAP& map, const V_ATT& position, V_ATT& vertex_centroid, unsigned int thread)
{ {
TraversorV<typename PFP::MAP> t(map, thread) ; // TraversorV<typename PFP::MAP> t(map, thread) ;
for(Dart d = t.begin(); d != t.end(); d = t.next()) // for(Dart d = t.begin(); d != t.end(); d = t.next())
foreachCellMT(VERTEX,d,typename PFP::MAP,map ,thread)
vertex_centroid[d] = vertexNeighborhoodCentroid<PFP,V_ATT>(map, d, position) ; vertex_centroid[d] = vertexNeighborhoodCentroid<PFP,V_ATT>(map, d, position) ;
} }
...@@ -247,12 +264,13 @@ namespace Geometry ...@@ -247,12 +264,13 @@ namespace Geometry
{ {
template <typename PFP, typename V_ATT> template <typename PFP, typename V_ATT>
typename V_ATT::DATA_TYPE vertexNeighborhoodCentroid(typename PFP::MAP& map, Dart d, const V_ATT& attributs) typename V_ATT::DATA_TYPE vertexNeighborhoodCentroid(typename PFP::MAP& map, Vertex d, const V_ATT& attributs, unsigned int thread)
{ {
typename V_ATT::DATA_TYPE center(0.0); typename V_ATT::DATA_TYPE center(0.0);
unsigned int count = 0 ; unsigned int count = 0 ;
Traversor3VVaE<typename PFP::MAP> t(map, d) ; // Traversor3VVaE<typename PFP::MAP> t(map, d) ;
for(Dart it = t.begin(); it != t.end(); it = t.next()) // for(Dart it = t.begin(); it != t.end(); it = t.next())
foreachAdjacent3MT(VERTEX,EDGE,d,it,typename PFP::MAP,map,thread)
{ {
center += attributs[it]; center += attributs[it];
++count ; ++count ;
...@@ -264,24 +282,27 @@ typename V_ATT::DATA_TYPE vertexNeighborhoodCentroid(typename PFP::MAP& map, Dar ...@@ -264,24 +282,27 @@ typename V_ATT::DATA_TYPE vertexNeighborhoodCentroid(typename PFP::MAP& map, Dar
template <typename PFP, typename V_ATT, typename W_ATT> template <typename PFP, typename V_ATT, typename W_ATT>
void computeCentroidVolumes(typename PFP::MAP& map, const V_ATT& position, W_ATT& vol_centroid