From: nds Date: Thu, 24 Mar 2016 07:35:35 +0000 (+0300) Subject: Issue #1343 Improvement of Extrusion and Revolution operations: revolution/revolution... X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=6ba17bde5a013be052b7083dfc1abc7868152f70;p=modules%2Fshaper.git Issue #1343 Improvement of Extrusion and Revolution operations: revolution/revolution cut/revolution fuse. --- diff --git a/src/FeaturesPlugin/FeaturesPlugin_CompositeSketch.cpp b/src/FeaturesPlugin/FeaturesPlugin_CompositeSketch.cpp index 5f7354120..3d8ce83ef 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_CompositeSketch.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_CompositeSketch.cpp @@ -28,7 +28,7 @@ void FeaturesPlugin_CompositeSketch::initAttributes() data()->addAttribute(SKETCH_SELECTION_ID(), ModelAPI_AttributeSelection::typeId()); ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), SKETCH_SELECTION_ID()); - initMakeSolidsAttributes(); + //initMakeSolidsAttributes(); } //================================================================================================= @@ -85,6 +85,9 @@ bool FeaturesPlugin_CompositeSketch::isSub(ObjectPtr theObject) const //================================================================================================= void FeaturesPlugin_CompositeSketch::removeFeature(std::shared_ptr theFeature) { + AttributeSelectionListPtr aFacesSelectionList = selectionList(LIST_ID()); + if (aFacesSelectionList.get() && aFacesSelectionList->size() > 0) + aFacesSelectionList->clear(); } //================================================================================================= @@ -215,3 +218,20 @@ void FeaturesPlugin_CompositeSketch::loadNamingDS(std::shared_ptr aSketchFeature = std::dynamic_pointer_cast( + reference(SKETCH_OBJECT_ID())->value()); + + if(aSketchFeature.get() && !aSketchFeature->results().empty()) { + ResultPtr aSketchRes = aSketchFeature->results().front(); + ResultConstructionPtr aConstruction = std::dynamic_pointer_cast(aSketchRes); + if(aConstruction.get()) { + AttributeSelectionListPtr aFacesSelectionList = selectionList(LIST_ID()); + if (aFacesSelectionList.get() && aFacesSelectionList->size() == 0) + aFacesSelectionList->append(aSketchRes, std::shared_ptr()); + } + } +} + diff --git a/src/FeaturesPlugin/FeaturesPlugin_CompositeSketch.h b/src/FeaturesPlugin/FeaturesPlugin_CompositeSketch.h index d4307edeb..7f0a9e9ce 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_CompositeSketch.h +++ b/src/FeaturesPlugin/FeaturesPlugin_CompositeSketch.h @@ -34,6 +34,14 @@ class FeaturesPlugin_CompositeSketch : public ModelAPI_CompositeFeature return MY_SKETCH_SELECTION_ID; } + /// attribute name of references sketch entities list, it should contain a sketch result or + /// a pair a sketch result to sketch face + inline static const std::string& LIST_ID() + { + static const std::string MY_GROUP_LIST_ID("base"); + return MY_GROUP_LIST_ID; + } + /// Creates a new part document if needed. FEATURESPLUGIN_EXPORT virtual void execute(); @@ -66,16 +74,20 @@ protected: FeaturesPlugin_CompositeSketch(){}; /// Define this function to init attributes for extrusion/revolution. - virtual void initMakeSolidsAttributes() = 0; + //virtual void initMakeSolidsAttributes() {}; /// Define this function to create solids from faces with extrusion/revolution. virtual void makeSolid(const std::shared_ptr theFace, - std::shared_ptr& theMakeShape) = 0; + std::shared_ptr& theMakeShape) {}; /// Results naming. void loadNamingDS(std::shared_ptr theResultBody, const std::shared_ptr& theBaseShape, const std::shared_ptr& theMakeShape); + + /// Set the sub-object to list of exturusion base. + void setSketchObjectToList(); + }; #endif diff --git a/src/FeaturesPlugin/FeaturesPlugin_Extrusion.cpp b/src/FeaturesPlugin/FeaturesPlugin_Extrusion.cpp index d38803592..0be521794 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_Extrusion.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_Extrusion.cpp @@ -60,7 +60,7 @@ void FeaturesPlugin_Extrusion::initAttributes() //================================================================================================= void FeaturesPlugin_Extrusion::execute() { - /// feature extrusion does not have the next attribute + /// sub feature of the composite should be set in the base list AttributeSelectionListPtr aFacesSelectionList = selectionList(LIST_ID()); if (aFacesSelectionList.get() && !aFacesSelectionList->isInitialized()) { AttributeReferencePtr aSketchAttr = reference(SKETCH_OBJECT_ID()); @@ -173,14 +173,6 @@ void FeaturesPlugin_Extrusion::execute() removeResults(aResultIndex); } -//================================================================================================= -void FeaturesPlugin_Extrusion::removeFeature(std::shared_ptr theFeature) -{ - AttributeSelectionListPtr aFacesSelectionList = selectionList(LIST_ID()); - if (aFacesSelectionList.get() && aFacesSelectionList->size() > 0) - aFacesSelectionList->clear(); -} - //================================================================================================= void FeaturesPlugin_Extrusion::loadNamingDS(GeomAlgoAPI_Prism& thePrismAlgo, std::shared_ptr theResultBody, @@ -227,20 +219,3 @@ void FeaturesPlugin_Extrusion::loadNamingDS(GeomAlgoAPI_Prism& thePrismAlgo, } } -//================================================================================================= -void FeaturesPlugin_Extrusion::setSketchObjectToList() -{ - std::shared_ptr aSketchFeature = std::dynamic_pointer_cast( - reference(SKETCH_OBJECT_ID())->value()); - - if(aSketchFeature.get() && !aSketchFeature->results().empty()) { - ResultPtr aSketchRes = aSketchFeature->results().front(); - ResultConstructionPtr aConstruction = std::dynamic_pointer_cast(aSketchRes); - if(aConstruction.get()) { - AttributeSelectionListPtr aFacesSelectionList = selectionList(LIST_ID()); - if (aFacesSelectionList.get() && aFacesSelectionList->size() == 0) - aFacesSelectionList->append(aSketchRes, std::shared_ptr()); - } - } -} - diff --git a/src/FeaturesPlugin/FeaturesPlugin_Extrusion.h b/src/FeaturesPlugin/FeaturesPlugin_Extrusion.h index a8867530e..a9330faf2 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_Extrusion.h +++ b/src/FeaturesPlugin/FeaturesPlugin_Extrusion.h @@ -33,13 +33,6 @@ class FeaturesPlugin_Extrusion : public FeaturesPlugin_CompositeSketch static const std::string MY_EXTRUSION_ID("Extrusion"); return MY_EXTRUSION_ID; } - /// attribute name of references sketch entities list, it should contain a sketch result or - /// a pair a sketch result to sketch face - inline static const std::string& LIST_ID() - { - static const std::string MY_GROUP_LIST_ID("base"); - return MY_GROUP_LIST_ID; - } /// attribute name of an object to which the extrusion grows inline static const std::string& AXIS_OBJECT_ID() @@ -110,29 +103,14 @@ class FeaturesPlugin_Extrusion : public FeaturesPlugin_CompositeSketch /// Request for initialization of data model of the feature: adding all attributes FEATURESPLUGIN_EXPORT virtual void initAttributes(); - /// This method to inform that sub-feature is removed and must be removed from the internal data - /// structures of the owner (the remove from the document will be done outside just after) - FEATURESPLUGIN_EXPORT virtual void removeFeature(std::shared_ptr theFeature); - /// Use plugin manager for features creation FeaturesPlugin_Extrusion(); -protected: - /// Init attributes for extrusion. - virtual void initMakeSolidsAttributes() {}; - - /// Create solid from face with extrusion. - virtual void makeSolid(const std::shared_ptr theFace, - std::shared_ptr& theMakeShape) {}; - private: /// Load Naming data structure of the feature to the document void loadNamingDS(GeomAlgoAPI_Prism& thePrismAlgo, std::shared_ptr theResultBody, std::shared_ptr theBasis); - - /// Set the sub-object to list of exturusion base. - void setSketchObjectToList(); }; #endif diff --git a/src/FeaturesPlugin/FeaturesPlugin_Revolution.cpp b/src/FeaturesPlugin/FeaturesPlugin_Revolution.cpp index 88163729c..e71194aef 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_Revolution.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_Revolution.cpp @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include @@ -51,14 +52,28 @@ void FeaturesPlugin_Revolution::initAttributes() ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), TO_OBJECT_ID()); ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), FROM_OBJECT_ID()); + + // Composite Sketch attribute + data()->addAttribute(FeaturesPlugin_CompositeSketch::SKETCH_OBJECT_ID(), + ModelAPI_AttributeReference::typeId()); + ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), + FeaturesPlugin_CompositeSketch::SKETCH_OBJECT_ID()); } //================================================================================================= void FeaturesPlugin_Revolution::execute() { + /// sub feature of the composite should be set in the base list + AttributeSelectionListPtr aFacesSelectionList = selectionList(LIST_ID()); + if (aFacesSelectionList.get() && !aFacesSelectionList->isInitialized()) { + AttributeReferencePtr aSketchAttr = reference(SKETCH_OBJECT_ID()); + if (aSketchAttr.get() && aSketchAttr->isInitialized()) + setSketchObjectToList(); + } + // Getting faces. ListOfShape aFacesList; - AttributeSelectionListPtr aFacesSelectionList = selectionList(LIST_ID()); + aFacesSelectionList = selectionList(LIST_ID()); for(int anIndex = 0; anIndex < aFacesSelectionList->size(); anIndex++) { AttributeSelectionPtr aFaceSel = aFacesSelectionList->value(anIndex); std::shared_ptr aFaceShape = aFaceSel->value(); diff --git a/src/FeaturesPlugin/FeaturesPlugin_Revolution.h b/src/FeaturesPlugin/FeaturesPlugin_Revolution.h index 44a9b773a..7c16ec3b2 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_Revolution.h +++ b/src/FeaturesPlugin/FeaturesPlugin_Revolution.h @@ -10,7 +10,7 @@ #include #include -#include +#include class GeomAPI_Shape; class ModelAPI_ResultBody; @@ -21,7 +21,7 @@ class ModelAPI_ResultBody; * Revolution creates the lateral faces based on edges of the base face and * the start and end faces and/or start and end angles. */ -class FeaturesPlugin_Revolution : public ModelAPI_Feature +class FeaturesPlugin_Revolution : public FeaturesPlugin_CompositeSketch { public: /// Revolution kind. @@ -31,14 +31,6 @@ class FeaturesPlugin_Revolution : public ModelAPI_Feature return MY_REVOLUTION_ID; } - /// Attribute name of references sketch entities list, it should contain a sketch result or - /// a pair a sketch result to sketch face. - inline static const std::string& LIST_ID() - { - static const std::string MY_GROUP_LIST_ID("base"); - return MY_GROUP_LIST_ID; - } - /// Attribute name of an revolution axis. inline static const std::string& AXIS_OBJECT_ID() { diff --git a/src/FeaturesPlugin/extrusionfuse_widget.xml b/src/FeaturesPlugin/extrusionfuse_widget.xml index fb06968e0..e918b4626 100644 --- a/src/FeaturesPlugin/extrusionfuse_widget.xml +++ b/src/FeaturesPlugin/extrusionfuse_widget.xml @@ -3,10 +3,20 @@ + attribute_list_id="base" + label="Select:<br /> +1. Planar face of non-sketch object or a plane. Sketch creation will be started.<br /> +2. An existing sketch face or contour. Extrusion will be filled by it.<br /> +3. An existing result shape of kind: wires/edge/vertices.Extrusion will be filled by it." + shape_types="face objects"> + + + diff --git a/src/FeaturesPlugin/revolution_widget.xml b/src/FeaturesPlugin/revolution_widget.xml index 187317bc0..73ed217c7 100644 --- a/src/FeaturesPlugin/revolution_widget.xml +++ b/src/FeaturesPlugin/revolution_widget.xml @@ -1,6 +1,21 @@ + + + + + + attribute_list_id="base" + label="Select:<br /> +1. Planar face of non-sketch object or a plane. Sketch creation will be started.<br /> +2. An existing sketch face or contour. Extrusion will be filled by it.<br /> +3. An existing result shape of kind: wires/edge/vertices.Extrusion will be filled by it." + shape_types="face objects"> + + + + attribute_list_id="base" + label="Select:<br /> +1. Planar face of non-sketch object or a plane. Sketch creation will be started.<br /> +2. An existing sketch face or contour. Extrusion will be filled by it.<br /> +3. An existing result shape of kind: wires/edge/vertices.Extrusion will be filled by it." + shape_types="face objects"> + + +