]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Implementation for 2 functions in ResultBody is added.
authorszy <szy@opencascade.com>
Fri, 31 Oct 2014 12:44:11 +0000 (15:44 +0300)
committerszy <szy@opencascade.com>
Fri, 31 Oct 2014 12:44:11 +0000 (15:44 +0300)
src/Model/Model_ResultBody.cpp

index f4a37d35316ac21749b73464e9d5e847ec469295..4aeeeed7a5ec78c36a9fc936d06df5461f6df989 100644 (file)
 #include <TDF_ChildIterator.hxx>
 #include <TopTools_MapOfShape.hxx>
 #include <TopExp_Explorer.hxx>
+#include <TopTools_ListOfShape.hxx>
+#include <TopTools_ListIteratorOfListOfShape.hxx>
+#include <TopTools_DataMapOfShapeListOfShape.hxx>
+#include <TopTools_DataMapIteratorOfDataMapOfShapeListOfShape.hxx>
+#include <TopTools_MapIteratorOfMapOfShape.hxx>
 #include <GeomAPI_Shape.h>
 #include <GeomAlgoAPI_MakeShape.h>
 // DEB
@@ -239,17 +244,105 @@ void Model_ResultBody::loadAndOrientGeneratedShapes (
   }
 }
 
-void Model_ResultBody::loadFirstLevel(boost::shared_ptr<GeomAPI_Shape> theShapeIn,int&  theTag)
+void Model_ResultBody::loadFirstLevel(boost::shared_ptr<GeomAPI_Shape> theShapeint&  theTag)
 {
 
 }
 
-void Model_ResultBody::loadDisconnectedEdges(boost::shared_ptr<GeomAPI_Shape> theShapeIn,int&  theTag)
+void Model_ResultBody::loadDisconnectedEdges(boost::shared_ptr<GeomAPI_Shape> theShapeint&  theTag)
 {
-
+  if(theShape->isNull()) return;
+  TopoDS_Shape aShape = theShape->impl<TopoDS_Shape>();  
+  TopTools_DataMapOfShapeListOfShape edgeNaborFaces;
+  TopTools_ListOfShape empty;
+  TopExp_Explorer explF(aShape, TopAbs_FACE);
+  for (; explF.More(); explF.Next()) {
+    const TopoDS_Shape& aFace = explF.Current();
+    TopExp_Explorer explV(aFace, TopAbs_EDGE);
+    for (; explV.More(); explV.Next()) {
+      const TopoDS_Shape& anEdge = explV.Current();
+      if (!edgeNaborFaces.IsBound(anEdge)) edgeNaborFaces.Bind(anEdge, empty);
+      Standard_Boolean faceIsNew = Standard_True;
+      TopTools_ListIteratorOfListOfShape itrF(edgeNaborFaces.Find(anEdge));
+      for (; itrF.More(); itrF.Next()) {
+           if (itrF.Value().IsSame(aFace)) {
+           faceIsNew = Standard_False;
+           break;
+               }
+         }
+      if (faceIsNew) 
+           edgeNaborFaces.ChangeFind(anEdge).Append(aFace);      
+       }
+  }
+  
+  TopTools_MapOfShape anEdgesToDelete;
+  TopExp_Explorer anEx(aShape,TopAbs_EDGE); 
+  for(;anEx.More();anEx.Next()) {
+    Standard_Boolean aC0 = Standard_False;
+    TopoDS_Shape anEdge1 = anEx.Current();
+    if (edgeNaborFaces.IsBound(anEdge1)) {
+      const TopTools_ListOfShape& aList1 = edgeNaborFaces.Find(anEdge1);
+      if (aList1.Extent()<2) continue;
+      TopTools_DataMapIteratorOfDataMapOfShapeListOfShape itr(edgeNaborFaces);
+      for (; itr.More(); itr.Next()) {
+           TopoDS_Shape anEdge2 = itr.Key();
+           if(anEdgesToDelete.Contains(anEdge2)) continue;
+           if (anEdge1.IsSame(anEdge2)) continue;
+           const TopTools_ListOfShape& aList2 = itr.Value();
+           // compare lists of the neighbour faces of edge1 and edge2
+           if (aList1.Extent() == aList2.Extent()) {
+           Standard_Integer aMatches = 0;
+           for(TopTools_ListIteratorOfListOfShape aLIter1(aList1);aLIter1.More();aLIter1.Next())
+             for(TopTools_ListIteratorOfListOfShape aLIter2(aList2);aLIter2.More();aLIter2.Next())
+               if (aLIter1.Value().IsSame(aLIter2.Value())) aMatches++;
+               if (aMatches == aList1.Extent()) {
+                 aC0=Standard_True;
+                         builder(++theTag)->Generated(anEdge2);              
+                 anEdgesToDelete.Add(anEdge2);
+                       }
+               }
+         }      
+      TopTools_MapIteratorOfMapOfShape itDelete(anEdgesToDelete);
+      for(;itDelete.More();itDelete.Next()) 
+           edgeNaborFaces.UnBind(itDelete.Key());      
+      edgeNaborFaces.UnBind(anEdge1);
+       }
+    if (aC0) 
+         builder(++theTag)->Generated(anEdge1);                  
+  }
 }
 
-void Model_ResultBody::loadDisconnectedVertexes(boost::shared_ptr<GeomAPI_Shape> theShapeIn,int&  theTag)
+void Model_ResultBody::loadDisconnectedVertexes(boost::shared_ptr<GeomAPI_Shape> theShapeint&  theTag)
 {
+  if(theShape->isNull()) return;
+  TopoDS_Shape aShape = theShape->impl<TopoDS_Shape>();  
+  TopTools_DataMapOfShapeListOfShape vertexNaborFaces;
+  TopTools_ListOfShape empty;
+  TopExp_Explorer explF(aShape, TopAbs_FACE);
+  for (; explF.More(); explF.Next()) {
+    const TopoDS_Shape& aFace = explF.Current();
+    TopExp_Explorer explV(aFace, TopAbs_VERTEX);
+    for (; explV.More(); explV.Next()) {
+      const TopoDS_Shape& aVertex = explV.Current();
+      if (!vertexNaborFaces.IsBound(aVertex)) vertexNaborFaces.Bind(aVertex, empty);
+      Standard_Boolean faceIsNew = Standard_True;
+      TopTools_ListIteratorOfListOfShape itrF(vertexNaborFaces.Find(aVertex));
+      for (; itrF.More(); itrF.Next()) {
+        if (itrF.Value().IsSame(aFace)) {
+          faceIsNew = Standard_False;
+          break;
+        }
+      }
+      if (faceIsNew) {
+        vertexNaborFaces.ChangeFind(aVertex).Append(aFace);
+      }
+    }
+  }
 
+  TopTools_DataMapIteratorOfDataMapOfShapeListOfShape itr(vertexNaborFaces);
+  for (; itr.More(); itr.Next()) {
+    const TopTools_ListOfShape& naborFaces = itr.Value();
+    if (naborFaces.Extent() < 3) 
+               builder(++theTag)->Generated(itr.Key());         
+  }
 }
\ No newline at end of file