]> SALOME platform Git repositories - modules/hydro.git/commitdiff
Salome HOME
refs #1065
authorisn <isn@opencascade.com>
Fri, 2 Dec 2016 13:46:07 +0000 (16:46 +0300)
committerisn <isn@opencascade.com>
Fri, 2 Dec 2016 13:46:07 +0000 (16:46 +0300)
src/HYDROData/HYDROData_SplitToZonesTool.cxx
src/HYDROData/HYDROData_SplitToZonesTool.h
src/HYDRO_tests/test_HYDROData_CalcCase.cxx

index 12548ef236cf138357e9b7bba9bca796f1c5edd3..182c61781ffcc8601989763b74f99d91b5bedbcf 100644 (file)
@@ -227,7 +227,8 @@ HYDROData_SplitToZonesTool::SplitDataList
       //anOutputSplitDataList.append(anInputSplitDataList); 
       SplitData SD = anInputSplitDataList.at(0);
       TopTools_ListOfShape newshs;
-      CutFaceByEdges(SD.Face(), newshs, InterPolys, &OutNE);
+      TopTools_IndexedDataMapOfShapeListOfShape OutOrSh2M;
+      CutFaceByEdges(SD.Face(), newshs, InterPolys, &OutNE, &OutOrSh2M);
       for (TopTools_ListIteratorOfListOfShape it(newshs); it.More(); it.Next())
       {
         SplitData NSD = SD;
@@ -246,7 +247,38 @@ HYDROData_SplitToZonesTool::SplitDataList
       }
 
       if(!theGroupsList.IsEmpty() ) 
-        anOutputSplitDataList.append(anInputGroupList);
+      {
+        SplitDataList ModifInpGroupList;
+        SplitDataListIterator it(anInputGroupList);
+        while( it.hasNext() )
+        {
+          const SplitData& SData = it.next();
+          if (SData.Type != SplitData::Data_Edge)
+            ModifInpGroupList.append(SData); //add as is
+          const TopoDS_Shape& SData_sh = SData.Shape;
+          const TopTools_ListOfShape& modif_ls = OutOrSh2M.FindFromKey(SData_sh);
+          if (modif_ls.IsEmpty())
+            ModifInpGroupList.append(SData); //non modified
+          else
+          {
+            TopTools_ListIteratorOfListOfShape itl_modif(modif_ls);
+            for (;itl_modif.More();itl_modif.Next())
+            {
+              const TopoDS_Shape& CSH = itl_modif.Value();
+              if (CSH.ShapeType() == TopAbs_EDGE)
+              {
+                SplitData NewSData;
+                NewSData.ObjectNames = SData.ObjectNames;
+                NewSData.Type = SData.Type;
+                NewSData.Shape = CSH;
+                ModifInpGroupList.append(NewSData);
+              }
+            }
+          }
+
+        }
+        anOutputSplitDataList.append(ModifInpGroupList);
+      }
       return anOutputSplitDataList;
     }
     else
@@ -688,7 +720,7 @@ void HYDROData_SplitToZonesTool::AddInternalEdges(HYDROData_DataMapOfShapeListOf
     TopTools_ListOfShape out;
     if (K.ShapeType() == TopAbs_FACE)
     {
-      CutByEdges(K, Wires, out, &OutNE1);
+      CutByEdges(K, Wires, out, &OutNE1, NULL);
       TopTools_ListIteratorOfListOfShape it(out);
       for (;it.More(); it.Next())
       {
@@ -710,7 +742,8 @@ void HYDROData_SplitToZonesTool::AddInternalEdges(HYDROData_DataMapOfShapeListOf
 void HYDROData_SplitToZonesTool::CutFaceByEdges(const TopoDS_Face& in, 
                                                 TopTools_ListOfShape& out, 
                                                 const HYDROData_SequenceOfObjects& thePolylines,
-                                                NCollection_DataMap<TopoDS_Shape, Handle(HYDROData_PolylineXY), TopTools_ShapeMapHasher>* OutNE)
+                                                NCollection_DataMap<TopoDS_Shape, Handle(HYDROData_PolylineXY), TopTools_ShapeMapHasher>* OutNE,                                                
+                                                TopTools_IndexedDataMapOfShapeListOfShape* OutOrSh2M)
 {
 
   HYDROData_SequenceOfObjects::Iterator it(thePolylines);
@@ -725,7 +758,7 @@ void HYDROData_SplitToZonesTool::CutFaceByEdges(const TopoDS_Face& in,
   }
 
   TopTools_IndexedDataMapOfShapeShape OutNE1;
-  CutByEdges(in, Wires, out, &OutNE1);
+  CutByEdges(in, Wires, out, &OutNE1, OutOrSh2M);
 
   for (int i = 1; i <= OutNE1.Extent(); i++)
     OutNE->Bind(OutNE1.FindKey(i), W2P(OutNE1.FindFromIndex(i)));
@@ -733,7 +766,9 @@ void HYDROData_SplitToZonesTool::CutFaceByEdges(const TopoDS_Face& in,
 }
 
 int HYDROData_SplitToZonesTool::CutByEdges(const TopoDS_Shape& InSh, const TopTools_ListOfShape& InW,
-  TopTools_ListOfShape& outShs, TopTools_IndexedDataMapOfShapeShape* OutNE)
+                                           TopTools_ListOfShape& outShs, 
+                                           TopTools_IndexedDataMapOfShapeShape* OutNE, 
+                                           TopTools_IndexedDataMapOfShapeListOfShape* OInSH2MSH)
 {
   int anError;
   if (InSh.IsNull())
@@ -791,7 +826,19 @@ int HYDROData_SplitToZonesTool::CutByEdges(const TopoDS_Shape& InSh, const TopTo
       if (AllEdges.Contains(CE))
         OutNE->Add(CE, V);
     }
+  }
 
+  //map all sub-shapes from the original InSh to modified shapes  
+  if (OInSH2MSH)
+  {
+    TopTools_IndexedMapOfShape allSh;
+    TopExp::MapShapes(InSh, allSh);
+    for(int i = 1; i <= allSh.Extent(); i++ )
+    {
+      const TopoDS_Shape& or_sh = allSh(i); 
+      const TopTools_ListOfShape& ls = anAlgo.Modified(or_sh);
+      OInSH2MSH->Add(or_sh, ls);
+    }
   }
 
   return 0;
index 63a3065e6c7cf5727c5ae84c588b7429f48dc400..367b22cdcf10512743edbd57c142d6eb3ba11475 100644 (file)
@@ -31,6 +31,7 @@
 #include <TopTools_ShapeMapHasher.hxx>
 #include <NCollection_IndexedMap.hxx>
 #include <TopTools_IndexedDataMapOfShapeShape.hxx>
+#include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
 #include <TopTools_ListOfShape.hxx>
 #include <QStringList>
 #include <NCollection_DataMap.hxx>
@@ -101,11 +102,13 @@ public:
   static void CutFaceByEdges(const TopoDS_Face& in, 
                              TopTools_ListOfShape& out, 
                              const HYDROData_SequenceOfObjects& thePolylines,
-                             NCollection_DataMap<TopoDS_Shape, Handle(HYDROData_PolylineXY), TopTools_ShapeMapHasher>* OutNE);
+                             NCollection_DataMap<TopoDS_Shape, Handle(HYDROData_PolylineXY), TopTools_ShapeMapHasher>* OutNE,
+                             TopTools_IndexedDataMapOfShapeListOfShape* OutOrSh2M);
 
   static int CutByEdges(const TopoDS_Shape& InSh, const TopTools_ListOfShape& InW,
                         TopTools_ListOfShape& outShs,
-                        TopTools_IndexedDataMapOfShapeShape* OutNE2OE);
+                        TopTools_IndexedDataMapOfShapeShape* OutNE2OE,
+                        TopTools_IndexedDataMapOfShapeListOfShape* OInSH2MSH);
 
   static void SetFileNames(const QString& theNameBefore, const QString& theNameAfter);
 
index f1cf71b8f434df1a775dea7cc5a9048e4ede7eca..7e3c9b7226aafa33ebd9f9b0ceebce12d6a3990b 100644 (file)
@@ -53,7 +53,7 @@ void test_HYDROData_CalcCase::test_add_int_wires()
 
     TopTools_ListOfShape OutSh;
     TopTools_IndexedDataMapOfShapeShape ls;
-    HYDROData_SplitToZonesTool::CutByEdges(InF, Wires, OutSh, &ls);
+    HYDROData_SplitToZonesTool::CutByEdges(InF, Wires, OutSh, &ls, NULL);
 
     CPPUNIT_ASSERT_EQUAL(2, OutSh.Extent());
     TopoDS_Compound cmp;
@@ -77,7 +77,7 @@ void test_HYDROData_CalcCase::test_add_int_wires()
 
     TopTools_ListOfShape OutSh;
     TopTools_IndexedDataMapOfShapeShape ls;
-    HYDROData_SplitToZonesTool::CutByEdges(InF, Wires, OutSh, &ls);
+    HYDROData_SplitToZonesTool::CutByEdges(InF, Wires, OutSh, &ls, NULL);
     CPPUNIT_ASSERT_EQUAL(1, OutSh.Extent());
     TestViewer::show( OutSh.First(), AIS_WireFrame, true, "cc_int_w_2" );
     //CPPUNIT_ASSERT_IMAGES
@@ -96,7 +96,7 @@ void test_HYDROData_CalcCase::test_add_int_wires()
 
     TopTools_ListOfShape OutSh;
     TopTools_IndexedDataMapOfShapeShape ls;
-    HYDROData_SplitToZonesTool::CutByEdges(InF, Wires, OutSh, &ls);
+    HYDROData_SplitToZonesTool::CutByEdges(InF, Wires, OutSh, &ls, NULL);
     CPPUNIT_ASSERT_EQUAL(1, OutSh.Extent());
     TestViewer::show( OutSh.First(), AIS_WireFrame, true, "cc_int_w_3" );
     CPPUNIT_ASSERT_IMAGES