Salome HOME
Partition naming
[modules/shaper.git] / src / GeomAlgoAPI / GeomAlgoAPI_Rotation.cpp
index 21815311070d170e47f4c714519a95895bfec868..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>
 //=================================================================================================
 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)
+: myDone(false)
 {
-  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,37 +38,33 @@ 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));
 
-  TopoDS_Shape aResult;
   // Transform the shape with copying it.
-  if (theSimpleTransform) {
-    TopLoc_Location aDelta(aTrsf);
-    aResult = aSourceShape.Moved(aDelta);
-    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;
+  }
+  myMkShape.reset(new GeomAlgoAPI_MakeShape(aBuilder));
+
+  myDone = aBuilder->IsDone() == Standard_True;
+
+  if(!myDone) {
+    return;
   }
 
+  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);
+  }
+
+  myShape.reset(new GeomAPI_Shape());
   myShape->setImpl(new TopoDS_Shape(aResult));
 }
 
@@ -88,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;
@@ -111,3 +102,9 @@ std::shared_ptr<GeomAlgoAPI_MakeShape> GeomAlgoAPI_Rotation::makeShape() const
 {
   return myMkShape;
 }
+
+//=================================================================================================
+std::shared_ptr<GeomAPI_Trsf> GeomAlgoAPI_Rotation::transformation() const
+{
+  return myTrsf;
+}