diff --git a/src/Mod/Import/App/ExportOCAF.cpp b/src/Mod/Import/App/ExportOCAF.cpp index 5ea2287482..4f874d1d13 100644 --- a/src/Mod/Import/App/ExportOCAF.cpp +++ b/src/Mod/Import/App/ExportOCAF.cpp @@ -103,6 +103,7 @@ using namespace Import; ExportOCAF::ExportOCAF(Handle(TDocStd_Document) h, bool explicitPlacement) : pDoc(h) , keepExplicitPlacement(explicitPlacement) + , filterBaseFeature(true) { aShapeTool = XCAFDoc_DocumentTool::ShapeTool(pDoc->Main()); aColorTool = XCAFDoc_DocumentTool::ColorTool(pDoc->Main()); @@ -121,6 +122,48 @@ ExportOCAF::~ExportOCAF() { } +std::vector ExportOCAF::filterPart(App::Part* part) const +{ + // Ignore shape of a Part that is referenced by a FeatureBase (#0003807) + // + std::vector entries = part->Group.getValues(); + + // get FeatureBases of the out-lists of the features of the Part + Base::Type featureBase = Base::Type::fromName("PartDesign::FeatureBase"); + std::vector filterType; + for (auto it : entries) { + std::vector outList = it->getOutList(); + for (auto jt : outList) { + if (jt->getTypeId() == featureBase) { + filterType.push_back(jt); + } + } + } + + // now check if for a feature of the Part it must be filtered + if (!filterType.empty()) { + std::vector keepObjects; + for (auto it : entries) { + std::vector inList = it->getInList(); + bool accept = true; + for (auto jt : inList) { + auto kt = std::find(filterType.begin(), filterType.end(), jt); + if (kt != filterType.end()) { + accept = false; + break; + } + } + + if (accept) + keepObjects.push_back(it); + } + + entries.swap(keepObjects); + } + + return entries; +} + int ExportOCAF::exportObject(App::DocumentObject* obj, std::vector & hierarchical_label, std::vector & hierarchical_loc, @@ -132,11 +175,15 @@ int ExportOCAF::exportObject(App::DocumentObject* obj, if (obj->getTypeId().isDerivedFrom(App::Part::getClassTypeId())) { App::Part* part = static_cast(obj); - // I shall recusrively select the elements and call back + // I shall recursively select the elements and call back std::vector entries = part->Group.getValues(); std::vector::iterator it; - for ( it = entries.begin(); it != entries.end(); it++ ) { + if (filterBaseFeature) { + entries = filterPart(part); + } + + for (it = entries.begin(); it != entries.end(); ++it) { int new_label=0; new_label = exportObject((*it), hierarchical_label, hierarchical_loc, hierarchical_part); local_label.push_back(new_label); diff --git a/src/Mod/Import/App/ExportOCAF.h b/src/Mod/Import/App/ExportOCAF.h index 1f555d04df..767c746947 100644 --- a/src/Mod/Import/App/ExportOCAF.h +++ b/src/Mod/Import/App/ExportOCAF.h @@ -85,6 +85,7 @@ public: private: virtual void findColors(Part::Feature*, std::vector&) const {} + std::vector filterPart(App::Part* part) const; private: Handle(TDocStd_Document) pDoc; @@ -92,6 +93,7 @@ private: Handle(XCAFDoc_ColorTool) aColorTool; TDF_Label rootLabel; bool keepExplicitPlacement; + bool filterBaseFeature; }; class ImportExport ExportOCAFCmd : public ExportOCAF