Salome HOME
Issue #427, 420 - crash during work through external edges.
[modules/shaper.git] / src / Model / Model_Data.cpp
index b3baaea43867efe74c0fa09eef6c3a1e6f1b1b7f..53444bb6d45845a17f5d46e7d783fec7fa0bb36f 100644 (file)
@@ -259,9 +259,28 @@ void Model_Data::eraseBackReferences()
     aRes->setIsConcealed(false);
 }
 
+void Model_Data::removeBackReference(FeaturePtr theFeature, std::string theAttrID)
+{
+  AttributePtr anAttribute = theFeature->data()->attribute(theAttrID);
+  if (myRefsToMe.find(anAttribute) == myRefsToMe.end())
+    return;
+
+  myRefsToMe.erase(anAttribute);
+  // TODO: check whether the concealed should be thrown down to the false value
+  std::shared_ptr<ModelAPI_Result> aRes = 
+    std::dynamic_pointer_cast<ModelAPI_Result>(myObject);
+  if (aRes)
+    aRes->setIsConcealed(false);
+}
+
 void Model_Data::addBackReference(FeaturePtr theFeature, std::string theAttrID, 
    const bool theApplyConcealment)
 {
+  // do not add the same attribute twice
+  AttributePtr anAttribute = theFeature->data()->attribute(theAttrID);
+  if (myRefsToMe.find(anAttribute) != myRefsToMe.end())
+    return;
+
   myRefsToMe.insert(theFeature->data()->attribute(theAttrID));
   if (theApplyConcealment && 
       ModelAPI_Session::get()->validators()->isConcealed(theFeature->getKind(), theAttrID)) {