diff --git a/src/Mod/Mesh/App/Exporter.cpp b/src/Mod/Mesh/App/Exporter.cpp index 2ec054d986..bd21ff0106 100644 --- a/src/Mod/Mesh/App/Exporter.cpp +++ b/src/Mod/Mesh/App/Exporter.cpp @@ -50,9 +50,9 @@ using namespace Mesh; using namespace MeshCore; static std::vector -expandSubObjects(const App::DocumentObject *obj, - std::map > &cache, - int depth) +expandSubObjectNames(const App::DocumentObject *obj, + std::map > &subObjectNameCache, + int depth) { if (!App::GetApplication().checkLinkDepth(depth)) return {}; @@ -72,9 +72,10 @@ expandSubObjects(const App::DocumentObject *obj, if (!sobj || (vis < 0 && !sobj->Visibility.getValue())) continue; auto linked = sobj->getLinkedObject(true); - auto it = cache.find(linked); - if (it == cache.end()) - it = cache.emplace(linked, expandSubObjects(linked, cache, depth+1)).first; + auto it = subObjectNameCache.find(linked); + if (it == subObjectNameCache.end()) + it = subObjectNameCache.emplace( + linked, expandSubObjectNames(linked, subObjectNameCache, depth+1)).first; for (auto & ssub : it->second) res.push_back(sub + ssub); } @@ -99,7 +100,7 @@ std::string Exporter::xmlEscape(const std::string &input) int Exporter::addObject(App::DocumentObject *obj, float tol) { int count = 0; - for (std::string & sub : expandSubObjects(obj, cache, 0)) { + for (std::string & sub : expandSubObjectNames(obj, subObjectNameCache, 0)) { Base::Matrix4D matrix; auto sobj = obj->getSubObject(sub.c_str(), nullptr, &matrix); auto linked = sobj->getLinkedObject(true, &matrix, false); diff --git a/src/Mod/Mesh/App/Exporter.h b/src/Mod/Mesh/App/Exporter.h index 3b0b564b57..9ed7f7243c 100644 --- a/src/Mod/Mesh/App/Exporter.h +++ b/src/Mod/Mesh/App/Exporter.h @@ -52,6 +52,14 @@ class Exporter Exporter(); virtual ~Exporter() = default; + /// Add object and all subobjects and links etc. Returns the number of stuff added. + /*! + * @param obj The object to export. If this is a group like object, its + * sub-objects will be added. + * @param tol The tolerance/accuracy with which to generate the triangle mesh + * @return The number of objects/subobjects that was exported from the document. + See the parameter `accuracy` of ComplexGeoData::getFaces + */ int addObject(App::DocumentObject *obj, float tol); virtual bool addMesh(const char *name, const MeshObject & mesh) = 0; @@ -60,7 +68,7 @@ class Exporter /// Does some simple escaping of characters for XML-type exports static std::string xmlEscape(const std::string &input); - std::map > cache; + std::map > subObjectNameCache; std::map meshCache; };