You will need to create two datatypes. The one below seems ok for 32-bit pointers, though maybe you could also create a (temporary) atomic datatype for your pointer member, using

  herr_t H5Tset_size( hid_t dtype_id, sizeof(APolygon*)  )

just for this pointer member, so it'd be portable for 32 and 64 bit (and also 16 bit, if you want to run it under MSDOS :) ).

This datatype as you create below is the memory datatype. In addition, you need a disk datatype, which looks exactly the same, but without the pointer member, so on H5Tcreate() it will be of size sizeof(tempGroup)-sizeof(APolygon*)  , and you don't insert the pointer member on this second datatype.

This disk datatype is the one to be used for H5Dcreate(). The memory datatype is the one that you use when calling  H5Dwrite().

 I assume  currently you're using the same datatype for both functions. However, they don't need to be the same, and if they're not, HDF5 does that automatic data conversion, based on the names of the compound members.

       Werner


On Tue, 22 Nov 2011 09:47:44 -0600, Jeff Womble <[email protected]> wrote:

I tried to include my code in the original message, but it doesn't seem to have made it - sorry about that.  Here is the struct I'm working with:
typedef struct {
    char name[50];
    int partType;
    int faceType;
    int materialNumber;
    float thickness;
    unsigned int numberOfPolygons;
    APolygon *facets;              //array of polygons
} ASubGroup;

The last memeber, .facets, is what's causing me problems.  When I'm setting up my compound datatype, how do I account for this member, but not write it to the H5 file?

This is how I'm setting up the datatype now:
    ASubGroup tempGroup;
    hid_t tPartID = H5Tcreate(H5T_COMPOUND, sizeof(tempGroup));
    hsize_t arrDim[] = {50};
    hid_t tPartNameID = H5Tarray_create2(H5T_NATIVE_CHAR,1,arrDim);
    H5Tinsert(tPartID, "Name", HOFFSET(ASubGroup, name),
              tPartNameID);
    H5Tinsert(tPartID, "PartType",HOFFSET(ASubGroup, partType),
              H5T_NATIVE_INT);
    H5Tinsert(tPartID, "FaceType",HOFFSET(ASubGroup, faceType),
              H5T_NATIVE_INT);
    H5Tinsert(tPartID, "Material",HOFFSET(ASubGroup, materialNumber),
              H5T_NATIVE_INT);
    H5Tinsert(tPartID, "Thickness",HOFFSET(ASubGroup, thickness),
              H5T_NATIVE_FLOAT);
    H5Tinsert(tPartID, "NumberOfFacets",HOFFSET(ASubGroup, numberOfPolygons),
              H5T_NATIVE_UINT);
    H5Tinsert(tPartID, "reference", HOFFSET(ASubGroup, facets),
              H5T_NATIVE_UINT32);


On 11/22/2011 09:30 AM, Werner Benger wrote:
Hi,

 you just need a different HDF5 type for the memory (the struct including
your pointer) and for the layout on disk (struct with same member names
and compatible data types, but omitting the pointer member). Then HDF5
will just do this conversion and write only those disk-struct members,
reading data from the memory-struct, except your pointer which is not
used for disk output then.

    Werner

On Tue, 22 Nov 2011 08:21:34 -0600, jwomble <[email protected]> wrote:

Hello,
I have an array of structs that I need to write to a dataset.  One of the
members of the struct is a pointer to an array of floats.  Right now I am
creating a compound datatype and treating the pointer as an unsigned int,
and this works, but the pointer information is obviously useless data.  Is
there a way to write this array, but skip the pointer memeber?

Here is what I am currently doing:





Thanks!


--
View this message in context: http://hdf-forum.184993.n3.nabble.com/How-to-skip-a-member-in-a-struct-tp3527822p3527822.html
Sent from the hdf-forum mailing list archive at Nabble.com.

_______________________________________________
Hdf-forum is for HDF software users discussion.
[email protected]
http://mail.hdfgroup.org/mailman/listinfo/hdf-forum_hdfgroup.org






--
___________________________________________________________________________
Dr. Werner Benger Visualization Research
Laboratory for Creative Arts and Technology (LCAT)
Center for Computation & Technology at Louisiana State University (CCT/LSU)
211 Johnston Hall, Baton Rouge, Louisiana 70803
Tel.: +1 225 578 4809 Fax.: +1 225 578-5362
_______________________________________________
Hdf-forum is for HDF software users discussion.
[email protected]
http://mail.hdfgroup.org/mailman/listinfo/hdf-forum_hdfgroup.org

Reply via email to