Salome HOME
Remove of unused methods from the BodyBuilder
[modules/shaper.git] / src / Model / Model_BodyBuilder.h
1 // Copyright (C) 2014-2017  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
18 // email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
19 //
20
21 #ifndef Model_BodyBuilder_H_
22 #define Model_BodyBuilder_H_
23
24 #include "Model.h"
25 #include <ModelAPI_BodyBuilder.h>
26
27 #include <GeomAlgoAPI_MakeShape.h>
28 #include <GeomAPI_DataMapOfShapeShape.h>
29 #include <vector>
30
31 class TNaming_Builder;
32
33 /**\class Model_BodyBuilder
34  * \ingroup DataModel
35  * \brief Extra API for the ResultBody that allows to work with naming.
36  */
37 class Model_BodyBuilder : public ModelAPI_BodyBuilder
38 {
39   /// builders that store the naming history: one per label to allow store several shapes to one
40   /// label; index in vector corresponds to the label tag
41   std::map<int, TNaming_Builder*> myBuilders;
42 public:
43   /// Stores the shape (called by the execution method).
44   MODEL_EXPORT virtual void store(const GeomShapePtr& theShape,
45                                   const bool theIsStoreSameShapes = true);
46
47   /// Stores the generated shape (called by the execution method).
48   MODEL_EXPORT virtual void storeGenerated(const GeomShapePtr& theFromShape,
49                                            const GeomShapePtr& theToShape);
50
51   /// Stores the modified shape (called by the execution method).
52   /// \param theOldShape shape that produces result
53   /// \param theNewShape resulting shape
54   /// \param theDecomposeSolidsTag tag for starting of solids sub-elements placement in case
55   ///          theNewShape is compound of solids, if zero it is not used
56   MODEL_EXPORT virtual void storeModified(const GeomShapePtr& theOldShape,
57                                           const GeomShapePtr& theNewShape,
58                                           const bool theIsCleanStored = true) override;
59
60   /// Returns the shape-result produced by this feature
61   MODEL_EXPORT virtual GeomShapePtr shape();
62
63   /// Records the subshape newShape which was generated during a topological construction.
64   /// As an example, consider the case of a face generated in construction of a box.
65   /// Returns true if it is stored correctly (the final shape contains this new sub-shape)
66   MODEL_EXPORT virtual bool generated(const GeomShapePtr& theNewShape,
67     const std::string& theName, const bool theCheckIsInResult = true) override;
68
69   /// Records the shape newShape which was generated from the shape oldShape during a topological
70   /// construction. As an example, consider the case of a face generated from an edge in
71   /// construction of a prism.
72   MODEL_EXPORT virtual void generated(const GeomShapePtr& theOldShape,
73                                       const GeomShapePtr& theNewShape,
74                                       const std::string& theName = "") override;
75
76
77   /// Records the shape newShape which is a modification of the shape oldShape.
78   /// As an example, consider the case of a face split or merged in a Boolean operation.
79   MODEL_EXPORT virtual void modified(const GeomShapePtr& theOldShape,
80                                      const GeomShapePtr& theNewShape,
81                                      const std::string& theName = "") override;
82
83   /// load deleted shapes
84   MODEL_EXPORT
85   virtual void loadDeletedShapes(const GeomMakeShapePtr& theAlgo,
86                                  const GeomShapePtr& theOldShape,
87                                  const GeomAPI_Shape::ShapeType theShapeTypeToExplore,
88                                  const GeomShapePtr& theShapesToExclude = GeomShapePtr()) override;
89
90   /// load and orient modified shapes
91   MODEL_EXPORT
92   virtual void loadModifiedShapes(const GeomMakeShapePtr& theAlgo,
93                                   const GeomShapePtr& theOldShape,
94                                   const GeomAPI_Shape::ShapeType theShapeTypeToExplore,
95                                   const std::string& theName = "") override;
96
97   /// load and orient generated shapes
98   MODEL_EXPORT
99   virtual void loadGeneratedShapes(const GeomMakeShapePtr& theAlgo,
100                                    const GeomShapePtr& theOldShape,
101                                    const GeomAPI_Shape::ShapeType theShapeTypeToExplore,
102                                    const std::string& theName = "") override;
103
104   /// Loads shapes of the first level (to be used during shape import)
105   MODEL_EXPORT virtual void loadFirstLevel(GeomShapePtr theShape,
106                                            const std::string& theName) override;
107
108   /// Removes the stored builders
109   MODEL_EXPORT virtual ~Model_BodyBuilder();
110
111 protected:
112   /// Default constructor accessible only by Model_Objects
113   Model_BodyBuilder(ModelAPI_Object* theOwner);
114
115   /// Removes the stored builders
116   void clean();
117
118   /// Returns (creates if necessary) the builder created on the needed tag of sub-label
119   TNaming_Builder* builder(const int theTag);
120
121 private:
122   /// Loads shapes of the next level (to be used during shape import)
123   void loadNextLevels(GeomShapePtr theShape,
124                       const std::string& theName);
125
126   /// builds name for the shape kept at the specified tag
127   void buildName(const int theTag, const std::string& theName);
128
129 private:
130   struct IndexTags {
131     int index;
132     std::vector<int> tags;
133   };
134
135 private:
136   int myFreePrimitiveTag;
137   std::map<std::string, IndexTags> myPrimitivesNamesIndexMap;
138
139 private:
140   friend class Model_ResultBody;
141   friend class Model_ResultCompSolid;
142 };
143
144 #endif