diff --git a/src/Mod/Import/App/ImportOCAF.cpp b/src/Mod/Import/App/ImportOCAF.cpp index 5b4fd337161f..395f6d2fb424 100644 --- a/src/Mod/Import/App/ImportOCAF.cpp +++ b/src/Mod/Import/App/ImportOCAF.cpp @@ -70,6 +70,7 @@ #include #include #include +#include #include #include #include @@ -193,21 +194,28 @@ void ImportOCAF::loadShapes(const TDF_Label& label, const TopLoc_Location& loc, void ImportOCAF::createShape(const TDF_Label& label, const TopLoc_Location& loc, const std::string& name) { const TopoDS_Shape& aShape = aShapeTool->GetShape(label); + BRep_Builder aBuilder; + std::vector lValue; + if (!aShape.IsNull() && aShape.ShapeType() == TopAbs_COMPOUND) { TopExp_Explorer xp; int ctSolids = 0, ctShells = 0; + + 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); + createShape(xp.Current(), loc, name, lValue); for (xp.Init(aShape, TopAbs_SHELL, TopAbs_SOLID); xp.More(); xp.Next(), ctShells++) - createShape(xp.Current(), loc, name); + createShape(xp.Current(), loc, name, lValue); + pcCompound->Links.setValues(lValue); if (ctSolids > 0 || ctShells > 0) return; } - createShape(aShape, loc, name); + createShape(aShape, loc, name,lValue); } -void ImportOCAF::createShape(const TopoDS_Shape& aShape, const TopLoc_Location& loc, const std::string& name) +void ImportOCAF::createShape(const TopoDS_Shape& aShape, const TopLoc_Location& loc, const std::string& name,std::vector& lvalue) { Part::Feature* part = static_cast(doc->addObject("Part::Feature")); if (!loc.IsIdentity()) @@ -215,6 +223,7 @@ void ImportOCAF::createShape(const TopoDS_Shape& aShape, const TopLoc_Location& else part->Shape.setValue(aShape); part->Label.setValue(name); + lvalue.push_back(part); Quantity_Color aColor; App::Color color(0.8f,0.8f,0.8f); diff --git a/src/Mod/Import/App/ImportOCAF.h b/src/Mod/Import/App/ImportOCAF.h index c03483ade4ab..dbf077d90ea4 100644 --- a/src/Mod/Import/App/ImportOCAF.h +++ b/src/Mod/Import/App/ImportOCAF.h @@ -59,7 +59,7 @@ class ImportExport ImportOCAF 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 createShape(const TopoDS_Shape& label, const TopLoc_Location&, const std::string&); + void createShape(const TopoDS_Shape& label, const TopLoc_Location&, const std::string&, std::vector &); virtual void applyColors(Part::Feature*, const std::vector&){} private: