Commit ac08c282 authored by Jerry Clarke's avatar Jerry Clarke
Browse files

Add a Release() method to release big data but leave structure in place

parent 7fd6a56e
......@@ -217,6 +217,7 @@ class XdmfAttribute(XdmfElement):
def UpdateInformation(*args): return _Xdmf.XdmfAttribute_UpdateInformation(*args)
def Update(*args): return _Xdmf.XdmfAttribute_Update(*args)
def Build(*args): return _Xdmf.XdmfAttribute_Build(*args)
def Release(*args): return _Xdmf.XdmfAttribute_Release(*args)
XdmfAttribute_swigregister = _Xdmf.XdmfAttribute_swigregister
XdmfAttribute_swigregister(XdmfAttribute)
......@@ -515,6 +516,7 @@ class XdmfDataItem(XdmfElement):
def GetIsMultiple(*args): return _Xdmf.XdmfDataItem_GetIsMultiple(*args)
def SetFunction(*args): return _Xdmf.XdmfDataItem_SetFunction(*args)
def GetFunction(*args): return _Xdmf.XdmfDataItem_GetFunction(*args)
def Release(*args): return _Xdmf.XdmfDataItem_Release(*args)
XdmfDataItem_swigregister = _Xdmf.XdmfDataItem_swigregister
XdmfDataItem_swigregister(XdmfDataItem)
......@@ -786,6 +788,7 @@ class XdmfTopology(XdmfElement):
def GetCellOffsets(*args): return _Xdmf.XdmfTopology_GetCellOffsets(*args)
def Update(*args): return _Xdmf.XdmfTopology_Update(*args)
def UpdateInformation(*args): return _Xdmf.XdmfTopology_UpdateInformation(*args)
def Release(*args): return _Xdmf.XdmfTopology_Release(*args)
XdmfTopology_swigregister = _Xdmf.XdmfTopology_swigregister
XdmfTopology_swigregister(XdmfTopology)
......@@ -824,6 +827,7 @@ class XdmfGeometry(XdmfElement):
def UpdateInformation(*args): return _Xdmf.XdmfGeometry_UpdateInformation(*args)
def SetPoints(*args): return _Xdmf.XdmfGeometry_SetPoints(*args)
def GetPoints(*args): return _Xdmf.XdmfGeometry_GetPoints(*args)
def Release(*args): return _Xdmf.XdmfGeometry_Release(*args)
def GetOrigin(*args): return _Xdmf.XdmfGeometry_GetOrigin(*args)
def GetOriginX(*args): return _Xdmf.XdmfGeometry_GetOriginX(*args)
def GetOriginY(*args): return _Xdmf.XdmfGeometry_GetOriginY(*args)
......@@ -901,6 +905,7 @@ class XdmfGrid(XdmfElement):
def GetChild(*args): return _Xdmf.XdmfGrid_GetChild(*args)
def FindGridsInTimeRange(*args): return _Xdmf.XdmfGrid_FindGridsInTimeRange(*args)
def FindGridsAtTime(*args): return _Xdmf.XdmfGrid_FindGridsAtTime(*args)
def Release(*args): return _Xdmf.XdmfGrid_Release(*args)
XdmfGrid_swigregister = _Xdmf.XdmfGrid_swigregister
XdmfGrid_swigregister(XdmfGrid)
......
......@@ -43,6 +43,12 @@ XdmfAttribute::~XdmfAttribute() {
delete this->ShapeDesc;
}
XdmfInt32
XdmfAttribute::Release(){
if( this->ValuesAreMine && this->Values ) delete this->Values;
this->Values = NULL;
return(XDMF_SUCCESS);
}
XdmfInt32
XdmfAttribute::Insert( XdmfElement *Child){
......
......@@ -123,7 +123,8 @@ public:
XdmfInt32 Update();
//! Build XML (output)
XdmfInt32 Build();
//! Release Big Data
XdmfInt32 Release();
protected:
XdmfInt32 AttributeType;
......
......@@ -51,13 +51,22 @@ XdmfDataItem::XdmfDataItem() {
XdmfDataItem::~XdmfDataItem() {
XdmfDebug(".... Deleteing DataItem " << this);
XdmfDebug("Deleteing array");
if(this->Array && this->ArrayIsMine ) delete this->Array;
XdmfDebug("Done Deleteing array");
if(this->Array && this->ArrayIsMine ){
XdmfDebug("Deleteing array " << this->Array);
delete this->Array;
XdmfDebug("Done Deleteing array");
}
if(this->DataDesc && this->DataDescIsMine) delete this->DataDesc;
if(this->Values) delete this->Values;
}
XdmfInt32
XdmfDataItem::Release(){
// Don't Delete it.
if(this->Array) this->Array->SetNumberOfElements(3);
return(XDMF_SUCCESS);
}
XdmfInt32
XdmfDataItem::Insert( XdmfElement *Child){
if(Child && (
......
......@@ -196,6 +196,8 @@ public:
XdmfSetStringMacro(Function);
//! Get the Function String
XdmfGetStringMacro(Function);
//! Release Large Data
XdmfInt32 Release();
protected:
XdmfInt32 Format;
......
......@@ -51,6 +51,30 @@ XdmfGeometry::~XdmfGeometry() {
if( this->PointsAreMine && this->Points ) delete this->Points;
}
XdmfInt32
XdmfGeometry::Release()
{
XdmfDataItem *di = NULL;
XdmfXmlNode node;
XdmfInt32 Index = 0;
XdmfXmlNode Node;
if( this->PointsAreMine && this->Points ){
delete this->Points;
this->Points = NULL;
}
// this->NumberOfPoints = 0;
Node = this->GetElement();
node = this->DOM->FindDataElement(Index++, Node);
while(node) {
di = (XdmfDataItem *)this->GetCurrentXdmfElement(node);
if(di){
di->Release();
}
node = this->DOM->FindDataElement(Index++, Node);
}
return(XDMF_SUCCESS);
}
// Returns an existing DataItem or build a new one
XdmfDataItem *
XdmfGeometry::GetDataItem(XdmfInt32 Index, XdmfXmlNode Node){
......@@ -455,6 +479,9 @@ if( ( this->GeometryType == XDMF_GEOMETRY_X_Y_Z ) ||
}
}
}
if( points ) this->SetPoints( points );
if( points ){
this->SetPoints( points );
this->PointsAreMine = 1;
}
return( XDMF_SUCCESS );
}
......@@ -110,6 +110,8 @@ XDMF_GEOMETRY_ORIGIN_DXDYDZ : Xorigin, Yorigin, Zorigin, Dx, Dy, Dz
XdmfInt32 SetPoints( XdmfArray *Points );
XdmfArray *GetPoints(XdmfInt32 Create=1);
XdmfInt32 Release();
#ifndef SWIG
XdmfInt32 SetOrigin( XdmfFloat64 *Origin );
XdmfInt32 SetDxDyDz( XdmfFloat64 *DxDyDz);
......
......@@ -74,6 +74,17 @@ XdmfGrid::~XdmfGrid() {
free(this->Attribute);
}
XdmfInt32
XdmfGrid::Release(){
XdmfInt32 Index;
if( this->GeometryIsMine && this->Geometry ) this->Geometry->Release();
if( this->TopologyIsMine && this->Topology ) this->Topology->Release();
for ( Index = 0; Index < this->NumberOfAttributes; Index ++ )
{
this->Attribute[Index]->Release();
}
return(XDMF_SUCCESS);
}
XdmfInt32
XdmfGrid::InsertTopology(){
if(!this->Topology->GetElement()){
......
......@@ -272,6 +272,9 @@ public:
//! Return indexes of first level children that are valid at a time
XdmfInt32 FindGridsAtTime(XdmfTime *Time, XdmfArray *ArrayToFill, XdmfFloat64 Epsilon = 0.0, XdmfInt32 Append=0);
//! Release Big Data
XdmfInt32 Release();
protected:
XdmfGeometry *Geometry;
......
......@@ -5284,6 +5284,28 @@ fail:
}
 
 
SWIGINTERN PyObject *_wrap_XdmfAttribute_Release(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
PyObject *resultobj = 0;
XdmfAttribute *arg1 = (XdmfAttribute *) 0 ;
XdmfInt32 result;
void *argp1 = 0 ;
int res1 = 0 ;
PyObject * obj0 = 0 ;
if (!PyArg_ParseTuple(args,(char *)"O:XdmfAttribute_Release",&obj0)) SWIG_fail;
res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfAttribute, 0 | 0 );
if (!SWIG_IsOK(res1)) {
SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfAttribute_Release" "', argument " "1"" of type '" "XdmfAttribute *""'");
}
arg1 = reinterpret_cast< XdmfAttribute * >(argp1);
result = (XdmfInt32)(arg1)->Release();
resultobj = SWIG_From_int(static_cast< int >(result));
return resultobj;
fail:
return NULL;
}
SWIGINTERN PyObject *XdmfAttribute_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
PyObject *obj;
if (!PyArg_ParseTuple(args,(char*)"O|swigregister", &obj)) return NULL;
......@@ -16906,6 +16928,28 @@ fail:
}
 
 
SWIGINTERN PyObject *_wrap_XdmfDataItem_Release(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
PyObject *resultobj = 0;
XdmfDataItem *arg1 = (XdmfDataItem *) 0 ;
XdmfInt32 result;
void *argp1 = 0 ;
int res1 = 0 ;
PyObject * obj0 = 0 ;
if (!PyArg_ParseTuple(args,(char *)"O:XdmfDataItem_Release",&obj0)) SWIG_fail;
res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfDataItem, 0 | 0 );
if (!SWIG_IsOK(res1)) {
SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfDataItem_Release" "', argument " "1"" of type '" "XdmfDataItem *""'");
}
arg1 = reinterpret_cast< XdmfDataItem * >(argp1);
result = (XdmfInt32)(arg1)->Release();
resultobj = SWIG_From_int(static_cast< int >(result));
return resultobj;
fail:
return NULL;
}
SWIGINTERN PyObject *XdmfDataItem_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
PyObject *obj;
if (!PyArg_ParseTuple(args,(char*)"O|swigregister", &obj)) return NULL;
......@@ -20783,6 +20827,28 @@ fail:
}
 
 
SWIGINTERN PyObject *_wrap_XdmfTopology_Release(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
PyObject *resultobj = 0;
XdmfTopology *arg1 = (XdmfTopology *) 0 ;
XdmfInt32 result;
void *argp1 = 0 ;
int res1 = 0 ;
PyObject * obj0 = 0 ;
if (!PyArg_ParseTuple(args,(char *)"O:XdmfTopology_Release",&obj0)) SWIG_fail;
res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfTopology, 0 | 0 );
if (!SWIG_IsOK(res1)) {
SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfTopology_Release" "', argument " "1"" of type '" "XdmfTopology *""'");
}
arg1 = reinterpret_cast< XdmfTopology * >(argp1);
result = (XdmfInt32)(arg1)->Release();
resultobj = SWIG_From_int(static_cast< int >(result));
return resultobj;
fail:
return NULL;
}
SWIGINTERN PyObject *XdmfTopology_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
PyObject *obj;
if (!PyArg_ParseTuple(args,(char*)"O|swigregister", &obj)) return NULL;
......@@ -21256,6 +21322,28 @@ fail:
}
 
 
SWIGINTERN PyObject *_wrap_XdmfGeometry_Release(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
PyObject *resultobj = 0;
XdmfGeometry *arg1 = (XdmfGeometry *) 0 ;
XdmfInt32 result;
void *argp1 = 0 ;
int res1 = 0 ;
PyObject * obj0 = 0 ;
if (!PyArg_ParseTuple(args,(char *)"O:XdmfGeometry_Release",&obj0)) SWIG_fail;
res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfGeometry, 0 | 0 );
if (!SWIG_IsOK(res1)) {
SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfGeometry_Release" "', argument " "1"" of type '" "XdmfGeometry *""'");
}
arg1 = reinterpret_cast< XdmfGeometry * >(argp1);
result = (XdmfInt32)(arg1)->Release();
resultobj = SWIG_From_int(static_cast< int >(result));
return resultobj;
fail:
return NULL;
}
SWIGINTERN PyObject *_wrap_XdmfGeometry_GetOrigin(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
PyObject *resultobj = 0;
XdmfGeometry *arg1 = (XdmfGeometry *) 0 ;
......@@ -22872,6 +22960,28 @@ fail:
}
 
 
SWIGINTERN PyObject *_wrap_XdmfGrid_Release(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
PyObject *resultobj = 0;
XdmfGrid *arg1 = (XdmfGrid *) 0 ;
XdmfInt32 result;
void *argp1 = 0 ;
int res1 = 0 ;
PyObject * obj0 = 0 ;
if (!PyArg_ParseTuple(args,(char *)"O:XdmfGrid_Release",&obj0)) SWIG_fail;
res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfGrid, 0 | 0 );
if (!SWIG_IsOK(res1)) {
SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfGrid_Release" "', argument " "1"" of type '" "XdmfGrid *""'");
}
arg1 = reinterpret_cast< XdmfGrid * >(argp1);
result = (XdmfInt32)(arg1)->Release();
resultobj = SWIG_From_int(static_cast< int >(result));
return resultobj;
fail:
return NULL;
}
SWIGINTERN PyObject *XdmfGrid_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
PyObject *obj;
if (!PyArg_ParseTuple(args,(char*)"O|swigregister", &obj)) return NULL;
......@@ -23915,6 +24025,7 @@ static PyMethodDef SwigMethods[] = {
{ (char *)"XdmfAttribute_UpdateInformation", _wrap_XdmfAttribute_UpdateInformation, METH_VARARGS, NULL},
{ (char *)"XdmfAttribute_Update", _wrap_XdmfAttribute_Update, METH_VARARGS, NULL},
{ (char *)"XdmfAttribute_Build", _wrap_XdmfAttribute_Build, METH_VARARGS, NULL},
{ (char *)"XdmfAttribute_Release", _wrap_XdmfAttribute_Release, METH_VARARGS, NULL},
{ (char *)"XdmfAttribute_swigregister", XdmfAttribute_swigregister, METH_VARARGS, NULL},
{ (char *)"XdmfTypeToHDF5Type", _wrap_XdmfTypeToHDF5Type, METH_VARARGS, NULL},
{ (char *)"HDF5TypeToXdmfType", _wrap_HDF5TypeToXdmfType, METH_VARARGS, NULL},
......@@ -24115,6 +24226,7 @@ static PyMethodDef SwigMethods[] = {
{ (char *)"XdmfDataItem_GetIsMultiple", _wrap_XdmfDataItem_GetIsMultiple, METH_VARARGS, NULL},
{ (char *)"XdmfDataItem_SetFunction", _wrap_XdmfDataItem_SetFunction, METH_VARARGS, NULL},
{ (char *)"XdmfDataItem_GetFunction", _wrap_XdmfDataItem_GetFunction, METH_VARARGS, NULL},
{ (char *)"XdmfDataItem_Release", _wrap_XdmfDataItem_Release, METH_VARARGS, NULL},
{ (char *)"XdmfDataItem_swigregister", XdmfDataItem_swigregister, METH_VARARGS, NULL},
{ (char *)"new_XdmfDataStructure", _wrap_new_XdmfDataStructure, METH_VARARGS, NULL},
{ (char *)"delete_XdmfDataStructure", _wrap_delete_XdmfDataStructure, METH_VARARGS, NULL},
......@@ -24232,6 +24344,7 @@ static PyMethodDef SwigMethods[] = {
{ (char *)"XdmfTopology_GetCellOffsets", _wrap_XdmfTopology_GetCellOffsets, METH_VARARGS, NULL},
{ (char *)"XdmfTopology_Update", _wrap_XdmfTopology_Update, METH_VARARGS, NULL},
{ (char *)"XdmfTopology_UpdateInformation", _wrap_XdmfTopology_UpdateInformation, METH_VARARGS, NULL},
{ (char *)"XdmfTopology_Release", _wrap_XdmfTopology_Release, METH_VARARGS, NULL},
{ (char *)"XdmfTopology_swigregister", XdmfTopology_swigregister, METH_VARARGS, NULL},
{ (char *)"HandleToXdmfTopology", _wrap_HandleToXdmfTopology, METH_VARARGS, NULL},
{ (char *)"new_XdmfGeometry", _wrap_new_XdmfGeometry, METH_VARARGS, NULL},
......@@ -24249,6 +24362,7 @@ static PyMethodDef SwigMethods[] = {
{ (char *)"XdmfGeometry_UpdateInformation", _wrap_XdmfGeometry_UpdateInformation, METH_VARARGS, NULL},
{ (char *)"XdmfGeometry_SetPoints", _wrap_XdmfGeometry_SetPoints, METH_VARARGS, NULL},
{ (char *)"XdmfGeometry_GetPoints", _wrap_XdmfGeometry_GetPoints, METH_VARARGS, NULL},
{ (char *)"XdmfGeometry_Release", _wrap_XdmfGeometry_Release, METH_VARARGS, NULL},
{ (char *)"XdmfGeometry_GetOrigin", _wrap_XdmfGeometry_GetOrigin, METH_VARARGS, NULL},
{ (char *)"XdmfGeometry_GetOriginX", _wrap_XdmfGeometry_GetOriginX, METH_VARARGS, NULL},
{ (char *)"XdmfGeometry_GetOriginY", _wrap_XdmfGeometry_GetOriginY, METH_VARARGS, NULL},
......@@ -24303,6 +24417,7 @@ static PyMethodDef SwigMethods[] = {
{ (char *)"XdmfGrid_GetChild", _wrap_XdmfGrid_GetChild, METH_VARARGS, NULL},
{ (char *)"XdmfGrid_FindGridsInTimeRange", _wrap_XdmfGrid_FindGridsInTimeRange, METH_VARARGS, NULL},
{ (char *)"XdmfGrid_FindGridsAtTime", _wrap_XdmfGrid_FindGridsAtTime, METH_VARARGS, NULL},
{ (char *)"XdmfGrid_Release", _wrap_XdmfGrid_Release, METH_VARARGS, NULL},
{ (char *)"XdmfGrid_swigregister", XdmfGrid_swigregister, METH_VARARGS, NULL},
{ (char *)"HandleToXdmfGrid", _wrap_HandleToXdmfGrid, METH_VARARGS, NULL},
{ (char *)"new_XdmfTime", _wrap_new_XdmfTime, METH_VARARGS, NULL},
......
......@@ -58,6 +58,15 @@ XdmfTopology::~XdmfTopology() {
delete this->Shape;
}
XdmfInt32
XdmfTopology::Release(){
if( this->ConnectivityIsMine && this->Connectivity ) delete this->Connectivity;
if(this->CellOffsets) delete this->CellOffsets;
this->Connectivity = NULL;
this->CellOffsets = NULL;
return(XDMF_SUCCESS);
}
XdmfInt32
XdmfTopology::Build(){
if(XdmfElement::Build() != XDMF_SUCCESS) return(XDMF_FAIL);
......@@ -583,6 +592,7 @@ if( this->GetClass() == XDMF_UNSTRUCTURED ){
// Steal the Array so it doesn't get deleted in the destructor of the DataItem
this->Connectivity = Connections.GetArray();
Connections.SetArrayIsMine(0);
this->ConnectivityIsMine = 1;
if( this->BaseOffset ) {
XdmfDebug("Adjusting due to BaseOffset");
......
......@@ -292,6 +292,8 @@ public:
XdmfInt32 Update( void );
//! Intiailize the Topology but do not access the Heavy Data
XdmfInt32 UpdateInformation(void);
//! Release Big Data
XdmfInt32 Release();
#ifndef DOXYGEN_SKIP
// XdmfInt32 SetBaseConnectivity( XdmfPointer Grid );
#endif
......
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