3Mf-Export: add prototypes for relations and rest of 3MF-document.
parent
a7be5b527f
commit
b474e75e29
|
@ -44,7 +44,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
#ifndef AI_3DSFILEHELPER_H_INC
|
||||
#define AI_3DSFILEHELPER_H_INC
|
||||
|
||||
|
||||
#include "SpatialSort.h"
|
||||
#include "SmoothingGroups.h"
|
||||
#include "StringUtils.h"
|
||||
|
@ -64,16 +63,19 @@ namespace D3DS {
|
|||
/** Discreet3DS class: Helper class for loading 3ds files. Defines chunks
|
||||
* and data structures.
|
||||
*/
|
||||
class Discreet3DS
|
||||
{
|
||||
class Discreet3DS {
|
||||
private:
|
||||
inline Discreet3DS() {}
|
||||
Discreet3DS() {
|
||||
// empty
|
||||
}
|
||||
|
||||
~Discreet3DS() {
|
||||
// empty
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
//! data structure for a single chunk in a .3ds file
|
||||
struct Chunk
|
||||
{
|
||||
struct Chunk {
|
||||
uint16_t Flag;
|
||||
uint32_t Size;
|
||||
} PACK_STRUCT;
|
||||
|
|
|
@ -50,7 +50,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
#include "3MFXmlTags.h"
|
||||
|
||||
namespace Assimp {
|
||||
namespace D3MF {
|
||||
|
||||
void ExportScene3MF( const char* pFile, IOSystem* pIOSystem, const aiScene* pScene, const ExportProperties* /*pProperties*/ ) {
|
||||
std::shared_ptr<IOStream> outfile( pIOSystem->Open( pFile, "wb" ) );
|
||||
|
@ -58,12 +57,16 @@ void ExportScene3MF( const char* pFile, IOSystem* pIOSystem, const aiScene* pSce
|
|||
throw DeadlyExportError( "Could not open output .3ds file: " + std::string( pFile ) );
|
||||
}
|
||||
|
||||
D3MFExporter myExporter( outfile, pScene );
|
||||
D3MF::D3MFExporter myExporter( outfile, pScene );
|
||||
if ( myExporter.validate() ) {
|
||||
bool ok = myExporter.exportAsset();
|
||||
}
|
||||
}
|
||||
|
||||
namespace D3MF {
|
||||
|
||||
#ifndef ASSIMP_BUILD_NO3MF_EXPORTER
|
||||
|
||||
D3MFExporter::D3MFExporter( std::shared_ptr<IOStream> outfile, const aiScene* pScene )
|
||||
: mStream( outfile.get() )
|
||||
, mScene( pScene )
|
||||
|
@ -101,6 +104,8 @@ bool D3MFExporter::exportAsset() {
|
|||
|
||||
mOutput << "</" << XmlTag::model << ">\n";
|
||||
|
||||
std::string exportedFile = mOutput.str();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -179,5 +184,7 @@ void D3MFExporter::writeBuild() {
|
|||
mOutput << "</" << XmlTag::build << ">\n";
|
||||
}
|
||||
|
||||
#endif // ASSIMP_BUILD_NO3MF_EXPORTER
|
||||
|
||||
}
|
||||
} // Namespace Assimp
|
||||
|
|
|
@ -56,6 +56,8 @@ class IOStream;
|
|||
|
||||
namespace D3MF {
|
||||
|
||||
#ifndef ASSIMP_BUILD_NO3MF_EXPORTER
|
||||
|
||||
class D3MFExporter {
|
||||
public:
|
||||
D3MFExporter( std::shared_ptr<IOStream> outfile, const aiScene* pScene );
|
||||
|
@ -78,6 +80,8 @@ private:
|
|||
std::vector<unsigned int> mBuildItems;
|
||||
};
|
||||
|
||||
#endif // ASSIMP_BUILD_NO3MF_EXPORTER
|
||||
|
||||
}
|
||||
} // Namespace Assimp
|
||||
|
||||
|
|
|
@ -107,7 +107,6 @@ voidpf IOSystem2Unzip::open(voidpf opaque, const char* filename, int mode) {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
return (voidpf) io_system->Open(filename, mode_fopen);
|
||||
}
|
||||
|
||||
|
@ -177,44 +176,32 @@ zlib_filefunc_def IOSystem2Unzip::get(IOSystem* pIOHandler) {
|
|||
return mapping;
|
||||
}
|
||||
|
||||
|
||||
class ZipFile : public IOStream
|
||||
{
|
||||
class ZipFile : public IOStream {
|
||||
friend class D3MFZipArchive;
|
||||
|
||||
public:
|
||||
explicit ZipFile(size_t size);
|
||||
|
||||
~ZipFile();
|
||||
|
||||
virtual ~ZipFile();
|
||||
size_t Read(void* pvBuffer, size_t pSize, size_t pCount );
|
||||
|
||||
size_t Write(const void* /*pvBuffer*/, size_t /*pSize*/, size_t /*pCount*/);
|
||||
|
||||
size_t FileSize() const;
|
||||
|
||||
aiReturn Seek(size_t /*pOffset*/, aiOrigin /*pOrigin*/);
|
||||
|
||||
size_t Tell() const;
|
||||
|
||||
void Flush();
|
||||
|
||||
private:
|
||||
|
||||
void* m_Buffer;
|
||||
|
||||
void *m_Buffer;
|
||||
size_t m_Size;
|
||||
|
||||
};
|
||||
|
||||
ZipFile::ZipFile(size_t size) : m_Size(size) {
|
||||
ai_assert(m_Size != 0);
|
||||
|
||||
m_Buffer = malloc(m_Size);
|
||||
m_Buffer = ::malloc(m_Size);
|
||||
}
|
||||
|
||||
ZipFile::~ZipFile() {
|
||||
free(m_Buffer);
|
||||
::free(m_Buffer);
|
||||
m_Buffer = NULL;
|
||||
}
|
||||
|
||||
|
@ -227,8 +214,12 @@ size_t ZipFile::Read(void* pvBuffer, size_t pSize, size_t pCount) {
|
|||
return size;
|
||||
}
|
||||
|
||||
size_t ZipFile::Write(const void* /*pvBuffer*/, size_t /*pSize*/, size_t /*pCount*/) {
|
||||
return 0;
|
||||
size_t ZipFile::Write(const void* pvBuffer, size_t size, size_t pCount ) {
|
||||
const size_t size_to_write( size * pCount );
|
||||
if ( 0 == size_to_write ) {
|
||||
return 0U;
|
||||
}
|
||||
return 0U;
|
||||
}
|
||||
|
||||
size_t ZipFile::FileSize() const {
|
||||
|
@ -247,7 +238,6 @@ void ZipFile::Flush() {
|
|||
// empty
|
||||
}
|
||||
|
||||
|
||||
class D3MFZipArchive : public IOSystem {
|
||||
public:
|
||||
static const unsigned int FileNameSize = 256;
|
||||
|
@ -272,14 +262,12 @@ private:
|
|||
// ------------------------------------------------------------------------------------------------
|
||||
// Constructor.
|
||||
D3MFZipArchive::D3MFZipArchive(IOSystem* pIOHandler, const std::string& rFile)
|
||||
: m_ZipFileHandle(NULL), m_ArchiveMap()
|
||||
{
|
||||
if (! rFile.empty())
|
||||
{
|
||||
: m_ZipFileHandle(NULL)
|
||||
, m_ArchiveMap() {
|
||||
if (! rFile.empty()) {
|
||||
zlib_filefunc_def mapping = IOSystem2Unzip::get(pIOHandler);
|
||||
|
||||
m_ZipFileHandle = unzOpen2(rFile.c_str(), &mapping);
|
||||
|
||||
if(m_ZipFileHandle != NULL) {
|
||||
mapArchive();
|
||||
}
|
||||
|
@ -409,8 +397,7 @@ bool D3MFZipArchive::mapArchive() {
|
|||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
|
||||
struct OpcPackageRelationship
|
||||
{
|
||||
struct OpcPackageRelationship {
|
||||
std::string id;
|
||||
std::string type;
|
||||
std::string target;
|
||||
|
@ -418,15 +405,10 @@ struct OpcPackageRelationship
|
|||
|
||||
typedef std::shared_ptr<OpcPackageRelationship> OpcPackageRelationshipPtr;
|
||||
|
||||
class OpcPackageRelationshipReader
|
||||
{
|
||||
class OpcPackageRelationshipReader {
|
||||
public:
|
||||
|
||||
OpcPackageRelationshipReader(XmlReader* xmlReader)
|
||||
{
|
||||
|
||||
while(xmlReader->read())
|
||||
{
|
||||
OpcPackageRelationshipReader(XmlReader* xmlReader) {
|
||||
while(xmlReader->read()) {
|
||||
if(xmlReader->getNodeType() == irr::io::EXN_ELEMENT &&
|
||||
xmlReader->getNodeName() == XmlTag::RELS_RELATIONSHIP_CONTAINER)
|
||||
{
|
||||
|
|
|
@ -95,29 +95,30 @@ void ExportSceneGLTF2(const char*, IOSystem*, const aiScene*, const ExportProper
|
|||
void ExportSceneAssbin(const char*, IOSystem*, const aiScene*, const ExportProperties*);
|
||||
void ExportSceneAssxml(const char*, IOSystem*, const aiScene*, const ExportProperties*);
|
||||
void ExportSceneX3D(const char*, IOSystem*, const aiScene*, const ExportProperties*);
|
||||
void ExportScene3MF( const char*, IOSystem*, const aiScene*, const ExportProperties* );
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// global array of all export formats which Assimp supports in its current build
|
||||
Exporter::ExportFormatEntry gExporters[] =
|
||||
{
|
||||
#ifndef ASSIMP_BUILD_NO_COLLADA_EXPORTER
|
||||
Exporter::ExportFormatEntry( "collada", "COLLADA - Digital Asset Exchange Schema", "dae", &ExportSceneCollada),
|
||||
Exporter::ExportFormatEntry( "collada", "COLLADA - Digital Asset Exchange Schema", "dae", &ExportSceneCollada ),
|
||||
#endif
|
||||
|
||||
#ifndef ASSIMP_BUILD_NO_X_EXPORTER
|
||||
Exporter::ExportFormatEntry( "x", "X Files", "x", &ExportSceneXFile,
|
||||
aiProcess_MakeLeftHanded | aiProcess_FlipWindingOrder | aiProcess_FlipUVs),
|
||||
aiProcess_MakeLeftHanded | aiProcess_FlipWindingOrder | aiProcess_FlipUVs ),
|
||||
#endif
|
||||
|
||||
#ifndef ASSIMP_BUILD_NO_STEP_EXPORTER
|
||||
Exporter::ExportFormatEntry( "stp", "Step Files", "stp", &ExportSceneStep, 0),
|
||||
Exporter::ExportFormatEntry( "stp", "Step Files", "stp", &ExportSceneStep, 0 ),
|
||||
#endif
|
||||
|
||||
#ifndef ASSIMP_BUILD_NO_OBJ_EXPORTER
|
||||
Exporter::ExportFormatEntry( "obj", "Wavefront OBJ format", "obj", &ExportSceneObj,
|
||||
aiProcess_GenSmoothNormals /*| aiProcess_PreTransformVertices */),
|
||||
aiProcess_GenSmoothNormals /*| aiProcess_PreTransformVertices */ ),
|
||||
Exporter::ExportFormatEntry( "objnomtl", "Wavefront OBJ format without material file", "obj", &ExportSceneObjNoMtl,
|
||||
aiProcess_GenSmoothNormals /*| aiProcess_PreTransformVertices */),
|
||||
aiProcess_GenSmoothNormals /*| aiProcess_PreTransformVertices */ ),
|
||||
#endif
|
||||
|
||||
#ifndef ASSIMP_BUILD_NO_STL_EXPORTER
|
||||
|
@ -140,28 +141,32 @@ Exporter::ExportFormatEntry gExporters[] =
|
|||
|
||||
#ifndef ASSIMP_BUILD_NO_3DS_EXPORTER
|
||||
Exporter::ExportFormatEntry( "3ds", "Autodesk 3DS (legacy)", "3ds" , &ExportScene3DS,
|
||||
aiProcess_Triangulate | aiProcess_SortByPType | aiProcess_JoinIdenticalVertices),
|
||||
aiProcess_Triangulate | aiProcess_SortByPType | aiProcess_JoinIdenticalVertices ),
|
||||
#endif
|
||||
|
||||
#ifndef ASSIMP_BUILD_NO_GLTF_EXPORTER
|
||||
Exporter::ExportFormatEntry( "gltf", "GL Transmission Format", "gltf", &ExportSceneGLTF,
|
||||
aiProcess_JoinIdenticalVertices | aiProcess_Triangulate | aiProcess_SortByPType),
|
||||
aiProcess_JoinIdenticalVertices | aiProcess_Triangulate | aiProcess_SortByPType ),
|
||||
Exporter::ExportFormatEntry( "glb", "GL Transmission Format (binary)", "glb", &ExportSceneGLB,
|
||||
aiProcess_JoinIdenticalVertices | aiProcess_Triangulate | aiProcess_SortByPType),
|
||||
aiProcess_JoinIdenticalVertices | aiProcess_Triangulate | aiProcess_SortByPType ),
|
||||
Exporter::ExportFormatEntry( "gltf2", "GL Transmission Format v. 2", "gltf2", &ExportSceneGLTF2,
|
||||
aiProcess_JoinIdenticalVertices | aiProcess_Triangulate | aiProcess_SortByPType),
|
||||
aiProcess_JoinIdenticalVertices | aiProcess_Triangulate | aiProcess_SortByPType ),
|
||||
#endif
|
||||
|
||||
#ifndef ASSIMP_BUILD_NO_ASSBIN_EXPORTER
|
||||
Exporter::ExportFormatEntry( "assbin", "Assimp Binary", "assbin" , &ExportSceneAssbin, 0),
|
||||
Exporter::ExportFormatEntry( "assbin", "Assimp Binary", "assbin" , &ExportSceneAssbin, 0 ),
|
||||
#endif
|
||||
|
||||
#ifndef ASSIMP_BUILD_NO_ASSXML_EXPORTER
|
||||
Exporter::ExportFormatEntry( "assxml", "Assxml Document", "assxml" , &ExportSceneAssxml, 0),
|
||||
Exporter::ExportFormatEntry( "assxml", "Assxml Document", "assxml" , &ExportSceneAssxml, 0 ),
|
||||
#endif
|
||||
|
||||
#ifndef ASSIMP_BUILD_NO_X3D_EXPORTER
|
||||
Exporter::ExportFormatEntry( "x3d", "Extensible 3D", "x3d" , &ExportSceneX3D, 0),
|
||||
Exporter::ExportFormatEntry( "x3d", "Extensible 3D", "x3d" , &ExportSceneX3D, 0 ),
|
||||
#endif
|
||||
|
||||
#ifndef ASSIMP_BUILD_NO3MF_EXPORTER
|
||||
Exporter::ExportFormatEntry( "3mf", "The 3MF-File-Format", "3mf", &ExportScene3MF, 0 )
|
||||
#endif
|
||||
};
|
||||
|
||||
|
|
|
@ -43,8 +43,11 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
#include "AbstractImportExportBase.h"
|
||||
|
||||
#include <assimp/Importer.hpp>
|
||||
#include <assimp/Exporter.hpp>
|
||||
#include <assimp/scene.h>
|
||||
|
||||
#include "D3MFExporter.h"
|
||||
|
||||
class utD3MFImporterExporter : public AbstractImportExportBase {
|
||||
public:
|
||||
virtual bool importerTest() {
|
||||
|
@ -58,8 +61,21 @@ public:
|
|||
|
||||
return ( nullptr != scene );
|
||||
}
|
||||
|
||||
virtual bool exporterTest() {
|
||||
Assimp::Importer importer;
|
||||
const aiScene *scene = importer.ReadFile( ASSIMP_TEST_MODELS_DIR "/3MF/box.3mf", 0 );
|
||||
|
||||
Assimp::Exporter exporter;
|
||||
return nullptr != exporter.ExportToBlob( scene, "3mf", 0 );
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
TEST_F(utD3MFImporterExporter, import3MFFromFileTest) {
|
||||
EXPECT_TRUE(importerTest());
|
||||
}
|
||||
|
||||
TEST_F( utD3MFImporterExporter, export3MFtoMemTest ) {
|
||||
EXPECT_TRUE( exporterTest() );
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue