Salome HOME
Issue #1922: After partition, some edges are not displayed below the connected shape...
[modules/shaper.git] / src / GeomAlgoAPI / GeomAlgoAPI_Rotation.cpp
index 1d1d8495971a03daf71238b9c369c11c488df01c..c5244788b8949eab1b51c3e828023111ce93e93e 100644 (file)
@@ -4,33 +4,22 @@
 // Created:     12 May 2015
 // Author:      Dmitry Bobylev
 
-#include <GeomAlgoAPI_Rotation.h>
-
-#include <GeomAlgoAPI_ShapeProps.h>
+#include "GeomAlgoAPI_Rotation.h"
 
 #include <BRepBuilderAPI_Transform.hxx>
-#include <BRepCheck_Analyzer.hxx>
-#include <Precision.hxx>
-#include <TopExp_Explorer.hxx>
 
 //=================================================================================================
 GeomAlgoAPI_Rotation::GeomAlgoAPI_Rotation(std::shared_ptr<GeomAPI_Shape> theSourceShape,
                                            std::shared_ptr<GeomAPI_Ax1>   theAxis,
-                                           double                         theAngle,
-                                           bool theSimpleTransform)
-: myDone(false),
-  myShape(new GeomAPI_Shape()),
-  myMap(new GeomAPI_DataMapOfShapeShape()),
-  myMkShape(new GeomAlgoAPI_MakeShape())
+                                           double                         theAngle)
 {
-  build(theSourceShape, theAxis, theAngle, theSimpleTransform);
+  build(theSourceShape, theAxis, theAngle);
 }
 
 //=================================================================================================
 void GeomAlgoAPI_Rotation::build(std::shared_ptr<GeomAPI_Shape> theSourceShape,
                                  std::shared_ptr<GeomAPI_Ax1>   theAxis,
-                                 double                         theAngle,
-                                 bool theSimpleTransform)
+                                 double                         theAngle)
 {
   if(!theSourceShape || !theAxis) {
     return;
@@ -43,78 +32,24 @@ void GeomAlgoAPI_Rotation::build(std::shared_ptr<GeomAPI_Shape> theSourceShape,
     return;
   }
 
-  gp_Trsf aTrsf;
-  aTrsf.SetRotation(anAxis, theAngle / 180.0 * M_PI);
+  gp_Trsf* aTrsf = new gp_Trsf();
+  aTrsf->SetRotation(anAxis, theAngle / 180.0 * M_PI);
 
-  TopoDS_Shape aResult;
   // Transform the shape with copying it.
-  if (theSimpleTransform) {
-    TopLoc_Location aDelta(aTrsf);
-    aResult = aSourceShape.Moved(aDelta);
-    myTrsf = std::shared_ptr<GeomAPI_Trsf>(new GeomAPI_Trsf(new gp_Trsf(aTrsf * aSourceShape.Location().Transformation())));
-    myDone = true; // is OK for sure
-  } else {
-    BRepBuilderAPI_Transform* aBuilder = new BRepBuilderAPI_Transform(aSourceShape, aTrsf, true);
-    if(!aBuilder) {
-      return;
-    }
-
-    myDone = aBuilder->IsDone() == Standard_True;
-
-    if(!myDone) {
-      return;
-    }
-
-    aResult = aBuilder->Shape();
-    // Fill data map to keep correct orientation of sub-shapes.
-    for(TopExp_Explorer anExp(aResult, TopAbs_FACE); anExp.More(); anExp.Next()) {
-      std::shared_ptr<GeomAPI_Shape> aCurrentShape(new GeomAPI_Shape());
-      aCurrentShape->setImpl(new TopoDS_Shape(anExp.Current()));
-      myMap->bind(aCurrentShape, aCurrentShape);
-    }
-    myMkShape->setImpl(aBuilder);
+  BRepBuilderAPI_Transform* aBuilder = new BRepBuilderAPI_Transform(aSourceShape, *aTrsf, true);
+  if(!aBuilder) {
+    return;
   }
+  this->setImpl(aBuilder);
+  this->setBuilderType(OCCT_BRepBuilderAPI_MakeShape);
 
-  myShape->setImpl(new TopoDS_Shape(aResult));
-}
-
-//=================================================================================================
-const bool GeomAlgoAPI_Rotation::isValid() const
-{
-  BRepCheck_Analyzer aChecker(myShape->impl<TopoDS_Shape>());
-  return (aChecker.IsValid() == Standard_True);
-}
-
-//=================================================================================================
-const bool GeomAlgoAPI_Rotation::hasVolume() const
-{
-  bool hasVolume(false);
-  if(isValid() && (GeomAlgoAPI_ShapeProps::volume(myShape) > Precision::Confusion())) {
-    hasVolume = true;
+  if(aBuilder->IsDone() != Standard_True) {
+    return;
   }
-  return hasVolume;
-}
+  TopoDS_Shape aResult = aBuilder->Shape();
 
-//=================================================================================================
-const std::shared_ptr<GeomAPI_Shape>& GeomAlgoAPI_Rotation::shape() const
-{
-  return myShape;
-}
-
-//=================================================================================================
-std::shared_ptr<GeomAPI_DataMapOfShapeShape> GeomAlgoAPI_Rotation::mapOfShapes() const
-{
-  return myMap;
-}
-
-//=================================================================================================
-std::shared_ptr<GeomAlgoAPI_MakeShape> GeomAlgoAPI_Rotation::makeShape() const
-{
-  return myMkShape;
-}
-
-//=================================================================================================
-std::shared_ptr<GeomAPI_Trsf> GeomAlgoAPI_Rotation::transformation() const
-{
-  return myTrsf;
+  std::shared_ptr<GeomAPI_Shape> aShape(new GeomAPI_Shape());
+  aShape->setImpl(new TopoDS_Shape(aResult));
+  this->setShape(aShape);
+  this->setDone(true);
 }