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)
case'Z':
{
Utils::Chrono ch;
ch.start();
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;
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();
for (unsigned int i=0; i<4; ++i)
Parallel::foreach_cell<VERTEX>(myMap,[&](Vertex v, unsigned int th)
{
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;
......
......@@ -498,8 +498,6 @@ int main(int argc, char **argv)
Utils::Chrono ch;
Vertex v(myMap.begin());
VEC3 p = Algo::Volume::Geometry::vertexNeighborhoodCentroid<PFP>(myMap,v,position);
......@@ -529,7 +527,6 @@ int main(int argc, char **argv)
vol += Algo::Geometry::totalVolume<PFP>(myMap, position);
std::cout << ch.elapsed()<< " ms val="<<vol<< std::endl;
// et on attend la fin.
return app.exec();
}
......@@ -114,7 +114,7 @@ int main()
{
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) !!!!
},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;
......@@ -127,17 +127,22 @@ int main()
// Example with // accumulation
// 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
float surf[4]={0.0f,0.0f,0.0f,0.0f};
float surf[3]={0.0f,0.0f,0.0f};
// traverse face in //
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);
},4,false);
},false);
std::cout << surf[0]<< "/"<< surf[1]<< "/"<< surf[2]<< "/"<< surf[3]<< "/"<< std::endl;
std::cout << "Total="<<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]<< std::endl;
TraversorV<MAP> tv0(myMap);
......
......@@ -86,6 +86,21 @@ void computeBarycentricAreaVertices(typename PFP::MAP& map, const VertexAttribut
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) ;
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 Surface
......
......@@ -76,8 +76,6 @@ typename PFP::REAL totalArea(typename PFP::MAP& map, const VertexAttribute<typen
{
typename PFP::REAL area(0) ;
// TraversorF<typename PFP::MAP> t(map) ;
foreach_cell<FACE>(map, [&] (Face f)
{
area += convexFaceArea<PFP>(map, f, position);
......@@ -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 area(0) ;
// Traversor2VF<typename PFP::MAP> t(map, d) ;
foreach_incident2<FACE>(map, v, [&] (Face f)
{
......@@ -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 area(0) ;
// Traversor2VF<typename PFP::MAP> t(map, v) ;
foreach_incident2<FACE>(map, v, [&] (Face f)
{
......@@ -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 area(0) ;
// Traversor2VF<typename PFP::MAP> t(map, v) ;
foreach_incident2<FACE>(map, v, [&] (Face it)
{
const typename PFP::VEC3& p1 = position[it] ;
......@@ -144,9 +139,12 @@ typename PFP::REAL vertexVoronoiArea(typename PFP::MAP& map, Vertex v, const Ver
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)
{
// TraversorF<typename PFP::MAP> t(map) ;
// for(Dart d = t.begin(); d != t.end(); d = t.next())
// face_area[d] = convexFaceArea<PFP>(map, d, position) ;
if ((CGoGN::Parallel::NumberOfThreads > 1) && (thread==0))
{
Parallel::computeAreaFaces<PFP>(map,position,face_area);
return;
}
foreach_cell<FACE>(map, [&] (Face f)
{
......@@ -159,6 +157,12 @@ void computeAreaFaces(typename PFP::MAP& map, const VertexAttribute<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)
{
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);
computeAreaFaces<PFP>(map,position,areas);
......@@ -177,7 +181,12 @@ void computeOneRingAreaVertices(typename PFP::MAP& map, const VertexAttribute<ty
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)
{
// 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)
{
vertex_area[v] = vertexBarycentricArea<PFP>(map, v, position) ;
......@@ -188,7 +197,12 @@ void computeBarycentricAreaVertices(typename PFP::MAP& map, const VertexAttribut
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)
{
// 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)
{
vertex_area[v] = vertexVoronoiArea<PFP>(map, v, position) ;
......@@ -202,7 +216,7 @@ 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, 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>())
// {
......@@ -219,31 +233,39 @@ void computeAreaFaces(typename PFP::MAP& map, const VertexAttribute<typename PFP
// },nbth,false,AUTO);
// }
// TODO A REMPLACER QUAND PLGTS CHANGES
CGoGN::Parallel::foreach_cell<FACE>(map,[&](Face f, unsigned int thr)
{
area[f] = convexFaceArea<PFP>(map, f, position) ;
},nbth,false,AUTO);
},false,AUTO);
}
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)
{
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>
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)
{
area[v] = vertexVoronoiArea<PFP>(map, v, position) ;
},nbth,false,FORCE_CELL_MARKING);
},false,FORCE_CELL_MARKING);
}
} // namespace Parallel
......
......@@ -140,36 +140,30 @@ namespace Parallel
* @param map the map
* @param position position vertex attribute
* @param face_centroid centroid face attribute
* @param nbth the number of threads
*/
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 nbth = 0) ;
const V_ATT& position, F_ATT& face_centroid) ;
/**
* Compute centroid of all faces (Edge Length Weighted)
* @param map the map
* @param position position vertex attribute
* @param face_centroid centroid face attribute
* @param nbth the number of threads
*/
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 nbth = 0) ;
const V_ATT& position, F_ATT& face_centroid) ;
/**
* Compute neighborhood centroid of all vertices (in parallel)
* @param map the map
* @param position position vertex attribute
* @param vertex_centroid centroid vertex attribute
* @param nbth the number of threads
*/
template <typename PFP, typename V_ATT>
void computeNeighborhoodCentroidVertices(typename PFP::MAP& map,
const V_ATT& position, V_ATT& vertex_centroid,
unsigned int nbth = 0) ;
const V_ATT& position, V_ATT& vertex_centroid) ;
} // namespace Parallel
......@@ -224,20 +218,17 @@ namespace Parallel
template <typename PFP, typename V_ATT, typename W_ATT>
void computeCentroidVolumes(typename PFP::MAP& map,
const V_ATT& position, W_ATT& vol_centroid,
unsigned int nbth = 0) ;
const V_ATT& position, W_ATT& vol_centroid) ;
template <typename PFP, typename V_ATT, typename W_ATT>
void computeCentroidELWVolumes(typename PFP::MAP& map,
const V_ATT& position, W_ATT& vol_centroid,
unsigned int nbth = 0) ;
const V_ATT& position, W_ATT& vol_centroid) ;
template <typename PFP, typename V_ATT>
void computeNeighborhoodCentroidVertices(typename PFP::MAP& map,
const V_ATT& position, V_ATT& vertex_centroid,
unsigned int nbth = 0) ;
const V_ATT& position, V_ATT& vertex_centroid) ;
} // namespace Parallel
......
......@@ -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);
unsigned int count = 0 ;
// Traversor3WV<typename PFP::MAP> tra(map,d,false,thread);
foreach_incident3<VERTEX>(map,d, [&] (Vertex v)
{
......@@ -66,7 +65,6 @@ typename V_ATT::DATA_TYPE volumeCentroidELW(typename PFP::MAP& map, Vol d, const
EMB center(0.0);
double count=0.0;
// Traversor3WE<typename PFP::MAP> t(map, d,false,thread) ;
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
typename V_ATT::DATA_TYPE center(0.0);
unsigned int count = 0 ;
// Traversor2FV<typename PFP::MAP> t(map, d) ;
foreach_incident2<VERTEX>(map, f, [&](Vertex it)
{
center += attributs[it];
......@@ -105,8 +101,6 @@ typename V_ATT::DATA_TYPE faceCentroidELW(typename PFP::MAP& map, Face f, const
EMB center(0.0);
double count=0.0;
// Traversor2FE<typename PFP::MAP> t(map, d) ;
foreach_incident2<EDGE>(map, f, [&](Edge it)
{
EMB e1 = attributs[it.dart];
......@@ -138,6 +132,12 @@ typename V_ATT::DATA_TYPE vertexNeighborhoodCentroid(typename PFP::MAP& map, Ver
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)
{
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)
{
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&
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)
{
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)
{
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
template <typename PFP, typename V_ATT>
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)
{
vertex_centroid[v] = vertexNeighborhoodCentroid<PFP,V_ATT>(map, v, position) ;
......@@ -170,35 +182,32 @@ namespace Parallel
{
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 nbth)
void computeCentroidFaces(typename PFP::MAP& map, const V_ATT& position, F_ATT& face_centroid)
{
CGoGN::Parallel::foreach_cell<FACE>(map,[&](Face f, unsigned int thr)
{
face_centroid[f] = faceCentroid<PFP>(map, f, position) ;
},nbth,false,AUTO);
},false,AUTO);
}
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 nbth, unsigned int current_thread)
void computeCentroidELWFaces(typename PFP::MAP& map, const V_ATT& position, F_ATT& face_centroid)
{
CGoGN::Parallel::foreach_cell<FACE>(map,[&](Face f, unsigned int thr)
{
face_centroid[f] = faceCentroidELW<PFP>(map, f, position) ;
},nbth,false,AUTO);
},false,AUTO);
}
template <typename PFP, typename V_ATT>
void computeNeighborhoodCentroidVertices(typename PFP::MAP& map,
const V_ATT& position, V_ATT& vertex_centroid,
unsigned int nbth, unsigned int current_thread)
const V_ATT& position, V_ATT& vertex_centroid)
{
CGoGN::Parallel::foreach_cell<VERTEX>(map,[&](Vertex v, unsigned int thr)
{
vertex_centroid[v] = vertexNeighborhoodCentroid<PFP>(map, v, position) ;
},nbth,false,FORCE_CELL_MARKING);
},false,FORCE_CELL_MARKING);
}
} // namespace Parallel
......@@ -233,6 +242,12 @@ typename V_ATT::DATA_TYPE vertexNeighborhoodCentroid(typename PFP::MAP& map, Ver
template <typename PFP, typename V_ATT, typename W_ATT>
void computeCentroidVolumes(typename PFP::MAP& map, const V_ATT& position, W_ATT& vol_centroid, unsigned int thread)
{
if ((CGoGN::Parallel::NumberOfThreads > 1) && (thread==0))
{
Parallel::computeCentroidVolumes<PFP,V_ATT,W_ATT>(map,position,vol_centroid);
return;
}
foreach_cell<VOLUME>(map, [&] (Vol v)
{
vol_centroid[v] = Surface::Geometry::volumeCentroid<PFP,V_ATT>(map, v, position,thread) ;
......@@ -243,6 +258,12 @@ void computeCentroidVolumes(typename PFP::MAP& map, const V_ATT& position, W_ATT
template <typename PFP, typename V_ATT, typename W_ATT>
void computeCentroidELWVolumes(typename PFP::MAP& map, const V_ATT& position, W_ATT& vol_centroid, unsigned int thread)
{
if ((CGoGN::Parallel::NumberOfThreads > 1) && (thread==0))
{
Parallel::computeCentroidELWVolumes<PFP,V_ATT,W_ATT>(map,position,vol_centroid);
return;
}
foreach_cell<VOLUME>(map, [&] (Vol v)
{
vol_centroid[v] = Surface::Geometry::volumeCentroidELW<PFP,V_ATT>(map, v, position,thread) ;
......@@ -253,6 +274,12 @@ void computeCentroidELWVolumes(typename PFP::MAP& map, const V_ATT& position, W_
template <typename PFP, typename V_ATT>
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)
{
vertex_centroid[v] = Volume::Geometry::vertexNeighborhoodCentroid<PFP,V_ATT>(map, v, position) ;
......@@ -265,34 +292,31 @@ namespace Parallel
{
template <typename PFP, typename V_ATT, typename W_ATT>
void computeCentroidVolumes(typename PFP::MAP& map, const V_ATT& position, W_ATT& vol_centroid, unsigned int nbth)
void computeCentroidVolumes(typename PFP::MAP& map, const V_ATT& position, W_ATT& vol_centroid)
{
CGoGN::Parallel::foreach_cell<VOLUME>(map,[&](Vol v, unsigned int thr)
{
vol_centroid[v] = Surface::Geometry::volumeCentroid<PFP,V_ATT,W_ATT>(map, v, position, thr) ;
},nbth,true,AUTO);
vol_centroid[v] = Surface::Geometry::volumeCentroid<PFP,V_ATT>(map, v, position, thr) ;
},true,AUTO);
}
template <typename PFP, typename V_ATT, typename W_ATT>
void computeCentroidELWVolumes(typename PFP::MAP& map,
const V_ATT& position, W_ATT& vol_centroid,
unsigned int nbth)
void computeCentroidELWVolumes(typename PFP::MAP& map, const V_ATT& position, W_ATT& vol_centroid)
{
CGoGN::Parallel::foreach_cell<VOLUME>(map,[&](Vol v, unsigned int thr)
{
vol_centroid[v] = Surface::Geometry::volumeCentroidELW<PFP,V_ATT>(map, v, position, thr) ;
},nbth,true,AUTO);
},true,AUTO);
}
template <typename PFP, typename V_ATT>
void computeNeighborhoodCentroidVertices(typename PFP::MAP& map, const V_ATT& position, V_ATT& vertex_centroid,
unsigned int nbth)
void computeNeighborhoodCentroidVertices(typename PFP::MAP& map, const V_ATT& position, V_ATT& vertex_centroid)
{
CGoGN::Parallel::foreach_cell<VERTEX>(map,[&](Vertex v, unsigned int thr)
{
vertex_centroid[v] = Volume::Geometry::vertexNeighborhoodCentroid<PFP,V_ATT>(map, v, position,thr) ;
},nbth,true,FORCE_CELL_MARKING);
},true,FORCE_CELL_MARKING);
}
} // namespace Parallel
......
......@@ -260,19 +260,30 @@ void computeCurvatureVertices_NormalCycles(
VertexAttribute<typename PFP::REAL, typename PFP::MAP::IMPL>& kmin,
VertexAttribute<typename PFP::VEC3, typename PFP::MAP::IMPL>& Kmax,
VertexAttribute<typename PFP::VEC3, typename PFP::MAP::IMPL>& Kmin,
VertexAttribute<typename PFP::VEC3, typename PFP::MAP::IMPL>& Knormal,
unsigned int nbth = 0) ;
VertexAttribute<typename PFP::VEC3, typename PFP::MAP::IMPL>& Knormal) ;
template <typename PFP>
void computeCurvatureVertices_QuadraticFitting(
void computeCurvatureVertices_NormalCycles_Projected(
typename PFP::MAP& map,
typename PFP::REAL radius,
const VertexAttribute<typename PFP::VEC3, typename PFP::MAP::IMPL>& position,
const VertexAttribute<typename PFP::VEC3, typename PFP::MAP::IMPL>& normal,
const EdgeAttribute<typename PFP::REAL, typename PFP::MAP::IMPL>& edgeangle,
VertexAttribute<typename PFP::REAL, typename PFP::MAP::IMPL>& kmax,
VertexAttribute<typename PFP::REAL, typename PFP::MAP::IMPL>& kmin,
VertexAttribute<typename PFP::VEC3, typename PFP::MAP::IMPL>& Kmax,
VertexAttribute<typename PFP::VEC3, typename PFP::MAP::IMPL>& Kmin,
unsigned int nbth = 0);
VertexAttribute<typename PFP::VEC3, typename PFP::MAP::IMPL>& Knormal) ;
template <typename PFP>
void computeCurvatureVertices_QuadraticFitting(
typename PFP::MAP& map,
const VertexAttribute<typename PFP::VEC3, typename PFP::MAP::IMPL>& position,
const VertexAttribute<typename PFP::VEC3, typename PFP::MAP::IMPL>& normal,
VertexAttribute<typename PFP::REAL, typename PFP::MAP::IMPL>& kmax,
VertexAttribute<typename PFP::REAL, typename PFP::MAP::IMPL>& kmin,
VertexAttribute<typename PFP::VEC3, typename PFP::MAP::IMPL>& Kmax,
VertexAttribute<typename PFP::VEC3, typename PFP::MAP::IMPL>& Kmin);
} // namespace Parallel
......
......@@ -49,9 +49,22 @@ void computeCurvatureVertices_QuadraticFitting(
VertexAttribute<typename PFP::VEC3, typename PFP::MAP::IMPL>& Kmax,
VertexAttribute<typename PFP::VEC3, typename PFP::MAP::IMPL>& Kmin)
{
TraversorV<typename PFP::MAP> t(map) ;
for(Vertex v = t.begin(); v != t.end(); v = t.next())
if ((CGoGN::Parallel::NumberOfThreads > 1) && (thread==0))
{
Parallel::computeCurvatureVertices_QuadraticFitting<PFP>(map, position, normal, kmax, kmin, Kmax, Kmin);
return;
}
foreach_cell<VERTEX>(map, [&] (Vertex v)
{
computeCurvatureVertex_QuadraticFitting<PFP>(map, v, position, normal, kmax, kmin, Kmax, Kmin) ;
}
,FORCE_CELL_MARKING,thread);
// TraversorV<typename PFP::MAP> t(map) ;
// for(Vertex v = t.begin(); v != t.end(); v = t.next())
// computeCurvatureVertex_QuadraticFitting<PFP>(map, v, position, normal, kmax, kmin, Kmax, Kmin) ;
}
template <typename PFP>
......@@ -300,9 +313,21 @@ void computeCurvatureVertices_NormalCycles(
VertexAttribute<typename PFP::VEC3, typename PFP::MAP::IMPL>& Knormal,
unsigned int thread)
{
TraversorV<typename PFP::MAP> t(map) ;
for(Vertex v = t.begin(); v != t.end(); v = t.next())
if ((CGoGN::Parallel::NumberOfThreads > 1) && (thread==0))
{
Parallel::computeCurvatureVertices_NormalCycles<PFP>(map, radius, position, normal, edgeangle, kmax, kmin, Kmax, Kmin, Knormal);
return;
}
foreach_cell<VERTEX>(map, [&] (Vertex v)
{
computeCurvatureVertex_NormalCycles<PFP>(map, v, radius, position, normal, edgeangle, kmax, kmin, Kmax, Kmin, Knormal,thread) ;
}
,FORCE_CELL_MARKING,thread);
// TraversorV<typename PFP::MAP> t(map) ;
// for(Vertex v = t.begin(); v != t.end(); v = t.next())
// computeCurvatureVertex_NormalCycles<PFP>(map, v, radius, position, normal, edgeangle, kmax, kmin, Kmax, Kmin, Knormal,thread) ;
}
template <typename PFP>
......@@ -365,9 +390,21 @@ void computeCurvatureVertices_NormalCycles_Projected(
VertexAttribute<typename PFP::VEC3, typename PFP::MAP::IMPL>& Knormal,
unsigned int thread)
{
TraversorV<typename PFP::MAP> t(map) ;
for(Vertex v = t.begin(); v.dart != t.end(); v = t.next())
computeCurvatureVertex_NormalCycles_Projected<PFP>(map, v, radius, position, normal, edgeangle, kmax, kmin, Kmax, Kmin, Knormal, thread) ;
if ((CGoGN::Parallel::NumberOfThreads > 1) && (thread==0))
{
Parallel::computeCurvatureVertices_NormalCycles_Projected<PFP>(map, radius, position, normal, edgeangle, kmax, kmin, Kmax, Kmin, Knormal);
return;
}
foreach_cell<VERTEX>(map, [&] (Vertex v)
{
computeCurvatureVertex_NormalCycles_Projected<PFP>(map, v, radius, position, normal, edgeangle, kmax, kmin, Kmax, Kmin, Knormal,thread) ;
}
,FORCE_CELL_MARKING,thread);
// TraversorV<typename PFP::MAP> t(map) ;
// for(Vertex v = t.begin(); v.dart != t.end(); v = t.next())
// computeCurvatureVertex_NormalCycles_Projected<PFP>(map, v, radius, position, normal, edgeangle, kmax, kmin, Kmax, Kmin, Knormal, thread) ;
}
template <typename PFP>
......@@ -613,8 +650,7 @@ void computeCurvatureVertices_NormalCycles(
VertexAttribute<typename PFP::REAL, typename PFP::MAP::IMPL>& kmin,
VertexAttribute<typename PFP::VEC3, typename PFP::MAP::IMPL>& Kmax,
VertexAttribute<typename PFP::VEC3, typename PFP::MAP::IMPL>& Kmin,
VertexAttribute<typename PFP::VEC3, typename PFP::MAP::IMPL>& Knormal,
unsigned int nbth)
VertexAttribute<typename PFP::VEC3, typename PFP::MAP::IMPL>& Knormal)
{
// WAHOO BIG PROBLEM WITH LAZZY EMBEDDING !!!
if (!map.template isOrbitEmbedded<VERTEX>())
......@@ -636,25 +672,62 @@ void computeCurvatureVertices_NormalCycles(
Parallel::foreach_cell<VERTEX>(map,[&](Vertex v, unsigned int threadID)
{
computeCurvatureVertex_NormalCycles<PFP>(map, v, radius, position, normal, edgeangle, kmax, kmin, Kmax, Kmin, Knormal, threadID) ;
},nbth,true,FORCE_CELL_MARKING);
},true,FORCE_CELL_MARKING);
}
template <typename PFP>
void computeCurvatureVertices_QuadraticFitting(
void computeCurvatureVertices_NormalCycles_Projected(
typename PFP::MAP& map,
typename PFP::REAL radius,
const VertexAttribute<typename PFP::VEC3, typename PFP::MAP::IMPL>& position,
const VertexAttribute<typename PFP::VEC3, typename PFP::MAP::IMPL>& normal,
const EdgeAttribute<typename PFP::REAL, typename PFP::MAP::IMPL>& edgeangle,
VertexAttribute<typename PFP::REAL, typename PFP::MAP::IMPL>& kmax,
VertexAttribute<typename PFP::REAL, typename PFP::MAP::IMPL>& kmin,
VertexAttribute<typename PFP::VEC3, typename PFP::MAP::IMPL>& Kmax,
VertexAttribute<typename PFP::VEC3, typename PFP::MAP::IMPL>& Kmin,
unsigned int nbth)
VertexAttribute<typename PFP::VEC3, typename PFP::MAP::IMPL>& Knormal)
{
// WAHOO BIG PROBLEM WITH LAZZY EMBEDDING !!!
if (!map.template isOrbitEmbedded<VERTEX>())
{
CellMarkerNoUnmark<typename PFP::MAP, VERTEX> cm(map);
map.template initAllOrbitsEmbedding<VERTEX>();