Replaced BOOST_FOREACH with c++11 ranged for loops

This commit is contained in:
mensinda
2016-04-05 22:53:54 +02:00
parent 4836a2993e
commit 18843fe5e1
33 changed files with 209 additions and 236 deletions

View File

@@ -54,7 +54,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "LineSplitter.h"
#include "TinyFormatter.h"
#include <boost/scoped_ptr.hpp>
#include <boost/foreach.hpp>
#include "../include/assimp/IOSystem.hpp"
#include "../include/assimp/DefaultLogger.hpp"
#include "../include/assimp/scene.h"
@@ -64,8 +63,6 @@ using namespace Assimp;
using namespace Assimp::COB;
using namespace Assimp::Formatter;
#define for_each BOOST_FOREACH
static const float units[] = {
1000.f,
@@ -170,17 +167,17 @@ void COBImporter::InternReadFile( const std::string& pFile,
}
// sort faces by material indices
for_each(boost::shared_ptr< Node >& n,scene.nodes) {
for(boost::shared_ptr< Node >& n : scene.nodes) {
if (n->type == Node::TYPE_MESH) {
Mesh& mesh = (Mesh&)(*n.get());
for_each(Face& f,mesh.faces) {
for(Face& f : mesh.faces) {
mesh.temp_map[f.material].push_back(&f);
}
}
}
// count meshes
for_each(boost::shared_ptr< Node >& n,scene.nodes) {
for(boost::shared_ptr< Node >& n : scene.nodes) {
if (n->type == Node::TYPE_MESH) {
Mesh& mesh = (Mesh&)(*n.get());
if (mesh.vertex_positions.size() && mesh.texture_coords.size()) {
@@ -193,7 +190,7 @@ void COBImporter::InternReadFile( const std::string& pFile,
pScene->mNumMeshes = 0;
// count lights and cameras
for_each(boost::shared_ptr< Node >& n,scene.nodes) {
for(boost::shared_ptr< Node >& n : scene.nodes) {
if (n->type == Node::TYPE_LIGHT) {
++pScene->mNumLights;
}
@@ -251,10 +248,10 @@ aiNode* COBImporter::BuildNodes(const Node& root,const Scene& scin,aiScene* fill
if (ndmesh.vertex_positions.size() && ndmesh.texture_coords.size()) {
typedef std::pair<unsigned int,Mesh::FaceRefList> Entry;
for_each(const Entry& reflist,ndmesh.temp_map) {
for(const Entry& reflist : ndmesh.temp_map) {
{ // create mesh
size_t n = 0;
for_each(Face* f, reflist.second) {
for(Face* f : reflist.second) {
n += f->indices.size();
}
if (!n) {
@@ -267,7 +264,7 @@ aiNode* COBImporter::BuildNodes(const Node& root,const Scene& scin,aiScene* fill
outmesh->mTextureCoords[0] = new aiVector3D[n];
outmesh->mFaces = new aiFace[reflist.second.size()]();
for_each(Face* f, reflist.second) {
for(Face* f : reflist.second) {
if (f->indices.empty()) {
continue;
}
@@ -275,7 +272,7 @@ aiNode* COBImporter::BuildNodes(const Node& root,const Scene& scin,aiScene* fill
aiFace& fout = outmesh->mFaces[outmesh->mNumFaces++];
fout.mIndices = new unsigned int[f->indices.size()];
for_each(VertexIndex& v, f->indices) {
for(VertexIndex& v : f->indices) {
if (v.pos_idx >= ndmesh.vertex_positions.size()) {
ThrowException("Position index out of range");
}
@@ -295,7 +292,7 @@ aiNode* COBImporter::BuildNodes(const Node& root,const Scene& scin,aiScene* fill
outmesh->mMaterialIndex = fill->mNumMaterials;
}{ // create material
const Material* min = NULL;
for_each(const Material& m, scin.materials) {
for(const Material& m : scin.materials) {
if (m.parent_id == ndmesh.id && m.matnum == reflist.first) {
min = &m;
break;
@@ -396,7 +393,7 @@ aiNode* COBImporter::BuildNodes(const Node& root,const Scene& scin,aiScene* fill
// add children recursively
nd->mChildren = new aiNode*[root.temp_children.size()]();
for_each(const Node* n, root.temp_children) {
for(const Node* n : root.temp_children) {
(nd->mChildren[nd->mNumChildren++] = BuildNodes(*n,scin,fill))->mParent = nd;
}
@@ -647,7 +644,7 @@ void COBImporter::ReadUnit_Ascii(Scene& out, LineSplitter& splitter, const Chunk
// parent chunks preceede their childs, so we should have the
// corresponding chunk already.
for_each(boost::shared_ptr< Node >& nd, out.nodes) {
for(boost::shared_ptr< Node >& nd : out.nodes) {
if (nd->id == nfo.parent_id) {
const unsigned int t=strtoul10(splitter[1]);
@@ -903,7 +900,7 @@ void COBImporter::ReadBitM_Ascii(Scene& /*out*/, LineSplitter& splitter, const C
void COBImporter::ReadString_Binary(std::string& out, StreamReaderLE& reader)
{
out.resize( reader.GetI2());
for_each(char& c,out) {
for(char& c : out) {
c = reader.GetI1();
}
}
@@ -1043,14 +1040,14 @@ void COBImporter::ReadPolH_Binary(COB::Scene& out, StreamReaderLE& reader, const
ReadBasicNodeInfo_Binary(msh,reader,nfo);
msh.vertex_positions.resize(reader.GetI4());
for_each(aiVector3D& v,msh.vertex_positions) {
for(aiVector3D& v : msh.vertex_positions) {
v.x = reader.GetF4();
v.y = reader.GetF4();
v.z = reader.GetF4();
}
msh.texture_coords.resize(reader.GetI4());
for_each(aiVector2D& v,msh.texture_coords) {
for(aiVector2D& v : msh.texture_coords) {
v.x = reader.GetF4();
v.y = reader.GetF4();
}
@@ -1283,7 +1280,7 @@ void COBImporter::ReadUnit_Binary(COB::Scene& out, StreamReaderLE& reader, const
// parent chunks preceede their childs, so we should have the
// corresponding chunk already.
for_each(boost::shared_ptr< Node >& nd, out.nodes) {
for(boost::shared_ptr< Node >& nd : out.nodes) {
if (nd->id == nfo.parent_id) {
const unsigned int t=reader.GetI2();
nd->unit_scale = t>=sizeof(units)/sizeof(units[0])?(