LDicomDS::InsertElement

Summary

Inserts a new element in the Data Set.

Syntax

#include "Ltdic.h"

pDICOMELEMENT LDicomDS::InsertElement(pNeighbor, bChild, nTag, nVR, bSequence, nIndex)

Parameters

pDICOMELEMENT pNeighbor

Pointer to a DICOMELEMENT structure that contains an item in the Data Set. The inserted item will be inserted as a neighbor to this item, or as a child, depending on the value of bChild.

L_BOOL bChild

Flag that indicates where to insert the item. Possible values are:

Value Meaning
TRUE The new item will be inserted as the last child of pNeighbor.
FALSE The new item will be inserted as the last sibling of pNeighbor.

L_UINT32 nTag

Tag value for the inserted element. For a list of default values, refer to Data Element Tag Constants.

L_UINT16 nVR

Value representation code that indicates the type of value stored in the data element. For a list of default values supported by DICOM, refer to Value Representation Constants.

L_BOOL bSequence

Flag that indicates whether the new item is a sequence. Possible values are:

Value Meaning
TRUE The new item is a sequence.
FALSE The new item is not a sequence.

L_UINT32 nIndex

Index value that indicates where to insert a TAG_ITEM data element in a sequence. This parameter is valid only if the data element being inserted has a tag of value TAG_ITEM. If the data element being inserted has any other tag value, this parameter is ignored. The index is zero based, so if you want to insert a TAG_ITEM data element as the first item in the sequence, set this to 0. The value ELEMENT_INDEX_MAX indicates to add the TAG_ITEM data element to the end of the sequence.

A sequence may consist of one or more items. This parameter lets you insert a TAG_ITEM data element as any item within the sequence, not just at the end. In addition, it lets you insert multiple TAG_ITEM data elements within a sequence. If pNeighbor points to the parent of a sequence and bChild is true, the index will pertain to the children of pNeighbor. If pNeighbor points to a member of a sequence and bChild is false, the index pertains to the siblings of pNeighbor.

Returns

Value Meaning
!NULL A pointer to a DICOMELEMENT structure containing the newly inserted item.
NULL Not enough memory to insert the item.

Comments

The illustrations below show how items are added to the Data Set (internally maintained as a tree), based on the value of bChild.

For the sake of these illustrations, the order of siblings is top to bottom. Therefore, since added items become the last sibling or the last child, these are drawn at the bottom of the appropriate group of items.

In this illustration, pNeighbor points to Item 1 and bChild is False. The new item is added as the last sibling of Item 1.

image\IODIsSib.gif

In this illustration, pNeighbor points to Item 1 and bChild is True. The new item is added as the last child of Item 1.

image\IODIsChd.gif

Required DLLs and Libraries

Platforms

Win32, x64

See Also

Functions

Topics

Example

This example inserts 2 elements in Data Set.

L_INT LDicomDS_InsertElementExample() 
{ 
   LDicomDS      *pDS; 
   pDICOMELEMENT  pElement; 
 
   pDS = new LDicomDS(NULL); 
 
   pDS->InitDS( CLASS_CT_IMAGE_STORAGE, 0);  
 
   pElement = pDS->InsertElement(NULL, FALSE, TAG_INSTITUTION_CODE_SEQUENCE, VR_SQ, TRUE, 0); 
   pElement = pDS->InsertElement(pElement, TRUE, TAG_CODE_VALUE, VR_SH, FALSE, 0); 
 
   delete pDS; 
 
   return DICOM_SUCCESS; 
} 

Help Version 22.0.2022.12.7
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.

LEADTOOLS DICOM C++ Class Library Help
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.