Toponaming: add code to implement guessing missing references

This commit is contained in:
bgbsww
2024-08-03 13:21:01 -04:00
committed by Chris Hennes
parent 87cc683ccc
commit 80045d0e88
4 changed files with 34 additions and 2 deletions

View File

@@ -313,6 +313,9 @@ App::ElementNamePair Feature::getExportElementName(TopoShape shape,
auto names =
shape.decodeElementComboName(idxName, mapped.name, idxName.getType(), &postfix);
std::vector<int> ancestors;
// TODO: if names.empty() then the existing heuristic has failed to find anything
// and we're going to flag this element as missing. This is the place to add
// heuristics as we develop them.
for (auto& name : names) {
auto index = shape.getIndexedName(name);
if (!index) {
@@ -1697,6 +1700,16 @@ bool Feature::getCameraAlignmentDirection(Base::Vector3d& direction, const char*
return GeoFeature::getCameraAlignmentDirection(direction, subname);
}
void Feature::guessNewLink(std::string &replacementName, DocumentObject *base, const char *oldLink) {
for (auto &element : Part::Feature::getRelatedElements(base, oldLink)) {
replacementName.clear();
element.index.appendToStringBuffer(replacementName);
FC_WARN("Feature guess element reference " << oldLink << " -> " << replacementName);
return;
}
replacementName = oldLink;
}
// ---------------------------------------------------------
PROPERTY_SOURCE(Part::FilletBase, Part::Feature)