Attached Files | 0002-Read-of-the-information-elements.patch [^] (4,102 bytes) 2010-09-30 02:57 [Show Content] [Hide Content]From a09d668878ef3fa40772579b354e5eb14c2fb070 Mon Sep 17 00:00:00 2001
From: Felipe Bordeu <felipe.bordeu@ec-nantes.fr>
Date: Tue, 28 Sep 2010 17:22:31 +0200
Subject: [PATCH 582/583] Read of the information elements
Code added to read and retreave information elements of a file
---
libsrc/XdmfAttribute.cxx | 20 ++++++++++++++++++++
libsrc/XdmfAttribute.h | 4 +++-
libsrc/XdmfGrid.cxx | 33 +++++++++++++++++++++++++++++++++
3 files changed, 56 insertions(+), 1 deletions(-)
diff --git a/libsrc/XdmfAttribute.cxx b/libsrc/XdmfAttribute.cxx
index 9c455c6..7bca63c 100644
--- a/libsrc/XdmfAttribute.cxx
+++ b/libsrc/XdmfAttribute.cxx
@@ -28,6 +28,7 @@
#include "XdmfDataDesc.h"
#include "XdmfArray.h"
#include "XdmfDOM.h"
+#include "XdmfInformation.h"
XdmfAttribute::XdmfAttribute() {
this->SetElementName("Attribute");
@@ -82,6 +84,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);
diff --git a/libsrc/XdmfAttribute.h b/libsrc/XdmfAttribute.h
index eaf4ee1..e733bd9 100644
--- a/libsrc/XdmfAttribute.h
+++ b/libsrc/XdmfAttribute.h
@@ -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();
diff --git a/libsrc/XdmfGrid.cxx b/libsrc/XdmfGrid.cxx
index f78ff05..be49a27 100644
--- a/libsrc/XdmfGrid.cxx
+++ b/libsrc/XdmfGrid.cxx
@@ -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 );
}
--
1.7.0.4
|