From 478846c310e9b801fa105569d254e5471545a0fa Mon Sep 17 00:00:00 2001 From: kimmi Date: Tue, 20 Mar 2012 20:52:28 +0000 Subject: [PATCH] =?UTF-8?q?Bugfix=20:=20Cleaned=20up=20code=20and=20remove?= =?UTF-8?q?d=20const=5Fcast=20in=20DXFImporter::ConvertMeshes.=20(=20merge?= =?UTF-8?q?d=20from=20GitHub,=20thanks=20to=20Riku=20Palom=C3=A4ki=20).?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@1219 67173fc5-114c-0410-ac8e-9d2fd5bffc1f --- code/DXFLoader.cpp | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/code/DXFLoader.cpp b/code/DXFLoader.cpp index 2aa2c4251..274b8ef79 100644 --- a/code/DXFLoader.cpp +++ b/code/DXFLoader.cpp @@ -220,20 +220,21 @@ void DXFImporter::ConvertMeshes(aiScene* pScene, DXF::FileData& output) throw DeadlyImportError("DXF: no data blocks loaded"); } + DXF::Block* entities = 0; + // index blocks by name DXF::BlockMap blocks_by_name; - BOOST_FOREACH (const DXF::Block& bl, output.blocks) { + BOOST_FOREACH (DXF::Block& bl, output.blocks) { blocks_by_name[bl.name] = &bl; + if ( !entities && bl.name == AI_DXF_ENTITIES_MAGIC_BLOCK ) { + entities = &bl; + } } - const DXF::BlockMap::iterator bit = blocks_by_name.find(AI_DXF_ENTITIES_MAGIC_BLOCK); - if (bit == blocks_by_name.end()) { + if (!entities) { throw DeadlyImportError("DXF: no ENTITIES data block loaded"); } - // ENTITIES is currently the only block that needs to be modified, - // this is the reason that blocks_by_name stores const by default. - DXF::Block& entities = const_cast( *(*bit).second ); typedef std::map LayerMap; LayerMap layers; @@ -241,10 +242,10 @@ void DXFImporter::ConvertMeshes(aiScene* pScene, DXF::FileData& output) // now expand all block references in the primary ENTITIES block // XXX this involves heavy memory copying, consider a faster solution for future versions. - ExpandBlockReferences(entities,blocks_by_name); + ExpandBlockReferences(*entities,blocks_by_name); unsigned int cur = 0; - BOOST_FOREACH (boost::shared_ptr pl, entities.lines) { + BOOST_FOREACH (boost::shared_ptr pl, entities->lines) { if (pl->positions.size()) { std::map::iterator it = layers.find(pl->layer);