]> SALOME platform Git repositories - modules/shaper.git/blob - src/ModelAPI/ModelAPI_ResultBody.cpp
Salome HOME
Initial implementation of support of any level of hierarchy in Result Bodies.
[modules/shaper.git] / src / ModelAPI / ModelAPI_ResultBody.cpp
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 #include "ModelAPI_ResultBody.h"
22
23 #include <ModelAPI_BodyBuilder.h>
24 #include <Events_Loop.h>
25 #include <ModelAPI_Events.h>
26
27 ModelAPI_ResultBody::ModelAPI_ResultBody()
28   : myBuilder(0)
29 {
30   myConnect = ConnectionNotComputed;
31 }
32
33 ModelAPI_ResultBody::~ModelAPI_ResultBody()
34 {
35   if (myBuilder)
36     delete myBuilder;
37 }
38
39 std::string ModelAPI_ResultBody::groupName()
40 {
41   return group();
42 }
43
44 void ModelAPI_ResultBody::store(const std::shared_ptr<GeomAPI_Shape>& theShape,
45   const bool theIsStoreSameShapes)
46 {
47   myBuilder->store(theShape, theIsStoreSameShapes);
48   myConnect = ConnectionNotComputed;
49
50   static Events_Loop* aLoop = Events_Loop::loop();
51   static Events_ID aRedispEvent = aLoop->eventByName(EVENT_OBJECT_TO_REDISPLAY);
52   static const ModelAPI_EventCreator* aECreator = ModelAPI_EventCreator::get();
53   aECreator->sendUpdated(data()->owner(), aRedispEvent);
54
55   updateSubs(theShape);
56 }
57
58 void ModelAPI_ResultBody::storeGenerated(const std::shared_ptr<GeomAPI_Shape>& theFromShape,
59   const std::shared_ptr<GeomAPI_Shape>& theToShape)
60 {
61   myBuilder->storeGenerated(theFromShape, theToShape);
62   myConnect = ConnectionNotComputed;
63
64   static Events_Loop* aLoop = Events_Loop::loop();
65   static Events_ID aRedispEvent = aLoop->eventByName(EVENT_OBJECT_TO_REDISPLAY);
66   static const ModelAPI_EventCreator* aECreator = ModelAPI_EventCreator::get();
67   aECreator->sendUpdated(data()->owner(), aRedispEvent);
68
69   updateSubs(theToShape);
70 }
71
72 void ModelAPI_ResultBody::storeModified(const std::shared_ptr<GeomAPI_Shape>& theOldShape,
73   const std::shared_ptr<GeomAPI_Shape>& theNewShape,
74   const int theDecomposeSolidsTag)
75 {
76   myBuilder->storeModified(theOldShape, theNewShape, theDecomposeSolidsTag);
77   myConnect = ConnectionNotComputed;
78
79   static Events_Loop* aLoop = Events_Loop::loop();
80   static Events_ID aRedispEvent = aLoop->eventByName(EVENT_OBJECT_TO_REDISPLAY);
81   static const ModelAPI_EventCreator* aECreator = ModelAPI_EventCreator::get();
82   aECreator->sendUpdated(data()->owner(), aRedispEvent);
83
84   updateSubs(theNewShape);
85 }
86
87 void ModelAPI_ResultBody::storeWithoutNaming(const std::shared_ptr<GeomAPI_Shape>& theShape)
88 {
89   myBuilder->storeWithoutNaming(theShape);
90   myConnect = ConnectionNotComputed;
91
92   static Events_Loop* aLoop = Events_Loop::loop();
93   static Events_ID aRedispEvent = aLoop->eventByName(EVENT_OBJECT_TO_REDISPLAY);
94   static const ModelAPI_EventCreator* aECreator = ModelAPI_EventCreator::get();
95   aECreator->sendUpdated(data()->owner(), aRedispEvent);
96 }
97
98 std::shared_ptr<GeomAPI_Shape> ModelAPI_ResultBody::shape()
99 {
100   return myBuilder->shape();
101 }
102
103 void ModelAPI_ResultBody::generated(const std::shared_ptr<GeomAPI_Shape>& theNewShape,
104   const std::string& theName, const int theTag)
105 {
106   myBuilder->generated(theNewShape, theName, theTag);
107 }
108
109 void ModelAPI_ResultBody::generated(const std::shared_ptr<GeomAPI_Shape>& theOldShape,
110   const std::shared_ptr<GeomAPI_Shape>& theNewShape, const std::string& theName,
111   const int theTag)
112 {
113   myBuilder->generated(theOldShape, theNewShape, theName, theTag);
114 }
115
116 void ModelAPI_ResultBody::modified(const std::shared_ptr<GeomAPI_Shape>& theOldShape,
117   const std::shared_ptr<GeomAPI_Shape>& theNewShape, const std::string& theName,
118   const int theTag)
119 {
120   myBuilder->modified(theOldShape, theNewShape, theName, theTag);
121 }
122
123
124 void ModelAPI_ResultBody::deleted(
125   const std::shared_ptr<GeomAPI_Shape>& theOldShape, const int theTag)
126 {
127   myBuilder->deleted(theOldShape, theTag);
128 }
129
130 void ModelAPI_ResultBody::loadDeletedShapes(GeomAlgoAPI_MakeShape* theMS,
131   std::shared_ptr<GeomAPI_Shape>  theShapeIn,
132   const int  theKindOfShape,
133   const int  theTag)
134 {
135   myBuilder->loadDeletedShapes(theMS, theShapeIn, theKindOfShape, theTag);
136 }
137
138 void ModelAPI_ResultBody::loadAndOrientModifiedShapes(GeomAlgoAPI_MakeShape* theMS,
139   std::shared_ptr<GeomAPI_Shape>  theShapeIn, const int  theKindOfShape, const int  theTag,
140   const std::string& theName, GeomAPI_DataMapOfShapeShape& theSubShapes,
141   const bool theIsStoreSeparate,
142   const bool theIsStoreAsGenerated,
143   const bool /*theSplitInSubs*/)
144 {
145   myBuilder->loadAndOrientModifiedShapes(
146     theMS, theShapeIn, theKindOfShape, theTag, theName, theSubShapes, theIsStoreSeparate,
147     theIsStoreAsGenerated);
148 }
149
150 void ModelAPI_ResultBody::loadAndOrientGeneratedShapes(GeomAlgoAPI_MakeShape* theMS,
151   std::shared_ptr<GeomAPI_Shape>  theShapeIn, const int  theKindOfShape,
152   const int  theTag, const std::string& theName, GeomAPI_DataMapOfShapeShape& theSubShapes)
153 {
154   myBuilder->loadAndOrientGeneratedShapes(
155     theMS, theShapeIn, theKindOfShape, theTag, theName, theSubShapes);
156 }
157
158 void ModelAPI_ResultBody::loadFirstLevel(std::shared_ptr<GeomAPI_Shape> theShape,
159   const std::string& theName, int&  theTag)
160 {
161   myBuilder->loadFirstLevel(theShape, theName, theTag);
162 }
163
164 void ModelAPI_ResultBody::loadDisconnectedEdges(std::shared_ptr<GeomAPI_Shape> theShape,
165   const std::string& theName, int&  theTag)
166 {
167   myBuilder->loadDisconnectedEdges(theShape, theName, theTag);
168 }
169
170 void ModelAPI_ResultBody::loadDisconnectedVertexes(std::shared_ptr<GeomAPI_Shape> theShape,
171   const std::string& theName, int&  theTag)
172 {
173   myBuilder->loadDisconnectedVertexes(theShape, theName, theTag);
174 }
175
176 bool ModelAPI_ResultBody::isConnectedTopology()
177 {
178   if (myConnect == ConnectionNotComputed) {
179     myConnect = shape()->isConnectedTopology() ? IsConnected : IsNotConnected;
180   }
181   return myConnect == IsConnected;
182 }
183
184 void ModelAPI_ResultBody::setDisplayed(const bool theDisplay)
185 {
186   ModelAPI_Result::setDisplayed(theDisplay);
187   for (int i = 0; i < numberOfSubs(); i++)
188     subResult(i)->setDisplayed(theDisplay);
189 }