Salome HOME
Make concealment of results working on compsolids: if at least one sub-body is concea...
authormpv <mpv@opencascade.com>
Thu, 20 Aug 2015 08:19:16 +0000 (11:19 +0300)
committermpv <mpv@opencascade.com>
Thu, 20 Aug 2015 08:19:16 +0000 (11:19 +0300)
src/Model/Model_Objects.cpp
src/Model/Model_ResultCompSolid.cpp
src/Model/Model_ResultCompSolid.h

index 49e922a804d8cb4a2cab873bcdf69955d2e01b77..8e1354f36ba11bf1d41e4297fc162223b1e3047e 100644 (file)
@@ -688,10 +688,24 @@ void Model_Objects::synchronizeBackRefs()
     for (; aRIter != aResults.cend(); aRIter++) {
       std::shared_ptr<Model_Data> aResData = 
         std::dynamic_pointer_cast<Model_Data>((*aRIter)->data());
-      if (aResData) {
+      if (aResData.get()) {
         aConcealed.push_back(std::pair<ResultPtr, bool>(*aRIter, (*aRIter)->isConcealed()));
         aResData->eraseBackReferences();
       }
+      // iterate sub-bodies of compsolid
+      ResultCompSolidPtr aComp = std::dynamic_pointer_cast<ModelAPI_ResultCompSolid>(*aRIter);
+      if (aComp.get()) {
+        int aNumSub = aComp->numberOfSubs();
+        for(int a = 0; a < aNumSub; a++) {
+          ResultPtr aSub = aComp->subResult(a);
+          std::shared_ptr<Model_Data> aResData = 
+            std::dynamic_pointer_cast<Model_Data>(aSub->data());
+          if (aResData.get()) {
+            aConcealed.push_back(std::pair<ResultPtr, bool>(aSub, aSub->isConcealed()));
+            aResData->eraseBackReferences();
+          }
+        }
+      }
     }
   }
 
index 577bf7074a7578cb6d088f0b705b2f3910f7adb5..45dc68ae534fcdec0c69d670f8518fc1fb81e58c 100755 (executable)
@@ -96,6 +96,17 @@ bool Model_ResultCompSolid::setDisabled(std::shared_ptr<ModelAPI_Result> theThis
   return aChanged;
 }
 
+bool Model_ResultCompSolid::isConcealed()
+{
+  if (ModelAPI_ResultCompSolid::isConcealed())
+    return true;
+  std::vector<std::shared_ptr<ModelAPI_ResultBody> >::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<GeomAPI_Shape>& theThisShape)
 {
   // iterate all sub-solids of compsolid to make sub-results synchronized with them
index 355be572129f08c030d3a05fdaa9f7d55aa09cc1..152ef4bba942210e94c09a525632d5fcc696f9b1 100755 (executable)
@@ -60,6 +60,8 @@ public:
   MODEL_EXPORT virtual bool setDisabled(std::shared_ptr<ModelAPI_Result> 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();