Salome HOME
Issue #1482: Fixed results of Extrusion, Revolution, Pipe and Partition. If it is...
authordbv <dbv@opencascade.com>
Thu, 5 May 2016 08:53:48 +0000 (11:53 +0300)
committerdbv <dbv@opencascade.com>
Thu, 5 May 2016 08:53:48 +0000 (11:53 +0300)
src/GeomAlgoAPI/GeomAlgoAPI_DFLoader.cpp
src/GeomAlgoAPI/GeomAlgoAPI_Partition.cpp
src/GeomAlgoAPI/GeomAlgoAPI_Pipe.cpp
src/GeomAlgoAPI/GeomAlgoAPI_Prism.cpp
src/GeomAlgoAPI/GeomAlgoAPI_Revolution.cpp

index 61e28412aab9d44a70420e17db223e8cee585566..289db4f28cc077d32dbccd8a57c54e82dc00905b 100644 (file)
 //function : refineResult
 //purpose  :
 //=======================================================================
-const TopoDS_Shape GeomAlgoAPI_DFLoader::refineResult(const  TopoDS_Shape& theResult)
+const TopoDS_Shape GeomAlgoAPI_DFLoader::refineResult(const TopoDS_Shape& theResult)
 {
-  TopoDS_Shape aResult;
-  if (theResult.ShapeType() == TopAbs_COMPOUND) {
-    Standard_Integer nbSubResults = 0;
-    TopoDS_Iterator itr(theResult);
-    for (; itr.More(); itr.Next()) nbSubResults++;
-    if (nbSubResults == 1) {
-      itr.Initialize(theResult);
-      if (itr.More()) aResult = itr.Value();
-    } else {
-      /// MPV: store compound anyway: it may be Boolean operation that produces two solids from one
-      aResult = theResult;
+  TopoDS_Shape aResult = theResult;
+  const TopAbs_ShapeEnum aShType = theResult.ShapeType();
+  if(aShType == TopAbs_COMPOUND || aShType == TopAbs_SHELL || aShType == TopAbs_WIRE) {
+    Standard_Integer aSubResultsNb = 0;
+    TopoDS_Iterator anIt(theResult);
+    for(; anIt.More(); anIt.Next()) {
+      ++aSubResultsNb;
+    }
+    if(aSubResultsNb == 1) {
+      anIt.Initialize(theResult);
+      if(anIt.More()) {
+        aResult = anIt.Value();
+      }
     }
   }
+
   return aResult;
 }
index 63a1ddc9e4b87a9cf3aaa7a27e72e73f30518ebe..55455220c3f2ecc2120d056c719c777e581fd56c 100644 (file)
@@ -89,6 +89,11 @@ void GeomAlgoAPI_Partition::build(const ListOfShape& theObjects,
     }
   }
 
+  // Setting result.
+  if(aResult.IsNull()) {
+    return;
+  }
+  aResult = GeomAlgoAPI_DFLoader::refineResult(aResult);
   std::shared_ptr<GeomAPI_Shape> aShape(new GeomAPI_Shape());
   aShape->setImpl(new TopoDS_Shape(aResult));
   this->setShape(aShape);
index 612df97c2bb9f63d52698f29bfc20b73d937caba..c24a9600e785d820670c89c942a6752f1e39a2dc 100644 (file)
@@ -6,6 +6,8 @@
 
 #include "GeomAlgoAPI_Pipe.h"
 
+#include "GeomAlgoAPI_DFLoader.h"
+
 #include <GeomAPI_Dir.h>
 #include <GeomAPI_Edge.h>
 #include <GeomAPI_Lin.h>
@@ -99,10 +101,11 @@ void GeomAlgoAPI_Pipe::build(const GeomShapePtr theBaseShape,
   this->addToShape(aToShape);
 
   // Setting result.
-  TopoDS_Shape aResultShape = aPipeBuilder->Shape();
-  GeomShapePtr aResultGeomShape(new GeomAPI_Shape());
-  aResultGeomShape->setImpl(new TopoDS_Shape(aResultShape));
-  this->setShape(aResultGeomShape);
+  TopoDS_Shape aResult = aPipeBuilder->Shape();
+  aResult = GeomAlgoAPI_DFLoader::refineResult(aResult);
+  GeomShapePtr aGeomSh(new GeomAPI_Shape());
+  aGeomSh->setImpl(new TopoDS_Shape(aResult));
+  this->setShape(aGeomSh);
   this->setDone(true);
 }
 
@@ -160,9 +163,7 @@ void GeomAlgoAPI_Pipe::build(const GeomShapePtr theBaseShape,
       return;
     }
   }
-  if(aPipeBuilder->Shape().IsNull()) {
-    return;
-  }
+  TopoDS_Shape aResult = aPipeBuilder->Shape();
 
   // Setting naming.
   GeomShapePtr aFromShape(new GeomAPI_Shape), aToShape(new GeomAPI_Shape);
@@ -172,10 +173,13 @@ void GeomAlgoAPI_Pipe::build(const GeomShapePtr theBaseShape,
   this->addToShape(aToShape);
 
   // Setting result.
-  TopoDS_Shape aResultShape = aPipeBuilder->Shape();
-  GeomShapePtr aResultGeomShape(new GeomAPI_Shape());
-  aResultGeomShape->setImpl(new TopoDS_Shape(aResultShape));
-  this->setShape(aResultGeomShape);
+  if(aResult.IsNull()) {
+    return;
+  }
+  aResult = GeomAlgoAPI_DFLoader::refineResult(aResult);
+  GeomShapePtr aGeomSh(new GeomAPI_Shape());
+  aGeomSh->setImpl(new TopoDS_Shape(aResult));
+  this->setShape(aGeomSh);
   this->setDone(true);
 }
 
@@ -251,9 +255,7 @@ void GeomAlgoAPI_Pipe::build(const ListOfShape& theBaseShapes,
       return;
     }
   }
-  if(aPipeBuilder->Shape().IsNull()) {
-    return;
-  }
+  TopoDS_Shape aResult = aPipeBuilder->Shape();
 
   // Setting naming.
   GeomShapePtr aFromShape(new GeomAPI_Shape), aToShape(new GeomAPI_Shape);
@@ -263,10 +265,13 @@ void GeomAlgoAPI_Pipe::build(const ListOfShape& theBaseShapes,
   this->addToShape(aToShape);
 
   // Setting result.
-  TopoDS_Shape aResultShape = aPipeBuilder->Shape();
-  GeomShapePtr aResultGeomShape(new GeomAPI_Shape());
-  aResultGeomShape->setImpl(new TopoDS_Shape(aResultShape));
-  this->setShape(aResultGeomShape);
+  if(aResult.IsNull()) {
+    return;
+  }
+  aResult = GeomAlgoAPI_DFLoader::refineResult(aResult);
+  GeomShapePtr aGeomSh(new GeomAPI_Shape());
+  aGeomSh->setImpl(new TopoDS_Shape(aResult));
+  this->setShape(aGeomSh);
   this->setDone(true);
 }
 
index 2829bff0a6fffd7984eb489f3744da2176f57514..7f2bd0b49e97e2742956682f097b0c32d4e4306b 100644 (file)
@@ -442,6 +442,7 @@ void GeomAlgoAPI_Prism::build(const GeomShapePtr&                theBaseShape,
   if(aResult.IsNull()) {
     return;
   }
+  aResult = GeomAlgoAPI_DFLoader::refineResult(aResult);
   GeomShapePtr aGeomSh(new GeomAPI_Shape());
   aGeomSh->setImpl(new TopoDS_Shape(aResult));
   this->setShape(aGeomSh);
index 92e5924eaec1a813a4b6a8480558af7fe54a29ae..889cce3525eb00c6d3c9969290bcdd043349b5b2 100644 (file)
@@ -549,6 +549,7 @@ void GeomAlgoAPI_Revolution::build(const GeomShapePtr&                 theBaseSh
   if(aResult.IsNull()) {
     return;
   }
+  aResult = GeomAlgoAPI_DFLoader::refineResult(aResult);
   GeomShapePtr aShape(new GeomAPI_Shape());
   aShape->setImpl(new TopoDS_Shape(aResult));
   this->setShape(aShape);