From e7736022c8aae264011b7d097ae8338e29cebe47 Mon Sep 17 00:00:00 2001 From: Tommy Date: Sun, 25 Feb 2018 09:34:14 +0100 Subject: [PATCH 1/4] assimp_cmd info: list meshes and print basic mesh stats. --- tools/assimp_cmd/Info.cpp | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/tools/assimp_cmd/Info.cpp b/tools/assimp_cmd/Info.cpp index a9f66eb1f..c4d5fe189 100644 --- a/tools/assimp_cmd/Info.cpp +++ b/tools/assimp_cmd/Info.cpp @@ -329,6 +329,29 @@ int Assimp_Info (const char* const* params, unsigned int num) special_points[2][0],special_points[2][1],special_points[2][2] ) ; + + // meshes + if (scene->mNumMeshes) { + printf("\nMeshes: (name) [vertices / bones / faces | primitive_types]\n"); + } + for (unsigned int i = 0; i < scene->mNumMeshes; ++i) { + const aiMesh* mesh = scene->mMeshes[i]; + printf(" %d (%s)", i, mesh->mName.C_Str()); + printf( + ": [%d / %d / %d |", + mesh->mNumVertices, + mesh->mNumBones, + mesh->mNumFaces + ); + const unsigned int ptypes = mesh->mPrimitiveTypes; + if (ptypes & aiPrimitiveType_POINT) { printf(" point"); } + if (ptypes & aiPrimitiveType_LINE) { printf(" line"); } + if (ptypes & aiPrimitiveType_TRIANGLE) { printf(" triangle"); } + if (ptypes & aiPrimitiveType_POLYGON) { printf(" polygon"); } + printf("]\n"); + } + + // materials unsigned int total=0; for(unsigned int i = 0;i < scene->mNumMaterials; ++i) { aiString name; @@ -340,6 +363,7 @@ int Assimp_Info (const char* const* params, unsigned int num) printf("\n"); } + // textures total=0; for(unsigned int i = 0;i < scene->mNumMaterials; ++i) { aiString name; @@ -369,6 +393,7 @@ int Assimp_Info (const char* const* params, unsigned int num) printf("\n"); } + // animations total=0; for(unsigned int i = 0;i < scene->mNumAnimations; ++i) { if (scene->mAnimations[i]->mName.length) { @@ -379,6 +404,7 @@ int Assimp_Info (const char* const* params, unsigned int num) printf("\n"); } + // node hierarchy printf("\nNode hierarchy:\n"); unsigned int cline=0; PrintHierarchy(scene->mRootNode,20,1000,cline,verbose); From c0f04bf9652d02d8764d2b8aa837cd1ba338c825 Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Tue, 27 Feb 2018 18:30:36 +0100 Subject: [PATCH 2/4] IMporter: fix lookup for tokens during inmemory imports. --- code/BaseImporter.cpp | 12 ++++++++++-- code/Importer/IFC/IFCLoader.cpp | 3 ++- test/unit/utIFCImportExport.cpp | 20 ++++++++++++++++++++ 3 files changed, 32 insertions(+), 3 deletions(-) diff --git a/code/BaseImporter.cpp b/code/BaseImporter.cpp index 0892efd9f..e7736d8a4 100644 --- a/code/BaseImporter.cpp +++ b/code/BaseImporter.cpp @@ -178,9 +178,17 @@ void BaseImporter::GetExtensionList(std::set& extensions) } *cur2 = '\0'; + std::string token; for (unsigned int i = 0; i < numTokens;++i) { - ai_assert(NULL != tokens[i]); - const char* r = strstr(buffer,tokens[i]); + ai_assert( nullptr != tokens[i] ); + size_t len( strlen( tokens[ i ] ) ); + token.clear(); + const char *ptr( tokens[ i ] ); + for ( size_t tokIdx = 0; tokIdx < len; ++tokIdx ) { + token.push_back( tolower( *ptr ) ); + ++ptr; + } + const char* r = strstr( buffer, token.c_str() ); if( !r ) { continue; } diff --git a/code/Importer/IFC/IFCLoader.cpp b/code/Importer/IFC/IFCLoader.cpp index de7a37037..5acc89545 100644 --- a/code/Importer/IFC/IFCLoader.cpp +++ b/code/Importer/IFC/IFCLoader.cpp @@ -141,7 +141,8 @@ bool IFCImporter::CanRead( const std::string& pFile, IOSystem* pIOHandler, bool // it is only unambiguous as long as we don't support any further // file formats with STEP as their encoding. const char* tokens[] = {"ISO-10303-21"}; - return SearchFileHeaderForToken(pIOHandler,pFile,tokens,1); + const bool found( SearchFileHeaderForToken( pIOHandler, pFile, tokens, 1 ) ); + return found; } return false; } diff --git a/test/unit/utIFCImportExport.cpp b/test/unit/utIFCImportExport.cpp index fa27bb7a8..e13244e34 100644 --- a/test/unit/utIFCImportExport.cpp +++ b/test/unit/utIFCImportExport.cpp @@ -62,3 +62,23 @@ public: TEST_F( utIFCImportExport, importIFCFromFileTest ) { EXPECT_TRUE( importerTest() ); } + +TEST_F( utIFCImportExport, importComplextypeAsColor ) { + std::string asset = + "ISO-10303-21;\n" + "HEADER;\n" + "FILE_DESCRIPTION( ( 'ViewDefinition [CoordinationView, SpaceBoundary2ndLevelAddOnView]', 'Option [Filter: ]' ), '2;1' );\n" + "FILE_NAME( 'S:\\[IFC]\\[COMPLETE-BUILDINGS]\\FZK-MODELS\\FZK-Haus\\ArchiCAD-14\\AC14-FZK-Haus.ifc', '2010-10-07T13:40:52', ( 'Architect' ), ( 'Building Designer Office' ), 'PreProc - EDM 5.0', 'ArchiCAD 14.00 Release 1. Windows Build Number of the Ifc 2x3 interface: 3427', 'The authorising person' );\n" + "FILE_SCHEMA( ( 'IFC2X3' ) );\n" + "ENDSEC;\n" + "\n" + "DATA;\n" + "#1 = IFCORGANIZATION( 'GS', 'Graphisoft', 'Graphisoft', $, $ );\n" + "#2 = IFCPROPERTYSINGLEVALUE( 'Red', $, IFCINTEGER( 255 ), $ );\n" + "#3 = IFCPROPERTYSINGLEVALUE( 'Green', $, IFCINTEGER( 255 ), $ );\n" + "#4 = IFCPROPERTYSINGLEVALUE( 'Blue', $, IFCINTEGER( 255 ), $ );\n" + "#5 = IFCCOMPLEXPROPERTY( 'Color', $, 'Color', ( #19, #20, #21 ) );\n"; + Assimp::Importer importer; + const aiScene *scene = importer.ReadFileFromMemory( asset.c_str(), asset.size(), 0 ); + +} From d53f95801180cce74123f58c08fd839222d2f4ff Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Tue, 27 Feb 2018 18:56:07 +0100 Subject: [PATCH 3/4] unittest: fix compiler warning --- test/unit/utIFCImportExport.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/test/unit/utIFCImportExport.cpp b/test/unit/utIFCImportExport.cpp index e13244e34..01132435b 100644 --- a/test/unit/utIFCImportExport.cpp +++ b/test/unit/utIFCImportExport.cpp @@ -80,5 +80,6 @@ TEST_F( utIFCImportExport, importComplextypeAsColor ) { "#5 = IFCCOMPLEXPROPERTY( 'Color', $, 'Color', ( #19, #20, #21 ) );\n"; Assimp::Importer importer; const aiScene *scene = importer.ReadFileFromMemory( asset.c_str(), asset.size(), 0 ); + EXPECT_EQ( nullptr, scene ); } From a58f8e1c1a4127df2051ad955f87e4bab64909bd Mon Sep 17 00:00:00 2001 From: Tommy Date: Wed, 28 Feb 2018 23:38:49 +0100 Subject: [PATCH 4/4] FBX Export: add missing 0 value to file footer. --- code/FBXExporter.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/code/FBXExporter.cpp b/code/FBXExporter.cpp index f1c6290e2..8e32ed46c 100644 --- a/code/FBXExporter.cpp +++ b/code/FBXExporter.cpp @@ -247,6 +247,11 @@ void FBXExporter::WriteBinaryFooter() outfile->Write("\x00", 1, 1); } + // not sure what this is, but it seems to always be 0 in modern files + for (size_t i = 0; i < 4; ++i) { + outfile->Write("\x00", 1, 1); + } + // now the file version again { StreamWriterLE outstream(outfile);