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 000000000..3b5a8350d Binary files /dev/null and b/test/models/3MF/box.3mf differ