Salome HOME
Update the names of Regions and Zones if case name changed (Bug #110).
[modules/hydro.git] / src / HYDROData / HYDROData_Region.cxx
index a4f68c331faeb01b7e24a27db665fc1bf4c3165d..090171f9e8b09619801de27ad7976baa15c1c306 100644 (file)
 #include <TopoDS_Face.hxx>
 #include <TopTools_ListOfShape.hxx>
 #include <TopTools_ListIteratorOfListOfShape.hxx>
-#include <TopExp_Explorer.hxx>
-#include <ShapeUpgrade_UnifySameDomain.hxx>
+#include <TopTools_IndexedMapOfShape.hxx>
+#include <TopExp.hxx>
 #include <BRep_Builder.hxx>
 #include <BRepAlgoAPI_Fuse.hxx>
+#include <ShapeUpgrade_UnifySameDomain.hxx>
 
 #include <QStringList>
 
@@ -196,20 +197,16 @@ TopoDS_Shape HYDROData_Region::GetShape() const
         }
       } // faces iterator
 
+      // Check the result of fuse operation
       if ( !aFuseShape.IsNull() ) {
-        ShapeUpgrade_UnifySameDomain aUnify;
-        aUnify.Initialize( aFuseShape );
-        aUnify.UnifyFacesAndEdges();
-        aUnify.Build();
-        TopoDS_Shape aUnitedShape = aUnify.Shape();
-
-        TopExp_Explorer anExp( aUnitedShape, TopAbs_FACE );
-        if ( anExp.More() ) {
-          aRegionFace = TopoDS::Face( anExp.Current() );
-          anExp.Next();
-          if ( anExp.More() ) {
-            aRegionFace.Nullify();
-          }
+        ShapeUpgrade_UnifySameDomain anUnifier( aFuseShape );
+        anUnifier.Build();
+        TopoDS_Shape anUnitedShape = anUnifier.Shape();
+
+        TopTools_IndexedMapOfShape aMapOfFaces;
+        TopExp::MapShapes( anUnitedShape, TopAbs_FACE, aMapOfFaces );
+        if ( aMapOfFaces.Extent() == 1 ) {
+          aRegionFace = TopoDS::Face( aMapOfFaces(1) );
         }
       }
     }
@@ -231,4 +228,4 @@ TopoDS_Shape HYDROData_Region::GetShape() const
   }
   
   return aResShape;
-}
\ No newline at end of file
+}