From b392322454c22e849ef830c41ae8b448aba6c291 Mon Sep 17 00:00:00 2001 From: Alexander Gessler Date: Tue, 25 Jun 2013 00:12:03 +0200 Subject: [PATCH 1/5] Remove M3Importer from vc9 solution. --- workspaces/vc9/assimp.vcproj | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/workspaces/vc9/assimp.vcproj b/workspaces/vc9/assimp.vcproj index af1b89e63..724944074 100644 --- a/workspaces/vc9/assimp.vcproj +++ b/workspaces/vc9/assimp.vcproj @@ -2044,18 +2044,6 @@ > - - - - - - From 31311bdb3b0a3b7de49bc3b9904abf3f658ee133 Mon Sep 17 00:00:00 2001 From: Alexander Gessler Date: Tue, 25 Jun 2013 00:22:47 +0200 Subject: [PATCH 2/5] IFC: support reading from IFCZip archives that don't use the same name for the embedded IFC file as the ZIP itself. --- code/IFCLoader.cpp | 51 ++++++++++++++++++++++++++++++---------------- 1 file changed, 33 insertions(+), 18 deletions(-) diff --git a/code/IFCLoader.cpp b/code/IFCLoader.cpp index cca41f4a2..0af15228c 100644 --- a/code/IFCLoader.cpp +++ b/code/IFCLoader.cpp @@ -192,29 +192,44 @@ void IFCImporter::InternReadFile( const std::string& pFile, } // search file (same name as the IFCZIP except for the file extension) and place file pointer there - if ( unzLocateFile( zip, fileName.c_str(), 0 ) == UNZ_OK ) - { - // get file size, etc. - unz_file_info fileInfo; - unzGetCurrentFileInfo( zip , &fileInfo, 0, 0, 0, 0, 0, 0 ); + + if(UNZ_OK == unzGoToFirstFile(zip)) { + do { + // - uint8_t* buff = new uint8_t[fileInfo.uncompressed_size]; + // get file size, etc. + unz_file_info fileInfo; + char filename[256]; + unzGetCurrentFileInfo( zip , &fileInfo, filename, sizeof(filename), 0, 0, 0, 0 ); + + if (GetExtension(filename) != "ifc") { + continue; + } - LogInfo("Decompressing IFCZIP file"); + uint8_t* buff = new uint8_t[fileInfo.uncompressed_size]; - unzOpenCurrentFile( zip ); - const int ret = unzReadCurrentFile( zip, buff, fileInfo.uncompressed_size); - size_t filesize = fileInfo.uncompressed_size; - if ( ret < 0 || size_t(ret) != filesize ) - { - delete[] buff; - ThrowException("Failed to decompress IFC ZIP file"); - } - unzCloseCurrentFile( zip ); - stream.reset(new MemoryIOStream(buff,fileInfo.uncompressed_size,true)); + LogInfo("Decompressing IFCZIP file"); + + unzOpenCurrentFile( zip ); + const int ret = unzReadCurrentFile( zip, buff, fileInfo.uncompressed_size); + size_t filesize = fileInfo.uncompressed_size; + if ( ret < 0 || size_t(ret) != filesize ) + { + delete[] buff; + ThrowException("Failed to decompress IFC ZIP file"); + } + unzCloseCurrentFile( zip ); + stream.reset(new MemoryIOStream(buff,fileInfo.uncompressed_size,true)); + break; + + if (unzGoToNextFile(zip) == UNZ_END_OF_LIST_OF_FILE) { + ThrowException("Found no IFC file member in IFCZIP file (1)"); + } + + } while(true); } else { - ThrowException("Found no IFC file member in IFCZIP file"); + ThrowException("Found no IFC file member in IFCZIP file (2)"); } unzClose(zip); From 34d2bdd17867c4482afcee906da86abe0e083401 Mon Sep 17 00:00:00 2001 From: Alexander Gessler Date: Tue, 25 Jun 2013 14:09:28 +0200 Subject: [PATCH 3/5] Exporters: raise errors if output files cannot be opened. --- code/ColladaExporter.cpp | 3 +++ code/ObjExporter.cpp | 6 ++++++ code/PlyExporter.cpp | 4 ++++ code/STLExporter.cpp | 4 ++++ 4 files changed, 17 insertions(+) diff --git a/code/ColladaExporter.cpp b/code/ColladaExporter.cpp index 763480650..19f86fcf8 100644 --- a/code/ColladaExporter.cpp +++ b/code/ColladaExporter.cpp @@ -58,6 +58,9 @@ void ExportSceneCollada(const char* pFile,IOSystem* pIOSystem, const aiScene* pS // we're still here - export successfully completed. Write result to the given IOSYstem boost::scoped_ptr outfile (pIOSystem->Open(pFile,"wt")); + if(outfile == NULL) { + throw DeadlyExportError("could not open output .dae file: " + std::string(pFile)); + } // XXX maybe use a small wrapper around IOStream that behaves like std::stringstream in order to avoid the extra copy. outfile->Write( iDoTheExportThing.mOutput.str().c_str(), static_cast(iDoTheExportThing.mOutput.tellp()),1); diff --git a/code/ObjExporter.cpp b/code/ObjExporter.cpp index 4bd65a338..9ac902ee3 100644 --- a/code/ObjExporter.cpp +++ b/code/ObjExporter.cpp @@ -59,10 +59,16 @@ void ExportSceneObj(const char* pFile,IOSystem* pIOSystem, const aiScene* pScene // we're still here - export successfully completed. Write both the main OBJ file and the material script { boost::scoped_ptr outfile (pIOSystem->Open(pFile,"wt")); + if(outfile == NULL) { + throw DeadlyExportError("could not open output .obj file: " + std::string(pFile)); + } outfile->Write( exporter.mOutput.str().c_str(), static_cast(exporter.mOutput.tellp()),1); } { boost::scoped_ptr outfile (pIOSystem->Open(exporter.GetMaterialLibFileName(),"wt")); + if(outfile == NULL) { + throw DeadlyExportError("could not open output .mtl file: " + std::string(exporter.GetMaterialLibFileName())); + } outfile->Write( exporter.mOutputMat.str().c_str(), static_cast(exporter.mOutputMat.tellp()),1); } } diff --git a/code/PlyExporter.cpp b/code/PlyExporter.cpp index df06175d2..257e6f1f7 100644 --- a/code/PlyExporter.cpp +++ b/code/PlyExporter.cpp @@ -57,6 +57,10 @@ void ExportScenePly(const char* pFile,IOSystem* pIOSystem, const aiScene* pScene // we're still here - export successfully completed. Write the file. boost::scoped_ptr outfile (pIOSystem->Open(pFile,"wt")); + if(outfile == NULL) { + throw DeadlyExportError("could not open output .ply file: " + std::string(pFile)); + } + outfile->Write( exporter.mOutput.str().c_str(), static_cast(exporter.mOutput.tellp()),1); } diff --git a/code/STLExporter.cpp b/code/STLExporter.cpp index b71cea66e..521f28ae3 100644 --- a/code/STLExporter.cpp +++ b/code/STLExporter.cpp @@ -57,6 +57,10 @@ void ExportSceneSTL(const char* pFile,IOSystem* pIOSystem, const aiScene* pScene // we're still here - export successfully completed. Write the file. boost::scoped_ptr outfile (pIOSystem->Open(pFile,"wt")); + if(outfile == NULL) { + throw DeadlyExportError("could not open output .stl file: " + std::string(pFile)); + } + outfile->Write( exporter.mOutput.str().c_str(), static_cast(exporter.mOutput.tellp()),1); } From b597ebbe430289649978e1e218f0c355a7003d55 Mon Sep 17 00:00:00 2001 From: Alexander Gessler Date: Tue, 25 Jun 2013 16:39:40 +0200 Subject: [PATCH 4/5] Change spec of obj exporter. --- code/Exporter.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/code/Exporter.cpp b/code/Exporter.cpp index 7d0f0e895..3b2badab7 100644 --- a/code/Exporter.cpp +++ b/code/Exporter.cpp @@ -85,7 +85,8 @@ Exporter::ExportFormatEntry gExporters[] = #endif #ifndef ASSIMP_BUILD_NO_OBJ_EXPORTER - Exporter::ExportFormatEntry( "obj", "Wavefront OBJ format", "obj", &ExportSceneObj), + Exporter::ExportFormatEntry( "obj", "Wavefront OBJ format", "obj", &ExportSceneObj, + aiProcess_GenNormals | aiProcess_PreTransformVertices), #endif #ifndef ASSIMP_BUILD_NO_STL_EXPORTER From 506d3fa1543d19d4a141760be0367e5fcc97be68 Mon Sep 17 00:00:00 2001 From: Alexander Gessler Date: Sun, 30 Jun 2013 16:25:46 +0200 Subject: [PATCH 5/5] Forward declare IOSystem in Exporter.hpp --- include/assimp/Exporter.hpp | 1 + 1 file changed, 1 insertion(+) diff --git a/include/assimp/Exporter.hpp b/include/assimp/Exporter.hpp index 30db01508..20cd7dc6e 100644 --- a/include/assimp/Exporter.hpp +++ b/include/assimp/Exporter.hpp @@ -51,6 +51,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. namespace Assimp { class ExporterPimpl; + class IOSystem; // ----------------------------------------------------------------------------------