const ShapeUpgrade_UnifySameDomain& aUnifyAlgo = this->impl<ShapeUpgrade_UnifySameDomain>();
for (int aIsModified = 0; aIsModified <= 1; aIsModified++) {
+ if (!aUnifyAlgo.History()->IsSupportedType(aShape)) // to avoid crash in BRepTools_History
+ continue;
const TopTools_ListOfShape& aMList = aIsModified ?
aUnifyAlgo.History()->Modified(aShape) : aUnifyAlgo.History()->Generated(aShape);
for (TopTools_ListIteratorOfListOfShape aModified(aMList); aModified.More(); aModified.Next()) {
TopTools_ListOfShape aValShapes;
if (searchNewContext(aDoc, aNewCShape, aContext, aValShape, aContLab, aNewContexts, aValShapes))
{
+ std::set<ResultPtr> allContexts, aSkippedContext;
+ std::list<ResultPtr>::iterator aNewContext = aNewContexts.begin();
+ for(; aNewContext != aNewContexts.end(); aNewContext++)
+ allContexts.insert(*aNewContext);
+
+ // if there exist context composite and sub-result(s), leave only sub(s)
+ std::set<ResultPtr>::iterator aResIter = allContexts.begin();
+ for(; aResIter != allContexts.end(); aResIter++) {
+ ResultPtr aParent = ModelAPI_Tools::bodyOwner(*aResIter);
+ for(; aParent.get(); aParent = ModelAPI_Tools::bodyOwner(aParent))
+ if (allContexts.count(aParent))
+ aSkippedContext.insert(aParent);
+ }
+
GeomAPI_Shape::ShapeType aListShapeType = GeomAPI_Shape::SHAPE;
if (myParent) {
if (myParent->selectionType() == "VERTEX") aListShapeType = GeomAPI_Shape::VERTEX;
TopTools_ListIteratorOfListOfShape aNewValues(aValShapes);
bool aFirst = true; // first is set to this, next are appended to parent
for(; aNewCont != aNewContexts.end(); aNewCont++, aNewValues.Next()) {
+ if (aSkippedContext.count(*aNewCont))
+ continue;
GeomShapePtr aValueShape;
if (!aNewValues.Value().IsNull()) {
{
bool aStored = false;
std::list<GeomShapePtr>::const_iterator anOldIter = theFromShapes.cbegin();
- for(; anOldIter != theFromShapes.cend(); anOldIter++) {
- ListOfShape aNews; // check this old really generates theToShape
- theMakeShape->generated(*anOldIter, aNews);
- ListOfShape::iterator aNewIter = aNews.begin();
- for(; aNewIter != aNews.end(); aNewIter++) {
- if (theToShape->isSame(*aNewIter))
- break;
+ for (; anOldIter != theFromShapes.cend(); anOldIter++) {
+ bool aStore = (*anOldIter)->isCompound() || (*anOldIter)->isShell() || (*anOldIter)->isWire();
+ if (!aStore) {
+ ListOfShape aNews; // check this old really generates theToShape
+ theMakeShape->generated(*anOldIter, aNews);
+ ListOfShape::iterator aNewIter = aNews.begin();
+ for (; aNewIter != aNews.end(); aNewIter++) {
+ if (theToShape->isSame(*aNewIter))
+ break;
+ }
+ aStore = aNewIter != aNews.end();
}
- if (aNewIter != aNews.end()) {
+ if (aStore) {
storeGenerated(*anOldIter, theToShape, !aStored);
TNaming_Builder* aBuilder = builder(0);
aStored = !aBuilder->NamedShape()->IsEmpty();
bool aStored = false;
std::list<GeomShapePtr>::const_iterator anOldIter = theOldShapes.cbegin();
for(; anOldIter != theOldShapes.cend(); anOldIter++) {
- ListOfShape aNews; // check this old really modifies theNewShape
- theMakeShape->modified(*anOldIter, aNews);
- ListOfShape::iterator aNewIter = aNews.begin();
- for(; aNewIter != aNews.end(); aNewIter++) {
- if (theNewShape->isSame(*aNewIter))
- break;
+ // compounds may cause crash if call "modified"
+ bool aStore = (*anOldIter)->isCompound() || (*anOldIter)->isShell() || (*anOldIter)->isWire();
+ if (!aStore) {
+ ListOfShape aNews; // check this old really modifies theNewShape
+ theMakeShape->modified(*anOldIter, aNews);
+ ListOfShape::iterator aNewIter = aNews.begin();
+ for(; aNewIter != aNews.end(); aNewIter++) {
+ if (theNewShape->isSame(*aNewIter))
+ break;
+ }
+ aStore = aNewIter != aNews.end();
}
- if (aNewIter != aNews.end()) {
+ if (aStore) {
storeModified(*anOldIter, theNewShape, !aStored);
TNaming_Builder* aBuilder = builder(0);
aStored = !aBuilder->NamedShape()->IsEmpty();
#include <Model_Data.h>
#include <Events_Loop.h>
#include <GeomAPI_ShapeIterator.h>
+#include <GeomAPI_ShapeExplorer.h>
#include <TopoDS_Shape.hxx>
#include <TopExp_Explorer.hxx>
return;
if (theSubSubs.Add(theSub->impl<TopoDS_Shape>())) {
bool aIsComp = theSub->isCompound() || theSub->isCompSolid();
- if (aIsComp || theOneLevelMore) {
- for(GeomAPI_ShapeIterator anIter(theSub); anIter.more(); anIter.next()) {
- collectSubs(anIter.current(), theSubSubs, aIsComp && theOneLevelMore);
+ if (aIsComp) {
+ for(GeomAPI_ShapeIterator anIter(theSub); anIter.more(); anIter.next())
+ collectSubs(anIter.current(), theSubSubs, theOneLevelMore);
+ } else if (theOneLevelMore) {
+ GeomAPI_Shape::ShapeType aSubType = GeomAPI_Shape::ShapeType(int(theSub->shapeType()) + 1);
+ if (aSubType == GeomAPI_Shape::SHAPE)
+ return;
+ if (aSubType == GeomAPI_Shape::SHELL)
+ aSubType = GeomAPI_Shape::FACE;
+ if (aSubType == GeomAPI_Shape::WIRE)
+ aSubType = GeomAPI_Shape::EDGE;
+
+ for(GeomAPI_ShapeExplorer anExp(theSub, aSubType); anExp.more(); anExp.next()) {
+ collectSubs(anExp.current(), theSubSubs, false);
}
}
}
for (TopTools_MapOfShape::Iterator anOldIter(anOldSubs); anOldIter.More(); anOldIter.Next()) {
GeomShapePtr anOldSub(new GeomAPI_Shape);
anOldSub->setImpl<TopoDS_Shape>(new TopoDS_Shape(anOldIter.Value()));
+ if (anOldSub->isCompound() || anOldSub->isShell() || anOldSub->isWire())
+ continue; // container old-shapes are not supported by the history, may cause crash
ListOfShape aNews;
myIsGenerated ? myAlgo->generated(anOldSub, aNews) : myAlgo->modified(anOldSub, aNews);
// MakeShape may return alone old shape if there is no history information for this input