From: mpv Date: Thu, 24 Jan 2019 14:25:45 +0000 (+0300) Subject: Fix for several unit-tests behavior. X-Git-Tag: HighLevelObjectsHierarchy~13^2~28 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=e74c1257a2a5f86000dd272cf4db90f18143e6c1;p=modules%2Fshaper.git Fix for several unit-tests behavior. --- diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_UnifySameDomain.cpp b/src/GeomAlgoAPI/GeomAlgoAPI_UnifySameDomain.cpp index ee9c6feca..795a0fac1 100644 --- a/src/GeomAlgoAPI/GeomAlgoAPI_UnifySameDomain.cpp +++ b/src/GeomAlgoAPI/GeomAlgoAPI_UnifySameDomain.cpp @@ -113,6 +113,8 @@ void GeomAlgoAPI_UnifySameDomain::modified(const std::shared_ptr const ShapeUpgrade_UnifySameDomain& aUnifyAlgo = this->impl(); 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()) { diff --git a/src/Model/Model_AttributeSelection.cpp b/src/Model/Model_AttributeSelection.cpp index ce8a3b77f..ba7ebae63 100644 --- a/src/Model/Model_AttributeSelection.cpp +++ b/src/Model/Model_AttributeSelection.cpp @@ -1398,6 +1398,20 @@ void Model_AttributeSelection::updateInHistory() TopTools_ListOfShape aValShapes; if (searchNewContext(aDoc, aNewCShape, aContext, aValShape, aContLab, aNewContexts, aValShapes)) { + std::set allContexts, aSkippedContext; + std::list::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::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; @@ -1409,6 +1423,8 @@ void Model_AttributeSelection::updateInHistory() 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()) { diff --git a/src/Model/Model_BodyBuilder.cpp b/src/Model/Model_BodyBuilder.cpp index a0f074c75..04c405946 100755 --- a/src/Model/Model_BodyBuilder.cpp +++ b/src/Model/Model_BodyBuilder.cpp @@ -270,15 +270,19 @@ void Model_BodyBuilder::storeGenerated(const std::list& theFromSha { bool aStored = false; std::list::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(); @@ -359,14 +363,19 @@ void Model_BodyBuilder::storeModified(const std::list& theOldShape bool aStored = false; std::list::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(); diff --git a/src/Model/Model_ResultBody.cpp b/src/Model/Model_ResultBody.cpp index b6fb91da1..3ba643118 100644 --- a/src/Model/Model_ResultBody.cpp +++ b/src/Model/Model_ResultBody.cpp @@ -30,6 +30,7 @@ #include #include #include +#include #include #include @@ -351,9 +352,20 @@ static void collectSubs( return; if (theSubSubs.Add(theSub->impl())) { 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); } } } @@ -375,6 +387,8 @@ void Model_ResultBody::computeOldForSub(const GeomShapePtr& theSub, for (TopTools_MapOfShape::Iterator anOldIter(anOldSubs); anOldIter.More(); anOldIter.Next()) { GeomShapePtr anOldSub(new GeomAPI_Shape); anOldSub->setImpl(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