1 // Copyright (C) 2014-2017 CEA/DEN, EDF R&D
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.
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.
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
17 // See http://www.salome-platform.org/ or
18 // email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
21 #include "ModelAPI_ResultBody.h"
23 #include <ModelAPI_BodyBuilder.h>
24 #include <Events_Loop.h>
25 #include <ModelAPI_Events.h>
27 ModelAPI_ResultBody::ModelAPI_ResultBody()
30 myConnect = ConnectionNotComputed;
33 ModelAPI_ResultBody::~ModelAPI_ResultBody()
39 std::string ModelAPI_ResultBody::groupName()
44 void ModelAPI_ResultBody::store(const std::shared_ptr<GeomAPI_Shape>& theShape,
45 const bool theIsStoreSameShapes)
47 myBuilder->store(theShape, theIsStoreSameShapes);
48 myConnect = ConnectionNotComputed;
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);
58 void ModelAPI_ResultBody::storeGenerated(const std::shared_ptr<GeomAPI_Shape>& theFromShape,
59 const std::shared_ptr<GeomAPI_Shape>& theToShape)
61 myBuilder->storeGenerated(theFromShape, theToShape);
62 myConnect = ConnectionNotComputed;
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);
69 updateSubs(theToShape);
72 void ModelAPI_ResultBody::storeModified(const std::shared_ptr<GeomAPI_Shape>& theOldShape,
73 const std::shared_ptr<GeomAPI_Shape>& theNewShape,
74 const int theDecomposeSolidsTag)
76 myBuilder->storeModified(theOldShape, theNewShape, theDecomposeSolidsTag);
77 myConnect = ConnectionNotComputed;
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);
84 updateSubs(theNewShape);
87 void ModelAPI_ResultBody::storeWithoutNaming(const std::shared_ptr<GeomAPI_Shape>& theShape)
89 myBuilder->storeWithoutNaming(theShape);
90 myConnect = ConnectionNotComputed;
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);
98 std::shared_ptr<GeomAPI_Shape> ModelAPI_ResultBody::shape()
100 return myBuilder->shape();
103 void ModelAPI_ResultBody::generated(const std::shared_ptr<GeomAPI_Shape>& theNewShape,
104 const std::string& theName, const int theTag)
106 myBuilder->generated(theNewShape, theName, theTag);
109 void ModelAPI_ResultBody::generated(const std::shared_ptr<GeomAPI_Shape>& theOldShape,
110 const std::shared_ptr<GeomAPI_Shape>& theNewShape, const std::string& theName,
113 myBuilder->generated(theOldShape, theNewShape, theName, theTag);
116 void ModelAPI_ResultBody::modified(const std::shared_ptr<GeomAPI_Shape>& theOldShape,
117 const std::shared_ptr<GeomAPI_Shape>& theNewShape, const std::string& theName,
120 myBuilder->modified(theOldShape, theNewShape, theName, theTag);
124 void ModelAPI_ResultBody::deleted(
125 const std::shared_ptr<GeomAPI_Shape>& theOldShape, const int theTag)
127 myBuilder->deleted(theOldShape, theTag);
130 void ModelAPI_ResultBody::loadDeletedShapes(GeomAlgoAPI_MakeShape* theMS,
131 std::shared_ptr<GeomAPI_Shape> theShapeIn,
132 const int theKindOfShape,
135 myBuilder->loadDeletedShapes(theMS, theShapeIn, theKindOfShape, theTag);
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*/)
145 myBuilder->loadAndOrientModifiedShapes(
146 theMS, theShapeIn, theKindOfShape, theTag, theName, theSubShapes, theIsStoreSeparate,
147 theIsStoreAsGenerated);
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)
154 myBuilder->loadAndOrientGeneratedShapes(
155 theMS, theShapeIn, theKindOfShape, theTag, theName, theSubShapes);
158 void ModelAPI_ResultBody::loadFirstLevel(std::shared_ptr<GeomAPI_Shape> theShape,
159 const std::string& theName, int& theTag)
161 myBuilder->loadFirstLevel(theShape, theName, theTag);
164 void ModelAPI_ResultBody::loadDisconnectedEdges(std::shared_ptr<GeomAPI_Shape> theShape,
165 const std::string& theName, int& theTag)
167 myBuilder->loadDisconnectedEdges(theShape, theName, theTag);
170 void ModelAPI_ResultBody::loadDisconnectedVertexes(std::shared_ptr<GeomAPI_Shape> theShape,
171 const std::string& theName, int& theTag)
173 myBuilder->loadDisconnectedVertexes(theShape, theName, theTag);
176 bool ModelAPI_ResultBody::isConnectedTopology()
178 if (myConnect == ConnectionNotComputed) {
179 myConnect = shape()->isConnectedTopology() ? IsConnected : IsNotConnected;
181 return myConnect == IsConnected;
184 void ModelAPI_ResultBody::setDisplayed(const bool theDisplay)
186 ModelAPI_Result::setDisplayed(theDisplay);
187 for (int i = 0; i < numberOfSubs(); i++)
188 subResult(i)->setDisplayed(theDisplay);