From 95eaef2c17309c871072a4cfb98f2df39badb48e Mon Sep 17 00:00:00 2001 From: dbv Date: Thu, 24 Dec 2015 10:50:39 +0300 Subject: [PATCH 1/1] GeomAlgoAPI_Rotation now derived from GeomAlgoAPI_MakeShape --- .../FeaturesPlugin_Rotation.cpp | 14 ++-- src/FeaturesPlugin/FeaturesPlugin_Rotation.h | 9 ++- src/GeomAlgoAPI/GeomAlgoAPI_Rotation.cpp | 71 +++---------------- src/GeomAlgoAPI/GeomAlgoAPI_Rotation.h | 51 +++---------- 4 files changed, 27 insertions(+), 118 deletions(-) diff --git a/src/FeaturesPlugin/FeaturesPlugin_Rotation.cpp b/src/FeaturesPlugin/FeaturesPlugin_Rotation.cpp index 422a4d334..0423ac8af 100755 --- a/src/FeaturesPlugin/FeaturesPlugin_Rotation.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_Rotation.cpp @@ -8,9 +8,7 @@ #include #include -#include #include -#include #include #include @@ -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 theResultBody, std::shared_ptr theBaseShape) { // Store result. theResultBody->storeModified(theBaseShape, theRotaionAlgo.shape()); - std::shared_ptr aSubShapes = theRotaionAlgo.mapOfShapes(); + std::shared_ptr 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()); } diff --git a/src/FeaturesPlugin/FeaturesPlugin_Rotation.h b/src/FeaturesPlugin/FeaturesPlugin_Rotation.h index 573163166..1326e7ac5 100755 --- a/src/FeaturesPlugin/FeaturesPlugin_Rotation.h +++ b/src/FeaturesPlugin/FeaturesPlugin_Rotation.h @@ -13,10 +13,9 @@ #include -/** \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 theResultBody, std::shared_ptr theBaseShape); }; diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_Rotation.cpp b/src/GeomAlgoAPI/GeomAlgoAPI_Rotation.cpp index 62e687d98..c5244788b 100644 --- a/src/GeomAlgoAPI/GeomAlgoAPI_Rotation.cpp +++ b/src/GeomAlgoAPI/GeomAlgoAPI_Rotation.cpp @@ -4,20 +4,14 @@ // Created: 12 May 2015 // Author: Dmitry Bobylev -#include - -#include +#include "GeomAlgoAPI_Rotation.h" #include -#include -#include -#include //================================================================================================= GeomAlgoAPI_Rotation::GeomAlgoAPI_Rotation(std::shared_ptr theSourceShape, std::shared_ptr theAxis, double theAngle) -: myDone(false) { build(theSourceShape, theAxis, theAngle); } @@ -40,71 +34,22 @@ void GeomAlgoAPI_Rotation::build(std::shared_ptr 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 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()); - 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& GeomAlgoAPI_Rotation::shape() const -{ - return myShape; -} - -//================================================================================================= -std::shared_ptr GeomAlgoAPI_Rotation::mapOfShapes() const -{ - return myMap; -} - -//================================================================================================= -std::shared_ptr GeomAlgoAPI_Rotation::makeShape() const -{ - return myMkShape; -} - -//================================================================================================= -std::shared_ptr GeomAlgoAPI_Rotation::transformation() const -{ - return myTrsf; + std::shared_ptr aShape(new GeomAPI_Shape()); + aShape->setImpl(new TopoDS_Shape(aResult)); + this->setShape(aShape); + this->setDone(true); } diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_Rotation.h b/src/GeomAlgoAPI/GeomAlgoAPI_Rotation.h index ef56c33ea..48f922b04 100644 --- a/src/GeomAlgoAPI/GeomAlgoAPI_Rotation.h +++ b/src/GeomAlgoAPI/GeomAlgoAPI_Rotation.h @@ -9,62 +9,29 @@ #include #include + #include -#include #include -#include -/** \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 theSourceShape, std::shared_ptr 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& shape() const; - - /// \return map of sub-shapes of the result. To be used for History keeping. - GEOMALGOAPI_EXPORT std::shared_ptr mapOfShapes() const; - - /// \return interface for for History processing. - GEOMALGOAPI_EXPORT std::shared_ptr makeShape() const; - - /// Returns the simple transformation - GEOMALGOAPI_EXPORT std::shared_ptr transformation() const; - private: /// Builds resulting shape. void build(std::shared_ptr theSourceShape, std::shared_ptr theAxis, double theAngle); - -private: - /// Fields. - bool myDone; - std::shared_ptr myShape; - std::shared_ptr myMap; - std::shared_ptr myMkShape; - std::shared_ptr myTrsf; ///< transformation of the shape in case theSimpleTransform }; #endif -- 2.30.2