From f10a43678767c822b3d2fac4fe388b197bd47fca Mon Sep 17 00:00:00 2001 From: Jean-Marie Verdun Date: Sun, 22 Jan 2017 18:29:10 +0100 Subject: [PATCH] STEP reader improvements Create Global STEP Tree when assemblies are present Make TBB usage dependant of its activation status at CMake Level Fix hierarchy opening into STEP Assembly --- src/Mod/Import/App/ImportOCAF.cpp | 60 +++++++++++++++++++++++-------- src/Mod/Import/App/ImportOCAF.h | 8 +++-- 2 files changed, 52 insertions(+), 16 deletions(-) diff --git a/src/Mod/Import/App/ImportOCAF.cpp b/src/Mod/Import/App/ImportOCAF.cpp index 8e1ffe54e021..7c393e7c0926 100644 --- a/src/Mod/Import/App/ImportOCAF.cpp +++ b/src/Mod/Import/App/ImportOCAF.cpp @@ -64,17 +64,25 @@ # endif #endif -#include "ImportOCAF.h" +// #include "ImportOCAF.h" #include #include #include #include #include #include +#include "ImportOCAF.h" #include #include #include +#ifdef HAVE_TBB +#include +#include +#include +#endif + + using namespace Import; @@ -94,15 +102,23 @@ ImportOCAF::~ImportOCAF() void ImportOCAF::loadShapes() { + std::vector lValue; myRefShapes.clear(); - loadShapes(pDoc->Main(), TopLoc_Location(), default_name, "", false); + loadShapes(pDoc->Main(), TopLoc_Location(), default_name, "", false,lValue); } void ImportOCAF::loadShapes(const TDF_Label& label, const TopLoc_Location& loc, - const std::string& defaultname, const std::string& /*assembly*/, bool isRef) + const std::string& defaultname, const std::string& /*assembly*/, bool isRef, std::vector& lValue) { int hash = 0; +#ifdef HAVE_TBB + using namespace tbb; + task_group g; +#endif TopoDS_Shape aShape; + + std::vector localValue; + if (aShapeTool->GetShape(label,aShape)) { hash = aShape.HashCode(HashUpper); } @@ -167,7 +183,7 @@ void ImportOCAF::loadShapes(const TDF_Label& label, const TopLoc_Location& loc, TDF_Label ref; if (aShapeTool->IsReference(label) && aShapeTool->GetReferredShape(label, ref)) { - loadShapes(ref, part_loc, part_name, asm_name, true); + loadShapes(ref, part_loc, part_name, asm_name, true, lValue); } if (isRef || myRefShapes.find(hash) == myRefShapes.end()) { @@ -179,39 +195,55 @@ void ImportOCAF::loadShapes(const TDF_Label& label, const TopLoc_Location& loc, if (!asm_name.empty()) part_name = asm_name; if (isRef) - createShape(label, loc, part_name); + createShape(label, loc, part_name, lValue); else - createShape(label, part_loc, part_name); + createShape(label, part_loc, part_name, localValue); } else { + // This is probably an Assembly let's try to create a Compound with the name + Part::Compound *pcCompound = NULL; + if (aShapeTool->IsAssembly(label)) { + pcCompound = static_cast(doc->addObject + ("Part::Compound",asm_name.c_str() )); + } + for (TDF_ChildIterator it(label); it.More(); it.Next()) { - loadShapes(it.Value(), part_loc, part_name, asm_name, isRef); + loadShapes(it.Value(), part_loc, part_name, asm_name, isRef, localValue); } + if (pcCompound) + pcCompound->Links.setValues(localValue); + lValue.push_back(pcCompound); } } } -void ImportOCAF::createShape(const TDF_Label& label, const TopLoc_Location& loc, const std::string& name) +void ImportOCAF::createShape(const TDF_Label& label, const TopLoc_Location& loc, const std::string& name, std::vector& lValue) { const TopoDS_Shape& aShape = aShapeTool->GetShape(label); - std::vector lValue; +#ifdef HAVE_TBB + using namespace tbb; + task_group g; +#endif if (!aShape.IsNull() && aShape.ShapeType() == TopAbs_COMPOUND) { TopExp_Explorer xp; int ctSolids = 0, ctShells = 0; + std::vector localValue; Part::Compound *pcCompound = static_cast(doc->addObject ("Part::Compound",name.c_str() )); for (xp.Init(aShape, TopAbs_SOLID); xp.More(); xp.Next(), ctSolids++) - createShape(xp.Current(), loc, name, lValue); + { + createShape(xp.Current(), loc, name, localValue); + } for (xp.Init(aShape, TopAbs_SHELL, TopAbs_SOLID); xp.More(); xp.Next(), ctShells++) - createShape(xp.Current(), loc, name, lValue); - pcCompound->Links.setValues(lValue); + createShape(xp.Current(), loc, name, localValue); + pcCompound->Links.setValues(localValue); + lValue.push_back(pcCompound); if (ctSolids > 0 || ctShells > 0) return; } - - createShape(aShape, loc, name, lValue); + createShape(aShape, loc, name, lValue); } void ImportOCAF::createShape(const TopoDS_Shape& aShape, const TopLoc_Location& loc, const std::string& name, diff --git a/src/Mod/Import/App/ImportOCAF.h b/src/Mod/Import/App/ImportOCAF.h index dbf077d90ea4..c5fac0472f8a 100644 --- a/src/Mod/Import/App/ImportOCAF.h +++ b/src/Mod/Import/App/ImportOCAF.h @@ -35,6 +35,8 @@ #include #include #include +#include + class TDF_Label; class TopLoc_Location; @@ -57,8 +59,10 @@ class ImportExport ImportOCAF void loadShapes(); private: - void loadShapes(const TDF_Label& label, const TopLoc_Location&, const std::string& partname, const std::string& assembly, bool isRef); - void createShape(const TDF_Label& label, const TopLoc_Location&, const std::string&); +// void loadShapes(const TDF_Label& label, const TopLoc_Location&, const std::string& partname, const std::string& assembly, bool isRef); + void loadShapes(const TDF_Label& label, const TopLoc_Location&, const std::string& partname, const std::string& assembly, bool isRef, std::vector &); +// void createShape(const TDF_Label& label, const TopLoc_Location&, const std::string&); + void createShape(const TDF_Label& label, const TopLoc_Location&, const std::string&, std::vector &); void createShape(const TopoDS_Shape& label, const TopLoc_Location&, const std::string&, std::vector &); virtual void applyColors(Part::Feature*, const std::vector&){}