Salome HOME
72413a03f5c9c3e226b4ab5914ee085a98816c4c
[modules/shaper.git] / src / FeaturesPlugin / FeaturesPlugin_CompositeSketch.h
1 // Copyright (C) 2014-2021  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 email : webmaster.salome@opencascade.com
18 //
19
20 #ifndef FeaturesPlugin_CompositeSketch_H_
21 #define FeaturesPlugin_CompositeSketch_H_
22
23 #include "FeaturesPlugin.h"
24
25 #include <ModelAPI_CompositeFeature.h>
26
27 #include <ModelAPI_ResultBody.h>
28
29 /// \class FeaturesPlugin_CompositeSketch
30 /// \ingroup Plugins
31 /// \brief Interface for the composite sketch feature.
32 class FeaturesPlugin_CompositeSketch : public ModelAPI_CompositeFeature
33 {
34 public:
35   /// Attribute name of sketch feature.
36   inline static const std::string& SKETCH_ID()
37   {
38     static const std::string MY_SKETCH_ID("sketch");
39     return MY_SKETCH_ID;
40   }
41
42   /// Attribute name of base objects.
43   inline static const std::string& BASE_OBJECTS_ID()
44   {
45     static const std::string MY_BASE_OBJECTS_ID("base");
46     return MY_BASE_OBJECTS_ID;
47   }
48
49   /// Appends a feature to the sketch sub-elements container.
50   FEATURESPLUGIN_EXPORT virtual std::shared_ptr<ModelAPI_Feature> addFeature(std::string theID);
51
52   /// \return the number of sub-elements.
53   FEATURESPLUGIN_EXPORT virtual int numberOfSubs(bool forTree = false) const;
54
55   /// \return the sub-feature by zero-base index.
56   FEATURESPLUGIN_EXPORT virtual
57     std::shared_ptr<ModelAPI_Feature> subFeature(const int theIndex, bool forTree = false);
58
59   /// \return the sub-feature unique identifier in this composite feature by zero-base index.
60   FEATURESPLUGIN_EXPORT virtual int subFeatureId(const int theIndex) const;
61
62   /// \return true if feature or result belong to this composite feature as subs.
63   FEATURESPLUGIN_EXPORT virtual bool isSub(ObjectPtr theObject) const;
64
65   /// This method to inform that sub-feature is removed and must be removed from the internal data
66   /// structures of the owner (the remove from the document will be done outside just after).
67   FEATURESPLUGIN_EXPORT virtual void removeFeature(std::shared_ptr<ModelAPI_Feature> theFeature);
68
69 protected:
70   enum InitFlags {
71     InitSketchLauncher   = 1 << 0,
72     InitBaseObjectsList  = 1 << 1
73   };
74
75   FeaturesPlugin_CompositeSketch(){};
76
77   /// Initializes composite sketch attributes.
78   void initCompositeSketchAttribtues(const int theInitFlags);
79
80   /// \brief Returns list of base shapes.
81   /// \param[out] theBaseShapesList list of base shapes (warning: list not cleared).
82   /// \param[in] theIsMakeShells if true make shells from faces with shared edges.
83   void getBaseShapes(ListOfShape& theBaseShapesList, const bool theIsMakeShells = true);
84
85   /// Stores result of generation.
86   void storeResult(const GeomShapePtr theBaseShape,
87                    const std::shared_ptr<GeomAlgoAPI_MakeShape> theMakeShape,
88                    const int theIndex = 0);
89
90   /// Stores generation history.
91   void storeGenerationHistory(ResultBodyPtr theResultBody,
92                               const GeomShapePtr theBaseShape,
93                               const std::shared_ptr<GeomAlgoAPI_MakeShape> theMakeShape);
94
95   /// Used to store from and to shapes: generated, or in common modified tag
96   void storeShapes(const std::shared_ptr<GeomAlgoAPI_MakeShape> theMakeShape,
97                    ResultBodyPtr theResultBody,
98                    const GeomAPI_Shape::ShapeType theBaseShapeType,
99                    const ListOfShape& theShapes,
100                    const std::string theName);
101
102 private:
103   std::string myCurrentSelectionType; //< type of selection (vertex, edge or face)
104 };
105
106 #endif