| 591 | } |
| 592 | |
| 593 | void SubShapeBinder::update(SubShapeBinder::UpdateOption options) |
| 594 | { |
| 595 | Part::TopoShape result; |
| 596 | std::vector<Part::TopoShape> shapes; |
| 597 | std::vector<std::pair<int, int>> shapeOwners; |
| 598 | std::vector<const Base::Matrix4D*> shapeMats; |
| 599 | |
| 600 | bool forced = (Shape.getValue().IsNull() || (options & UpdateForced)) ? true : false; |
| 601 | bool init = (!forced && (options & UpdateForced)) ? true : false; |
| 602 | |
| 603 | std::string errMsg; |
| 604 | auto parent = Context.getValue(); |
| 605 | std::string parentSub = Context.getSubName(false); |
| 606 | if (!Relative.getValue()) { |
| 607 | parent = nullptr; |
| 608 | } |
| 609 | else { |
| 610 | if (parent && parent->getSubObject(parentSub.c_str()) == this) { |
| 611 | auto parents = parent->getParents(); |
| 612 | if (!parents.empty()) { |
| 613 | parent = parents.begin()->first; |
| 614 | parentSub = parents.begin()->second + parentSub; |
| 615 | } |
| 616 | } |
| 617 | else { |
| 618 | parent = nullptr; |
| 619 | } |
| 620 | if (!parent && parentSub.empty()) { |
| 621 | auto parents = getParents(); |
| 622 | if (!parents.empty()) { |
| 623 | parent = parents.begin()->first; |
| 624 | parentSub = parents.begin()->second; |
| 625 | } |
| 626 | } |
| 627 | if (parent && (parent != Context.getValue() || parentSub != Context.getSubName(false))) { |
| 628 | Context.setValue(parent, parentSub.c_str()); |
| 629 | } |
| 630 | } |
| 631 | |
| 632 | bool first = false; |
| 633 | std::unordered_map<const App::DocumentObject*, Base::Matrix4D> mats; |
| 634 | int idx = -1; |
| 635 | for (auto& l : Support.getSubListValues()) { |
| 636 | ++idx; |
| 637 | auto obj = l.getValue(); |
| 638 | if (!obj || !obj->isAttachedToDocument()) { |
| 639 | continue; |
| 640 | } |
| 641 | auto res = mats.emplace(obj, Base::Matrix4D()); |
| 642 | if (parent && res.second) { |
| 643 | std::string resolvedSub = parentSub; |
| 644 | std::string linkSub; |
| 645 | auto link = obj; |
| 646 | auto resolved = parent->resolveRelativeLink(resolvedSub, link, linkSub); |
| 647 | if (!resolved) { |
| 648 | if (!link) { |
| 649 | FC_WARN( |
| 650 | getFullName() << " cannot resolve relative link of " << parent->getFullName() |
no test coverage detected