Toponaming: Fix transformed; abstract index element name generation

This commit is contained in:
bgbsww
2024-08-09 22:04:05 -04:00
parent 99b753b006
commit 25ba8ab223
7 changed files with 107 additions and 32 deletions

View File

@@ -91,4 +91,16 @@ bool Data::hasMissingElement(const char *subname) {
const char *Data::hasMappedElementName(const char *subname) {
return isMappedElement(findElementName(subname));
}
}
// Currently used by CrossSection.cpp and FeatureTransformed.cpp with different label types
// with a default of "I" and "_" used by CrossSection.
const std::string Data::indexSuffix(int index, const char *label)
{
if ( index < 2 ) { // Don't add a suffix for item #1, begin appending at 2
return {""};
}
std::string name(label);
name += std::to_string(index);
return name;
}

View File

@@ -69,6 +69,8 @@ constexpr const char* POSTFIX_GEN = ";:G";
constexpr const char* POSTFIX_MODGEN = ";:MG";
constexpr const char* POSTFIX_DUPLICATE = ";D";
constexpr const char* ELEMENT_MAP_INDEX = "I";
constexpr const char* ELEMENT_MAP_INDEX2 = "_";
/// Check if a subname contains missing element
AppExport bool hasMissingElement(const char *subname);
@@ -95,6 +97,7 @@ AppExport const char *findElementName(const char *subname);
AppExport const char *hasMappedElementName(const char *subname);
AppExport const std::string indexSuffix(int index, const char *label=ELEMENT_MAP_INDEX);
} // namespace Data
// clang-format on

View File

@@ -462,18 +462,7 @@ const std::string& StringHasher::getPersistenceFileName() const
void StringHasher::Save(Base::Writer& writer) const
{
size_t count = 0;
if (_hashes->SaveAll) {
count = _hashes->size();
}
else {
count = 0;
for (auto& hasher : _hashes->right) {
if (hasher.second->isMarked() || hasher.second->isPersistent()) {
++count;
}
}
}
std::size_t count = _hashes->SaveAll ? _hashes->size() : this->count();
writer.Stream() << writer.ind() << "<StringHasher saveall=\"" << _hashes->SaveAll
<< "\" threshold=\"" << _hashes->Threshold << "\"";