Salome HOME
Update mail address
[modules/geom.git] / src / GEOMAlgo / BlockFix_CheckTool.cxx
index ba902ba5ab6edd47d314af5e5d70eb3babb03bcd..94269ef7531e50125f7db17459214dbbeb1871bc 100644 (file)
@@ -1,3 +1,22 @@
+// 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
@@ -54,6 +73,7 @@ void BlockFix_CheckTool::Perform()
 {
   myNbSolids=0;
   myNbBlocks=0;
+  myNbDegen=0;
   myNbUF=0;
   myNbUE=0;
   myNbUFUE=0;
@@ -108,13 +128,29 @@ void BlockFix_CheckTool::Perform()
       }
     }
 
-    Standard_Integer ne=0;
+    Standard_Integer nbe=0;
+    TopTools_MapOfShape DegenEdges;
     TopExp_Explorer expe;
-    for(expe.Init(aSolid, TopAbs_EDGE); expe.More(); expe.Next()) ne++;
-    ne = ne/2;
-    if(ne<12)
+    for(expe.Init(aSolid, TopAbs_EDGE); expe.More(); expe.Next()) {
+      TopoDS_Edge E = TopoDS::Edge(expe.Current());
+      if(BRep_Tool::Degenerated(E)) {
+        if(!DegenEdges.Contains(E)) {
+          DegenEdges.Add(E);
+        }
+      }
+      else {
+        nbe++;
+      }
+    }
+    if( nbe==24 && DegenEdges.Extent()>0 ) {
+      IsBlock=Standard_False;
+      myNbDegen++;
+      myPossibleBlocks.Append(aSolid);
+      continue;
+    }
+    if(nbe<24)
       IsBlock=Standard_False;
-    if(ne>12) {
+    if(nbe>24) {
       IsBlock=Standard_False;
       // check edges unification
       // creating map of edge faces
@@ -141,13 +177,13 @@ void BlockFix_CheckTool::Perform()
             }
           }
         }
-        Standard_Integer i = 1;
-        for (; i <= aMapFacesEdges.Extent(); i++) {
+        Standard_Integer i=1;
+        for(; i<=aMapFacesEdges.Extent(); i++) {
           const TopTools_ListOfShape& ListEdges = aMapFacesEdges.FindFromIndex(i);
-          if (ListEdges.Extent() > 1) break;
+          if(ListEdges.Extent()>1) break;
         }
-        if (i <= aMapFacesEdges.Extent()) {
-          MayBeUE = Standard_True;
+        if(i<=aMapFacesEdges.Extent()) {
+          MayBeUE=Standard_True;
           break;
         }
       }
@@ -214,11 +250,11 @@ void BlockFix_CheckTool::DumpCheckResult(Standard_OStream& S) const
     S<<"  total number of solids = "<<myNbSolids<<endl;
     S<<"  including: number of good blocks = "<<myNbBlocks<<endl;
     S<<"             number of possible blocks = "<<NbPossibleBlocks()<<endl;
-    Standard_Integer nbtmp = myNbSolids - myNbBlocks - NbPossibleBlocks();
-    S<<"             number of impossible blocks = "<<nbtmp<<endl;
-    S<<"             including: need unionfaces = "<<myNbUF<<endl;
+    S<<"             including: need remove degenerative = "<<myNbDegen<<endl;
+    S<<"                        need unionfaces = "<<myNbUF<<endl;
     S<<"                        need unionedges = "<<myNbUE<<endl;
     S<<"                        need both unionfaces and unionedges = "<<myNbUFUE<<endl;
+    Standard_Integer nbtmp = myNbSolids - myNbBlocks - NbPossibleBlocks();
+    S<<"             number of impossible blocks = "<<nbtmp<<endl;
   }
 }
-