Toposhape/Part: Transfer in PropoertyTopoShape and related
This commit is contained in:
@@ -189,6 +189,17 @@ const std::string &ComplexGeoData::elementMapPrefix() {
|
||||
return prefix;
|
||||
}
|
||||
|
||||
std::string ComplexGeoData::getElementMapVersion() const {
|
||||
return "4";
|
||||
}
|
||||
|
||||
bool ComplexGeoData::checkElementMapVersion(const char * ver) const
|
||||
{
|
||||
return !boost::equals(ver, "3")
|
||||
&& !boost::equals(ver, "4")
|
||||
&& !boost::starts_with(ver, "3.");
|
||||
}
|
||||
|
||||
size_t ComplexGeoData::getElementMapSize(bool flush) const
|
||||
{
|
||||
if (flush) {
|
||||
@@ -653,5 +664,18 @@ void ComplexGeoData::beforeSave() const
|
||||
}
|
||||
}
|
||||
|
||||
void ComplexGeoData::hashChildMaps()
|
||||
{
|
||||
flushElementMap();
|
||||
if (_elementMap)
|
||||
_elementMap->hashChildMaps(Tag);
|
||||
}
|
||||
|
||||
bool ComplexGeoData::hasChildElementMap() const
|
||||
{
|
||||
flushElementMap();
|
||||
return _elementMap && _elementMap->hasChildElementMap();
|
||||
}
|
||||
|
||||
|
||||
// NOLINTEND(cppcoreguidelines-pro-bounds-pointer-arithmetic)
|
||||
|
||||
@@ -242,6 +242,12 @@ public:
|
||||
std::vector<std::pair<MappedName, ElementIDRefs> >
|
||||
getElementMappedNames(const IndexedName & element, bool needUnmapped=false) const;
|
||||
|
||||
/// Hash the child element map postfixes to shorten element name from hierarchical maps
|
||||
void hashChildMaps();
|
||||
|
||||
/// Check if there is child element map
|
||||
bool hasChildElementMap() const;
|
||||
|
||||
/// Append the Tag (if and only if it is non zero) into the element map
|
||||
virtual void reTagElementMap(long tag,
|
||||
App::StringHasherRef hasher,
|
||||
@@ -289,6 +295,12 @@ public:
|
||||
/// Get the current element map size
|
||||
size_t getElementMapSize(bool flush=true) const;
|
||||
|
||||
/// Return the current element map version
|
||||
virtual std::string getElementMapVersion() const;
|
||||
|
||||
/// Return true to signal element map version change
|
||||
virtual bool checkElementMapVersion(const char * ver) const;
|
||||
|
||||
/// Check if the given sub-name only contains an element name
|
||||
static bool isElementName(const char *subName) {
|
||||
return (subName != nullptr) && (*subName != 0) && findElementName(subName)==subName;
|
||||
|
||||
@@ -1244,6 +1244,40 @@ PropertyComplexGeoData::PropertyComplexGeoData() = default;
|
||||
|
||||
PropertyComplexGeoData::~PropertyComplexGeoData() = default;
|
||||
|
||||
std::string PropertyComplexGeoData::getElementMapVersion(bool) const {
|
||||
auto data = getComplexData();
|
||||
if(!data)
|
||||
return std::string();
|
||||
auto owner = Base::freecad_dynamic_cast<DocumentObject>(getContainer());
|
||||
std::ostringstream ss;
|
||||
if(owner && owner->getDocument()
|
||||
&& owner->getDocument()->getStringHasher()==data->Hasher)
|
||||
ss << "1.";
|
||||
else
|
||||
ss << "0.";
|
||||
ss << data->getElementMapVersion();
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
bool PropertyComplexGeoData::checkElementMapVersion(const char * ver) const
|
||||
{
|
||||
auto data = getComplexData();
|
||||
if(!data)
|
||||
return false;
|
||||
auto owner = Base::freecad_dynamic_cast<DocumentObject>(getContainer());
|
||||
std::ostringstream ss;
|
||||
const char *prefix;
|
||||
if(owner && owner->getDocument()
|
||||
&& owner->getDocument()->getStringHasher() == data->Hasher)
|
||||
prefix = "1.";
|
||||
else
|
||||
prefix = "0.";
|
||||
if (!boost::starts_with(ver, prefix))
|
||||
return true;
|
||||
return data->checkElementMapVersion(ver+2);
|
||||
}
|
||||
|
||||
|
||||
void PropertyComplexGeoData::afterRestore()
|
||||
{
|
||||
auto data = getComplexData();
|
||||
|
||||
@@ -541,6 +541,16 @@ public:
|
||||
Base::BoundBox3d getBoundingBox() const override = 0;
|
||||
//@}
|
||||
|
||||
/** Return the element map version
|
||||
*
|
||||
* @param persisted: if true, return the restored element map version. Or
|
||||
* else, return the current element map version
|
||||
*/
|
||||
virtual std::string getElementMapVersion(bool restored=false) const;
|
||||
|
||||
/// Return true to signal element map version change
|
||||
virtual bool checkElementMapVersion(const char * ver) const;
|
||||
|
||||
void afterRestore() override;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user