Toposhape/Part:: fix, relocate and test element methods in ComplexGeoData and TopoShape

This commit is contained in:
bgbsww
2024-02-28 15:56:45 -05:00
parent e5ef0b5833
commit 5c582b7b2d
11 changed files with 273 additions and 105 deletions

View File

@@ -211,7 +211,7 @@ App::DocumentObjectExecReturn *MultiCommon::execute()
shapes.push_back(sh);
}
TopoShape res {};
TopoShape res {0};
res.makeElementBoolean(Part::OpCodes::Common, shapes);
if (res.isNull()) {
throw Base::RuntimeError("Resulting shape is null");

View File

@@ -1240,6 +1240,14 @@ public:
void copyElementMap(const TopoShape & topoShape, const char *op=nullptr);
bool canMapElement(const TopoShape &other) const;
void cacheRelatedElements(const Data::MappedName & name,
HistoryTraceType sameType,
const QVector<Data::MappedElement> & names) const;
bool getRelatedElementsCached(const Data::MappedName & name,
HistoryTraceType sameType,
QVector<Data::MappedElement> &names) const;
void mapSubElement(const TopoShape &other,const char *op=nullptr, bool forceHasher=false);
void mapSubElement(const std::vector<TopoShape> &shapes, const char *op=nullptr);
void mapSubElementsTo(std::vector<TopoShape>& shapes, const char* op = nullptr) const;

View File

@@ -5002,23 +5002,22 @@ bool TopoShape::isSame(const Data::ComplexGeoData &_other) const
&& Hasher == other.Hasher
&& _Shape.IsEqual(other._Shape);
}
void TopoShape::cacheRelatedElements(const Data::MappedName &name,
bool sameType,
HistoryTraceType sameType,
const QVector<Data::MappedElement> & names) const
{
INIT_SHAPE_CACHE();
_Cache->insertRelation(ShapeRelationKey(name,sameType), names);
initCache();
_cache->insertRelation(ShapeRelationKey(name,sameType), names);
}
bool TopoShape::getRelatedElementsCached(const Data::MappedName &name,
bool sameType,
HistoryTraceType sameType,
QVector<Data::MappedElement> &names) const
{
if(!_Cache)
if(!_cache)
return false;
auto it = _Cache->relations.find(ShapeRelationKey(name,sameType));
if(it == _Cache->relations.end())
auto it = _cache->relations.find(ShapeRelationKey(name,sameType));
if(it == _cache->relations.end())
return false;
names = it->second;
return true;