]> SALOME platform Git repositories - modules/hydro.git/commitdiff
Salome HOME
refs #766
authorisn <isn@opencascade.com>
Tue, 8 Dec 2015 15:30:42 +0000 (18:30 +0300)
committerisn <isn@opencascade.com>
Tue, 8 Dec 2015 15:30:42 +0000 (18:30 +0300)
more complex way to store the history of shape modifications

src/HYDROData/HYDROData_LandCoverMap.cxx
src/HYDROData/HYDROData_LandCoverMap.h

index e5dacdf560869235397b3065f0c32672152f8020..8f257c79df3c7a623739ff0c014cf619b1e527f5 100644 (file)
@@ -925,8 +925,10 @@ void HYDROData_LandCoverMap::StoreLandCovers( const HYDROData_MapOfFaceToStrickl
 
   //remove internal edges
   //if nothing changes => the result shape should be the same
-  //in any other case the history of modifications may be broken
-  aResult = RemoveInternal(aResult);
+  //hence the map will be empty
+
+  NCollection_IndexedDataMap<TopoDS_Face, TopoDS_Face> ShF2FHistory;
+  RemoveInternal(aResult, &ShF2FHistory);
 
   //one face => mark as unchanged
   if( aListOfFaces.Extent() == 1 )
@@ -943,8 +945,11 @@ void HYDROData_LandCoverMap::StoreLandCovers( const HYDROData_MapOfFaceToStrickl
     TopTools_ListOfShape aLS = ShHistory.FindFromKey(aFF);
     if (aLS.IsEmpty())
     {
-      QString SType = theMap.FindFromKey(aFF);
-      aChF2ST.Add(aFF, SType);
+      QString aSType = theMap.FindFromKey(aFF);
+      if (ShF2FHistory.Contains(aFF))
+        aChF2ST.Add(ShF2FHistory.FindFromKey(aFF), aSType);
+      else
+        aChF2ST.Add(aFF, aSType);
     }
     else
     {
@@ -952,7 +957,11 @@ void HYDROData_LandCoverMap::StoreLandCovers( const HYDROData_MapOfFaceToStrickl
       for (; anIt.More(); anIt.Next())
       {
         QString aSType = theMap.FindFromKey(aFF);
-        aChF2ST.Add(TopoDS::Face(anIt.Value()), aSType);
+        const TopoDS_Face& aMF = TopoDS::Face(anIt.Value()); 
+        if (ShF2FHistory.Contains(aFF))
+          aChF2ST.Add(ShF2FHistory.FindFromKey(aFF), aSType);
+        else
+          aChF2ST.Add(aFF, aSType);
       }
     }
   }
@@ -1049,35 +1058,51 @@ QStringList HYDROData_LandCoverMap::DumpToPython( const QString&       thePyScri
   return aResList;
 }
 
-TopoDS_Shape HYDROData_LandCoverMap::RemoveInternal(const TopoDS_Shape& InSh)
+void HYDROData_LandCoverMap::RemoveInternal(TopoDS_Shape& ShToRebuild, NCollection_IndexedDataMap<TopoDS_Face, TopoDS_Face>* aF2FReplace)
 {
   //Shape must be topologically correct
-  TopExp_Explorer anExp(InSh, TopAbs_EDGE);
-  TopTools_ListOfShape anEdgesToRemove;
-
-  for(; anExp.More(); anExp.Next() )
+  TopExp_Explorer anExpF(ShToRebuild, TopAbs_FACE);
+  //
+  for(; anExpF.More(); anExpF.Next() )
   {
-    TopoDS_Edge CurEdge = TopoDS::Edge(anExp.Current());
-    if (CurEdge.Orientation() == TopAbs_INTERNAL)
-      anEdgesToRemove.Append(CurEdge);
+    TopoDS_Face CurFace = TopoDS::Face(anExpF.Current());
+    //
+    TopExp_Explorer anExp(CurFace, TopAbs_EDGE);
+    TopTools_ListOfShape anEdgesToRemove;
+    //
+    for(; anExp.More(); anExp.Next() )
+    {
+      TopoDS_Edge CurEdge = TopoDS::Edge(anExp.Current());
+      if (CurEdge.Orientation() == TopAbs_INTERNAL)
+        anEdgesToRemove.Append(CurEdge);
+    }
+    //
+    if (!anEdgesToRemove.IsEmpty())
+    {
+      Handle_ShapeBuild_ReShape aReshape = new ShapeBuild_ReShape();
+      TopoDS_Shape OutF = aReshape->Apply(CurFace);
+      TopTools_ListIteratorOfListOfShape aIt(anEdgesToRemove);
+      for (; aIt.More(); aIt.Next()) 
+        aReshape->Remove(aIt.Value());
+      OutF = aReshape->Apply(CurFace);
+
+      Handle(ShapeFix_Shape) sfs = new ShapeFix_Shape;
+      sfs->Init(OutF);
+      sfs->Perform();
+      OutF = sfs->Shape();
+      aF2FReplace->Add(CurFace, TopoDS::Face(OutF));
+    }
   }
-  if (!anEdgesToRemove.IsEmpty())
+  //
+  Handle_ShapeBuild_ReShape anExtReshape = new ShapeBuild_ReShape();
+  for (int i = 1; i <= aF2FReplace->Extent(); i++)
   {
-    Handle_ShapeBuild_ReShape aReshape = new ShapeBuild_ReShape();
-    TopoDS_Shape OutSh = aReshape->Apply(InSh);
-    TopTools_ListIteratorOfListOfShape aIt(anEdgesToRemove);
-    for (; aIt.More(); aIt.Next()) 
-      aReshape->Remove(aIt.Value());
-    OutSh = aReshape->Apply(InSh);
-
-    Handle(ShapeFix_Shape) sfs = new ShapeFix_Shape;
-    sfs->Init(OutSh);
-    sfs->Perform();
-    return sfs->Shape();
+    TopoDS_Face aFK = aF2FReplace->FindKey(i);
+    TopoDS_Face aFV = aF2FReplace->FindFromIndex(i);
+    anExtReshape->Replace(aFK, aFV);
+    ShToRebuild = anExtReshape->Apply(ShToRebuild);
   }
-  else
-    return InSh;
+
 }
 
 void HYDROData_LandCoverMap::SetTransparency( double theTransparency )
index 736a8d7e16a49be03a5bd26bc029a5d39f62fada..cf2fe76fb6f801455b0983c7e9d60bbef0f9aa43 100644 (file)
@@ -142,7 +142,7 @@ public:
   HYDRODATA_EXPORT void SetTransparency( double );
   HYDRODATA_EXPORT double GetTransparency() const;
 
-  HYDRODATA_EXPORT TopoDS_Shape RemoveInternal(const TopoDS_Shape& InSh);
+  HYDRODATA_EXPORT void RemoveInternal(TopoDS_Shape& ShToRebuild, NCollection_IndexedDataMap<TopoDS_Face, TopoDS_Face>* aF2FReplace);
 
   HYDRODATA_EXPORT bool CheckLinear();