#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>
}
ResultBodyPtr aResultBody = document()->createBody(data(), aResultIndex);
- LoadNamingDS(aRotationAlgo, aResultBody, aBaseShape);
+ loadNamingDS(aRotationAlgo, aResultBody, aBaseShape);
setResult(aResultBody, aResultIndex);
}
aResultIndex++;
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());
}
#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:
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);
};
// 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);
}
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);
}
#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