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()
37 std::string ModelAPI_ResultBody::groupName()
42 void ModelAPI_ResultBody::store(const std::shared_ptr<GeomAPI_Shape>& theShape,
43 const bool theIsStoreSameShapes)
45 myBuilder->store(theShape, theIsStoreSameShapes);
46 myConnect = ConnectionNotComputed;
48 static Events_Loop* aLoop = Events_Loop::loop();
49 static Events_ID aRedispEvent = aLoop->eventByName(EVENT_OBJECT_TO_REDISPLAY);
50 static const ModelAPI_EventCreator* aECreator = ModelAPI_EventCreator::get();
51 aECreator->sendUpdated(data()->owner(), aRedispEvent);
56 void ModelAPI_ResultBody::storeGenerated(const std::shared_ptr<GeomAPI_Shape>& theFromShape,
57 const std::shared_ptr<GeomAPI_Shape>& theToShape)
59 myBuilder->storeGenerated(theFromShape, theToShape);
60 myConnect = ConnectionNotComputed;
62 static Events_Loop* aLoop = Events_Loop::loop();
63 static Events_ID aRedispEvent = aLoop->eventByName(EVENT_OBJECT_TO_REDISPLAY);
64 static const ModelAPI_EventCreator* aECreator = ModelAPI_EventCreator::get();
65 aECreator->sendUpdated(data()->owner(), aRedispEvent);
67 updateSubs(theToShape);
70 void ModelAPI_ResultBody::storeModified(const std::shared_ptr<GeomAPI_Shape>& theOldShape,
71 const std::shared_ptr<GeomAPI_Shape>& theNewShape,
72 const int theDecomposeSolidsTag)
74 myBuilder->storeModified(theOldShape, theNewShape, theDecomposeSolidsTag);
75 myConnect = ConnectionNotComputed;
77 static Events_Loop* aLoop = Events_Loop::loop();
78 static Events_ID aRedispEvent = aLoop->eventByName(EVENT_OBJECT_TO_REDISPLAY);
79 static const ModelAPI_EventCreator* aECreator = ModelAPI_EventCreator::get();
80 aECreator->sendUpdated(data()->owner(), aRedispEvent);
82 updateSubs(theNewShape);
85 void ModelAPI_ResultBody::storeWithoutNaming(const std::shared_ptr<GeomAPI_Shape>& theShape)
87 myBuilder->storeWithoutNaming(theShape);
88 myConnect = ConnectionNotComputed;
90 static Events_Loop* aLoop = Events_Loop::loop();
91 static Events_ID aRedispEvent = aLoop->eventByName(EVENT_OBJECT_TO_REDISPLAY);
92 static const ModelAPI_EventCreator* aECreator = ModelAPI_EventCreator::get();
93 aECreator->sendUpdated(data()->owner(), aRedispEvent);
96 std::shared_ptr<GeomAPI_Shape> ModelAPI_ResultBody::shape()
98 return myBuilder->shape();
101 void ModelAPI_ResultBody::generated(const std::shared_ptr<GeomAPI_Shape>& theNewShape,
102 const std::string& theName, const int theTag)
104 myBuilder->generated(theNewShape, theName, theTag);
107 void ModelAPI_ResultBody::generated(const std::shared_ptr<GeomAPI_Shape>& theOldShape,
108 const std::shared_ptr<GeomAPI_Shape>& theNewShape, const std::string& theName,
111 myBuilder->generated(theOldShape, theNewShape, theName, theTag);
114 void ModelAPI_ResultBody::modified(const std::shared_ptr<GeomAPI_Shape>& theOldShape,
115 const std::shared_ptr<GeomAPI_Shape>& theNewShape, const std::string& theName,
118 myBuilder->modified(theOldShape, theNewShape, theName, theTag);
122 void ModelAPI_ResultBody::deleted(
123 const std::shared_ptr<GeomAPI_Shape>& theOldShape, const int theTag)
125 myBuilder->deleted(theOldShape, theTag);
128 void ModelAPI_ResultBody::loadDeletedShapes(GeomAlgoAPI_MakeShape* theMS,
129 std::shared_ptr<GeomAPI_Shape> theShapeIn,
130 const int theKindOfShape,
133 myBuilder->loadDeletedShapes(theMS, theShapeIn, theKindOfShape, theTag);
136 void ModelAPI_ResultBody::loadAndOrientModifiedShapes(GeomAlgoAPI_MakeShape* theMS,
137 std::shared_ptr<GeomAPI_Shape> theShapeIn, const int theKindOfShape, const int theTag,
138 const std::string& theName, GeomAPI_DataMapOfShapeShape& theSubShapes,
139 const bool theIsStoreSeparate,
140 const bool theIsStoreAsGenerated,
141 const bool /*theSplitInSubs*/)
143 myBuilder->loadAndOrientModifiedShapes(
144 theMS, theShapeIn, theKindOfShape, theTag, theName, theSubShapes, theIsStoreSeparate,
145 theIsStoreAsGenerated);
148 void ModelAPI_ResultBody::loadAndOrientGeneratedShapes(GeomAlgoAPI_MakeShape* theMS,
149 std::shared_ptr<GeomAPI_Shape> theShapeIn, const int theKindOfShape,
150 const int theTag, const std::string& theName, GeomAPI_DataMapOfShapeShape& theSubShapes)
152 myBuilder->loadAndOrientGeneratedShapes(
153 theMS, theShapeIn, theKindOfShape, theTag, theName, theSubShapes);
156 void ModelAPI_ResultBody::loadFirstLevel(std::shared_ptr<GeomAPI_Shape> theShape,
157 const std::string& theName, int& theTag)
159 myBuilder->loadFirstLevel(theShape, theName, theTag);
162 void ModelAPI_ResultBody::loadDisconnectedEdges(std::shared_ptr<GeomAPI_Shape> theShape,
163 const std::string& theName, int& theTag)
165 myBuilder->loadDisconnectedEdges(theShape, theName, theTag);
168 void ModelAPI_ResultBody::loadDisconnectedVertexes(std::shared_ptr<GeomAPI_Shape> theShape,
169 const std::string& theName, int& theTag)
171 myBuilder->loadDisconnectedVertexes(theShape, theName, theTag);
174 bool ModelAPI_ResultBody::isConnectedTopology()
176 if (myConnect == ConnectionNotComputed) {
177 myConnect = shape()->isConnectedTopology() ? IsConnected : IsNotConnected;
179 return myConnect == IsConnected;
182 void ModelAPI_ResultBody::setDisplayed(const bool theDisplay)
184 ModelAPI_Result::setDisplayed(theDisplay);
185 for (int i = 0; i < numberOfSubs(); i++)
186 subResult(i)->setDisplayed(theDisplay);