Salome HOME
LOT 15 BR_H2018_DRAFT
authorisn <isn@opencascade.com>
Fri, 21 Dec 2018 19:07:13 +0000 (22:07 +0300)
committerisn <isn@opencascade.com>
Fri, 21 Dec 2018 19:10:08 +0000 (22:10 +0300)
Signed-off-by: isn <isn@opencascade.com>
15 files changed:
src/HYDROData/CMakeLists.txt
src/HYDROData/HYDROData_CalculationCase.h
src/HYDROData/HYDROData_CompleteCalcCase.cxx [new file with mode: 0644]
src/HYDROData/HYDROData_CompleteCalcCase.h [new file with mode: 0644]
src/HYDROData/HYDROData_Region.cxx
src/HYDROData/HYDROData_Region.h
src/HYDROData/HYDROData_SplitToZonesTool.cxx
src/HYDROData/HYDROData_SplitToZonesTool.h
src/HYDROGUI/HYDROGUI_CalculationDlg.cxx
src/HYDROGUI/HYDROGUI_CalculationDlg.h
src/HYDROGUI/HYDROGUI_CalculationOp.cxx
src/HYDROGUI/HYDROGUI_CalculationOp.h
src/HYDROGUI/HYDROGUI_Module.cxx
src/HYDROGUI/HYDROGUI_Operations.cxx
src/HYDROGUI/HYDROGUI_Operations.h

index 94a55cc638b3b2f0b3a457ec468ea656f2363247..9c412e8102f69d38a27bc3b26cd3ca77d7accbd6 100644 (file)
@@ -66,6 +66,7 @@ set(PROJECT_HEADERS
     HYDROData_DTM.h   
     HYDROData_BCPolygon.h
     HYDROData_BoundaryPolygonTools.h 
+    HYDROData_CompleteCalcCase.h 
 )
 
 set(PROJECT_SOURCES 
@@ -130,6 +131,7 @@ set(PROJECT_SOURCES
     HYDROData_DTM.cxx
     HYDROData_BCPolygon.cxx
     HYDROData_BoundaryPolygonTools.cxx
+    HYDROData_CompleteCalcCase.cxx
  )
 
 SET( ECW_INCLUDES $ENV{ECWLIB_ROOT_DIR}/include )
index 74a128e0988751fe2f468b877ff8e50b1a70cadf..953be5ce017e21711f92daf7705112c93aded587 100644 (file)
@@ -426,7 +426,9 @@ private:
    * Add new one region for calculation case.
    * The new region is added into the list of reference regions.
    */
-  Handle(HYDROData_Region) addNewRegion( const Handle(HYDROData_Document)& theDoc,
+
+  public: //TEMP TODO
+  HYDRODATA_EXPORT Handle(HYDROData_Region) addNewRegion( const Handle(HYDROData_Document)& theDoc,
                                          const QString& thePrefixOrName,
                                          bool isPrefix = true );
 
diff --git a/src/HYDROData/HYDROData_CompleteCalcCase.cxx b/src/HYDROData/HYDROData_CompleteCalcCase.cxx
new file mode 100644 (file)
index 0000000..2aa627b
--- /dev/null
@@ -0,0 +1,435 @@
+// Copyright (C) 2014-2018  EDF-R&D
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+// File:     HYDROData_CompleteCalcCase.cxx
+// Author:   Ilya SHCHEKIN
+
+#include <HYDROData_CompleteCalcCase.h>
+
+#include <gp_Pnt.hxx>
+#include <HYDROData_SplitToZonesTool.h>
+#include <HYDROData_SplitShapesGroup.h>
+#include <BOPTools_AlgoTools3D.hxx>
+#include <IntTools_Context.hxx>
+#include <BRepBuilderAPI_MakeFace.hxx>
+#include <TopTools_HSequenceOfShape.hxx>
+#include <HYDROData_PolylineXY.h>
+#include <TopoDS.hxx>
+#include <HYDROData_Region.h>
+#include <TopTools_IndexedMapOfShape.hxx>
+#include <TopExp.hxx>
+#include <HYDROData_Document.h>
+#include <HYDROData_Tool.h>
+
+static void GetModifToOrigHistory(BOPAlgo_Builder& theAlgo, TopTools_IndexedDataMapOfShapeListOfShape& theModifToOrigMap)
+{
+  const TopTools_ListOfShape& args = theAlgo.Arguments();
+  TopTools_IndexedMapOfShape argsAllSh;
+  TopTools_ListOfShape::Iterator it(args);
+  for (;it.More();it.Next())
+    TopExp::MapShapes(it.Value(), argsAllSh);
+  for (int i=1;i<=argsAllSh.Extent();i++)
+  {
+    const TopoDS_Shape& arg_sh = argsAllSh(i);
+    const TopTools_ListOfShape& modif_ls = theAlgo.Modified(arg_sh);
+    for (TopTools_ListIteratorOfListOfShape itLS(modif_ls); itLS.More(); itLS.Next())
+    {
+      const TopoDS_Shape& val = itLS.Value();
+      TopTools_ListOfShape* LS = theModifToOrigMap.ChangeSeek(val);
+      if (LS)
+        LS->Append(arg_sh);
+      else
+      {
+        TopTools_ListOfShape newLS;
+        newLS.Append(arg_sh);
+        theModifToOrigMap.Add(val, newLS);
+      }
+    }
+  }
+}
+
+
+static bool CheckIntersection(BOPAlgo_Builder& theAlgo, const std::vector<TopoDS_Shape>& SHM,
+  const TopTools_MapOfShape& ShapesToAvoid)
+{
+  TopTools_MapOfShape gmodif_m;
+  int calc_ext = 0;
+  for (int i=0; i<SHM.size();i++)
+  {
+    TopTools_MapOfShape modif_m;
+    const TopTools_ListOfShape& modif_ls = theAlgo.Modified(SHM[i]);
+    for (TopTools_ListIteratorOfListOfShape itLS(modif_ls); itLS.More(); itLS.Next())
+    {
+      const TopoDS_Shape& val = itLS.Value();
+      if (!ShapesToAvoid.Contains(val))
+        modif_m.Add(val);
+    }
+    calc_ext+=modif_m.Extent();
+    gmodif_m.Unite(modif_m);
+    if (gmodif_m.Extent() < calc_ext)
+      return true; //there is an intersection
+  }
+  return false;
+}
+
+bool HYDROData_CompleteCalcCase::AddObjects( const Handle(HYDROData_Document)& doc,
+                                             Handle(HYDROData_CalculationCase)& theCalcCase, 
+                                             NCollection_Sequence<Handle(HYDROData_Entity)> theNewObjects,
+                                             bool& IsIntersectionOfNewObj)
+{
+  Handle(HYDROData_PolylineXY) aBndPolyline = theCalcCase->GetBoundaryPolyline();        
+  TopoDS_Wire aBndWire;
+  TopoDS_Face aLimFace;
+  bool UseBndPolyline = false;
+  QString CaseName = theCalcCase->GetName();
+  if (!aBndPolyline.IsNull())
+  {
+    Handle(TopTools_HSequenceOfShape) aConnectedWires = new TopTools_HSequenceOfShape;
+    int nbWires = aBndPolyline->GetNbConnectedWires(aConnectedWires);
+    if (nbWires > 0)
+    {
+      aBndWire = TopoDS::Wire(aConnectedWires->Value(1));
+      if(!aBndWire.IsNull()) 
+      {      
+        if(HYDROData_SplitToZonesTool::buildLimFace(aBndWire, aLimFace)) 
+        {
+          theNewObjects.Append(theCalcCase->GetBoundaryPolyline());
+          UseBndPolyline = true;
+        }
+      }
+    }
+  }
+
+  BOPAlgo_Builder anAlgo;
+  std::vector<TopoDS_Shape> newShapes;
+  std::vector<Handle(HYDROData_ShapesGroup)> newshapesGroups;
+  NCollection_DataMap<TopoDS_Shape, QStringList, TopTools_ShapeMapHasher> aShToRefObjects;
+  for (int i=1; i<= theNewObjects.Size();i++)
+  {
+    Handle(HYDROData_PolylineXY) aPolyXY = Handle(HYDROData_PolylineXY)::DownCast( theNewObjects(i) );
+    if (!aPolyXY.IsNull())
+    {
+      TopoDS_Shape aSh = aPolyXY->GetShape();
+      newShapes.push_back(aSh);
+      anAlgo.AddArgument(aSh);
+      QStringList aLS(aPolyXY->GetName());
+      aShToRefObjects.Bind(aSh, aLS);
+    }
+    else 
+    {
+      Handle(HYDROData_Object ) anObj = Handle(HYDROData_Object)::DownCast( theNewObjects(i) );
+      if (!anObj.IsNull())
+      {
+        TopoDS_Shape aSh = anObj->GetTopShape();
+        //
+        HYDROData_SequenceOfObjects groups = anObj->GetGroups();
+        for ( int k=1; k<=groups.Size(); k++ )
+        {
+          Handle(HYDROData_ShapesGroup) aGroup = Handle(HYDROData_ShapesGroup)::DownCast(groups(k));
+          if ( aGroup.IsNull() )
+            continue;
+          newshapesGroups.push_back(aGroup);
+        }
+        //
+        newShapes.push_back(aSh);
+        anAlgo.AddArgument(aSh);
+        QStringList aLS(anObj->GetName());
+        aShToRefObjects.Bind(aSh, aLS);
+      }
+    }
+  }
+
+  HYDROData_SequenceOfObjects aRegions = theCalcCase->GetRegions();
+  for ( int i = 1; i <= aRegions.Size(); i++ )
+  {
+    Handle(HYDROData_Region) aRegion = Handle(HYDROData_Region)::DownCast( aRegions(i) );
+    if ( !aRegion.IsNull() )
+    {
+      HYDROData_SequenceOfObjects aZones = aRegion->GetZones();
+      for ( int j = 1; j <= aZones.Size(); j++ )
+      {
+        Handle(HYDROData_Zone) aZone = Handle(HYDROData_Zone)::DownCast( aZones(j) );
+        TopoDS_Shape aSh = aZone->GetShape();
+        anAlgo.AddArgument(aSh);
+        HYDROData_SequenceOfObjects aRefObjects = aZone->GetObjects();
+        QStringList aRefObjList;
+        for (int k=1;k<=aRefObjects.Size();k++)
+          aRefObjList << aRefObjects(k)->GetName();
+        aShToRefObjects.Bind(aSh, aRefObjList);
+      }
+    }
+  }
+
+  anAlgo.Perform(); 
+#if OCC_VERSION_LARGE > 0x07020000
+  if (anAlgo.HasErrors())
+    return false;
+#endif
+  TopoDS_Shape aRes = anAlgo.Shape();        
+  TopTools_MapOfShape UsedFaces;
+  ///
+  TopTools_IndexedDataMapOfShapeListOfShape theModifToOrigMap;
+  GetModifToOrigHistory(anAlgo, theModifToOrigMap);
+
+  //
+  if (UseBndPolyline)
+  {
+    TopTools_IndexedMapOfShape aResFaces;
+    TopExp::MapShapes(aRes, TopAbs_FACE, aResFaces);
+    Handle(IntTools_Context) aContext = new IntTools_Context();
+    for (int i=1; i<= aResFaces.Extent();i++)
+    {
+      gp_Pnt aP3D;
+      gp_Pnt2d aP2D;
+      TopoDS_Face aF = TopoDS::Face(aResFaces(i));
+      int err = BOPTools_AlgoTools3D::PointInFace(aF, aP3D, aP2D, aContext);
+      if (err)
+        continue;
+
+      TopAbs_State aState = HYDROData_Tool::ComputePointState(gp_XY(aP3D.X(), aP3D.Y()), aLimFace);
+      if (aState == TopAbs_OUT)
+      {
+        UsedFaces.Add(aF); //filter out the faces which is out of boundary polyline
+      }
+    }
+  }
+
+  ///
+  //check intersection between new objects => if it's present, the combining of zones into region will be depend on ordering
+  IsIntersectionOfNewObj = CheckIntersection(anAlgo, newShapes, UsedFaces);
+  //
+  std::vector<std::vector<TopoDS_Shape>> NREGV; //new regions vector (each vector is a region, subvector == zones) 
+  for (int i=0;i<newShapes.size();i++)
+  {
+    TopoDS_Shape aSh = newShapes[i];
+    if (aSh.ShapeType() != TopAbs_FACE)
+      continue;
+    TopTools_ListOfShape newShL = anAlgo.Modified(aSh);
+    if (newShL.IsEmpty()) //non-modified
+    {
+      if (!UsedFaces.Contains(aSh))
+      {
+        std::vector<TopoDS_Shape> vect;
+        vect.push_back(aSh);
+        NREGV.push_back(vect);
+        UsedFaces.Add(aSh);
+      }
+    }
+    else //was modified
+    {
+      std::vector<TopoDS_Shape> vect;
+      for (TopTools_ListIteratorOfListOfShape it(newShL); it.More(); it.Next())
+      {
+        TopoDS_Face nF = TopoDS::Face(it.Value());
+        if (!nF.IsNull() && !UsedFaces.Contains(nF))
+        {                                         
+          vect.push_back(nF);
+          UsedFaces.Add(nF);
+        }
+      }    
+      NREGV.push_back(vect);
+    }
+  }
+  
+  //iter through already existing zone
+  //substract new zones (NREGV) from old zones
+  for ( int i = 1; i <= aRegions.Size(); i++ )
+  {
+    Handle(HYDROData_Region) aRegion = Handle(HYDROData_Region)::DownCast( aRegions(i) );
+    if ( !aRegion.IsNull() )
+    {
+      HYDROData_SequenceOfObjects aZones = aRegion->GetZones();
+      for ( int j = 1; j <= aZones.Size(); j++ )
+      {
+        Handle(HYDROData_Zone) aZone = Handle(HYDROData_Zone)::DownCast(aZones(j));
+        TopoDS_Shape aSh = aZone->GetShape();
+        TopTools_ListOfShape newShL = anAlgo.Modified(aSh);
+        if (newShL.IsEmpty() )
+          newShL.Append(aSh);
+        TopTools_MapOfShape newShM;
+        for (TopTools_ListIteratorOfListOfShape it(newShL); it.More(); it.Next())
+          newShM.Add(it.Value());
+        //
+        newShM.Subtract(UsedFaces); ///substract UsedFaces from newShM (since they have been taken by regions/object with higher priority)
+        //
+
+        if (newShM.Size() == 0)
+        {
+          //remove zone
+          aRegion->RemoveZone(aZone, true);
+        }
+        else if (newShM.Size() == 1)
+        {
+          TopoDS_Shape newS = *newShM.cbegin();
+          if (!newS.IsEqual(aSh))
+            aZone->SetShape(newS);
+        }
+        else ///newShM > 1
+        {
+          QString anOldZoneName = aZone->GetName();                
+          HYDROData_SequenceOfObjects aRefObjects = aZone->GetObjects();
+          aRegion->RemoveZone(aZone, false);
+          QStringList aRefObjList;
+          for (int k=1;k<=aRefObjects.Size();k++)
+            aRefObjList << aRefObjects(k)->GetName();
+          for (TopTools_MapIteratorOfMapOfShape it(newShM); it.More(); it.Next())
+          {
+            if (it.Value().ShapeType() == TopAbs_FACE)
+            {
+              TopoDS_Face F = TopoDS::Face(it.Value());
+              aRegion->addNewZone( doc, anOldZoneName, F, aRefObjList );
+            }
+          }
+        }
+      }
+    }
+  }
+
+  //create new regions/zones based on NREGV
+  QString aRegsPref = CaseName + "_Reg_";
+  QString aZonesPref = CaseName + "_Zone";
+  for ( int k=0;k<NREGV.size();k++ )
+  {
+    const std::vector<TopoDS_Shape>& sh_vec = NREGV[k];
+    Handle(HYDROData_Region) aRegion = theCalcCase->addNewRegion( doc, aRegsPref );
+    for (int i=0;i<sh_vec.size();i++)
+    {
+      TopoDS_Face nF = TopoDS::Face(sh_vec[i]);
+      QString zoneName = aZonesPref;
+      QStringList refObjList;
+      //
+      const TopTools_ListOfShape* origLS = theModifToOrigMap.Seek(nF);
+      if (origLS)
+      {
+        for (TopTools_ListIteratorOfListOfShape itLS1(*origLS); itLS1.More(); itLS1.Next())
+        {
+          const TopoDS_Shape& OrSh = itLS1.Value();
+          const QStringList* names = aShToRefObjects.Seek(OrSh);
+          if (names)
+            refObjList.append(*names);
+        }
+      }
+      //
+      Handle(HYDROData_Zone) aRegionZone = aRegion->addNewZone( doc, aZonesPref, nF, refObjList);
+    }
+  }
+
+  //GROUPS
+  HYDROData_SequenceOfObjects aSplitGroups = theCalcCase->GetSplitGroups();
+
+  ///process boundary polyline group (if present)
+  Handle(HYDROData_ShapesGroup) aBndWireGroup;
+  QString BndWireGroupName;
+  TopTools_ListOfShape aNewGroupForBndWireLS;
+  if (UseBndPolyline)
+  {
+    TopTools_IndexedMapOfShape aBndWireEdges;
+    TopTools_IndexedDataMapOfShapeListOfShape aResEdgesToFaces;
+    TopExp::MapShapes(aBndWire, TopAbs_EDGE, aBndWireEdges);
+    TopExp::MapShapesAndAncestors(aRes, TopAbs_EDGE, TopAbs_FACE, aResEdgesToFaces);
+    TopTools_IndexedMapOfShape aNewGroupForBndWire;
+    for (int i=1;i<=aBndWireEdges.Extent();i++)
+    {
+      TopoDS_Shape E = aBndWireEdges(i);
+      TopTools_ListOfShape aMLS = anAlgo.Modified(E);
+      if (aMLS.IsEmpty())
+        aMLS.Append(E);
+      TopTools_ListIteratorOfListOfShape itLS(aMLS);
+      for (;itLS.More();itLS.Next())
+      {
+        TopoDS_Edge E1 = TopoDS::Edge(itLS.Value());
+        if (E1.IsNull())
+          continue;
+        if (!aResEdgesToFaces.Contains(E1)) //should contains E since it's a part of aRes
+          continue;
+        //skip free edges
+        if (aResEdgesToFaces.FindFromKey(E1).Extent() > 0) 
+          aNewGroupForBndWire.Add(E1);
+      }
+    }
+    //
+    BndWireGroupName = CaseName + "_" + aBndPolyline->GetName();
+    for (int i=1;i<=aNewGroupForBndWire.Extent();i++)
+      aNewGroupForBndWireLS.Append(aNewGroupForBndWire(i));
+  }
+
+  // UPDATE SPLIT GROUPS       
+  for ( int k=1; k<=aSplitGroups.Size(); k++ )
+  {
+    Handle(HYDROData_ShapesGroup) aGroup = Handle(HYDROData_ShapesGroup)::DownCast(aSplitGroups(k));
+    if ( aGroup.IsNull() )
+      continue;
+
+    TopTools_SequenceOfShape GDefSeq, ModifedGDefSeq;
+
+    if (UseBndPolyline && aGroup->GetName() == BndWireGroupName)
+    {
+      aBndWireGroup = aGroup;
+      continue;
+    }
+
+    aGroup->GetShapes( GDefSeq );
+    for (int i=1;i<=GDefSeq.Length();i++)
+    {
+      const TopoDS_Shape& CSH = GDefSeq(i); 
+      TopTools_ListOfShape aMLS = anAlgo.Modified(CSH);
+      if (aMLS.IsEmpty())
+        aMLS.Append(CSH);
+      TopTools_ListIteratorOfListOfShape itLS(aMLS);
+      for (;itLS.More();itLS.Next())
+        ModifedGDefSeq.Append(itLS.Value());                     
+    }
+    aGroup->SetShapes(ModifedGDefSeq);
+  }
+
+  if (UseBndPolyline)
+  {
+    if (!aBndWireGroup.IsNull()) //modify group
+    {
+      aBndWireGroup->SetShapes(aNewGroupForBndWireLS);
+    }
+    else //add new group
+    {
+      Handle(HYDROData_SplitShapesGroup) aSplitGroup = theCalcCase->addNewSplitGroup( BndWireGroupName );
+      aSplitGroup->SetShapes(aNewGroupForBndWireLS);
+    }
+  }
+
+  ///Add new groups from newly added objects
+  for ( int k=0; k<newshapesGroups.size(); k++ )
+  {
+    Handle(HYDROData_ShapesGroup) aGroup = newshapesGroups[k];
+    QString aName = aGroup->GetName();
+    TopTools_SequenceOfShape aSeqSh, ModifedGDefSeq;
+    aGroup->GetShapes(aSeqSh);
+    Handle(HYDROData_SplitShapesGroup) aSplitGroup = theCalcCase->addNewSplitGroup( aName );
+
+    for (int i=1;i<=aSeqSh.Length();i++)
+    {
+      const TopoDS_Shape& CSH = aSeqSh(i); 
+      TopTools_ListOfShape aMLS = anAlgo.Modified(CSH);
+      if (aMLS.IsEmpty())
+        aMLS.Append(CSH);
+      TopTools_ListIteratorOfListOfShape itLS(aMLS);
+      for (;itLS.More();itLS.Next())
+        ModifedGDefSeq.Append(itLS.Value());                     
+    }
+    aSplitGroup->SetShapes(ModifedGDefSeq);
+  }
+  return true;
+}
diff --git a/src/HYDROData/HYDROData_CompleteCalcCase.h b/src/HYDROData/HYDROData_CompleteCalcCase.h
new file mode 100644 (file)
index 0000000..9f170c8
--- /dev/null
@@ -0,0 +1,44 @@
+// Copyright (C) 2014-2015  EDF-R&D
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#ifndef HYDROData_CompleteCalcCase_HeaderFile
+#define HYDROData_CompleteCalcCase_HeaderFile
+
+
+/**\class HYDROData_CompleteCalcCase
+ *
+ * \brief Allows to add new objects (natural/artificial objects, polylines) to already existing calc.case without full recomputation 
+ *
+*/
+
+#include <NCollection_Sequence.hxx>
+#include <HYDROData_CalculationCase.h>
+#include <HYDROData_Document.h>
+
+class HYDRODATA_EXPORT HYDROData_CompleteCalcCase
+{
+public:
+
+  static bool AddObjects( const Handle(HYDROData_Document)& doc,
+                          Handle(HYDROData_CalculationCase)& theCalcCase, 
+                          NCollection_Sequence<Handle(HYDROData_Entity)> theNewObjects,
+                          bool& IsIntersectionOfNewObj);
+
+};
+
+#endif
index 0a32ca181227460d561de20d23d6551332b22203..4e2a6be6dad258d6970691645f97ce799e2dadf0 100644 (file)
@@ -137,7 +137,7 @@ HYDROData_SequenceOfObjects HYDROData_Region::GetZones() const
   return GetReferenceObjects( DataTag_Zone );
 }
 
-void HYDROData_Region::RemoveZone( const Handle(HYDROData_Zone)& theZone )
+void HYDROData_Region::RemoveZone( const Handle(HYDROData_Zone)& theZone,  bool removeRegion )
 {
   if ( theZone.IsNull() )
     return;
@@ -150,10 +150,13 @@ void HYDROData_Region::RemoveZone( const Handle(HYDROData_Zone)& theZone )
   if ( !aFatherRegion.IsNull() && aFatherRegion->Label() == myLab )
     theZone->Remove();
 
-  // If the last zone has been removed from region we remove this region
-  HYDROData_SequenceOfObjects aRefZones = GetZones();
-  if ( aRefZones.IsEmpty() )
-    Remove();
+  if (removeRegion)
+  {
+    // If the last zone has been removed from region we remove this region
+    HYDROData_SequenceOfObjects aRefZones = GetZones();
+    if ( aRefZones.IsEmpty() )
+      Remove();
+  }
 }
 
 void HYDROData_Region::RemoveZones()
index 205e546ef97bfdf1f214a25c0e5209b2f5be87c1..b9a5314c6ae5febf2442120a457ad5d8fea4550b 100644 (file)
@@ -96,7 +96,7 @@ public:
   /**
    * Removes reference zone from region.
    */
-  HYDRODATA_EXPORT virtual void RemoveZone( const Handle(HYDROData_Zone)& theZone );
+  HYDRODATA_EXPORT virtual void RemoveZone( const Handle(HYDROData_Zone)& theZone, bool removeRegion = true );
 
   /**
    * Removes all reference zones from region.
@@ -115,8 +115,6 @@ public:
 
   HYDRODATA_EXPORT bool IsSubmersible() const;
 
-protected:
-
   /**
    * Create new one reference zone for region on child label.
    * The new zone is added into the list of reference zones.
index 25302c1503e5938c565f751e878f85aa0012340e..cea2e55c11e04247a7a06bc41fb2c8884928c952 100644 (file)
@@ -78,7 +78,7 @@ TopoDS_Face HYDROData_SplitToZonesTool::SplitData::Face() const
   return aResFace;
 }
 
-Standard_Boolean buildLimFace(const TopoDS_Wire& theBndWire, TopoDS_Face& outFace) 
+Standard_Boolean HYDROData_SplitToZonesTool::buildLimFace(const TopoDS_Wire& theBndWire, TopoDS_Face& outFace) 
 {
   GProp_GProps G;
   BRepGProp::LinearProperties(theBndWire,G);
index b4e092eb87402a0704d875eba352d34f29ab248c..e3d9af035a966ababc2ad9a19e4b891fa54a0a3a 100644 (file)
@@ -28,6 +28,8 @@
 #include <TopoDS_Shape.hxx>
 #include <TopoDS_Compound.hxx>
 #include <TopoDS_Face.hxx>
+#include <TopoDS_Wire.hxx>
+
 #include <TopTools_ShapeMapHasher.hxx>
 #include <NCollection_IndexedMap.hxx>
 #include <TopTools_IndexedDataMapOfShapeShape.hxx>
@@ -113,6 +115,9 @@ public:
 
   static void SetFileNames(const QString& theNameBefore, const QString& theNameAfter);
 
+  static Standard_Boolean buildLimFace(const TopoDS_Wire& theBndWire, TopoDS_Face& outFace);
+
+
 private:
 
   /**
index b5c783d84ebbc4d037be6b095ba709b88248e77f..c4fd3ac7249a5962fdfedf688f1c39954741a910 100644 (file)
@@ -917,18 +917,23 @@ void HYDROGUI_CalculationDlg::setEditZonesEnabled( const bool theIsEnabled )
   Get included geometry objects.
   @return the list of geometry objects
  */
-QList<Handle(HYDROData_Entity)> HYDROGUI_CalculationDlg::getGeometryObjects()
+QList<Handle(HYDROData_Entity)> HYDROGUI_CalculationDlg::getGeometryObjects(bool GeomObjOnly)
 {
   QList<Handle(HYDROData_Entity)> anEntities = myGeomObjects->getObjects();
   QList<Handle(HYDROData_Entity)> anObjects;
 
-  foreach ( Handle(HYDROData_Entity) anEntity, anEntities ) {
-    Handle(HYDROData_Object) anObj = Handle(HYDROData_Object)::DownCast( anEntity );
-    if ( anObj.IsNull() ) {
-      continue;
+  foreach ( Handle(HYDROData_Entity) anEntity, anEntities ) 
+  {
+    if (GeomObjOnly)
+    {
+      Handle(HYDROData_Object) anObj = Handle(HYDROData_Object)::DownCast( anEntity );
+      if ( anObj.IsNull() ) {
+        continue;
+      }      
+      anObjects << anObj;
     }
-
-    anObjects << anObj;
+    else
+      anObjects << anEntity;
   }
 
   return anObjects;
index 2866b623440101e4729415ba0ea8bf403b57434a..07307c744ab465a48e758dcfdd7324779bd6e2e9 100644 (file)
@@ -83,6 +83,8 @@ public:
   HYDROData_ListOfRules      getRules() const;
   void                       setRules( const HYDROData_ListOfRules& theRules ) const;
 
+  QList<Handle(HYDROData_Entity)> getGeometryObjects(bool GeomObjOnly = true);
+
 public slots:
   void                       setMode( int theMode );
   void                       setBoundary( const QString& theObjName );
@@ -158,7 +160,7 @@ protected slots:
   void OnNewRegion();
 
 private:
-  QList<Handle(HYDROData_Entity)> getGeometryObjects();
+
   
   QWizardPage*               createObjectsPage();
   QWizardPage*               createGroupsPage();
index 739df20fcb81f4ce75dc5bf11039f2ffe6a6844a..fca5ae8d7046fe97b995218400a2903712455a8d 100644 (file)
 #include <QApplication>
 #include <QKeySequence>
 #include <QShortcut>
+#include <BRep_Builder.hxx>
+#include <TopoDS.hxx>
+#include <TopTools_IndexedMapOfShape.hxx>
+#include <TopExp.hxx>
+#include <TopoDS.hxx>
 
-HYDROGUI_CalculationOp::HYDROGUI_CalculationOp( HYDROGUI_Module* theModule, bool theIsEdit )
+HYDROGUI_CalculationOp::HYDROGUI_CalculationOp( HYDROGUI_Module* theModule, bool theIsEdit, bool IsComplete )
 : HYDROGUI_Operation( theModule ),
   myIsEdit( theIsEdit ),
   myActiveViewManager( NULL ),
   myPreviewViewManager( NULL ),
   myShowGeomObjects( true ),
   myShowLandCoverMap( false ),
-  myShowZones( false )
+  myShowZones( false ),
+  myDenyIncExcl (IsComplete)
 {
   setName( myIsEdit ? tr( "EDIT_CALCULATION" ) : tr( "CREATE_CALCULATION" ) );
 }
@@ -177,6 +183,9 @@ void HYDROGUI_CalculationOp::startOperation()
   aPanel->setObjectName( anObjectName );
   aPanel->setEditedObject( myEditedObject );
 
+  myIncObjAtStart.clear();
+  myIncObjAtStart = aPanel->getGeometryObjects(false);
+
   setGeomObjectsVisible( true );
 
   createPreview( false );
@@ -571,6 +580,20 @@ void HYDROGUI_CalculationOp::onRemoveObjects()
     return;
 
   QStringList aSelectedList = aPanel->getSelectedGeomObjects();
+
+  if (myDenyIncExcl)
+  {
+    QSet<QString> selMap = aSelectedList.toSet();
+    myIncObjAtStart.toVector();
+    for (int i=0;i<myIncObjAtStart.size();i++)
+    {
+      QString str = myIncObjAtStart[i]->GetName();
+      if (selMap.contains(str))
+        return;
+    }
+  }
+
+
   if ( aSelectedList.isEmpty() || !confirmRegionsChange() )
     return;
 
@@ -602,10 +625,21 @@ void HYDROGUI_CalculationOp::onRemoveObjects()
 
 bool HYDROGUI_CalculationOp::confirmRegionsChange() const
 {
+
   // Check if the case is already modified or not
   bool isConfirmed = myEditedObject->IsMustBeUpdated( HYDROData_Entity::Geom_2d );
+
   if ( !isConfirmed )
   {
+  
+   if (myDenyIncExcl)
+   {
+     SUIT_MessageBox::information(module()->getApp()->desktop(),
+                              tr( "REGIONS_CHANGED" ),
+                              tr( "COMPLETE_OP_WILL_BE_PERFORMED" ));
+     return true;
+   }
+
     // If not modified check if the case has already defined regions with zones
     HYDROData_SequenceOfObjects aSeq = myEditedObject->GetRegions();
     if ( aSeq.Length() > 0 )
@@ -812,7 +846,7 @@ void HYDROGUI_CalculationOp::onApply()
                                aMsg ); 
   }
 }
-
+#include <HYDROData_CompleteCalcCase.h>
 void HYDROGUI_CalculationOp::onNext( const int theIndex )
 {
   if( theIndex==1 )
@@ -986,7 +1020,29 @@ void HYDROGUI_CalculationOp::onNext( const int theIndex )
     if ( myEditedObject->IsMustBeUpdated( HYDROData_Entity::Geom_All ) )
     {
       myShowZones = true;
-      myEditedObject->Update();
+      
+      if (myDenyIncExcl)
+      {
+        QList<Handle(HYDROData_Entity)> ibcludedGeomObj = aPanel->getGeometryObjects(false);
+        //QSet<Handle(HYDROData_Entity)> includedObjAtStartSet = myIncObjAtStart.toSet();
+        NCollection_Sequence<Handle(HYDROData_Entity)> theNewObjects;
+        foreach (Handle(HYDROData_Entity) obj, ibcludedGeomObj)
+        {
+          if (!myIncObjAtStart.contains(obj))
+            theNewObjects.Append(obj);
+        }
+
+        bool is_int = false;
+        HYDROData_CompleteCalcCase::AddObjects(doc(), myEditedObject, theNewObjects, is_int);
+        if (is_int)        
+          SUIT_MessageBox::information(module()->getApp()->desktop(),
+          tr( "COMPLETE_CASE" ),
+          tr( "There is an intersection(s) between new objects. result will be depend on order" ));
+
+        myEditedObject->ClearChanged();
+      }
+      else
+        myEditedObject->Update();
       
       AssignDefaultZonesColors();
 
index 8eb18c1463deed01f16d76e1f63768623db0b2d2..e2ba6d4cff3035b39731f0cbca1f3e80d4cce9fc 100644 (file)
@@ -38,7 +38,7 @@ class HYDROGUI_CalculationOp : public HYDROGUI_Operation
   Q_OBJECT
 
 public:
-  HYDROGUI_CalculationOp( HYDROGUI_Module* theModule, bool theIsEdit );
+  HYDROGUI_CalculationOp( HYDROGUI_Module* theModule, bool theIsEdit, bool IsComplete );
   virtual ~HYDROGUI_CalculationOp();
 
 protected:
@@ -170,6 +170,9 @@ private:
 
   SUIT_ViewManager*               myActiveViewManager;
   OCCViewer_ViewManager*          myPreviewViewManager;
+  QList<Handle(HYDROData_Entity)> myIncObjAtStart;
+
+  bool myDenyIncExcl;
 };
 
 #endif
index cca1a2ae051bf165c0c9a25f09619296e9b1693b..4b0e8863dd3e6b614515aca308eb9221066d5067 100755 (executable)
@@ -693,6 +693,7 @@ void HYDROGUI_Module::contextMenuPopup( const QString& theClient,
       {
         theMenu->addAction( action( EditCalculationId ) );
         theMenu->addAction( action( ExportCalculationId ) );
+        theMenu->addAction( action( CompleteCalculationId ) );
         theMenu->addSeparator();
       }
       else if( anIsImmersibleZone )
index 8c459d9a845488ca46928c816227f92096870f45..f4cec87b19e80ccce1cb00de53bd487b1315f4de 100644 (file)
@@ -214,6 +214,8 @@ void HYDROGUI_Module::createActions()
   createAction( EditCalculationId, "EDIT_CALCULATION", "EDIT_CALCULATION_ICO" );
   createAction( ExportCalculationId, "EXPORT_CALCULATION", "EXPORT_CALCULATION_ICO" );
 
+  createAction( CompleteCalculationId, "COMPLETE_CALCULATION", "COMPLETE_CALCULATION_ICO" );
+
   createAction( FuseImagesId, "FUSE_IMAGES", "FUSE_IMAGES_ICO" );
   createAction( EditFusedImageId, "EDIT_FUSED_IMAGE", "EDIT_FUSED_IMAGE_ICO" );
 
@@ -736,8 +738,13 @@ LightApp_Operation* HYDROGUI_Module::createOperation( const int theId ) const
     break;
   case CreateCalculationId:
   case EditCalculationId:
-    anOp = new HYDROGUI_CalculationOp( aModule, theId == EditCalculationId );
+    anOp = new HYDROGUI_CalculationOp( aModule, theId == EditCalculationId, false );
+    break;
+
+  case CompleteCalculationId:
+    anOp = new HYDROGUI_CalculationOp( aModule, true, true);
     break;
+
   case ExportCalculationId:
     anOp = new HYDROGUI_ExportCalculationOp( aModule );
     break;
index c1aac72b7a90df8f52a634a006df3b51f233285b..4ebcef9105963f9d8f7f2717b2456d45aed9d1c7 100644 (file)
@@ -72,6 +72,7 @@ enum OperationId
   CreateCalculationId,
   EditCalculationId,
   ExportCalculationId,
+  CompleteCalculationId,
 
   FuseImagesId,
   EditFusedImageId,