1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
3 // File: ModelAPI_ResultConstruction.hxx
4 // Created: 07 Jul 2014
5 // Author: Mikhail PONIKAROV
7 #ifndef Model_ResultConstruction_H_
8 #define Model_ResultConstruction_H_
11 #include <ModelAPI_ResultConstruction.h>
14 class ModelAPI_Document;
17 /**\class Model_ResultConstruction
19 * \brief The construction element result of a feature.
21 * Provides a shape that may be displayed in the viewer.
22 * Intermediate, light result that in many cases produces a result on the fly.
24 class Model_ResultConstruction : public ModelAPI_ResultConstruction
26 std::shared_ptr<ModelAPI_Feature> myOwner; ///< owner of this result
27 std::shared_ptr<GeomAPI_Shape> myShape; ///< shape of this result created "on the fly"
28 bool myFacesUpToDate; ///< is true if faces in myuFaces are computed and up to date
29 /// stores the up to date faces if they exist
30 std::vector<std::shared_ptr<GeomAPI_Face> > myFaces;
34 /// Retuns the parameters of color definition in the resources config manager
35 MODEL_EXPORT virtual void colorConfigInfo(std::string& theSection, std::string& theName,
36 std::string& theDefault);
38 /// By default object is displayed in the object browser.
39 MODEL_EXPORT virtual bool isInHistory()
45 MODEL_EXPORT virtual void setShape(std::shared_ptr<GeomAPI_Shape> theShape);
46 /// Returns the shape-result produced by this feature
47 MODEL_EXPORT virtual std::shared_ptr<GeomAPI_Shape> shape();
49 /// Sets the flag that it must be displayed in history (default is true)
50 MODEL_EXPORT virtual void setIsInHistory(const bool myIsInHistory);
52 /// if the construction result may be used as faces, this method returns not zero number of faces
53 MODEL_EXPORT virtual int facesNum();
54 /// if the construction result may be used as faces, this method returns face by zero based index
55 MODEL_EXPORT virtual std::shared_ptr<GeomAPI_Face> face(const int theIndex);
57 /// By default object is not infinite.
58 MODEL_EXPORT virtual bool isInfinite();
59 /// Sets the flag that it is infinite
60 MODEL_EXPORT virtual void setInfinite(const bool theInfinite);
61 /// The construction element is never concealed
62 MODEL_EXPORT virtual void setIsConcealed(const bool theValue);
64 // methods related to selection of sub-shapes in construction, used by SelectionAttribute
66 /// Selects theSubShape in the construction. Returns an index of the selected sub-shape.
67 /// Puts the selected shape with a needed BRepNaming sub-structure to the data tree of result.
68 /// If theSubShape is null, it selects the whole construction and returns zero index.
69 /// If theIndex is not -1, it re-selects over the existing data (used for update selection).
70 /// If theExtDoc is document where this selection is needed, if it differs from this,
71 /// naming structures will be located there.
72 int select(const std::shared_ptr<GeomAPI_Shape>& theSubShape,
73 const std::shared_ptr<ModelAPI_Document> theExtDoc, const int theIndex = -1);
75 /// Returns already selected shape by the given index. Zero index means the whole construction,
76 /// so, the returned shape in this case is null.
77 /// If theExtDoc is document where this selection is needed, if it differs from this,
78 /// naming structures will be located there.
79 std::shared_ptr<GeomAPI_Shape> shape(const int theIndex,
80 const std::shared_ptr<ModelAPI_Document> theExtDoc);
82 /// Updates the existing selection by the index.
83 /// Returns false if update is failed. Returns theModified true if the selection was updated.
84 /// If theExtDoc is document where this selection is needed, if it differs from this,
85 /// naming structures will be updated there.
86 bool update(const int theIndex, const std::shared_ptr<ModelAPI_Document> theExtDoc,
90 /// Makes a body on the given feature
91 Model_ResultConstruction();
93 /// Searchies for the working label selection/update will start from
94 /// Returns true if this is label of the external document.
95 /// theExtDoc is document where this selection is required
96 TDF_Label startLabel(const std::shared_ptr<ModelAPI_Document> theExtDoc, bool& theExternal);
98 friend class Model_Objects;