From ef4efc52e50334044264d690e756b99f644228bf Mon Sep 17 00:00:00 2001 From: Jean-Marie Verdun Date: Sun, 9 Jul 2017 22:16:57 +0200 Subject: [PATCH] Improve hierarchical exporter --- src/Mod/Import/App/AppImportPy.cpp | 9 +++++++-- src/Mod/Import/App/ImportOCAF.cpp | 6 +++--- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/Mod/Import/App/AppImportPy.cpp b/src/Mod/Import/App/AppImportPy.cpp index 496a750647..48359bfc56 100644 --- a/src/Mod/Import/App/AppImportPy.cpp +++ b/src/Mod/Import/App/AppImportPy.cpp @@ -221,6 +221,7 @@ private: hApp->NewDocument(TCollection_ExtendedString("MDTV-CAF"), hDoc); bool keepExplicitPlacement = list.size() > 1; + Import::ExportOCAF ocaf(hDoc, keepExplicitPlacement); for (Py::Sequence::iterator it = list.begin(); it != list.end(); ++it) { @@ -230,7 +231,9 @@ private: if (obj->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId())) { Part::Feature* part = static_cast(obj); std::vector colors; - ocaf.saveShape(part, colors); + std::vector hierarchical_label; + std::vector hierarchical_loc; + ocaf.saveShape(part, colors, hierarchical_label, hierarchical_loc); } else { Base::Console().Message("'%s' is not a shape, export will be ignored.\n", obj->Label.getValue()); @@ -246,7 +249,9 @@ private: Part::Feature* part = static_cast(obj); App::PropertyColorList colors; colors.setPyObject(item1.ptr()); - ocaf.saveShape(part, colors.getValues()); + std::vector hierarchical_label; + std::vector hierarchical_loc; + ocaf.saveShape(part, colors.getValues(), hierarchical_label, hierarchical_loc); } else { Base::Console().Message("'%s' is not a shape, export will be ignored.\n", obj->Label.getValue()); diff --git a/src/Mod/Import/App/ImportOCAF.cpp b/src/Mod/Import/App/ImportOCAF.cpp index 6187f4d0c4..e4635a2f28 100644 --- a/src/Mod/Import/App/ImportOCAF.cpp +++ b/src/Mod/Import/App/ImportOCAF.cpp @@ -530,7 +530,7 @@ int ExportOCAF::saveShape(Part::Feature* part, const std::vector& co { const TopoDS_Shape& shape = part->Shape.getValue(); if (shape.IsNull()) - return; + return -1; TopoDS_Shape baseShape; TopLoc_Location aLoc; @@ -560,11 +560,11 @@ int ExportOCAF::saveShape(Part::Feature* part, const std::vector& co aShapeTool->SetShape(shapeLabel, baseShape); TDataStd_Name::Set(shapeLabel, TCollection_ExtendedString(part->Label.getValue(), 1)); - +/* if (keepExplicitPlacement) { aShapeTool->AddComponent(rootLabel, shapeLabel, aLoc); } - +*/ // Add color information Quantity_Color col;