Improved documentation for the Foreach Helpers
This commit is contained in:
parent
c71321a3b6
commit
eddd63caea
|
@ -50,39 +50,86 @@ inline void ForEachFacePos(MeshType &m, std::function<void (typename face::Pos<t
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ForEachFace Helper
|
||||||
|
* to traverse all the faces of a mesh you can simply write something like:
|
||||||
|
*
|
||||||
|
* ForEachFace(m, [&](const FaceType &f){
|
||||||
|
* MakeSomethingWithFace(f);
|
||||||
|
* });
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
template <class MeshType>
|
template <class MeshType>
|
||||||
inline void ForEachFace(const MeshType &m, std::function<void (const typename MeshType::FaceType &)> action)
|
inline void ForEachFace(const MeshType &m, std::function<void (const typename MeshType::FaceType &)> action)
|
||||||
{
|
{
|
||||||
|
if(m.fn == (int) m.face.size())
|
||||||
|
{
|
||||||
|
for(auto fi=m.face.begin();fi!=m.face.end();++fi) {
|
||||||
|
action(*fi);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
for(auto fi=m.face.begin();fi!=m.face.end();++fi)
|
for(auto fi=m.face.begin();fi!=m.face.end();++fi)
|
||||||
if(!(*fi).IsD())
|
if(!(*fi).IsD())
|
||||||
{
|
{
|
||||||
action(*fi);
|
action(*fi);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class MeshType>
|
template <class MeshType>
|
||||||
inline void ForEachFace(MeshType &m, std::function<void (typename MeshType::FaceType &)> action)
|
inline void ForEachFace(const MeshType &m, std::function<void (typename MeshType::FaceType &)> action)
|
||||||
{
|
{
|
||||||
|
if(m.fn == (int) m.face.size())
|
||||||
|
{
|
||||||
|
for(auto fi=m.face.begin();fi!=m.face.end();++fi) {
|
||||||
|
action(*fi);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
for(auto fi=m.face.begin();fi!=m.face.end();++fi)
|
for(auto fi=m.face.begin();fi!=m.face.end();++fi)
|
||||||
if(!(*fi).IsD())
|
if(!(*fi).IsD())
|
||||||
{
|
{
|
||||||
action(*fi);
|
action(*fi);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ForEachVertex Helper
|
||||||
|
* to traverse all the vertexes of a mesh you can simply write something like:
|
||||||
|
*
|
||||||
|
* ForEachVertex(m, [&](const VertexType &v){
|
||||||
|
* MakeSomethingWithVertex(v);
|
||||||
|
* });
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
template <class MeshType>
|
template <class MeshType>
|
||||||
inline void forEachVertex(MeshType &m, std::function<void (typename MeshType::FaceType &)> action)
|
inline void ForEachVertex(MeshType &m, std::function<void (typename MeshType::VertexType &)> action)
|
||||||
{
|
{
|
||||||
for(auto fi=m.face.begin();fi!=m.face.end();++fi)
|
if(m.vn == (int) m.vert.size())
|
||||||
if(!(*fi).IsD())
|
{
|
||||||
{
|
for(auto vi=m.vert.begin();vi!=m.vert.end();++vi) {
|
||||||
action(*fi);
|
action(*vi);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for(auto vi=m.vert.begin();vi!=m.vert.end();++vi)
|
||||||
|
if(!(*vi).IsD())
|
||||||
|
{
|
||||||
|
action(*vi);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/** @} */ // end doxygen group trimesh
|
/** @} */ // end doxygen group trimesh
|
||||||
} // end namespace tri
|
} // end namespace tri
|
||||||
} // end namespace vcg
|
} // end namespace vcg
|
||||||
|
|
Loading…
Reference in New Issue