X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FModel%2FModel_ResultBody.cpp;h=3d28be7c668bdff13d28f9f393dc037bfbaf798b;hb=c57b0044525edb117d2b10cca0a931eecb5681f5;hp=c226ac7626e8ac6994eb2905f7cfa6f4864d89e2;hpb=bc80cc95e126484f9da128cd640ab245c6ac1ee6;p=modules%2Fshaper.git diff --git a/src/Model/Model_ResultBody.cpp b/src/Model/Model_ResultBody.cpp index c226ac762..3d28be7c6 100644 --- a/src/Model/Model_ResultBody.cpp +++ b/src/Model/Model_ResultBody.cpp @@ -29,6 +29,7 @@ #include #include #include +#include #include #include @@ -95,31 +96,12 @@ void Model_ResultBody::loadModifiedShapes(const std::shared_ptrisNewShapesCollected(theOldShape, theShapeTypeToExplore)) theAlgo->collectNewShapes(theOldShape, theShapeTypeToExplore); std::vector::const_iterator aSubIter = mySubs.cbegin(); for(; aSubIter != mySubs.cend(); aSubIter++) { - // check that sub-shape was also created as modification of ShapeIn - /* to find when it is needed later to enable: to store modification of sub-bodies not only as primitives - GeomShapePtr aSubGeomShape = (*aSubIter)->shape(); - if (!theIsStoreAsGenerated && aSubGeomShape.get() && !aSubGeomShape->isNull()) { - TopoDS_Shape aSubShape = aSubGeomShape->impl(); - TopoDS_Shape aWholeIn = theShapeIn->impl(); - for(TopExp_Explorer anExp(aWholeIn, aSubShape.ShapeType()); anExp.More(); anExp.Next()) { - ListOfShape aHistory; - std::shared_ptr aSubIn(new GeomAPI_Shape()); - aSubIn->setImpl((new TopoDS_Shape(anExp.Current()))); - theMS->modified(aSubIn, aHistory); - std::list >::const_iterator anIt = aHistory.begin(); - for (; anIt != aHistory.end(); anIt++) { - if ((*anIt)->isSame(aSubGeomShape)) { - (*aSubIter)->storeModified(aSubIn, aSubGeomShape, -2); // -2 is to avoid clearing - } - } - } - }*/ (*aSubIter)->loadModifiedShapes(theAlgo, theOldShape, theShapeTypeToExplore, theName); } } else { // do for this directly @@ -271,8 +253,16 @@ void Model_ResultBody::updateSubs(const std::shared_ptr& theThisS } else { // just update shape of this result aSub = mySubs[aSubIndex]; } - if (!aShape->isEqual(aSub->shape())) { - aSub->store(aShape, false); + GeomShapePtr anOldSubShape = aSub->shape(); + if (!aShape->isEqual(anOldSubShape)) { + if (myAlgo.get()) { + std::list anOldForSub; + computeOldForSub(aShape, myOlds, anOldForSub); + myIsGenerated ? aSub->storeGenerated(anOldForSub, aShape, myAlgo) : + aSub->storeModified(anOldForSub, aShape, myAlgo); + } else { + aSub->store(aShape, false); + } aECreator->sendUpdated(aSub, EVENT_DISP); aECreator->sendUpdated(aSub, EVENT_UPD); } @@ -293,6 +283,7 @@ void Model_ResultBody::updateSubs(const std::shared_ptr& theThisS // redisplay this because result with and without subs are displayed differently aECreator->sendUpdated(data()->owner(), EVENT_DISP); } + cleanCash(); } else if (!mySubs.empty()) { // erase all subs while(!mySubs.empty()) { ResultBodyPtr anErased = *(mySubs.rbegin()); @@ -309,6 +300,19 @@ void Model_ResultBody::updateSubs(const std::shared_ptr& theThisS } } +void Model_ResultBody::updateSubs( + const GeomShapePtr& theThisShape, const std::list& theOlds, + const std::shared_ptr theMakeShape, const bool isGenerated) +{ + myAlgo = theMakeShape; + myOlds = theOlds; + myIsGenerated = isGenerated; + updateSubs(theThisShape, true); + myAlgo.reset(); + myOlds.clear(); +} + + bool Model_ResultBody::isConnectedTopology() { TDF_Label aDataLab = std::dynamic_pointer_cast(data())->label(); @@ -326,3 +330,42 @@ bool Model_ResultBody::isConnectedTopology() } return false; // invalid case } + +void Model_ResultBody::cleanCash() +{ + myBuilder->cleanCash(); + for (std::vector::const_iterator aSubIter = mySubs.cbegin(); + aSubIter != mySubs.cend(); ++aSubIter) + { + const ResultBodyPtr& aSub = *aSubIter; + aSub->cleanCash(); + } +} + +void Model_ResultBody::computeOldForSub(const GeomShapePtr& theSub, + const std::list& theAllOlds, std::list& theOldForSub) +{ + std::list::const_iterator aRootOlds = theAllOlds.cbegin(); + for(; aRootOlds != theAllOlds.cend(); aRootOlds++) { + ListOfShape aNews; + myIsGenerated ? myAlgo->generated(*aRootOlds, aNews) : myAlgo->modified(*aRootOlds, aNews); + // MakeShape may return alone old shape if there is no history information for this input + if (aNews.size() == 1 && aNews.front()->isEqual(*aRootOlds)) + aNews.clear(); + if (aNews.empty()) { // try to iterate to sub-elements (for intersection of solids this is face) + std::list theAllSubOlds; + for(GeomAPI_ShapeIterator aSubOld(*aRootOlds); aSubOld.more(); aSubOld.next()) { + GeomShapePtr aSub = aSubOld.current(); + if (aSub.get() && !aSub->isNull()) + theAllSubOlds.push_back(aSub); + } + computeOldForSub(theSub, theAllSubOlds, theOldForSub); + } + for(ListOfShape::iterator aNewIter = aNews.begin(); aNewIter != aNews.end(); aNewIter++) { + if (theSub->isSame(*aNewIter)) { // found old that was used for new theSubShape creation + theOldForSub.push_back(*aRootOlds); + break; + } + } + } +}