Salome HOME
Changes for bug 0019761 from Mantis.
[modules/geom.git] / src / GEOMImpl / GEOMImpl_BlockDriver.cxx
index 9e2d85745ca0a232b91ab60e3eadf496bba7f544..873b0a751f3c3c5539f0fee45cef0cd322b63560 100644 (file)
@@ -34,7 +34,8 @@
 #include <GEOM_Function.hxx>
 
 #include <ShHealOper_Sewing.hxx>
-#include <NMTAlgo_Splitter1.hxx>
+#include <ShHealOper_ShapeProcess.hxx>
+#include <GEOMAlgo_Gluer.hxx>
 #include <BlockFix_BlockFixAPI.hxx>
 
 #include "utilities.h"
@@ -52,6 +53,7 @@
 #include <BRepBuilderAPI_MakeWire.hxx>
 #include <BRepBuilderAPI_MakePolygon.hxx>
 #include <BRepBuilderAPI_Transform.hxx>
+#include <BRepCheck_Analyzer.hxx>
 #include <BRepClass_FaceClassifier.hxx>
 #include <BRepClass3d_SolidClassifier.hxx>
 #include <BRepExtrema_ExtPF.hxx>
@@ -470,14 +472,21 @@ Standard_Integer GEOMImpl_BlockDriver::Execute(TFunction_Logbook& log) const
       TopoDS_Shape aCompound = anArgs(1);
 
       // Glue coincident faces and edges (with Partition algorithm).
-      NMTAlgo_Splitter1 PS;
-      PS.AddShape(aCompound);
-      PS.Compute();
-      PS.SetRemoveWebs(Standard_False);
-//      PS.Build(aCompound.ShapeType());
-      PS.Build(TopAbs_SOLID);
-
-      aShape = PS.Shape();
+      //NMTAlgo_Splitter1 PS;
+      //PS.AddShape(aCompound);
+      //PS.Compute();
+      //PS.SetRemoveWebs(Standard_False);
+      //      PS.Build(aCompound.ShapeType());
+      //PS.Build(TopAbs_SOLID);
+      //aShape = PS.Shape();
+
+      GEOMAlgo_Gluer aGluer;
+      aGluer.SetShape(aCompound);
+      aGluer.SetCheckGeometry(Standard_True);
+      aGluer.Perform();
+      aShape = aGluer.Result();
+
+
     } else {
     }
 
@@ -499,17 +508,28 @@ Standard_Integer GEOMImpl_BlockDriver::Execute(TFunction_Logbook& log) const
       aTool.SetShape(aBlockOrComp);
       aTool.Perform();
 
-      if (aType == BLOCK_REMOVE_EXTRA) {
+      TopoDS_Shape aFixedExtra = aTool.Shape();
+
+      // Repair result
+      BRepCheck_Analyzer ana (aFixedExtra, false);
+      if (!ana.IsValid()) {
+        TopoDS_Shape aFixed;
+        ShHealOper_ShapeProcess aHealer;
+        aHealer.Perform(aFixedExtra, aFixed);
+        if (aHealer.isDone())
+          aFixedExtra = aFixed;
+      }
+
+      if (aType == BLOCK_REMOVE_EXTRA)
+      {
+        aShape = aFixedExtra;
 
-        aShape = aTool.Shape();
         if (aShape == aBlockOrComp) {
           MESSAGE("No modifications have been done");
         }
-
-      } else { // aType == BLOCK_COMPOUND_IMPROVE
-
-        TopoDS_Shape aFixedExtra = aTool.Shape();
-
+      }
+      else // aType == BLOCK_COMPOUND_IMPROVE
+      {
         // 2. Separate non-blocks
         TopTools_ListOfShape BLO; // All blocks from the given compound
         TopTools_ListOfShape NOT; // Not blocks
@@ -537,7 +557,7 @@ Standard_Integer GEOMImpl_BlockDriver::Execute(TFunction_Logbook& log) const
         }
 
         // 5. Glue Faces
-        aShape = GEOMImpl_GlueDriver::GlueFaces(aComp, Precision::Confusion());
+        aShape = GEOMImpl_GlueDriver::GlueFaces(aComp, Precision::Confusion(), Standard_False);
       }
 
     } else if (aType == BLOCK_MULTI_TRANSFORM_1D ||
@@ -643,7 +663,7 @@ Standard_Integer GEOMImpl_BlockDriver::Execute(TFunction_Logbook& log) const
       }
 
       // Glue faces of the multi-block
-      aShape = GEOMImpl_GlueDriver::GlueFaces(aMulti, aTol);
+      aShape = GEOMImpl_GlueDriver::GlueFaces(aMulti, aTol, Standard_False);
 
     } else { // unknown function type
       return 0;