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"
22 #include <ModelAPI_BodyBuilder.h>
23 #include <Events_Loop.h>
24 #include <ModelAPI_Events.h>
26 ModelAPI_ResultBody::ModelAPI_ResultBody()
29 myConnect = ConnectionNotComputed;
32 ModelAPI_ResultBody::~ModelAPI_ResultBody()
38 std::string ModelAPI_ResultBody::groupName()
43 void ModelAPI_ResultBody::store(const std::shared_ptr<GeomAPI_Shape>& theShape,
44 const bool theIsStoreSameShapes)
46 myBuilder->store(theShape, theIsStoreSameShapes);
47 myConnect = ConnectionNotComputed;
49 static Events_Loop* aLoop = Events_Loop::loop();
50 static Events_ID aRedispEvent = aLoop->eventByName(EVENT_OBJECT_TO_REDISPLAY);
51 static const ModelAPI_EventCreator* aECreator = ModelAPI_EventCreator::get();
52 aECreator->sendUpdated(data()->owner(), aRedispEvent);
55 void ModelAPI_ResultBody::storeGenerated(const std::shared_ptr<GeomAPI_Shape>& theFromShape,
56 const std::shared_ptr<GeomAPI_Shape>& theToShape)
58 myBuilder->storeGenerated(theFromShape, theToShape);
59 myConnect = ConnectionNotComputed;
61 static Events_Loop* aLoop = Events_Loop::loop();
62 static Events_ID aRedispEvent = aLoop->eventByName(EVENT_OBJECT_TO_REDISPLAY);
63 static const ModelAPI_EventCreator* aECreator = ModelAPI_EventCreator::get();
64 aECreator->sendUpdated(data()->owner(), aRedispEvent);
67 void ModelAPI_ResultBody::storeModified(const std::shared_ptr<GeomAPI_Shape>& theOldShape,
68 const std::shared_ptr<GeomAPI_Shape>& theNewShape,
69 const int theDecomposeSolidsTag)
71 myBuilder->storeModified(theOldShape, theNewShape, theDecomposeSolidsTag);
72 myConnect = ConnectionNotComputed;
74 static Events_Loop* aLoop = Events_Loop::loop();
75 static Events_ID aRedispEvent = aLoop->eventByName(EVENT_OBJECT_TO_REDISPLAY);
76 static const ModelAPI_EventCreator* aECreator = ModelAPI_EventCreator::get();
77 aECreator->sendUpdated(data()->owner(), aRedispEvent);
80 void ModelAPI_ResultBody::storeWithoutNaming(const std::shared_ptr<GeomAPI_Shape>& theShape)
82 myBuilder->storeWithoutNaming(theShape);
83 myConnect = ConnectionNotComputed;
85 static Events_Loop* aLoop = Events_Loop::loop();
86 static Events_ID aRedispEvent = aLoop->eventByName(EVENT_OBJECT_TO_REDISPLAY);
87 static const ModelAPI_EventCreator* aECreator = ModelAPI_EventCreator::get();
88 aECreator->sendUpdated(data()->owner(), aRedispEvent);
91 std::shared_ptr<GeomAPI_Shape> ModelAPI_ResultBody::shape()
93 return myBuilder->shape();
96 void ModelAPI_ResultBody::generated(const std::shared_ptr<GeomAPI_Shape>& theNewShape,
97 const std::string& theName, const int theTag)
99 myBuilder->generated(theNewShape, theName, theTag);
102 void ModelAPI_ResultBody::generated(const std::shared_ptr<GeomAPI_Shape>& theOldShape,
103 const std::shared_ptr<GeomAPI_Shape>& theNewShape, const std::string& theName,
106 myBuilder->generated(theOldShape, theNewShape, theName, theTag);
109 void ModelAPI_ResultBody::modified(const std::shared_ptr<GeomAPI_Shape>& theOldShape,
110 const std::shared_ptr<GeomAPI_Shape>& theNewShape, const std::string& theName,
113 myBuilder->modified(theOldShape, theNewShape, theName, theTag);
117 void ModelAPI_ResultBody::deleted(
118 const std::shared_ptr<GeomAPI_Shape>& theOldShape, const int theTag)
120 myBuilder->deleted(theOldShape, theTag);
123 void ModelAPI_ResultBody::loadDeletedShapes (GeomAlgoAPI_MakeShape* theMS,
124 std::shared_ptr<GeomAPI_Shape> theShapeIn,
125 const int theKindOfShape,
128 myBuilder->loadDeletedShapes(theMS, theShapeIn, theKindOfShape, theTag);
131 void ModelAPI_ResultBody::loadAndOrientModifiedShapes (GeomAlgoAPI_MakeShape* theMS,
132 std::shared_ptr<GeomAPI_Shape> theShapeIn, const int theKindOfShape, const int theTag,
133 const std::string& theName, GeomAPI_DataMapOfShapeShape& theSubShapes,
134 const bool theIsStoreSeparate,
135 const bool theIsStoreAsGenerated,
136 const bool /*theSplitInSubs*/)
138 myBuilder->loadAndOrientModifiedShapes(
139 theMS, theShapeIn, theKindOfShape, theTag, theName, theSubShapes, theIsStoreSeparate,
140 theIsStoreAsGenerated);
143 void ModelAPI_ResultBody::loadAndOrientGeneratedShapes (GeomAlgoAPI_MakeShape* theMS,
144 std::shared_ptr<GeomAPI_Shape> theShapeIn, const int theKindOfShape,
145 const int theTag, const std::string& theName, GeomAPI_DataMapOfShapeShape& theSubShapes)
147 myBuilder->loadAndOrientGeneratedShapes(
148 theMS, theShapeIn, theKindOfShape, theTag, theName, theSubShapes);
151 void ModelAPI_ResultBody::loadFirstLevel(std::shared_ptr<GeomAPI_Shape> theShape,
152 const std::string& theName, int& theTag)
154 myBuilder->loadFirstLevel(theShape, theName, theTag);
157 void ModelAPI_ResultBody::loadDisconnectedEdges(std::shared_ptr<GeomAPI_Shape> theShape,
158 const std::string& theName, int& theTag)
160 myBuilder->loadDisconnectedEdges(theShape, theName, theTag);
163 void ModelAPI_ResultBody::loadDisconnectedVertexes(std::shared_ptr<GeomAPI_Shape> theShape,
164 const std::string& theName,int& theTag)
166 myBuilder->loadDisconnectedVertexes(theShape, theName, theTag);
169 bool ModelAPI_ResultBody::isConnectedTopology()
171 if (myConnect == ConnectionNotComputed) {
172 myConnect = shape()->isConnectedTopology() ? IsConnected : IsNotConnected;
174 return myConnect == IsConnected;