Salome HOME
GeomAlgoAPI_Rotation now derived from GeomAlgoAPI_MakeShape
authordbv <dbv@opencascade.com>
Thu, 24 Dec 2015 07:50:39 +0000 (10:50 +0300)
committerdbv <dbv@opencascade.com>
Thu, 24 Dec 2015 07:57:27 +0000 (10:57 +0300)
src/FeaturesPlugin/FeaturesPlugin_Rotation.cpp
src/FeaturesPlugin/FeaturesPlugin_Rotation.h
src/GeomAlgoAPI/GeomAlgoAPI_Rotation.cpp
src/GeomAlgoAPI/GeomAlgoAPI_Rotation.h

index 422a4d3347c3648a1e55552c0b0ee9251f7aecc7..0423ac8afc8c7513376c8d50468bcb6c2f5fd31b 100755 (executable)
@@ -8,9 +8,7 @@
 
 #include <ModelAPI_AttributeDouble.h>
 #include <ModelAPI_AttributeSelectionList.h>
-#include <ModelAPI_BodyBuilder.h>
 #include <ModelAPI_ResultBody.h>
-#include <ModelAPI_Session.h>
 #include <ModelAPI_ResultPart.h>
 
 #include <GeomAPI_Edge.h>
@@ -108,7 +106,7 @@ void FeaturesPlugin_Rotation::execute()
       }
 
       ResultBodyPtr aResultBody = document()->createBody(data(), aResultIndex);
-      LoadNamingDS(aRotationAlgo, aResultBody, aBaseShape);
+      loadNamingDS(aRotationAlgo, aResultBody, aBaseShape);
       setResult(aResultBody, aResultIndex);
     }
     aResultIndex++;
@@ -118,19 +116,19 @@ void FeaturesPlugin_Rotation::execute()
   removeResults(aResultIndex);
 }
 
-void FeaturesPlugin_Rotation::LoadNamingDS(const GeomAlgoAPI_Rotation& theRotaionAlgo,
+void FeaturesPlugin_Rotation::loadNamingDS(GeomAlgoAPI_Rotation& theRotaionAlgo,
                                            std::shared_ptr<ModelAPI_ResultBody> theResultBody,
                                            std::shared_ptr<GeomAPI_Shape> theBaseShape)
 {
   // Store result.
   theResultBody->storeModified(theBaseShape, theRotaionAlgo.shape());
 
-  std::shared_ptr<GeomAPI_DataMapOfShapeShape> aSubShapes = theRotaionAlgo.mapOfShapes();
+  std::shared_ptr<GeomAPI_DataMapOfShapeShape> aSubShapes = theRotaionAlgo.mapOfSubShapes();
 
   int aRotatedTag = 1;
   std::string aRotatedName = "Rotated";
-  theResultBody->loadAndOrientModifiedShapes(theRotaionAlgo.makeShape().get(),
-                                              theBaseShape, GeomAPI_Shape::FACE,
-                                              aRotatedTag, aRotatedName, *aSubShapes.get());
+  theResultBody->loadAndOrientModifiedShapes(&theRotaionAlgo,
+                                             theBaseShape, GeomAPI_Shape::FACE,
+                                             aRotatedTag, aRotatedName, *aSubShapes.get());
 
 }
index 57316316603250344466403abca713cc1103d097..1326e7ac55f90488149e5328a2f5f770021d6fc3 100755 (executable)
 
 #include <GeomAlgoAPI_Rotation.h>
 
-/** \class FeaturesPlugin_Rotation
- *  \ingroup Plugins
- *  \brief Feature for rotation objects around the axis.
- */
+/// \class FeaturesPlugin_Rotation
+/// \ingroup Plugins
+/// \brief Feature for rotation objects around the axis.
 class FeaturesPlugin_Rotation : public ModelAPI_Feature
 {
  public:
@@ -65,7 +64,7 @@ class FeaturesPlugin_Rotation : public ModelAPI_Feature
   FeaturesPlugin_Rotation();
 
 private:
-  void LoadNamingDS(const GeomAlgoAPI_Rotation& theRotaionAlgo,
+  void loadNamingDS(GeomAlgoAPI_Rotation& theRotaionAlgo,
                     std::shared_ptr<ModelAPI_ResultBody> theResultBody,
                     std::shared_ptr<GeomAPI_Shape> theBaseShape);
 };
index 62e687d98dc9e5aea6e277d23ddd2836930d52df..c5244788b8949eab1b51c3e828023111ce93e93e 100644 (file)
@@ -4,20 +4,14 @@
 // Created:     12 May 2015
 // Author:      Dmitry Bobylev
 
-#include <GeomAlgoAPI_Rotation.h>
-
-#include <GeomAlgoAPI_ShapeTools.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)
-: myDone(false)
 {
   build(theSourceShape, theAxis, theAngle);
 }
@@ -40,71 +34,22 @@ void GeomAlgoAPI_Rotation::build(std::shared_ptr<GeomAPI_Shape> theSourceShape,
 
   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);
   if(!aBuilder) {
     return;
   }
-  myMkShape.reset(new GeomAlgoAPI_MakeShape(aBuilder));
-
-  myDone = aBuilder->IsDone() == Standard_True;
+  this->setImpl(aBuilder);
+  this->setBuilderType(OCCT_BRepBuilderAPI_MakeShape);
 
-  if(!myDone) {
+  if(aBuilder->IsDone() != Standard_True) {
     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));
-}
-
-//=================================================================================================
-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_ShapeTools::volume(myShape) > Precision::Confusion())) {
-    hasVolume = true;
-  }
-  return hasVolume;
-}
 
-//=================================================================================================
-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);
 }
index ef56c33eafc67e79573d515ea50d601c27eb87d6..48f922b04e90ffcac4913121c6bc6658b79e7f52 100644 (file)
@@ -9,62 +9,29 @@
 
 #include <GeomAlgoAPI.h>
 #include <GeomAlgoAPI_MakeShape.h>
+
 #include <GeomAPI_Ax1.h>
-#include <GeomAPI_DataMapOfShapeShape.h>
 #include <GeomAPI_Shape.h>
-#include <GeomAPI_Trsf.h>
 
-/** \class GeomAlgoAPI_Rotation
- *  \ingroup DataAlgo
- *  \brief Creates a copy of the object by rotating it around the axis.
- */
-class GeomAlgoAPI_Rotation : public GeomAPI_Interface
+/// \class GeomAlgoAPI_Rotation
+/// \ingroup DataAlgo
+/// \brief Creates a copy of the object by rotating it around the axis.
+class GeomAlgoAPI_Rotation : public GeomAlgoAPI_MakeShape
 {
 public:
-  /** \brief Creates an object which is obtained from current object by rotating it around the axis.
-   *  \param[in] theSourceShape  a shape to be rotated.
-   *  \param[in] theAxis         rotation axis.
-   *  \param[in] theAngle        rotation angle(in degree).
-   */
+  /// \brief Creates an object which is obtained from current object by rotating it around the axis.
+  /// \param[in] theSourceShape  a shape to be rotated.
+  /// \param[in] theAxis         rotation axis.
+  /// \param[in] theAngle        rotation angle(in degree).
   GEOMALGOAPI_EXPORT GeomAlgoAPI_Rotation(std::shared_ptr<GeomAPI_Shape> theSourceShape,
                                           std::shared_ptr<GeomAPI_Ax1>   theAxis,
                                           double                         theAngle);
 
-  /// \return true if algorithm succeed.
-  GEOMALGOAPI_EXPORT const bool isDone() const
-  { return myDone; }
-
-  /// \return true if resulting shape is valid.
-  GEOMALGOAPI_EXPORT const bool isValid() const;
-
-  /// \return true if resulting shape has volume.
-  GEOMALGOAPI_EXPORT const bool hasVolume() const;
-
-  /// \return result of the rotation algorithm.
-  GEOMALGOAPI_EXPORT const std::shared_ptr<GeomAPI_Shape>& shape() const;
-
-  /// \return map of sub-shapes of the result. To be used for History keeping.
-  GEOMALGOAPI_EXPORT std::shared_ptr<GeomAPI_DataMapOfShapeShape> mapOfShapes() const;
-
-  /// \return interface for for History processing.
-  GEOMALGOAPI_EXPORT std::shared_ptr<GeomAlgoAPI_MakeShape> makeShape() const;
-
-  /// Returns the simple transformation
-  GEOMALGOAPI_EXPORT std::shared_ptr<GeomAPI_Trsf> transformation() const;
-
 private:
   /// Builds resulting shape.
   void build(std::shared_ptr<GeomAPI_Shape> theSourceShape,
              std::shared_ptr<GeomAPI_Ax1>   theAxis,
              double                         theAngle);
-
-private:
-  /// Fields.
-  bool myDone;
-  std::shared_ptr<GeomAPI_Shape> myShape;
-  std::shared_ptr<GeomAPI_DataMapOfShapeShape> myMap;
-  std::shared_ptr<GeomAlgoAPI_MakeShape> myMkShape;
-  std::shared_ptr<GeomAPI_Trsf> myTrsf; ///< transformation of the shape in case theSimpleTransform
 };
 
 #endif