#include <TDF_ChildIterator.hxx>
#include <TDF_RelocationTable.hxx>
#include <TopAbs_ShapeEnum.hxx>
-
#include <TopoDS.hxx>
#include <TopoDS_Shape.hxx>
#include <TopoDS_Edge.hxx>
#include <BRep_Tool.hxx>
+#include <TNaming_Builder.hxx>
+#include <TNaming_Iterator.hxx>
using namespace std;
}
}
+ if (myIsCashed && !theTemporarily) {
+ myCash[theContext].push_back(theSubShape);
+ }
+
int aNewTag = mySize->Get() + 1;
TDF_Label aNewLab = mySize->Label().FindChild(aNewTag);
}
}
-#include <TNaming_Builder.hxx>
-#include <TNaming_Iterator.hxx>
-
// copies named shapes: we need the implementation of this
static void CopyNS(const Handle(TNaming_NamedShape)& theFrom,
const Handle(TDF_Attribute)& theTo)
const std::shared_ptr<GeomAPI_Shape>& theSubShape,
const bool theTemporarily)
{
+ if (myIsCashed) { // the cashing is active
+ std::map<ResultPtr, std::list<std::shared_ptr<GeomAPI_Shape> > >::iterator aContext =
+ myCash.find(theContext);
+ if (aContext != myCash.end()) {
+ // iterate shapes because "isEqual" method must be called for each shape
+ std::list<std::shared_ptr<GeomAPI_Shape> >::iterator aShapes = aContext->second.begin();
+ for(; aShapes != aContext->second.end(); aShapes++) {
+ if (!theSubShape.get()) {
+ if (!aShapes->get())
+ return true;
+ } else {
+ if (theSubShape->isEqual(*aShapes))
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+ // no-cash method
for(int anIndex = size() - 1; anIndex >= 0; anIndex--) {
AttributeSelectionPtr anAttr = value(anIndex);
- if (anAttr.get() && anAttr->value().get()) {
- if (anAttr->context() == theContext && anAttr->value()->isEqual(theSubShape))
- return true;
+ if (anAttr.get()) {
+ if (anAttr->context() == theContext) { // contexts are equal, so, check that values are also
+ std::shared_ptr<GeomAPI_Shape> aValue = anAttr->value();
+ if (!aValue.get()) {
+ if (!theSubShape.get()) { // both are null
+ return true;
+ }
+ } else {
+ if (aValue->isEqual(theSubShape)) // shapes are equal
+ return true;
+ }
+ }
}
}
return false;
} else { // recollect mySubs
theLabel.FindAttribute(TDataStd_Comment::GetID(), mySelectionType);
}
+ myIsCashed = false;
+}
+
+void Model_AttributeSelectionList::cashValues(const bool theEnabled)
+{
+ myIsCashed = theEnabled;
+ myCash.clear(); // empty list as indicator that cash is not used
+ if (theEnabled) {
+ for(int anIndex = size() - 1; anIndex >= 0; anIndex--) {
+ AttributeSelectionPtr anAttr = value(anIndex);
+ if (anAttr.get()) {
+ myCash[anAttr->context()].push_back(anAttr->value());
+ }
+ }
+ }
}