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

Method loadShape

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

Source from the content-addressed store, hash-verified

655}
656
657App::DocumentObject* ImportOCAF2::loadShape(
658 App::Document* doc,
659 TDF_Label label,
660 const TopoDS_Shape& shape,
661 bool baseOnly,
662 bool newDoc
663)
664{
665 if (shape.IsNull()) {
666 return nullptr;
667 }
668
669 auto baseShape = shape.Located(TopLoc_Location());
670 auto it = myShapes.find(baseShape);
671 if (it == myShapes.end()) {
672 Info info;
673 auto baseLabel = aShapeTool->FindShape(baseShape);
674 if (sequencer && !baseLabel.IsNull() && aShapeTool->IsTopLevel(baseLabel)) {
675 sequencer->next(true);
676 }
677 bool res;
678 if (baseLabel.IsNull() || !aShapeTool->IsAssembly(baseLabel)) {
679 res = createObject(doc, baseLabel, baseShape, info, newDoc);
680 }
681 else {
682 res = createAssembly(doc, baseLabel, baseShape, info, newDoc);
683 }
684 if (!res) {
685 return nullptr;
686 }
687 setObjectName(info, baseLabel);
688 it = myShapes.emplace(baseShape, info).first;
689 }
690 if (baseOnly) {
691 return it->second.obj;
692 }
693
694 std::map<std::string, Base::Color> shuoColors;
695 if (!options.useLinkGroup) {
696 getSHUOColors(label, shuoColors, false);
697 }
698
699 auto info = it->second;
700 getColor(shape, info, true);
701
702 if (shuoColors.empty() && info.free && doc == info.obj->getDocument()) {
703 it->second.free = false;
704 auto name = getLabelName(label);
705 if (info.faceColor != it->second.faceColor || info.edgeColor != it->second.edgeColor
706 || (!name.empty() && !info.baseName.empty() && name != info.baseName)) {
707 auto compound = doc->addObject<Part::Compound2>("Compound");
708 compound->Links.setValue(info.obj);
709 info.propPlacement = &compound->Placement;
710 if (info.faceColor != it->second.faceColor) {
711 applyFaceColors(compound, {info.faceColor});
712 }
713 if (info.edgeColor != it->second.edgeColor) {
714 applyEdgeColors(compound, {info.edgeColor});

Callers

nothing calls this directly

Calls 15

createObjectFunction · 0.85
setObjectNameFunction · 0.85
applyFaceColorsFunction · 0.85
applyEdgeColorsFunction · 0.85
setPlacementFunction · 0.85
applyLinkColorFunction · 0.85
applyElementColorsFunction · 0.85
FindShapeMethod · 0.80
TopLoc_LocationClass · 0.70
getColorFunction · 0.50
IsNullMethod · 0.45
findMethod · 0.45

Tested by

no test coverage detected