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

Function getElementSource

src/Mod/Part/App/PartFeature.cpp:508–599  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

506}
507
508static std::vector<std::pair<long, Data::MappedName>> getElementSource(
509 App::DocumentObject* owner,
510 TopoShape shape,
511 const Data::MappedName& name,
512 char type
513)
514{
515 std::set<std::pair<App::Document*, long>> tagSet;
516 std::vector<std::pair<long, Data::MappedName>> ret;
517 ret.emplace_back(0, name);
518 int depth = 0;
519 while (1) {
520 Data::MappedName original;
521 std::vector<Data::MappedName> history;
522 // It is possible the name does not belong to the shape, e.g. when user
523 // changes modeling order in PartDesign. So we try to assign the
524 // document hasher here in case getElementHistory() needs to de-hash
525 if (!shape.Hasher && owner) {
526 shape.Hasher = owner->getDocument()->getStringHasher();
527 }
528 long tag = shape.getElementHistory(ret.back().second, &original, &history);
529 if (!tag) {
530 break;
531 }
532 auto obj = owner;
533 App::Document* doc = nullptr;
534 if (owner) {
535 doc = owner->getDocument();
536 for (;; ++depth) {
537 auto linked = owner->getLinkedObject(false, nullptr, false, depth);
538 if (linked == owner) {
539 break;
540 }
541 owner = linked;
542 if (owner->getDocument() != doc) {
543 doc = owner->getDocument();
544 break;
545 }
546 }
547 if (owner->isDerivedFrom<App::GeoFeature>()) {
548 auto ownerGeoFeature = static_cast<App::GeoFeature*>(owner)->getElementOwner(
549 ret.back().second
550 );
551 if (ownerGeoFeature) {
552 doc = ownerGeoFeature->getDocument();
553 }
554 }
555 obj = doc->getObjectByID(tag < 0 ? -tag : tag);
556 if (type) {
557 for (auto& hist : history) {
558 if (shape.elementType(hist) != type) {
559 return ret;
560 }
561 }
562 }
563 }
564 owner = 0;
565 if (!obj) {

Callers 1

getRelatedElementsMethod · 0.85

Calls 13

absFunction · 0.85
getStringHasherMethod · 0.80
getObjectByIDMethod · 0.80
elementTypeMethod · 0.80
TopoDS_ShapeClass · 0.70
getDocumentMethod · 0.45
getElementHistoryMethod · 0.45
backMethod · 0.45
getLinkedObjectMethod · 0.45
setShapeMethod · 0.45
insertMethod · 0.45
isEnabledMethod · 0.45

Tested by

no test coverage detected