From: mpv Date: Tue, 18 Sep 2018 07:21:38 +0000 (+0300) Subject: Issue #2615 : EDF 2018-3 Sub-results states X-Git-Tag: V9_2_0a1~28 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=22d52a8110982f722b4fb46f762a8ed851fc108e;p=modules%2Fshaper.git Issue #2615 : EDF 2018-3 Sub-results states Keep the connected compounds information. --- diff --git a/src/Model/Model_Data.h b/src/Model/Model_Data.h index 8d12bc4d3..598193cb8 100644 --- a/src/Model/Model_Data.h +++ b/src/Model/Model_Data.h @@ -96,6 +96,7 @@ class Model_Data : public ModelAPI_Data friend class Model_ValidatorsFactory; friend class Model_SelectionNaming; friend class Model_ResultConstruction; + friend class Model_ResultBody; public: /// The simplest constructor. "setLabel" must be called just after to initialize correctly. diff --git a/src/Model/Model_Objects.cpp b/src/Model/Model_Objects.cpp index 1b8dad602..70183795c 100644 --- a/src/Model/Model_Objects.cpp +++ b/src/Model/Model_Objects.cpp @@ -1903,7 +1903,7 @@ void Model_Objects::updateResults(FeaturePtr theFeature, std::set& t for (; aResSize && aRes != theFeature->results().cend(); aRes++, aResSize++) { if ((*aRes)->data()->isValid() && (*aRes)->groupName() == ModelAPI_ResultBody::group()) { ResultBodyPtr aBody = std::dynamic_pointer_cast(*aRes); - aBody->updateSubs(aBody->shape()); + aBody->updateSubs(aBody->shape(), false); } } } diff --git a/src/Model/Model_ResultBody.cpp b/src/Model/Model_ResultBody.cpp index c68a4ae4b..514b0406d 100644 --- a/src/Model/Model_ResultBody.cpp +++ b/src/Model/Model_ResultBody.cpp @@ -27,11 +27,17 @@ #include #include #include +#include #include #include #include +#include +// if this attribute exists, the shape is connected topology +Standard_GUID kIsConnectedTopology("e51392e0-3a4d-405d-8e36-bbfe19858ef5"); +// if this attribute exists, the connected topology flag must be recomputed +Standard_GUID kUpdateConnectedTopology("01ef7a45-0bec-4266-b0b4-4aa570921818"); Model_ResultBody::Model_ResultBody() : ModelAPI_ResultBody() { @@ -121,7 +127,7 @@ bool Model_ResultBody::setDisabled(std::shared_ptr theThis, con bool aChanged = ModelAPI_ResultBody::setDisabled(theThis, theFlag); if (aChanged) { // state is changed, so modifications are needed myBuilder->evolutionToSelection(theFlag); - updateSubs(shape()); // to set disabled/enabled + updateSubs(shape(), false); // to set disabled/enabled } return aChanged; } @@ -192,12 +198,20 @@ void Model_ResultBody::updateConcealment() } } -void Model_ResultBody::updateSubs(const std::shared_ptr& theThisShape) +void Model_ResultBody::updateSubs(const std::shared_ptr& theThisShape, + const bool theShapeChanged) { static Events_Loop* aLoop = Events_Loop::loop(); static Events_ID EVENT_DISP = aLoop->eventByName(EVENT_OBJECT_TO_REDISPLAY); static Events_ID EVENT_UPD = aLoop->eventByName(EVENT_OBJECT_UPDATED); static const ModelAPI_EventCreator* aECreator = ModelAPI_EventCreator::get(); + // erase flag that topology is connected: the shape is new + if (theShapeChanged && data().get()) { + TDF_Label aDataLab = std::dynamic_pointer_cast(data())->label(); + if (!aDataLab.IsNull()) { + TDataStd_UAttribute::Set(aDataLab, kUpdateConnectedTopology); + } + } // iterate all sub-solids of compsolid to make sub-results synchronized with them TopoDS_Shape aThisShape; if (theThisShape.get()) aThisShape = theThisShape->impl(); @@ -269,3 +283,21 @@ bool Model_ResultBody::isLatestEqual(const std::shared_ptr& theSh } return false; } + +bool Model_ResultBody::isConnectedTopology() +{ + TDF_Label aDataLab = std::dynamic_pointer_cast(data())->label(); + if (!aDataLab.IsNull()) { + if (aDataLab.IsAttribute(kUpdateConnectedTopology)) { // recompute state + aDataLab.ForgetAttribute(kUpdateConnectedTopology); + GeomShapePtr aShape = shape(); + if (aShape.get() && aShape->isConnectedTopology()) { + TDataStd_UAttribute::Set(aDataLab, kIsConnectedTopology); + } else { + aDataLab.ForgetAttribute(kIsConnectedTopology); + } + } + return aDataLab.IsAttribute(kIsConnectedTopology); + } + return false; // invalid case +} diff --git a/src/Model/Model_ResultBody.h b/src/Model/Model_ResultBody.h index ad5f1c531..6047bc059 100644 --- a/src/Model/Model_ResultBody.h +++ b/src/Model/Model_ResultBody.h @@ -87,12 +87,16 @@ public: // is equal to the given shape MODEL_EXPORT virtual bool isLatestEqual(const std::shared_ptr& theShape); + /// Returns true is the topology is connected. + MODEL_EXPORT virtual bool isConnectedTopology(); + protected: /// Makes a body on the given feature Model_ResultBody(); /// Updates the sub-bodies if shape of this object is composite-solid - void updateSubs(const std::shared_ptr& theThisShape); + void updateSubs(const std::shared_ptr& theThisShape, + const bool theShapeChanged = true); // Checks the state of children and partents to send events of creation/erase when needed void updateConcealment(); diff --git a/src/ModelAPI/ModelAPI_ResultBody.h b/src/ModelAPI/ModelAPI_ResultBody.h index 049e82175..cb17e6522 100644 --- a/src/ModelAPI/ModelAPI_ResultBody.h +++ b/src/ModelAPI/ModelAPI_ResultBody.h @@ -170,16 +170,16 @@ public: // is equal to the given shape MODELAPI_EXPORT virtual bool isLatestEqual(const std::shared_ptr& theShape) = 0; - /// Returns true is the topology is connected. Cashes this information for the current shape, - /// so it is more effective to use this method than directly GeomAPI_Shape. - MODELAPI_EXPORT virtual bool isConnectedTopology(); + /// Returns true is the topology is connected. + MODELAPI_EXPORT virtual bool isConnectedTopology() = 0; /// Set displayed flag to the result and all sub results /// \param theDisplay a boolean value MODELAPI_EXPORT virtual void setDisplayed(const bool theDisplay); /// Updates the sub-bodies if shape of this object is compsolid or compound - MODELAPI_EXPORT virtual void updateSubs(const std::shared_ptr& theThisShape) = 0; + MODELAPI_EXPORT virtual void updateSubs(const std::shared_ptr& theThisShape, + const bool theShapeChanged = true) = 0; protected: /// Default constructor accessible only from Model_Objects