Salome HOME
Mantis issue 0020998: EDF 1572 GEOM: Some limitations to the PipeTShape.
[modules/geom.git] / src / GEOMImpl / GEOMImpl_BooleanDriver.cxx
index bf82f5136a13d1b932d71beaa4b533e6c9abf4ef..d311b0dcec72ca420b10ac2454487947cc151cc4 100644 (file)
@@ -1,4 +1,4 @@
-//  Copyright (C) 2007-2008  CEA/DEN, EDF R&D, OPEN CASCADE
+//  Copyright (C) 2007-2010  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
@@ -19,6 +19,7 @@
 //
 //  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
+
 #include <GEOMImpl_BooleanDriver.hxx>
 #include <GEOMImpl_IBoolean.hxx>
 #include <GEOMImpl_Types.hxx>
@@ -56,7 +57,6 @@ const Standard_GUID& GEOMImpl_BooleanDriver::GetID()
   return aBooleanDriver;
 }
 
-
 //=======================================================================
 //function : GEOMImpl_BooleanDriver
 //purpose  :
@@ -410,6 +410,15 @@ Standard_Integer GEOMImpl_BooleanDriver::Execute(TFunction_Logbook& log) const
 
   if (aShape.IsNull()) return 0;
 
+  // as boolean operations always produce compound, lets simplify it
+  // for the case, if it contans only one sub-shape
+  TopTools_ListOfShape listShapeRes;
+  AddSimpleShapes(aShape, listShapeRes);
+  if (listShapeRes.Extent() == 1) {
+    aShape = listShapeRes.First();
+    if (aShape.IsNull()) return 0;
+  }
+
   // 08.07.2008 skl for bug 19761 from Mantis
   BRepCheck_Analyzer ana (aShape, Standard_True);
   ana.Init(aShape);
@@ -428,6 +437,16 @@ Standard_Integer GEOMImpl_BooleanDriver::Execute(TFunction_Logbook& log) const
   //  Standard_ConstructionError::Raise("Boolean operation aborted : non valid shape result");
   //}
 
+  //Alternative case to check shape result Mantis 0020604: EDF 1172
+/*  TopoDS_Iterator It (aShape, Standard_True, Standard_True);
+  int nbSubshapes=0;
+  for (; It.More(); It.Next())
+    nbSubshapes++;
+  if (!nbSubshapes)
+    Standard_ConstructionError::Raise("Boolean operation aborted : result object is empty compound");*/
+  //end of 0020604: EDF 1172
+  //! the changes temporary commented because of customer needs (see the same mantis bug)
+
   aFunction->SetValue(aShape);
 
   log.SetTouched(Label());
@@ -453,10 +472,10 @@ Standard_EXPORT Handle_Standard_Type& GEOMImpl_BooleanDriver_Type_()
 
   static Handle_Standard_Transient _Ancestors[]= {aType1,aType2,aType3,NULL};
   static Handle_Standard_Type _aType = new Standard_Type("GEOMImpl_BooleanDriver",
-                                                        sizeof(GEOMImpl_BooleanDriver),
-                                                        1,
-                                                        (Standard_Address)_Ancestors,
-                                                        (Standard_Address)NULL);
+                                                         sizeof(GEOMImpl_BooleanDriver),
+                                                         1,
+                                                         (Standard_Address)_Ancestors,
+                                                         (Standard_Address)NULL);
 
   return _aType;
 }