Salome HOME
Fix for #21537 : Dumped file not loadable
authormpv <mikhail.ponikarov@opencascade.com>
Thu, 4 Jun 2020 10:51:39 +0000 (13:51 +0300)
committermpv <mikhail.ponikarov@opencascade.com>
Thu, 4 Jun 2020 10:51:39 +0000 (13:51 +0300)
src/Model/Model_AttributeSelection.cpp
src/Model/Model_AttributeSelection.h
src/ModelHighAPI/ModelHighAPI_Interface.cpp

index 68c9c32030abd45a78567c6c4d57d908d5e05b78..3badb0068c7bd854780f450434620d2320b29ff2 100644 (file)
@@ -1316,7 +1316,8 @@ void Model_AttributeSelection::computeValues(
 
 void Model_AttributeSelection::concealedFeature(
   const FeaturePtr theFeature, const FeaturePtr theStop, const bool theCheckCopy,
-  std::list<FeaturePtr>& theConcealers, const ResultPtr theResultOfFeature)
+  std::list<FeaturePtr>& theConcealers, const ResultPtr theResultOfFeature,
+  const bool theCheckWholeFeature)
 {
   std::set<FeaturePtr> alreadyProcessed;
   alreadyProcessed.insert(theFeature);
@@ -1332,16 +1333,21 @@ void Model_AttributeSelection::concealedFeature(
   }
   std::list<ResultPtr>::const_iterator aRootIter = aRootRes.cbegin();
   for(; aRootIter != aRootRes.cend(); aRootIter++) {
-    std::list<ResultPtr> allRes;
-    allRes.push_back(*aRootIter);
+    std::list<DataPtr> allRes;
+    allRes.push_back((*aRootIter)->data());
     ResultBodyPtr aRootBody = ModelAPI_Tools::bodyOwner(*aRootIter, true);
     if (!aRootBody.get())
       aRootBody = std::dynamic_pointer_cast<ModelAPI_ResultBody>(*aRootIter);
     if (aRootBody.get()) {
-      ModelAPI_Tools::allSubs(aRootBody, allRes);
-    }
-    for(std::list<ResultPtr>::iterator aRIter = allRes.begin(); aRIter != allRes.end(); aRIter++) {
-      const std::set<AttributePtr>& aRefs = (*aRIter)->data()->refsToMe();
+      std::list<ResultPtr> allSub;
+      ModelAPI_Tools::allSubs(aRootBody, allSub);
+      for(std::list<ResultPtr>::iterator anIt = allSub.begin(); anIt != allSub.end(); anIt++)
+        allRes.push_back((*anIt)->data());
+    }
+    if (theCheckWholeFeature)
+      allRes.push_back(theFeature->data());
+    for(std::list<DataPtr>::iterator aRIter = allRes.begin(); aRIter != allRes.end(); aRIter++) {
+      const std::set<AttributePtr>& aRefs = (*aRIter)->refsToMe();
       std::set<AttributePtr>::const_iterator aRef = aRefs.cbegin();
       for (; aRef != aRefs.cend(); aRef++) {
         if (!aRef->get() || !(*aRef)->owner().get())
@@ -2094,8 +2100,15 @@ ResultPtr Model_AttributeSelection::newestContext(
   }
   // in case sketch line was selected for wire, but wire was concealed and not such line anymore,
   // so, actually, the sketch element was selected (which is never concealed)
-  if (aResult != theCurrent && aResult->isConcealed())
-    aResult = theCurrent;
+  if (aResult != theCurrent && theCurrent->groupName() == ModelAPI_ResultConstruction::group()) {
+    //&& aResult->isConcealed())
+    std::list<FeaturePtr> aConcealers;
+    FeaturePtr aResFeature = aDoc->feature(aResult);
+    FeaturePtr aThisFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(owner());
+    concealedFeature(aResFeature, aThisFeature, false, aConcealers, aResult, true);
+    if (aConcealers.size())
+      aResult = theCurrent;
+  }
   return aResult;
 }
 
index 0b1af7181804e48893d34995253c16bd8698d9db..193f2d1dde31ebe410a0ab1c243a69aae5cb9362 100644 (file)
@@ -209,7 +209,8 @@ protected:
   /// theResultOfFeature if not null defines exact referenced result of a feature
   void concealedFeature(
     const FeaturePtr theFeature, const FeaturePtr theStop, const bool theCheckCopy,
-    std::list<FeaturePtr>& theConcealers, const ResultPtr theResultOfFeature);
+    std::list<FeaturePtr>& theConcealers, const ResultPtr theResultOfFeature,
+    const bool theCheckWholeFeature = false);
 
   friend class Model_Data;
   friend class Model_AttributeSelectionList;
index 9555b977de91c5d76eb4e9aed10f57db0b7c75c5..cec0fb1cec3a359bc2d59d28c5199dda95875d49 100644 (file)
@@ -88,8 +88,11 @@ void ModelHighAPI_Interface::execute(bool isForce)
 
 void ModelHighAPI_Interface::setName(const std::string& theName)
 {
-  if (feature().get())
+  if (feature().get() && feature()->data()->isValid())
     feature()->data()->setName(theName);
+  else {
+    std::cout<<"Error: set name "<<theName.c_str()<<" for an invalid feature"<<std::endl;
+  }
 }
 
 std::string ModelHighAPI_Interface::name() const