MCPcopy Create free account
hub / github.com/FreeCAD/FreeCAD / createAssembly

Method createAssembly

src/Mod/Import/App/ImportOCAF2.cpp:749–877  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

747};
748
749bool ImportOCAF2::createAssembly(
750 App::Document* _doc,
751 TDF_Label label,
752 const TopoDS_Shape& shape,
753 Info& info,
754 bool newDoc
755)
756{
757 (void)label;
758
759 std::vector<App::DocumentObject*> children;
760 std::map<App::DocumentObject*, ChildInfo> childrenMap;
761 boost::dynamic_bitset<> visibilities;
762 std::map<std::string, Base::Color> shuoColors;
763
764 auto doc = _doc;
765 if (newDoc) {
766 doc = getDocument(_doc, label);
767 }
768
769 for (TopoDS_Iterator it(shape, Standard_False, Standard_False); it.More(); it.Next()) {
770 TopoDS_Shape childShape = it.Value();
771 if (childShape.IsNull()) {
772 continue;
773 }
774 TDF_Label childLabel;
775 aShapeTool->Search(childShape, childLabel, Standard_True, Standard_True, Standard_False);
776 if (!childLabel.IsNull() && !options.importHidden && !aColorTool->IsVisible(childLabel)) {
777 continue;
778 }
779 auto obj = loadShape(doc, childLabel, childShape, options.reduceObjects);
780 if (!obj) {
781 continue;
782 }
783 bool vis = true;
784 if (!childLabel.IsNull() && aShapeTool->IsComponent(childLabel)) {
785 vis = aColorTool->IsVisible(childLabel);
786 }
787 if (!options.reduceObjects) {
788 visibilities.push_back(vis);
789 children.push_back(obj);
790 getSHUOColors(childLabel, shuoColors, true);
791 continue;
792 }
793
794 auto& childInfo = childrenMap[obj];
795 if (childInfo.plas.empty()) {
796 children.push_back(obj);
797 visibilities.push_back(vis);
798 childInfo.shape = childShape;
799 }
800
801 childInfo.vis.push_back(vis);
802 childInfo.labels.push_back(childLabel);
803 childInfo.plas.emplace_back(Part::TopoShape::convert(childShape.Location().Transformation()));
804 Quantity_ColorRGBA aColor;
805 if (aColorTool->GetColor(childShape, XCAFDoc_ColorSurf, aColor)) {
806 childInfo.colors[childInfo.plas.size() - 1] = Tools::convertColor(aColor);

Callers

nothing calls this directly

Calls 15

applyLinkColorFunction · 0.85
setObjectNameFunction · 0.85
applyElementColorsFunction · 0.85
GetColorMethod · 0.80
closeDocumentMethod · 0.80
getDocumentFunction · 0.50
convertFunction · 0.50
to_stringFunction · 0.50
MoreMethod · 0.45
NextMethod · 0.45
ValueMethod · 0.45
IsNullMethod · 0.45

Tested by

no test coverage detected