"""
Sets what is returned in the GEOM_IGroupOperations::GetObjects
"""
- self.data = None # nullify the cashed shape when selection is changed
+ #self.data = None # nullify the cashed shape when selection is changed
+ print("Set selection for the group " + str(self.entry) + " = " + str(theSelection))
self.selection = theSelection
def GetSelection(self):
#include "StudyData_Object.h"
#include <TopExp.hxx>
+#include <TopoDS_Iterator.hxx>
#include <BRep_Builder.hxx>
#include <BRepTools.hxx>
#include <BRepBuilderAPI_Copy.hxx>
aBuilder.Add(aResult, aSel);
}
myShape = aResult;
+ } else { // check myShape equals to the new result
+ TopoDS_Shape* aShape = (TopoDS_Shape*)theMainShape;
+ TopTools_IndexedMapOfShape anIndices;
+ TopExp::MapShapes(*aShape, anIndices);
+ TopoDS_Iterator aMyIter(myShape);
+ std::list<long>::const_iterator aSelIter = theSelection.cbegin();
+ for(; aSelIter != theSelection.cend() && aMyIter.More(); aSelIter++, aMyIter.Next()) {
+ TopoDS_Shape aSel = anIndices.FindKey(*aSelIter);
+ if (!aSel.IsSame(aMyIter.Value()))
+ break;
+ }
+ if (aMyIter.More() || aSelIter != theSelection.cend()) { // recompute myShape
+ TopoDS_Compound aResult;
+ BRep_Builder aBuilder;
+ aBuilder.MakeCompound(aResult);
+ std::list<long>::const_iterator aSelIter = theSelection.cbegin();
+ for(; aSelIter != theSelection.cend(); aSelIter++) {
+ TopoDS_Shape aSel = anIndices.FindKey(*aSelIter);
+ aBuilder.Add(aResult, aSel);
+ }
+ myShape = aResult;
+ }
}
return (long long)(&myShape);
}