1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-04 13:13:25 +03:00

0029830: STEPCAFControl_Reader poor performance - quadratic dependence

Various performance improvements in STEP read/write algorithms:
- Search for the  label of a shape or component shape is improved using map mechanism instead of brute force iteration.
- Invariant FindEntities() is moved out of the loop in the method getStyledItem in STEPCAFControl/STEPCAFControl_Writer.cxx.
- A pointer to the end of binders chain is added in Transfer_Binder class to speed up adding a binder to the chain.
- Small fixes are added  to eliminate excess copying of handles, calls of handle DownCasts and so on.

Stack overflow is removed during destruction of STEP model with long chains of Transfer_Binder.
It is possible to use the Draw commands ReadStep and WriteStep to read/write from the session without accessing the disk file (use '.' for the file name).

Performance test cases for STEP reading/writing have been added.
This commit is contained in:
msv
2018-06-01 14:38:39 +03:00
committed by bugmaster
parent 0a96e0bbc4
commit 63cdf48ec1
17 changed files with 349 additions and 185 deletions

View File

@@ -77,20 +77,17 @@ void Transfer_Binder::AddResult (const Handle(Transfer_Binder)& next)
thenextr = next;
else {
//Modification of recursive to cycle
Handle(Transfer_Binder) theBinder = thenextr;
Handle(Transfer_Binder) theBinder = theendr.IsNull() ? thenextr : theendr;
while( theBinder != next ) {
if( theBinder->NextResult().IsNull() ) {
theBinder->AddResult(next);
theendr = next;
return;
}
else
theBinder = theBinder->NextResult();
}
}
//former recursive
// if (thenextr.IsNull()) thenextr = next;
// else if (thenextr == next) return;
// else thenextr->AddResult (next);
}
//=======================================================================
@@ -101,7 +98,11 @@ void Transfer_Binder::AddResult (const Handle(Transfer_Binder)& next)
void Transfer_Binder::CutResult (const Handle(Transfer_Binder)& next)
{
if (thenextr.IsNull()) return;
if (thenextr == next) thenextr.Nullify();
if (thenextr == next)
{
thenextr.Nullify();
theendr.Nullify();
}
//else thenextr->CutResult (next);
else {
Handle(Transfer_Binder) currBinder = thenextr, currNext;
@@ -223,3 +224,27 @@ Handle(Interface_Check) Transfer_Binder::CCheck ()
return thecheck;
}
//=======================================================================
//function : Destructor
//purpose :
//=======================================================================
Transfer_Binder::~Transfer_Binder()
{
// To prevent stack overflow on long chains it is needed
// to avoid recursive destruction of the field thenextr
if (!thenextr.IsNull())
{
Handle(Transfer_Binder) aCurr = thenextr;
theendr.Nullify();
thenextr.Nullify();
// we check GetRefCount in order to not destroy a chain if it belongs also
// to another upper level chain (two chains continue at the same binder)
while (!aCurr->thenextr.IsNull() && aCurr->thenextr->GetRefCount() == 1)
{
Handle(Transfer_Binder) aPrev = aCurr;
aCurr = aCurr->thenextr;
aPrev->thenextr.Nullify();
}
}
}

View File

@@ -134,8 +134,8 @@ public:
//! it (adding messages, or replacing it)
Standard_EXPORT Handle(Interface_Check) CCheck();
//! Destructor
Standard_EXPORT ~Transfer_Binder();
DEFINE_STANDARD_RTTIEXT(Transfer_Binder,Standard_Transient)
@@ -165,6 +165,7 @@ private:
Transfer_StatusExec theexecst;
Handle(Interface_Check) thecheck;
Handle(Transfer_Binder) thenextr;
Handle(Transfer_Binder) theendr;
};

View File

@@ -63,7 +63,7 @@ Transfer_SimpleBinderOfTransient::Transfer_SimpleBinderOfTransient () { }
Handle(Transfer_SimpleBinderOfTransient)::DownCast(bn);
bn = bn->NextResult();
if (trb.IsNull()) continue;
Handle(Standard_Transient) rs = trb->Result();
const Handle(Standard_Transient)& rs = trb->Result();
if (rs.IsNull()) continue;
if (!rs->IsKind(atype)) continue;
res = rs;