Available in LEADTOOLS Medical Imaging toolkits. |
L_DicomCopyDSExt
#include "ltdic.h"
L_LTDIC_API L_UINT16 L_DicomCopyDSExt(hDstDS, pDstParent, hSrcDS, pSrcParent, pfnCallback, pUserData)
HDICOMDS hDstDS; |
/* a DICOM handle */ |
pDICOMELEMENT pDstParent; |
/* pointer to a DICOMELEMENT structure */ |
HDICOMDS hSrcDS; |
/* a DICOM handle */ |
pDICOMELEMENT pSrcParent; |
/* pointer to a DICOMELEMENT structure */ |
COPYDSCALLBACK pfnCallback; |
/* pointer to a callback function * |
L_VOID *pUserData; |
/* pointer to additional parameters */ |
Copies the data elements from one data set to another.
Parameter |
Description |
hDstDS |
A DICOM handle to the data set to receive the copied data set (the destination data set). |
pDstParent |
A pointer to a DICOMELEMENT structure that contains a Data element within the destination data set. A copy of the source data set will be inserted as the child of this data element. |
hSrcDS |
A DICOM handle to the data set to be copied (the source data set). |
pSrcParent |
A pointer to a DICOMELEMENT structure that contains a Data element within the source data set. All children, grandchildren, etc. of this element will be added to the destination data set. |
pfnCallback |
Optional callback function. If you do not provide a callback function, use NULL as the value of this parameter. If you do provide a callback function, use the function pointer as the value of this parameter. The callback function must adhere to the function prototype described in COPYDSCALLBACK Function. |
pUserData |
Void pointer that you can use to pass one or more additional parameters that the callback function needs. To use this feature, assign a value to a variable or create a structure that contains as many fields as you need. Then, in this parameter, pass the address of the variable or structure, casting it to L_VOID *. The callback function, which receives the address in its own pUserData parameter, can cast it to a pointer of the appropriate data type to access your variable or structure. If the additional parameters are not needed, you can pass NULL in this parameter. |
Returns
0 |
SUCCESS |
>0 |
An error occurred. Refer to Return Codes . |
Comments
If both pSrcParent and pDstParent are NULL, the source data set will be inserted at the root level of the destination data set. Therefore the highest level elements of the source data set will be added as siblings to the highest level elements of the destination data set. This can be seen in the diagram below.
If pSrcParent is not NULL and pDstParent is NULL, the children of pSrcParent will be added at the root level of the destination data set (i.e. as siblings to elements at the highest level). This can be seen in the diagram below. Note that the source elements to be added are in blue.
If pScrParent is NULL and pDstParent is not NULL, the entire source data set will be added as children to pDstParent. This can be seen in the diagram below.
If pSrcParent and pDstParent are both not NULL, then the children of pSrcParent are added as the children of pDstParent. This can be seen in the diagram below. The original children of pDstParent are in red and the source elements to be added are in blue.
If an inserted element has the same tag value as a destination element at the same level and with the same parent, then the value from the source element is copied into the destination element and any child elements are added accordingly. For example, the diagram below shows the result of a call to L_DicomCopyDSExt. If the two elements indicated by the arrows have the same tag value, the value from the source element is copied into the destination element and the structure on the right results. This is shown by the red outline of the destination element with the blue center of the source element.
To make the destination data set an exact copy of the source data set, instead of inserting it within the destination data set, you must call L_DicomResetDS with the destination data set as the parameter, before calling L_DicomCopyDSExt.
To copy only portions of a data set, use L_DicomCopyDSExt. The callback gets called before each DICOM element gets copied. Return TRUE in the callback function to copy the element. Return FALSE in the callback function to leave the element out of the data set. For more information, see the documentation for COPYDSCALLBACK.
Required DLLs and Libraries
LTDIC For a listing of the exact DLLs and Libraries needed, based on the toolkit version, refer to Files To Be Included With Your Application |
Win32, x64
See Also
Functions: |
L_DicomCreateDS, L_DicomInitDS, L_DicomGetInfoDS, L_DicomCopyDS |
Topics: |
|
|
|
|
Data Sets: Creating, Initializing, Loading, and Saving Data Sets |
|
Example
This example makes a copy of the DICOM data set pSrcDS. All DICOM elements are copied except the pixel data element. The resulting data set is saved as a file pszName.
L_BOOL EXT_CALLBACK pfnCopyDSExtCallBack(pDICOMELEMENT pElement, L_UINT16 nFlags, L_VOID *pUserData) { UNREFERENCED_PARAMETER(nFlags); UNREFERENCED_PARAMETER(pUserData); if (pElement->nTag == TAG_PIXEL_DATA) return FALSE; return TRUE; } L_INT DicomCopyDSExtExample(HDICOMDS hSrcDS, L_TCHAR * pszName) { L_INT nRet = DICOM_SUCCESS; HDICOMDS hDS = L_DicomCreateDS(NULL); if (hSrcDS && pszName) { nRet = L_DicomCopyDSExt(hDS, NULL, hSrcDS, NULL, pfnCopyDSExtCallBack, NULL); } L_DicomSaveDS(hDS, pszName, 0); L_DicomFreeDS(hDS); return nRet; }