From: szy Date: Fri, 31 Oct 2014 12:44:11 +0000 (+0300) Subject: Implementation for 2 functions in ResultBody is added. X-Git-Tag: V_0.5~48^2~3 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=931d63489fc9bddc030b2b422f87a27106cff41f;p=modules%2Fshaper.git Implementation for 2 functions in ResultBody is added. --- diff --git a/src/Model/Model_ResultBody.cpp b/src/Model/Model_ResultBody.cpp index f4a37d353..4aeeeed7a 100644 --- a/src/Model/Model_ResultBody.cpp +++ b/src/Model/Model_ResultBody.cpp @@ -10,6 +10,11 @@ #include #include #include +#include +#include +#include +#include +#include #include #include // DEB @@ -239,17 +244,105 @@ void Model_ResultBody::loadAndOrientGeneratedShapes ( } } -void Model_ResultBody::loadFirstLevel(boost::shared_ptr theShapeIn,int& theTag) +void Model_ResultBody::loadFirstLevel(boost::shared_ptr theShape, int& theTag) { } -void Model_ResultBody::loadDisconnectedEdges(boost::shared_ptr theShapeIn,int& theTag) +void Model_ResultBody::loadDisconnectedEdges(boost::shared_ptr theShape, int& theTag) { - + if(theShape->isNull()) return; + TopoDS_Shape aShape = theShape->impl(); + 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 theShapeIn,int& theTag) +void Model_ResultBody::loadDisconnectedVertexes(boost::shared_ptr theShape, int& theTag) { + if(theShape->isNull()) return; + TopoDS_Shape aShape = theShape->impl(); + 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