mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-09 13:22:24 +03:00
0026029: Visualization - Poor performance of connected objects
Fix performance issue with SelectMgr_SelectableObjectSet.
This commit is contained in:
@@ -32,6 +32,7 @@ Graphic3d_ShaderVariable.cxx
|
||||
Graphic3d_ShaderVariable.lxx
|
||||
Graphic3d_MapOfStructure.hxx
|
||||
Graphic3d_MapIteratorOfMapOfStructure.hxx
|
||||
Graphic3d_IndexedMapOfAddress.hxx
|
||||
Graphic3d_TypeOfShaderObject.hxx
|
||||
Graphic3d_DataStructure.pxx
|
||||
Graphic3d_StructureManager.pxx
|
||||
|
@@ -493,6 +493,7 @@ is
|
||||
imported transient class NMapOfTransient;
|
||||
|
||||
imported MapOfStructure;
|
||||
imported IndexedMapOfAddress;
|
||||
imported SequenceOfDisplayedStructures;
|
||||
|
||||
---------------------------------
|
||||
|
23
src/Graphic3d/Graphic3d_IndexedMapOfAddress.hxx
Normal file
23
src/Graphic3d/Graphic3d_IndexedMapOfAddress.hxx
Normal file
@@ -0,0 +1,23 @@
|
||||
// Created on: 2015-04-2015
|
||||
// Created by: Denis BOGOLEPOV
|
||||
// Copyright (c) 2015 OPEN CASCADE SAS
|
||||
//
|
||||
// This file is part of Open CASCADE Technology software library.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it under
|
||||
// the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
// by the Free Software Foundation, with special exception defined in the file
|
||||
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
// distribution for complete text of the license and disclaimer of any warranty.
|
||||
//
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#ifndef _Graphic3d_IndexedMapOfAddress
|
||||
#define _Graphic3d_IndexedMapOfAddress
|
||||
|
||||
#include <NCollection_DataMap.hxx>
|
||||
|
||||
typedef NCollection_DataMap<const Standard_Address, Standard_Integer> Graphic3d_IndexedMapOfAddress;
|
||||
|
||||
#endif // _Graphic3d_IndexedMapOfAddress
|
@@ -40,42 +40,42 @@ class Structure from Graphic3d inherits TShared
|
||||
|
||||
uses
|
||||
|
||||
Array2OfReal from TColStd,
|
||||
SequenceOfAddress from TColStd,
|
||||
Array2OfReal from TColStd,
|
||||
SequenceOfAddress from TColStd,
|
||||
|
||||
Color from Quantity,
|
||||
Color from Quantity,
|
||||
|
||||
GenId from Aspect,
|
||||
TypeOfHighlightMethod from Aspect,
|
||||
GenId from Aspect,
|
||||
TypeOfHighlightMethod from Aspect,
|
||||
|
||||
DataStructureManager from Graphic3d,
|
||||
AspectFillArea3d from Graphic3d,
|
||||
AspectLine3d from Graphic3d,
|
||||
AspectMarker3d from Graphic3d,
|
||||
AspectText3d from Graphic3d,
|
||||
CStructure from Graphic3d,
|
||||
CStructure from Graphic3d,
|
||||
GraphicDriver from Graphic3d,
|
||||
Group from Graphic3d,
|
||||
SequenceOfGroup from Graphic3d,
|
||||
SequenceOfStructure from Graphic3d,
|
||||
HSequenceOfStructure from Graphic3d,
|
||||
MapOfStructure from Graphic3d,
|
||||
StructureManager from Graphic3d,
|
||||
StructureManagerPtr from Graphic3d,
|
||||
TypeOfComposition from Graphic3d,
|
||||
TypeOfConnection from Graphic3d,
|
||||
TypeOfPrimitive from Graphic3d,
|
||||
TypeOfStructure from Graphic3d,
|
||||
Vector from Graphic3d,
|
||||
Vertex from Graphic3d,
|
||||
TransModeFlags from Graphic3d,
|
||||
ZLayerId from Graphic3d,
|
||||
Pnt from gp,
|
||||
SequenceOfHClipPlane from Graphic3d,
|
||||
BndBox4f from Graphic3d,
|
||||
BndBox4d from Graphic3d,
|
||||
Box from Bnd
|
||||
DataStructureManager from Graphic3d,
|
||||
AspectFillArea3d from Graphic3d,
|
||||
AspectLine3d from Graphic3d,
|
||||
AspectMarker3d from Graphic3d,
|
||||
AspectText3d from Graphic3d,
|
||||
CStructure from Graphic3d,
|
||||
GraphicDriver from Graphic3d,
|
||||
Group from Graphic3d,
|
||||
SequenceOfGroup from Graphic3d,
|
||||
SequenceOfStructure from Graphic3d,
|
||||
HSequenceOfStructure from Graphic3d,
|
||||
MapOfStructure from Graphic3d,
|
||||
IndexedMapOfAddress from Graphic3d,
|
||||
StructureManager from Graphic3d,
|
||||
StructureManagerPtr from Graphic3d,
|
||||
TypeOfComposition from Graphic3d,
|
||||
TypeOfConnection from Graphic3d,
|
||||
TypeOfPrimitive from Graphic3d,
|
||||
TypeOfStructure from Graphic3d,
|
||||
Vector from Graphic3d,
|
||||
Vertex from Graphic3d,
|
||||
TransModeFlags from Graphic3d,
|
||||
ZLayerId from Graphic3d,
|
||||
Pnt from gp,
|
||||
SequenceOfHClipPlane from Graphic3d,
|
||||
BndBox4f from Graphic3d,
|
||||
BndBox4d from Graphic3d,
|
||||
Box from Bnd
|
||||
|
||||
raises
|
||||
|
||||
@@ -957,6 +957,38 @@ is
|
||||
---C++: return const &
|
||||
---C++: inline
|
||||
|
||||
AppendDescendant (me : mutable;
|
||||
theDescendant : Address from Standard)
|
||||
returns Boolean from Standard
|
||||
is protected;
|
||||
---Level: Internal
|
||||
---Purpose: Appends new descendant structure.
|
||||
---Category: Private methods
|
||||
|
||||
RemoveDescendant (me : mutable;
|
||||
theDescendant : Address from Standard)
|
||||
returns Boolean from Standard
|
||||
is protected;
|
||||
---Level: Internal
|
||||
---Purpose: Removes the given descendant structure.
|
||||
---Category: Private methods
|
||||
|
||||
AppendAncestor (me : mutable;
|
||||
theAncestor : Address from Standard)
|
||||
returns Boolean from Standard
|
||||
is protected;
|
||||
---Level: Internal
|
||||
---Purpose: Appends new ancestor structure.
|
||||
---Category: Private methods
|
||||
|
||||
RemoveAncestor (me : mutable;
|
||||
theAncestor : Address from Standard)
|
||||
returns Boolean from Standard
|
||||
is protected;
|
||||
---Level: Internal
|
||||
---Purpose: Removes the given ancestor structure.
|
||||
---Category: Private methods
|
||||
|
||||
fields
|
||||
|
||||
--
|
||||
@@ -968,14 +1000,20 @@ fields
|
||||
-- It is a sequence of groups of primitives.
|
||||
--
|
||||
|
||||
-- the associated low-level structure
|
||||
myCStructure : CStructure from Graphic3d;
|
||||
-- the associated low-level structure
|
||||
myCStructure : CStructure from Graphic3d;
|
||||
|
||||
-- the structures to which the structure is attached
|
||||
myAncestors : SequenceOfAddress from TColStd;
|
||||
-- the structures to which the structure is attached
|
||||
myAncestors : SequenceOfAddress from TColStd;
|
||||
|
||||
-- the structures attached to the structure
|
||||
myDescendants : SequenceOfAddress from TColStd;
|
||||
-- the structures attached to the structure
|
||||
myDescendants : SequenceOfAddress from TColStd;
|
||||
|
||||
-- the map of structures to which the structure is attached
|
||||
myAncestorMap : IndexedMapOfAddress from Graphic3d;
|
||||
|
||||
-- the map of structures attached to the structure
|
||||
myDescendantMap : IndexedMapOfAddress from Graphic3d;
|
||||
|
||||
-- the highlight method of the structure
|
||||
myHighlightColor : Color from Quantity;
|
||||
|
@@ -1312,6 +1312,90 @@ void Graphic3d_Structure::Descendants (Graphic3d_MapOfStructure& theSet) const
|
||||
}
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
//function : AppendDescendant
|
||||
//purpose :
|
||||
//=============================================================================
|
||||
Standard_Boolean Graphic3d_Structure::AppendDescendant (const Standard_Address theDescendant)
|
||||
{
|
||||
if (myDescendantMap.IsBound (theDescendant))
|
||||
{
|
||||
return Standard_False; // already connected
|
||||
}
|
||||
|
||||
myDescendantMap.Bind (theDescendant, myDescendants.Length() + 1);
|
||||
myDescendants.Append (theDescendant);
|
||||
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
//function : RemoveDescendant
|
||||
//purpose :
|
||||
//=============================================================================
|
||||
Standard_Boolean Graphic3d_Structure::RemoveDescendant (const Standard_Address theDescendant)
|
||||
{
|
||||
Standard_Integer aStructIdx;
|
||||
if (!myDescendantMap.Find (theDescendant, aStructIdx))
|
||||
{
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
myDescendantMap.UnBind (theDescendant);
|
||||
|
||||
if (aStructIdx != myDescendants.Length())
|
||||
{
|
||||
myDescendants.Exchange (aStructIdx, myDescendants.Length());
|
||||
myDescendantMap.Bind (myDescendants (aStructIdx), aStructIdx);
|
||||
}
|
||||
|
||||
myDescendants.Remove (myDescendants.Length());
|
||||
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
//function : AppendAncestor
|
||||
//purpose :
|
||||
//=============================================================================
|
||||
Standard_Boolean Graphic3d_Structure::AppendAncestor (const Standard_Address theAncestor)
|
||||
{
|
||||
if (myAncestorMap.IsBound (theAncestor))
|
||||
{
|
||||
return Standard_False; // already connected
|
||||
}
|
||||
|
||||
myAncestorMap.Bind (theAncestor, myAncestors.Length() + 1);
|
||||
myAncestors.Append (theAncestor);
|
||||
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
//function : RemoveAncestor
|
||||
//purpose :
|
||||
//=============================================================================
|
||||
Standard_Boolean Graphic3d_Structure::RemoveAncestor (const Standard_Address theAncestor)
|
||||
{
|
||||
Standard_Integer aStructIdx;
|
||||
if (!myAncestorMap.Find (theAncestor, aStructIdx))
|
||||
{
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
myAncestorMap.UnBind (theAncestor);
|
||||
|
||||
if (aStructIdx != myAncestors.Length())
|
||||
{
|
||||
myAncestors.Exchange (aStructIdx, myAncestors.Length());
|
||||
myAncestorMap.Bind (myAncestors (aStructIdx), aStructIdx);
|
||||
}
|
||||
|
||||
myAncestors.Remove (myAncestors.Length());
|
||||
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
//function : Connect
|
||||
//purpose :
|
||||
@@ -1320,7 +1404,10 @@ void Graphic3d_Structure::Connect (const Handle(Graphic3d_Structure)& theStructu
|
||||
const Graphic3d_TypeOfConnection theType,
|
||||
const Standard_Boolean theWithCheck)
|
||||
{
|
||||
if (IsDeleted()) return;
|
||||
if (IsDeleted())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// cycle detection
|
||||
if (theWithCheck
|
||||
@@ -1329,47 +1416,34 @@ void Graphic3d_Structure::Connect (const Handle(Graphic3d_Structure)& theStructu
|
||||
return;
|
||||
}
|
||||
|
||||
switch (theType)
|
||||
const Standard_Address aStructure = theStructure.operator->();
|
||||
|
||||
if (theType == Graphic3d_TOC_DESCENDANT)
|
||||
{
|
||||
case Graphic3d_TOC_DESCENDANT:
|
||||
if (!AppendDescendant (aStructure))
|
||||
{
|
||||
const Standard_Integer aNbDesc = myDescendants.Length();
|
||||
for (Standard_Integer anIter = 1; anIter <= aNbDesc; ++anIter)
|
||||
{
|
||||
if (myDescendants.Value (anIter) == theStructure.operator->())
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
myDescendants.Append (theStructure.operator->());
|
||||
CalculateBoundBox();
|
||||
theStructure->Connect (this, Graphic3d_TOC_ANCESTOR);
|
||||
|
||||
GraphicConnect (theStructure);
|
||||
myStructureManager->Connect (this, theStructure);
|
||||
|
||||
Update();
|
||||
return;
|
||||
}
|
||||
case Graphic3d_TOC_ANCESTOR:
|
||||
|
||||
CalculateBoundBox();
|
||||
theStructure->Connect (this, Graphic3d_TOC_ANCESTOR);
|
||||
|
||||
GraphicConnect (theStructure);
|
||||
myStructureManager->Connect (this, theStructure);
|
||||
|
||||
Update();
|
||||
}
|
||||
else // Graphic3d_TOC_ANCESTOR
|
||||
{
|
||||
if (!AppendAncestor (aStructure))
|
||||
{
|
||||
const Standard_Integer aNbAnces = myAncestors.Length();
|
||||
for (Standard_Integer anIter = 1; anIter <= aNbAnces; ++anIter)
|
||||
{
|
||||
if (myAncestors.Value (anIter) == theStructure.operator->())
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
myAncestors.Append (theStructure.operator->());
|
||||
CalculateBoundBox();
|
||||
theStructure->Connect (this, Graphic3d_TOC_DESCENDANT);
|
||||
|
||||
// myGraphicDriver->Connect is called in case if connection between parent and child
|
||||
return;
|
||||
}
|
||||
|
||||
CalculateBoundBox();
|
||||
theStructure->Connect (this, Graphic3d_TOC_DESCENDANT);
|
||||
|
||||
// myStructureManager->Connect is called in case if connection between parent and child
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1379,37 +1453,29 @@ void Graphic3d_Structure::Connect (const Handle(Graphic3d_Structure)& theStructu
|
||||
//=============================================================================
|
||||
void Graphic3d_Structure::Disconnect (const Handle(Graphic3d_Structure)& theStructure)
|
||||
{
|
||||
if (IsDeleted()) return;
|
||||
|
||||
const Standard_Integer aNbDesc = myDescendants.Length();
|
||||
for (Standard_Integer anIter = 1; anIter <= aNbDesc; ++anIter)
|
||||
if (IsDeleted())
|
||||
{
|
||||
if (myDescendants.Value (anIter) == theStructure.operator->())
|
||||
{
|
||||
myDescendants.Remove (anIter);
|
||||
theStructure->Disconnect (this);
|
||||
|
||||
GraphicDisconnect (theStructure);
|
||||
myStructureManager->Disconnect (this, theStructure);
|
||||
|
||||
CalculateBoundBox();
|
||||
|
||||
Update();
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
const Standard_Integer aNbAnces = myAncestors.Length();
|
||||
for (Standard_Integer anIter = 1; anIter <= aNbAnces; ++anIter)
|
||||
const Standard_Address aStructure = theStructure.operator->();
|
||||
|
||||
if (RemoveDescendant (aStructure))
|
||||
{
|
||||
if (myAncestors.Value (anIter) == theStructure.operator->())
|
||||
{
|
||||
myAncestors.Remove (anIter);
|
||||
theStructure->Disconnect (this);
|
||||
CalculateBoundBox();
|
||||
// no call of myGraphicDriver->Disconnect in case of an ancestor
|
||||
return;
|
||||
}
|
||||
theStructure->Disconnect (this);
|
||||
|
||||
GraphicDisconnect (theStructure);
|
||||
myStructureManager->Disconnect (this, theStructure);
|
||||
|
||||
CalculateBoundBox();
|
||||
Update();
|
||||
}
|
||||
else if (RemoveAncestor (aStructure))
|
||||
{
|
||||
theStructure->Disconnect (this);
|
||||
CalculateBoundBox();
|
||||
|
||||
// no call of myStructureManager->Disconnect in case of an ancestor
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1680,34 +1746,13 @@ gp_Pnt Graphic3d_Structure::TransformPersistencePoint() const
|
||||
void Graphic3d_Structure::Remove (const Standard_Address thePtr,
|
||||
const Graphic3d_TypeOfConnection theType)
|
||||
{
|
||||
switch (theType)
|
||||
if (theType == Graphic3d_TOC_DESCENDANT)
|
||||
{
|
||||
case Graphic3d_TOC_DESCENDANT:
|
||||
{
|
||||
const Standard_Integer aNbDesc = myDescendants.Length();
|
||||
for (Standard_Integer anIter = 1; anIter <= aNbDesc; ++anIter)
|
||||
{
|
||||
if (myDescendants.Value (anIter) == thePtr)
|
||||
{
|
||||
myDescendants.Remove (anIter);
|
||||
return;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case Graphic3d_TOC_ANCESTOR:
|
||||
{
|
||||
const Standard_Integer aNbAncestors = myAncestors.Length();
|
||||
for (Standard_Integer anIter = 1; anIter <= aNbAncestors; ++anIter)
|
||||
{
|
||||
if (myAncestors.Value (anIter) == thePtr)
|
||||
{
|
||||
myAncestors.Remove (anIter);
|
||||
return;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
RemoveDescendant (thePtr);
|
||||
}
|
||||
else
|
||||
{
|
||||
RemoveAncestor (thePtr);
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user