1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
3 // File: FeaturesPlugin_CompositeSketch.h
4 // Created: 11 September 2015
5 // Author: Dmitry Bobylev
7 #ifndef FeaturesPlugin_CompositeSketch_H_
8 #define FeaturesPlugin_CompositeSketch_H_
10 #include "FeaturesPlugin.h"
12 #include <ModelAPI_CompositeFeature.h>
14 #include <ModelAPI_ResultBody.h>
16 /// \class FeaturesPlugin_CompositeSketch
18 /// \brief Interface for the composite sketch feature.
19 class FeaturesPlugin_CompositeSketch : public ModelAPI_CompositeFeature
22 /// Attribute name of sketch feature.
23 inline static const std::string& SKETCH_ID()
25 static const std::string MY_SKETCH_ID("sketch");
29 /// Attribute name of base objects.
30 inline static const std::string& BASE_OBJECTS_ID()
32 static const std::string MY_BASE_OBJECTS_ID("base");
33 return MY_BASE_OBJECTS_ID;
36 /// Appends a feature to the sketch sub-elements container.
37 FEATURESPLUGIN_EXPORT virtual std::shared_ptr<ModelAPI_Feature> addFeature(std::string theID);
39 /// \return the number of sub-elements.
40 FEATURESPLUGIN_EXPORT virtual int numberOfSubs(bool forTree = false) const;
42 /// \return the sub-feature by zero-base index.
43 FEATURESPLUGIN_EXPORT virtual
44 std::shared_ptr<ModelAPI_Feature> subFeature(const int theIndex, bool forTree = false);
46 /// \return the sub-feature unique identifier in this composite feature by zero-base index.
47 FEATURESPLUGIN_EXPORT virtual int subFeatureId(const int theIndex) const;
49 /// \return true if feature or result belong to this composite feature as subs.
50 FEATURESPLUGIN_EXPORT virtual bool isSub(ObjectPtr theObject) const;
52 /// This method to inform that sub-feature is removed and must be removed from the internal data
53 /// structures of the owner (the remove from the document will be done outside just after).
54 FEATURESPLUGIN_EXPORT virtual void removeFeature(std::shared_ptr<ModelAPI_Feature> theFeature);
58 InitSketchLauncher = 1 << 0,
59 InitBaseObjectsList = 1 << 1
62 FeaturesPlugin_CompositeSketch(){};
64 /// Initializes composite sketch attributes.
65 void initCompositeSketchAttribtues(const int theInitFlags);
67 /// \brief Returns list of base shapes.
68 /// \param[out] theBaseShapesList list of base shapes (warning: list not cleared).
69 /// \param[in] theIsMakeShells if true make shells from faces with shared edges.
70 void getBaseShapes(ListOfShape& theBaseShapesList, const bool theIsMakeShells = true);
72 /// Checks make shape algo.
73 bool isMakeShapeValid(const std::shared_ptr<GeomAlgoAPI_MakeShape> theMakeShape);
75 /// Stores result of generation.
76 void storeResult(const GeomShapePtr theBaseShape,
77 const std::shared_ptr<GeomAlgoAPI_MakeShape> theMakeShape,
78 const int theIndex = 0);
80 /// Stores generation history.
81 void storeGenerationHistory(ResultBodyPtr theResultBody,
82 const GeomShapePtr theBaseShape,
83 const std::shared_ptr<GeomAlgoAPI_MakeShape> theMakeShape,
86 /// Used to store from and to shapes.
87 void storeShapes(ResultBodyPtr theResultBody,
88 const GeomAPI_Shape::ShapeType theBaseShapeType,
89 const std::shared_ptr<GeomAPI_DataMapOfShapeShape> theMapOfSubShapes,
90 const ListOfShape& theShapes,
91 const std::string theName,