LEADTOOLS Medical (Leadtools.Dicom assembly)
LEAD Technologies, Inc

Copy(DicomDataSet,DicomElement,DicomElement,DicomCopyCallback) Method

Example 







The Data Set to be copied (the source Data Set).
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.
A data element within the source Data Set. All children, grandchildren, etc., of this element will be added to the destination Data Set.
which will be called for each DicomElement in the DicomDataSet. This parameter cannot be null
Copies the data elements from one Data Set to another. .NET support WinRT support Silverlight support
Syntax
'Declaration
 
Public Overloads Sub Copy( _
   ByVal dataSet As DicomDataSet, _
   ByVal destination As DicomElement, _
   ByVal source As DicomElement, _
   ByVal callback As DicomCopyCallback _
) 
'Usage
 
Dim instance As DicomDataSet
Dim dataSet As DicomDataSet
Dim destination As DicomElement
Dim source As DicomElement
Dim callback As DicomCopyCallback
 
instance.Copy(dataSet, destination, source, callback)
ObjectiveC Syntax
 function Leadtools.Dicom.DicomDataSet.Copy(DicomDataSet,DicomElement,DicomElement,DicomCopyCallback)( 
   dataSet ,
   destination ,
   source ,
   callback 
)

Parameters

dataSet
The Data Set to be copied (the source Data Set).
destination
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.
source
A data element within the source Data Set. All children, grandchildren, etc., of this element will be added to the destination Data Set.
callback
which will be called for each DicomElement in the DicomDataSet. This parameter cannot be null
Remarks
If both source and destination 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 source is not null and destination is null, the children of source 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 source is null and destination is not null, the entire source Data Set will be added as children to destination. This can be seen in the diagram below.

If source and destination are both not null, then the children of source are added as the children of destination. This can be seen in the diagram below. The original children of destination 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 Copy(DicomDataSet,DicomElement,DicomElement). 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 Reset on the destination Data Set, before calling Copy(DicomDataSet,DicomElement,DicomElement).

This overload of Copy(DicomDataSet,DicomElement,DicomElement) will call callback to for each DicomElement in the DicomDataSet.
The purpose of callback is to determine if a particular
DicomElement is to be part of the copy. callback should return true to include the DicomElement in the copy. callback should return false to exclude the DicomElement in the copy.

Example
Copy CodeCopy Code  
'''
   Private Function DicomCopyCallback(ByVal element As DicomElement, ByVal flags As DicomCopyFlags) As Boolean
      If element.Tag = DicomTag.PixelData Then
         Return False
      End If
      Return True
   End Function

   Private Sub DicomDataSet_CopyExample(ByVal dsOriginal As DicomDataSet)
      Dim dsNew As DicomDataSet = New DicomDataSet()
      dsNew.Copy(dsOriginal, Nothing, Nothing, addressof DicomCopyCallback)

      Dim sFile As String = Path.Combine(LEAD_VARS.ImagesDir, "test.dcm")
      dsNew.Save(sFile, DicomDataSetSaveFlags.None)
      Dim sMsg As String = String.Format("File Saved: {0}", sFile)
      MessageBox.Show(sMsg)
   End Sub


Public NotInheritable Class LEAD_VARS
   Public Const ImagesDir As String = "C:\Users\Public\Documents\LEADTOOLS Images"
End Class
///

   private bool DicomCopyCallback(DicomElement element, DicomCopyFlags flags)
   {
      if (element.Tag == DicomTag.PixelData)
         return false;
      return true;
   }

   private void DicomDataSet_CopyExample(DicomDataSet dsOriginal)
   {
      DicomDataSet dsNew = new DicomDataSet();
      dsNew.Copy(dsOriginal, null, null, DicomCopyCallback);

      string sFile = Path.Combine(LEAD_VARS.ImagesDir, "test.dcm");
      dsNew.Save(sFile, DicomDataSetSaveFlags.None);
      string sMsg = string.Format("File Saved: {0}", sFile);
      MessageBox.Show(sMsg);
   }


static class LEAD_VARS
{
   public const string ImagesDir = @"C:\Users\Public\Documents\LEADTOOLS Images";
}
///

private bool DicomCopyCallback(DicomElement element, DicomCopyFlags flags)
{
   if (element.Tag == DicomTagConstants.PixelData)
      return false;
   return true;
}

private async Task DicomDataSet_CopyExample(DicomDataSet dsOriginal)
{
   DicomDataSet dsNew = new DicomDataSet();
   dsNew.Copy(dsOriginal, null, null, DicomCopyCallback);

   string dicomFileNameOutput = "test.dcm";
   StorageFile saveFile = await Tools.AppLocalFolder.CreateFileAsync(dicomFileNameOutput);
   await dsNew.SaveAsync(saveFile.Path, DicomDataSetSaveFlags.None);
   string sMsg = string.Format("File Saved: {0}", saveFile.Path);
   Debug.WriteLine(sMsg);
}
private bool DicomCopyCallback(DicomElement element, DicomCopyFlags flags)
{
   if (element.Tag == DicomTag.PixelData)
      return false;
   return true;
}
private void DicomDataSet_CopyExample(DicomDataSet dsOriginal, Stream outputStream)
{
   DicomDataSet dsNew = new DicomDataSet();
   dsNew.Copy(dsOriginal, null, null, DicomCopyCallback);
   dsNew.Save(outputStream, DicomDataSetSaveFlags.None);
}
Private Function DicomCopyCallback(ByVal element As DicomElement, ByVal flags As DicomCopyFlags) As Boolean
   If element.Tag = DicomTag.PixelData Then
      Return False
   End If
   Return True
End Function
Private Sub DicomDataSet_CopyExample(ByVal dsOriginal As DicomDataSet, ByVal outputStream As Stream)
   Dim dsNew As DicomDataSet = New DicomDataSet()
   dsNew.Copy(dsOriginal, Nothing, Nothing, AddressOf DicomCopyCallback)
   dsNew.Save(outputStream, DicomDataSetSaveFlags.None)
End Sub
Requirements

Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also

Reference

DicomDataSet Class
DicomDataSet Members
Overload List
Initialize(DicomClassType,DicomDataSetInitializeType) Method
InformationClass Property
InformationFlags Property

 

 


Products | Support | Contact Us | Copyright Notices

© 2006-2012 All Rights Reserved. LEAD Technologies, Inc.

Leadtools.Dicom requires a Medical toolkit server license and unlock key. For more information, refer to: Imaging Pro/Document/Medical Features