#include "HDFconvert.hxx"
#include "HDFascii.hxx"
+
+#include "HDFarray.hxx"
--- /dev/null
+// Copyright (C) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+// SALOME HDFPersist : implementation of HDF persitent ( save/ restore )
+// File : HDFarray.cc
+// Module : SALOME
+//
+#include "HDFarray.hxx"
+#include "HDFexception.hxx"
+#include "hdfi.h"
+
+
+HDFarray::HDFarray( HDFobject* father, hdf_type dataType, int ndim, hdf_size *dim )
+ : HDFobject("")
+{
+ _father = father;
+ _datatype = dataType;
+ _ndim = ndim;
+ _dim = dim;
+}
+
+HDFarray::HDFarray( HDFobject* father)
+ : HDFobject("")
+{
+ _father = father;
+ _datatype = HDF_NONE;
+ _ndim = -1;
+ _dim = 0;
+
+ if( father )
+ _id = HDFarrayGetTypeId(father->GetId());
+
+}
+
+
+HDFarray::~HDFarray()
+{
+ if(_dim )
+ delete [] _dim;
+}
+
+hdf_type HDFarray::GetDataType() {
+ if (_datatype == HDF_NONE)
+ if ((_datatype = HDFarrayGetType(_id)) == HDF_NONE )
+ throw HDFexception("Can't determine the type of array data");
+ return _datatype;
+}
+
+
+void HDFarray::CreateOnDisk() {
+ if( (_id = HDFarrayCreate(_datatype,_ndim, _dim)) < 0 )
+ throw HDFexception("Can't create HDF array");
+}
+
+void HDFarray::CloseOnDisk() {
+ if( HDFarrayClose(_id) < 0 )
+ throw HDFexception("Can't close HDF array");
+}
+
+int HDFarray::nDim() {
+ if (_ndim == -1)
+ if ((_ndim = HDFarrayGetnDim(_id)) < 0)
+ throw HDFexception("Can't determine the array dimensions number");
+
+ return _ndim;
+
+}
+
+
+void HDFarray::GetDim(hdf_size dim[]) {
+ int i;
+ int ndim;
+ hdf_err ret;
+
+ if (_dim == 0)
+ {
+ if (_ndim == -1)
+ ndim = HDFdatasetGetnDim(_id);
+ else
+ ndim = _ndim;
+ _dim = new hdf_size[ndim];
+ if ((ret = HDFarrayGetDim(_id,_dim)) < 0)
+ throw HDFexception("Can't determine the size dimensions of the array ");
+ }
+
+ for (i=0;i<_ndim;i++)
+ dim[i] = _dim[i];
+}
+
+
+hdf_object_type HDFarray::GetObjectType() {
+ return HDF_ARRAY_TYPE;
+}
--- /dev/null
+// Copyright (C) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+// SALOME HDFPersist : implementation of HDF persitent ( save/ restore )
+// File : HDFarray.hxx
+// Module : SALOME
+//
+#ifndef HDFARRAY_HXX
+#define HDFARRAY_HXX
+
+#include "HDFobject.hxx"
+#include "HDFexport.hxx"
+
+class HDFPERSIST_EXPORT HDFarray : public HDFobject {
+protected:
+ HDFobject* _father;
+ hdf_type _datatype;
+ hdf_size* _dim;
+ int _ndim;
+
+public :
+ HDFarray( HDFobject* father, hdf_type dataType, int ndim, hdf_size *dim);
+
+ HDFarray( HDFobject* father);
+
+ virtual ~HDFarray();
+
+ virtual hdf_type GetDataType();
+
+ virtual hdf_object_type GetObjectType();
+
+ void CreateOnDisk();
+ void CloseOnDisk();
+
+ int nDim();
+ void GetDim(hdf_size dim[]);
+};
+
+#endif /* HDFARRAY_HXX */
+
--- /dev/null
+// Copyright (C) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+/*----------------------------------------------------------------------------
+ SALOME HDFPersist : implementation of HDF persitent ( save/ restore )
+ File : HDFarrayClose.c
+ Module : SALOME
+----------------------------------------------------------------------------*/
+
+#include "hdfi.h"
+
+/*
+ * - Name : HDFarrayClose
+ * - Description : close a HDF array
+ * - Parameters :
+ * - id (IN) : array ID
+ * - Result :
+ * - if success : returns 0
+ * - if failure : returns -1
+ */
+
+hdf_err
+HDFarrayClose(hdf_idt id)
+{
+ hdf_err ret;
+
+ if ((ret = H5Tclose(id)) < 0)
+ return -1;
+
+ return 0;
+}
--- /dev/null
+// Copyright (C) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+/*----------------------------------------------------------------------------
+SALOME HDFPersist : implementation of HDF persitent ( save/ restore )
+ File : HDFarrayCreate.c
+ Module : SALOME
+----------------------------------------------------------------------------*/
+
+#include "hdfi.h"
+
+/*
+ * - Name : HDFarrayCreate
+ * - Description : creates a HDF array
+ * - Parameters :
+ * - dataType (IN) : type of the data in the array (HDF_INT32, HDF_INT64, HDF_FLOAT64, HDF_CHAR).
+ * - ndim (IN) : is the number of dimensions and the size of each dimension is specified in the array dims.
+ * - dim (IN) : size of each array dimension.
+ * - Result :
+ * - if success : returns array ID
+ * - if failure : -1
+ */
+
+hdf_idt HDFarrayCreate(hdf_type dataType, int ndim, hdf_size *dim)
+{
+ hdf_idt type_hdf;
+ switch(dataType)
+ {
+ case HDF_FLOAT64 :
+#if defined (PCLINUX) || defined (PCLINUX64)
+ type_hdf = H5T_IEEE_F64BE;
+#else
+ type_hdf = H5T_IEEE_F64LE;
+#endif
+ break;
+
+ case HDF_INT32 :
+#if defined (PCLINUX) || defined (PCLINUX64)
+ type_hdf = H5T_STD_I32BE;
+#else
+ type_hdf = H5T_NATIVE_INT;
+#endif
+ break;
+
+ case HDF_INT64 :
+ type_hdf = H5T_NATIVE_LONG;
+ break;
+ case HDF_CHAR :
+ type_hdf = H5T_NATIVE_CHAR;
+ break;
+ default:
+ return -1;
+ break;
+ }
+
+ return H5Tarray_create2( type_hdf, ndim, dim );
+}
--- /dev/null
+// Copyright (C) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+/*----------------------------------------------------------------------------
+ SALOME HDFPersist : implementation of HDF persitent ( save/ restore )
+ File : HDFarrayGetDim.c
+ Module : SALOME
+----------------------------------------------------------------------------*/
+
+#include <hdf5.h>
+#include "hdfi.h"
+#include <stdlib.h>
+
+hdf_err
+HDFarrayGetDim(hdf_idt id,hdf_size dim[])
+{
+ hdf_err ret = 0;
+ hdf_size *tmp;
+ int ndim, i;
+
+ if ( (ndim = H5Tget_array_ndims(id)) < 0 )
+ return -1;
+
+ tmp = (hdf_size *) malloc(sizeof(hdf_size)*ndim);
+
+ ret = H5Tget_array_dims2(id, tmp);
+
+ for( i=0 ; i < ndim ; i++)
+ dim[i] = tmp[i];
+
+ free (tmp);
+
+ return ret;
+}
--- /dev/null
+// Copyright (C) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+/*----------------------------------------------------------------------------
+ SALOME HDFPersist : implementation of HDF persitent ( save/ restore )
+ File : HDFarrayGetType.c
+ Module : SALOME
+----------------------------------------------------------------------------*/
+
+#include "hdfi.h"
+#include <hdf5.h>
+
+hdf_type
+HDFarrayGetType(hdf_idt type_id)
+{
+ hdf_idt super;
+ hdf_type type;
+ hdf_size_type size;
+
+ if(type_id < 0 )
+ return HDF_NONE;
+
+ if((super = H5Tget_super(type_id)) < 0 )
+ return HDF_NONE;
+
+ switch (H5Tget_class(super))
+ {
+ case H5T_INTEGER :
+ size = H5Tget_size(super);
+ if(size == 1)
+ type = HDF_CHAR;
+ else if (size == 4)
+ type = HDF_INT32;
+ else
+ type = HDF_INT64;
+ break;
+
+ case H5T_FLOAT :
+ type = HDF_FLOAT64;
+ break;
+
+ case H5T_STRING :
+ type = HDF_STRING;
+ break;
+
+ default :
+ type = HDF_NONE;
+ }
+
+ H5Tclose(super);
+ return type;
+}
--- /dev/null
+// Copyright (C) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+/*----------------------------------------------------------------------------
+ SALOME HDFPersist : implementation of HDF persitent ( save/ restore )
+ File : HDFarrayGetTypeId.c
+ Module : SALOME
+----------------------------------------------------------------------------*/
+
+#include "hdfi.h"
+#include <hdf5.h>
+
+hdf_idt
+HDFarrayGetTypeId(hdf_idt id) {
+ return H5Dget_type(id);
+}
--- /dev/null
+// Copyright (C) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+/*----------------------------------------------------------------------------
+ SALOME HDFPersist : implementation of HDF persitent ( save/ restore )
+ File : HDFarrayGetnDim.c
+ Module : SALOME
+----------------------------------------------------------------------------*/
+
+#include "hdfi.h"
+#include <hdf5.h>
+
+int
+HDFarrayGetnDim(hdf_idt id)
+{
+ int ndim;
+
+ if ((ndim = H5Tget_array_ndims(id)) < 0)
+ return -1;
+
+ return ndim;
+}
void write_float64(FILE* fp, hdf_float64* value);
void read_float64(FILE* fp, hdf_float64* value);
+void WriteSimpleData( FILE* fp, HDFdataset *hdf_dataset, hdf_type type, long size );
+
#define MAX_STRING_SIZE 65535
#define MAX_ID_SIZE 20
#define NB_FLOAT_IN_ROW 3
delete [] dim;
fprintf(fp, "%li %i:", size, order);
-
- if (type == HDF_STRING) {
- char* val = new char[size];
- hdf_dataset->ReadFromDisk(val);
- fwrite(val, 1, size, fp);
- delete [] val;
- } else if (type == HDF_FLOAT64) {
- hdf_float64* val = new hdf_float64[size];
- hdf_dataset->ReadFromDisk(val);
- fprintf(fp, "\n");
- for (int i = 0, j = 0; i < size; i++) {
- write_float64(fp, &val[i]);
- if(++j == NB_FLOAT_IN_ROW) {
- fprintf(fp, "\n");
- j = 0;
- }
- else fprintf(fp," ");
- }
- delete [] val;
- } else if(type == HDF_INT64) {
- hdf_int64* val = new hdf_int64[size];
- hdf_dataset->ReadFromDisk(val);
- fprintf(fp, "\n");
- for (int i = 0, j = 0; i < size; i++) {
- fprintf(fp, " %li", val[i]);
- if(++j == NB_INTEGER_IN_ROW) {
- fprintf(fp, "\n");
- j = 0;
- }
- }
- delete [] val;
- } else if(type == HDF_INT32) {
- hdf_int32* val = new hdf_int32[size];
- hdf_dataset->ReadFromDisk(val);
- fprintf(fp, "\n");
- for (int i = 0, j = 0; i < size; i++) {
- fprintf(fp, " %i", val[i]);
- if(++j == NB_INTEGER_IN_ROW) {
- fprintf(fp, "\n");
- j = 0;
- }
+ if( type == HDF_ARRAY ) {
+ HDFarray *array = new HDFarray(hdf_dataset);
+ hdf_type data_type = array->GetDataType();
+ fprintf(fp, "\n" );
+ fprintf(fp, " %i\n", data_type ); //Write array data type
+
+ //Write nDim of the array
+ int arr_ndim = array->nDim();
+ fprintf(fp, " %i\n", arr_ndim);
+ hdf_size *arr_dim = new hdf_size[arr_ndim];
+ array->GetDim(arr_dim);
+
+ for( int i = 0;i < arr_ndim; i++ ) {
+ fprintf(fp, " %i", arr_dim[i]);
}
- delete [] val;
+
+ //And write the data array
+ WriteSimpleData( fp, hdf_dataset, data_type, size);
+ } else {
+ WriteSimpleData( fp, hdf_dataset, type, size);
}
fprintf(fp, "\n");
sizeArray[i] = dim;
}
- // order (2-d member) was not written in earlier versions
+ // order (2-d member) was not written in earlier versions
char tmp;
int nbRead = fscanf(fp, "%li %i%c", &size, &order, &tmp);
if ( nbRead < 2 ) { // fscanf stops before ":"
if ( type != HDF_FLOAT64 ) // use order only for FLOAT64
order = H5T_ORDER_NONE;
- HDFdataset* hdf_dataset = new HDFdataset(new_name, father,type, sizeArray, nbDim, order);
+
+ HDFarray* anArray = 0;
+ if( type == HDF_ARRAY ){
+ //Get array information
+ hdf_type arr_data_type;
+ int arr_ndim;
+ fscanf(fp, "%c", &tmp);
+ fscanf(fp, " %i\n", &arr_data_type ); //Get array data type
+ fscanf(fp, " %i\n", &arr_ndim ); //Get array nDim
+ hdf_size *arr_dim = new hdf_size[arr_ndim];
+
+ int tdim = 0;
+ for( int i = 0;i < arr_ndim; i++ ) {
+ fscanf(fp, " %i", &tdim);
+ arr_dim[i] = tdim;
+ }
+ anArray = new HDFarray(0, arr_data_type, arr_ndim, arr_dim);
+ anArray->CreateOnDisk();
+
+ type = arr_data_type;
+ delete [] arr_dim;
+ }
+
+ HDFdataset* hdf_dataset = new HDFdataset(new_name, father, anArray ? HDF_ARRAY : type, sizeArray, nbDim, order);
+
+ if(anArray)
+ hdf_dataset->SetArrayId(anArray->GetId());
+
delete [] new_name;
delete [] sizeArray;
}
hdf_dataset->WriteOnDisk(val);
delete [] val;
+ } else if(type == HDF_CHAR) {
+ hdf_char* val = new hdf_char[size];
+ for(i=0; i<size; i++) {
+ fscanf(fp, " %i", &(val[i]));
+ }
+ hdf_dataset->WriteOnDisk(val);
+ delete [] val;
}
char token[MAX_ID_SIZE];
hdf_dataset->CloseOnDisk();
hdf_dataset = 0; //will be deleted by father destructor
+ if(anArray) {
+ anArray->CloseOnDisk();
+ anArray = 0; //will be deleted by father destructor
+ }
+
return true;
}
#endif
}
+void WriteSimpleData( FILE* fp, HDFdataset *hdf_dataset, hdf_type type, long size ) {
+ if (type == HDF_STRING) {
+ char* val = new char[size];
+ hdf_dataset->ReadFromDisk(val);
+ fwrite(val, 1, size, fp);
+ delete [] val;
+ } else if (type == HDF_FLOAT64) {
+ hdf_float64* val = new hdf_float64[size];
+ hdf_dataset->ReadFromDisk(val);
+ fprintf(fp, "\n");
+ for (int i = 0, j = 0; i < size; i++) {
+ write_float64(fp, &val[i]);
+ if(++j == NB_FLOAT_IN_ROW) {
+ fprintf(fp, "\n");
+ j = 0;
+ }
+ else fprintf(fp," ");
+ }
+ delete [] val;
+ } else if(type == HDF_INT64) {
+ hdf_int64* val = new hdf_int64[size];
+ hdf_dataset->ReadFromDisk(val);
+ fprintf(fp, "\n");
+ for (int i = 0, j = 0; i < size; i++) {
+ fprintf(fp, " %li", val[i]);
+ if(++j == NB_INTEGER_IN_ROW) {
+ fprintf(fp, "\n");
+ j = 0;
+ }
+ }
+ delete [] val;
+ } else if(type == HDF_INT32) {
+ hdf_int32* val = new hdf_int32[size];
+ hdf_dataset->ReadFromDisk(val);
+ fprintf(fp, "\n");
+ for (int i = 0, j = 0; i < size; i++) {
+ fprintf(fp, " %i", val[i]);
+ if(++j == NB_INTEGER_IN_ROW) {
+ fprintf(fp, "\n");
+ j = 0;
+ }
+ }
+ delete [] val;
+ }else if(type == HDF_CHAR) {
+ hdf_char* val = new hdf_char[size];
+ hdf_dataset->ReadFromDisk(val);
+ fprintf(fp, "\n");
+ for (int i = 0, j = 0; i < size; i++) {
+ fprintf(fp, " %i", val[i]);
+ if(++j == NB_INTEGER_IN_ROW) {
+ fprintf(fp, "\n");
+ j = 0;
+ }
+ }
+ delete [] val;
+ }
+}
_dim[i] = dim[i];
_size = _size * _dim[i];
}
+ _arrayId = -1;
}
_byte_order = H5T_ORDER_ERROR;
_size = -1;
_attribute = NULL;
+ _arrayId = -1;
}
HDFdataset::~HDFdataset()
void HDFdataset::CreateOnDisk()
{
- if ((_id = HDFdatasetCreate(_fid,_name,_type,_dim,_ndim,_byte_order)) < 0)
+ if ((_id = HDFdatasetCreate(_fid,_name,_type,_dim,_ndim,_byte_order,_arrayId)) < 0)
throw HDFexception("Can't create dataset");
}
return _attribute;
}
+void HDFdataset::SetArrayId(hdf_idt arrayId) {
+ _arrayId = arrayId;
+}
hdf_size _size;
int _ndim;
char* _attribute;
+ hdf_idt _arrayId;
public:
HDFdataset(const char *name, HDFcontainerObject *father,hdf_type type,
hdf_object_type GetObjectType();
hdf_byte_order GetOrder();
+ void SetArrayId(hdf_idt arrayId);
+
int nAttributes();
char* GetAttributeName(unsigned idx);
};
*/
hdf_idt HDFdatasetCreate(hdf_idt pid,char *name,hdf_type type,
- hdf_size *dimd, int ndim, hdf_byte_order order)
+ hdf_size *dimd, int ndim, hdf_byte_order order, hdf_idt arrayId)
{
hdf_idt dataset, dataspace = 0;
hdf_err ret;
return -1;
if((ret = H5Tset_size(new_type_hdf,1)) < 0)
return -1;
- break;
+ break;
+ case HDF_ARRAY :
+ type_hdf = arrayId;
+ break;
+
default :
return -1;
}
case H5T_STRING :
type = HDF_STRING;
break;
+
+ case H5T_ARRAY :
+ type = HDF_ARRAY;
+ break;
default :
type = HDF_NONE;
typedef hbool_t hdf_bool;
typedef H5T_order_t hdf_byte_order;
+typedef char hdf_char;
typedef int hdf_int32;
typedef long hdf_int64;
typedef double hdf_float64;
typedef enum {HDF_RDONLY,HDF_RDWR} hdf_access_mode;
/* Values types for HDF datasets and attributes */
-typedef enum {HDF_NONE,HDF_STRING, HDF_INT32, HDF_INT64, HDF_FLOAT64} hdf_type;
+typedef enum {HDF_NONE,HDF_STRING, HDF_INT32, HDF_INT64, HDF_FLOAT64, HDF_CHAR, HDF_ARRAY} hdf_type;
/* - HDF_STRING : C string
- HDF_INT32 : 32 bits integer
- HDF_INT64 : 64 bits integer
- HDF_FLOAT64 : IEEE 64 bits float
+ - HDF_ARRAY : Array
*/
/* HDF object types */
typedef enum {HDF_OBJECT,HDF_FILE,HDF_GROUP,HDF_DATASET,
- HDF_ATTRIBUTE} hdf_object_type;
+ HDF_ATTRIBUTE, HDF_ARRAY_TYPE } hdf_object_type;
#endif /* HDFTYPES_H */
HDFgroup.hxx \
HDFinternalObject.hxx \
HDFobject.hxx \
+ HDFarray.hxx \
HDFOI.hxx \
HDFtypes.h \
HDFconvert.hxx \
HDFdatasetGetType.c \
HDFdatasetGetnDim.c \
HDFdatasetGetOrder.c \
+ HDFarrayGetType.c \
+ HDFarrayGetTypeId.c \
+ HDFarrayCreate.c \
+ HDFarrayClose.c \
+ HDFarrayGetnDim.c \
+ HDFarrayGetDim.c \
HDFattrOpen.c \
HDFattrClose.c \
HDFattrWrite.c \
HDFobjectIdentify.c \
HDFobjectType.c \
HDFobject.cc \
+ HDFarray.cc \
HDFinternalObject.cc \
HDFattribute.cc \
HDFcontainerObject.cc \
hdf_err HDFdatasetClose(hdf_idt id);
extern
-hdf_idt HDFdatasetCreate(hdf_idt pid,char *name,hdf_type type,
- hdf_size *dimd, int ndim, hdf_byte_order order);
+hdf_idt HDFdatasetCreate(hdf_idt pid,char *name, hdf_type type,
+ hdf_size *dimd, int ndim, hdf_byte_order order, hdf_idt arrayId);
extern
hdf_err HDFdatasetWrite(hdf_idt id, void *val);
extern
hdf_type HDFdatasetGetType(hdf_idt id);
+extern
+hdf_type HDFarrayGetType(hdf_idt id);
+
+extern
+hdf_idt HDFarrayGetTypeId(hdf_idt type_id);
+
+extern
+hdf_err HDFarrayClose(hdf_idt id);
+
+extern
+int HDFarrayGetnDim(hdf_idt id);
+
+extern
+hdf_err HDFarrayGetDim(hdf_idt id, hdf_size dim[]);
+
+
+extern
+hdf_idt HDFarrayCreate(hdf_type dataType,int ndim,hdf_size *dim);
+
extern
int HDFdatasetGetnDim(hdf_idt id);