From 7cedd4ab89ce12b8b1b7dc29c65280e90ca457ad Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Sat, 10 Sep 2016 08:48:01 +0200 Subject: [PATCH 1/2] CMake: fix buildCMake: fix build.. --- CMakeLists.txt | 1 - code/CMakeLists.txt | 3 --- tools/assimp_qt_viewer/main.cpp | 12 +++++------- 3 files changed, 5 insertions(+), 11 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5105e3a1f..82706a4a0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -275,7 +275,6 @@ ENDIF ( ASSIMP_BUILD_COMPILER STREQUAL "") MARK_AS_ADVANCED ( ASSIMP_BUILD_ARCHITECTURE ASSIMP_BUILD_COMPILER ) - SET ( ASSIMP_BUILD_NONFREE_C4D_IMPORTER OFF CACHE BOOL "Build the C4D importer, which relies on the non-free Melange SDK." ) diff --git a/code/CMakeLists.txt b/code/CMakeLists.txt index 3efd83213..8b3d23773 100644 --- a/code/CMakeLists.txt +++ b/code/CMakeLists.txt @@ -617,8 +617,6 @@ ADD_ASSIMP_IMPORTER( 3MF D3MFOpcPackage.h D3MFOpcPackage.cpp ) -SOURCE_GROUP( 3MF FILES ${(3MF_SRCS}) - SET( Step_SRCS StepExporter.h @@ -662,7 +660,6 @@ SET( Clipper_SRCS ) SOURCE_GROUP( Clipper FILES ${Clipper_SRCS}) - SET( Poly2Tri_SRCS ../contrib/poly2tri/poly2tri/common/shapes.cc ../contrib/poly2tri/poly2tri/common/shapes.h diff --git a/tools/assimp_qt_viewer/main.cpp b/tools/assimp_qt_viewer/main.cpp index fa6f51b20..f9f35df80 100644 --- a/tools/assimp_qt_viewer/main.cpp +++ b/tools/assimp_qt_viewer/main.cpp @@ -10,12 +10,10 @@ // Header files, Qt. #include -int main(int argc, char *argv[]) -{ -QApplication a(argc, argv); -MainWindow w; +int main(int argc, char *argv[]) { + QApplication a(argc, argv); + MainWindow w; + w.show(); - w.show(); - - return a.exec(); + return a.exec(); } From 22cfe84cba10caebea61078c16fbb564af9e39dc Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Sat, 10 Sep 2016 09:27:29 +0200 Subject: [PATCH 2/2] 3MF: add a simple box example from the 3MF-sample repo. --- CMakeLists.txt | 13 +++++------ code/AssxmlExporter.cpp | 3 +-- code/D3MFImporter.cpp | 18 +++++---------- code/D3MFOpcPackage.cpp | 48 ++++++++++++++++------------------------ test/models/3MF/box.3mf | Bin 0 -> 1416 bytes 5 files changed, 31 insertions(+), 51 deletions(-) create mode 100644 test/models/3MF/box.3mf diff --git a/CMakeLists.txt b/CMakeLists.txt index 82706a4a0..c91a7e68e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -336,16 +336,16 @@ IF ( ASSIMP_BUILD_ASSIMP_TOOLS ) # Why here? Maybe user do not want Qt viewer and have no Qt. # Why assimp_qt_viewer/CMakeLists.txt still contain similar check? # Because viewer can be build independently of Assimp. - FIND_PACKAGE(Qt4 QUIET) + FIND_PACKAGE(Qt5 QUIET) FIND_PACKAGE(DevIL QUIET) FIND_PACKAGE(OpenGL QUIET) - IF ( Qt4_FOUND AND IL_FOUND AND OPENGL_FOUND) + IF ( Qt5_FOUND AND IL_FOUND AND OPENGL_FOUND) ADD_SUBDIRECTORY( tools/assimp_qt_viewer/ ) ELSE() SET ( ASSIMP_QT_VIEWER_DEPENDENCIES "") - IF (NOT Qt4_FOUND) - SET ( ASSIMP_QT_VIEWER_DEPENDENCIES "${ASSIMP_QT_VIEWER_DEPENDENCIES} Qt4") - ENDIF (NOT Qt4_FOUND) + IF (NOT Qt5_FOUND) + SET ( ASSIMP_QT_VIEWER_DEPENDENCIES "${ASSIMP_QT_VIEWER_DEPENDENCIES} Qt5") + ENDIF (NOT Qt5_FOUND) IF (NOT IL_FOUND) SET ( ASSIMP_QT_VIEWER_DEPENDENCIES "${ASSIMP_QT_VIEWER_DEPENDENCIES} DevIL") @@ -356,10 +356,9 @@ IF ( ASSIMP_BUILD_ASSIMP_TOOLS ) ENDIF (NOT OPENGL_FOUND) MESSAGE (WARNING "Build of assimp_qt_viewer is disabled. Unsatisfied dendencies: ${ASSIMP_QT_VIEWER_DEPENDENCIES}") - ENDIF ( Qt4_FOUND AND IL_FOUND AND OPENGL_FOUND) + ENDIF ( Qt5_FOUND AND IL_FOUND AND OPENGL_FOUND) ENDIF ( ASSIMP_BUILD_ASSIMP_TOOLS ) - IF ( ASSIMP_BUILD_SAMPLES) IF ( WIN32 ) ADD_SUBDIRECTORY( samples/SimpleTexturedOpenGL/ ) diff --git a/code/AssxmlExporter.cpp b/code/AssxmlExporter.cpp index f55f0174b..5bd174cce 100644 --- a/code/AssxmlExporter.cpp +++ b/code/AssxmlExporter.cpp @@ -74,11 +74,10 @@ static int ioprintf( IOStream * io, const char *format, ... ) { static const size_t Size = 4096; char sz[ Size ]; - size_t len( strlen( format ) ); ::memset( sz, '\0', Size ); va_list va; va_start( va, format ); - int nSize = vsnprintf( sz, Size-1, format, va ); + const unsigned int nSize = vsnprintf( sz, Size-1, format, va ); ai_assert( nSize < Size ); va_end( va ); diff --git a/code/D3MFImporter.cpp b/code/D3MFImporter.cpp index 39fdd1b32..045138be1 100644 --- a/code/D3MFImporter.cpp +++ b/code/D3MFImporter.cpp @@ -339,15 +339,12 @@ D3MFImporter::~D3MFImporter() bool D3MFImporter::CanRead(const std::string &pFile, IOSystem *pIOHandler, bool checkSig) const { const std::string extension = GetExtension(pFile); - - if(extension == "3mf") - { + if(extension == "3mf") { return true; - } - else if(!extension.length() || checkSig) - { - if(!pIOHandler) + } else if ( !extension.length() || checkSig ) { + if (nullptr == pIOHandler ) { return true; + } } return false; @@ -365,8 +362,6 @@ const aiImporterDesc *D3MFImporter::GetInfo() const void D3MFImporter::InternReadFile(const std::string &pFile, aiScene *pScene, IOSystem *pIOHandler) { - - D3MF::D3MFOpcPackage opcPackage(pIOHandler, pFile); std::unique_ptr xmlStream(new CIrrXML_IOStreamReader(opcPackage.RootStream())); @@ -374,12 +369,9 @@ void D3MFImporter::InternReadFile(const std::string &pFile, aiScene *pScene, IOS D3MF::XmlSerializer xmlSerializer(xmlReader.get()); - xmlSerializer.ImportXml(pScene); - - } -} +} // Namespace Assimp #endif // ASSIMP_BUILD_NO_3MF_IMPORTER diff --git a/code/D3MFOpcPackage.cpp b/code/D3MFOpcPackage.cpp index 7cc1dd50b..f01ca7e0f 100644 --- a/code/D3MFOpcPackage.cpp +++ b/code/D3MFOpcPackage.cpp @@ -61,26 +61,21 @@ namespace Assimp { namespace D3MF { - - namespace XmlTag { - -const std::string CONTENT_TYPES_ARCHIVE = "[Content_Types].xml"; -const std::string ROOT_RELATIONSHIPS_ARCHIVE = "_rels/.rels"; -const std::string SCHEMA_CONTENTTYPES = "http://schemas.openxmlformats.org/package/2006/content-types"; -const std::string SCHEMA_RELATIONSHIPS = "http://schemas.openxmlformats.org/package/2006/relationships"; -const std::string RELS_RELATIONSHIP_CONTAINER = "Relationships"; -const std::string RELS_RELATIONSHIP_NODE = "Relationship"; -const std::string RELS_ATTRIB_TARGET = "Target"; -const std::string RELS_ATTRIB_TYPE = "Type"; -const std::string RELS_ATTRIB_ID = "Id"; -const std::string PACKAGE_START_PART_RELATIONSHIP_TYPE = "http://schemas.microsoft.com/3dmanufacturing/2013/01/3dmodel"; -const std::string PACKAGE_PRINT_TICKET_RELATIONSHIP_TYPE = "http://schemas.microsoft.com/3dmanufacturing/2013/01/printticket"; -const std::string PACKAGE_TEXTURE_RELATIONSHIP_TYPE = "http://schemas.microsoft.com/3dmanufacturing/2013/01/3dtexture"; -const std::string PACKAGE_CORE_PROPERTIES_RELATIONSHIP_TYPE = "http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties"; -const std::string PACKAGE_THUMBNAIL_RELATIONSHIP_TYPE = "http://schemas.openxmlformats.org/package/2006/relationships/metadata/thumbnail"; - - + static const std::string CONTENT_TYPES_ARCHIVE = "[Content_Types].xml"; + static const std::string ROOT_RELATIONSHIPS_ARCHIVE = "_rels/.rels"; + static const std::string SCHEMA_CONTENTTYPES = "http://schemas.openxmlformats.org/package/2006/content-types"; + static const std::string SCHEMA_RELATIONSHIPS = "http://schemas.openxmlformats.org/package/2006/relationships"; + static const std::string RELS_RELATIONSHIP_CONTAINER = "Relationships"; + static const std::string RELS_RELATIONSHIP_NODE = "Relationship"; + static const std::string RELS_ATTRIB_TARGET = "Target"; + static const std::string RELS_ATTRIB_TYPE = "Type"; + static const std::string RELS_ATTRIB_ID = "Id"; + static const std::string PACKAGE_START_PART_RELATIONSHIP_TYPE = "http://schemas.microsoft.com/3dmanufacturing/2013/01/3dmodel"; + static const std::string PACKAGE_PRINT_TICKET_RELATIONSHIP_TYPE = "http://schemas.microsoft.com/3dmanufacturing/2013/01/printticket"; + static const std::string PACKAGE_TEXTURE_RELATIONSHIP_TYPE = "http://schemas.microsoft.com/3dmanufacturing/2013/01/3dtexture"; + static const std::string PACKAGE_CORE_PROPERTIES_RELATIONSHIP_TYPE = "http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties"; + static const std::string PACKAGE_THUMBNAIL_RELATIONSHIP_TYPE = "http://schemas.openxmlformats.org/package/2006/relationships/metadata/thumbnail"; } class IOSystem2Unzip { @@ -461,9 +456,8 @@ public: ParseRootNode(xmlReader); } } - - } + void ParseRootNode(XmlReader* xmlReader) { ParseAttributes(xmlReader); @@ -476,13 +470,13 @@ public: ParseChildNode(xmlReader); } } - } void ParseAttributes(XmlReader*) { } + void ParseChildNode(XmlReader* xmlReader) { OpcPackageRelationshipPtr relPtr(new OpcPackageRelationship()); @@ -494,26 +488,22 @@ public: m_relationShips.push_back(relPtr); } std::vector m_relationShips; - }; // ------------------------------------------------------------------------------------------------ D3MFOpcPackage::D3MFOpcPackage(IOSystem* pIOHandler, const std::string& rFile) : m_RootStream(nullptr) { - zipArchive.reset(new D3MF::D3MFZipArchive( pIOHandler, rFile )); - if(!zipArchive->isOpen()) + if(!zipArchive->isOpen()) { throw DeadlyImportError("Failed to open file " + rFile+ "."); + } std::vector fileList; zipArchive->getFileList(fileList); for(auto& file: fileList){ - - if(file == D3MF::XmlTag::ROOT_RELATIONSHIPS_ARCHIVE) - { - + if(file == D3MF::XmlTag::ROOT_RELATIONSHIPS_ARCHIVE) { //PkgRelationshipReader pkgRelReader(file, archive); ai_assert(zipArchive->Exists(file.c_str())); diff --git a/test/models/3MF/box.3mf b/test/models/3MF/box.3mf new file mode 100644 index 0000000000000000000000000000000000000000..3b5a8350d40fb2c878e274dddee47ec00e2201da GIT binary patch literal 1416 zcmWIWW@Zs#0D;oZ-)>+AlwbzZ#xD8+Pz4+eO+W>|+rytGF)}dxWMNll=~^~z3@R7(P3Kg-zZ%ttg$~l{qOTj){6Ue-?zNj#F^|ry@sjx)TFmU4jIv}t5rrF{td?Jpv zHX=D0rbhQaKfM@H%ZP{%M__y`n*RCGAz(b%1LH&(NJl&8=ar=9mBfcs7Ni!(>Q&_C zv`&c4I&2`&vR>)i)*D698cT1SbFTNBAeS)lx_w9#XQu3>+vRhoh&d_rZ#K4;_t|aD zmd`ikw9wAx-@6!{-#psz;mX11{}xxZ#om9nUs!Z;pq}g*rI$xcr~Nrs$?>s zhSuj4;a&Q3PS}~8om@JxHA3sA)q?!{8Aq;mSK7b&*>m;@_l)bs1<9oinm>;&T#?Uj z6BDp1-f8Xp`<)%)+)Fm4&0Q3I#<8aNyYn_Rw`5n}db4ol zYVNaIA6;eC20O0t4+Rg2Y53w*)!nEqAEbofdD8kf&ehXaxo}?nT!k)4Eqn(bk&`>z=%#G48@kM zVTOXtQ3PV3p(vRg*@o8s`_l>8fSFKXHZ%ZD-w2E&EXfwx5{85Q{vb;}y?}TJMkBm| zEos0k0fo&HCRjp2HWxiu=Fftdk1&^m0W&$l%mq3A1l(M3;zBkY=4f