Merge pull request #12750 from bgbsww/bgbsww-toponamingElementCacheExtras

Toponaming/Part element cache extras
This commit is contained in:
Chris Hennes
2024-03-05 08:32:32 -06:00
committed by GitHub
12 changed files with 296 additions and 6 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

@@ -4084,6 +4084,7 @@ TopoShape &TopoShape::makeRefine(const TopoShape &shape, const char *op, RefineF
return *this;
}
// TODO: Does the toponaming branch version of this method need to be here?
bool TopoShape::findPlane(gp_Pln &pln, double tol) const {
if(_Shape.IsNull())
return false;

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,5 +5002,27 @@ bool TopoShape::isSame(const Data::ComplexGeoData &_other) const
&& Hasher == other.Hasher
&& _Shape.IsEqual(other._Shape);
}
void TopoShape::cacheRelatedElements(const Data::MappedName &name,
HistoryTraceType sameType,
const QVector<Data::MappedElement> & names) const
{
initCache();
_cache->insertRelation(ShapeRelationKey(name,sameType), names);
}
bool TopoShape::getRelatedElementsCached(const Data::MappedName &name,
HistoryTraceType sameType,
QVector<Data::MappedElement> &names) const
{
if(!_cache) {
return false;
}
auto it = _cache->relations.find(ShapeRelationKey(name,sameType));
if(it == _cache->relations.end()) {
return false;
}
names = it->second;
return true;
}
} // namespace Part