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 std::shared_ptr<ModelAPI_Feature> subFeature(const int theIndex, bool forTree = false);
45 /// \return the sub-feature unique identifier in this composite feature by zero-base index.
46 FEATURESPLUGIN_EXPORT virtual int subFeatureId(const int theIndex) const;
48 /// \return true if feature or result belong to this composite feature as subs.
49 FEATURESPLUGIN_EXPORT virtual bool isSub(ObjectPtr theObject) const;
51 /// This method to inform that sub-feature is removed and must be removed from the internal data
52 /// structures of the owner (the remove from the document will be done outside just after).
53 FEATURESPLUGIN_EXPORT virtual void removeFeature(std::shared_ptr<ModelAPI_Feature> theFeature);
55 /// Removes also all sub-sketch.
56 FEATURESPLUGIN_EXPORT virtual void erase();
60 InitSketchLauncher = 1 << 0,
61 InitBaseObjectsList = 1 << 1
64 FeaturesPlugin_CompositeSketch(){};
66 /// Initializes composite sketch attributes.
67 void initCompositeSketchAttribtues(const int theInitFlags);
69 /// Sets the sub-object to list of base.
70 void setSketchObjectToList();
72 /// \brief Returns list of base shapes.
73 /// \param[out] theBaseShapesList list of base shapes (warning: list not cleared).
74 /// \param[in] theIsMakeShells if true make shells from faces with shared edges.
75 void getBaseShapes(ListOfShape& theBaseShapesList, const bool theIsMakeShells = true);
77 /// Checks make shape algo.
78 bool isMakeShapeValid(const std::shared_ptr<GeomAlgoAPI_MakeShape> theMakeShape);
80 /// Stores result of generation.
81 void storeResult(const GeomShapePtr theBaseShape,
82 const std::shared_ptr<GeomAlgoAPI_MakeShape> theMakeShape,
83 const int theIndex = 0);
85 /// Stores generation history.
86 void storeGenerationHistory(ResultBodyPtr theResultBody,
87 const GeomShapePtr theBaseShape,
88 const std::shared_ptr<GeomAlgoAPI_MakeShape> theMakeShape,
91 /// Used to store from and to shapes.
92 void storeShapes(ResultBodyPtr theResultBody,
93 const GeomAPI_Shape::ShapeType theBaseShapeType,
94 const std::shared_ptr<GeomAPI_DataMapOfShapeShape> theMapOfSubShapes,
95 const ListOfShape& theShapes,
96 const std::string theName,