Toponaming: bring in missing code fragments in Sketcher
This commit is contained in:
@@ -9551,14 +9551,28 @@ void SketchObject::setExpression(const App::ObjectIdentifier& path,
|
||||
}
|
||||
}
|
||||
|
||||
const std::string &SketchObject::internalPrefix()
|
||||
{
|
||||
static std::string _prefix("Internal");
|
||||
return _prefix;
|
||||
}
|
||||
|
||||
const char *SketchObject::convertInternalName(const char *name)
|
||||
{
|
||||
if (name && boost::starts_with(name, internalPrefix()))
|
||||
return name + internalPrefix().size();
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
std::pair<std::string,std::string> SketchObject::getElementName(
|
||||
const char *name, ElementNameType type) const
|
||||
{
|
||||
// Todo: Toponaming Project March 2024: This method override breaks the sketcher - selection and deletion
|
||||
// of constraints ceases to work. See #13169. We need to prove that this works before
|
||||
// enabling it. For now, bypass it.
|
||||
// enabling it. This appears to be okay now.
|
||||
#ifndef FC_USE_TNP_FIX
|
||||
return Part2DObject::getElementName(name,type);
|
||||
|
||||
#endif
|
||||
std::pair<std::string, std::string> ret;
|
||||
if(!name) return ret;
|
||||
|
||||
@@ -9566,30 +9580,57 @@ std::pair<std::string,std::string> SketchObject::getElementName(
|
||||
return Part2DObject::getElementName(name,type);
|
||||
|
||||
const char *mapped = Data::isMappedElement(name);
|
||||
Data::IndexedName index = checkSubName(name);
|
||||
index.appendToStringBuffer(ret.second);
|
||||
if (auto realName = convertInternalName(ret.second.c_str())) {
|
||||
Data::MappedElement mappedElement;
|
||||
// Todo: Do we need to add the InternalShape?
|
||||
// if (mapped)
|
||||
// mappedElement = InternalShape.getShape().getElementName(name);
|
||||
// else if (type == ElementNameType::Export)
|
||||
// ret.first = getExportElementName(InternalShape.getShape(), realName).first;
|
||||
// else
|
||||
// mappedElement = InternalShape.getShape().getElementName(realName);
|
||||
|
||||
if (mapped || type != ElementNameType::Export) {
|
||||
if (mappedElement.index) {
|
||||
ret.second = internalPrefix();
|
||||
mappedElement.index.appendToStringBuffer(ret.second);
|
||||
}
|
||||
if (mappedElement.name) {
|
||||
ret.first = Data::ComplexGeoData::elementMapPrefix();
|
||||
mappedElement.name.appendToBuffer(ret.first);
|
||||
}
|
||||
else if (mapped)
|
||||
ret.first = name;
|
||||
}
|
||||
|
||||
if (ret.first.size()) {
|
||||
if (auto dot = strrchr(ret.first.c_str(), '.'))
|
||||
ret.first.resize(dot+1-ret.first.c_str());
|
||||
else
|
||||
ret.first += ".";
|
||||
ret.first += ret.second;
|
||||
}
|
||||
if (mapped && (!mappedElement.index || !mappedElement.name))
|
||||
ret.second.insert(0, Data::MISSING_PREFIX);
|
||||
return ret;
|
||||
}
|
||||
|
||||
if(!mapped) {
|
||||
auto occindex = Part::TopoShape::shapeTypeAndIndex(name);
|
||||
if (occindex.second)
|
||||
return Part2DObject::getElementName(name,type);
|
||||
|
||||
Data::IndexedName index = checkSubName(name);
|
||||
ret.first = convertSubName(index, true);
|
||||
if(!Data::isMappedElement(ret.first.c_str()))
|
||||
ret.first.clear();
|
||||
index.appendToStringBuffer(ret.second);
|
||||
return ret;
|
||||
}
|
||||
|
||||
Data::IndexedName index = checkSubName(name);
|
||||
if(index) {
|
||||
index.appendToStringBuffer(ret.second);
|
||||
ret.first = convertSubName(index, true);
|
||||
if(type==ElementNameType::Export) {
|
||||
if(boost::starts_with(ret.second,"Vertex"))
|
||||
ret.second[0] = 'v';
|
||||
else if(boost::starts_with(ret.second,"Edge"))
|
||||
ret.second[0] = 'e';
|
||||
}
|
||||
if(index && type==ElementNameType::Export) {
|
||||
if(boost::starts_with(ret.second,"Vertex"))
|
||||
ret.second[0] = 'v';
|
||||
else if(boost::starts_with(ret.second,"Edge"))
|
||||
ret.second[0] = 'e';
|
||||
}
|
||||
ret.first = convertSubName(index, true);
|
||||
if(!Data::isMappedElement(ret.first.c_str()))
|
||||
ret.first.clear();
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user