Help Inserting Multi-Valued fields using putAndInsertFloat32

All other questions regarding DCMTK

Moderator: Moderator Team

Post Reply
Message
Author
feldman_joel
Posts: 14
Joined: Fri, 2013-01-04, 16:23

Help Inserting Multi-Valued fields using putAndInsertFloat32

#1 Post by feldman_joel »

i am having difficulty trying to simply add a multi-valued field. any help would be appreciated. here is a code snippet:

Code: Select all

OFCondition result;
DcmItem *item_id_1 = new DcmItem();
result = item_id_1->putAndInsertFloat32( DCM_GraphicData /*(0070,0022)*/, 1.0, 0, OFTrue);
result = item_id_1->putAndInsertFloat32( DCM_GraphicData /*(0070,0022)*/, 2.0, 1, OFTrue);
the first call to putAndInsertFloat32 is successful, but the following calls generate an "Illegal call, perhaps the wrong parameters" message. simply put, i need tag (0070,0022) to have a VM of 2 and contain 1.0\2.0. i have tried several combinations for the third parameter, which is the position, but have not had any success.

thanks in advance for your help,

joel

Uli Schlachter
DCMTK Developer
Posts: 120
Joined: Thu, 2009-11-26, 08:15

Re: Help Inserting Multi-Valued fields using putAndInsertFlo

#2 Post by Uli Schlachter »

This is almost an exact duplicate of viewtopic.php?f=1&t=3653 and the answer will be the same.

Uli

Uli Schlachter
DCMTK Developer
Posts: 120
Joined: Thu, 2009-11-26, 08:15

Re: Help Inserting Multi-Valued fields using putAndInsertFlo

#3 Post by Uli Schlachter »

feldman_joel wrote:

Code: Select all

result = item_id_1->putAndInsertFloat32( DCM_GraphicData /*(0070,0022)*/, 2.0, 1, OFTrue);
This call tries to construct a new element and set its second entry to "2.0". The resulting element should then replace any already-existing entry in the item (=the one from the previous line). This fails because an element cannot have a second entry without having a first one.

Here's my version:

Code: Select all

	DcmItem *item_id_1 = new DcmItem();
	DcmFloatingPointSingle *elem = new DcmFloatingPointSingle(DCM_GraphicData);
	elem->putFloat32(1.0, 0);
	elem->putFloat32(2.0, 1);
	item_id_1->insert(elem, OFTrue);
(Checking for errors is left as an excercise for the interested reader)

Cheers,
Uli

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Bing [Bot] and 1 guest