Mesh: move Extension3MFFactory outside Exporter3MF

This commit is contained in:
wmayer
2022-09-26 11:05:01 +02:00
parent cbc5cf8ee0
commit 50bd4d8428
3 changed files with 11 additions and 10 deletions

View File

@@ -269,7 +269,8 @@ private:
exporter.reset( new ExporterAMF(outputFileName, meta, exportAmfCompressed) );
}
else if (exportFormat == MeshIO::ThreeMF) {
exporter.reset( new Exporter3MF(outputFileName) );
Extension3MFFactory::initialize();
exporter.reset( new Exporter3MF(outputFileName, Extension3MFFactory::createExtensions()) );
}
else if (exportFormat != MeshIO::Undefined) {
exporter.reset( new MergeExporter(outputFileName, exportFormat) );

View File

@@ -257,7 +257,7 @@ void Extension3MFFactory::initialize()
}
}
std::vector<Extension3MFPtr> Extension3MFFactory::create()
std::vector<Extension3MFPtr> Extension3MFFactory::createExtensions()
{
std::vector<Extension3MFPtr> ext;
for (const auto& it : producer) {
@@ -272,19 +272,19 @@ std::vector<Extension3MFProducerPtr> Extension3MFFactory::producer;
class Exporter3MF::Private {
public:
explicit Private(const std::string& filename)
: writer3mf(filename) {
Extension3MFFactory::initialize();
ext = Extension3MFFactory::create();
explicit Private(const std::string& filename,
const std::vector<Extension3MFPtr>& ext)
: writer3mf(filename)
, ext(ext) {
}
MeshCore::Writer3MF writer3mf;
std::vector<Extension3MFPtr> ext;
};
Exporter3MF::Exporter3MF(std::string fileName)
Exporter3MF::Exporter3MF(std::string fileName, const std::vector<Extension3MFPtr>& ext)
{
throwIfNoPermission(fileName);
d.reset(new Private(fileName));
d.reset(new Private(fileName, ext));
}
Exporter3MF::~Exporter3MF()

View File

@@ -171,7 +171,7 @@ class MeshExport Extension3MFFactory
public:
static void addProducer(Extension3MFProducer* ext);
static void initialize();
static std::vector<Extension3MFPtr> create();
static std::vector<Extension3MFPtr> createExtensions();
private:
static std::vector<Extension3MFProducerPtr> producer;
@@ -187,7 +187,7 @@ private:
class Exporter3MF : public Exporter
{
public:
Exporter3MF(std::string fileName);
Exporter3MF(std::string fileName, const std::vector<Extension3MFPtr>& = {});
~Exporter3MF() override;
bool addMesh(const char *name, const MeshObject & mesh) override;