findAndGetOFStringArray and findAndGetOFString

All other questions regarding DCMTK

Moderator: Moderator Team

Post Reply
Message
Author
Roadrunner
Posts: 56
Joined: Mon, 2010-06-14, 16:41

findAndGetOFStringArray and findAndGetOFString

#1 Post by Roadrunner »

Today I tryed to get the pixel spacing value.
From a dump i saw the following: (0018,1164) DS [0.086196\0.086215] # 18, 2 ImagerPixelSpacing

My first thought was to use "findAndGetOFString" which gave 0.086196 as result. okay i thought the \0 is the end of a string - so you have to use
an array as follow

Code: Select all

OFString *pixelSpacingStringArray = (OFString*) malloc(2 * sizeof(OFString));
    if (!pixelSpacingStringArray){
        qDebug() << "malloc error!";
            pixelSpacingHorizontal = 0.0;
            pixelSpacingVertikal   = 0.0;
    }
    else{
        qDebug() << "malloc okay";

        if((dataset->findAndGetOFStringArray(DCM_ImagerPixelSpacing, *pixelSpacingStringArray,false).good())
                ||
            (dataset->findAndGetOFStringArray(DCM_PixelSpacing, *pixelSpacingStringArray,false).good()) )
        {
            qDebug() << "spacing string: " << pixelSpacingStringArray[0].c_str();
            qDebug() << "spacing string: " << pixelSpacingStringArray[1].c_str();
            free(pixelSpacingStringArray); // free malloced memory
        }

        else{
            pixelSpacingHorizontal = 0.0;
            pixelSpacingVertikal   = 0.0;
        }

The debug output was:
01:18:05 Debug: spacing string: 0.086196\0.086215

01:18:05 Debug: spacing string:

So my feeling is GetArrayOfOFstring doesn't look for the \0 and copies the whole string while GetOFString
doesn't copy the whole string because of the \0. :>

I'm using the dcmtk-3.6.1_20120222 (VC++ 2010 release build)

Btw for a hint to make it better would be nice. ;-)

Frank

J. Riesmeier
DCMTK Developer
Posts: 2501
Joined: Tue, 2011-05-03, 14:38
Location: Oldenburg, Germany
Contact:

#2 Post by J. Riesmeier »

Did you ever look into the API documentation? :-)

- findAndGetOFString()
- findAndGetOFStringArray()

Of course, you could also use findAndGetFloat64() for this DS element ...

Roadrunner
Posts: 56
Joined: Mon, 2010-06-14, 16:41

#3 Post by Roadrunner »

Did you ever look into the API documentation?
Shame on me - no... and sorry for it. :(

It's working right now.

Thank you for your help. :-)

Frank

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Baidu [Spider], Google [Bot] and 1 guest