]> SALOME platform Git repositories - modules/geom.git/blobdiff - src/GEOMImpl/GEOMImpl_HealingDriver.cxx
Salome HOME
Merge branch 'master' of https://git.salome-platform.org/git/modules/geom
[modules/geom.git] / src / GEOMImpl / GEOMImpl_HealingDriver.cxx
index 644b8a835e4d51f754ceac6d93a77a738e843e90..966cd0334af5a9891bce8d47b768ea0781bdccff 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007-2013  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2014  CEA/DEN, EDF R&D, OPEN CASCADE
 //
 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
@@ -6,7 +6,7 @@
 // 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.
+// version 2.1 of the License, or (at your option) any later version.
 //
 // This library is distributed in the hope that it will be useful,
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -20,8 +20,6 @@
 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
 
-#include <Standard_Stream.hxx>
-
 #include <GEOMImpl_HealingDriver.hxx>
 #include <GEOMImpl_Types.hxx>
 #include <GEOMImpl_IHealing.hxx>
 
 #include <TNaming_CopyShape.hxx>
 
-#include <ShapeFix_ShapeTolerance.hxx>
-#include <ShapeFix_Shape.hxx>
-
 #include <BRep_Builder.hxx>
 #include <BRepAdaptor_Curve.hxx>
-#include <BRepCheck_Analyzer.hxx>
 #include <BRepTools_WireExplorer.hxx>
 
 #include <TopExp.hxx>
@@ -458,18 +452,21 @@ Standard_Boolean GEOMImpl_HealingDriver::RemoveInternalFaces (const TopoDS_Shape
   aTool.SetShape(theOriginalShape);
   aTool.Perform();
 
-  if (aTool.ErrorStatus() != 0)
-    StdFail_NotDone::Raise("GEOMAlgo_RemoverWebs failed!");
-
-  theOutShape = aTool.Result();
+  if (aTool.ErrorStatus() == 0) { // OK
+    theOutShape = aTool.Result();
 
-  // as GEOMAlgo_RemoverWebs always produces compound, lets simplify it
-  // for the case, if it contains only one sub-shape
-  TopTools_ListOfShape listShapeRes;
-  GEOMUtils::AddSimpleShapes(theOutShape, listShapeRes);
-  if (listShapeRes.Extent() == 1) {
-    theOutShape = listShapeRes.First();
+    // as GEOMAlgo_RemoverWebs always produces compound, lets simplify it
+    // for the case, if it contains only one sub-shape
+    TopTools_ListOfShape listShapeRes;
+    GEOMUtils::AddSimpleShapes(theOutShape, listShapeRes);
+    if (listShapeRes.Extent() == 1) {
+      theOutShape = listShapeRes.First();
+    }
   }
+  else if (aTool.ErrorStatus() == 11) // invalid argument (contains non-solids), do nothing
+    theOutShape = theOriginalShape;
+  else // error
+    StdFail_NotDone::Raise("GEOMAlgo_RemoverWebs failed!");
 
   return Standard_True;
 }
@@ -538,6 +535,8 @@ void GEOMImpl_HealingDriver::LimitTolerance (GEOMImpl_IHealing* theHI,
                                              TopoDS_Shape& theOutShape) const
 {
   Standard_Real aTol = theHI->GetTolerance();
+  TopAbs_ShapeEnum aType = theHI->GetType();
+
   if (aTol < Precision::Confusion())
     aTol = Precision::Confusion();
 
@@ -547,17 +546,10 @@ void GEOMImpl_HealingDriver::LimitTolerance (GEOMImpl_IHealing* theHI,
   TNaming_CopyShape::CopyTool(theOriginalShape, aMapTShapes, aShapeCopy);
 
   // 2. Limit tolerance.
-  ShapeFix_ShapeTolerance aSFT;
-  aSFT.LimitTolerance(aShapeCopy, aTol, aTol, TopAbs_SHAPE);
-
-  // 3. Fix obtained shape.
-  Handle(ShapeFix_Shape) aSfs = new ShapeFix_Shape (aShapeCopy);
-  aSfs->Perform();
-  theOutShape = aSfs->Shape();
-
-  BRepCheck_Analyzer ana (theOutShape, Standard_True);
-  if (!ana.IsValid())
+  if (!GEOMUtils::FixShapeTolerance(aShapeCopy, aType, aTol))
     StdFail_NotDone::Raise("Non valid shape result");
+
+  theOutShape = aShapeCopy;
 }
 
 //=======================================================================
@@ -732,8 +724,7 @@ void GEOMImpl_HealingDriver::FuseCollinearEdges (const TopoDS_Shape& theOriginal
   }
   theOutShape = aFinalWire;
 
-  BRepCheck_Analyzer ana (theOutShape, Standard_True);
-  if (!ana.IsValid())
+  if (!GEOMUtils::CheckShape(theOutShape, true))
     StdFail_NotDone::Raise("Non valid shape result");
 }
 
@@ -899,12 +890,17 @@ GetCreationInformation(std::string&             theOperationName,
     theOperationName = "LIMIT_TOLERANCE";
     AddParam( theParams, "Selected shape", aCI.GetOriginal() );
     AddParam( theParams, "Tolerance", aCI.GetTolerance() );
+    AddParam( theParams, "Type", aCI.GetType() );
     break;
   case FUSE_COLLINEAR_EDGES:
     theOperationName = "FUSE_EDGES";
     AddParam( theParams, "Wire", aCI.GetOriginal() );
     AddParam( theParams, "Vertexes", aCI.GetShapes() );
     break;
+  case REMOVE_INTERNAL_FACES:
+    theOperationName = "REMOVE_WEBS";
+    AddParam( theParams, "Selected shape", aCI.GetOriginal() );
+    break;
   default:
     return false;
   }