App: refactor ComplexGeoData::getSubElementByName
This commit is contained in:
@@ -57,19 +57,25 @@ using namespace Data;
|
||||
|
||||
ComplexGeoData::ComplexGeoData() = default;
|
||||
|
||||
Data::Segment* ComplexGeoData::getSubElementByName(const char* name) const
|
||||
std::pair<std::string, unsigned long> ComplexGeoData::getTypeAndIndex(const char* Name)
|
||||
{
|
||||
int index = 0;
|
||||
std::string element;
|
||||
boost::regex ex("^([^0-9]*)([0-9]*)$");
|
||||
boost::cmatch what;
|
||||
|
||||
if (boost::regex_match(name, what, ex)) {
|
||||
if (boost::regex_match(Name, what, ex)) {
|
||||
element = what[1].str();
|
||||
index = std::atoi(what[2].str().c_str());
|
||||
}
|
||||
|
||||
return getSubElement(element.c_str(), static_cast<unsigned long>(index));
|
||||
return std::make_pair(element, index);
|
||||
}
|
||||
|
||||
Data::Segment* ComplexGeoData::getSubElementByName(const char* name) const
|
||||
{
|
||||
auto type = getTypeAndIndex(name);
|
||||
return getSubElement(type.first.c_str(),type.second);
|
||||
}
|
||||
|
||||
void ComplexGeoData::applyTransform(const Base::Matrix4D& rclTrf)
|
||||
|
||||
Reference in New Issue
Block a user