Salome HOME
Refs #289 - Spline profile is represented in OCC view as polyline profile
[modules/hydro.git] / src / HYDROData / HYDROData_Region.cxx
index 384b4bd2400a7b5b913f5d2db19916162f687fcf..12103c787be22250d261167419a95149ea3ec36f 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>
 
@@ -65,6 +66,11 @@ QStringList HYDROData_Region::DumpToPython( MapOfTreatedObjects& theTreatedObjec
   return aResList;
 }
 
+bool HYDROData_Region::CanBeUpdated() const
+{
+  return false;
+}
+
 void HYDROData_Region::Remove()
 {
   Handle(HYDROData_CalculationCase) aFatherCalc = 
@@ -76,6 +82,21 @@ void HYDROData_Region::Remove()
     aFatherCalc->UpdateRegionsOrder();
 }
 
+bool HYDROData_Region::CanRemove()
+{
+  return false;
+}
+
+HYDROData_SequenceOfObjects HYDROData_Region::GetAllReferenceObjects() const
+{
+  HYDROData_SequenceOfObjects aResSeq = HYDROData_Entity::GetAllReferenceObjects();
+
+  HYDROData_SequenceOfObjects aSeqOfZones = GetZones();
+  aResSeq.Append( aSeqOfZones );
+
+  return aResSeq;
+}
+
 bool HYDROData_Region::AddZone( const Handle(HYDROData_Zone)& theZone )
 {
   if ( theZone.IsNull() )
@@ -196,19 +217,16 @@ TopoDS_Shape HYDROData_Region::GetShape() const
         }
       } // faces iterator
 
+      // Check the result of fuse operation
       if ( !aFuseShape.IsNull() ) {
         ShapeUpgrade_UnifySameDomain anUnifier( aFuseShape );
-        anUnifier.UnifyFacesAndEdges();
         anUnifier.Build();
         TopoDS_Shape anUnitedShape = anUnifier.Shape();
 
-        TopExp_Explorer anExp( anUnitedShape, TopAbs_FACE );
-        if ( anExp.More() ) {
-          aRegionFace = TopoDS::Face( anExp.Current() );
-          anExp.Next();
-          if ( anExp.More() ) {
-            aRegionFace.Nullify();
-          }
+        TopTools_IndexedMapOfShape aMapOfFaces;
+        TopExp::MapShapes( anUnitedShape, TopAbs_FACE, aMapOfFaces );
+        if ( aMapOfFaces.Extent() == 1 ) {
+          aRegionFace = TopoDS::Face( aMapOfFaces(1) );
         }
       }
     }