]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
GeomAlgoAPI_Translation now derived from GeomAlgoAPI_MakeShape
authordbv <dbv@opencascade.com>
Thu, 24 Dec 2015 07:50:58 +0000 (10:50 +0300)
committerdbv <dbv@opencascade.com>
Thu, 24 Dec 2015 07:57:28 +0000 (10:57 +0300)
src/FeaturesPlugin/FeaturesPlugin_Translation.cpp
src/FeaturesPlugin/FeaturesPlugin_Translation.h
src/GeomAlgoAPI/GeomAlgoAPI_Translation.cpp
src/GeomAlgoAPI/GeomAlgoAPI_Translation.h

index c55d23d818391355b24abc3609adda4dec98f075..41a93ddba767bfc57799a41b1967e4a253ee333c 100644 (file)
@@ -89,27 +89,27 @@ void FeaturesPlugin_Translation::execute()
       aResultPart->setTrsf(*aContext, aTrsf);
       setResult(aResultPart);
     } else {
-      GeomAlgoAPI_Translation aMovementAlgo(aBaseShape, anAxis, aDistance);
+      GeomAlgoAPI_Translation aTranslationAlgo(aBaseShape, anAxis, aDistance);
 
       // Checking that the algorithm worked properly.
-      if(!aMovementAlgo.isDone()) {
-        static const std::string aFeatureError = "Movement algorithm failed";
+      if(!aTranslationAlgo.isDone()) {
+        static const std::string aFeatureError = "Translation algorithm failed";
         setError(aFeatureError);
         break;
       }
-      if(aMovementAlgo.shape()->isNull()) {
+      if(aTranslationAlgo.shape()->isNull()) {
         static const std::string aShapeError = "Resulting shape is Null";
         setError(aShapeError);
         break;
       }
-      if(!aMovementAlgo.isValid()) {
+      if(!aTranslationAlgo.isValid()) {
         std::string aFeatureError = "Warning: resulting shape is not valid";
         setError(aFeatureError);
         break;
       }
 
       ResultBodyPtr aResultBody = document()->createBody(data(), aResultIndex);
-      LoadNamingDS(aMovementAlgo, aResultBody, aBaseShape);
+      loadNamingDS(aTranslationAlgo, aResultBody, aBaseShape);
       setResult(aResultBody, aResultIndex);
     }
     aResultIndex++;
@@ -119,19 +119,19 @@ void FeaturesPlugin_Translation::execute()
   removeResults(aResultIndex);
 }
 
-void FeaturesPlugin_Translation::LoadNamingDS(const GeomAlgoAPI_Translation& theMovementAlgo,
-                                           std::shared_ptr<ModelAPI_ResultBody> theResultBody,
-                                           std::shared_ptr<GeomAPI_Shape> theBaseShape)
+void FeaturesPlugin_Translation::loadNamingDS(GeomAlgoAPI_Translation& theTranslationAlgo,
+                                              std::shared_ptr<ModelAPI_ResultBody> theResultBody,
+                                              std::shared_ptr<GeomAPI_Shape> theBaseShape)
 {
   // Store result.
-  theResultBody->storeModified(theBaseShape, theMovementAlgo.shape());
+  theResultBody->storeModified(theBaseShape, theTranslationAlgo.shape());
 
-  std::shared_ptr<GeomAPI_DataMapOfShapeShape> aSubShapes = theMovementAlgo.mapOfShapes();
+  std::shared_ptr<GeomAPI_DataMapOfShapeShape> aSubShapes = theTranslationAlgo.mapOfSubShapes();
 
-  int aMovedTag = 1;
-  std::string aMovedName = "Moved";
-  theResultBody->loadAndOrientModifiedShapes(theMovementAlgo.makeShape().get(),
-                                              theBaseShape, GeomAPI_Shape::FACE,
-                                              aMovedTag, aMovedName, *aSubShapes.get());
+  int aTranslatedTag = 1;
+  std::string aTranslatedName = "Translated";
+  theResultBody->loadAndOrientModifiedShapes(&theTranslationAlgo,
+                                             theBaseShape, GeomAPI_Shape::FACE,
+                                             aTranslatedTag, aTranslatedName, *aSubShapes.get());
 
 }
index 2f6ce2d92fb9c2b7d2b60cd5ae7ea2b29b15b7d1..93d72c33bbdffa92974edd6d8fa4b72cbc1a762e 100644 (file)
 
 #include <GeomAlgoAPI_Translation.h>
 
-/** \class FeaturesPlugin_Translation
- *  \ingroup Plugins
- *  \brief Feature for movement objects along the axis.
- */
+/// \class FeaturesPlugin_Translation
+/// \ingroup Plugins
+/// \brief Feature for translation objects along the axis.
 class FeaturesPlugin_Translation : public ModelAPI_Feature
 {
  public:
-  /// Movement kind.
+  /// Translation kind.
   inline static const std::string& ID()
   {
-    static const std::string MY_MOVEMENT_ID("Translation");
-    return MY_MOVEMENT_ID;
+    static const std::string MY_TRANSLATION_ID("Translation");
+    return MY_TRANSLATION_ID;
   }
 
   /// Attribute name of referenced objects.
@@ -65,7 +64,7 @@ class FeaturesPlugin_Translation : public ModelAPI_Feature
   FeaturesPlugin_Translation();
 
 private:
-  void LoadNamingDS(const GeomAlgoAPI_Translation& theMovementAlgo,
+  void loadNamingDS(GeomAlgoAPI_Translation& theTranslationAlgo,
                     std::shared_ptr<ModelAPI_ResultBody> theResultBody,
                     std::shared_ptr<GeomAPI_Shape> theBaseShape);
 };
index 8f505072fcd30199867814a90207a4089014cff4..27af5311f05f1879307097b5998bbe444c3fcd26 100644 (file)
@@ -4,21 +4,15 @@
 // Created:     8 June 2015
 // Author:      Dmitry Bobylev
 
-#include <GeomAlgoAPI_Translation.h>
-
-#include <GeomAlgoAPI_ShapeTools.h>
+#include "GeomAlgoAPI_Translation.h"
 
 #include <BRepBuilderAPI_Transform.hxx>
-#include <BRepCheck_Analyzer.hxx>
 #include <gp_Ax1.hxx>
-#include <Precision.hxx>
-#include <TopExp_Explorer.hxx>
 
 //=================================================================================================
 GeomAlgoAPI_Translation::GeomAlgoAPI_Translation(std::shared_ptr<GeomAPI_Shape> theSourceShape,
                                                  std::shared_ptr<GeomAPI_Ax1>   theAxis,
                                                  double                         theDistance)
-: myDone(false)
 {
   build(theSourceShape, theAxis, theDistance);
 }
@@ -41,71 +35,22 @@ void GeomAlgoAPI_Translation::build(std::shared_ptr<GeomAPI_Shape> theSourceShap
 
   gp_Trsf* aTrsf = new gp_Trsf();
   aTrsf->SetTranslation(gp_Vec(anAxis.Direction()) * theDistance);
-  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_Translation::isValid() const
-{
-  BRepCheck_Analyzer aChecker(myShape->impl<TopoDS_Shape>());
-  return (aChecker.IsValid() == Standard_True);
-}
-
-//=================================================================================================
-const bool GeomAlgoAPI_Translation::hasVolume() const
-{
-  bool hasVolume(false);
-  if(isValid() && (GeomAlgoAPI_ShapeTools::volume(myShape) > Precision::Confusion())) {
-    hasVolume = true;
-  }
-  return hasVolume;
-}
 
-//=================================================================================================
-const std::shared_ptr<GeomAPI_Shape>& GeomAlgoAPI_Translation::shape() const
-{
-  return myShape;
-}
-
-//=================================================================================================
-std::shared_ptr<GeomAPI_DataMapOfShapeShape> GeomAlgoAPI_Translation::mapOfShapes() const
-{
-  return myMap;
-}
-
-//=================================================================================================
-std::shared_ptr<GeomAlgoAPI_MakeShape> GeomAlgoAPI_Translation::makeShape() const
-{
-  return myMkShape;
-}
-
-//=================================================================================================
-std::shared_ptr<GeomAPI_Trsf> GeomAlgoAPI_Translation::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 e8f3d8147fc0149fadcf688494ae738381048387..8f27aaa6f6ce073ec9b80efda19b7c5388cffab6 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_Translation
- *  \ingroup DataAlgo
- *  \brief Creates a copy of the object by moving it along the axis.
- */
-class GeomAlgoAPI_Translation : public GeomAPI_Interface
+/// \class GeomAlgoAPI_Translation
+/// \ingroup DataAlgo
+/// \brief Creates a copy of the object by moving it along the axis.
+class GeomAlgoAPI_Translation : public GeomAlgoAPI_MakeShape
 {
 public:
-  /** \brief Creates an object which is obtained from current object by moving it along the axis.
-   *  \param[in] theSourceShape  a shape to be moved.
-   *  \param[in] theAxis         movement axis.
-   *  \param[in] theDistance     movement distance.
-   */
+  /// \brief Creates an object which is obtained from current object by moving it along the axis.
+  /// \param[in] theSourceShape  a shape to be moved.
+  /// \param[in] theAxis         movement axis.
+  /// \param[in] theDistance     movement distance.
   GEOMALGOAPI_EXPORT GeomAlgoAPI_Translation(std::shared_ptr<GeomAPI_Shape> theSourceShape,
                                              std::shared_ptr<GeomAPI_Ax1>   theAxis,
                                              double                         theDistance);
 
-  /// \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 movement 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                         theDistance);
-
-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;
 };
 
 #endif