Skip to content

Commit

Permalink
Mesh: [skip ci] support compressed X3D output
Browse files Browse the repository at this point in the history
  • Loading branch information
wwmayer committed Aug 29, 2020
1 parent f50c4a9 commit 66617c5
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/Mod/Mesh/App/Core/MeshIO.cpp
Expand Up @@ -1772,6 +1772,7 @@ std::vector<std::string> MeshOutput::supportedMeshFormats()
fmt.emplace_back("off");
fmt.emplace_back("smf");
fmt.emplace_back("x3d");
fmt.emplace_back("x3dz");
fmt.emplace_back("xhtml");
fmt.emplace_back("wrl");
fmt.emplace_back("wrz");
Expand Down Expand Up @@ -1813,6 +1814,9 @@ MeshIO::Format MeshOutput::GetFormat(const char* FileName)
else if (file.hasExtension("x3d")) {
return MeshIO::X3D;
}
else if (file.hasExtension("x3dz")) {
return MeshIO::X3DZ;
}
else if (file.hasExtension("xhtml")) {
return MeshIO::X3DOM;
}
Expand Down Expand Up @@ -1928,6 +1932,13 @@ bool MeshOutput::SaveAny(const char* FileName, MeshIO::Format format) const
if (!SaveX3D(str))
throw Base::FileException("Export of X3D failed",FileName);
}
else if (fileformat == MeshIO::X3DZ) {
// Compressed X3D is nothing else than a GZIP'ped X3D ascii file
zipios::GZIPOutputStream gzip(str);
// write file
if (!SaveX3D(gzip))
throw Base::FileException("Export of compressed X3D mesh failed",FileName);
}
else if (fileformat == MeshIO::X3DOM) {
// write file
if (!SaveX3DOM(str))
Expand Down
1 change: 1 addition & 0 deletions src/Mod/Mesh/App/Core/MeshIO.h
Expand Up @@ -50,6 +50,7 @@ namespace MeshIO {
MGL,
IV,
X3D,
X3DZ,
X3DOM,
VRML,
WRZ,
Expand Down
2 changes: 2 additions & 0 deletions src/Mod/Mesh/App/MeshPyImp.cpp
Expand Up @@ -169,6 +169,7 @@ PyObject* MeshPy::read(PyObject *args, PyObject *kwds)
ext["OFF" ] = MeshCore::MeshIO::OFF;
ext["IV" ] = MeshCore::MeshIO::IV;
ext["X3D" ] = MeshCore::MeshIO::X3D;
ext["X3DZ"] = MeshCore::MeshIO::X3DZ;
ext["VRML"] = MeshCore::MeshIO::VRML;
ext["WRL" ] = MeshCore::MeshIO::VRML;
ext["WRZ" ] = MeshCore::MeshIO::WRZ;
Expand Down Expand Up @@ -220,6 +221,7 @@ PyObject* MeshPy::write(PyObject *args, PyObject *kwds)
ext["MGL" ] = MeshCore::MeshIO::MGL;
ext["IV" ] = MeshCore::MeshIO::IV;
ext["X3D" ] = MeshCore::MeshIO::X3D;
ext["X3DZ" ] = MeshCore::MeshIO::X3DZ;
ext["X3DOM"] = MeshCore::MeshIO::X3DOM;
ext["VRML" ] = MeshCore::MeshIO::VRML;
ext["WRL" ] = MeshCore::MeshIO::VRML;
Expand Down
1 change: 1 addition & 0 deletions src/Mod/Mesh/Gui/Command.cpp
Expand Up @@ -516,6 +516,7 @@ void CmdMeshExport::activated(int)
ext << qMakePair<QString, QByteArray>(QString::fromLatin1("%1 (*.off)").arg(QObject::tr("Object File Format")), "OFF");
ext << qMakePair<QString, QByteArray>(QString::fromLatin1("%1 (*.iv)").arg(QObject::tr("Inventor V2.1 ascii")), "IV");
ext << qMakePair<QString, QByteArray>(QString::fromLatin1("%1 (*.x3d)").arg(QObject::tr("X3D Extensible 3D")), "X3D");
ext << qMakePair<QString, QByteArray>(QString::fromLatin1("%1 (*.x3dz)").arg(QObject::tr("Compressed X3D")), "X3DZ");
ext << qMakePair<QString, QByteArray>(QString::fromLatin1("%1 (*.xhtml)").arg(QObject::tr("WebGL/X3D")), "X3DOM");
ext << qMakePair<QString, QByteArray>(QString::fromLatin1("%1 (*.ply)").arg(QObject::tr("Stanford Polygon")), "PLY");
ext << qMakePair<QString, QByteArray>(QString::fromLatin1("%1 (*.wrl *.vrml)").arg(QObject::tr("VRML V2.0")), "VRML");
Expand Down

0 comments on commit 66617c5

Please sign in to comment.