Salome HOME
Issue #1664: improve mechanism of removing coincidence
[modules/shaper.git] / src / SketchPlugin / SketchPlugin_MultiRotation.cpp
index 4737cd1724dcd34bec5e059d89bd7e2958ec1e09..6ae033dec67086f271731da7795cd6f4f3d1f044 100755 (executable)
@@ -121,7 +121,6 @@ void SketchPlugin_MultiRotation::execute()
         FeaturePtr aFeature =  aDoc ? aDoc->feature(aRC) : FeaturePtr();
         if (aFeature)
           aFeaturesToBeRemoved.insert(aFeature);
-          //aDoc->removeFeature(aFeature);
       }
     } else {
       for (int i = 0; i <= aNbCopies && aTargetIter != aTargetList.end(); i++)
@@ -165,7 +164,6 @@ void SketchPlugin_MultiRotation::execute()
             FeaturePtr aFeature =  aDoc ? aDoc->feature(aRC) : FeaturePtr();
             if (aFeature)
               aFeaturesToBeRemoved.insert(aFeature);
-              //aDoc->removeFeature(aFeature);
           }
           ind++;
         }
@@ -334,8 +332,7 @@ void SketchPlugin_MultiRotation::attributeChanged(const std::string& theID)
         return;
 
       // Clear list of objects
-      AttributeRefListPtr aRefListOfRotated = std::dynamic_pointer_cast<ModelAPI_AttributeRefList>(
-          data()->attribute(SketchPlugin_Constraint::ENTITY_B()));
+      AttributeRefListPtr aRefListOfRotated = reflist(SketchPlugin_Constraint::ENTITY_B());
       std::list<ObjectPtr> aTargetList = aRefListOfRotated->list();
       std::list<ObjectPtr>::iterator aTargetIter = aTargetList.begin();
       std::set<FeaturePtr> aFeaturesToBeRemoved;
@@ -344,22 +341,15 @@ void SketchPlugin_MultiRotation::attributeChanged(const std::string& theID)
         for (int i = 0; i < aNbCopies && aTargetIter != aTargetList.end(); i++, aTargetIter++) {
           aRefListOfRotated->remove(*aTargetIter);
           // remove the corresponding feature from the sketch
-          ResultConstructionPtr aRC =
-            std::dynamic_pointer_cast<ModelAPI_ResultConstruction>(*aTargetIter);
-          DocumentPtr aDoc = aRC ? aRC->document() : DocumentPtr();
-          FeaturePtr aFeature =  aDoc ? aDoc->feature(aRC) : FeaturePtr();
+          FeaturePtr aFeature = ModelAPI_Feature::feature(*aTargetIter);
           if (aFeature)
             aFeaturesToBeRemoved.insert(aFeature);
-            //aDoc->removeFeature(aFeature);
         }
       }
       ModelAPI_Tools::removeFeaturesAndReferences(aFeaturesToBeRemoved);
 
       aRefListOfRotated->clear();
-      std::dynamic_pointer_cast<ModelAPI_AttributeRefList>(
-        data()->attribute(SketchPlugin_Constraint::ENTITY_A()))->clear();
-      std::dynamic_pointer_cast<ModelAPI_AttributeRefList>(
-        data()->attribute(SketchPlugin_Constraint::ENTITY_B()))->clear();
+      reflist(SketchPlugin_Constraint::ENTITY_A())->clear();
     }
   }
 }