From: dbv Date: Thu, 11 Jun 2015 16:30:06 +0000 (+0300) Subject: RevolutionCut and RevolutionFuse features. X-Git-Tag: V_1.3.0~242 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=7ae8f08629e5f99575f3cec07a8b701dd9209591;p=modules%2Fshaper.git RevolutionCut and RevolutionFuse features. Some changes in icons placement on toolbar. --- diff --git a/src/FeaturesPlugin/CMakeLists.txt b/src/FeaturesPlugin/CMakeLists.txt index 6d7a69b8a..a29526870 100644 --- a/src/FeaturesPlugin/CMakeLists.txt +++ b/src/FeaturesPlugin/CMakeLists.txt @@ -17,6 +17,9 @@ SET(PROJECT_HEADERS FeaturesPlugin_ExtrusionBoolean.h FeaturesPlugin_ExtrusionCut.h FeaturesPlugin_ExtrusionFuse.h + FeaturesPlugin_RevolutionBoolean.h + FeaturesPlugin_RevolutionCut.h + FeaturesPlugin_RevolutionFuse.h ) SET(PROJECT_SOURCES @@ -30,6 +33,7 @@ SET(PROJECT_SOURCES FeaturesPlugin_Placement.cpp FeaturesPlugin_CompositeBoolean.cpp FeaturesPlugin_ExtrusionBoolean.cpp + FeaturesPlugin_RevolutionBoolean.cpp ) SET(XML_RESOURCES @@ -38,6 +42,8 @@ SET(XML_RESOURCES extrusioncut_widget.xml extrusionfuse_widget.xml revolution_widget.xml + revolutioncut_widget.xml + revolutionfuse_widget.xml rotation_widget.xml movement_widget.xml boolean_widget.xml diff --git a/src/FeaturesPlugin/FeaturesPlugin_ExtrusionBoolean.cpp b/src/FeaturesPlugin/FeaturesPlugin_ExtrusionBoolean.cpp index 7ce64731f..fcc224488 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_ExtrusionBoolean.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_ExtrusionBoolean.cpp @@ -48,8 +48,8 @@ ListOfShape FeaturesPlugin_ExtrusionBoolean::MakeSolids(const ListOfShape& theFa // Extrude faces. ListOfShape anExtrusionList; for(ListOfShape::const_iterator aFacesIt = theFaces.begin(); aFacesIt != theFaces.end(); aFacesIt++) { - std::shared_ptr aBaseFace = *aFacesIt; - GeomAlgoAPI_Prism aPrismAlgo(aBaseFace, aFromShape, aFromSize, aToShape, aToSize); + std::shared_ptr aBaseShape = *aFacesIt; + GeomAlgoAPI_Prism aPrismAlgo(aBaseShape, aFromShape, aFromSize, aToShape, aToSize); // Checking that the algorithm worked properly. if(!aPrismAlgo.isDone() || aPrismAlgo.shape()->isNull() || !aPrismAlgo.isValid()) { diff --git a/src/FeaturesPlugin/FeaturesPlugin_Movement.cpp b/src/FeaturesPlugin/FeaturesPlugin_Movement.cpp index 5842ffd59..12bced349 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_Movement.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_Movement.cpp @@ -50,7 +50,7 @@ void FeaturesPlugin_Movement::execute() anObjects.push_back(anObject); } - //Getting axe. + //Getting axis. std::shared_ptr anAxis; std::shared_ptr anEdge; std::shared_ptr anObjRef = selection(FeaturesPlugin_Movement::AXIS_OBJECT_ID()); diff --git a/src/FeaturesPlugin/FeaturesPlugin_Plugin.cpp b/src/FeaturesPlugin/FeaturesPlugin_Plugin.cpp index 97643a705..bbc67e103 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_Plugin.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_Plugin.cpp @@ -10,6 +10,8 @@ #include #include #include +#include +#include #include #include @@ -49,6 +51,10 @@ FeaturePtr FeaturesPlugin_Plugin::createFeature(string theFeatureID) return FeaturePtr(new FeaturesPlugin_ExtrusionCut); } else if (theFeatureID == FeaturesPlugin_ExtrusionFuse::ID()) { return FeaturePtr(new FeaturesPlugin_ExtrusionFuse); + } else if (theFeatureID == FeaturesPlugin_RevolutionCut::ID()) { + return FeaturePtr(new FeaturesPlugin_RevolutionCut); + } else if (theFeatureID == FeaturesPlugin_RevolutionFuse::ID()) { + return FeaturePtr(new FeaturesPlugin_RevolutionFuse); } // feature of such kind is not found return FeaturePtr(); diff --git a/src/FeaturesPlugin/FeaturesPlugin_Revolution.cpp b/src/FeaturesPlugin/FeaturesPlugin_Revolution.cpp index b0a2a4606..8f34e2f56 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_Revolution.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_Revolution.cpp @@ -58,7 +58,7 @@ void FeaturesPlugin_Revolution::execute() { AttributeSelectionListPtr aFaceRefs = selectionList(FeaturesPlugin_Revolution::LIST_ID()); - //Getting axe. + //Getting axis. std::shared_ptr anAxis; std::shared_ptr anEdge; std::shared_ptr anObjRef = selection(FeaturesPlugin_Revolution::AXIS_OBJECT_ID()); diff --git a/src/FeaturesPlugin/FeaturesPlugin_Revolution.h b/src/FeaturesPlugin/FeaturesPlugin_Revolution.h index ffb7ae2a5..160cc890c 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_Revolution.h +++ b/src/FeaturesPlugin/FeaturesPlugin_Revolution.h @@ -39,11 +39,11 @@ class FeaturesPlugin_Revolution : public ModelAPI_Feature return MY_GROUP_LIST_ID; } - /// Attribute name of an object to which the extrusion grows. + /// Attribute name of an revolution axis. inline static const std::string& AXIS_OBJECT_ID() { - static const std::string MY_TO_OBJECT_ID("axis_object"); - return MY_TO_OBJECT_ID; + static const std::string MY_AXIS_ID("axis_object"); + return MY_AXIS_ID; } /// Attribute name of revolution angle. diff --git a/src/FeaturesPlugin/FeaturesPlugin_RevolutionBoolean.cpp b/src/FeaturesPlugin/FeaturesPlugin_RevolutionBoolean.cpp new file mode 100644 index 000000000..646792492 --- /dev/null +++ b/src/FeaturesPlugin/FeaturesPlugin_RevolutionBoolean.cpp @@ -0,0 +1,78 @@ +// Copyright (C) 2014-20xx CEA/DEN, EDF R&D + +// File: FeaturesPlugin_RevolutionBoolean.h +// Created: 11 June 2015 +// Author: Dmitry Bobylev + +#include + +#include +#include +#include +#include + +#include +#include +#include + +//================================================================================================= +void FeaturesPlugin_RevolutionBoolean::initMakeSolidsAttributes() +{ + data()->addAttribute(FeaturesPlugin_RevolutionBoolean::AXIS_OBJECT_ID(), ModelAPI_AttributeSelection::typeId()); + + data()->addAttribute(FROM_OBJECT_ID(), ModelAPI_AttributeSelection::typeId()); + data()->addAttribute(FROM_ANGLE_ID(), ModelAPI_AttributeDouble::typeId()); + + data()->addAttribute(TO_OBJECT_ID(), ModelAPI_AttributeSelection::typeId()); + data()->addAttribute(TO_ANGLE_ID(), ModelAPI_AttributeDouble::typeId()); + + ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), FROM_OBJECT_ID()); + ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), TO_OBJECT_ID()); +} + +//================================================================================================= +ListOfShape FeaturesPlugin_RevolutionBoolean::MakeSolids(const ListOfShape& theFaces) +{ + //Getting axis. + std::shared_ptr anAxis; + std::shared_ptr anEdge; + std::shared_ptr anObjRef = selection(FeaturesPlugin_RevolutionBoolean::AXIS_OBJECT_ID()); + if(anObjRef && anObjRef->value() && anObjRef->value()->isEdge()) { + anEdge = std::shared_ptr(new GeomAPI_Edge(anObjRef->value())); + } + if(anEdge) { + anAxis = std::shared_ptr(new GeomAPI_Ax1(anEdge->line()->location(), anEdge->line()->direction())); + } + + // Getting revolution bounding planes. + std::shared_ptr aFromShape; + std::shared_ptr aToShape; + anObjRef = selection(FROM_OBJECT_ID()); + if (anObjRef) { + aFromShape = std::dynamic_pointer_cast(anObjRef->value()); + } + anObjRef = selection(TO_OBJECT_ID()); + if (anObjRef) { + aToShape = std::dynamic_pointer_cast(anObjRef->value()); + } + + // Getting revolution angles. + double aFromAngle = real(FROM_ANGLE_ID())->value(); + double aToAngle = real(TO_ANGLE_ID())->value(); + + // Revol faces. + ListOfShape aRevolutionList; + for(ListOfShape::const_iterator aFacesIt = theFaces.begin(); aFacesIt != theFaces.end(); aFacesIt++) { + std::shared_ptr aBaseShape = *aFacesIt; + GeomAlgoAPI_Revolution aRevolAlgo(aBaseShape, anAxis, aFromShape, aFromAngle, aToShape, aToAngle); + + // Checking that the algorithm worked properly. + if(!aRevolAlgo.isDone() || aRevolAlgo.shape()->isNull() || !aRevolAlgo.isValid()) { + setError("Revolution algorithm failed"); + return ListOfShape(); + } + aRevolutionList.push_back(aRevolAlgo.shape()); + } + + return aRevolutionList; +} \ No newline at end of file diff --git a/src/FeaturesPlugin/FeaturesPlugin_RevolutionBoolean.h b/src/FeaturesPlugin/FeaturesPlugin_RevolutionBoolean.h new file mode 100644 index 000000000..e9fe6fb7e --- /dev/null +++ b/src/FeaturesPlugin/FeaturesPlugin_RevolutionBoolean.h @@ -0,0 +1,64 @@ +// Copyright (C) 2014-20xx CEA/DEN, EDF R&D + +// File: FeaturesPlugin_RevolutionBoolean.h +// Created: 11 June 2015 +// Author: Dmitry Bobylev + +#ifndef FeaturesPlugin_RevolutionBoolean_H_ +#define FeaturesPlugin_RevolutionBoolean_H_ + +#include + +/** \class FeaturesPlugin_RevolutionBoolean + * \ingroup Plugins + */ +class FeaturesPlugin_RevolutionBoolean : public FeaturesPlugin_CompositeBoolean +{ +public: + /// Attribute name of an revolution axis. + inline static const std::string& AXIS_OBJECT_ID() + { + static const std::string MY_AXIS_ID("axis_object"); + return MY_AXIS_ID; + } + + /// Attribute name of an object from which the revolution grows. + inline static const std::string& FROM_OBJECT_ID() + { + static const std::string MY_FROM_OBJECT_ID("from_object"); + return MY_FROM_OBJECT_ID; + } + + /// Attribute name of revolution from angle. + inline static const std::string& FROM_ANGLE_ID() + { + static const std::string MY_FROM_ANGLE_ID("from_angle"); + return MY_FROM_ANGLE_ID; + } + + /// attribute name of an object to which the revolution grows. + inline static const std::string& TO_OBJECT_ID() + { + static const std::string MY_TO_OBJECT_ID("to_object"); + return MY_TO_OBJECT_ID; + } + + /// Attribute name of revolution to angle. + inline static const std::string& TO_ANGLE_ID() + { + static const std::string MY_TO_ANGLE_ID("to_angle"); + return MY_TO_ANGLE_ID; + } + +protected: + /// Init attributes for revolution. + virtual void initMakeSolidsAttributes(); + + /// Create solids from faces with revolution. + virtual ListOfShape MakeSolids(const ListOfShape& theFaces); + +protected: + FeaturesPlugin_RevolutionBoolean(){}; +}; + +#endif diff --git a/src/FeaturesPlugin/FeaturesPlugin_RevolutionCut.h b/src/FeaturesPlugin/FeaturesPlugin_RevolutionCut.h new file mode 100644 index 000000000..9116a46cd --- /dev/null +++ b/src/FeaturesPlugin/FeaturesPlugin_RevolutionCut.h @@ -0,0 +1,39 @@ +// Copyright (C) 2014-20xx CEA/DEN, EDF R&D + +// File: FeaturesPlugin_RevolutionCut.h +// Created: 11 June 2015 +// Author: Dmitry Bobylev + +#ifndef FeaturesPlugin_RevolutionCut_H_ +#define FeaturesPlugin_RevolutionCut_H_ + +#include + +/** \class FeaturesPlugin_RevolutionCut + * \ingroup Plugins + */ +class FeaturesPlugin_RevolutionCut : public FeaturesPlugin_RevolutionBoolean +{ + public: + /// Feature kind. + inline static const std::string& ID() + { + static const std::string MY_REVOLUTION_ID("RevolutionCut"); + return MY_REVOLUTION_ID; + } + + /// \return the kind of a feature + FEATURESPLUGIN_EXPORT virtual const std::string& getKind() + { + static std::string MY_KIND = FeaturesPlugin_RevolutionCut::ID(); + return MY_KIND; + } + + /// Use plugin manager for features creation. + FeaturesPlugin_RevolutionCut() + { + myBooleanOperationType = GeomAlgoAPI_Boolean::BOOL_CUT; + } +}; + +#endif diff --git a/src/FeaturesPlugin/FeaturesPlugin_RevolutionFuse.h b/src/FeaturesPlugin/FeaturesPlugin_RevolutionFuse.h new file mode 100644 index 000000000..f7e939773 --- /dev/null +++ b/src/FeaturesPlugin/FeaturesPlugin_RevolutionFuse.h @@ -0,0 +1,39 @@ +// Copyright (C) 2014-20xx CEA/DEN, EDF R&D + +// File: FeaturesPlugin_RevolutionFuse.h +// Created: 11 June 2015 +// Author: Dmitry Bobylev + +#ifndef FeaturesPlugin_RevolutionFuse_H_ +#define FeaturesPlugin_RevolutionFuse_H_ + +#include + +/** \class FeaturesPlugin_RevolutionFuse + * \ingroup Plugins + */ +class FeaturesPlugin_RevolutionFuse : public FeaturesPlugin_RevolutionBoolean +{ + public: + /// Feature kind. + inline static const std::string& ID() + { + static const std::string MY_REVOLUTION_ID("RevolutionFuse"); + return MY_REVOLUTION_ID; + } + + /// \return the kind of a feature + FEATURESPLUGIN_EXPORT virtual const std::string& getKind() + { + static std::string MY_KIND = FeaturesPlugin_RevolutionFuse::ID(); + return MY_KIND; + } + + /// Use plugin manager for features creation. + FeaturesPlugin_RevolutionFuse() + { + myBooleanOperationType = GeomAlgoAPI_Boolean::BOOL_FUSE; + } +}; + +#endif diff --git a/src/FeaturesPlugin/FeaturesPlugin_Rotation.cpp b/src/FeaturesPlugin/FeaturesPlugin_Rotation.cpp index cbff4e0ca..25faa8dd6 100755 --- a/src/FeaturesPlugin/FeaturesPlugin_Rotation.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_Rotation.cpp @@ -50,7 +50,7 @@ void FeaturesPlugin_Rotation::execute() anObjects.push_back(anObject); } - //Getting axe. + //Getting axis. std::shared_ptr anAxis; std::shared_ptr anEdge; std::shared_ptr anObjRef = selection(FeaturesPlugin_Rotation::AXIS_OBJECT_ID()); diff --git a/src/FeaturesPlugin/extrusionfuse_widget.xml b/src/FeaturesPlugin/extrusionfuse_widget.xml index 9f0803a61..f7b0acbe2 100644 --- a/src/FeaturesPlugin/extrusionfuse_widget.xml +++ b/src/FeaturesPlugin/extrusionfuse_widget.xml @@ -41,7 +41,7 @@ diff --git a/src/FeaturesPlugin/plugin-Features.xml b/src/FeaturesPlugin/plugin-Features.xml index 30cd1569b..6e82e3087 100644 --- a/src/FeaturesPlugin/plugin-Features.xml +++ b/src/FeaturesPlugin/plugin-Features.xml @@ -3,23 +3,19 @@ - - - - - - - - - + + + - - + + + + @@ -28,6 +24,22 @@ + + + + + + + + + + + + + + + + - + diff --git a/src/FeaturesPlugin/revolutioncut_widget.xml b/src/FeaturesPlugin/revolutioncut_widget.xml new file mode 100644 index 000000000..9f0ca3732 --- /dev/null +++ b/src/FeaturesPlugin/revolutioncut_widget.xml @@ -0,0 +1,56 @@ + + + + + /> + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/FeaturesPlugin/revolutionfuse_widget.xml b/src/FeaturesPlugin/revolutionfuse_widget.xml new file mode 100644 index 000000000..cbf047351 --- /dev/null +++ b/src/FeaturesPlugin/revolutionfuse_widget.xml @@ -0,0 +1,56 @@ + + + + + /> + + + + + + + + + + + + + + + + + + + + + +