Salome HOME
Issue #1084: parameter cyclic dependence
[modules/shaper.git] / src / GeomAlgoAPI / GeomAlgoAPI_Rotation.cpp
index f165e5aa829efb4b484528408610e9266418b905..62e687d98dc9e5aea6e277d23ddd2836930d52df 100644 (file)
@@ -6,7 +6,7 @@
 
 #include <GeomAlgoAPI_Rotation.h>
 
-#include <GeomAlgoAPI_ShapeProps.h>
+#include <GeomAlgoAPI_ShapeTools.h>
 
 #include <BRepBuilderAPI_Transform.hxx>
 #include <BRepCheck_Analyzer.hxx>
@@ -17,8 +17,7 @@
 GeomAlgoAPI_Rotation::GeomAlgoAPI_Rotation(std::shared_ptr<GeomAPI_Shape> theSourceShape,
                                            std::shared_ptr<GeomAPI_Ax1>   theAxis,
                                            double                         theAngle)
-: myDone(false),
-  myShape(new GeomAPI_Shape())
+: myDone(false)
 {
   build(theSourceShape, theAxis, theAngle);
 }
@@ -39,16 +38,17 @@ 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);
+  myTrsf.reset(new GeomAPI_Trsf(aTrsf));
 
   // Transform the shape with copying it.
-  BRepBuilderAPI_Transform* aBuilder = new BRepBuilderAPI_Transform(aSourceShape, aTrsf, true);
+  BRepBuilderAPI_Transform* aBuilder = new BRepBuilderAPI_Transform(aSourceShape, *aTrsf, true);
   if(!aBuilder) {
     return;
   }
+  myMkShape.reset(new GeomAlgoAPI_MakeShape(aBuilder));
 
-  setImpl(aBuilder);
   myDone = aBuilder->IsDone() == Standard_True;
 
   if(!myDone) {
@@ -57,14 +57,15 @@ void GeomAlgoAPI_Rotation::build(std::shared_ptr<GeomAPI_Shape> theSourceShape,
 
   TopoDS_Shape aResult = aBuilder->Shape();
   // Fill data map to keep correct orientation of sub-shapes.
+  myMap.reset(new GeomAPI_DataMapOfShapeShape());
   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);
+    myMap->bind(aCurrentShape, aCurrentShape);
   }
 
+  myShape.reset(new GeomAPI_Shape());
   myShape->setImpl(new TopoDS_Shape(aResult));
-  myMkShape = new GeomAlgoAPI_MakeShape(aBuilder);
 }
 
 //=================================================================================================
@@ -78,7 +79,7 @@ const bool GeomAlgoAPI_Rotation::isValid() const
 const bool GeomAlgoAPI_Rotation::hasVolume() const
 {
   bool hasVolume(false);
-  if(isValid() && (GeomAlgoAPI_ShapeProps::volume(myShape) > Precision::Confusion())) {
+  if(isValid() && (GeomAlgoAPI_ShapeTools::volume(myShape) > Precision::Confusion())) {
     hasVolume = true;
   }
   return hasVolume;
@@ -91,21 +92,19 @@ const std::shared_ptr<GeomAPI_Shape>& GeomAlgoAPI_Rotation::shape() const
 }
 
 //=================================================================================================
-void GeomAlgoAPI_Rotation::mapOfShapes(GeomAPI_DataMapOfShapeShape& theMap) const
+std::shared_ptr<GeomAPI_DataMapOfShapeShape> GeomAlgoAPI_Rotation::mapOfShapes() const
 {
-  theMap = myMap;
+  return myMap;
 }
 
 //=================================================================================================
-GeomAlgoAPI_MakeShape* GeomAlgoAPI_Rotation::makeShape() const
+std::shared_ptr<GeomAlgoAPI_MakeShape> GeomAlgoAPI_Rotation::makeShape() const
 {
   return myMkShape;
 }
 
 //=================================================================================================
-GeomAlgoAPI_Rotation::~GeomAlgoAPI_Rotation()
+std::shared_ptr<GeomAPI_Trsf> GeomAlgoAPI_Rotation::transformation() const
 {
-  if (myImpl) {
-    myMap.clear();
-  }
+  return myTrsf;
 }