diff --git a/src/Mod/Import/App/ImportOCAF.cpp b/src/Mod/Import/App/ImportOCAF.cpp
index 8e1ffe54e0..7c393e7c09 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 dbf077d90e..c5fac0472f 100644
--- a/src/Mod/Import/App/ImportOCAF.h
+++ b/src/Mod/Import/App/ImportOCAF.h
@@ -35,6 +35,8 @@
#include