X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FFeaturesPlugin%2FFeaturesPlugin_CompositeBoolean.h;h=34b88aebc511df99c57e94f0de0fe951d49cdc0a;hb=85b662214060cf733b44ac7822e3e4db49e2da4b;hp=4150d3af6c7001bf9845c1ebef71cbbc9b77e2db;hpb=ec9b85c536b6f28dde7433128827a11f07d3e956;p=modules%2Fshaper.git diff --git a/src/FeaturesPlugin/FeaturesPlugin_CompositeBoolean.h b/src/FeaturesPlugin/FeaturesPlugin_CompositeBoolean.h index 4150d3af6..34b88aebc 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_CompositeBoolean.h +++ b/src/FeaturesPlugin/FeaturesPlugin_CompositeBoolean.h @@ -7,87 +7,70 @@ #ifndef FeaturesPlugin_CompositeBoolean_H_ #define FeaturesPlugin_CompositeBoolean_H_ -#include +#include "FeaturesPlugin.h" -#include +#include +#include +#include -#include - -/** \class FeaturesPlugin_CompositeBoolean - * \ingroup Plugins - */ -class FeaturesPlugin_CompositeBoolean : public ModelAPI_CompositeFeature +/// \class FeaturesPlugin_CompositeBoolean +/// \ingroup Plugins +/// \brief Interface for the composite boolean feature. +class FeaturesPlugin_CompositeBoolean { - public: - /// Attribute name of sketch feature. - inline static const std::string& SKETCH_OBJECT_ID() +public: + enum OperationType { + BOOL_CUT, + BOOL_FUSE, + BOOL_COMMON, + BOOL_SMASH + }; + + /// Attribute name of main objects. + inline static const std::string& OBJECTS_ID() { - static const std::string MY_SKETCH_OBJECT_ID("sketch"); - return MY_SKETCH_OBJECT_ID; - } - - /// Attribute name of sketch feature. - inline static const std::string& SKETCH_SELECTION_ID() - { - static const std::string MY_SKETCH_SELECTION_ID("sketch_selection"); - return MY_SKETCH_SELECTION_ID; - } - - /// Attribute name of objects for boolean operation. - inline static const std::string& BOOLEAN_OBJECTS_ID() - { - static const std::string MY_BOOLEAN_OBJECTS_ID("boolean_objects"); - return MY_BOOLEAN_OBJECTS_ID; + static const std::string MY_OBJECTS_ID("main_objects"); + return MY_OBJECTS_ID; } /// Creates a new part document if needed. - FEATURESPLUGIN_EXPORT virtual void execute(); - - /// Request for initialization of data model of the feature: adding all attributes. - FEATURESPLUGIN_EXPORT virtual void initAttributes(); - - /// Appends a feature to the sketch sub-elements container. - FEATURESPLUGIN_EXPORT virtual std::shared_ptr addFeature(std::string theID); - - /// \return the number of sub-elements. - FEATURESPLUGIN_EXPORT virtual int numberOfSubs(bool forTree = false) const; - - /// \return the sub-feature by zero-base index. - FEATURESPLUGIN_EXPORT virtual std::shared_ptr subFeature(const int theIndex, bool forTree = false) const; - - /// \return the sub-feature unique identifier in this composite feature by zero-base index. - FEATURESPLUGIN_EXPORT virtual int subFeatureId(const int theIndex) const; - - /// \return true if feature or reuslt belong to this composite feature as subs. - FEATURESPLUGIN_EXPORT virtual bool isSub(ObjectPtr theObject) const; - - /// 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); - - /// removes also all sub-sketch - FEATURESPLUGIN_EXPORT virtual void erase(); + FEATURESPLUGIN_EXPORT virtual void executeCompositeBoolean(); protected: FeaturesPlugin_CompositeBoolean(){}; - /// Define this function to init attributes for extrusion/revolution. - virtual void initMakeSolidsAttributes() = 0; - - /// Define this function to create solids from faces with extrusion/revolution. - virtual void makeSolids(const ListOfShape& theFaces, - ListOfShape& theResults, - std::list>& theAlgos) = 0; - - void loadNamingDS(std::shared_ptr theResultBody, - const std::shared_ptr& theBaseShape, - const ListOfShape& theShells, - const std::list>& theAlgos, - const ListOfShape& theTools, - const GeomAlgoAPI_Boolean& theAlgo); + /// Initializes boolean attributes. + void initBooleanAttributes(); + + /// This function need to be defined for extrusion/revolution generation. + virtual bool makeGeneration(ListOfShape& theBaseShapes, + ListOfMakeShape& theMakeShapes) = 0; + + /// Makes boolean operation. + /// \param[in] theTools list of tools. + /// \param[out] theObjects list of objects. + /// \param[out] theMakeShapes list of according algos. + /// \return false in failed. + bool makeBoolean(const ListOfShape& theTools, + ListOfShape& theObjects, + ListOfMakeShape& theMakeShapes); + + /// Stores generation history. + virtual void storeGenerationHistory(ResultBodyPtr theResultBody, + const GeomShapePtr theBaseShape, + const std::shared_ptr theMakeShape, + int& theTag) = 0; + + /// Stores modification history. + void storeModificationHistory(ResultBodyPtr theResultBody, + const GeomShapePtr theObject, + const ListOfShape& theTools, + const std::shared_ptr theMakeShape, + int& theTag); protected: - GeomAlgoAPI_Boolean::OperationType myBooleanOperationType; + ModelAPI_Feature* myFeature; + OperationType myOperationType; }; #endif