From e9c782234ba1216d7a7d92b3cd1696d0c4280fa3 Mon Sep 17 00:00:00 2001 From: Jean-Marie Verdun Date: Thu, 23 Mar 2017 21:43:46 +0100 Subject: [PATCH] Move Step reader to New Part Design workflow --- src/Mod/Import/App/ImportOCAF.cpp | 42 ++++++++++++++++++--------- src/Mod/Import/App/ImportOCAF.h | 10 ------- src/Mod/Import/Gui/AppImportGuiPy.cpp | 10 ------- 3 files changed, 29 insertions(+), 33 deletions(-) diff --git a/src/Mod/Import/App/ImportOCAF.cpp b/src/Mod/Import/App/ImportOCAF.cpp index 902337d433f0..84306b24f9a5 100644 --- a/src/Mod/Import/App/ImportOCAF.cpp +++ b/src/Mod/Import/App/ImportOCAF.cpp @@ -68,6 +68,7 @@ #include #include #include +#include #include #include #include "ImportOCAF.h" @@ -107,6 +108,7 @@ void ImportOCAF::loadShapes() std::vector lValue; myRefShapes.clear(); loadShapes(pDoc->Main(), TopLoc_Location(), default_name, "", false, lValue); + lValue.clear(); } void ImportOCAF::loadShapes(const TDF_Label& label, const TopLoc_Location& loc, @@ -205,20 +207,23 @@ void ImportOCAF::loadShapes(const TDF_Label& label, const TopLoc_Location& loc, } else { // This is probably an Assembly let's try to create a Compound with the name - Part::Compound *pcCompound = NULL; + App::Part *pcPart = NULL; if (aShapeTool->IsAssembly(label)) { - pcCompound = static_cast(doc->addObject - ("Part::Compound",asm_name.c_str())); + pcPart = static_cast(doc->addObject + ("App::Part",asm_name.c_str())); } for (TDF_ChildIterator it(label); it.More(); it.Next()) { loadShapes(it.Value(), part_loc, part_name, asm_name, isRef, localValue); } - if (pcCompound) { - pcCompound->Links.setValues(localValue); - lValue.push_back(pcCompound); - Node_Shapes.push_back(pcCompound->getNameInDocument()); + if (pcPart) { + for (std::size_t i=0; iaddObject((localValue[i])); + } + + if (!localValue.empty()) + lValue.push_back(pcPart); } } } @@ -238,8 +243,7 @@ void ImportOCAF::createShape(const TDF_Label& label, const TopLoc_Location& loc, int ctSolids = 0, ctShells = 0; std::vector localValue; - Part::Compound *pcCompound = static_cast(doc->addObject - ("Part::Compound",name.c_str() )); + App::Part *pcPart = NULL; for (xp.Init(aShape, TopAbs_SOLID); xp.More(); xp.Next(), ctSolids++) { createShape(xp.Current(), loc, name, localValue); } @@ -247,9 +251,18 @@ void ImportOCAF::createShape(const TDF_Label& label, const TopLoc_Location& loc, createShape(xp.Current(), loc, name, localValue); } - pcCompound->Links.setValues(localValue); - lValue.push_back(pcCompound); - Node_Shapes.push_back(pcCompound->getNameInDocument()); + if (!localValue.empty()) { + pcPart = static_cast(doc->addObject("App::Part",name.c_str())); + + // localValue contain the object that I must add to the local Part + // I must add the PartOrigin and the Part itself + for (std::size_t i=0; iaddObject(localValue[i]); + } + + lValue.push_back(pcPart); + } + if (ctSolids > 0 || ctShells > 0) return; } @@ -261,12 +274,15 @@ void ImportOCAF::createShape(const TopoDS_Shape& aShape, const TopLoc_Location& std::vector& lvalue) { Part::Feature* part = static_cast(doc->addObject("Part::Feature")); + + // I probably have to create a Part copy + // as to properly set it up into my new step tree if (!loc.IsIdentity()) part->Shape.setValue(aShape.Moved(loc)); else part->Shape.setValue(aShape); + part->Label.setValue(name); - Leaf_Shapes.push_back(part->getNameInDocument()); lvalue.push_back(part); Quantity_Color aColor; diff --git a/src/Mod/Import/App/ImportOCAF.h b/src/Mod/Import/App/ImportOCAF.h index 7d145882fef8..595e2ee7d83a 100644 --- a/src/Mod/Import/App/ImportOCAF.h +++ b/src/Mod/Import/App/ImportOCAF.h @@ -57,12 +57,6 @@ class ImportExport ImportOCAF ImportOCAF(Handle_TDocStd_Document h, App::Document* d, const std::string& name); virtual ~ImportOCAF(); void loadShapes(); - std::vector return_leaf() const { - return Leaf_Shapes; - } - std::vector return_node() const { - return Node_Shapes; - } private: void loadShapes(const TDF_Label& label, const TopLoc_Location&, const std::string& partname, const std::string& assembly, bool isRef, std::vector &); @@ -78,10 +72,6 @@ class ImportExport ImportOCAF std::string default_name; std::set myRefShapes; static const int HashUpper = INT_MAX; - // These variables are used to transfer Shape names to the UI backend and decide - // to activate / deactivate the right members for performance improvements - std::vector Leaf_Shapes; - std::vector Node_Shapes; }; class ImportExport ExportOCAF diff --git a/src/Mod/Import/Gui/AppImportGuiPy.cpp b/src/Mod/Import/Gui/AppImportGuiPy.cpp index cd05af12c935..ff51957c9cec 100644 --- a/src/Mod/Import/Gui/AppImportGuiPy.cpp +++ b/src/Mod/Import/Gui/AppImportGuiPy.cpp @@ -407,16 +407,6 @@ class Module : public Py::ExtensionModule ImportOCAFExt ocaf(hDoc, pcDoc, file.fileNamePure()); ocaf.loadShapes(); - - // Shape are loaded we must now sort the one we want to display and the one we do want to hide - Gui::Document *guiDoc = Gui::Application::Instance->activeDocument(); - std::vectorkeep_leaf= ocaf.return_leaf(); - for (std::vector::iterator it = keep_leaf.begin() ; it != keep_leaf.end(); ++it) - guiDoc->setShow((*it)); - std::vectorhide_node= ocaf.return_node(); - for (std::vector::iterator it = hide_node.begin() ; it != hide_node.end(); ++it) - guiDoc->setHide((*it)); - pcDoc->recompute(); } catch (Standard_Failure) {