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/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); 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/ObjFileData.h b/code/ObjFileData.h old mode 100644 new mode 100755 index 905f69346..4331a7d10 --- a/code/ObjFileData.h +++ b/code/ObjFileData.h @@ -283,6 +283,7 @@ struct Model m_pCurrent(NULL), m_pCurrentMaterial(NULL), m_pDefaultMaterial(NULL), + m_pGroupFaceIDs(NULL), m_strActiveGroup(""), m_pCurrentMesh(NULL) { diff --git a/code/ObjFileParser.cpp b/code/ObjFileParser.cpp index 5dcdf4b9a..83f25c40a 100644 --- a/code/ObjFileParser.cpp +++ b/code/ObjFileParser.cpp @@ -528,18 +528,12 @@ int ObjFileParser::getMaterialIndex( const std::string &strMaterialName ) // Getter for a group name. void ObjFileParser::getGroupName() { - // Get next word from data buffer - m_DataIt = getNextToken(m_DataIt, m_DataItEnd); - m_DataIt = getNextWord(m_DataIt, m_DataItEnd); + std::string strGroupName; + + m_DataIt = getName(m_DataIt, m_DataItEnd, strGroupName); if ( isEndOfBuffer( m_DataIt, m_DataItEnd ) ) return; - // Store the group name in the group library - char *pStart = &(*m_DataIt); - while ( m_DataIt != m_DataItEnd && !isSeparator(*m_DataIt) ) - m_DataIt++; - std::string strGroupName( pStart, &(*m_DataIt) ); - // Change active group, if necessary if ( m_pModel->m_strActiveGroup != strGroupName ) { 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); } diff --git a/include/assimp/mesh.h b/include/assimp/mesh.h index 449451632..01d5baf7c 100644 --- a/include/assimp/mesh.h +++ b/include/assimp/mesh.h @@ -135,8 +135,9 @@ struct aiFace //! Default constructor aiFace() + : mNumIndices( 0 ) + , mIndices( NULL ) { - mNumIndices = 0; mIndices = NULL; } //! Default destructor. Delete the index array @@ -147,13 +148,13 @@ struct aiFace //! Copy constructor. Copy the index array aiFace( const aiFace& o) + : mIndices( NULL ) { - mIndices = NULL; *this = o; } //! Assignment operator. Copy the index array - const aiFace& operator = ( const aiFace& o) + aiFace& operator = ( const aiFace& o) { if (&o == this) return *this; @@ -248,17 +249,17 @@ struct aiBone //! Default constructor aiBone() + : mNumWeights( 0 ) + , mWeights( NULL ) { - mNumWeights = 0; mWeights = NULL; } //! Copy constructor aiBone(const aiBone& other) + : mName( other.mName ) + , mNumWeights( other.mNumWeights ) + , mOffsetMatrix( other.mOffsetMatrix ) { - mNumWeights = other.mNumWeights; - mOffsetMatrix = other.mOffsetMatrix; - mName = other.mName; - if (other.mWeights && other.mNumWeights) { mWeights = new aiVertexWeight[mNumWeights]; @@ -378,10 +379,10 @@ struct aiAnimMesh #ifdef __cplusplus aiAnimMesh() - : mVertices() - , mNormals() - , mTangents() - , mBitangents() + : mVertices( NULL ) + , mNormals( NULL ) + , mTangents( NULL ) + , mBitangents( NULL ) , mNumVertices( 0 ) { // fixme consider moving this to the ctor initializer list as well @@ -610,29 +611,28 @@ struct aiMesh //! Default constructor. Initializes all members to 0 aiMesh() + : mPrimitiveTypes( 0 ) + , mNumVertices( 0 ) + , mNumFaces( 0 ) + , mVertices( NULL ) + , mNormals( NULL ) + , mTangents( NULL ) + , mBitangents( NULL ) + , mFaces( NULL ) + , mNumBones( 0 ) + , mBones( 0 ) + , mMaterialIndex( 0 ) + , mNumAnimMeshes( 0 ) + , mAnimMeshes( NULL ) { - mNumVertices = 0; - mNumFaces = 0; - - mNumAnimMeshes = 0; - - mPrimitiveTypes = 0; - mVertices = NULL; mFaces = NULL; - mNormals = NULL; mTangents = NULL; - mBitangents = NULL; - mAnimMeshes = NULL; - for( unsigned int a = 0; a < AI_MAX_NUMBER_OF_TEXTURECOORDS; a++) { mNumUVComponents[a] = 0; mTextureCoords[a] = NULL; } + for( unsigned int a = 0; a < AI_MAX_NUMBER_OF_COLOR_SETS; a++) mColors[a] = NULL; - mNumBones = 0; mBones = NULL; - mMaterialIndex = 0; - mNumAnimMeshes = 0; - mAnimMeshes = NULL; } //! Deletes all storage allocated for the mesh 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 @@ > - - - - - -