| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| |
|
| | |
| |
|
| |
|
| | #include <boost_regex.hpp> |
| |
|
| | #include <Base/Tools.h> |
| |
|
| | #include "SubnameHelper.h" |
| |
|
| |
|
| | using namespace Measure; |
| |
|
| |
|
| | std::string SubnameHelper::pathToLongSub(std::list<App::DocumentObject*> path) |
| | { |
| | std::vector<std::string> elementNames; |
| | for (auto& item : path) { |
| | auto name = item->getNameInDocument(); |
| | if (!name) { |
| | continue; |
| | } |
| | elementNames.emplace_back(name); |
| | } |
| | return namesToLongSub(elementNames); |
| | } |
| |
|
| |
|
| | |
| | |
| | std::string SubnameHelper::namesToLongSub(const std::vector<std::string>& pathElementNames) |
| | { |
| | std::string result; |
| | for (auto& name : pathElementNames) { |
| | result += (name + "."); |
| | } |
| | return result; |
| | } |
| |
|
| |
|
| | |
| | std::string SubnameHelper::getLastTerm(const std::string& inString) |
| | { |
| | auto result {inString}; |
| | size_t lastDot = inString.rfind('.'); |
| | if (lastDot != std::string::npos) { |
| | result = result.substr(lastDot + 1); |
| | } |
| | return result; |
| | } |
| |
|
| | |
| | std::string SubnameHelper::getFirstTerm(const std::string& inString) |
| | { |
| | auto result {inString}; |
| | size_t lastDot = inString.find('.'); |
| | if (lastDot != std::string::npos) { |
| | result = result.substr(0, lastDot); |
| | } |
| | return result; |
| | } |
| |
|
| | |
| | std::string SubnameHelper::pruneFirstTerm(const std::string& inString) |
| | { |
| | auto result {inString}; |
| | size_t lastDot = inString.find('.'); |
| | if (lastDot != std::string::npos) { |
| | result = result.substr(lastDot + 1); |
| | } |
| | return result; |
| | } |
| |
|
| | |
| | |
| | std::string SubnameHelper::pruneLastTerm(const std::string& inString) |
| | { |
| | auto result {inString}; |
| | if (result.back() == '.') { |
| | |
| | result = result.substr(0, result.length() - 1); |
| | } |
| |
|
| | size_t lastDotPos = result.rfind('.'); |
| | if (lastDotPos != std::string::npos) { |
| | result = result.substr(0, lastDotPos + 1); |
| | } |
| | else { |
| | |
| | result = ""; |
| | } |
| |
|
| | return result; |
| | } |
| |
|
| | |
| | |
| | |
| | std::string SubnameHelper::removeGeometryTerm(const std::string& longSubname) |
| | { |
| | auto lastTerm = getLastTerm(longSubname); |
| | if (longSubname.empty() || longSubname.back() == '.') { |
| | |
| | return longSubname; |
| | } |
| |
|
| | |
| | auto pos = lastTerm.find("Vertex"); |
| | if (pos != std::string::npos) { |
| | return pruneLastTerm(longSubname); |
| | } |
| |
|
| | pos = lastTerm.find("Edge"); |
| | if (pos != std::string::npos) { |
| | return pruneLastTerm(longSubname); |
| | } |
| |
|
| | pos = lastTerm.find("Face"); |
| | if (pos != std::string::npos) { |
| | return pruneLastTerm(longSubname); |
| | } |
| |
|
| | pos = lastTerm.find("Shell"); |
| | if (pos != std::string::npos) { |
| | return pruneLastTerm(longSubname); |
| | } |
| |
|
| | pos = lastTerm.find("Solid"); |
| | if (pos != std::string::npos) { |
| | return pruneLastTerm(longSubname); |
| | } |
| |
|
| | return longSubname; |
| | } |
| |
|
| |
|
| | |
| | |
| | |
| | std::string SubnameHelper::removeTnpInfo(const std::string& inString) |
| | { |
| | constexpr char TNPDelimiter {';'}; |
| | size_t firstDelimiter = inString.find(TNPDelimiter); |
| | if (firstDelimiter == std::string::npos) { |
| | |
| | return inString; |
| | } |
| | auto geomName = getLastTerm(inString); |
| | auto path = inString.substr(0, firstDelimiter); |
| | auto result = path + geomName; |
| | return result; |
| | } |
| |
|