-//=======================================================================
-void Model_ResultBody::loadFirstLevel(
- std::shared_ptr<GeomAPI_Shape> theShape, int& theTag)
-{
- if(theShape->isNull()) return;
- TopoDS_Shape aShape = theShape->impl<TopoDS_Shape>();
- if (aShape.ShapeType() == TopAbs_COMPOUND || aShape.ShapeType() == TopAbs_COMPSOLID) {
- TopoDS_Iterator itr(aShape);
- for (; itr.More(); itr.Next()) {
- builder(++theTag)->Generated(itr.Value());
- if (itr.Value().ShapeType() == TopAbs_COMPOUND ||
- itr.Value().ShapeType() == TopAbs_COMPSOLID)
- {
- std::shared_ptr<GeomAPI_Shape> itrShape(new GeomAPI_Shape());
- itrShape->setImpl(new TopoDS_Shape(itr.Value()));
- loadFirstLevel(itrShape, theTag);
- } else {
- std::shared_ptr<GeomAPI_Shape> itrShape(new GeomAPI_Shape());
- itrShape->setImpl(new TopoDS_Shape(itr.Value()));
- loadNextLevels(itrShape, theTag);
- }
- }
- } else {
- std::shared_ptr<GeomAPI_Shape> itrShape(new GeomAPI_Shape());
- itrShape->setImpl(new TopoDS_Shape(aShape));
- loadNextLevels(itrShape, theTag);
- }
-}
-
-//=======================================================================
-void Model_ResultBody::loadDisconnectedEdges(
- std::shared_ptr<GeomAPI_Shape> theShape, int& 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(std::shared_ptr<GeomAPI_Shape> theShape, int& 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