From f2462e26e4c9e0b9d550f949022f7830468a7414 Mon Sep 17 00:00:00 2001 From: drochalo Date: Thu, 26 Oct 2023 11:43:19 +0100 Subject: [PATCH] 0032487: Visualization - synchronize myHasEntityWithPersistence with such entities number Changed myHasEntityWithPersistence to a counter. Renamed variable to myNbEntityWithPersistence. Modified HasEntityWithPersistence() method. Modified logical test in SelectMgr_ViewerSelector::traverseObject. --- src/SelectMgr/SelectMgr_SensitiveEntitySet.cxx | 16 ++++++++++------ src/SelectMgr/SelectMgr_SensitiveEntitySet.hxx | 8 ++++---- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/src/SelectMgr/SelectMgr_SensitiveEntitySet.cxx b/src/SelectMgr/SelectMgr_SensitiveEntitySet.cxx index 209d9f9b55..5f853514b7 100644 --- a/src/SelectMgr/SelectMgr_SensitiveEntitySet.cxx +++ b/src/SelectMgr/SelectMgr_SensitiveEntitySet.cxx @@ -28,7 +28,7 @@ IMPLEMENT_STANDARD_RTTIEXT(SelectMgr_SensitiveEntitySet, BVH_PrimitiveSet3d) SelectMgr_SensitiveEntitySet::SelectMgr_SensitiveEntitySet (const Handle(Select3D_BVHBuilder3d)& theBuilder) : BVH_PrimitiveSet3d (theBuilder) { - // + myNbEntityWithPersistence = 0; } //======================================================================= @@ -42,7 +42,6 @@ void SelectMgr_SensitiveEntitySet::Append (const Handle(SelectMgr_SensitiveEntit theEntity->ResetSelectionActiveStatus(); return; } - const Standard_Integer anExtent = mySensitives.Extent(); if (mySensitives.Add (theEntity) > anExtent) { @@ -50,7 +49,7 @@ void SelectMgr_SensitiveEntitySet::Append (const Handle(SelectMgr_SensitiveEntit } if (!theEntity->BaseSensitive()->TransformPersistence().IsNull()) { - myHasEntityWithPersistence = Standard_True; + ++myNbEntityWithPersistence; } MarkDirty(); } @@ -78,7 +77,7 @@ void SelectMgr_SensitiveEntitySet::Append (const Handle(SelectMgr_Selection)& th } if (!aSensEnt->BaseSensitive()->TransformPersistence().IsNull()) { - myHasEntityWithPersistence = Standard_True; + ++myNbEntityWithPersistence; } } MarkDirty(); @@ -93,7 +92,8 @@ void SelectMgr_SensitiveEntitySet::Remove (const Handle(SelectMgr_Selection)& th { for (NCollection_Vector::Iterator aSelEntIter (theSelection->Entities()); aSelEntIter.More(); aSelEntIter.Next()) { - const Standard_Integer anEntIdx = mySensitives.FindIndex (aSelEntIter.Value()); + const Handle(SelectMgr_SensitiveEntity)& aSensEnt = aSelEntIter.Value(); + const Standard_Integer anEntIdx = mySensitives.FindIndex (aSensEnt); if (anEntIdx == 0) { continue; @@ -103,9 +103,13 @@ void SelectMgr_SensitiveEntitySet::Remove (const Handle(SelectMgr_Selection)& th { Swap (anEntIdx - 1, mySensitives.Size() - 1); } + if (!aSensEnt->BaseSensitive()->TransformPersistence().IsNull()) + { + --myNbEntityWithPersistence; + } mySensitives.RemoveLast(); - removeOwner (aSelEntIter.Value()->BaseSensitive()->OwnerId()); + removeOwner (aSensEnt->BaseSensitive()->OwnerId()); } MarkDirty(); diff --git a/src/SelectMgr/SelectMgr_SensitiveEntitySet.hxx b/src/SelectMgr/SelectMgr_SensitiveEntitySet.hxx index 41cf732333..01752fd2f3 100644 --- a/src/SelectMgr/SelectMgr_SensitiveEntitySet.hxx +++ b/src/SelectMgr/SelectMgr_SensitiveEntitySet.hxx @@ -77,7 +77,7 @@ public: const SelectMgr_MapOfOwners& Owners() const { return myOwnersMap; } //! Returns map of entities. - Standard_Boolean HasEntityWithPersistence() const { return myHasEntityWithPersistence; } + Standard_Boolean HasEntityWithPersistence() const { return myNbEntityWithPersistence > 0; } protected: @@ -89,9 +89,9 @@ protected: private: - SelectMgr_IndexedMapOfHSensitive mySensitives; //!< Map of entities and its corresponding index in BVH - SelectMgr_MapOfOwners myOwnersMap; //!< Map of entity owners and its corresponding number of sensitives - Standard_Boolean myHasEntityWithPersistence; //!< flag if some of sensitive entity has own transform persistence + SelectMgr_IndexedMapOfHSensitive mySensitives; //!< Map of entities and its corresponding index in BVH + SelectMgr_MapOfOwners myOwnersMap; //!< Map of entity owners and its corresponding number of sensitives + Standard_Integer myNbEntityWithPersistence; //!< number of sensitive entities that have own transform persistence }; #endif // _SelectMgr_SensitiveEntitySet_HeaderFile