| 457 | } |
| 458 | |
| 459 | bool 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 | |
| 507 | App::DocumentObject* ImportOCAF2::loadShapes() |
| 508 | { |
nothing calls this directly
no test coverage detected