1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
|
/////////////////////////////////////////////////////////////
// //
// Copyright (c) 2003-2014 by The University of Queensland //
// Centre for Geoscience Computing //
// http://earth.uq.edu.au/centre-geoscience-computing //
// //
// Primary Business: Brisbane, Queensland, Australia //
// Licensed under the Open Software License version 3.0 //
// http://www.apache.org/licenses/LICENSE-2.0 //
// //
/////////////////////////////////////////////////////////////
#include <utility>
using std::make_pair;
/*!
Call a constant member function of Triangle taking no argument and returning a
value for all Triangles and collect the return values in a container. The
container has to be an STL sequence container (vector,list...) or something
with the same interface. The template parameter P is a type of container of
the return type of the particle member function, not the return type itself.
\param cont the container
\param rdf the particle member function
*/
template <typename P>
void TriMesh::forAllTrianglesGet(P& cont,typename P::value_type (Triangle::*rdf)() const)
{
for(vector<Triangle>::iterator iter=m_triangles.begin();
iter!=m_triangles.end();
iter++){
cont.push_back(((*iter).*rdf)());
}
}
/*!
\param rdf the particle member function
*/
template <typename P>
vector<pair<int,P> > TriMesh::forAllTrianglesGetIndexed(P (Triangle::*rdf)() const)
{
vector<pair<int,P> > res;
for(vector<Triangle>::iterator iter=m_triangles.begin();
iter!=m_triangles.end();
iter++){
res.push_back(make_pair(iter->getID(),((*iter).*rdf)()));
}
return res;
}
|