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

Method createGroup

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

Source from the content-addressed store, hash-verified

457}
458
459bool ImportOCAF2::createGroup(
460 App::Document* doc,
461 Info& info,
462 const TopoDS_Shape& shape,
463 std::vector<App::DocumentObject*>& children,
464 const boost::dynamic_bitset<>& visibilities,
465 bool canReduce
466)
467{
468 assert(children.size() == visibilities.size());
469 if (children.empty()) {
470 return false;
471 }
472 bool hasColor = getColor(shape, info, false, true);
473 if (canReduce && !hasColor && options.reduceObjects && children.size() == 1 && visibilities[0]) {
474 info.obj = children.front();
475 info.free = true;
476 info.propPlacement = dynamic_cast<App::PropertyPlacement*>(
477 info.obj->getPropertyByName("Placement")
478 );
479 myCollapsedObjects.emplace(info.obj, info.propPlacement);
480 return true;
481 }
482 auto group = doc->addObject<App::LinkGroup>("LinkGroup");
483 for (auto& child : children) {
484 if (child->getDocument() != doc) {
485 auto link = doc->addObject<App::Link>("Link");
486 link->Label.setValue(child->Label.getValue());
487 link->setLink(-1, child);
488 auto pla = freecad_cast<App::PropertyPlacement*>(child->getPropertyByName("Placement"));
489 if (pla) {
490 link->Placement.setValue(pla->getValue());
491 }
492 child = link;
493 }
494 }
495 group->ElementList.setValues(children);
496 group->VisibilityList.setValue(visibilities);
497 info.obj = group;
498 info.propPlacement = &group->Placement;
499 if (getColor(shape, info, false, true)) {
500 if (info.hasFaceColor) {
501 applyLinkColor(group, -1, info.faceColor);
502 }
503 }
504 return true;
505}
506
507App::DocumentObject* ImportOCAF2::loadShapes()
508{

Callers

nothing calls this directly

Calls 12

applyLinkColorFunction · 0.85
getColorFunction · 0.50
sizeMethod · 0.45
emptyMethod · 0.45
frontMethod · 0.45
getPropertyByNameMethod · 0.45
emplaceMethod · 0.45
getDocumentMethod · 0.45
setValueMethod · 0.45
getValueMethod · 0.45
setLinkMethod · 0.45
setValuesMethod · 0.45

Tested by

no test coverage detected