Commit 9ecc6162 authored by Felipe Bordeu's avatar Felipe Bordeu Committed by David Partyka
Browse files

Read of the information elements

Code added to read and retreave information elements of a file
parent f6bc9809
......@@ -28,6 +28,7 @@
#include "XdmfDataDesc.h"
#include "XdmfArray.h"
#include "XdmfDOM.h"
#include "XdmfInformation.h"
XdmfAttribute::XdmfAttribute() {
this->SetElementName("Attribute");
......@@ -82,6 +83,24 @@ XdmfDataItem * XdmfAttribute::GetDataItem(){
return(di);
}
XdmfInformation * XdmfAttribute::GetInformation(const XdmfInt32 Index){
if(Index < this->DOM->FindNumberOfElements("Information", this->Element )){
XdmfInformation *di = NULL;
XdmfXmlNode Node = this->DOM->FindElement( "Information", Index, this->Element, 0);
if(Node) {
di = new XdmfInformation;
di->SetDeleteOnGridDelete(true);
di->SetDOM( this->DOM );
di->SetElement( Node );
di->UpdateInformation();
return(di);
}
}else{
XdmfErrorMessage("Grid has " << this->DOM->FindNumberOfElements("Information", this->Element ) << " Information. Index " << Index << " is out of range");
}
return(NULL);
}
XdmfInt32
XdmfAttribute::Build(){
if(XdmfElement::Build() != XDMF_SUCCESS) return(XDMF_FAIL);
......
......@@ -47,7 +47,7 @@ class XdmfTopology;
class XdmfDataDesc;
class XdmfDataItem;
class XdmfArray;
class XdmfInformation;
//! Class for Scalar, Vector, and Tensor Computed Data
/*!
XdmfAttribute is a Class that handles the Computed Values
......@@ -142,6 +142,8 @@ public:
XdmfInt32 Build();
//! Release Big Data
XdmfInt32 Release();
//! Retreives a Information Element
XdmfInformation * GetInformation(const XdmfInt32 Index);
protected:
XdmfDataItem *GetDataItem();
......
......@@ -93,6 +93,11 @@ XdmfGrid::~XdmfGrid() {
}
}
free(this->Sets);
for ( Index = 0; Index < this->NumberOfInformations; Index ++ ){
if (this->Informations[Index]->GetDeleteOnGridDelete()){
delete this->Informations[Index];
}
}
free(this->Informations);
}
......@@ -622,6 +627,34 @@ if( this->NumberOfSets > 0 ){
iSet->UpdateInformation();
}
}
// Get Information
XdmfInt32 OldNumberOfInformation = this->NumberOfInformations;
this->NumberOfInformations = this->DOM->FindNumberOfElements("Information", this->Element );
if( this->NumberOfInformations > 0 ){
XdmfInt32 Index;
XdmfInformation *iInformation;
XdmfXmlNode lInformationElement;
for ( Index = 0; Index < OldNumberOfInformation; Index ++ )
{
delete this->Informations[Index];
}
this->Informations = ( XdmfInformation **)realloc( this->Informations,
this->NumberOfInformations * sizeof( XdmfInformation * ));
for( Index = 0 ; Index < this->NumberOfInformations ; Index++ ){
iInformation = new XdmfInformation;
iInformation->SetDeleteOnGridDelete(true);
this->Informations[Index] = iInformation;
if (Index==0) {
lInformationElement = this->DOM->FindElement( "Information", Index, this->Element, 0);
} else {
lInformationElement = this->DOM->FindNextElement( "Information", lInformationElement, 0);
}
iInformation->SetDOM( this->DOM );
iInformation->SetElement( lInformationElement );
iInformation->UpdateInformation();
}
}
return( XDMF_SUCCESS );
}
......
Markdown is supported
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