]> SALOME platform Git repositories - modules/shaper.git/blob - src/Model/Model_ResultBody.h
Salome HOME
Update copyrights
[modules/shaper.git] / src / Model / Model_ResultBody.h
1 // Copyright (C) 2014-2019  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 Model_ResultBody_H_
21 #define Model_ResultBody_H_
22
23 #include "Model.h"
24 #include <ModelAPI_ResultBody.h>
25 #include <vector>
26 #include <map>
27
28 /**\class Model_ResultBody
29 * \ingroup DataModel
30 * \brief The body (shape) result of a feature.
31 *
32 * Provides a shape that may be displayed in the viewer.
33 * May provide really huge results, so, working with this kind
34 * of result must be optimized.
35 * Also provides a container of sub-body result in case it is compound or compsolid.
36 */
37 class Model_ResultBody : public ModelAPI_ResultBody
38 {
39   /// Sub-bodies if this is compsolid or compound: zero-based index to subs
40   std::vector<ResultBodyPtr> mySubs;
41   /// Also keep map of result to index in mySubs to facilitate speed of access from OB
42   std::map<ObjectPtr, int> mySubsMap;
43   /// Keeps the last state of the concealment flag in order to update it when needed.
44   bool myLastConcealed;
45
46 public:
47
48   /// Removes the stored builders
49   MODEL_EXPORT virtual ~Model_ResultBody();
50
51   /// Records the subshape newShape which was generated during a topological construction.
52   /// As an example, consider the case of a face generated in construction of a box.
53   MODEL_EXPORT virtual bool generated(const GeomShapePtr& theNewShape,
54     const std::string& theName, const bool theCheckIsInResult = true) override;
55
56   /// load generated shapes
57   MODEL_EXPORT
58   virtual void loadGeneratedShapes(const std::shared_ptr<GeomAlgoAPI_MakeShape>& theAlgo,
59                                    const GeomShapePtr& theOldShape,
60                                    const GeomAPI_Shape::ShapeType theShapeTypeToExplore,
61                                    const std::string& theName = "") override;
62
63   /// load modified shapes for sub-objects
64   MODEL_EXPORT
65   virtual void loadModifiedShapes(const std::shared_ptr<GeomAlgoAPI_MakeShape>& theAlgo,
66                                   const GeomShapePtr& theOldShape,
67                                   const GeomAPI_Shape::ShapeType theShapeTypeToExplore,
68                                   const std::string& theName = "") override;
69
70
71   /// Returns the number of sub-elements
72   MODEL_EXPORT virtual int numberOfSubs(bool forTree = false) const;
73
74   /// Returns the sub-result by zero-base index
75   MODEL_EXPORT virtual ResultBodyPtr subResult(const int theIndex,
76     bool forTree = false) const;
77
78   /// Returns true if feature or result belong to this composite feature as subs
79   /// Returns theIndex - zero based index of sub if found
80   MODEL_EXPORT virtual bool isSub(ObjectPtr theObject, int& theIndex) const;
81
82   /// Returns the parameters of color definition in the resources configuration manager
83   MODEL_EXPORT virtual void colorConfigInfo(std::string& theSection, std::string& theName,
84                                             std::string& theDefault);
85
86   /// Disables the result body: keeps the resulting shape as selection, but erases the underlaying
87   /// naming data structure if theFlag if false. Or restores every  thing on theFlag is true.
88   MODEL_EXPORT virtual bool setDisabled(std::shared_ptr<ModelAPI_Result> theThis,
89     const bool theFlag);
90
91   /// The compsolid is concealed if at least one of the sub is concealed
92   MODEL_EXPORT virtual bool isConcealed();
93
94   /// Sets all subs as concealed in the data tree (referenced by other objects)
95   MODEL_EXPORT virtual void setIsConcealed(const bool theValue);
96
97   /// Returns true is the topology is connected.
98   MODEL_EXPORT virtual bool isConnectedTopology();
99
100   /// Cleans cash related to the already stored elements
101   MODEL_EXPORT virtual void cleanCash() override;
102
103 protected:
104   /// Makes a body on the given feature
105   Model_ResultBody();
106
107   /// Updates the sub-bodies if shape of this object is composite-solid
108   void updateSubs(const std::shared_ptr<GeomAPI_Shape>& theThisShape,
109                   const bool theShapeChanged = true);
110
111   // Checks the state of children and parents to send events of creation/erase when needed
112   void updateConcealment();
113
114   friend class Model_Objects;
115 };
116
117 #endif