Commit 0c249b1a authored by Sylvain Thery's avatar Sylvain Thery

automatic using of // versions

parent 753c8238
...@@ -457,19 +457,56 @@ void Viewer::cb_keyPress(int keycode) ...@@ -457,19 +457,56 @@ void Viewer::cb_keyPress(int keycode)
case'Z': case'Z':
{ {
Utils::Chrono ch; Utils::Chrono ch;
ch.start(); ch.start();
for (unsigned int i=0; i<4; ++i) for (unsigned int i=0; i<4; ++i)
Algo::Surface::Geometry::Parallel::computeNormalVertices<PFP>(myMap, position, normal) ; Algo::Surface::Geometry::computeNormalVertices<PFP>(myMap, position, normal) ;
std::cout << "Algo::Surface::Geometry::Parallel::computeNormalVertices "<< ch.elapsed()<< " ms "<< std::endl; std::cout << "Algo::Surface::Geometry::Parallel::computeNormalVertices "<< ch.elapsed()<< " ms "<< std::endl;
ch.start();
CGoGN::Parallel::NumberOfThreads = 1;
for (unsigned int i=0; i<4; ++i)
Algo::Surface::Geometry::Parallel::computeNormalVertices<PFP>(myMap, position, normal) ;
std::cout << "Algo::Surface::Geometry::Parallel::computeNormalVertices1 "<< ch.elapsed()<< " ms "<< std::endl;
ch.start();
CGoGN::Parallel::NumberOfThreads = 2;
for (unsigned int i=0; i<4; ++i)
Algo::Surface::Geometry::Parallel::computeNormalVertices<PFP>(myMap, position, normal) ;
std::cout << "Algo::Surface::Geometry::Parallel::computeNormalVertices2 "<< ch.elapsed()<< " ms "<< std::endl;
ch.start();
CGoGN::Parallel::NumberOfThreads = 3;
for (unsigned int i=0; i<4; ++i)
Algo::Surface::Geometry::Parallel::computeNormalVertices<PFP>(myMap, position, normal) ;
std::cout << "Algo::Surface::Geometry::Parallel::computeNormalVertices3 "<< ch.elapsed()<< " ms "<< std::endl;
ch.start();
CGoGN::Parallel::NumberOfThreads = 4;
for (unsigned int i=0; i<4; ++i)
Algo::Surface::Geometry::Parallel::computeNormalVertices<PFP>(myMap, position, normal) ;
std::cout << "Algo::Surface::Geometry::Parallel::computeNormalVertices4 "<< ch.elapsed()<< " ms "<< std::endl;
ch.start();
CGoGN::Parallel::NumberOfThreads = 8;
for (unsigned int i=0; i<4; ++i)
Algo::Surface::Geometry::Parallel::computeNormalVertices<PFP>(myMap, position, normal) ;
std::cout << "Algo::Surface::Geometry::Parallel::computeNormalVertices8 "<< ch.elapsed()<< " ms "<< std::endl;
ch.start(); ch.start();
for (unsigned int i=0; i<4; ++i) for (unsigned int i=0; i<4; ++i)
Parallel::foreach_cell<VERTEX>(myMap,[&](Vertex v, unsigned int th) Parallel::foreach_cell<VERTEX>(myMap,[&](Vertex v, unsigned int th)
{ {
normal[v] = Algo::Surface::Geometry::vertexNormal<PFP>(myMap,v,position); normal[v] = Algo::Surface::Geometry::vertexNormal<PFP>(myMap,v,position);
},4,false,FORCE_CELL_MARKING); },false,FORCE_CELL_MARKING);
std::cout << "Parallel::foreach_cell "<< ch.elapsed()<< " ms "<< std::endl; std::cout << "Parallel::foreach_cell "<< ch.elapsed()<< " ms "<< std::endl;
......
...@@ -498,8 +498,6 @@ int main(int argc, char **argv) ...@@ -498,8 +498,6 @@ int main(int argc, char **argv)
Utils::Chrono ch; Utils::Chrono ch;
Vertex v(myMap.begin()); Vertex v(myMap.begin());
VEC3 p = Algo::Volume::Geometry::vertexNeighborhoodCentroid<PFP>(myMap,v,position); VEC3 p = Algo::Volume::Geometry::vertexNeighborhoodCentroid<PFP>(myMap,v,position);
...@@ -529,7 +527,6 @@ int main(int argc, char **argv) ...@@ -529,7 +527,6 @@ int main(int argc, char **argv)
vol += Algo::Geometry::totalVolume<PFP>(myMap, position); vol += Algo::Geometry::totalVolume<PFP>(myMap, position);
std::cout << ch.elapsed()<< " ms val="<<vol<< std::endl; std::cout << ch.elapsed()<< " ms val="<<vol<< std::endl;
// et on attend la fin. // et on attend la fin.
return app.exec(); return app.exec();
} }
...@@ -114,7 +114,7 @@ int main() ...@@ -114,7 +114,7 @@ int main()
{ {
position[v] += VEC3(0.0,0.0,PFP::REAL(thread)*0.1f); position[v] += VEC3(0.0,0.0,PFP::REAL(thread)*0.1f);
// WARNING thread vary here from 1 to 4 (and not from 0 to 3) !!!! // WARNING thread vary here from 1 to 4 (and not from 0 to 3) !!!!
},4,false); // 4:4 thread, false for no need for markers in threaded code. },false); // 4:4 thread, false for no need for markers in threaded code.
std::cout << "After // processing"<< std::endl; std::cout << "After // processing"<< std::endl;
...@@ -127,17 +127,22 @@ int main() ...@@ -127,17 +127,22 @@ int main()
// Example with // accumulation // Example with // accumulation
// computing the sum of area faces // computing the sum of area faces
// force number of threads to 4 (0 for traverse, 1,2,3 for computation)
CGoGN::Parallel::NumberOfThreads = 4;
// init nbthread values with 0 // init nbthread values with 0
float surf[4]={0.0f,0.0f,0.0f,0.0f}; float surf[3]={0.0f,0.0f,0.0f};
// traverse face in // // traverse face in //
Parallel::foreach_cell<FACE>(myMap,[&](Face f, unsigned int thr) Parallel::foreach_cell<FACE>(myMap,[&](Face f, unsigned int thr)
{ {
// for each face add surface to accumulator (-1 because counter between 1-4 not 0-3) // for each face add surface to accumulator (-1 because counter between 1-3 not 0-3)
surf[thr-1] += Algo::Surface::Geometry::convexFaceArea<PFP>(myMap,f,position); surf[thr-1] += Algo::Surface::Geometry::convexFaceArea<PFP>(myMap,f,position);
},4,false); },false);
std::cout << surf[0]<< "/"<< surf[1]<< "/"<< surf[2]<< "/"<< surf[3]<< "/"<< std::endl; std::cout << surf[0]<< "/"<< surf[1]<< "/"<< surf[2]<< "/"<< std::endl;
std::cout << "Total="<<surf[0]+surf[1]+surf[2]+surf[3]<< std::endl; std::cout << "Total="<<surf[0]+surf[1]+surf[2]<< std::endl;
TraversorV<MAP> tv0(myMap); TraversorV<MAP> tv0(myMap);
......
...@@ -86,6 +86,21 @@ void computeBarycentricAreaVertices(typename PFP::MAP& map, const VertexAttribut ...@@ -86,6 +86,21 @@ void computeBarycentricAreaVertices(typename PFP::MAP& map, const VertexAttribut
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, unsigned int thread = 0) ; 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 Parallel
{
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>& area);
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>& area);
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);
template <typename PFP>
void computeVoronoiAreaVertices(typename PFP::MAP& map, const VertexAttribute<typename PFP::VEC3, typename PFP::MAP>& position, VertexAttribute<typename PFP::REAL, typename PFP::MAP>& area);
} // namespace Parallel
} // namespace Geometry } // namespace Geometry
} // namespace Surface } // namespace Surface
......
...@@ -76,8 +76,6 @@ typename PFP::REAL totalArea(typename PFP::MAP& map, const VertexAttribute<typen ...@@ -76,8 +76,6 @@ typename PFP::REAL totalArea(typename PFP::MAP& map, const VertexAttribute<typen
{ {
typename PFP::REAL area(0) ; typename PFP::REAL area(0) ;
// TraversorF<typename PFP::MAP> t(map) ;
foreach_cell<FACE>(map, [&] (Face f) foreach_cell<FACE>(map, [&] (Face f)
{ {
area += convexFaceArea<PFP>(map, f, position); area += convexFaceArea<PFP>(map, f, position);
...@@ -91,7 +89,6 @@ template <typename PFP> ...@@ -91,7 +89,6 @@ template <typename PFP>
typename PFP::REAL vertexOneRingArea(typename PFP::MAP& map, Vertex v, 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)
{ {
typename PFP::REAL area(0) ; typename PFP::REAL area(0) ;
// Traversor2VF<typename PFP::MAP> t(map, d) ;
foreach_incident2<FACE>(map, v, [&] (Face f) foreach_incident2<FACE>(map, v, [&] (Face f)
{ {
...@@ -104,7 +101,6 @@ template <typename PFP> ...@@ -104,7 +101,6 @@ template <typename PFP>
typename PFP::REAL vertexBarycentricArea(typename PFP::MAP& map, Vertex v, 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)
{ {
typename PFP::REAL area(0) ; typename PFP::REAL area(0) ;
// Traversor2VF<typename PFP::MAP> t(map, v) ;
foreach_incident2<FACE>(map, v, [&] (Face f) foreach_incident2<FACE>(map, v, [&] (Face f)
{ {
...@@ -117,7 +113,6 @@ template <typename PFP> ...@@ -117,7 +113,6 @@ template <typename PFP>
typename PFP::REAL vertexVoronoiArea(typename PFP::MAP& map, Vertex v, 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)
{ {
typename PFP::REAL area(0) ; typename PFP::REAL area(0) ;
// Traversor2VF<typename PFP::MAP> t(map, v) ;
foreach_incident2<FACE>(map, v, [&] (Face it) foreach_incident2<FACE>(map, v, [&] (Face it)
{ {
const typename PFP::VEC3& p1 = position[it] ; const typename PFP::VEC3& p1 = position[it] ;
...@@ -144,9 +139,12 @@ typename PFP::REAL vertexVoronoiArea(typename PFP::MAP& map, Vertex v, const Ver ...@@ -144,9 +139,12 @@ typename PFP::REAL vertexVoronoiArea(typename PFP::MAP& map, Vertex v, const Ver
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, unsigned int thread) 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) ;
// for(Dart d = t.begin(); d != t.end(); d = t.next()) if ((CGoGN::Parallel::NumberOfThreads > 1) && (thread==0))
// face_area[d] = convexFaceArea<PFP>(map, d, position) ; {
Parallel::computeAreaFaces<PFP>(map,position,face_area);
return;
}
foreach_cell<FACE>(map, [&] (Face f) foreach_cell<FACE>(map, [&] (Face f)
{ {
...@@ -159,6 +157,12 @@ void computeAreaFaces(typename PFP::MAP& map, const VertexAttribute<typename PFP ...@@ -159,6 +157,12 @@ void computeAreaFaces(typename PFP::MAP& map, const VertexAttribute<typename PFP
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, unsigned int thread) 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)
{ {
if ((CGoGN::Parallel::NumberOfThreads > 1) && (thread==0))
{
Parallel::computeOneRingAreaVertices<PFP>(map,position,vertex_area);
return;
}
FaceAutoAttribute<typename PFP::REAL,typename PFP::MAP::IMPL> areas(map); FaceAutoAttribute<typename PFP::REAL,typename PFP::MAP::IMPL> areas(map);
computeAreaFaces<PFP>(map,position,areas); computeAreaFaces<PFP>(map,position,areas);
...@@ -177,7 +181,12 @@ void computeOneRingAreaVertices(typename PFP::MAP& map, const VertexAttribute<ty ...@@ -177,7 +181,12 @@ void computeOneRingAreaVertices(typename PFP::MAP& map, const VertexAttribute<ty
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, unsigned int thread) 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) ; if ((CGoGN::Parallel::NumberOfThreads > 1) && (thread==0))
{
Parallel::computeBarycentricAreaVertices<PFP>(map,position,vertex_area);
return;
}
foreach_cell<VERTEX>(map, [&] (Vertex v) foreach_cell<VERTEX>(map, [&] (Vertex v)
{ {
vertex_area[v] = vertexBarycentricArea<PFP>(map, v, position) ; vertex_area[v] = vertexBarycentricArea<PFP>(map, v, position) ;
...@@ -188,7 +197,12 @@ void computeBarycentricAreaVertices(typename PFP::MAP& map, const VertexAttribut ...@@ -188,7 +197,12 @@ void computeBarycentricAreaVertices(typename PFP::MAP& map, const VertexAttribut
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, unsigned int thread) 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) ; if ((CGoGN::Parallel::NumberOfThreads > 1) && (thread==0))
{
Parallel::computeVoronoiAreaVertices<PFP>(map,position,vertex_area);
return;
}
foreach_cell<VERTEX>(map, [&] (Vertex v) foreach_cell<VERTEX>(map, [&] (Vertex v)
{ {
vertex_area[v] = vertexVoronoiArea<PFP>(map, v, position) ; vertex_area[v] = vertexVoronoiArea<PFP>(map, v, position) ;
...@@ -202,7 +216,7 @@ namespace Parallel ...@@ -202,7 +216,7 @@ namespace Parallel
{ {
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>& area, unsigned int nbth) void computeAreaFaces(typename PFP::MAP& map, const VertexAttribute<typename PFP::VEC3, typename PFP::MAP::IMPL>& position, FaceAttribute<typename PFP::REAL, typename PFP::MAP::IMPL>& area)
{ {
// if (map.isOrbitEmbedded<FACE>()) // if (map.isOrbitEmbedded<FACE>())
// { // {
...@@ -219,31 +233,39 @@ void computeAreaFaces(typename PFP::MAP& map, const VertexAttribute<typename PFP ...@@ -219,31 +233,39 @@ void computeAreaFaces(typename PFP::MAP& map, const VertexAttribute<typename PFP
// },nbth,false,AUTO); // },nbth,false,AUTO);
// } // }
// TODO A REMPLACER QUAND PLGTS CHANGES
CGoGN::Parallel::foreach_cell<FACE>(map,[&](Face f, unsigned int thr) CGoGN::Parallel::foreach_cell<FACE>(map,[&](Face f, unsigned int thr)
{ {
area[f] = convexFaceArea<PFP>(map, f, position) ; area[f] = convexFaceArea<PFP>(map, f, position) ;
},nbth,false,AUTO); },false,AUTO);
} }
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>& area, unsigned int nbth) void computeOneRingAreaVertices(typename PFP::MAP& map, const VertexAttribute<typename PFP::VEC3, typename PFP::MAP::IMPL>& position, VertexAttribute<typename PFP::REAL, typename PFP::MAP::IMPL>& area)
{ {
CGoGN::Parallel::foreach_cell<VERTEX>(map,[&](Vertex v, unsigned int thr) CGoGN::Parallel::foreach_cell<VERTEX>(map,[&](Vertex v, unsigned int thr)
{ {
area[v] = vertexOneRingArea<PFP>(map, v, position) ; area[v] = vertexOneRingArea<PFP>(map, v, position) ;
},nbth,false,FORCE_CELL_MARKING); },false,FORCE_CELL_MARKING);
}
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)
{
CGoGN::Parallel::foreach_cell<VERTEX>(map, [&] (Vertex v, unsigned int thr)
{
vertex_area[v] = vertexBarycentricArea<PFP>(map, v, position) ;
}
,false,FORCE_CELL_MARKING);
} }
template <typename PFP> template <typename PFP>
void computeVoronoiAreaVertices(typename PFP::MAP& map, const VertexAttribute<typename PFP::VEC3, typename PFP::MAP>& position, VertexAttribute<typename PFP::REAL, typename PFP::MAP>& area, unsigned int nbth) void computeVoronoiAreaVertices(typename PFP::MAP& map, const VertexAttribute<typename PFP::VEC3, typename PFP::MAP>& position, VertexAttribute<typename PFP::REAL, typename PFP::MAP>& area)
{ {
CGoGN::Parallel::foreach_cell<VERTEX>(map,[&](Vertex v, unsigned int thr) CGoGN::Parallel::foreach_cell<VERTEX>(map,[&](Vertex v, unsigned int thr)
{ {
area[v] = vertexVoronoiArea<PFP>(map, v, position) ; area[v] = vertexVoronoiArea<PFP>(map, v, position) ;
},nbth,false,FORCE_CELL_MARKING); },false,FORCE_CELL_MARKING);
} }
} // namespace Parallel } // namespace Parallel
......
...@@ -140,36 +140,30 @@ namespace Parallel ...@@ -140,36 +140,30 @@ namespace Parallel
* @param map the map * @param map the map
* @param position position vertex attribute * @param position position vertex attribute
* @param face_centroid centroid face attribute * @param face_centroid centroid face attribute
* @param nbth the number of threads
*/ */
template <typename PFP, typename V_ATT, typename F_ATT> template <typename PFP, typename V_ATT, typename F_ATT>
void computeCentroidFaces(typename PFP::MAP& map, void computeCentroidFaces(typename PFP::MAP& map,
const V_ATT& position, F_ATT& face_centroid, const V_ATT& position, F_ATT& face_centroid) ;
unsigned int nbth = 0) ;
/** /**
* Compute centroid of all faces (Edge Length Weighted) * Compute centroid of all faces (Edge Length Weighted)
* @param map the map * @param map the map
* @param position position vertex attribute * @param position position vertex attribute
* @param face_centroid centroid face attribute * @param face_centroid centroid face attribute
* @param nbth the number of threads
*/ */
template <typename PFP, typename V_ATT, typename F_ATT> template <typename PFP, typename V_ATT, typename F_ATT>
void computeCentroidELWFaces(typename PFP::MAP& map, void computeCentroidELWFaces(typename PFP::MAP& map,
const V_ATT& position, F_ATT& face_centroid, const V_ATT& position, F_ATT& face_centroid) ;
unsigned int nbth = 0) ;
/** /**
* Compute neighborhood centroid of all vertices (in parallel) * Compute neighborhood centroid of all vertices (in parallel)
* @param map the map * @param map the map
* @param position position vertex attribute * @param position position vertex attribute
* @param vertex_centroid centroid vertex attribute * @param vertex_centroid centroid vertex attribute
* @param nbth the number of threads
*/ */
template <typename PFP, typename V_ATT> template <typename PFP, typename V_ATT>
void computeNeighborhoodCentroidVertices(typename PFP::MAP& map, void computeNeighborhoodCentroidVertices(typename PFP::MAP& map,
const V_ATT& position, V_ATT& vertex_centroid, const V_ATT& position, V_ATT& vertex_centroid) ;
unsigned int nbth = 0) ;
} // namespace Parallel } // namespace Parallel
...@@ -224,20 +218,17 @@ namespace Parallel ...@@ -224,20 +218,17 @@ namespace Parallel
template <typename PFP, typename V_ATT, typename W_ATT> template <typename PFP, typename V_ATT, typename W_ATT>
void computeCentroidVolumes(typename PFP::MAP& map, void computeCentroidVolumes(typename PFP::MAP& map,
const V_ATT& position, W_ATT& vol_centroid, const V_ATT& position, W_ATT& vol_centroid) ;
unsigned int nbth = 0) ;
template <typename PFP, typename V_ATT, typename W_ATT> template <typename PFP, typename V_ATT, typename W_ATT>
void computeCentroidELWVolumes(typename PFP::MAP& map, void computeCentroidELWVolumes(typename PFP::MAP& map,
const V_ATT& position, W_ATT& vol_centroid, const V_ATT& position, W_ATT& vol_centroid) ;
unsigned int nbth = 0) ;
template <typename PFP, typename V_ATT> template <typename PFP, typename V_ATT>
void computeNeighborhoodCentroidVertices(typename PFP::MAP& map, void computeNeighborhoodCentroidVertices(typename PFP::MAP& map,
const V_ATT& position, V_ATT& vertex_centroid, const V_ATT& position, V_ATT& vertex_centroid) ;
unsigned int nbth = 0) ;
} // namespace Parallel } // namespace Parallel
......
...@@ -46,7 +46,6 @@ typename V_ATT::DATA_TYPE volumeCentroid(typename PFP::MAP& map, Vol d, const V_ ...@@ -46,7 +46,6 @@ typename V_ATT::DATA_TYPE volumeCentroid(typename PFP::MAP& map, Vol d, const V_
{ {
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);
foreach_incident3<VERTEX>(map,d, [&] (Vertex v) foreach_incident3<VERTEX>(map,d, [&] (Vertex v)
{ {
...@@ -66,7 +65,6 @@ typename V_ATT::DATA_TYPE volumeCentroidELW(typename PFP::MAP& map, Vol d, const ...@@ -66,7 +65,6 @@ typename V_ATT::DATA_TYPE volumeCentroidELW(typename PFP::MAP& map, Vol d, const
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) ;
foreach_incident3<EDGE>(map,d, [&] (Edge it) foreach_incident3<EDGE>(map,d, [&] (Edge it)
{ {
...@@ -86,8 +84,6 @@ typename V_ATT::DATA_TYPE faceCentroid(typename PFP::MAP& map, Face f, const V_A ...@@ -86,8 +84,6 @@ typename V_ATT::DATA_TYPE faceCentroid(typename PFP::MAP& map, Face f, const V_A
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) ;
foreach_incident2<VERTEX>(map, f, [&](Vertex it) foreach_incident2<VERTEX>(map, f, [&](Vertex it)
{ {
center += attributs[it]; center += attributs[it];
...@@ -105,8 +101,6 @@ typename V_ATT::DATA_TYPE faceCentroidELW(typename PFP::MAP& map, Face f, const ...@@ -105,8 +101,6 @@ typename V_ATT::DATA_TYPE faceCentroidELW(typename PFP::MAP& map, Face f, const
EMB center(0.0); EMB center(0.0);
double count=0.0; double count=0.0;
// Traversor2FE<typename PFP::MAP> t(map, d) ;
foreach_incident2<EDGE>(map, f, [&](Edge it) foreach_incident2<EDGE>(map, f, [&](Edge it)
{ {
EMB e1 = attributs[it.dart]; EMB e1 = attributs[it.dart];
...@@ -138,6 +132,12 @@ typename V_ATT::DATA_TYPE vertexNeighborhoodCentroid(typename PFP::MAP& map, Ver ...@@ -138,6 +132,12 @@ typename V_ATT::DATA_TYPE vertexNeighborhoodCentroid(typename PFP::MAP& map, Ver
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)
{ {
if ((CGoGN::Parallel::NumberOfThreads > 1) && (thread==0))
{
Parallel::computeCentroidFaces<PFP,V_ATT,F_ATT>(map,position,face_centroid);
return;
}
foreach_cell<FACE>(map, [&] (Face f) foreach_cell<FACE>(map, [&] (Face f)
{ {
face_centroid[f] = faceCentroid<PFP,V_ATT>(map, f, position) ; face_centroid[f] = faceCentroid<PFP,V_ATT>(map, f, position) ;
...@@ -148,6 +148,12 @@ void computeCentroidFaces(typename PFP::MAP& map, const V_ATT& position, F_ATT& ...@@ -148,6 +148,12 @@ void computeCentroidFaces(typename PFP::MAP& map, const V_ATT& position, F_ATT&
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)
{ {
if ((CGoGN::Parallel::NumberOfThreads > 1) && (thread==0))
{
Parallel::computeCentroidELWFaces<PFP,V_ATT,F_ATT>(map,position,face_centroid);
return;
}
foreach_cell<FACE>(map, [&] (Face f) foreach_cell<FACE>(map, [&] (Face f)
{ {
face_centroid[f] = faceCentroidELW<PFP,V_ATT>(map, f, position) ; face_centroid[f] = faceCentroidELW<PFP,V_ATT>(map, f, position) ;
...@@ -158,6 +164,12 @@ void computeCentroidELWFaces(typename PFP::MAP& map, const V_ATT& position, F_AT ...@@ -158,6 +164,12 @@ void computeCentroidELWFaces(typename PFP::MAP& map, const V_ATT& position, F_AT
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)
{ {
if ((CGoGN::Parallel::NumberOfThreads > 1) && (thread==0))
{
Parallel::computeNeighborhoodCentroidVertices<PFP,V_ATT>(map,position,vertex_centroid);
return;
}
foreach_cell<VERTEX>(map, [&] (Vertex v) foreach_cell<VERTEX>(map, [&] (Vertex v)
{ {
vertex_centroid[v] = vertexNeighborhoodCentroid<PFP,V_ATT>(map, v, position) ; vertex_centroid[v] = vertexNeighborhoodCentroid<PFP,V_ATT>(map, v, position) ;
...@@ -170,35 +182,32 @@ namespace Parallel ...@@ -170,35 +182,32 @@ namespace Parallel
{ {
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, void computeCentroidFaces(typename PFP::MAP& map, const V_ATT& position, F_ATT& face_centroid)
unsigned int nbth)
{ {
CGoGN::Parallel::foreach_cell<FACE>(map,[&](Face f, unsigned int thr) CGoGN::Parallel::foreach_cell<FACE>(map,[&](Face f, unsigned int thr)
{ {
face_centroid[f] = faceCentroid<PFP>(map, f, position) ; face_centroid[f] = faceCentroid<PFP>(map, f, position) ;
},nbth,false,AUTO); },false,AUTO);
} }