浏览代码

Merge branch 'master' of https://github.com/tszirr/assimp

tszirr 12 年之前
父节点
当前提交
6c6283e4d8
共有 8 个文件被更改,包括 56 次插入34 次删除
  1. 3 0
      code/ColladaExporter.cpp
  2. 2 1
      code/Exporter.cpp
  3. 36 21
      code/IFCLoader.cpp
  4. 6 0
      code/ObjExporter.cpp
  5. 4 0
      code/PlyExporter.cpp
  6. 4 0
      code/STLExporter.cpp
  7. 1 0
      include/assimp/Exporter.hpp
  8. 0 12
      workspaces/vc9/assimp.vcproj

+ 3 - 0
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<IOStream> 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<size_t>(iDoTheExportThing.mOutput.tellp()),1);

+ 2 - 1
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

+ 36 - 21
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 );
-
-			uint8_t* buff = new uint8_t[fileInfo.uncompressed_size];
-
-			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));
+		
+		if(UNZ_OK == unzGoToFirstFile(zip)) {
+			do {
+				//
+
+				// 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;
+				}
+
+				uint8_t* buff = new uint8_t[fileInfo.uncompressed_size];
+
+				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);

+ 6 - 0
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<IOStream> 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<size_t>(exporter.mOutput.tellp()),1);
 	}
 	{
 		boost::scoped_ptr<IOStream> 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<size_t>(exporter.mOutputMat.tellp()),1);
 	}
 }

+ 4 - 0
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<IOStream> 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<size_t>(exporter.mOutput.tellp()),1);
 }
 

+ 4 - 0
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<IOStream> 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<size_t>(exporter.mOutput.tellp()),1);
 }
 

+ 1 - 0
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;
 
 
 // ----------------------------------------------------------------------------------

+ 0 - 12
workspaces/vc9/assimp.vcproj

@@ -2044,18 +2044,6 @@
 						>
 					</File>
 				</Filter>
-				<Filter
-					Name="m3"
-					>
-					<File
-						RelativePath="..\..\code\M3Importer.cpp"
-						>
-					</File>
-					<File
-						RelativePath="..\..\code\M3Importer.h"
-						>
-					</File>
-				</Filter>
 				<Filter
 					Name="xgl"
 					>