// Copyright (C) 2005 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License. // // This library is distributed in the hope that it will be useful // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public // License along with this library; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // // File: BlockFix_CheckTool.cxx // Created: 17.12.04 11:15:25 // Author: Sergey KUUL // Copyright: Open CASCADE SA 2004 #include #include #include #include #include #include #include #include #include #include #include #include #include #include //======================================================================= //function : BlockFix_CheckTool() //purpose : Constructor //======================================================================= BlockFix_CheckTool::BlockFix_CheckTool( ) { myHasCheck = Standard_False; myPossibleBlocks.Clear(); } //======================================================================= //function : SetShape //purpose : //======================================================================= void BlockFix_CheckTool::SetShape(const TopoDS_Shape& aShape) { myHasCheck = Standard_False; myShape = aShape; myPossibleBlocks.Clear(); } //======================================================================= //function : Perform //purpose : //======================================================================= void BlockFix_CheckTool::Perform() { myNbSolids=0; myNbBlocks=0; myNbDegen=0; myNbUF=0; myNbUE=0; myNbUFUE=0; TopExp_Explorer exps; for(exps.Init(myShape, TopAbs_SOLID); exps.More(); exps.Next()) { TopoDS_Solid aSolid = TopoDS::Solid(exps.Current()); myNbSolids++; Standard_Boolean IsBlock=Standard_True; Standard_Boolean MayBeUF=Standard_False; Standard_Boolean MayBeUE=Standard_False; Standard_Integer nf=0; TopExp_Explorer expf; for(expf.Init(aSolid, TopAbs_FACE); expf.More(); expf.Next()) nf++; if(nf<6) { IsBlock=Standard_False; } else if(nf>6) { IsBlock=Standard_False; // check faces unification TopTools_SequenceOfShape faces; for( expf.Init(aSolid, TopAbs_FACE); expf.More(); expf.Next()) { TopoDS_Face aFace = TopoDS::Face(expf.Current()); faces.Append(aFace); } Standard_Boolean HasFacesForUnification = Standard_False; for(Standard_Integer i=1; i0 ) { IsBlock=Standard_False; myNbDegen++; myPossibleBlocks.Append(aSolid); continue; } if(nbe<24) IsBlock=Standard_False; if(nbe>24) { IsBlock=Standard_False; // check edges unification // creating map of edge faces TopTools_IndexedDataMapOfShapeListOfShape aMapEdgeFaces; TopExp::MapShapesAndAncestors(aSolid, TopAbs_EDGE, TopAbs_FACE, aMapEdgeFaces); for(expf.Init(aSolid, TopAbs_FACE); expf.More(); expf.Next()) { TopoDS_Face aFace = TopoDS::Face(expf.Current()); TopTools_IndexedDataMapOfShapeListOfShape aMapFacesEdges; for(expe.Init(aFace,TopAbs_EDGE); expe.More(); expe.Next()) { TopoDS_Edge edge = TopoDS::Edge(expe.Current()); if(!aMapEdgeFaces.Contains(edge)) continue; const TopTools_ListOfShape& aList = aMapEdgeFaces.FindFromKey(edge); TopTools_ListIteratorOfListOfShape anIter(aList); for( ; anIter.More(); anIter.Next()) { TopoDS_Face face = TopoDS::Face(anIter.Value()); if(face.IsSame(aFace)) continue; if(aMapFacesEdges.Contains(face)) { aMapFacesEdges.ChangeFromKey(face).Append(edge); } else { TopTools_ListOfShape ListEdges; ListEdges.Append(edge); aMapFacesEdges.Add(face,ListEdges); } } } Standard_Integer i=1; for(; i<=aMapFacesEdges.Extent(); i++) { const TopTools_ListOfShape& ListEdges = aMapFacesEdges.FindFromIndex(i); if(ListEdges.Extent()>1) break; } if(i<=aMapFacesEdges.Extent()) { MayBeUE=Standard_True; break; } } } if(IsBlock) myNbBlocks++; else { if(MayBeUF) { myPossibleBlocks.Append(aSolid); if(MayBeUE) myNbUFUE++; else myNbUF++; } else if(MayBeUE) { myNbUE++; myPossibleBlocks.Append(aSolid); } } } myHasCheck = Standard_True; } //======================================================================= //function : NbPossibleBlocks //purpose : //======================================================================= Standard_Integer BlockFix_CheckTool::NbPossibleBlocks() const { return myPossibleBlocks.Length(); } //======================================================================= //function : PossibleBlock //purpose : //======================================================================= TopoDS_Shape BlockFix_CheckTool::PossibleBlock(const Standard_Integer num) const { TopoDS_Shape res; if( num>0 && num<=myPossibleBlocks.Length() ) res = myPossibleBlocks.Value(num); return res; } //======================================================================= //function : DumpCheckResult //purpose : //======================================================================= void BlockFix_CheckTool::DumpCheckResult(Standard_OStream& S) const { if(!myHasCheck) S<<"Check not performed!"<