Commit 0d4a9209 authored by Utkarsh Ayachit's avatar Utkarsh Ayachit
Browse files

PERF: Performance improvements to the XdmfReader (and panel) to avoid repeated

RequestInformation passes and speed up performance when reading large xmf files.
parent 27bcdfa3
......@@ -525,6 +525,43 @@ if ( !type ) {
return(NULL);
}
XdmfXmlNode
XdmfDOM::FindNextElement(XdmfConstString TagName, XdmfXmlNode Node, XdmfInt32 IgnoreInfo) {
XdmfString type = (XdmfString )TagName;
XdmfXmlNode child;
// this->SetDebug(1);
if(TagName){
XdmfDebug("FindNextElement" << TagName);
}else{
XdmfDebug("FindNextElement NULL");
}
if(!Node) {
if(!this->Tree) return( NULL );
Node = this->Tree->children;
}
if(!Node) return(NULL);
if ( type ) {
if( STRNCASECMP( type, "NULL", 4 ) == 0 ) type = NULL;
}
child = XdmfGetNextElement(Node);
while (child) {
if(IgnoreInfo && XDMF_WORD_CMP("Information", (const char *)(child)->name)){
// skip Information elements.
} else {
if(!type ||
(XDMF_WORD_CMP((const char *)type, (const char *)(child)->name))){
return child;
}
}
child = XdmfGetNextElement(child);
}
return (NULL);
}
XdmfXmlNode
XdmfDOM::FindElementByAttribute(XdmfConstString Attribute,
XdmfConstString Value, XdmfInt32 Index, XdmfXmlNode Node ) {
......
......@@ -181,6 +181,13 @@ the "Information" Elements not to be counted against Index.
XdmfInt32 Index= 0,
XdmfXmlNode Node = NULL,
XdmfInt32 IgnoreInfo=1);
/*!
Find the next sibling for the node that is of a certain type. IgnoreInfo allows
the "Information" elements to be skipped.
*/
XdmfXmlNode FindNextElement(XdmfConstString TagName,
XdmfXmlNode Node,
XdmfInt32 IgnoreInfo=1);
/*! Find DataItem, DataStructure, or DataTransform
This is needed for backward compatibility but will
be removed in the future and XML will be forced
......
......@@ -409,7 +409,12 @@ if( this->GridType & XDMF_GRID_MASK){
}
anElement = this->DOM->FindElement("Geometry", 0, this->Element);
for(i=0 ; i < nchild ; i++){
node = this->DOM->FindElement("Grid", i, this->Element);
if (i==0) {
node = this->DOM->FindElement("Grid", i, this->Element);
} else {
node = this->DOM->FindNextElement("Grid", node);
}
if(!node) {
XdmfErrorMessage("Can't find Child Grid #" << i);
return(XDMF_FAIL);
......@@ -536,9 +541,12 @@ if( this->NumberOfAttributes > 0 ){
this->NumberOfAttributes * sizeof( XdmfAttribute * ));
for( Index = 0 ; Index < this->NumberOfAttributes ; Index++ ){
iattribute = new XdmfAttribute;
this->Attribute[Index] = iattribute;
AttributeElement = this->DOM->FindElement( "Attribute", Index, this->Element );
if (Index == 0) {
AttributeElement = this->DOM->FindElement( "Attribute", Index, this->Element );
} else {
AttributeElement = this->DOM->FindNextElement( "Attribute", AttributeElement);
}
iattribute->SetDOM( this->DOM );
iattribute->SetElement( AttributeElement );
iattribute->UpdateInformation();
......@@ -562,7 +570,11 @@ if( this->NumberOfSets > 0 ){
iSet = new XdmfSet;
this->Sets[Index] = iSet;
SetElement = this->DOM->FindElement( "Set", Index, this->Element );
if (Index==0) {
SetElement = this->DOM->FindElement( "Set", Index, this->Element );
} else {
SetElement = this->DOM->FindNextElement( "Set", SetElement);
}
iSet->SetDOM( this->DOM );
iSet->SetElement( SetElement );
iSet->UpdateInformation();
......
This diff is collapsed.
......@@ -58,13 +58,15 @@ public:
int GetNumberOfDomains();
// Description:
// Get/Set the current domain name.
virtual void SetDomainName(const char*);
vtkGetStringMacro(DomainName);
// Get the name of domain at index.
const char* GetDomainName(int idx);
// Description:
// Get/Set the current domain name. If none is set, the first domain will be
// used.
virtual void SetDomainName(const char*);
vtkGetStringMacro(DomainName);
// GRIDS ///////////////////////////////////////////////////////////////////
// Description:
// Get number of grids in the current domain.
......@@ -90,7 +92,7 @@ public:
void DisableGrid(const char* name);
void DisableGrid(int idx);
void DisableAllGrids();
void RemoveAllGrids();
void RemoveAllGrids(); // <<--FIXME: remove me.
// Description:
// Get current enable/disable of the grid
......@@ -220,7 +222,13 @@ public:
protected:
vtkXdmfReader();
~vtkXdmfReader();
~vtkXdmfReader();
// Description:
// This methods parses the XML. Returns true on success. This method can be
// called repeatedly. It has checks to ensure that the XML parsing is done
// only if needed.
bool ParseXML();
virtual int ProcessRequest(vtkInformation *request,
vtkInformationVector **inputVector,
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment