3MF: add a simple box example from the 3MF-sample repo.

pull/972/head
Kim Kulling 2016-09-10 09:27:29 +02:00
parent 7cedd4ab89
commit 22cfe84cba
5 changed files with 31 additions and 51 deletions

View File

@ -336,16 +336,16 @@ IF ( ASSIMP_BUILD_ASSIMP_TOOLS )
# Why here? Maybe user do not want Qt viewer and have no Qt. # Why here? Maybe user do not want Qt viewer and have no Qt.
# Why assimp_qt_viewer/CMakeLists.txt still contain similar check? # Why assimp_qt_viewer/CMakeLists.txt still contain similar check?
# Because viewer can be build independently of Assimp. # Because viewer can be build independently of Assimp.
FIND_PACKAGE(Qt4 QUIET) FIND_PACKAGE(Qt5 QUIET)
FIND_PACKAGE(DevIL QUIET) FIND_PACKAGE(DevIL QUIET)
FIND_PACKAGE(OpenGL 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/ ) ADD_SUBDIRECTORY( tools/assimp_qt_viewer/ )
ELSE() ELSE()
SET ( ASSIMP_QT_VIEWER_DEPENDENCIES "") SET ( ASSIMP_QT_VIEWER_DEPENDENCIES "")
IF (NOT Qt4_FOUND) IF (NOT Qt5_FOUND)
SET ( ASSIMP_QT_VIEWER_DEPENDENCIES "${ASSIMP_QT_VIEWER_DEPENDENCIES} Qt4") SET ( ASSIMP_QT_VIEWER_DEPENDENCIES "${ASSIMP_QT_VIEWER_DEPENDENCIES} Qt5")
ENDIF (NOT Qt4_FOUND) ENDIF (NOT Qt5_FOUND)
IF (NOT IL_FOUND) IF (NOT IL_FOUND)
SET ( ASSIMP_QT_VIEWER_DEPENDENCIES "${ASSIMP_QT_VIEWER_DEPENDENCIES} DevIL") SET ( ASSIMP_QT_VIEWER_DEPENDENCIES "${ASSIMP_QT_VIEWER_DEPENDENCIES} DevIL")
@ -356,10 +356,9 @@ IF ( ASSIMP_BUILD_ASSIMP_TOOLS )
ENDIF (NOT OPENGL_FOUND) ENDIF (NOT OPENGL_FOUND)
MESSAGE (WARNING "Build of assimp_qt_viewer is disabled. Unsatisfied dendencies: ${ASSIMP_QT_VIEWER_DEPENDENCIES}") 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 ) ENDIF ( ASSIMP_BUILD_ASSIMP_TOOLS )
IF ( ASSIMP_BUILD_SAMPLES) IF ( ASSIMP_BUILD_SAMPLES)
IF ( WIN32 ) IF ( WIN32 )
ADD_SUBDIRECTORY( samples/SimpleTexturedOpenGL/ ) ADD_SUBDIRECTORY( samples/SimpleTexturedOpenGL/ )

View File

@ -74,11 +74,10 @@ static int ioprintf( IOStream * io, const char *format, ... ) {
static const size_t Size = 4096; static const size_t Size = 4096;
char sz[ Size ]; char sz[ Size ];
size_t len( strlen( format ) );
::memset( sz, '\0', Size ); ::memset( sz, '\0', Size );
va_list va; va_list va;
va_start( va, format ); 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 ); ai_assert( nSize < Size );
va_end( va ); va_end( va );

View File

@ -339,15 +339,12 @@ D3MFImporter::~D3MFImporter()
bool D3MFImporter::CanRead(const std::string &pFile, IOSystem *pIOHandler, bool checkSig) const bool D3MFImporter::CanRead(const std::string &pFile, IOSystem *pIOHandler, bool checkSig) const
{ {
const std::string extension = GetExtension(pFile); const std::string extension = GetExtension(pFile);
if(extension == "3mf") {
if(extension == "3mf")
{
return true; return true;
} } else if ( !extension.length() || checkSig ) {
else if(!extension.length() || checkSig) if (nullptr == pIOHandler ) {
{
if(!pIOHandler)
return true; return true;
}
} }
return false; return false;
@ -365,8 +362,6 @@ const aiImporterDesc *D3MFImporter::GetInfo() const
void D3MFImporter::InternReadFile(const std::string &pFile, aiScene *pScene, IOSystem *pIOHandler) void D3MFImporter::InternReadFile(const std::string &pFile, aiScene *pScene, IOSystem *pIOHandler)
{ {
D3MF::D3MFOpcPackage opcPackage(pIOHandler, pFile); D3MF::D3MFOpcPackage opcPackage(pIOHandler, pFile);
std::unique_ptr<CIrrXML_IOStreamReader> xmlStream(new CIrrXML_IOStreamReader(opcPackage.RootStream())); std::unique_ptr<CIrrXML_IOStreamReader> 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()); D3MF::XmlSerializer xmlSerializer(xmlReader.get());
xmlSerializer.ImportXml(pScene); xmlSerializer.ImportXml(pScene);
} }
} } // Namespace Assimp
#endif // ASSIMP_BUILD_NO_3MF_IMPORTER #endif // ASSIMP_BUILD_NO_3MF_IMPORTER

View File

@ -61,26 +61,21 @@ namespace Assimp {
namespace D3MF { namespace D3MF {
namespace XmlTag { namespace XmlTag {
static const std::string CONTENT_TYPES_ARCHIVE = "[Content_Types].xml";
const std::string CONTENT_TYPES_ARCHIVE = "[Content_Types].xml"; static const std::string ROOT_RELATIONSHIPS_ARCHIVE = "_rels/.rels";
const std::string ROOT_RELATIONSHIPS_ARCHIVE = "_rels/.rels"; static const std::string SCHEMA_CONTENTTYPES = "http://schemas.openxmlformats.org/package/2006/content-types";
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";
const std::string SCHEMA_RELATIONSHIPS = "http://schemas.openxmlformats.org/package/2006/relationships"; static const std::string RELS_RELATIONSHIP_CONTAINER = "Relationships";
const std::string RELS_RELATIONSHIP_CONTAINER = "Relationships"; static const std::string RELS_RELATIONSHIP_NODE = "Relationship";
const std::string RELS_RELATIONSHIP_NODE = "Relationship"; static const std::string RELS_ATTRIB_TARGET = "Target";
const std::string RELS_ATTRIB_TARGET = "Target"; static const std::string RELS_ATTRIB_TYPE = "Type";
const std::string RELS_ATTRIB_TYPE = "Type"; static const std::string RELS_ATTRIB_ID = "Id";
const std::string RELS_ATTRIB_ID = "Id"; static const std::string PACKAGE_START_PART_RELATIONSHIP_TYPE = "http://schemas.microsoft.com/3dmanufacturing/2013/01/3dmodel";
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";
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";
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";
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";
const std::string PACKAGE_THUMBNAIL_RELATIONSHIP_TYPE = "http://schemas.openxmlformats.org/package/2006/relationships/metadata/thumbnail";
} }
class IOSystem2Unzip { class IOSystem2Unzip {
@ -461,9 +456,8 @@ public:
ParseRootNode(xmlReader); ParseRootNode(xmlReader);
} }
} }
} }
void ParseRootNode(XmlReader* xmlReader) void ParseRootNode(XmlReader* xmlReader)
{ {
ParseAttributes(xmlReader); ParseAttributes(xmlReader);
@ -476,13 +470,13 @@ public:
ParseChildNode(xmlReader); ParseChildNode(xmlReader);
} }
} }
} }
void ParseAttributes(XmlReader*) void ParseAttributes(XmlReader*)
{ {
} }
void ParseChildNode(XmlReader* xmlReader) void ParseChildNode(XmlReader* xmlReader)
{ {
OpcPackageRelationshipPtr relPtr(new OpcPackageRelationship()); OpcPackageRelationshipPtr relPtr(new OpcPackageRelationship());
@ -494,26 +488,22 @@ public:
m_relationShips.push_back(relPtr); m_relationShips.push_back(relPtr);
} }
std::vector<OpcPackageRelationshipPtr> m_relationShips; std::vector<OpcPackageRelationshipPtr> m_relationShips;
}; };
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
D3MFOpcPackage::D3MFOpcPackage(IOSystem* pIOHandler, const std::string& rFile) D3MFOpcPackage::D3MFOpcPackage(IOSystem* pIOHandler, const std::string& rFile)
: m_RootStream(nullptr) : m_RootStream(nullptr)
{ {
zipArchive.reset(new D3MF::D3MFZipArchive( pIOHandler, rFile )); zipArchive.reset(new D3MF::D3MFZipArchive( pIOHandler, rFile ));
if(!zipArchive->isOpen()) if(!zipArchive->isOpen()) {
throw DeadlyImportError("Failed to open file " + rFile+ "."); throw DeadlyImportError("Failed to open file " + rFile+ ".");
}
std::vector<std::string> fileList; std::vector<std::string> fileList;
zipArchive->getFileList(fileList); zipArchive->getFileList(fileList);
for(auto& file: fileList){ for(auto& file: fileList){
if(file == D3MF::XmlTag::ROOT_RELATIONSHIPS_ARCHIVE) {
if(file == D3MF::XmlTag::ROOT_RELATIONSHIPS_ARCHIVE)
{
//PkgRelationshipReader pkgRelReader(file, archive); //PkgRelationshipReader pkgRelReader(file, archive);
ai_assert(zipArchive->Exists(file.c_str())); ai_assert(zipArchive->Exists(file.c_str()));

Binary file not shown.