Salome HOME
Merge remote-tracking branch 'remotes/origin/Operations_on_Groups'
[modules/shaper.git] / src / ModuleBase / ModuleBase_Tools.cpp
index b528344ce493df558b99541aabaa011b1cdc12fd..40d74c1d20629effe4ebecb36d940559cc91d6ef 100644 (file)
@@ -1299,6 +1299,28 @@ std::string generateName(const AttributePtr& theAttribute,
   return aName;
 }
 
+bool isSameShape(const TopoDS_Shape& theShape1, const TopoDS_Shape& theShape2)
+{
+  // In case of compound we cannot rely on simple comparison method.
+  // If the compound is generated by Group feature then this compound is alwais new.
+  // So, we have to compare content of these compounds
+  if (theShape1.ShapeType() != theShape2.ShapeType())
+    return false;
+
+  if (theShape1.ShapeType() != TopAbs_COMPOUND)
+    return theShape1.IsSame(theShape2);
+
+  TopoDS_Iterator aIt1(theShape1);
+  TopoDS_Iterator aIt2(theShape2);
+
+  for (; aIt1.More() && aIt2.More(); aIt1.Next(), aIt2.Next()) {
+    if (!(aIt1.Value()).IsSame(aIt2.Value()))
+      return false;
+  }
+  return true;
+}
+
+
 } // namespace ModuleBase_Tools