]> OCCT Git - occt-copy.git/commitdiff
Next version CR26907_4
authorjgv <jgv@opencascade.com>
Wed, 24 Oct 2018 13:38:18 +0000 (16:38 +0300)
committerjgv <jgv@opencascade.com>
Wed, 24 Oct 2018 13:38:18 +0000 (16:38 +0300)
src/ChFi3d/ChFi3d_Builder.cxx
src/ChFi3d/ChFi3d_Builder.hxx
src/ChFi3d/ChFi3d_Builder_6.cxx

index 9dd623e2195f167cb3bc5e609e66ac78877f4d49..98c05291995d90a89c78fe5f51488561eb5bd4ea 100644 (file)
@@ -82,6 +82,7 @@
 #include <TopTools_ListIteratorOfListOfShape.hxx>
 #include <TopTools_ListOfShape.hxx>
 #include <TopTools_MapOfOrientedShape.hxx>
+#include <BRepTools_ReShape.hxx>
 
 #ifdef OCCT_DEBUG
 #include <OSD_Chronometer.hxx>
@@ -109,6 +110,44 @@ extern void ChFi3d_ResultChron(OSD_Chronometer & ch, Standard_Real& time);
 extern Standard_Boolean ChFi3d_GettraceCHRON();
 #endif
 
+//=======================================================================
+//function : FindProperSubShape
+//purpose  : 
+//=======================================================================
+
+TopoDS_Shape FindProperSubShape(const TopoDS_Shape& theNewFace,
+                                const TopoDS_Shape& theShape)
+{
+  TopoDS_Shape NullShape;
+
+  TopTools_IndexedMapOfShape Emap;
+  TopExp::MapShapes(theNewFace, TopAbs_EDGE, Emap);
+
+  TopoDS_Iterator iter(theShape);
+  for (; iter.More(); iter.Next())
+  {
+    const TopoDS_Shape& aShape = iter.Value();
+    if (aShape.ShapeType() == TopAbs_FACE)
+    {
+      TopExp_Explorer Explo(aShape, TopAbs_EDGE);
+      for (; Explo.More(); Explo.Next())
+      {
+        const TopoDS_Shape& anEdge = Explo.Current();
+        if (Emap.Contains(anEdge))
+          return theShape;
+      }
+    }
+    else
+    {
+      TopoDS_Shape aResult = FindProperSubShape(theNewFace, aShape);
+      if (!aResult.IsNull())
+        return aResult;
+    }
+  }
+
+  return NullShape;
+}
+
 //=======================================================================
 //function : BuildNewWire
 //purpose  : 
@@ -599,6 +638,14 @@ void  ChFi3d_Builder::Compute()
       //general fuse (compound of wires from a face, compound of new edges for this face)
       //method building new face from old and new edges
       //assembling of resulting shape from modified and unmodified faces.
+
+      TopTools_ListOfShape aChFiFaces;
+      TopTools_IndexedDataMapOfShapeShape aFacesModifiedFaces;
+
+      //Temporary
+      TopoDS_Shell aShell;
+      BB.MakeShell(aShell);
+      
       for (Standard_Integer i = 1; i <= myNewFaces.Extent(); i++)
       {
         TopoDS_Face aFace = TopoDS::Face(myNewFaces(i));
@@ -618,36 +665,83 @@ void  ChFi3d_Builder::Compute()
           aNewEdge.Orientation(anOr);
           BB.Add(aNewEdges, aNewEdge);
         }
-        //BRepAlgoAPI_Fuse aFuse(aWires, aNewEdges);
-        BOPAlgo_Builder GenFuse;
-        GenFuse.AddArgument(aFace);
-        GenFuse.AddArgument(aNewEdges);
-        GenFuse.Perform();
-        TopoDS_Shape aNewFace = aFace.EmptyCopied();
-        const TopoDS_Shape& aResFuse = GenFuse.Shape();
-        //const BOPCol_DataMapOfShapeListOfShape& ModifiedShapes = GenFuse.Images();
-        const TopTools_DataMapOfShapeListOfShape& ModifiedShapes = GenFuse.Images();
-        TopTools_IndexedDataMapOfShapeListOfShape VEmapOfNewFace;
-        TopExp::MapShapesAndAncestors(aResFuse, TopAbs_VERTEX, TopAbs_EDGE, VEmapOfNewFace);
-        TopoDS_Iterator itw(aFace);
-        for (; itw.More(); itw.Next())
+
+        if (myIndsChFiFaces.Contains(i)) //absolutely new face
+        {
+          TopoDS_Wire aWire;
+          BB.MakeWire(aWire);
+          TopoDS_Iterator iter(aNewEdges);
+          for (; iter.More(); iter.Next())
+            BB.Add(aWire, iter.Value());
+          BB.Add(aFace, aWire);
+          aChFiFaces.Append(aFace);
+          //Temporary
+          BB.Add(aShell, aFace);
+        }
+        else //a modified old face
+        {
+          //BRepAlgoAPI_Fuse aFuse(aWires, aNewEdges);
+          BOPAlgo_Builder GenFuse;
+          GenFuse.AddArgument(aFace);
+          GenFuse.AddArgument(aNewEdges);
+          GenFuse.Perform();
+          TopoDS_Shape aNewFace = aFace.EmptyCopied();
+          const TopoDS_Shape& aResFuse = GenFuse.Shape();
+          //const BOPCol_DataMapOfShapeListOfShape& ModifiedShapes = GenFuse.Images();
+          const TopTools_DataMapOfShapeListOfShape& ModifiedShapes = GenFuse.Images();
+          TopTools_IndexedDataMapOfShapeListOfShape VEmapOfNewFace;
+          TopExp::MapShapesAndAncestors(aResFuse, TopAbs_VERTEX, TopAbs_EDGE, VEmapOfNewFace);
+          TopoDS_Iterator itw(aFace);
+          for (; itw.More(); itw.Next())
+          {
+            const TopoDS_Shape& aWire = itw.Value();
+            if (!ModifiedShapes.IsBound(aWire))
+              continue;
+            const TopTools_ListOfShape& aListOfModified = ModifiedShapes(aWire);
+            TopTools_ListIteratorOfListOfShape itwm(aListOfModified);
+            for (; itwm.More(); itwm.Next())
+            {
+              const TopoDS_Wire& aModifiedWire = TopoDS::Wire(itwm.Value());
+              cout<<"a Modified Wire ..."<<endl;
+              TopoDS_Wire aNewWire = BuildNewWire(aModifiedWire, VEmapOfNewFace, aNewEdges, aFace);
+              cout<<"a New Wire ..."<<endl;
+              BB.Add(aNewFace, aNewWire);
+              cout<<"a New Face ..."<<endl;
+              aFacesModifiedFaces.Add(aFace, aNewFace);
+              //Temporary
+              BB.Add(aShell, aNewFace);
+            }
+          }
+        }
+      }
+
+      //Modify the original shape using ReShape
+      BRepTools_ReShape aReshape;
+      for (Standard_Integer i = 1; i <= aFacesModifiedFaces.Extent(); i++)
+      {
+        const TopoDS_Shape& aFace = aFacesModifiedFaces.FindKey(i);
+        const TopoDS_Shape& aNewFace = aFacesModifiedFaces(i);
+        aReshape.Replace(aFace, aNewFace);
+      }
+      myShapeResult = aReshape.Apply(myShape);
+      //Add ChFiFaces
+      while (!aChFiFaces.IsEmpty())
+      {
+        TopTools_ListIteratorOfListOfShape itl(aChFiFaces);
+        while (itl.More())
         {
-          const TopoDS_Shape& aWire = itw.Value();
-          if (!ModifiedShapes.IsBound(aWire))
-            continue;
-          const TopTools_ListOfShape& aListOfModified = ModifiedShapes(aWire);
-          TopTools_ListIteratorOfListOfShape itwm(aListOfModified);
-          for (; itwm.More(); itwm.Next())
+          const TopoDS_Shape& aChFiFace = itl.Value();
+          TopoDS_Shape aTargetShape = FindProperSubShape(aChFiFace, myShapeResult); //recursive method
+          if (!aTargetShape.IsNull())
           {
-            const TopoDS_Wire& aModifiedWire = TopoDS::Wire(itwm.Value());
-            cout<<"a Modified Wire ..."<<endl;
-            TopoDS_Wire aNewWire = BuildNewWire(aModifiedWire, VEmapOfNewFace, aNewEdges, aFace);
-            cout<<"a New Wire ..."<<endl;
-            BB.Add(aNewFace, aNewWire);
-            cout<<"a New Face ..."<<endl;
+            BB.Add(aTargetShape, aChFiFace);
+            aChFiFaces.Remove(itl);
           }
+          else
+            itl.Next();
         }
       }
+      /////////////////////////////////////////
 
       myCoup->Perform(myDS);
       //jgv//
index abdc46645d235c4aca97128c6d7bf3d32f8e0658..e3b9f14eaff50babc1950525e12e03eae898fddb 100644 (file)
@@ -31,6 +31,7 @@
 #include <TopTools_ListOfShape.hxx>
 #include <TopTools_DataMapOfShapeListOfInteger.hxx>
 #include <TopTools_IndexedMapOfShape.hxx>
+#include <TColStd_MapOfInteger.hxx>
 #include <Standard_Boolean.hxx>
 #include <Standard_Integer.hxx>
 #include <ChFiDS_ErrorStatus.hxx>
@@ -327,6 +328,7 @@ protected:
   //NCollection_IndexedDataMap<Standard_Integer, ChFi3d_ListOfQualifiedEdge> myFaceNewEdges;
   TopTools_IndexedMapOfShape myNewFaces;
   TopTools_IndexedMapOfShape myNewEdges;
+  TColStd_MapOfInteger myIndsChFiFaces;
   Handle(TopOpeBRepBuild_HBuilder) myCoup;
   ChFiDS_ListOfStripe myListStripe;
   ChFiDS_StripeMap myVDataMap;
index bbfa1c260be9685f72302af30b184858698be7f0..c2e4b9f1903bed42b438cdcd9788a6767117be0c 100644 (file)
@@ -722,6 +722,7 @@ Standard_Boolean ChFi3d_Builder::StoreData(Handle(ChFiDS_SurfData)& Data,
   TopLoc_Location aLoc;
   BB.UpdateFace(aNewFace, Surf, aLoc, Precision::Confusion());
   Standard_Integer IndNewFace = myNewFaces.Add(aNewFace);
+  myIndsChFiFaces.Add(IndNewFace);
   //ChFi3d_ListOfQualifiedEdge aList;
   TColStd_ListOfInteger aList;
   myFaceNewEdges.Add(IndNewFace, aList);