Added ForEachEdge helper

This commit is contained in:
Paolo Cignoni 2017-09-05 00:36:53 +02:00
parent d1a63e73be
commit a8220b3bda
1 changed files with 28 additions and 0 deletions

View File

@ -127,6 +127,34 @@ inline void ForEachVertex(MeshType &m, std::function<void (typename MeshType::Ve
}
}
/**
* ForEachEdge Helper
* to traverse all the vertexes of a mesh you can simply write something like:
*
* ForEachEdge(m, [&](const EdgeType &e){
* MakeSomethingWithEdge(e);
* });
*
*/
template <class MeshType>
inline void ForEachEdge(MeshType &m, std::function<void (typename MeshType::EdgeType &)> action)
{
if(m.en == (int) m.edge.size())
{
for(auto ei=m.edge.begin();ei!=m.edge.end();++ei) {
action(*ei);
}
}
else
{
for(auto ei=m.edge.begin();ei!=m.edge.end();++ei)
if(!(*ei).IsD())
{
action(*ei);
}
}
}