Salome HOME
Issue #2611: Partition of a solid belonging to a Compsolid
[modules/shaper.git] / src / FeaturesPlugin / FeaturesPlugin_CompositeSketch.h
1 // Copyright (C) 2014-2017  CEA/DEN, EDF R&D
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or
18 // email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
19 //
20
21 #ifndef FeaturesPlugin_CompositeSketch_H_
22 #define FeaturesPlugin_CompositeSketch_H_
23
24 #include "FeaturesPlugin.h"
25
26 #include <ModelAPI_CompositeFeature.h>
27
28 #include <ModelAPI_ResultBody.h>
29
30 /// \class FeaturesPlugin_CompositeSketch
31 /// \ingroup Plugins
32 /// \brief Interface for the composite sketch feature.
33 class FeaturesPlugin_CompositeSketch : public ModelAPI_CompositeFeature
34 {
35 public:
36   /// Attribute name of sketch feature.
37   inline static const std::string& SKETCH_ID()
38   {
39     static const std::string MY_SKETCH_ID("sketch");
40     return MY_SKETCH_ID;
41   }
42
43   /// Attribute name of base objects.
44   inline static const std::string& BASE_OBJECTS_ID()
45   {
46     static const std::string MY_BASE_OBJECTS_ID("base");
47     return MY_BASE_OBJECTS_ID;
48   }
49
50   /// Appends a feature to the sketch sub-elements container.
51   FEATURESPLUGIN_EXPORT virtual std::shared_ptr<ModelAPI_Feature> addFeature(std::string theID);
52
53   /// \return the number of sub-elements.
54   FEATURESPLUGIN_EXPORT virtual int numberOfSubs(bool forTree = false) const;
55
56   /// \return the sub-feature by zero-base index.
57   FEATURESPLUGIN_EXPORT virtual
58     std::shared_ptr<ModelAPI_Feature> subFeature(const int theIndex, bool forTree = false);
59
60   /// \return the sub-feature unique identifier in this composite feature by zero-base index.
61   FEATURESPLUGIN_EXPORT virtual int subFeatureId(const int theIndex) const;
62
63   /// \return true if feature or result belong to this composite feature as subs.
64   FEATURESPLUGIN_EXPORT virtual bool isSub(ObjectPtr theObject) const;
65
66   /// This method to inform that sub-feature is removed and must be removed from the internal data
67   /// structures of the owner (the remove from the document will be done outside just after).
68   FEATURESPLUGIN_EXPORT virtual void removeFeature(std::shared_ptr<ModelAPI_Feature> theFeature);
69
70 protected:
71   enum InitFlags {
72     InitSketchLauncher   = 1 << 0,
73     InitBaseObjectsList  = 1 << 1
74   };
75
76   FeaturesPlugin_CompositeSketch(){};
77
78   /// Initializes composite sketch attributes.
79   void initCompositeSketchAttribtues(const int theInitFlags);
80
81   /// \brief Returns list of base shapes.
82   /// \param[out] theBaseShapesList list of base shapes (warning: list not cleared).
83   /// \param[in] theIsMakeShells if true make shells from faces with shared edges.
84   void getBaseShapes(ListOfShape& theBaseShapesList, const bool theIsMakeShells = true);
85
86   /// Checks make shape algo.
87   bool isMakeShapeValid(const std::shared_ptr<GeomAlgoAPI_MakeShape> theMakeShape);
88
89   /// Stores result of generation.
90   void storeResult(const GeomShapePtr theBaseShape,
91                    const std::shared_ptr<GeomAlgoAPI_MakeShape> theMakeShape,
92                    const int theIndex = 0);
93
94   /// Stores generation history.
95   void storeGenerationHistory(ResultBodyPtr theResultBody,
96                               const GeomShapePtr theBaseShape,
97                               const std::shared_ptr<GeomAlgoAPI_MakeShape> theMakeShape,
98                               int& theTag);
99
100   /// Used to store from and to shapes.
101   void storeShapes(ResultBodyPtr theResultBody,
102                    const GeomAPI_Shape::ShapeType theBaseShapeType,
103                    const std::shared_ptr<GeomAPI_DataMapOfShapeShape> theMapOfSubShapes,
104                    const ListOfShape& theShapes,
105                    const std::string theName,
106                    int& theTag);
107
108 };
109
110 #endif