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

Method getParents

src/App/DocumentObject.cpp:1279–1319  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1277}
1278
1279std::vector<std::pair<App::DocumentObject*, std::string>>
1280DocumentObject::getParents(int depth) const
1281{
1282 std::vector<std::pair<App::DocumentObject*, std::string>> ret;
1283 if (!isAttachedToDocument() || !GetApplication().checkLinkDepth(depth, MessageOption::Throw)) {
1284 return ret;
1285 }
1286
1287 std::string name(getNameInDocument());
1288 name += ".";
1289 for (auto parent : getInList()) {
1290 if (!parent || !parent->isAttachedToDocument()) {
1291 continue;
1292 }
1293
1294 if (!parent->hasChildElement()
1295 && !parent->hasExtension(GeoFeatureGroupExtension::getExtensionClassTypeId())) {
1296 continue;
1297 }
1298
1299 if (!parent->getSubObject(name.c_str())) {
1300 continue;
1301 }
1302
1303 auto links = GetApplication().getLinksTo(parent, App::GetLinkRecursive);
1304 links.insert(parent);
1305
1306 for (auto parent : links) {
1307 auto parents = parent->getParents(depth + 1);
1308 if (parents.empty()) {
1309 parents.emplace_back(parent, std::string());
1310 }
1311
1312 for (auto& v : parents) {
1313 ret.emplace_back(v.first, v.second + name);
1314 }
1315 }
1316 }
1317
1318 return ret;
1319}
1320
1321App::DocumentObject* DocumentObject::getFirstParent() const
1322{

Callers 9

printInvalidLinksMethod · 0.45
getObjectInfoMethod · 0.45
getSelectedLinkFunction · 0.45
updateMethod · 0.45
makeBodyActiveFunction · 0.45
updatePlacementMethod · 0.45
updateDataMethod · 0.45
createModelStructureFunction · 0.45

Calls 9

checkLinkDepthMethod · 0.80
isAttachedToDocumentMethod · 0.45
hasChildElementMethod · 0.45
hasExtensionMethod · 0.45
getSubObjectMethod · 0.45
c_strMethod · 0.45
getLinksToMethod · 0.45
insertMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected