From 74e9ba33303efc2282db1261706e904efa36b255 Mon Sep 17 00:00:00 2001 From: mpv Date: Thu, 20 Aug 2015 11:19:16 +0300 Subject: [PATCH] Make concealment of results working on compsolids: if at least one sub-body is concealed, the whole compsolid is concealed --- src/Model/Model_Objects.cpp | 16 +++++++++++++++- src/Model/Model_ResultCompSolid.cpp | 11 +++++++++++ src/Model/Model_ResultCompSolid.h | 2 ++ 3 files changed, 28 insertions(+), 1 deletion(-) diff --git a/src/Model/Model_Objects.cpp b/src/Model/Model_Objects.cpp index 49e922a80..8e1354f36 100644 --- a/src/Model/Model_Objects.cpp +++ b/src/Model/Model_Objects.cpp @@ -688,10 +688,24 @@ void Model_Objects::synchronizeBackRefs() for (; aRIter != aResults.cend(); aRIter++) { std::shared_ptr aResData = std::dynamic_pointer_cast((*aRIter)->data()); - if (aResData) { + if (aResData.get()) { aConcealed.push_back(std::pair(*aRIter, (*aRIter)->isConcealed())); aResData->eraseBackReferences(); } + // iterate sub-bodies of compsolid + ResultCompSolidPtr aComp = std::dynamic_pointer_cast(*aRIter); + if (aComp.get()) { + int aNumSub = aComp->numberOfSubs(); + for(int a = 0; a < aNumSub; a++) { + ResultPtr aSub = aComp->subResult(a); + std::shared_ptr aResData = + std::dynamic_pointer_cast(aSub->data()); + if (aResData.get()) { + aConcealed.push_back(std::pair(aSub, aSub->isConcealed())); + aResData->eraseBackReferences(); + } + } + } } } diff --git a/src/Model/Model_ResultCompSolid.cpp b/src/Model/Model_ResultCompSolid.cpp index 577bf7074..45dc68ae5 100755 --- a/src/Model/Model_ResultCompSolid.cpp +++ b/src/Model/Model_ResultCompSolid.cpp @@ -96,6 +96,17 @@ bool Model_ResultCompSolid::setDisabled(std::shared_ptr theThis return aChanged; } +bool Model_ResultCompSolid::isConcealed() +{ + if (ModelAPI_ResultCompSolid::isConcealed()) + return true; + std::vector >::const_iterator aSubIter = mySubs.cbegin(); + for(; aSubIter != mySubs.cend(); aSubIter++) + if ((*aSubIter)->isConcealed()) + return true; + return false; +} + void Model_ResultCompSolid::updateSubs(const std::shared_ptr& theThisShape) { // iterate all sub-solids of compsolid to make sub-results synchronized with them diff --git a/src/Model/Model_ResultCompSolid.h b/src/Model/Model_ResultCompSolid.h index 355be5721..152ef4bba 100755 --- a/src/Model/Model_ResultCompSolid.h +++ b/src/Model/Model_ResultCompSolid.h @@ -60,6 +60,8 @@ public: MODEL_EXPORT virtual bool setDisabled(std::shared_ptr theThis, const bool theFlag); + /// The compsolid is concealed if at least one of the sub is concealed + MODEL_EXPORT virtual bool isConcealed(); protected: /// Makes a body on the given feature Model_ResultCompSolid(); -- 2.39.2