mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-14 13:30:48 +03:00
0031920: Application Framework - speed up methods of getting label by entry and vice versa
A table for fast access to the labels by entry is implemented in OCAF document. A method TDF_Data::SetAccessByEntries(true) fills-in a table for fast access to the labels. New labels, created later will be added to the table automatically. The method TDF_Tool::Label() will search the entry in the table and then, if not found, will call the old code. Disabling of usage of the table (by calling of TDF_Data::SetAccessByEntries(false)) cleans the internal table of entries - labels. By default, the table is not used. This improvement is useful for large documents with a lot of labels, and if the application uses entries to get labels. The application should call TDF_Data::SetAccessByEntries(true) for a document and then, the method TDF_Tool::Label() called inside OCAF and XCAF will use the fast access to the labels and speed-up the application. Also, the method TDF_Tool::Entry() is improved (by MPV). Modified files: - TDF_Data.hxx and cxx: the new methods SetAccessByEntries(bool), IsAccessByEntries() and GetLabel(entry) are implemented. No need to use the method GetLabel() directly. It is called in TDF_Tool::Label(). - TDF_Label.cxx: adding of a newly created label to the table of entries - labels. - TDF_Tool.cxx: the method Entry() is accelerated (by MPV) and Label() is improved to call TDF_Data::GetLabel(). - DDF_DataCommands.cxx: a new draw-command is added SetAccessByEntry, which sets or unsets usage of the table for fast access to the labels. Usage of the draw-command is illustrated in a new test "bugs caf bug31920". Tests: - bugs caf bug31920: a new simple test to check TDF_Tool::Label() when fast access to the labels is on. Doc: - dox\upgrade\upgrade.md is extended for new information
This commit is contained in:
@@ -94,7 +94,8 @@ myTransaction (0),
|
||||
myNbTouchedAtt (0),
|
||||
myNotUndoMode (Standard_True),
|
||||
myTime (0),
|
||||
myAllowModification (Standard_True)
|
||||
myAllowModification (Standard_True),
|
||||
myAccessByEntries (Standard_False)
|
||||
{
|
||||
const Handle(NCollection_IncAllocator) anIncAllocator=
|
||||
new NCollection_IncAllocator (16000);
|
||||
@@ -118,6 +119,7 @@ void TDF_Data::Destroy()
|
||||
Handle(TDF_Attribute) aFirst = myRoot->FirstAttribute();
|
||||
myRoot->RemoveAttribute(anEmpty, aFirst);
|
||||
}
|
||||
myAccessByEntriesTable.Clear();
|
||||
myRoot->Destroy (myLabelNodeAllocator);
|
||||
myRoot = NULL;
|
||||
}
|
||||
@@ -439,7 +441,43 @@ Handle(TDF_Delta) TDF_Data::Undo(const Handle(TDF_Delta)& aDelta,
|
||||
return newDelta;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : SetAccessByEntries
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void TDF_Data::SetAccessByEntries(const Standard_Boolean aSet)
|
||||
{
|
||||
myAccessByEntries = aSet;
|
||||
|
||||
myAccessByEntriesTable.Clear();
|
||||
if (myAccessByEntries) {
|
||||
// Add root label.
|
||||
TCollection_AsciiString anEntry;
|
||||
TDF_Tool::Entry (myRoot, anEntry);
|
||||
myAccessByEntriesTable.Bind (anEntry, myRoot);
|
||||
|
||||
// Add all other labels.
|
||||
TDF_ChildIterator itr (myRoot, Standard_True);
|
||||
for (; itr.More(); itr.Next()) {
|
||||
const TDF_Label aLabel = itr.Value();
|
||||
TDF_Tool::Entry (aLabel, anEntry);
|
||||
myAccessByEntriesTable.Bind (anEntry, aLabel);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : RegisterLabel
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void TDF_Data::RegisterLabel(const TDF_Label& aLabel)
|
||||
{
|
||||
TCollection_AsciiString anEntry;
|
||||
TDF_Tool::Entry (aLabel, anEntry);
|
||||
myAccessByEntriesTable.Bind (anEntry, aLabel);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Dump
|
||||
|
Reference in New Issue
Block a user