Small refactoring on 3MF export
parent
c10d592b79
commit
0952038461
|
@ -137,7 +137,7 @@ bool D3MFExporter::exportContentTypes() {
|
||||||
mContentOutput << std::endl;
|
mContentOutput << std::endl;
|
||||||
mContentOutput << "</Types>";
|
mContentOutput << "</Types>";
|
||||||
mContentOutput << std::endl;
|
mContentOutput << std::endl;
|
||||||
exportContentTyp(XmlTag::CONTENT_TYPES_ARCHIVE);
|
zipContentType(XmlTag::CONTENT_TYPES_ARCHIVE);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -162,7 +162,7 @@ bool D3MFExporter::exportRelations() {
|
||||||
mRelOutput << "</Relationships>";
|
mRelOutput << "</Relationships>";
|
||||||
mRelOutput << std::endl;
|
mRelOutput << std::endl;
|
||||||
|
|
||||||
writeRelInfoToFile("_rels", ".rels");
|
zipRelInfo("_rels", ".rels");
|
||||||
mRelOutput.flush();
|
mRelOutput.flush();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -196,7 +196,7 @@ bool D3MFExporter::export3DModel() {
|
||||||
info->type = XmlTag::PACKAGE_START_PART_RELATIONSHIP_TYPE;
|
info->type = XmlTag::PACKAGE_START_PART_RELATIONSHIP_TYPE;
|
||||||
mRelations.push_back(info);
|
mRelations.push_back(info);
|
||||||
|
|
||||||
writeModelToArchive("3D", "3DModel.model");
|
zipModel("3D", "3DModel.model");
|
||||||
mModelOutput.flush();
|
mModelOutput.flush();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -357,42 +357,27 @@ void D3MFExporter::writeBuild() {
|
||||||
mModelOutput << std::endl;
|
mModelOutput << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
void D3MFExporter::exportContentTyp(const std::string &filename) {
|
void D3MFExporter::zipContentType(const std::string &filename) {
|
||||||
if (nullptr == m_zipArchive) {
|
addFileInZip(filename, mContentOutput.str());
|
||||||
throw DeadlyExportError("3MF-Export: Zip archive not valid, nullptr.");
|
|
||||||
}
|
|
||||||
const std::string entry = filename;
|
|
||||||
zip_entry_open(m_zipArchive, entry.c_str());
|
|
||||||
|
|
||||||
const std::string &exportTxt(mContentOutput.str());
|
|
||||||
zip_entry_write(m_zipArchive, exportTxt.c_str(), exportTxt.size());
|
|
||||||
|
|
||||||
zip_entry_close(m_zipArchive);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void D3MFExporter::writeModelToArchive(const std::string &folder, const std::string &modelName) {
|
void D3MFExporter::zipModel(const std::string &folder, const std::string &modelName) {
|
||||||
if (nullptr == m_zipArchive) {
|
|
||||||
throw DeadlyExportError("3MF-Export: Zip archive not valid, nullptr.");
|
|
||||||
}
|
|
||||||
const std::string entry = folder + "/" + modelName;
|
const std::string entry = folder + "/" + modelName;
|
||||||
zip_entry_open(m_zipArchive, entry.c_str());
|
addFileInZip(entry, mModelOutput.str());
|
||||||
|
|
||||||
const std::string &exportTxt(mModelOutput.str());
|
|
||||||
zip_entry_write(m_zipArchive, exportTxt.c_str(), exportTxt.size());
|
|
||||||
|
|
||||||
zip_entry_close(m_zipArchive);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void D3MFExporter::writeRelInfoToFile(const std::string &folder, const std::string &relName) {
|
void D3MFExporter::zipRelInfo(const std::string &folder, const std::string &relName) {
|
||||||
|
const std::string entry = folder + "/" + relName;
|
||||||
|
addFileInZip(entry, mRelOutput.str());
|
||||||
|
}
|
||||||
|
|
||||||
|
void D3MFExporter::addFileInZip(const std::string& entry, const std::string& content) {
|
||||||
if (nullptr == m_zipArchive) {
|
if (nullptr == m_zipArchive) {
|
||||||
throw DeadlyExportError("3MF-Export: Zip archive not valid, nullptr.");
|
throw DeadlyExportError("3MF-Export: Zip archive not valid, nullptr.");
|
||||||
}
|
}
|
||||||
const std::string entry = folder + "/" + relName;
|
|
||||||
zip_entry_open(m_zipArchive, entry.c_str());
|
zip_entry_open(m_zipArchive, entry.c_str());
|
||||||
|
zip_entry_write(m_zipArchive, content.c_str(), content.size());
|
||||||
const std::string &exportTxt(mRelOutput.str());
|
|
||||||
zip_entry_write(m_zipArchive, exportTxt.c_str(), exportTxt.size());
|
|
||||||
|
|
||||||
zip_entry_close(m_zipArchive);
|
zip_entry_close(m_zipArchive);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue