diff --git a/src/OpenGl/FILES b/src/OpenGl/FILES index 37d3e63a1f..963f2d7fe2 100755 --- a/src/OpenGl/FILES +++ b/src/OpenGl/FILES @@ -141,7 +141,6 @@ OpenGl_ShaderManager.hxx OpenGl_ShaderManager.cxx OpenGl_ShaderStates.hxx OpenGl_ShaderStates.cxx -OpenGl_SequenceOfStructure.hxx Handle_OpenGl_ShaderObject.hxx Handle_OpenGl_ShaderProgram.hxx Handle_OpenGl_ShaderManager.hxx diff --git a/src/OpenGl/OpenGl_BVHClipPrimitiveSet.cxx b/src/OpenGl/OpenGl_BVHClipPrimitiveSet.cxx index e105ab3733..5ed300708a 100644 --- a/src/OpenGl/OpenGl_BVHClipPrimitiveSet.cxx +++ b/src/OpenGl/OpenGl_BVHClipPrimitiveSet.cxx @@ -71,13 +71,13 @@ void OpenGl_BVHClipPrimitiveSet::Swap (const Standard_Integer theIdx1, // function : Assign // purpose : // ======================================================================= -void OpenGl_BVHClipPrimitiveSet::Assign (const OpenGl_ArrayOfStructure& theStructs) +void OpenGl_BVHClipPrimitiveSet::Assign (const OpenGl_ArrayOfIndexedMapOfStructure& theStructs) { myStructs.Clear(); for (Standard_Integer aPriorityIdx = 0, aNbPriorities = theStructs.Length(); aPriorityIdx < aNbPriorities; ++aPriorityIdx) { - for (OpenGl_SequenceOfStructure::Iterator aStructIter (theStructs (aPriorityIdx)); aStructIter.More(); aStructIter.Next()) + for (OpenGl_IndexedMapOfStructure::Iterator aStructIter (theStructs (aPriorityIdx)); aStructIter.More(); aStructIter.Next()) { const OpenGl_Structure* aStruct = aStructIter.Value(); diff --git a/src/OpenGl/OpenGl_BVHClipPrimitiveSet.hxx b/src/OpenGl/OpenGl_BVHClipPrimitiveSet.hxx index 617a29ccc6..4da06c622a 100644 --- a/src/OpenGl/OpenGl_BVHClipPrimitiveSet.hxx +++ b/src/OpenGl/OpenGl_BVHClipPrimitiveSet.hxx @@ -21,9 +21,12 @@ #include #include -#include -typedef NCollection_Array1 OpenGl_ArrayOfStructure; +//! Defines index map of OpenGL structures. +typedef NCollection_IndexedMap OpenGl_IndexedMapOfStructure; + +//! Defines array of indexed maps of OpenGL structures. +typedef NCollection_Array1 OpenGl_ArrayOfIndexedMapOfStructure; //! Set of OpenGl_Structures for building BVH tree. class OpenGl_BVHClipPrimitiveSet : public BVH_PrimitiveSet @@ -53,7 +56,7 @@ public: //! Replaces the set by the given array taking into account //! if each structure is cullable or not. - void Assign (const OpenGl_ArrayOfStructure& theStructs); + void Assign (const OpenGl_ArrayOfIndexedMapOfStructure& theStructs); //! Adds structure to the set. void Add (const OpenGl_Structure* theStruct); diff --git a/src/OpenGl/OpenGl_Layer.cxx b/src/OpenGl/OpenGl_Layer.cxx index 5ab137cd56..6b59d55de6 100644 --- a/src/OpenGl/OpenGl_Layer.cxx +++ b/src/OpenGl/OpenGl_Layer.cxx @@ -56,7 +56,7 @@ void OpenGl_Layer::Add (const OpenGl_Structure* theStruct, return; } - myArray (anIndex).Append (theStruct); + myArray (anIndex).Add (theStruct); if (theStruct->IsAlwaysRendered()) { theStruct->MarkAsNotCulled(); @@ -85,21 +85,22 @@ bool OpenGl_Layer::Remove (const OpenGl_Structure* theStruct, const Standard_Integer aNbPriorities = myArray.Length(); for (Standard_Integer aPriorityIter = 0; aPriorityIter < aNbPriorities; ++aPriorityIter) { - OpenGl_SequenceOfStructure& aSeq = myArray (aPriorityIter); - for (OpenGl_SequenceOfStructure::Iterator aStructIter (aSeq); aStructIter.More(); aStructIter.Next()) + OpenGl_IndexedMapOfStructure& aStructures = myArray (aPriorityIter); + + const Standard_Integer anIndex = aStructures.FindIndex (theStruct); + if (anIndex != 0) { - if (aStructIter.Value() == theStruct) + aStructures.Swap (anIndex, aStructures.Size()); + aStructures.RemoveLast(); + + if (!theStruct->IsAlwaysRendered() + && !isForChangePriority) { - aSeq.Remove (aStructIter); - if (!theStruct->IsAlwaysRendered() - && !isForChangePriority) - { - myBVHPrimitives.Remove (theStruct); - } - --myNbStructures; - thePriority = aPriorityIter; - return true; + myBVHPrimitives.Remove (theStruct); } + --myNbStructures; + thePriority = aPriorityIter; + return true; } } @@ -126,9 +127,10 @@ void OpenGl_Layer::renderAll (const Handle(OpenGl_Workspace)& theWorkspace) cons const Standard_Integer aViewId = theWorkspace->ActiveViewId(); for (Standard_Integer aPriorityIter = 0; aPriorityIter < aNbPriorities; ++aPriorityIter) { - for (OpenGl_SequenceOfStructure::Iterator aStructIter (myArray (aPriorityIter)); aStructIter.More(); aStructIter.Next()) + const OpenGl_IndexedMapOfStructure& aStructures = myArray (aPriorityIter); + for (Standard_Integer aStructIdx = 1; aStructIdx <= aStructures.Size(); ++aStructIdx) { - const OpenGl_Structure* aStruct = aStructIter.Value(); + const OpenGl_Structure* aStruct = aStructures.FindKey (aStructIdx); if (!aStruct->IsVisible()) { continue; @@ -163,9 +165,10 @@ void OpenGl_Layer::renderTraverse (const Handle(OpenGl_Workspace)& theWorkspace) const Standard_Integer aViewId = theWorkspace->ActiveViewId(); for (Standard_Integer aPriorityIter = 0; aPriorityIter < aNbPriorities; ++aPriorityIter) { - for (OpenGl_SequenceOfStructure::Iterator aStructIter (myArray (aPriorityIter)); aStructIter.More(); aStructIter.Next()) + const OpenGl_IndexedMapOfStructure& aStructures = myArray (aPriorityIter); + for (Standard_Integer aStructIdx = 1; aStructIdx <= aStructures.Size(); ++aStructIdx) { - const OpenGl_Structure* aStruct = aStructIter.Value(); + const OpenGl_Structure* aStruct = aStructures.FindKey (aStructIdx); if (!aStruct->IsVisible() || aStruct->IsCulled()) { @@ -267,9 +270,10 @@ Standard_Boolean OpenGl_Layer::Append (const OpenGl_Layer& theOther) // add all structures to destination priority list for (Standard_Integer aPriorityIter = 0; aPriorityIter < aNbPriorities; ++aPriorityIter) { - for (OpenGl_SequenceOfStructure::Iterator aStructIter (theOther.myArray (aPriorityIter)); aStructIter.More(); aStructIter.Next()) + const OpenGl_IndexedMapOfStructure& aStructures = theOther.myArray (aPriorityIter); + for (Standard_Integer aStructIdx = 1; aStructIdx <= aStructures.Size(); ++aStructIdx) { - Add (aStructIter.Value(), aPriorityIter); + Add (aStructures.FindKey (aStructIdx), aPriorityIter); } } diff --git a/src/OpenGl/OpenGl_Layer.hxx b/src/OpenGl/OpenGl_Layer.hxx index cc1697ee0d..ed45ed9173 100644 --- a/src/OpenGl/OpenGl_Layer.hxx +++ b/src/OpenGl/OpenGl_Layer.hxx @@ -82,7 +82,7 @@ public: Standard_Boolean Append (const OpenGl_Layer& theOther); //! Returns array of OpenGL structures. - const OpenGl_ArrayOfStructure& ArrayOfStructures() const { return myArray; } + const OpenGl_ArrayOfIndexedMapOfStructure& ArrayOfStructures() const { return myArray; } //! Marks BVH tree for given priority list as dirty and //! marks primitive set for rebuild. @@ -105,12 +105,12 @@ protected: private: - OpenGl_ArrayOfStructure myArray; - Standard_Integer myNbStructures; - Graphic3d_ZLayerSettings myLayerSettings; //!< Layer setting flags - mutable OpenGl_BVHClipPrimitiveSet myBVHPrimitives; // - -class OpenGl_Structure; -typedef NCollection_Sequence OpenGl_SequenceOfStructure; - -#endif // _OpenGl_SequenceOfStructure diff --git a/src/OpenGl/OpenGl_View.hxx b/src/OpenGl/OpenGl_View.hxx index 2a16e41593..aa41691979 100644 --- a/src/OpenGl/OpenGl_View.hxx +++ b/src/OpenGl/OpenGl_View.hxx @@ -201,7 +201,7 @@ class OpenGl_View : public MMgt_TShared void InvalidateBVHData (const Standard_Integer theLayerId); //! Returns list of immediate structures rendered on top of main presentation - const OpenGl_SequenceOfStructure& ImmediateStructures() const + const OpenGl_IndexedMapOfStructure& ImmediateStructures() const { return myImmediateList; } @@ -267,8 +267,8 @@ protected: //View_LABDepthCueing - fixed index used - OpenGl_LayerList myZLayers; //!< main list of displayed structure, sorted by layers - OpenGl_SequenceOfStructure myImmediateList; //!< list of immediate structures rendered on top of main presentation + OpenGl_LayerList myZLayers; //!< main list of displayed structure, sorted by layers + OpenGl_IndexedMapOfStructure myImmediateList; //!< list of immediate structures rendered on top of main presentation const TEL_TRANSFORM_PERSISTENCE *myTransPers; Standard_Boolean myIsTransPers; diff --git a/src/OpenGl/OpenGl_View_2.cxx b/src/OpenGl/OpenGl_View_2.cxx index 3abea5156f..fe40d8d914 100644 --- a/src/OpenGl/OpenGl_View_2.cxx +++ b/src/OpenGl/OpenGl_View_2.cxx @@ -919,16 +919,7 @@ void OpenGl_View::DisplayStructure (const Handle(Graphic3d_Structure)& theStruct void OpenGl_View::DisplayImmediateStructure (const Handle(Graphic3d_Structure)& theStructure) { const OpenGl_Structure* aStruct = reinterpret_cast (theStructure->CStructure().operator->()); - for (OpenGl_SequenceOfStructure::Iterator anIter (myImmediateList); - anIter.More(); anIter.Next()) - { - if (anIter.Value() == aStruct) - { - return; - } - } - - myImmediateList.Append (aStruct); + myImmediateList.Add (aStruct); } //======================================================================= @@ -948,14 +939,12 @@ void OpenGl_View::EraseStructure (const Handle(Graphic3d_Structure)& theStructur void OpenGl_View::EraseImmediateStructure (const OpenGl_Structure* theStructure) { - for (OpenGl_SequenceOfStructure::Iterator anIter (myImmediateList); - anIter.More(); anIter.Next()) + const Standard_Integer anIndex = myImmediateList.FindIndex (theStructure); + + if (anIndex != 0) { - if (anIter.Value() == theStructure) - { - myImmediateList.Remove (anIter); - return; - } + myImmediateList.Swap (myImmediateList.Size(), anIndex); + myImmediateList.RemoveLast(); } } diff --git a/src/OpenGl/OpenGl_View_Raytrace.cxx b/src/OpenGl/OpenGl_View_Raytrace.cxx index 15e9f9d0c9..728c98cba0 100644 --- a/src/OpenGl/OpenGl_View_Raytrace.cxx +++ b/src/OpenGl/OpenGl_View_Raytrace.cxx @@ -71,11 +71,11 @@ Standard_Boolean OpenGl_View::updateRaytraceGeometry (const RaytraceUpdateMode if (aLayer.NbStructures() != 0) { - const OpenGl_ArrayOfStructure& aStructArray = aLayer.ArrayOfStructures(); + const OpenGl_ArrayOfIndexedMapOfStructure& aStructArray = aLayer.ArrayOfStructures(); for (Standard_Integer anIndex = 0; anIndex < aStructArray.Length(); ++anIndex) { - for (OpenGl_SequenceOfStructure::Iterator aStructIt (aStructArray (anIndex)); aStructIt.More(); aStructIt.Next()) + for (OpenGl_IndexedMapOfStructure::Iterator aStructIt (aStructArray (anIndex)); aStructIt.More(); aStructIt.Next()) { const OpenGl_Structure* aStructure = aStructIt.Value(); diff --git a/src/OpenGl/OpenGl_Workspace.cxx b/src/OpenGl/OpenGl_Workspace.cxx index b93bd86b37..59264e6b6a 100644 --- a/src/OpenGl/OpenGl_Workspace.cxx +++ b/src/OpenGl/OpenGl_Workspace.cxx @@ -1429,8 +1429,7 @@ bool OpenGl_Workspace::redrawImmediate (const Graphic3d_CView& theCView, { glDisable (GL_DEPTH_TEST); } - for (OpenGl_SequenceOfStructure::Iterator anIter (myView->ImmediateStructures()); - anIter.More(); anIter.Next()) + for (OpenGl_IndexedMapOfStructure::Iterator anIter (myView->ImmediateStructures()); anIter.More(); anIter.Next()) { const OpenGl_Structure* aStructure = anIter.Value(); if (!aStructure->IsVisible())